--Neo-Tempester's Storm function c249001095.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,2490010951+EFFECT_COUNT_CODE_OATH) e1:SetOperation(c249001095.activate) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_GRAVE) e2:SetCode(EVENT_DAMAGE) e2:SetCondition(c249001095.sumcon) e2:SetCost(c249001095.sumcost) e2:SetTarget(c249001095.sumtg) e2:SetOperation(c249001095.sumop) c:RegisterEffect(e2) --special summon (GY) local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(36668118,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_FZONE) e3:SetCountLimit(1,2490010952) e3:SetCondition(c249001095.spcon) e3:SetTarget(c249001095.sptg2) e3:SetOperation(c249001095.spop2) c:RegisterEffect(e3) end function c249001095.addfilter(c) return c:IsSetCard(0x228) and c:IsAbleToHand() end function c249001095.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(c249001095.addfilter,tp,LOCATION_DECK,0,nil) if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(57103969,0)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:Select(tp,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end function c249001095.filter(c) return not c:IsStatus(STATUS_LEAVE_CONFIRMED) end function c249001095.sumcon(e,tp,eg,ep,ev,re,r,rp) return ep==tp and not Duel.IsExistingMatchingCard(c249001095.filter,tp,LOCATION_MZONE,0,1,nil) end function c249001095.costfilter(c) return c:IsSetCard(0x228) and c:IsDiscardable() end function c249001095.sumcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c249001095.costfilter,tp,LOCATION_HAND,0,1,nil) and e:GetHandler():IsAbleToDeckAsCost() end Duel.DiscardHand(tp,c249001095.costfilter,1,1,REASON_COST+REASON_DISCARD) Duel.SendtoDeck(e:GetHandler(),nil,0,REASON_COST) end function c249001095.sumfilter(c,e,tp) return c:IsType(TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0 and Duel.IsExistingMatchingCard(Card.IsRace,tp,LOCATION_GRAVE,0,1,nil,c:GetRace()) end function c249001095.sumtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c249001095.sumfilter,tp,LOCATION_EXTRA,0,3,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c249001095.sumop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c249001095.thfilter,tp,LOCATION_EXTRA,0,nil,e,tp) if g:GetCount()>=3 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=g:Select(tp,3,3,nil) Duel.ConfirmCards(1-tp,sg) Duel.ShuffleDeck(tp) local tg=sg:RandomSelect(1-tp,1) if tg:GetCount()>0 and Duel.SpecialSummon(tg,0,tp,tp,false,false,POS_FACEUP)~=0 then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetOwnerPlayer(tp) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetRange(LOCATION_MZONE) e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetCondition(c249001095.tdcon) e1:SetOperation(c249001095.tdop) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,2) e1:SetCountLimit(1) tg:GetFirst():RegisterEffect(e1) end end end function c249001095.tdcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp end function c249001095.tdop(e,tp,eg,ep,ev,re,r,rp) Duel.SendtoDeck(e:GetHandler(),nil,2,REASON_EFFECT) end function c249001095.spfilter(c,e,tp) return c:IsSetCard(0x228) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE) end function c249001095.spcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0) end function c249001095.sptg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c249001095.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE) end function c249001095.spop2(e,tp,eg,ep,ev,re,r,rp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) local ct=Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)-Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0) local g=Duel.GetMatchingGroup(c249001095.spfilter,tp,LOCATION_GRAVE,0,nil,e,tp) if ft<1 or ct<1 or g:GetCount()==0 then return end if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=g:SelectSubGroup(tp,aux.dncheck,false,1,math.min(ft,ct)) Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP_DEFENSE) end