--Abyss Guardian - Leviathan --Script by APurpleApple local s = c56132083 function s.initial_effect(c) --Special summon from GY local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_NEGATE) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetRange(LOCATION_GRAVE) e1:SetCode(EVENT_CHAINING) e1:SetCountLimit(1,56132083) 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_DESTROY) 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) if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end local tg=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) if not tg then return false end if not Duel.IsChainDisablable(ev) then return false end if tp==rp then return false end if not tg:IsExists(Card.IsControler,1,nil,tp) then return false end local g = Duel.GetMatchingGroup(Card.IsFacedown,tp, LOCATION_REMOVED, 0, nil) return g:GetCount() >= e:GetHandler():GetLevel() 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) Duel.SetOperationInfo(0,CATEGORY_NEGATE,nil,1,0,0) end function s.operation1(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() Duel.NegateEffect(ev) 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:IsOnField() and chkc~=e:GetHandler() end if chk==0 then return Duel.IsExistingTarget(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,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 tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end