Un-petrifying Petrified units and Vice Versa

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
User avatar
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

Post by Lord-Knightmare »

Hello, I have been trying to make these macros work, but I cannot speculate what I have done wrong.

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]
2P_Minotaur_Battlefield v0.3.cfg
(12.32 KiB) Downloaded 149 times
Can anybody help me out :) ?
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: Un-petrifying Petrified units and Vice Versa

Post by pyrophorus »

Code: Select all

{VARIABLE_OP minotaurs[$i] petrified no}
The second parameter should be an operator name. I doubt 'petrified' being valid in this context.
Maybe you could use instead:

Code: Select all

{VARIABLE minotaurs[$i].status.petrified no}
HTH
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: Un-petrifying Petrified units and Vice Versa

Post by iceiceice »

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.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Un-petrifying Petrified units and Vice Versa

Post by zookeeper »

Not to mention [filter_location] obviously isn't an action tag.
User avatar
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

Post by Lord-Knightmare »

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 started with that and it did not work and thus, I was compelled to make the code more sophisticated.
The second parameter should be an operator name. I doubt 'petrified' being valid in this context.
Maybe you could use instead:
I got these errors after I made your suggested edit.
Screen Shot 2014-02-14 at 18.42.56.png
Screen Shot 2014-02-14 at 18.41.50.png
Not to mention [filter_location] obviously isn't an action tag.
Then how shall I take the time of day into account in the coding?
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: Un-petrifying Petrified units and Vice Versa

Post by iceiceice »

So you might do things like:

Code: Select all

[unpetrify]
    side = 3
    [filter_location]
        time_of_day = lawful
    [/filter_location]
[/unpetrify]
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

Code: Select all

IF initiate minotaurs
    unpetrify chaotic
ENDIF
IF initiate minotaurs
    unpetrify lawful
ENDIF
Clearly, you could just test once and unpetrify all...

Code: Select all

{IF_VAR initiate_minotaurs boolean_equals yes (
    [then]
        [unpetrify]
            side = 3
        [/unpetrify]
    [/then]
)}
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

{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]
)}
User avatar
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

Post by Lord-Knightmare »

So you might do things like:
Thank you! It works now! :D

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
JaMiT
Inactive Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: Un-petrifying Petrified units and Vice Versa

Post by JaMiT »

Lord-Knightmare wrote:I started with that and it did not work and thus, I was compelled to make the code more sophisticated.
Well, your "more sophisticated" code did not work either, did it?
Lord-Knightmare wrote:I got these errors after I made your suggested edit.
The first error message suggests you neglected to change VARIABLE_OP to VARIABLE.

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.
Post Reply