I want to understand

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.
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: I want to understand

Post by The_Gnat »

What you have written looks much better, but the code does not look quite correct. You have written:

Code: Select all

[have_unit]
    [and]
        [variable]
                name=hotclimate
        [/variable]
   [/and]
[/have_unit]
This means: check if their is a unit with the variable hotclimate. Is this what you want? Also i am no expert but it seems you should have a value? For example:

Code: Select all

        [variable]
                name=hotclimate
                value=true
        [/variable]
Rodrom
Posts: 41
Joined: March 4th, 2017, 7:00 am
Location: Reach me here: Orwell64123@gmail.com

Re: I want to understand

Post by Rodrom »

The_Gnat wrote:What you have written looks much better, but the code does not look quite correct. You have written:

Code: Select all

[have_unit]
    [and]
        [variable]
                name=hotclimate
        [/variable]
   [/and]
[/have_unit]
This means: check if their is a unit with the variable hotclimate. Is this what you want?
Yes. My intent was for the code will check each unit for one of three different variables, and select one of three different weapon specials based on the which of the three different booleans had a value of "true".
Also i am no expert but it seems you should have a value?
Value added. I forgot that boolean values equal "no" on default, not "yes".

Thanks for the help. WML doesn't seem to be something I understand well.
Rodrom
Posts: 41
Joined: March 4th, 2017, 7:00 am
Location: Reach me here: Orwell64123@gmail.com

Re: I want to understand

Post by Rodrom »

Code: Select all

#textdomain wesnoth-The_Legend_Of_Buttheart

#   Weapon Special

#define WEAPON_SPECIAL_ARCANA_ACTIVATE_P
    [arcana_activate_p]
        id=TLOBH_arcana_activate_p
        name= _ "arcana activate"
        name_inactive=_ "inactive activate"
        description= _ "Changes the schedule based on the nature of the attacking unit, and may change stats as well."
        description_inactive=_ "This attack changes the unit's surroundings."
    [/arcana_activate_p] # wmlxgettext: [specials]
[/specials] # wmlxgettext: [attack]
[/attack]
[event]
    name=polar_unlock
	first_time_only=no
		[time_area]
		  x,y=$unit.x,$unit.y
		  radius=6
		  {POLAR_SCHEDULE}
		[/time_area]
			{POLAR_SIGNAL}
[/event]
[event]
    name=attacker hits
    first_time_only=no
		[if]	
			[have_unit]
				[variable]
					name=cold_climate
					value=yes
				[/variable]
			[/have_unit]	 
				[then]
					[fire_event]
						name=polar_unlock
					[/fire_event]
				[/then]
					[else]
						{PALLID_SIGNAL}
					[/else]
		[/if]
[/event]
[+attack]
    [+specials]
        # wmlxgettext: [/specials]
        # wmlxgettext: [/attack]
		
#enddef
I thought on it some more, and thought about using fire events to keep the inputs from getting confused, or at least gaining the ability to debug each event separately. Could be working better though. The message macros say they're working but I don't see the time areas changing anymore.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: I want to understand

Post by zookeeper »

Rodrom wrote:
gfgtdf wrote: well now you have [filter_wml] which not an accepted tag in [if] ... .really the only accepted tag atre the ones in the link i put in my last post
I apologize. I need to do a better job remembering the more common sub-tags and when they are valid.
No, you're entirely missing the point. No one expects you to remember anything.

When you don't remember which tag you can put where, check the wiki. If you think you probably remember it right and write your code without checking the wiki, but then the code doesn't actually work, check the wiki and see whether you remembered correctly or not. What you seem to be doing is just writing some code blindly while you know you don't know how to write it correctly, and then when it doesn't work you don't even try to verify its correctness yourself but just ask others to point out the problems.

If you're confused about how the ReferenceWML is organized or how you're supposed to find for example what you can put in a [have_unit] in it, then please do ask about that.
The_Gnat wrote:This means: check if their is a unit with the variable hotclimate. Is this what you want? Also i am no expert but it seems you should have a value? For example:

Code: Select all

        [variable]
                name=hotclimate
                value=true
        [/variable]
That is completely wrong. No, you can't do that.
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: I want to understand

Post by The_Gnat »

zookeeper wrote: No, you're entirely missing the point. No one expects you to remember anything.
Zookeeper is right, most of the time i just copy and paste other peoples code ;) Also i suggest you check your code every few lines you write until you understand it better. For example if you right an if statement, put a [message] in it to make sure it works and then launch the game. The more often you test your code the easier it will be to find a bug. Then you can say to yourself: "hmm... all i did was change this and it broke." and you will know your problem. :D
zookeeper wrote:
The_Gnat wrote:This means: check if their is a unit with the variable hotclimate. Is this what you want? Also i am no expert but it seems you should have a value? For example:

Code: Select all

        [variable]
                name=hotclimate
                value=true
        [/variable]
That is completely wrong. No, you can't do that.
:P :mrgreen: Sorry about bad advice. This is (i think ;) ) is what you are trying to do

@zookeeper: thank you for pointing out my mistake, does this work?

Code: Select all

[if]
   [have_unit]
     [filter_wml]
          [variables]
              hotclimate=true
          [/variables]
    [/filter_wml]
  [/have_unit]
[then]
[/then]
[/if]
Or maybe you don't want to check the unit for a specific variable but want to check the game:

Code: Select all

[if]
    [have_unit]
        id=blahblah
    [/have_unit]

   [and]
      [variable]
             name=hotclimate
             equals=true
      [/variable]
  [/and]
[/if]
Rodrom
Posts: 41
Joined: March 4th, 2017, 7:00 am
Location: Reach me here: Orwell64123@gmail.com

Re: I want to understand

Post by Rodrom »

zookeeper wrote: What you seem to be doing is just writing some code blindly while you know you don't know how to write it correctly, and then when it doesn't work you don't even try to verify its correctness yourself but just ask others to point out the problems.
I've been having a lot of trouble so I figured I would ask. I get that I need to write and understand the code on my own. If there's a way to understand the basics faster that would help. It might just be faster to learn coding properly.
The_Gnat wrote:Or maybe you don't want to check the unit for a specific variable
That's exactly what I want to do.

Code: Select all


    #define WEAPON_SPECIAL_ARCANA_ACTIVATE_N
        [arcana_activate_n]
            id=TLOBH_arcana_activate_n
            name= _ "arcana activate"
            name_inactive=_ "inactive activate"
            description= _ "Changes the schedule based on the nature of the attacking unit, and may change stats as well."
            description_inactive=_ "This attack changes the unit's surroundings."
        [/arcana_activate_n] # wmlxgettext: [specials]
    [/specials] # wmlxgettext: [attack]
    [/attack]
    [event]
        name=attacker hits
        first_time_only=no
          [if]

				 mildclimate=yes

                [then]
                   [time_area]
                     x,y=$unit.x,$unit.y
                     radius=10
                     {DEFAULT_SCHEDULE}
                   [/time_area]
                      {BASIC_SIGNAL}
                [/then]
          [/if]
    [/event]
    [+attack]
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]

    #enddef



    #define WEAPON_SPECIAL_ARCANA_ACTIVATE_P
        [arcana_activate_p]
            id=TLOBH_arcana_activate_p
            name= _ "arcana activate"
            name_inactive=_ "inactive activate"
            description= _ "Changes the schedule based on the nature of the attacking unit, and may change stats as well."
            description_inactive=_ "This attack changes the unit's surroundings."
        [/arcana_activate_p] # wmlxgettext: [specials]
    [/specials] # wmlxgettext: [attack]
    [/attack]

    [event]
        name=attacker hits
        first_time_only=no
          [if]

				 coldclimate=yes

                [then]
                   [time_area]
                     x,y=$unit.x,$unit.y
                     radius=10
                     {POLAR_SCHEDULE}
                   [/time_area]
                      {POLAR_SIGNAL}
                [/then]
          [/if]
    [/event]
    [+attack]
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]
          
    #enddef



    #define WEAPON_SPECIAL_ARCANA_ACTIVATE_S
        [arcana_activate_s]
            id=TLOBH_arcana_activate_s
            name= _ "arcana activate"
            name_inactive=_ "inactive activate"
            description= _ "Changes the schedule based on the nature of the attacking unit, and may change stats as well."
            description_inactive=_ "This attack changes the unit's surroundings."
        [/arcana_activate_s] # wmlxgettext: [specials]
    [/specials] # wmlxgettext: [attack]
    [/attack]

    [event]
        name=attacker hits
        first_time_only=no
          [if]
	
				 hotclimate=yes
	
                [then]
                   [time_area]
                     x,y=$unit.x,$unit.y
                     radius=10
                     {SOLAR_SCHEDULE}
                   [/time_area]
                      {SOLAR_SIGNAL}
                [/then]
          [/if]

    [/event]

    [+attack]
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]
          
    #enddef
Thank you The_Gnat. The filtering doesn't work still but at least the incorrect tags are gone. I removed the invalid tags step by step and made sure everything worked.


After using the tags at https://wiki.wesnoth.org/ConditionalAct ... ition_Tags to filter. I've tried removing small parts of code from the macros for while, and only the "attacker hits" event is changing anything. It seems to me almost like the "attacker hits" event is triggered before the units are filtered, I'm not sure how to reverse that order. I would use custom events with [fire event] tags, but I'm not sure if that's the right approach. I'm not asking someone to code the fire event for me, I just want to know if that is a good approach.

If it looks I should just slow down and understand the basics instead I'll accept that.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: I want to understand

Post by zookeeper »

The way event filters work is like this:

1. Let's say you have an 'attacker hits' event. Now, you're playing the game and some combat happens. Maybe you attack, or your enemy attacks. Let's say the attacker is lucky enough to hit the other unit.

2. Now, for purposes of the 'attacker hits' event, the attacker is considered to be the primary unit of the event. So, the game goes through every 'attacker hits' event it knows of, and checks whether the primary unit (the attacker) matches that event's primary unit filter; in this case, the contents of a [filter] block directly inside that 'attacker hits' [event] (and not inside any other tag).

3. If the event has no such [filter], then that means the event doesn't want to discriminate based on what kind of unit the attacker is, but instead wants to be fired literally every time any attacker hits. However, you can have other filtering criteria for when the event should and shouldn't fire; all the other [filter_*] tags listed here. Maybe you want to only fire the event when any attacker hits a Wose that is standing in water at night, in which case you'd just need a [filter_second], because the unit being hit in an 'attacker hits' event is the secondary unit and the secondary unit is filtered for with the contents of [filter_second]. Maybe you want to fire an event when a Knight on side 3 with 1hp left kills any undead unit on side 2, in which case you need both a [filter] and a [filter_second], and so on.

4. Note that not all filtering tags work for all event types. There is no units associated with 'start' or 'side turn' events, so the only filtering tags which make sense in them is [filter_condition] and [filter_side]. Likewise there is only one unit associated with a 'moveto' event, and that's the primary unit which is the unit that is moving, so a [filter_second] isn't going to do anything there, and neither is [filter_attack] because there's no attack to filter for because no one is attacking anyone.

5. Everything that's not listed in EventWML are the so-called ActionWML of the event, that is the commands that are actually executed from top to bottom in linear order after the game has determined that according to the given filtering criteria, this particular event will actually be fired.

I don't know the details of how you envision your thingy working, but to begin with you seem to want your 'attacker hits' event to fire when any unit is hit by an attacker who is using an attack which has a specific weapon special. Which means you want a [filter_attack] tag with special=TLOBH_arcana_activate_n or something in it, and to put that tag in your 'attacker hits' [event] (but not inside any other tag).
Rodrom
Posts: 41
Joined: March 4th, 2017, 7:00 am
Location: Reach me here: Orwell64123@gmail.com

Re: I want to understand

Post by Rodrom »

Thank you zookeeper. The code works!

Code: Select all

    #define WEAPON_SPECIAL_ARCANA_ACTIVATE_N
        [arcana_activate_n]
            id=TLOBH_arcana_activate_n
            name= _ "arcana activate"
            name_inactive=_ "inactive activate"
            description= _ "Changes the schedule based on the nature of the attacking unit, and may change stats as well."
            description_inactive=_ "This attack changes the unit's surroundings."
        [/arcana_activate_n] # wmlxgettext: [specials]
    [/specials] # wmlxgettext: [attack]
    [/attack]
    [event]
        name=attacker hits
        first_time_only=no
				[filter_attack] 
					special=TLOBH_arcana_activate_n
				[/filter_attack] 
					   [time_area]
						 x,y=$unit.x,$unit.y
						 radius=10
						 {DEFAULT_SCHEDULE}
					   [/time_area]
						  {BASIC_SIGNAL}
    [/event]
    [+attack]
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]

    #enddef



    #define WEAPON_SPECIAL_ARCANA_ACTIVATE_P
        [arcana_activate_p]
            id=TLOBH_arcana_activate_p
            name= _ "arcana activate"
            name_inactive=_ "inactive activate"
            description= _ "Changes the schedule based on the nature of the attacking unit, and may change stats as well."
            description_inactive=_ "This attack changes the unit's surroundings."
        [/arcana_activate_p] # wmlxgettext: [specials]
    [/specials] # wmlxgettext: [attack]
    [/attack]
    [event]
        name=attacker hits
        first_time_only=no
				[filter_attack] 
					special=TLOBH_arcana_activate_p
				[/filter_attack] 
					   [time_area]
						 x,y=$unit.x,$unit.y
						 radius=10
						 {POLAR_SCHEDULE}
					   [/time_area]
						  {POLAR_SIGNAL}
    [/event]
    [+attack]
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]
          
    #enddef



    #define WEAPON_SPECIAL_ARCANA_ACTIVATE_S
        [arcana_activate_s]
            id=TLOBH_arcana_activate_s
            name= _ "arcana activate"
            name_inactive=_ "inactive activate"
            description= _ "Changes the schedule based on the nature of the attacking unit, and may change stats as well."
            description_inactive=_ "This attack changes the unit's surroundings."
        [/arcana_activate_s] # wmlxgettext: [specials]
    [/specials] # wmlxgettext: [attack]
    [/attack]
    [event]
        name=attacker hits
        first_time_only=no
				[filter_attack] 
					special=TLOBH_arcana_activate_s
				[/filter_attack] 
					   [time_area]
						 x,y=$unit.x,$unit.y
						 radius=10
						 {SOLAR_SCHEDULE}
					   [/time_area]
						  {SOLAR_SIGNAL}
    [/event]
    [+attack]time_of_day_id: this accepts a list of one or more actual times of day, separated by commas. These IDs are taken from 
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]
          
    #enddef
EDIT:
I have a question about the [/filter_location] tag.
I get that the tag can be used with the "time_of_day_id" key to filter units based on the time of day, for example:

Code: Select all

  
[filter]
	[filter_location]
		time_of_day_id=dawn
	[/filter_location]
[/filter]


Is there a way to use time of day values not found in data/core/macros/schedules.cfg?
Attachments
n2.png
p2.png
p.png
s.png
s2.png
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: I want to understand

Post by beetlenaut »

Rodrom wrote:Is there a way to use time of day values not found in data/core/macros/schedules.cfg?
I haven't tried this, but I assume that if you make your own [time] of day, and give it an id, you could filter for it.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Rodrom
Posts: 41
Joined: March 4th, 2017, 7:00 am
Location: Reach me here: Orwell64123@gmail.com

Re: I want to understand

Post by Rodrom »

Okay, I WAS able to use my own time_of_day_id values to filter units, and it has been a great help. I made several abilities that use time_of_day_id to filter units and they work well. I've spent my free time this week figuring out how to store variables inside of units using the [store_unit] and [unstore_unit] tags. SigurdFireDragon's gamestate GUI has made it MUCH easier to start learning how to use variables, but I'm still having trouble understanding it all. The https://wiki.wesnoth.org/VariablesWML/H ... _variables page is comprehensive, but a lot of it is still going over my head after all this time.

How do I store multiple units in a variable array, add the boolean variable "unit.variable.frigid" to them all, and define said variable as "yes" for all stored units?

I saw a lot of weapon macros in the War of Legends Era / Ageless Era add-ons whose activation was conditional upon finding a custom-made status and/or variable stored inside the unit, for example:

Code: Select all

#define WEAPON_SPECIAL_AE_ELECTRIC
    [electric]
        id=AE_agl_sh_electric
        name= _ "electric"
        name_inactive=_"electric"
        description= _ "This attack reduces an enemy's movement by half on its next turn."
        description_inactive=_"This attack reduces an enemy's movement by half on its next turn."
    [/electric] # wmlxgettext: [specials]
[/specials] # wmlxgettext: [attack]
[/attack]
[event]
    name=turn refresh
    first_time_only=no
    [store_unit]
        [filter]
            side=$side_number
            [filter_wml]
                [status]
                    electric=yes
                [/status]
            [/filter_wml]
        [/filter]
        variable=electric_store
        kill=yes
    [/store_unit]
    {FOREACH electric_store i}
        {VARIABLE electric_store[$i].moves $electric_store[$i].max_moves}
        {VARIABLE_OP electric_store[$i].moves multiply 0.5}
        {CLEAR_VARIABLE electric_store[$i].status.electric}
        [unstore_unit]
            variable=electric_store[$i]
        [/unstore_unit]
        [remove_unit_overlay]
            id=$electric_store[$i].id
            image=misc/electric.png
        [/remove_unit_overlay]
    {NEXT i}
    {CLEAR_VARIABLE electric_store[$i]}
[/event]
[event]
    name=attacker hits
    first_time_only=no
    [filter_attack]
        special=AE_agl_sh_electric
    [/filter_attack]
    {VARIABLE second_unit.status.electric yes}
    [unstore_unit]
        variable=second_unit
    [/unstore_unit]
    [unit_overlay]
        id=$second_unit.id
        image=misc/electric.png
    [/unit_overlay]
[/event]
[event]
    name=defender hits
    first_time_only=no
    [filter_second_attack]
        special=AE_agl_sh_electric
    [/filter_second_attack]
    {VARIABLE unit.status.electric  yes}
    [unstore_unit]
        variable=unit
    [/unstore_unit]
    [unit_overlay]
        id=$unit.id
        image=misc/electric.png
    [/unit_overlay]
[/event]

I originally intended to store my variable as unit.status.frigid, but it seems like using status as a variable would be more difficult and complicated than simply using unit.variable.frigid. What I am trying to do right now is get

[status]
frigid=yes
[/status]

OR

[variable]
frigid=yes
[/variable]

inside of multiple stored units before I unstore them, that's it. I try to do this stuff on my own before I post, but it's starting to feel like I'm missing something really obvious.

Code: Select all

[event]
    name=side turn
    first_time_only=no
	id=frigid_store
	[store_unit]
		[filter]
			[filter_location]
			time_of_day_id=Pdawn,Pmorning,Pafternoon,Pdusk,Pfirst_watch,Psecond_watch
			[/filter_location]
		[/filter]
	variable=unit.variable.frigid
	mode=append
	[/store_unit]
    {FOREACH frigid_store i}
        {VARIABLE frigid_store[$i] $frigid_store[$i].variable.frigid}
        {VARIABLE_OP frigid_store[$i].variable add 1}
        {CLEAR_VARIABLE frigid_store[$i].variable.frigid}
        [unstore_unit]
            variable=frigid_store[$i]
        [/unstore_unit]
    {NEXT i}
    {CLEAR_VARIABLE frigid_store[$i]}
[/event]
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: I want to understand

Post by Ravana »

>variable=unit.variable.frigid
>{FOREACH frigid_store i}
These should use same variable, and mode=append might not be what you want.

>{CLEAR_VARIABLE frigid_store[$i]}
Previous line ends the part where i could safely be used.
Rodrom
Posts: 41
Joined: March 4th, 2017, 7:00 am
Location: Reach me here: Orwell64123@gmail.com

Re: I want to understand

Post by Rodrom »

Is this more accurate?

Code: Select all

#define FRIGID_STORE

[event]
    name=side turn
    first_time_only=no
	id=frigid_store
	[store_unit]
		[filter]
			[filter_location]
			time_of_day_id=Pdawn,Pmorning,Pafternoon,Pdusk,Pfirst_watch,Psecond_watch
			[/filter_location]
		[/filter]
	variable="variable.frigid"
	value=unit
	[/store_unit]
	{FOREACH variable.frigid i}
	[set_variable]
		name=unit.variable.frigid
		value=yes
		mode=insert
	[/set_variable]
	{VARIABLE variable.frigid[$i] unit.variable.frigid[$i]}
	{VARIABLE_OP variable.frigid[$i] multiply 1}
		[unstore_unit]
            variable=variable.frigid[$i]
        [/unstore_unit]
	{CLEAR_VARIABLE unit.variable.frigid[$i]}
    {NEXT i}
[/event]

#enddef
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: I want to understand

Post by beetlenaut »

The reason nobody responded right away is probably because there are so many problems to explain. I had some free time today though, so....

You are still doing what zookeeper told you not to and putting keys into tags where they can't go. Use the wiki to see what is allowed! I'm not sure you understand what a period in a variable name does, but it accesses a member inside a container. It can also be used to create a new container in [set_variable] or somewhere else where a variable is created.

Don't expect to just change a couple small things and have the code suddenly work. A lot of it just doesn't make sense. I put notes in the code with # to try to explain the issues.

Code: Select all

#define FRIGID_STORE
# Is there a reason for putting this event in a macro? Where are you
# going to insert it? If you don't, it won't do anything.

[event]
    name=side turn
    first_time_only=no
   id=frigid_store
   # OK so far, though "id" is probably not necessary.
   [store_unit]
      [filter]
         [filter_location]
         time_of_day_id=Pdawn,Pmorning,Pafternoon,Pdusk,Pfirst_watch,Psecond_watch
         [/filter_location]
      [/filter]
      # This filter looks OK too.
   variable="variable.frigid"
   # This line creates a container called "variable". Inside that, is
   # another set of containers called "frigid". Inside each of *those* is
   # a bunch of unit data from the units you are storing. So, you have data like
   # "variable.frigid[0].hitpoints" and "variable.frigid[0].experience" and
   # "variable.frigid[0].variables.frigid". That will *work*, but it's confusing.
   # Just use a single variable here like "stored_units" or something.
   value=unit
   # "value" is not a part of "store_unit", so this line is ignored and
   # does nothing.
   [/store_unit]
   {FOREACH variable.frigid i}
   # This will actually work to loop through the confusing variable you created
   # before, but you should be using something less confusing like I said above.
   [set_variable]
      name=unit.variable.frigid
      # This line creates a new container variable called "unit". Inside that
      # is another container called "variable". Inside *that* is a variable
      # called "frigid". I'm sure that's not what you wanted. You probably
      # wanted to operate on the variable you created.
      #  "name=stored_units[$i].frigid" for example.
      value=yes
      mode=insert
      # "mode" is not a part of "set_variable", so this line is ignored and
      # does nothing.
   [/set_variable]
   {VARIABLE variable.frigid[$i] unit.variable.frigid[$i]}
   # "unit.variable.frigid" is not an array at this point, so I think this will
   # just erase all the unit data that was stored in "variable.frigid[i]".
   # Anyway, not what you want. I'm not sure what you are trying to do here though.
   # Also, you should probably stick with one: "[set_variable]" or "{VARIABLE...}".
   # At the moment, you are using one of each.
   {VARIABLE_OP variable.frigid[$i] multiply 1}
   # I have no idea what you think this does. I'm not sure what it's going to do
   # either. That was a collection of unit data, and then it was probably erased,
   # and now you're multiplying it like it's a number...
      [unstore_unit]
            variable=variable.frigid[$i]
            # This line is correct if you stick with the confusing variable name,
            # but it probably won't work anymore after the lines above.
        [/unstore_unit]
   {CLEAR_VARIABLE unit.variable.frigid[$i]}
    {NEXT i}
[/event]

#enddef
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Rodrom
Posts: 41
Joined: March 4th, 2017, 7:00 am
Location: Reach me here: Orwell64123@gmail.com

Re: I want to understand

Post by Rodrom »

Beetlenaut, I listened to what you said and I included more code after fixing the mistakes you pointed out.

Code: Select all

    #define WEAPON_SPECIAL_ARCANA_ACTIVATE_P
        [arcana_activate_p]
            id=TLOBH_arcana_activate_p
            name= _ "arcana activate"
            name_inactive=_ "inactive activate"
            description= _ "Changes the schedule based on the nature of the attacking unit, and may change stats as well."
            description_inactive=_ "This attack changes the unit's surroundings."
        [/arcana_activate_p] # wmlxgettext: [specials]
    [/specials] # wmlxgettext: [attack]
    [/attack]	
	# I know to add macros in the main scenario file so they can work without
	# the weapon macro being fired. That's still kind of confusing, so I added 
	# the code I was using to a weapon macro.
	[event]
		name=side turn
		first_time_only=no
		[store_unit]
			[filter]
				side=$side_number
				[filter_wml]
					[status]
						frigid=yes
					[/status]
				[/filter_wml]
			[/filter]
			variable=frigid_store
			value=unit
			kill=yes
		[/store_unit]
   # What I didn't understand about the "store unit" tag before was the way
   # it automatically takes effect on all chosen units at the beginning of each 
   # turn. Before I assumed that a conditional or action event was needed. 
   # What I don't understand is how to store every unit in the 
   # same hexes where I change the time area. Right now, something like 
   # "frigid_store[0].hitpoints" can be used, but only one unit gets 
   # stored so "frigid_store[1].hitpoints" can not be used.  
		{FOREACH frigid_store i}
			[set_variable]
			  name=status.frigid
			  value=yes
			[/set_variable]
			[unstore_unit]
				variable=frigid_store[$i]
			[/unstore_unit]
			[unit_overlay]
				id=$unit.id
				image="data/add-ons/The_Legend_of_Buttheart/images/misc/frigid_clear.png"
			[/unit_overlay]
		{NEXT i}
		{CLEAR_VARIABLE frigid_store[$i]}
		{CLEAR_VARIABLE unit.frigid_store[$i]}
	[/event]
	[event]
		name=attacker hits
		first_time_only=no
				[filter_attack] 
					special=TLOBH_arcana_activate_p
				[/filter_attack] 
					   [time_area]
						 x,y=$unit.x,$unit.y
						 radius=10
						 {POLAR_SCHEDULE}
					   [/time_area]
						  {POLAR_SIGNAL}
							[set_variable]
							  name=second_unit.status.frigid
							  value=yes
							[/set_variable]
							[unstore_unit]
								variable=second_unit
							[/unstore_unit]
							[unit_overlay]
								id=$unit.id
								image="data/add-ons/The_Legend_of_Buttheart/images/misc/frigid_clear.png"
							[/unit_overlay]
   # Gave the folder weird name, added a snowflake image for the overlay. 
	[/event]
    [+attack]
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]
#enddef

For now, I'm just trying to make sure the code above is correct.

When this code is run, only the defending unit gets "frigid" status. None
of the other units get the status, I intend to change that. The overlay
get applied to every single unit at the beginning of side 2's turn, but
I intend to change that myself.


What I am trying to do after that is set a new variable array with numeric values so that the game can apply the
"frigid" status to more than one unit at a time. What I am assuming is that variable arrays are the way
to store multiple units on one array, while storing the same boolean variable from a second array inside
all of the affected units at the same time. If this is true, then what I intend to do next is to find a way to limit this
group of units to the smaller number in the time area So if units [0] through [11] are in the time area,
then those 12 units would get

[status]
frigid=yes
[/status]

placed inside them at the same time. Working on that is what intend to do next.
Last edited by Rodrom on April 22nd, 2017, 7:32 pm, edited 1 time in total.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: I want to understand

Post by Ravana »

Better than before.

Line 27: I dont recall [store_unit] having value
Line 39: its frigid_store.status.frigid
Line 46: Side turn has no $unit, better be $frigid_store.id
Line 47, 74: Possible to use shorter image path
Line 50, 51: i is out of scope. You want {CLEAR_VARIABLE frigid_store}
Post Reply