--Chaos Tempest function c249000909.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c249000909.target) e1:SetOperation(c249000909.activate) c:RegisterEffect(e1) --draw local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_DRAW) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetRange(LOCATION_GRAVE) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_PLAYER_TARGET) e2:SetCondition(c249000909.drcon) e2:SetCost(c249000909.drcost) e2:SetTarget(c249000909.drtg) e2:SetOperation(c249000909.drop) c:RegisterEffect(e2) end function c249000909.filter(c) return c:IsType(TYPE_SPELL+TYPE_TRAP) end function c249000909.cfilter(c) return c:IsFaceup() and (c:IsSetCard(0xcf) or c:IsSetCard(0x1048) or c:IsSetCard(0x1073)) end function c249000909.target(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then local ct=Duel.GetMatchingGroupCount(c249000909.cfilter,tp,LOCATION_MZONE,0,nil) e:SetLabel(ct) return Duel.IsExistingMatchingCard(c249000909.filter,tp,0,LOCATION_ONFIELD,ct,c) end local ct=e:GetLabel() local sg=Duel.GetMatchingGroup(c249000909.filter,tp,0,LOCATION_ONFIELD,c) Duel.SetOperationInfo(0,CATEGORY_DESTROY,sg,ct,0,0) end function c249000909.activate(e,tp,eg,ep,ev,re,r,rp) local ct=Duel.GetMatchingGroupCount(c249000909.cfilter,tp,LOCATION_MZONE,0,nil) local g=Duel.GetMatchingGroup(c249000909.filter,tp,0,LOCATION_ONFIELD,aux.ExceptThisCard(e)) if g:GetCount()>=ct then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local sg=g:Select(tp,ct,ct,nil) Duel.HintSelection(sg) Duel.Destroy(sg,REASON_EFFECT) end end function c249000909.cfilter2(c,tp) return c:IsFaceup() and c:GetSummonPlayer()==tp and (c:IsSetCard(0xcf) or c:IsSetCard(0x1048) or c:IsSetCard(0x1073)) and (c:IsLevelAbove(7) or c:GetRank()>6) end function c249000909.drcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c249000909.cfilter2,1,nil,tp) end function c249000909.drcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c249000909.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(2) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c249000909.drop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end