Un-petrifying Petrified units and Vice Versa
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.
- Lord-Knightmare
- Discord Moderator
- Posts: 2360
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Un-petrifying Petrified units and Vice Versa
Hello, I have been trying to make these macros work, but I cannot speculate what I have done wrong.
Can anybody help me out ?
Code: Select all
[event]
name="turn 6"
{VARIABLE initiate_minotaurs yes}
[/event]
[event]
name="new turn"
first_time_only=no
[if]
{VARIABLE_CONDITIONAL initiate_minotaurs equals yes}
[then]
[filter_location]
time_of_day=chaotic
[/filter_location]
[store_unit]
[filter]
side=3
[/filter]
variable="minotaurs"
kill=no
[/store_unit]
{FOREACH minotaurs i}
{VARIABLE_OP minotaurs[$i] petrified no}
[unstore_unit]
variable="minotaurs[$i]"
find_vacant=no
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE minotaurs}
[/then]
[/if]
[if]
{VARIABLE_CONDITIONAL initiate_minotaurs equals yes}
[then]
[filter_location]
time_of_day=lawful
[/filter_location]
[store_unit]
[filter]
side=3
[/filter]
variable="minotaurs"
kill=no
[/store_unit]
{FOREACH minotaurs i}
{VARIABLE_OP minotaurs[$i] petrified yes}
[unstore_unit]
variable="minotaurs[$i]"
find_vacant=no
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE minotaurs}
[/then]
[/if]
[/event]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- pyrophorus
- Posts: 533
- Joined: December 1st, 2010, 12:54 pm
Re: Un-petrifying Petrified units and Vice Versa
Code: Select all
{VARIABLE_OP minotaurs[$i] petrified no}
Maybe you could use instead:
Code: Select all
{VARIABLE minotaurs[$i].status.petrified no}
HowTos: WML filtering, WML variables
Re: Un-petrifying Petrified units and Vice Versa
This code would be significantly simpler if instead of storing and unstoring, you just use the [unpetrify] tag. There is also a corresponding [petrify] tag for vice versa.
Re: Un-petrifying Petrified units and Vice Versa
Not to mention [filter_location] obviously isn't an action tag.
- Lord-Knightmare
- Discord Moderator
- Posts: 2360
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Un-petrifying Petrified units and Vice Versa
I started with that and it did not work and thus, I was compelled to make the code more sophisticated.iceiceice wrote:This code would be significantly simpler if instead of storing and unstoring, you just use the [unpetrify] tag. There is also a corresponding [petrify] tag for vice versa.
I got these errors after I made your suggested edit.The second parameter should be an operator name. I doubt 'petrified' being valid in this context.
Maybe you could use instead:
Then how shall I take the time of day into account in the coding?Not to mention [filter_location] obviously isn't an action tag.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Un-petrifying Petrified units and Vice Versa
So you might do things like:
If you are confused about why this is the code, the description of [petrify] says that it should take a standard unit filter as an argument, but you suppress the [filter] and [/filter] tags when using it. The unit filter you want also contains a filter based on location as an extra condition on the unit, so [filter_location] is a subsection of this unit filter.
In the above code you have structure
Clearly, you could just test once and unpetrify all...
unless for some reason you haven't shown us you want sometimes to unpetrify some and not others, and then you still need the location tests.
If e.g. side 3 controls some other statues on the map, which are at neutral locations and shouldn't be unpetrified, you might use something like
Code: Select all
[unpetrify]
side = 3
[filter_location]
time_of_day = lawful
[/filter_location]
[/unpetrify]
In the above code you have structure
Code: Select all
IF initiate minotaurs
unpetrify chaotic
ENDIF
IF initiate minotaurs
unpetrify lawful
ENDIF
Code: Select all
{IF_VAR initiate_minotaurs boolean_equals yes (
[then]
[unpetrify]
side = 3
[/unpetrify]
[/then]
)}
If e.g. side 3 controls some other statues on the map, which are at neutral locations and shouldn't be unpetrified, you might use something like
Code: Select all
{IF_VAR initiate_minotaurs boolean_equals yes (
[then]
[unpetrify]
side = 3
[filter_location]
time_of_day = lawful
[or]
time_of_day = chaotic
[/or]
[/filter_location]
[/unpetrify]
[/then]
)}
- Lord-Knightmare
- Discord Moderator
- Posts: 2360
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Un-petrifying Petrified units and Vice Versa
Thank you! It works now!So you might do things like:
Now, to upload the add-on...
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Un-petrifying Petrified units and Vice Versa
Well, your "more sophisticated" code did not work either, did it?Lord-Knightmare wrote:I started with that and it did not work and thus, I was compelled to make the code more sophisticated.
The first error message suggests you neglected to change VARIABLE_OP to VARIABLE.Lord-Knightmare wrote:I got these errors after I made your suggested edit.
I have no guess as to the cause of the second error, and since you have it working, I won't spend time on it.