--created & coded by Lyris, art from Cardfight!! Vanguard's "Amber Dragon Eclipse" --機夜光襲雷竜-エクリプス local s,id,o=GetID() function s.initial_effect(c) c:EnableReviveLimit() aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkRace,RACE_DRAGON),2,99,s.lcheck) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FIELD) e2:SetCode(EVENT_DESTROYED) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,id) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET) e2:SetCategory(CATEGORY_DESTROY) 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 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 e5=e1:Clone() e5:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET) e5:SetValue(aux.imval1) c:RegisterEffect(e5) local e0=Effect.CreateEffect(c) 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) 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.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.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.disop(e,tp,eg,ep,ev,re,r,rp) if Duel.SelectEffectYesNo(tp,e:GetOwner()) then Duel.Hint(HINT_CARD,0,id) Duel.NegateAttack() 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.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.lcheck(g,lc) return g:IsExists(function(c,g) return c:IsLinkAttribute(ATTRIBUTE_LIGHT) and g:IsExists(Card.IsLinkAttribute,1,c,ATTRIBUTE_DARK) end,1,nil,g) end function s.tg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_ONFIELD) and chkc:IsControler(1-tp) and chkc:IsType(TYPE_SPELL+TYPE_TRAP) end local ct=e:GetHandler():GetLinkedGroupCount() if chk==0 then return ct>0 and Duel.IsExistingTarget(Card.IsType,tp,0,LOCATION_ONFIELD,1,nil,TYPE_SPELL+TYPE_TRAP) and Duel.IsExistingMatchingCard(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end local tg=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,nil) local dc=math.min(#tg,ct) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_OPPO) Duel.SetOperationInfo(0,CATEGORY_DESTROY,tg,#Duel.SelectTarget(tp,Card.IsType,tp,0,LOCATION_ONFIELD,1,dc,nil,TYPE_SPELL+TYPE_TRAP),0,0) end function s.op(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) local ct=g:FilterCount(Card.IsType,nil,TYPE_SPELL+TYPE_TRAP) local tg=Duel.GetFieldGroup(tp,LOCATION_MZONE,LOCATION_MZONE) if ct>0 and ct>=#tg then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local rg=tg:Select(tp,ct,ct,g) Duel.HintSelection(rg) Duel.Destroy(rg,REASON_EFFECT) end end