How can I make the player's units turn on them?

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
Ringcaat
Posts: 68
Joined: August 21st, 2004, 11:54 am
Location: Minneapolis, Minnesota
Contact:

How can I make the player's units turn on them?

Post by Ringcaat »

What I want to do in my campaign is have the player's own units start fighting against the player if a given event is triggered.

I know it's possible to change what team a side is playing for. It doesn't seem to be possible, however, to change who controls a given side--human versus ai. The other choice would appear to be changing the side number of each and every unit on side 1 to some other number. Is there an easy way to do this? I imagine it could be done by building a complex array-driven piece of code that sweeps the whole board looking for units with side=1 and stores them, hacks them to be side=2, and unstores them, but that seems dauntingly diffcult.
This is a young gryphon. She likes cheese. She will steal all your cheese.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

The easiest way would be to just have an empty AI side (that's hostile to the player) that represents the turncoats, and just flip the player's units to that side when the event occurs.

To turn all side 1 units to side 2, for example, you can just use this:

Code: Select all

{MODIFY_UNIT side=1 side 2}
Or, if you want to turn all units but not the leader, for example, just flip the leader back to side 1 immediately afterwards using the same way, or make it all fancy to begin with (I think this should work):

Code: Select all

{MODIFY_UNIT (
    side=1
    [not]
        description=Myleader
    [/not])
    side 2}
Obviously, you need to play a recent version to have the MODIFY_UNIT macro (otherwise just copy it from the WML Fragments page).
I imagine it could be done by building a complex array-driven piece of code that sweeps the whole board looking for units with side=1 and stores them, hacks them to be side=2, and unstores them, but that seems dauntingly diffcult.
That's why we have macros. ;) And that's actually exactly what my examples do.
Ringcaat
Posts: 68
Joined: August 21st, 2004, 11:54 am
Location: Minneapolis, Minnesota
Contact:

Post by Ringcaat »

Thanks :-)
Post Reply