--created by Seth, coded by Lyris --Shadow NOVA Dragon local s,id,o=GetID() function s.initial_effect(c) c:EnableReviveLimit() aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsSetCard,0xe1f),3,3) local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_FIELD) e5:SetCode(EFFECT_CANNOT_DISEFFECT) e5:SetRange(LOCATION_MZONE) e5:SetValue(s.efilter) c:RegisterEffect(e5) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,id) e1:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND) e1:SetTarget(s.target) e1:SetOperation(s.operation) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_DESTROYED) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,id+1000) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetCondition(function(e,tp,eg) return eg:IsExists(s.cfilter,1,nil,tp,c:GetLinkedZone()) end) e2:SetCost(s.cost) e2:SetTarget(s.tg) e2:SetOperation(s.op) c:RegisterEffect(e2) end function s.efilter(e,ct) local tc=Duel.GetChainInfo(ct,CHAININFO_TRIGGERING_EFFECT):GetHandler() if not (tc:IsSetCard(0xe1f) and e:GetHandler():GetLinkedGroup():IsContains(tc) and tc:GetFlagEffect(id)==0) then return false end local ne=Duel.GetChainInfo(ct+1,CHAININFO_TRIGGERING_EFFECT) if ne and ne:IsActiveType(TYPE_SPELL) then return false end local et={tc:IsHasEffect(EFFECT_DISABLE),tc:IsHasEffect(EFFECT_DISABLE_EFFECT)} for _,ef in ipairs(et) do if ef:IsActiveType(TYPE_SPELL) then return false end end return true end function s.filter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0xe1f) and c:IsAbleToHand() and not c:IsCode(id) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.operation(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil) Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end function s.cfilter(c,tp,zone) local seq=c:GetPreviousSequence() if c:IsPreviousControler(1-tp) then seq=seq+16 end return c:GetReasonPlayer()~=tp and c:IsPreviousLocation(LOCATION_MZONE) and c:GetReason()&0x41==0x41 and bit.extract(zone,seq)>0 end function s.dfilter(c) return c:IsSetCard(0xe1f) and c:IsType(TYPE_MONSTER) and c:IsAbleToGraveAsCost() end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.dfilter,tp,LOCATION_HAND,0,1,nil) end Duel.DiscardHand(tp,s.dfilter,1,1,REASON_COST) end function s.spfilter(c,e,tp,zone) return s.cfilter(c,tp,zone) and c:IsCanBeSpecialSummoned(e,0,tp,true,false) end function s.tg(e,tp,eg,ep,ev,re,r,rp,chk) local zone=e:GetHandler():GetLinkedZone() if chk==0 then local ct=eg:FilterCount(s.spfilter,nil,e,tp,zone) return ct>0 and (ct==1 or not Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT)) and Duel.GetLocationCount(tp,LOCATION_MZONE,tp,LOCATION_REASON_TOFIELD,zone)>=ct end Duel.SetTargetCard(eg) local g=eg:Filter(s.spfilter,nil,e,tp,zone) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,#g,0,0) end function s.sfilter(c,e,tp,zone) return s.spfilter(c,e,tp,zone) and c:IsRelateToEffect(e) end function s.op(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local zone=c:GetLinkedZone() local ft=Duel.GetLocationCount(tp,LOCATION_MZONE,tp,LOCATION_REASON_TOFIELD,zone) if ft<=0 then return end if Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT) then ft=1 end local sg=eg:Filter(s.sfilter,nil,e,tp,zone) if ft<#sg then return end local ct=Duel.GetTurnPlayer()==tp and Duel.GetCurrentPhase()==PHASE_STANDBY and 2 or 1 for tc in aux.Next(sg) do if Duel.SpecialSummonStep(tc,0,tp,tp,true,false,POS_FACEUP) then tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD,0,1) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,ct) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,ct) tc:RegisterEffect(e2) end end Duel.SpecialSummonComplete() end