Unit Limit
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
-
- Posts: 15
- Joined: June 7th, 2007, 11:44 am
Unit Limit
Hi, i need some help, i want to know if there is any way to set a "Unit limit" to any "side".
i search in the forum, but i didnt found anything about it.
i search in the forum, but i didnt found anything about it.
I've dones something like this but not exactly.
That one is to limit one the numvber of one type of unit, according to an hysteresys :
- the macro uses VAR as the variable name to store the number of creatures
- at the begining you can recruit that unit type
- when your reach HIGH recruited creatures, you can no longer recruit them
- if you cannot recruit you have to wait until you have less than LOW creatures
- note that advancing the unit have an influence there
one example :
This allows side 1 to recruit 16 bats.
When it had 16 bats, you cannot recruit bats until you have 4 bats left.
That one is to limit one the numvber of one type of unit, according to an hysteresys :
- the macro uses VAR as the variable name to store the number of creatures
- at the begining you can recruit that unit type
- when your reach HIGH recruited creatures, you can no longer recruit them
- if you cannot recruit you have to wait until you have less than LOW creatures
- note that advancing the unit have an influence there
Code: Select all
#define HYSTERESYS_RECRUIT SIDE LOW HIGH CREATURE VAR
[event]
name=prestart
[store_unit]
[filter]
side={SIDE}
type={CREATURE}
[/filter]
kill=no
variable=hysteresis_creatures
[/store_unit]
[set_variable]
name={VAR}
to_variable=hysteresis_creatures.length
[/set_variable]
[clear_variable]
name=hysteresis_creatures
[/clear_variable]
[/event]
[event]
name=recruit
first_time_only=no
[filter]
side={SIDE}
type={CREATURE}
[/filter]
[set_variable]
name={VAR}
add=1
[/set_variable]
[if]
[variable]
name={VAR}
greater_than={HIGH}
[/variable]
[then]
[disallow_recruit]
side={SIDE}
type={CREATURE}
[/disallow_recruit]
[/then]
[/if]
[/event]
[event]
name=die
first_time_only=no
[filter]
side={SIDE}
type={CREATURE}
[/filter]
[set_variable]
name={VAR}
add=-1
[/set_variable]
[if]
[variable]
name={VAR}
less_than={LOW}
[/variable]
[then]
[allow_recruit]
side={SIDE}
type={CREATURE}
[/allow_recruit]
[/then]
[/if]
[/event]
[event]
name=advance
first_time_only=no
[filter]
side={SIDE}
type={CREATURE}
[/filter]
[set_variable]
name={VAR}
add=-1
[/set_variable]
[if]
[variable]
name={VAR}
less_than={LOW}
[/variable]
[then]
[allow_recruit]
side={SIDE}
type={CREATURE}
[/allow_recruit]
[/then]
[/if]
[/event]
#enddef
Code: Select all
{HYSTERESYS_RECRUIT 1 5 15 (Vampire Bat) nb_bat}
When it had 16 bats, you cannot recruit bats until you have 4 bats left.
"Ooh, man, my mage had a 30% chance to miss, but he still managed to hit! Awesome!" -- xtifr