--Arcarum XVIII - LA LUNA --Script by XGlitchy30 local cid,id=GetID() function cid.initial_effect(c) --spsummon self local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetCode(EVENT_DRAW) e1:SetCountLimit(1) e1:SetCondition(cid.spcon) e1:SetCost(cid.spcost) e1:SetTarget(cid.sptg) e1:SetOperation(cid.spop) c:RegisterEffect(e1) --draw local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_DRAW+CATEGORY_HANDES) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_PREDRAW) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetCondition(cid.drawcon) e2:SetTarget(cid.drawtg) e2:SetOperation(cid.drawop) c:RegisterEffect(e2) --protection local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,2)) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e3:SetCode(EVENT_BATTLE_START) e3:SetCondition(cid.proccon) e3:SetOperation(cid.procop) c:RegisterEffect(e3) end --filters --spsummon self function cid.spcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentPhase()==PHASE_DRAW and Duel.GetTurnPlayer()==tp and r==REASON_RULE end function cid.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end if Duel.GetCurrentPhase()==PHASE_DRAW and Duel.GetTurnPlayer()==tp then e:GetHandler():RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DRAW+RESET_SELF_TURN-RESET_TOFIELD,0,2,Duel.GetTurnCount()) else e:GetHandler():RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DRAW+RESET_SELF_TURN-RESET_TOFIELD,0,1,0) end end function cid.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function cid.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end --draw function cid.drawcon(e,tp,eg,ep,ev,re,r,rp) local tid=e:GetHandler():GetFlagEffectLabel(id) return tid and tid~=Duel.GetTurnCount() and Duel.GetTurnPlayer()==tp and Duel.GetDrawCount(tp)>0 end function cid.drawtg(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) Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1) end function cid.drawop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) if Duel.Draw(p,d,REASON_EFFECT)~=0 then Duel.ShuffleHand(tp) Duel.BreakEffect() Duel.DiscardHand(tp,nil,1,1,REASON_EFFECT+REASON_DISCARD) end end --protection function cid.proccon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local bc=c:GetBattleTarget() return bc and bc:IsControler(1-tp) and bc:IsSummonType(SUMMON_TYPE_SPECIAL) end function cid.procop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsFaceup() then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_UNCOPYABLE) e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE) e1:SetValue(1) e1:SetReset(RESET_PHASE+PHASE_DAMAGE) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) c:RegisterEffect(e2) end end