--Depths Devourer - Leviathan --Script by APurpleApple local s = c56132084 function s.initial_effect(c) --Special summon from GY local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetRange(LOCATION_GRAVE) e1:SetCode(EVENT_ATTACK_ANNOUNCE) e1:SetCountLimit(1,56132084) e1:SetCondition(s.condition1) e1:SetTarget(s.target1) e1:SetOperation(s.operation1) c:RegisterEffect(e1) --Banish top three local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_REMOVE) e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCondition(s.condition2) e2:SetTarget(s.target2) e2:SetOperation(s.operation2) c:RegisterEffect(e2) end function s.sumFilter(c,tp) return c:GetControler(tp) end function s.condition1(e,tp,eg,ep,ev,re,r,rp) local g = Duel.GetMatchingGroup(Card.IsFacedown,tp, LOCATION_REMOVED, 0, nil) return g:GetCount() >= e:GetHandler():GetLevel() and tp~=Duel.GetTurnPlayer() end function s.target1(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 s.operation1(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,SUMMON_VALUE_SELF,tp,tp,false,false,POS_FACEUP)>0 then local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_REMOVE) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EFFECT_SEND_REPLACE) e1:SetRange(LOCATION_MZONE) e1:SetTarget(s.leaveBanish) c:RegisterEffect(e1,true) end end function s.leaveBanish(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsLocation(LOCATION_MZONE) and not c:IsReason(REASON_REPLACE) end Duel.Remove(c,POS_FACEDOWN,r|REASON_REPLACE) end function s.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:GetLocation()==LOCATION_GRAVE and chkc~=e:GetHandler() end if chk==0 then return Duel.IsExistingTarget(aux.TRUE,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,aux.TRUE,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,nil) local c = g:GetFirst() g = Duel.GetMatchingGroup(s.getSimilar, tp,LOCATION_GRAVE + LOCATION_ONFIELD, LOCATION_GRAVE + LOCATION_ONFIELD,nil,c:GetCode()) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,g:GetCount(),0,0) end function s.condition2(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL+SUMMON_VALUE_SELF end function s.operation2(e,tp,eg,ep,ev,re,r,rp) local c=Duel.GetFirstTarget() if c:IsRelateToEffect(e) then local g = Duel.GetMatchingGroup(s.getSimilar, tp,LOCATION_GRAVE + LOCATION_ONFIELD, LOCATION_GRAVE + LOCATION_ONFIELD,nil,c:GetCode()) Duel.Remove(g,POS_FACEDOWN,REASON_EFFECT) end end function s.getSimilar(c,code) return c:IsCode(code) and c:IsAbleToRemove() end