How do I change a unit's side once defeated?

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
michaelan
Posts: 30
Joined: April 21st, 2013, 6:42 pm

How do I change a unit's side once defeated?

Post by michaelan »

Hi, I'm working on a scenario where the player is meant to "capture" some ogres by defeating them in battle. Basically, I'd like to make it so that once an ogre is killed, it switches to the player's side.
I currently created this bit of code here:

Code: Select all

	[event]
	 name=last breath

	 [filter]
	  side=2
	 [/filter]

	 [filter_second]
	  side=1
	 [/filter_second]

	 [message]
	  speaker=unit
	  message=_ "Me surrender!"
	 [/message]

	 [heal_unit]
	  [filter]
	   id=unit
	  [/filter]
	 [/heal_unit]

	 {MODIFY_UNIT (id=unit) side 1 }
	[/event]
However, it seems using "unit" only works for dialog, and not unit modifications. I'd appreciate any help I can get with this. Thank you very much!
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do I change a unit's side once defeated?

Post by Ravana »

id=$unit.id
Also, you might want first_time_only=no
michaelan
Posts: 30
Joined: April 21st, 2013, 6:42 pm

Re: How do I change a unit's side once defeated?

Post by michaelan »

Yup, that did it. Thank you very much for the help; I really appreciate it!
Post Reply