Gloria Victis code issues
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.
- Elvish_Hunter
- Posts: 1576
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Gloria Victis code issues
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:I recently had to do this in Sceptre of Fire, scenario Outriding the Outriders, to fix the very same bug:
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]
Spoiler:
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- Neuromancer
- Posts: 204
- Joined: September 10th, 2010, 9:49 pm
Re: Gloria Victis code issues
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.
Secondly, I created capture event which doesnt work, most probably because the variables are incorrectly specified. What are correct names for these?
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]
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]
Re: Gloria Victis code issues
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!
- Neuromancer
- Posts: 204
- Joined: September 10th, 2010, 9:49 pm
Re: Gloria Victis code issues
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.
Re: Gloria Victis code issues
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...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.
- Neuromancer
- Posts: 204
- Joined: September 10th, 2010, 9:49 pm
Re: Gloria Victis code issues
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]
Re: Gloria Victis code issues
there's no filter_location on this level (just include it in [filter]).
- Neuromancer
- Posts: 204
- Joined: September 10th, 2010, 9:49 pm
Re: Gloria Victis code issues
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]
Re: Gloria Victis code issues
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:
and make sure you have
You could also use
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]
first_time_only=no
.You could also use
[if]
, [have_unit]
and count=9
.SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- Neuromancer
- Posts: 204
- Joined: September 10th, 2010, 9:49 pm
Re: Gloria Victis code issues
Thanks to both of you! It works with this code:
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].
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]
Re: Gloria Victis code issues
Actually, I am not sure whether multipleNeuromancer 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].
[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:
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. Thehttp://wiki.wesnoth.org/StandardUnitFilter wrote:[filter_location]: StandardLocationFilter - the tile that the unit is standing on matches the location filter.
[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. SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- Neuromancer
- Posts: 204
- Joined: September 10th, 2010, 9:49 pm
Re: Gloria Victis code issues
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]
Re: Gloria Victis code issues
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]
Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
- Neuromancer
- Posts: 204
- Joined: September 10th, 2010, 9:49 pm
Re: Gloria Victis code issues
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]
Re: Gloria Victis code issues
Neuro: I tested this in 1.9.13 with this code:
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.
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]
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.
Last edited by mattsc on January 7th, 2012, 10:28 pm, edited 2 times in total.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on