Unit Limit

The place to post your WML questions and answers.

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.
Post Reply
Finisterrex
Posts: 15
Joined: June 7th, 2007, 11:44 am

Unit Limit

Post by Finisterrex »

Hi, i need some help, i want to know if there is any way to set a "Unit limit" to any "side".

:lol:

i search in the forum, but i didnt found anything about it.
Troy
Posts: 152
Joined: May 9th, 2007, 12:55 am
Location: some where,but not sure where
Contact:

Post by Troy »

is it for a campiagn? if so, I think I can help you :)
well, all for the better good than for the bad good.

new forum
Finisterrex
Posts: 15
Joined: June 7th, 2007, 11:44 am

Post by Finisterrex »

Yes, Multiplayer Campaing for 1.2.4 v.
User avatar
Viliam
Translator
Posts: 1341
Joined: January 30th, 2004, 11:07 am
Location: Bratislava, Slovakia
Contact:

Post by Viliam »

Just an idea...

* after recruting a unit; if there are enough units; delete recruitment list for player
* after unit dies; restore recruitment list for player

not sure how the restoring would work, if players can have different factions. is it possible to save a recruitment list into variable?
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

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

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
one example :

Code: Select all

{HYSTERESYS_RECRUIT 1 5 15 (Vampire Bat) nb_bat}
This allows side 1 to recruit 16 bats.
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
Finisterrex
Posts: 15
Joined: June 7th, 2007, 11:44 am

Post by Finisterrex »

Thanks, that will be enough!
CIB
Code Contributor
Posts: 625
Joined: November 24th, 2006, 11:26 pm

Post by CIB »

Finisterrex wrote:Yes, Multiplayer Campaing for 1.2.4 v.
MP campaign? Those are bugged atm and have been for the last half year atleast, so I wouldn't work on something like that before it's fixed..
Post Reply