Gloria Victis code issues

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
Elvish_Hunter
Developer
Posts: 1383
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Gloria Victis code issues

Post by Elvish_Hunter » December 12th, 2011, 9:23 am

According to the wiki, [heal_unit] works only on those units that are already on the map. It does not work on units that are on the recall list, and does not work on stored units. To heal your units, perhaps a better solution is setting their variables by hand:

Code: Select all

{FOREACH roster i}
   {VARIABLE roster[$i].hitpoints $roster[$i].max_hitpoints}
   {VARIABLE roster[$i].attacks_left $roster[$i].max_attacks}
   {VARIABLE roster[$i].moves $roster[$i].max_moves}
   [unstore_unit]
      variable=roster[$i]
      x,y=recall,recall
   [/unstore_unit]
   {NEXT i}
   [clear_variable]
      name=roster
   [/clear_variable]
I recently had to do this in Sceptre of Fire, scenario Outriding the Outriders, to fix the very same bug:
Spoiler:
Current maintainer of these add-ons:
1.14: The Sojournings of Grog, A Rough Life, The White Troll (co-author), Wesnoth Lua Pack
1.12: Children of Dragons

User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: Gloria Victis code issues

Post by Neuromancer » December 12th, 2011, 8:46 pm

Thanks, will test it out.

Another issues:
First, if side 1 holds two specified villages for two consecutive turns, it will complete sidequest. I created two events for that, but they keep on firing even when the objective is completed.

Code: Select all

[event]
	name=side 1 turn end
	first_time_only=no
		[if]
			[have_location]
					x,y=47-53,9-13
					terrain=*^V*
					owner_side=1
			[/have_location]
			[variable]
				name=villagesowned
				equals=1
			[/variable]
			[then]
				[message]
					id=Hazael
					message= _ "it is done, we managed to get hold of vills for 2 consecutive turns!"
				[/message]
				{VARIABLE villagesowned 2}
			[/then]
			[else]
				{VARIABLE villagesowned 0}
			[/else]
		[/if]	
[/event]

[event]
	name=side 1 turn end
	first_time_only=no
	[if]
		[have_location]
				x,y=47-53,9-13
				terrain=*^V*
				owner_side=1
		[/have_location]
		[variable]
			name=villagesowned
			equals=0
		[/variable]
		[then]
			[message]
				id=Hazael
				message= _ "ok, we have secured the vills for now. only one turn to go."
			[/message]
			{VARIABLE villagesowned 1}
		[/then]
	[/if]
[/event]
Secondly, I created capture event which doesnt work, most probably because the variables are incorrectly specified. What are correct names for these?

Code: Select all

[event]
	name=capture
	[if]
		[variable]
			name=owner_side #this checks for previous owner of village
			equals=3
		[/variable]
		[variable]
			name=unit.side #this checks of side of unit which captured the village
			equals=1
		[/variable]
		[then]
			[message]
				side=3
				message= _ "Hey what do you think you are doing?"
			[/message]
		[/then]
	[/if]
[/event]

User avatar
Crendgrim
Moderator Emeritus
Posts: 1328
Joined: October 15th, 2010, 10:39 am
Location: Germany

Re: Gloria Victis code issues

Post by Crendgrim » December 12th, 2011, 8:55 pm

Let's say villagesowned equals zero. The first event doesn't do anything, but the second event sets it to 1. Next turn, villagesowned equals 1: The first event changes its value to 2, the second one to 1 again. Do you see the problem?
UMC Story Images — Story images for your campaign!

User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: Gloria Victis code issues

Post by Neuromancer » December 12th, 2011, 10:14 pm

You mean, these two events fire simultaneously? I think it should be going like this: villagesowned equals zero. The first event doesn't do anything, but the second event sets it to 1. Next turn, villagesowned equals 1: The first event changes its value to 2 and the second does nothing, because it is set to fire only if villagesowned is 0.

Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Gloria Victis code issues

Post by Max » December 12th, 2011, 11:16 pm

Neuromancer wrote:The first event changes its value to 2 and the second does nothing, because it is set to fire only if villagesowned is 0.
you're again setting the variable to 0 in the else branch in the first event. anyway - there's no need for two events. just add +1 to the value if side 1 owns the village and reset it otherwise...

User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: Gloria Victis code issues

Post by Neuromancer » January 4th, 2012, 11:08 am

Event is supposed to fire if 9 units of side 1 are standing in radius around specified location, but so far it fires at any move of side 1. Any suggestions please?

Code: Select all

[event]
	name=moveto
	[filter_location]
		x,y=25,13
		radius=4
		[filter]
			id=Hazael
		[/filter]
		[filter]
			id=Hailey
		[/filter]
                  #and so on, listing all 9 IDs
	[/filter_location]
...
[/event]

Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Gloria Victis code issues

Post by Max » January 4th, 2012, 2:35 pm

there's no filter_location on this level (just include it in [filter]).

User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: Gloria Victis code issues

Post by Neuromancer » January 4th, 2012, 5:07 pm

Something like this?

Code: Select all

[event]
	name=moveto
	[filter]
		[filter_location]
			x,y=25,13
			radius=4
				[filter]
					id=Hazael
				[/filter]
				[filter]
					id=Teresia
				[/filter]
				[filter]
					id=Garret,Kara,Aramis
				[/filter]
				[filter]
					id=Hailey,Bane,Wellen
				[/filter]
				[filter]
					id=Yveen,Wendala,Luciana
				[/filter]
				[filter]
					id=Pelduras,Brenton
				[/filter]
		[/filter_location]
	[/filter]

mattsc
Posts: 1115
Joined: October 13th, 2010, 6:14 pm
Location: Hidden on the hex behind Fred

Re: Gloria Victis code issues

Post by mattsc » January 4th, 2012, 5:25 pm

In principle that's one way to do it, but it won't quite work because of the way how radius operates. See explanation in last section here. Instead, you want:

Code: Select all

       [filter]
          [filter_location]
             [and]
                 x,y=25,13
                 radius=4
             [/and]
             [and]
                [filter]
                   id=list of units (is there a reason why you use several filter tags?)
                [/filter]
              [/and]
          [/filter_location]
       [/filter]
and make sure you have first_time_only=no.

You could also use [if], [have_unit] and count=9.

User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: Gloria Victis code issues

Post by Neuromancer » January 4th, 2012, 8:23 pm

Thanks to both of you! It works with this code:

Code: Select all

[event]
	name=moveto
	first_time_only=no
	[if]
		[have_unit]
			side=1
			count=9
			  [filter_location]
					 x,y=25,13
					 radius=4
			  [/filter_location]
		[/have_unit]
		[then]
		{VARIABLE portal_fired 1}
		[fire_event]
			name=portal
		[/fire_event]
		[/then]
	[/if]
[/event]
Edit: mattsc, I used several filter tags to ensure the event will fire only if selected units are at the location, but I guess it fired only when one of the units specified was there. I was thinking it would work as [and], but apparently it works as [or].

mattsc
Posts: 1115
Joined: October 13th, 2010, 6:14 pm
Location: Hidden on the hex behind Fred

Re: Gloria Victis code issues

Post by mattsc » January 5th, 2012, 3:43 am

Neuromancer wrote:Edit: mattsc, I used several filter tags to ensure the event will fire only if selected units are at the location, but I guess it fired only when one of the units specified was there. I was thinking it would work as [and], but apparently it works as [or].
Actually, I am not sure whether multiple [filter] tags inside [filter_location] have a well defined behavior. The engine might always grab the first or last or something, or do something undefined. The Developers, and probably some others, should know.

But then, what I posted up there is nonsense anyway. If you look at the SUF wiki page, it clearly states:
http://wiki.wesnoth.org/StandardUnitFilter wrote:[filter_location]: StandardLocationFilter - the tile that the unit is standing on matches the location filter.
So, you can test (easily) whether the tile the unit just moved to is within a radius=4 of 25,13, but it is not so straight-foward to test whether other units, at other locations, are also within that distance from 25,13. Or at least that's my current interpretation and I cannot come up with an easy way to do so right now. The [have_unit] code you have is probably what you want to do. I think I'll disappear into the background again and stop pretending that I know what I am talking about. ;)

User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: Gloria Victis code issues

Post by Neuromancer » January 6th, 2012, 9:58 pm

I modified the village capture event, but it still wont work. Im out of ideas for this one. Could someone please suggest whats wrong?

Code: Select all

[event]
	name=capture
	first_time_only=no
	[filter]
		side=1
	[/filter]
	[if]
		[variable]
			name=owner_side
			equals=5
		[/variable]
		[then]
			[message]
				side=5
				message= _ "you stepped on our village. we are now hostile to you."
			[/message]
			[modify_side]
				side=5
				team_name=Nagas
			[/modify_side]
		[/then]
	[/if]
[/event]

Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Gloria Victis code issues

Post by Ceres » January 6th, 2012, 11:24 pm

Move the owner_side thing to the filter:

Code: Select all

[event]
	name=capture
	first_time_only=no
	[filter]
		side=1
      [filter_location]
         owner_side=5
      [/filter_location]
	[/filter]
	[message]
		side=5
		message= _ "you stepped on our village. we are now hostile to you."
	[/message]
	[modify_side]
		side=5
		team_name=Nagas
	[/modify_side]
[/event]

User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: Gloria Victis code issues

Post by Neuromancer » January 7th, 2012, 7:37 pm

I tried that, it didnt work. Also tried this, didnt work too:

Code: Select all

[event]
   name=capture
   [filter]
      side=1
         owner_side=5
   [/filter]
   [message]
      side=5
      message= _ "you stepped on our village. we are now hostile to you."
   [/message]
   [modify_side]
      side=5
      team_name=Alliance,TollhouseNagas,SauriansNagas
   [/modify_side]
[/event]

mattsc
Posts: 1115
Joined: October 13th, 2010, 6:14 pm
Location: Hidden on the hex behind Fred

Re: Gloria Victis code issues

Post by mattsc » January 7th, 2012, 9:49 pm

Neuro: I tested this in 1.9.13 with this code:

Code: Select all

    [event]
        name=capture
        first_time_only=no

        [filter]
            side=1,2
            [filter_location]
                owner_side=1
            [/filter_location]
        [/filter]

        [inspect]
        [/inspect]
        {MESSAGE $unit.id "" ""  "Hello: $owner_side"}
    [/event]
This event fires, but only when Side 1 captures a village, that is owner_side contains the side which does the capture, not the previous owner side as it says at EventWML. Furthermore, the owner_side variable displayed both by [inspect] and in the message is always 0. So unless I misunderstand something here, this looks like a bug to me.

Another thing in you code snippet is that 'side' is not a valid key for [message] AFAIK. Oops, ignore that. It's wrong, as Ceres points out. :oops:
Last edited by mattsc on January 7th, 2012, 10:28 pm, edited 2 times in total.

Post Reply