How to make a unit do a thing in X turns
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.
How to make a unit do a thing in X turns
I am making a unit that transforms into a different unit depending on the terrain after a few turns.
I believe I can simply use an event to transform the unit with a bunch of if tags to decide what it gets turned into. However, I don't know how to actually trigger this event. I want it to be that 3 turns after my unit spawns, it transforms. The unit is immobile (we have a cocoon type thing going on here).
How could I make this work?
I believe I can simply use an event to transform the unit with a bunch of if tags to decide what it gets turned into. However, I don't know how to actually trigger this event. I want it to be that 3 turns after my unit spawns, it transforms. The unit is immobile (we have a cocoon type thing going on here).
How could I make this work?
Re: How to make a unit do a thing in X turns
You need to be more specific in describing what you want.
All I can say for now is have look at Liberty's 4th scenario for reference.
As for making a unit do a thing in X turns, you have 2 options. Either inject an event when you create the unit and have it be $($turn_number + 3) or use [unit] [variables] to set up a counter and increment that after each turn.
All I can say for now is have look at Liberty's 4th scenario for reference.
As for making a unit do a thing in X turns, you have 2 options. Either inject an event when you create the unit and have it be $($turn_number + 3) or use [unit] [variables] to set up a counter and increment that after each turn.
Re: How to make a unit do a thing in X turns
To be more specific, I am making a unit type that is spawned from other units (this bit works). I want each iteration of the unit to transform after that specific iteration has been alive for 3 turns. What do I put in the unit type WML to trigger the transformation?
Re: How to make a unit do a thing in X turns
Inside the unit_type you can add something like this:
Code: Select all
[event]
name=unit placed
[event]
name=turn_"$($turn_number + 3)"
delayed_variable_substitution=no
# Do Stuff
[/event]
[/event]
Re: How to make a unit do a thing in X turns
Here is a more fleshed out example, I recommend using a custom event name and firing that when you place the unit instead of relying on "unit placed"
In this example the recruited custom peasant unit dies after 3 turns
In this example the recruited custom peasant unit dies after 3 turns
Code: Select all
[unit_type]
[base_unit]
id=Peasant
[/base_unit]
id=My_Peasant
hide_help=yes
do_not_list=yes
[event]
name=unit_placed,my_custom_event_name
first_time_only=no
[filter]
type=My_Peasant
[/filter]
[event]
name=turn_"$($turn_number + 3)"
delayed_variable_substitution=no
[kill]
id=$unit.id
[/kill]
[/event]
[/event]
[/unit_type]
Re: How to make a unit do a thing in X turns
That is marvellously helpful, thank you.