--Destin, Cascad Defender --Script by XGlitchy30 function c31231306.initial_effect(c) --position local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_POSITION) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetOperation(c31231306.posop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e2) local e3=e1:Clone() e3:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e3) --topdeck local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(31231306,0)) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetProperty(EFFECT_FLAG_DELAY) e4:SetCode(EVENT_REMOVE) e4:SetCountLimit(1,31231306) e4:SetCondition(c31231306.tdcon) e4:SetTarget(c31231306.tdtg) e4:SetOperation(c31231306.tdop) c:RegisterEffect(e4) --effect gain local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(31231306,1)) e5:SetCategory(CATEGORY_DRAW) e5:SetType(EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_TRIGGER_O) e5:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_DELAY) e5:SetCode(EVENT_SPSUMMON_SUCCESS) e5:SetCountLimit(1) e5:SetCondition(c31231306.drcon) e5:SetCost(c31231306.drcost) e5:SetTarget(c31231306.drtg) e5:SetOperation(c31231306.drop) c:RegisterEffect(e5) end --filters function c31231306.tdfilter(c) return aux.IsCodeListed(c,31231300) and c:IsType(TYPE_SPELL+TYPE_TRAP) end --position function c31231306.posop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFaceup() and not c:IsPosition(POS_FACEUP_DEFENSE) then Duel.ChangePosition(c,POS_FACEUP_DEFENSE) end end --topdeck function c31231306.tdcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_COST) and re:IsHasType(0x7e0) and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsAttribute(ATTRIBUTE_WATER) end function c31231306.tdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c31231306.tdfilter,tp,LOCATION_DECK,0,1,nil) end end function c31231306.tdop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(16693254,1)) local g=Duel.SelectMatchingCard(tp,c31231306.tdfilter,tp,LOCATION_DECK,0,1,1,nil) local tc=g:GetFirst() if tc then Duel.ShuffleDeck(tp) Duel.MoveSequence(tc,0) Duel.ConfirmDecktop(tp,1) end end --gain effect function c31231306.drcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ) and e:GetHandler():IsSetCard(0x3233) end function c31231306.drcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLPCost(tp,500) end Duel.PayLPCost(tp,500) end function c31231306.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(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c31231306.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) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetCountLimit(1) e1:SetValue(c31231306.valcon) e1:SetReset(RESET_EVENT+0x1fe0000) e:GetHandler():RegisterEffect(e1) end function c31231306.valcon(e,re,r,rp) return bit.band(r,REASON_BATTLE+REASON_EFFECT)~=0 end