[SOLVED] WML prestart event misbehaviour in on-line games
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.
[SOLVED] WML prestart event misbehaviour in on-line games
I'm building a multiplayer scenario, intended to be played by 1-4 players. Each side has a predefined leader, so if there is less than 4 players I need to remove non-playing leaders in a prestart event. I wrote the following code to accomplish this:
Strangely, it works as intended in local multiplayer games, but in on-line games it seems to remove all the leaders regardless of whether a player is playing with that side or not, resulting in the scenario ending immediately. I wonder, what might be the reason for this difference in behaviour. There are no OOS errors to be seen…
Code: Select all
[event]
name=prestart
[kill]
[filter_side]
side=1,2,3,4
controller=null
[/filter_side]
[/kill]
[/event]
Last edited by Sventimir on August 14th, 2023, 7:13 am, edited 1 time in total.
Re: WML prestart event misbehaviour in on-line games
The reason is this line ,https://github.com/wesnoth/wesnoth/blob ... r.cpp#L221 , idk what the best way to ya does is though, chacking whether controller is null should be safe thing to do, but we cannot remove that line during stable
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
- Celtic_Minstrel
- Developer
- Posts: 2241
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML prestart event misbehaviour in on-line games
Workaround:
Untested, so I might've gotten some little detail wrong somewhere in there.
Code: Select all
[store_unit]
[filter_side]
side=1,2,3,4
[/filter_side]
variable=all_leaders
[/store_unit]
[foreach]
array=all_leaders
[do]
[if]
{VARIABLE_CONDITIONAL this_item.controller equals null}
[then]
[kill]
id=$this_item.id
[/kill]
[/then]
[/if]
[/do]
[/foreach]
{CLEAR_VARIABLE all_leaders}
Re: WML prestart event misbehaviour in on-line games
Thanks a lot for the explanation and the workaround. I'll try to make it work!
BTW, macros don't seem to work for me for some reason. I verified they're where they're supposed to be in /usr/share/wesnoth, but whenever I try to use one, I get file-not-found error mentioning the macro name. I place my scenarios in ~/.local/share/wesnoth/1.16/editor/scenarios – maybe I should move them to data/ for macros to work? So far I work around it by simply copying macro's content to the scenario, but that's a little annoying.
BTW, macros don't seem to work for me for some reason. I verified they're where they're supposed to be in /usr/share/wesnoth, but whenever I try to use one, I get file-not-found error mentioning the macro name. I place my scenarios in ~/.local/share/wesnoth/1.16/editor/scenarios – maybe I should move them to data/ for macros to work? So far I work around it by simply copying macro's content to the scenario, but that's a little annoying.
- Celtic_Minstrel
- Developer
- Posts: 2241
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML prestart event misbehaviour in on-line games
Normally your files should be in data/add-ons/Your_Addon_Name, where Your_Addon_Name can be anything you choose. If you really want to leave them in editor/scenarios though, you should be able to make macros work just by adding the line
{data/core/macros}
at the top of your file.Re: WML prestart event misbehaviour in on-line games
I thought to leave it there for the moment, while I'm still developing the scenario. Otherwise, what is the
editor/scenarios
directory good for if files in there don't load macros by default? In any case, this doesn't seem to work. When I enter any multiplayer game setup, I get Error: Macro/file 'data/core/macros' is missing...
followed by my scenario file.Re: WML prestart event misbehaviour in on-line games
I managed to solve it using
formula
condition instead of controller
within filter_side
like this:
Code: Select all
[event]
name=prestart
[kill]
[filter_side]
side=1,2,3,4
formula="not (is_human or is_network or is_ai)"
[/filter_side]
[/kill]
[/event]
- Celtic_Minstrel
- Developer
- Posts: 2241
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML prestart event misbehaviour in on-line games
Its original purpose was for scenarios created with the map editor, which don't contain macros. It's no longer used in 1.17, however.
I… what? I don't understand. How can it fail to find a file in the core mainline directory? Especially when it can find that file just fine when it loads core?