Skip to content

Effect.SetCountLimit ​

Signature ​

lua
Effect.SetCountLimit(Effect e, int count, [int code]) -> void

Description ​

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:

lua
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.

Parameters ​

  • e Effect - Effect whose count limit is set.
  • count int - Maximum uses before the count is spent; 0 is normalized to 1 by the core.
  • code int optional - 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:

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.
CardIDScriptDetected Calls
Salamandra with Chain62091148Scripts/c62091148.lua2
Astrograph Sorcerer, the Starfrost Magician48171151Scripts/c48171151.lua3
Artmage Non-Finito74631897Scripts/c74631897.lua1
Pendulum Evolution55795155Scripts/c55795155.lua3
Levia-Dragoon - Daedalus78579058Scripts/c78579058.lua2
Lady's Dragonmaid48658295Scripts/c48658295.lua2
Azure Ocean Dragon Lord - Neo-Daedalus Rage41570943Scripts/c41570943.lua1
Eternal Favorite87532344Scripts/c87532344.lua2
Surprise Fusion35167375Scripts/c35167375.lua1
Astrograph Sorcerer76794549Scripts/c76794549.lua1
Spellbook of the Grand Circle11911336Scripts/c11911336.lua2
Accel Synchro Stardust Dragon30983281Scripts/c30983281.lua2
Melffy Playtime Surprise58036097Scripts/c58036097.lua2
Ashtraja Susanoo17020474Scripts/c17020474.lua2
Deftero Enneacraft - "alazoneIA"92171126Scripts/c92171126.lua2
Destiny HERO - Destro-Dogma25158975Scripts/c25158975.lua3
Yomagna the Fire Phantom17350692Scripts/c17350692.lua2
Fiendsmith's Sequence49867899Scripts/c49867899.lua2
D/D/D Alfred the Divine Sage King11852093Scripts/c11852093.lua2
El Shaddoll Apkallone50907446Scripts/c50907446.lua2
Mementotlan Fusion66518509Scripts/c66518509.lua2
Meteoroa Drytron24166324Scripts/c24166324.lua2
Favorite HERO Flame Wingman13243124Scripts/c13243124.lua2
Mixousia the Confounder80843006Scripts/c80843006.lua3
...and 7996 more

Script Examples ​

Salamandra with Chain (62091148) ​

Source: Scripts/c62091148.lua

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

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

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)