--created by LeonDuvall, coded by Lyris --Aerin, Magitate Divinitatum local s,id,o=GetID() function s.initial_effect(c) aux.AddDoubleSidedProc(c,SIDE_REVERSE,131792008) aux.AddReverseSideProc(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetRange(LOCATION_MZONE) e1:SetTargetRange(0,1) e1:SetValue(1) e1:SetCondition(s.discon) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_BE_BATTLE_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e2:SetCondition(s.discon) e2:SetOperation(s.disop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_DISABLE) e3:SetRange(LOCATION_MZONE) e3:SetTargetRange(0,LOCATION_MZONE) e3:SetTarget(s.distg) c:RegisterEffect(e3) local e4=e3:Clone() e4:SetCode(EFFECT_DISABLE_EFFECT) c:RegisterEffect(e4) local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_QUICK_O) e5:SetCode(EVENT_FREE_CHAIN) e5:SetRange(LOCATION_MZONE) e5:SetCountLimit(1) e5:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DRAW) e5:SetCost(s.spcost) e5:SetTarget(s.sptg) e5:SetOperation(s.spop) c:RegisterEffect(e5) end function s.filter(c) return c:IsFaceup() and c:IsLevel(5) and c:IsSetCard(0xd16) end function s.discon(e) return (s.filter(Duel.GetAttacker()) and Duel.GetAttackTarget()) or s.filter(Duel.GetAttackTarget()) end function s.disop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() c:GetBattleTarget():RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_BATTLE,0,1) Duel.AdjustInstantly(c) end function s.distg(e,c) return c:GetFlagEffect(id)>0 end function s.cfilter(c) return c:IsSetCard(0x1d16) and c:IsAbleToRemoveAsCost() end function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) Duel.Remove(Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_GRAVE,0,1,1,nil),POS_FACEUP,REASON_COST) end function s.sfilter(c,e,tp) return c:IsSetCard(0xd16) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and not c:IsCode(131792008) and c:IsCanTransform(SIDE_REVERSE) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.sfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,1,nil,e,tp) and Duel.IsPlayerCanDraw(tp,1) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE+LOCATION_HAND) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function s.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<1 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tc=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.sfilter),tp,LOCATION_GRAVE+LOCATION_HAND,0,1,1,nil,e,tp):GetFirst() if tc and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then Duel.Transform(tc,SIDE_REVERSE,e,tp) end Duel.SpecialSummonComplete() if tc:IsOnField() then Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end end