--Emblem of Fiend Carnival (scripter: Elma✓) function c12593465.initial_effect(c) --Activate local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_ACTIVATE) e0:SetCountLimit(1,12593465) e0:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e0) --to hand local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(12593465,1)) e1:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e1:SetRange(LOCATION_SZONE) e1:SetCondition(c12593465.thcon) e1:SetTarget(c12593465.thtg) e1:SetOperation(c12593465.thop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e2) --indes local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e3:SetRange(LOCATION_SZONE) e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE) e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x2F1)) e3:SetValue(1) c:RegisterEffect(e3) end function c12593465.cfilter(c,tp) return c:IsFaceup() and c:IsSetCard(0x2EF) and c:GetSummonPlayer()==tp end function c12593465.tgfilter(c,tp,g) return g:IsContains(c) and Duel.IsExistingMatchingCard(c12593465.thfilter,tp,LOCATION_DECK,0,1,nil,c:GetCode()) end function c12593465.thfilter(c,code) return c:IsSetCard(0x2EF) and c:IsType(TYPE_MONSTER) and not c:IsCode(code) and c:IsAbleToHand() end function c12593465.thcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp and (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2) and eg:IsExists(c12593465.cfilter,1,nil,tp) end function c12593465.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local g=eg:Filter(c12593465.cfilter,nil,tp) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c12593465.tgfilter(chkc,tp,g) end if chk==0 then return Duel.IsExistingTarget(c12593465.tgfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,tp,g) end if g:GetCount()==1 then Duel.SetTargetCard(g) else Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c12593465.tgfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil,tp,g) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c12593465.thop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and tc:IsFaceup() then local code=tc:GetCode() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c12593465.thfilter,tp,LOCATION_DECK,0,1,1,nil,code) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end end function c12593465.spfilter(c,e,tp) return c:IsSetCard(0x2EF) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end