--created & coded by Lyris, art by xTheDragonRebornx of DeviantArt --襲雷竜-銀河 local s,id,o=GetID() function s.initial_effect(c) aux.EnablePendulumAttribute(c) local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_DESTROYED) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_PZONE) e2:SetCondition(function(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(s.cfilter,1,nil,tp) end) e2:SetTarget(s.tg) e2:SetOperation(s.op) c:RegisterEffect(e2) local e0=Effect.CreateEffect(c) e0:SetCategory(CATEGORY_DESTROY) e0:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e0:SetRange(LOCATION_MZONE) e0:SetCode(EVENT_ATTACK_ANNOUNCE) e0:SetCondition(s.descon) e0:SetTarget(s.destg) e0:SetOperation(s.desop) c:RegisterEffect(e0) end function s.descon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return Duel.GetTurnPlayer()~=tp and c:IsFaceup() and Duel.GetAttackTarget()==c end function s.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0) end function s.desop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() Duel.NegateAttack() if c:IsRelateToEffect(e) and Duel.Destroy(c,REASON_EFFECT)~=0 then local g=Duel.SelectMatchingCard(tp,Card.IsType,tp,0,LOCATION_ONFIELD,1,1,nil,TYPE_SPELL+TYPE_TRAP) Duel.HintSelection(g) if #g>0 then Duel.BreakEffect() Duel.Destroy(g,REASON_EFFECT) end end end function s.cfilter(c,tp) return c:GetOriginalType()&TYPE_MONSTER~=0 and (c:IsPreviousPosition(POS_FACEUP) or c:GetPreviousControler()==tp) and c:IsSetCard(0x7c4) end function s.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>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.op(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)>0 then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EFFECT_SEND_REPLACE) e1:SetTarget(s.rtg) e1:SetValue(aux.TargetBoolFunction(s.rfilter)) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e3:SetCode(EVENT_ADJUST) e3:SetOperation(function() for tc in aux.Next(Duel.GetMatchingGroup(s.reset,tp,0xff,0xff,nil)) do while s.reset(tc) do tc:ResetFlagEffect(id) end end end) e3:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e3,tp) end end function s.reset(c) return c:GetFlagEffect(id)>0 end function s.rfilter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x7c4) and (c:IsOnField() or c:GetFlagEffect(id)>0) end function s.rchk(c) return not c:IsReason(REASON_DESTROY) end function s.rtg(e,tp,eg,ep,ev,re,r,rp,chk) local g=eg:Filter(aux.AND(s.rfilter,s.rchk),nil) if chk==0 then return #g>0 end local dt,ct,mode={},0 if g:GetClassCount(Card.GetDestination)>1 then for tc in aux.Next(g) do local d=tc:GetDestination() if dt[d] then dt[d]=dt[d]+1 else dt[d]=1 end if dt[d]>ct then ct=dt[d] mode=d end end local gt={} for i=0,5 do gt[0x2<