--Etherveil Kingdom of Decay --Scripted by Boos local function ID() local str=string.match(debug.getinfo(2,'S')['source'],"c%d+%.lua") str=string.sub(str,1,string.len(str)-4) local cod=_G[str] local id=tonumber(string.sub(str,2)) return id,cod end local id,cod=ID() function cod.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e1:SetCondition(cod.actcon) e1:SetCost(cod.thcost) e1:SetTarget(cod.thtg) e1:SetOperation(cod.thop) c:RegisterEffect(e1) --summon count limit local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetRange(LOCATION_FZONE) e2:SetCode(EFFECT_CANNOT_SUMMON) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetTargetRange(1,1) e2:SetCondition(cod.limitcon) e2:SetTarget(cod.limittg) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EFFECT_CANNOT_FLIP_SUMMON) c:RegisterEffect(e3) local e4=e2:Clone() e4:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) c:RegisterEffect(e4) --counter local et=Effect.CreateEffect(c) et:SetType(EFFECT_TYPE_FIELD) et:SetCode(EFFECT_LEFT_SPSUMMON_COUNT) et:SetRange(LOCATION_FZONE) et:SetProperty(EFFECT_FLAG_PLAYER_TARGET) et:SetTargetRange(1,1) et:SetValue(cod.countval) c:RegisterEffect(et) --Cannot activate S/T local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_FIELD) e5:SetRange(LOCATION_FZONE) e5:SetCode(EFFECT_CANNOT_ACTIVATE) e5:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e5:SetTargetRange(1,1) e5:SetCondition(cod.limitcon1) e5:SetValue(cod.stlimit) c:RegisterEffect(e5) --Cannot activate monsters local e6=Effect.CreateEffect(c) e6:SetType(EFFECT_TYPE_FIELD) e6:SetRange(LOCATION_FZONE) e6:SetCode(EFFECT_CANNOT_ACTIVATE) e6:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e6:SetTargetRange(1,1) e6:SetCondition(cod.limitcon2) e6:SetValue(cod.monlimit) c:RegisterEffect(e6) --splimit local e7=Effect.CreateEffect(c) e7:SetType(EFFECT_TYPE_FIELD) e7:SetCode(EFFECT_CANNOT_SUMMON) e7:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e7:SetRange(LOCATION_FZONE) e7:SetTargetRange(1,0) e7:SetTarget(cod.splimit) c:RegisterEffect(e7) local e8=e7:Clone() e8:SetCode(EFFECT_CANNOT_FLIP_SUMMON) c:RegisterEffect(e8) local e9=e7:Clone() e9:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) c:RegisterEffect(e9) end function cod.cfilter(c) return c:IsFacedown() or (c:IsType(TYPE_MONSTER) and not c:IsSetCard(0x312)) end function cod.actcon(e,tp,eg,ep,ev,re,r,rp) return not Duel.IsExistingMatchingCard(cod.cfilter,tp,LOCATION_MZONE,0,1,nil) end function cod.thcost(e,tp,eg,ep,ev,re,r,rp,chk) local g=Duel.GetDecktopGroup(tp,5) if chk==0 then return g:FilterCount(Card.IsAbleToRemoveAsCost,nil,POS_FACEDOWN)==5 end Duel.DisableShuffleCheck() Duel.Remove(g,POS_FACEDOWN,REASON_COST) end function cod.thfilter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x312) and c:IsAbleToHand() end function cod.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cod.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cod.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cod.thfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function cod.limitcon(e) return Duel.IsExistingMatchingCard(Card.IsPosition,0,LOCATION_REMOVED,LOCATION_REMOVED,10,nil,POS_FACEDOWN) end function cod.limittg(e,c,tp) local t1,t2,t3=Duel.GetActivityCount(tp,ACTIVITY_SUMMON,ACTIVITY_FLIPSUMMON,ACTIVITY_SPSUMMON) return t1+t2+t3>=3 end function cod.countval(e,re,tp) local t1,t2,t3=Duel.GetActivityCount(tp,ACTIVITY_SUMMON,ACTIVITY_FLIPSUMMON,ACTIVITY_SPSUMMON) if t1+t2+t3>=3 then return 0 else return 3-t1-t2-t3 end end function cod.limitcon1(e) return Duel.IsExistingMatchingCard(Card.IsPosition,0,LOCATION_REMOVED,LOCATION_REMOVED,20,nil,POS_FACEDOWN) end function cod.stlimit(e,re,rp) local rc=re:GetHandler() return re:IsHasType(EFFECT_TYPE_ACTIVATE) and not rc:IsSetCard(0x312) end function cod.limitcon2(e,c) return Duel.IsExistingMatchingCard(Card.IsPosition,0,LOCATION_REMOVED,LOCATION_REMOVED,30,nil,POS_FACEDOWN) end function cod.monlimit(e,re,rp) local rc=re:GetHandler() return re:IsActiveType(TYPE_MONSTER) and not rc:IsSetCard(0x312) end function cod.splimit(e,c,tp,sumtp,sumpos) return not c:IsSetCard(0x312) end