--Labyrinth Guardian local s,id=GetID() function s.initial_effect(c) aux.AddCodeList(c,25955164,62340868,98434877,25833572,id) c:EnableReviveLimit() --Special summon itself local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_HAND+LOCATION_GRAVE) e1:SetCountLimit(1,id) e1:SetCost(s.spcost) e1:SetTarget(s.sptg) e1:SetOperation(s.spop) c:RegisterEffect(e1) --Special Summon local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e2:SetCountLimit(1,{id,1}) e2:SetCondition(s.spcon) e2:SetTarget(s.sptg2) e2:SetOperation(s.spop2) c:RegisterEffect(e2) --To hand and negate local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_TOHAND+CATEGORY_DISABLE) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetCode(EVENT_FREE_CHAIN) e3:SetRange(LOCATION_MZONE) e3:SetCountLimit(1,{id,2}) e3:SetCondition(s.thcon) e3:SetTarget(s.thtg) e3:SetOperation(s.thop) c:RegisterEffect(e3) end function s.cfilter(c,ft) return (c:IsLocation(LOCATION_HAND) or c:IsFaceup()) and (c:IsCode(25955164,62340868,98434877,25833572) or (aux.IsCodeListed(c,25955164,62340868,98434877) and c:IsMonster())) and not c:IsCode(id) and c:IsAbleToGraveAsCost() and (ft>0 or c:GetSequence()<5) end function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) local loc=LOCATION_HAND+LOCATION_ONFIELD if ft==0 then loc=LOCATION_MZONE end if chk==0 then return ft>-3 and Duel.IsExistingMatchingCard(s.cfilter,tp,loc,0,3,nil,ft) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,s.cfilter,tp,loc,0,3,3,nil,ft) Duel.SendtoGrave(g,REASON_COST) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,true,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end Duel.SpecialSummon(c,0,tp,tp,true,false,POS_FACEUP) end function s.spcon(e,tp,eg,ep,ev,re,r,rp) if not re then return false end return aux.IsCodeListed(re:GetHandler(),25955164,62340868,98434877) end function s.filter(c,e,tp) return c:IsCode(25833572) and c:IsCanBeSpecialSummoned(e,0,tp,true,false,POS_FACEUP) end function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_HAND,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE+LOCATION_HAND) end function s.spop2(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.filter),tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_HAND,0,1,1,nil,e,tp) if #g>0 then Duel.SpecialSummon(g,0,tp,tp,true,false,POS_FACEUP) end end function s.thcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==1-tp end function s.thfilter(c) return (c:IsCode(25955164,62340868,98434877,25833572) or aux.IsCodeListed(c,25955164,62340868,98434877)) and (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.thfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(s.thfilter,tp,LOCATION_MZONE+LOCATION_GRAVE,0,1,nil) and Duel.IsExistingMatchingCard(Card.IsNegatable,tp,0,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_MZONE+LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_DISABLE,nil,1,0,0) end function s.thop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() local g=Duel.GetMatchingGroup(Card.IsNegatable,tp,0,LOCATION_ONFIELD,nil) if tc:IsRelateToEffect(e) and Duel.SendtoHand(tc,nil,REASON_EFFECT)>0 and #g>0 then local sc=g:Select(tp,1,1,nil):GetFirst() Duel.NegateRelatedChain(sc,RESET_TURN_SET) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) sc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetValue(RESET_TURN_SET) e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) sc:RegisterEffect(e2) if sc:IsType(TYPE_TRAPMONSTER) then local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e3:SetCode(EFFECT_DISABLE_TRAPMONSTER) e3:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) sc:RegisterEffect(e3) end end end