--created & coded by Lyris, art by Takayama Toshiaki --襲雷属性-PSYph local s,id,o=GetID() function s.initial_effect(c) aux.EnablePendulumAttribute(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_DESTROYED) e1:SetRange(LOCATION_PZONE) e1:SetCountLimit(1,id) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetCondition(function(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(s.cfilter,1,nil,tp) end) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) e1:SetTarget(s.pftg) e1:SetOperation(s.pfop) c:RegisterEffect(e1) 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) local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_BATTLED) e4:SetRange(LOCATION_HAND) e4:SetCategory(CATEGORY_DESTROY) e4:SetCondition(function(e,tp) return Duel.GetTurnPlayer()~=tp end) e4:SetTarget(s.tg) e4:SetOperation(s.op) c:RegisterEffect(e4) 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,nil,tp,0,LOCATION_MZONE,1,1,nil) 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.mffilter0(c) return c:IsCanBeFusionMaterial() and c:IsFaceup() and c:IsDestructable() end function s.pffilter1(c) return c:IsOnField() and c:IsDestructable() end function s.pffilter2(c,e,tp,m,f,gc,chkf) return c:IsType(TYPE_FUSION) and c:IsSetCard(0x7c4) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,gc,chkf) end function s.pftg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then if not c:IsDestructable() then return false end local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(s.pffilter1,nil) mg1:Merge(Duel.GetMatchingGroup(s.mffilter0,tp,LOCATION_EXTRA,0,nil)+c) local res=Duel.IsExistingMatchingCard(s.pffilter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,c,chkf) if not res then local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() local mg2=fgroup(ce,e,tp)+c local mf=ce:GetValue() res=Duel.IsExistingMatchingCard(s.pffilter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,c,chkf) end end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) Duel.SetOperationInfo(0,CATEGORY_DESTROY,c,2,tp,LOCATION_ONFIELD) end function s.pfop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) or not c:IsDestructable() then return end local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(s.pffilter1,nil,e) mg1:Merge(Duel.GetMatchingGroup(s.mffilter0,tp,LOCATION_EXTRA,0,nil)+c) local sg1=Duel.GetMatchingGroup(s.pffilter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,c,chkf) local mg2=nil local sg2=nil local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() mg2=fgroup(ce,e,tp)+c local mf=ce:GetValue() sg2=Duel.GetMatchingGroup(s.pffilter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,c,chkf) end if #sg1>0 or (sg2~=nil and #sg2>0) then local sg=sg1:Clone() if sg2 then sg:Merge(sg2) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:Select(tp,1,1,nil) local tc=tg:GetFirst() if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,c,chkf) tc:SetMaterial(mat1) if Duel.Destroy(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)<#mat1 then return end Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP) else local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,c,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() end end function s.dfilter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x7c4) and c:IsDestructable() and not c:IsCode(id) end function s.tg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() local dg=Duel.GetMatchingGroup(s.dfilter,tp,LOCATION_HAND,0,nil) if chk==0 then return c:IsDestructable() and #dg>0 end local g=Duel.GetMatchingGroup(Card.IsAttackPos,tp,LOCATION_MZONE,LOCATION_MZONE,nil) Duel.GetOperationInfo(0,CATEGORY_DESTROY,g,#g+2,tp,LOCATION_HAND) end function s.op(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local g=Duel.GetMatchingGroup(s.dfilter,tp,LOCATION_HAND,0,nil) if not c:IsDestructable() or #g==0 then return end local dg=Duel.GetMatchingGroup(Card.IsAttackPos,tp,LOCATION_MZONE,LOCATION_MZONE,nil)+g:Select(tp,1,1,c)+c Duel.Destroy(dg,REASON_EFFECT) end