4 WML coding questions

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
Rubashov
Posts: 4
Joined: November 25th, 2005, 6:09 pm
Location: The Blue Ridge Mountains

4 WML coding questions

Post by Rubashov »

(I'm not sure if this should be here or in scenario development, sorry)

Great game. Played a few of the campaigns, thought I'd try and make one. I'd like to do some different events, but I'm having trouble coding them in WML. Any help would be appreciated.

1) How do I write an event so if a particular kind of unit (peasant) kills an enemy unit (for simplicity's sake, any kind of unit is okay), it immediately turns into another type of unit (e.g. Partisan). As far as I can figure from the Wiki, events trigger when the primary unit dies, but I don't see a trigger for when the primary unit kills something.

2) How can I make the "recruit=" tag conditional on unit type. For example, when "Bob the Main Character" is a level 1 "90 pound weakling" he can only recruit peasants, but when he advances to a "Football Quarterback" he can recruit peasants _and_ thugs.

3) I think I should use variables for the following situation, but I'm not sure how. Imagine: Bob's objective is to go to his girlfriend's house, pick her up, and get her and himself in the car before her Dad catches them. So, the victory condition is Bob getting in his Camaro--but before he does that, he has to open the door for Sally. In game terms, Sally appears mid-way through the scenario. Then both Bob and Sally have to reach the exit point to win. I'd like it to be Sally has to reach it first, then Bob.

4) I'm having trouble convincing my ai leaders to go and attack Bob. They tend to sit on their keep. Even worse, in a scenario where Bob and his friends have ranged weapons and the bad guys don't (Sally's Dad left the shotgun inside), the bad guy leader just sits there until killed with ranged attacks, and never actually attacks the units next to him, even though he has a far superior melee attack.
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

1) use [filter_second] in a die event
2) you can check his type every turn and [allow_recruit] if necessary according to the unit type. For trunk you can also use an advance event.
3) set a variable to check if if Sally went first to the car
4) you can specify some parameters for the ai in the side definition ... See the AIWML page in the wikii.
Rubashov
Posts: 4
Joined: November 25th, 2005, 6:09 pm
Location: The Blue Ridge Mountains

Post by Rubashov »

Noyga wrote:1) use [filter_second] in a die event
2) you can check his type every turn and [allow_recruit] if necessary according to the unit type. For trunk you can also use an advance event.
3) set a variable to check if if Sally went first to the car
4) you can specify some parameters for the ai in the side definition ... See
the AIWML page in the wikii.
Thanks. I pretty much get the theory, but it's the implementation that I'm having trouble with.

1) I can filter the "die" event on a secondary unit, but then doesn't the effect still happen to the primary unit? And what is the code for transform (not advance) at unit to a different type? I haven't been able to find it on the wiki.

2) How would I do that? Would I set up a one-time per scenario event that triggers when the character is a certain type? If it triggers in scenario 1, and he can recuit them in scenario 1, do I have to redo the event in scenario 2 or will he still be able to recruit them?

3). Yes, well, "setting a variable check" is proving to be difficult. Do you know of a scenario where this sort of thing is done that I could copy from?

4) I've played around with the AI parameters, mostly making it aggressive. I'll keep doing so, I guess.
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

1) yes the effect will still happen
To transform a unit you need to :
- use [store_unit] to store the unit in a variable
- then modify the unit by modifying the variable
- then use [unstore_unit] to apply the changes

2) in a turn event use an [if] with an [has_unit] matching the unit like this :

Code: Select all

[has_unit]
side=1
canrecruit=1
type=Football Quarterback
[/has_unit]
and apply the change with [allow_recruit] in the [then] part
3) there are some but i don't rember exactly which ones
Basicaly you do two moveto events
- one that matches Sally, in which you check a variable (previously initialised to 0) to 1
- one that matches Bob, in which you do nothing if the variable is set to 0. Do set firstimeonly=no for this one
aelius
Posts: 497
Joined: August 30th, 2004, 8:07 pm
Location: Virginia, USA

Post by aelius »

Here's the code to transform a unit into a different type. It's pulled from The South Guard (specifically, /scenarios/7a.Into_The_Depths.cfg), and may be helpful. The WML documentation for this stuff isn't well organized (or so I think).

Code: Select all

	[store_unit]
		variable=unit_store
		kill=yes
		[filter]
			type=Peasant
		[/filter]
	[/store_unit]

[set_variable]
	name=unit_store.type
	value=Footpad
[/set_variable]

[unstore_unit]
	variable=unit_store
	find_vacant=yes
[/unstore_unit]

{CLEAR_VARIABLE unit_store}
La perfection est atteinte non quand il ne reste rien à ajouter, mais quand il ne reste rien à enlever. - Antoine de Saint Exupery (of course)
Rubashov
Posts: 4
Joined: November 25th, 2005, 6:09 pm
Location: The Blue Ridge Mountains

Post by Rubashov »

Thanks a lot! I never imagined people would be this helpful this soon. I'll take these and see what I can do.

Thanks!!
Emmanovi
Posts: 266
Joined: October 21st, 2005, 4:24 pm
Location: In a galaxy, far, far away........

Post by Emmanovi »

If the enemy leaders don't recruit, then remove or recheck their recruitment pattern. This can be the cause (and in my experience, often is).
If white was black and black was white, what would happen to zebra crossings?
Post Reply