--Magicalia's Defender local s,id=GetID() function s.initial_effect(c) --During the Main Phase, if your opponent controls more monsters than you do (Quick Effect): You can Special Summon this card from your hand. local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_HAND) e1:SetHintTiming(0,TIMING_MAIN_END|TIMINGS_CHECK_MONSTER|TIMING_SUMMON) e1:SetCountLimit(1,{id,0}) e1:SetCondition(s.spcon) e1:SetTarget(s.sptg) e1:SetOperation(s.spop) c:RegisterEffect(e1) --When your opponent activates a card or effect in response to your other "Magicalia" card or effect activation (Quick Effect): --You can Tribute this card from your hand or face-up field; negate that effect, then, if you Tributed this card from the field, you can destroy that card. local e2=Effect.CreateEffect(c) e2:SetCountLimit(1,{id,1}) e2:SetDescription(aux.Stringid(id,1)) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_CHAINING) e2:SetRange(LOCATION_MZONE+LOCATION_HAND) e2:SetCost(s.negatecost) e2:SetCondition(s.negatecon) e2:SetTarget(s.negatetg) e2:SetOperation(s.negateop) c:RegisterEffect(e2) end function s.spcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return Duel.IsMainPhase() and Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.GetFieldGroupCount(c:GetControler(),LOCATION_MZONE,0,nil)0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end function s.negatecon(e,tp,eg,ep,ev,re,r,rp) local ct=Duel.GetCurrentChain() if ct<2 then return end local te,p=Duel.GetChainInfo(ct-1,CHAININFO_TRIGGERING_EFFECT,CHAININFO_TRIGGERING_PLAYER) return te and te:GetHandler():IsSetCard(0x722) and p==tp and rp==1-tp and e:GetHandler():IsReleasable() end function s.negatecost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsReleasable() end if e:GetHandler():IsOnField() then e:SetLabel(1) end Duel.Release(e:GetHandler(),REASON_COST) end function s.negatetg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_DISABLE,eg,1,0,0) end function s.negateop(e,tp,eg,ep,ev,re,r,rp) Duel.NegateEffect(ev) if e:GetLabel()==1 and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then Duel.BreakEffect() Duel.Destroy(eg,REASON_EFFECT) end end