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.
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 »

This is what I have now.

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]	
	[event]
		name=side turn
		first_time_only=no
		[store_unit]
			[filter]
				id=$frigid_store[i].id
				[filter_wml]
					[status]
						frigid=yes
					[/status]
				[/filter_wml]
			[/filter]
			variable=frigid_store
			value=unit
			kill=yes
		[/store_unit]
		{FOREACH frigid_store i}
			[set_variable]
			  name=status.frigid
			  value=yes
			[/set_variable]
			[unstore_unit]
				variable=frigid_store[i].status.frigid
			[/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}
	[/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=50
						 {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]
	[/event]
    [+attack]
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]
#enddef
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: I want to understand

Post by Ravana »

Lines 16, 24, 29, 33, 36 are wrong.

16, 33 were correct in your last post.
24, 29, 36 are still wrong.
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 »

Not sure about the first [set_variable] tag.

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]	
   [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
         kill=yes
      [/store_unit]
      {FOREACH frigid_store i}
         [set_variable]
           name=status.frigid
           value=unit
         [/set_variable]
		[unstore_unit]
			variable=frigid_store[$i]
		[/unstore_unit]
         [unit_overlay]
            id=$unit.id
            image="misc/frigid_clear.png"
         [/unit_overlay]
      {NEXT i}
      {CLEAR_VARIABLE frigid_store}
   [/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=50
                   {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="misc/frigid_clear.png"
                     [/unit_overlay]
   [/event]
    [+attack]
        [+specials]
            # wmlxgettext: [/specials]
            # wmlxgettext: [/attack]
#enddef
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: I want to understand

Post by zookeeper »

It sets a variable that you clearly never use for anything. And it doesn't make any sense anyway. So, yeah.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: I want to understand

Post by beetlenaut »

Rodrom wrote:# 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.
No, store_unit does nothing automatically. You were right before in assuming that it needs an event. It is in one though. The [event] tag sets that up. This event (not the store_unit) automatically takes effect at the beginning of each side's turn. That's what "name=side turn" does. The store_unit is just along for the ride. If you change the event's name, the store_unit will happen at a different time.
Rodrom wrote: # only one unit gets
# stored
How do you know that? Did you use :inspect to check? And how do you know that more than one unit should be stored? Did you check that too? That [store_unit] tag looks OK to me. It may be the only part that really does work just like you want it to.
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 »

How do you know that? Did you use :inspect to check? And how do you know that more than one unit should be stored? Did you check that too? That [store_unit] tag looks OK to me. It may be the only part that really does work just like you want it to.
I used the SigurdFireDragon's gamestate GUI to check. What happens is that the unit hit by the new weapon special gets the frigid status and no other unit.
I don't want to change the [store_unit] tag, I want to select only the units in the changed time area,

[time_area]
x,y=$unit.x,$unit.y
radius=50
{POLAR_SCHEDULE}
[/time_area]

and then apply the [store_unit] tag to only those units. I'm not sure what the best way to do that is. I tried using a custom event to filter, but I see now that [store_unit] doesn't work that way.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: I want to understand

Post by beetlenaut »

Rodrom wrote:What happens is that the unit hit by the new weapon special gets the frigid status
If that's what you wanted, then the [filter_attack], [set_variable], and [unstore_unit] tags in the second event are correct.
Rodrom wrote:I want to select only the units in the changed time area
So, in the store_unit tag, filter for units in locations that have the changed time area. You actually had that before I think.
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 wrote:
Rodrom wrote:I want to select only the units in the changed time area
So, in the store_unit tag, filter for units in locations that have the changed time area. You actually had that before I think.

Code: Select all


[event]
      name=side turn
      first_time_only=no
      [store_unit]
		[filter]
			side=$side_number
			[filter_location]
				time_of_day_id=Pdawn,Pmorning,Pafternoon,Pdusk,Pfirst_watch,Psecond_watch
			[/filter_location]
		[/filter]
         variable=frigid_store
         kill=yes
      [/store_unit]
      {FOREACH frigid_store i}
         [set_variable]
           name=unit.status.frigid
           value=yes
         [/set_variable]
      [unstore_unit]
         variable=frigid_store[$i]
      [/unstore_unit]
         [unit_overlay]
            id=$unit.id
            image="misc/frigid_clear.png"
         [/unit_overlay]
      {NEXT i}
      {CLEAR_VARIABLE frigid_store}
   [/event]

I changed the side turn event. It doesn't seem to be working though.

Also, I just realized that I was treating the side turn event as though it was one of the ''predetermined events with filters" like attacker hits. I'm thinking I may need
to change the side turn event to an "enter_hex" event or "move to" event to use the WML I wanted.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: I want to understand

Post by beetlenaut »

Rodrom wrote:I'm thinking I may need to change the side turn event to an "enter_hex" event or "move to" event to use the WML I wanted.
I don't know about that. The reason the event doesn't seem to do anything is because "unit" has no automatic value in a side_turn event, and you didn't give it a value either. However, you don't need "unit" because you stored your units in frigid_store, so you can just use that. You used it with unstore_unit, so I don't know why you didn't use it with the set_variable or unit_overlay.
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 wrote:However, you don't need "unit" because you stored your units in frigid_store, so you can just use that. You used it with unstore_unit, so I don't know why you didn't use it with the set_variable or unit_overlay.

Code: Select all


	[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
         kill=yes
      [/store_unit]
      {FOREACH frigid_store i}
        # So the first set_variable tag should look like this?
         [set_variable]
            name=frigid_store[$i].status.frigid
			value=yes   
         [/set_variable]
		 [unstore_unit]
			 variable=frigid_store[$i]
		 [/unstore_unit]
         [unit_overlay]
            id=$frigid_store.id
            image="misc/frigid_clear.png"
         [/unit_overlay]
      {NEXT i}
      {CLEAR_VARIABLE frigid_store}
   [/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=50
                   {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=$frigid_store.id
                        image="misc/frigid_clear.png"
                     [/unit_overlay]
   [/event]

       # The [unit_overlay] tags work with the variable when I tested it.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: I want to understand

Post by beetlenaut »

Rodrom wrote:# So the first set_variable tag should look like this?
That looks right.
Rodrom wrote:# The [unit_overlay] tags work with the variable when I tested it.
No, you have to use the array index. Using no index is the same as using [0], so it will only work for the first stored unit.
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 »

Code: Select all


[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
         kill=yes
      [/store_unit]
      {FOREACH frigid_store i}
         [set_variable]
            name=frigid_store[$i].status.frigid
			value=yes   
         [/set_variable]
       [unstore_unit]
          variable=frigid_store[$i]
       [/unstore_unit]
         [unit_overlay]
            id=frigid_store[$i].id
            image="misc/frigid_clear.png"
         [/unit_overlay]
      {NEXT i}
      {CLEAR_VARIABLE frigid_store}
   [/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=50
                   {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=frigid_store[$i].id
                        image="misc/frigid_clear.png"
                     [/unit_overlay]
   [/event]

Not sure about the notation for the array variables, but this is what I changed the [unit_overlay] to.

EDIT:

[unit_overlay]
id=frigid_store[$i].id
image="misc/frigid_clear.png"
[/unit_overlay]

is wrong. I think it should be

[unit_overlay]
id=$frigid_store[$i].id
image="misc/frigid_clear.png"
[/unit_overlay]
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: I want to understand

Post by beetlenaut »

Your edit is right. The other $ is necessary. So, is it working now?
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 wrote:Your edit is right. The other $ is necessary. So, is it working now?
No, unfortunately. The overlay works fine, but the "frigid" status is only being applied by the attacker hits event (so just one or two units depending).
The side turn event doesn't change the status at all. I feel like I'm close to getting it but I'm unsure how to proceed.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: I want to understand

Post by beetlenaut »

Rodrom wrote:The side turn event doesn't change the status at all.
Probably because you've gone back to storing only the units that already have the status applied. And then you apply it to them. I didn't notice.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Post Reply