Effect.SetCountLimit
Signature
Effect.SetCountLimit(Effect e, int count, [int code]) -> voidDescription
Sets how many times e can be used before its count limit is spent. If count is 0, the core treats it as 1. Effects that share a nonzero code share the same usage count for the checked player. EFFECT_COUNT_CODE_OATH uses oath-style rollback on negated activations and failed procedure attempts; EFFECT_COUNT_CODE_DUEL uses the duel-long count map; EFFECT_COUNT_CODE_SINGLE shares usage by handler instance; EFFECT_COUNT_CODE_CHAIN uses the chain count map. Use flag effects for custom reminders or activity markers; use SetCountLimit for engine-managed use counts.
How To Use It
Use SetCountLimit for once-per-turn and shared-count restrictions.
A normal hard once per turn usually uses the card id as the shared code:
e1:SetCountLimit(1,id)Effects with the same nonzero code share the same count. Special flags such as EFFECT_COUNT_CODE_OATH, EFFECT_COUNT_CODE_DUEL, EFFECT_COUNT_CODE_SINGLE, and EFFECT_COUNT_CODE_CHAIN change how that count is scoped. If count is 0, MDPro4 stores it as 1.
Related Functions
Parameters
eEffect- Effect whose count limit is set.countint- Maximum uses before the count is spent; 0 is normalized to 1 by the core.codeintoptional - Shared count-limit code. Effects with the same nonzero code share usage for the checked player; combine a card id with EFFECT_COUNT_CODE_OATH, EFFECT_COUNT_CODE_DUEL, or EFFECT_COUNT_CODE_SINGLE when that special behavior is needed. Passing exactly EFFECT_COUNT_CODE_CHAIN stores it together with EFFECT_COUNT_CODE_SINGLE in this core.
Source
D:\Programs\GitHub\ygopro-core\libeffect.cpp:617
Guided Examples
Learn how to use this function in context:
- Activation Legality
- Common Script Errors And Debugging
- Count Limits And Once Per Turn
- Creation, Building, and Registration of an Effect Object
- Normal And Continuous Traps
Used By
Generated from the local Scripts/ folder and cards.cdb.
- Detected in 8020 indexed script(s).
- Search this function in the Script Explorer with
Effect.SetCountLimit.
Script Examples
Salamandra with Chain (62091148)
Source: Scripts/c62091148.lua
e2:SetRange(LOCATION_GRAVE)
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER)
e2:SetCountLimit(1,id)
e2:SetCost(aux.bfgcost)
e2:SetTarget(s.sptg)Astrograph Sorcerer, the Starfrost Magician (48171151)
Source: Scripts/c48171151.lua
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_PZONE)
e1:SetCountLimit(1,id)
e1:SetTarget(s.ptg)
e1:SetOperation(s.pop)Artmage Non-Finito (74631897)
Source: Scripts/c74631897.lua
e5:SetRange(LOCATION_MZONE)
e5:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e5:SetCountLimit(1)
e5:SetCondition(s.fspcon)
e5:SetTarget(s.fsptg)