--created & coded by Lyris --機夜光襲雷竜-ビッグバン・エオン local s,id,o=GetID() function s.initial_effect(c) c:EnableReviveLimit() aux.AddFusionProcFunRep(c,s.ffilter,2,true) local e0=Effect.CreateEffect(c) e0:SetDescription(1118) e0:SetCategory(CATEGORY_DESTROY+CATEGORY_SPECIAL_SUMMON) e0:SetType(EFFECT_TYPE_QUICK_O) e0:SetRange(LOCATION_MZONE) e0:SetCode(EVENT_FREE_CHAIN) e0:SetCountLimit(1) e0:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_BATTLE_START) e0:SetTarget(s.destg) e0:SetOperation(s.desop) c:RegisterEffect(e0) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetCode(EFFECT_IMMUNE_EFFECT) e1:SetRange(LOCATION_MZONE) e1:SetCondition(s.tgcon) e1:SetValue(s.etarget) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET) e2:SetValue(aux.imval1) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetDescription(1131) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetCode(EVENT_CHAINING) e3:SetRange(LOCATION_MZONE) e3:SetCountLimit(1,id) e3:SetCategory(CATEGORY_NEGATE+CATEGORY_TODECK) e3:SetProperty(EFFECT_FLAG_DAMAGE_CAL+EFFECT_FLAG_DAMAGE_STEP) e3:SetCondition(s.discon) e3:SetTarget(s.distg) e3:SetOperation(s.negop) c:RegisterEffect(e3) end function s.ffilter(c,fc,sub,mg,sg) return c:IsSetCard(0x7c4) and (not sg or sg:FilterCount(aux.TRUE,c)==0 or sg:IsExists(s.fcheck,1,c,c:GetAttack())) end function s.fcheck(c,atk) local dif=math.abs(c:GetAttack()-atk) return dif>0 and dif<=400 end function s.desfilter(c,e,tp) return c:IsLevelBelow(5) and c:IsSetCard(0x7c4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.destg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetMZoneCount(tp,c)>0 and Duel.GetTurnPlayer()~=tp and aux.bpcon() and Duel.IsExistingMatchingCard(s.desfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_GRAVE) end function s.desop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.Destroy(c,REASON_EFFECT)~=0 then if Duel.GetAttacker() then Duel.NegateAttack() else local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_ATTACK_ANNOUNCE) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetCountLimit(1) e1:SetOperation(function() Duel.Hint(HINT_CARD,0,id) Duel.NegateAttack() end) Duel.RegisterEffect(e1,tp) end if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) Duel.SpecialSummon(Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.desfilter),tp,LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil,e,tp),0,tp,tp,false,false,POS_FACEUP) end end function s.tgfilter(c) return c:IsFaceup() and c:IsSetCard(0x7c4) and c:IsLevelBelow(5) end function s.tgcon(e) return Duel.IsExistingMatchingCard(s.tgfilter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil) end function s.etarget(e,re) local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS) return g and g:IsContains(e:GetHandler()) end function s.discon(e,tp,eg,ep,ev,re,r,rp) return ep==1-tp and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev) end function s.filter(c) return c:IsSetCard(0x7c4) and c:IsType(TYPE_PENDULUM) and c:IsAbleToDeck() end function s.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) local ct=1 if re:GetHandler():IsAbleToDeck() and re:GetHandler():IsRelateToEffect(re) then ct=ct+1 end Duel.SetOperationInfo(0,CATEGORY_TODECK,eg,ct,tp,LOCATION_GRAVE) end function s.negop(e,tp,eg,ep,ev,re,r,rp) local rc=re:GetHandler() local g=Duel.GetMatchingGroup(s.filter,tp,LOCATION_GRAVE,0,nil) if #g>0 and Duel.NegateActivation(ev) and rc:IsRelateToEffect(re) and (re:IsHasType(EFFECT_TYPE_ACTIVATE) or rc:IsAbleToDeck()) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local dg=g:Select(tp,1,1,nil) rc:CancelToGrave() Duel.SendtoDeck(eg+dg,nil,2,REASON_EFFECT) end end