--Agile Runefall Ninja local cid,id=GetID() function cid.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsSetCard,0x522),3,2) c:EnableReviveLimit() --Draw local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCountLimit(1,id) e1:SetCost(cid.spcost1) e1:SetCondition(cid.tdcon) e1:SetTarget(cid.tdtg) e1:SetOperation(cid.tdop) c:RegisterEffect(e1) --sset local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetDescription(aux.Stringid(id,1)) e4:SetType(EFFECT_TYPE_QUICK_O) e4:SetCode(EVENT_FREE_CHAIN) e4:SetRange(LOCATION_MZONE) e4:SetCountLimit(1,id+100) e4:SetHintTiming(0,TIMING_BATTLE_START+TIMING_END_PHASE) e4:SetTarget(cid.settg) e4:SetOperation(cid.setop) c:RegisterEffect(e4) end function cid.tdcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ) end function cid.spcost1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,2,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,2,2,REASON_COST) end function cid.tdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function cid.tdop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function cid.spfilter(c,e,tp) return c:IsSetCard(0x522) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cid.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_GRAVE) end function cid.setop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET) local tc=e:GetHandler() if tc and tc:IsRelateToEffect(e) then local typ=tc:GetOriginalType() if aux.PandSSetCon(tc,tp) then local e1=Effect.CreateEffect(tc) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_MONSTER_SSET) e1:SetValue(TYPE_TRAP) tc:RegisterEffect(e1,true) Duel.SSet(tp,tc) e1:Reset() tc:SetCardData(CARDDATA_TYPE,TYPE_TRAP) --reset trap status local e2=Effect.CreateEffect(tc) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_ADJUST) e2:SetRange(LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED+LOCATION_HAND+LOCATION_EXTRA+LOCATION_OVERLAY+LOCATION_MZONE) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_SET_AVAILABLE) e2:SetLabelObject(e4) e2:SetOperation(function(ef) local c=ef:GetHandler() if c:GetOriginalType()==TYPE_TRAP then c:AddMonsterAttribute(typ) c:SetCardData(CARDDATA_TYPE,typ) if c:IsSummonType(SUMMON_TYPE_XYZ) then c:CompleteProcedure() end ef:Reset() end end) tc:RegisterEffect(e2) local e3=e2:Clone() e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e3:SetRange(0) e3:SetCode(EVENT_LEAVE_FIELD) tc:RegisterEffect(e3) --negate attack local e4=Effect.CreateEffect(tc) e4:SetType(EFFECT_TYPE_ACTIVATE) e4:SetCode(EVENT_ATTACK_ANNOUNCE) e4:SetCondition(cid.condition) e4:SetCost(cid.cost) e4:SetOperation(cid.operation) tc:RegisterEffect(e4,true) end end if not tc:IsLocation(LOCATION_SZONE) then return end tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD,EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_SET_AVAILABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE,1) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,cid.spfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil,e,tp) if #g>0 then Duel.BreakEffect() Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end --Negate Attack function cid.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetAttacker():GetControler()~=tp and e:GetHandler():GetFlagEffect(id)>0 end function cid.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,Card.IsSetCard,1,nil,0x522) end local g=Duel.SelectReleaseGroup(tp,Card.IsSetCard,1,1,nil,0x522) Duel.Release(g,REASON_COST) end function cid.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetAttacker() if Duel.NegateAttack(tc) then Duel.Recover(tp,tc:GetAttack(),REASON_EFFECT) Duel.SkipPhase(1-tp,PHASE_BATTLE,RESET_PHASE+PHASE_BATTLE_STEP,1) end end