Samonella's questions: currently solved

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.

Samonella's questions: currently solved

Postby Samonella » September 4th, 2016, 5:09 pm

Hi all.

I'm starting work on a campaign that uses lots and lots of [event]s. Trying to keep things clean, especially for save-files' sakes, I'm using the functionality for removing events quite a bit, but I'm hoping there's a similar way to add events. In explanation, at some point in the scenario I remove events that are only needed at the beginning, but events that are only needed toward the end just have to sit around unused for a while. Nesting [event] tags isn't what I'm looking for, because all the WML would still end up in save files. What I want to do is essentially this:
Code: Select all
[event]
    name=scenario_one_part_two
    {~add-ons/Campaign_Name/utils/scenario_one_part_two_events.cfg}
[/event]

except I don't want the preprocessor to dump all the new events in. I want them only to be read at the time this event is fired. Also, I suppose breaking the scenario into smaller scenarios seems logical, but in my case it's definitely not desirable- I think I'd rather just stick to massive save files.

I have one idea that should work but seems pretty unwieldy. Judging by the wiki on UnitTypeWML, I could use invisible, dummy units with [event]s in their unit type to get this done, but this leaves some details foggy... do the events disappear if the last unit of that type dies?
Alternatively, it seems likely enough that there's a way to do just what I want using lua, which I know nothing about. Maybe there's even a simple WML tag that I somehow overlooked.

So, let me phrase all this as a question. What would you do if you needed to add lots of new events halfway through a scenario? If no one has a better method than using dummy unit types, would it be fundamentally possible to make something like an [include_file] action? I think it would be an invaluable tool for blossoming UMC writers like myself.

Edit: gave the topic a more appropriate name
Last edited by Samonella on August 13th, 2017, 8:52 pm, edited 10 times in total.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Adding events mid-scenario

Postby gfgtdf » September 4th, 2016, 5:30 pm

do the events disappear if the last unit of that type dies

No they don't, i actuall think that you dont even have to puit te unit to the map, create a unit toa variable migth be enough.


You already listed all option you have in 1.12 to redocue preprocessor paring:
1) put them in a dummy unit type (dugi does this in his addon)
2) Use lua.

Option one woudl ofc also parse the events but only once, (as opposed to in each scenario)

Option 2 woudl require ou to write yoru events in lua, this can be quite soem work if you did already write them in wml. It has mutiple advnatages though:
1) it allows you to keep the savefiles very small, specially since you will usually just load the code form the lua file when loading a savefile (as opposes to keeping them in each savefile)
2) More complacated code is usually easier to write in lua than in wml.
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.
gfgtdf
Developer
 
Posts: 900
Joined: February 10th, 2013, 2:25 pm

Re: Adding events mid-scenario

Postby Samonella » September 4th, 2016, 5:40 pm

gfgtdf wrote:You already listed all option you have in 1.12 to redocue preprocessor paring:
1) put them in a dummy unit type (dugi does this in his addon)
2) Use lua.

Thanks for the quick, informative response. I'm not likely to be learning about lua any time soon, so dummy units it is!

Would it be worth my time to suggest an [include_file] action on the ideas forum?
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Adding events mid-scenario

Postby zookeeper » September 4th, 2016, 6:33 pm

Dummy units seem like the best way, but it's also worth making sure that you really need such a workaround in the first place. Do you really have, say, >5000 lines of event code in a scenario?
User avatar
zookeeper
WML Wizard
 
Posts: 9604
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Adding events mid-scenario

Postby Samonella » September 4th, 2016, 6:41 pm

zookeeper wrote:Dummy units seem like the best way, but it's also worth making sure that you really need such a workaround in the first place. Do you really have, say, >5000 lines of event code in a scenario?
Oh yes. So far I've only made a tutorial scenario, which is around 1500. The main scenario will be many times as long.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

move_unit question

Postby Samonella » October 10th, 2016, 9:46 pm

I have another question, so I guess I'll just make this my questions thread.

What I want to do is similar to [move_unit], but rather than move the unit all the way to the destination, only move him one turn's distance toward it. I could manage this by using [find_path], but as far as I can tell I would have to check each [step] until finding the last one such that required_turns=1. This seems like a poor solution, especially since I'll be doing this many times for many units.

The only other solution I can think of involves an ugly use of [micro_ai]s, and is definitely worse than the above. So what would you recommend?
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: move_unit question

Postby Samonella » October 11th, 2016, 4:36 pm

I think I've got a work around that eliminates this problem, though I'm still curious if there is a simple way to do it. Would it be possible to add something like a max_movement= key to [move_unit]?
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Adding events mid-scenario

Postby Samonella » October 11th, 2016, 6:26 pm

Alright, I'm stuck again already. :annoyed: Something is wrong with the following code, and I'm not sure what.

The goal here is to use variables like George.goto_x, Harold.goto_y, etc, to dynamically control the given units' movements. Note that the container variable names are identical to the unit ids; this is just a convenience. Harold.goto_x has nothing to do with the unit's actual goto_x property.

The micro_ai works fine if I use the commented line (x,y=50,28) instead of the line I want (x,y=${UNIT_ID}.goto_x|,${UNIT_ID}.goto_y|).

EDIT: The way this is written, the units don't move, regardless of the variables' values, but the scenario will run with no error messages.

Code: Select all
#define VOADAR_MICRO_AI UNIT_ID
    [micro_ai]
        side=2
        ai_type=goto
        action=add
        ca_id={UNIT_ID}_ai
        [filter]
            id={UNIT_ID}
        [/filter]
        [filter_location]
            x,y=${UNIT_ID}.goto_x|,${UNIT_ID}.goto_y|
            #x,y=50,28
        [/filter_location]
    [/micro_ai]
#enddef
[event]
    name=start
    id=create_all_micro_ais
    {VOADAR_MICRO_AI George}
    {VOADAR_MICRO_AI Gwain}
    {VOADAR_MICRO_AI Harold}
[/event]
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Adding events mid-scenario

Postby mattsc » October 12th, 2016, 3:44 am

It's difficult to say what exactly is going on here, but it sounds like the variables don't get set correctly. It might (or might not) have something to do with delayed variable substitution ...

In any case, you can check at any time during the scenario what the parameters in the [micro_ai] tag are set to by typing :inspect (you might have to type :debug first), clicking on the side (team) in question and then on 'ai config full'. Then scroll until you find the goto candidate action. The output is going to look a little messy, but you should be able to locate [filter_location] under 'eval_parms' and see what the x and y values are set to. That might give you an idea of what is going on. If you cannot figure it out, you can post a screengrab of it here and we will see if we can help.
mattsc
 
Posts: 951
Joined: October 13th, 2010, 6:14 pm
Location: Canada

Re: Adding events mid-scenario

Postby Samonella » October 12th, 2016, 5:44 pm

I got it working now, thanks for the tip about checking on the [micro_ai]. I had a bug in setting the goto_ variables before this start event, but the bigger problem was that I was assuming the [micro_ai] would re-check those variables every turn for updated coordinates. In reality, they only get the value once, when the [micro_ai] is first created. So instead of using x,y= I'm now using find_in=, which is working splendidly.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Adding events mid-scenario

Postby Samonella » October 12th, 2016, 10:28 pm

So apparently goto micro_ais don't work if there is shroud blocking the path? the wiki doesn't say anything about shroud, so it took me forever to figure out that it was the cause of certain destinations not working while others did for the very same micro_ai. I removed shroud=yes from the side's definition (not sure why I had it there in the first place), and all the problems disappeared. Anyway, this is a bug, right? This page says that the ai should completely ignore shroud and fog.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Adding events mid-scenario

Postby Celtic_Minstrel » October 12th, 2016, 10:46 pm

...what? No, the AI should not ignore shroud and fog, in general. (Presumably it used to and that wiki page was never updated.) I guess the goto micro_ai is one place where you might want it to ignore shroud, though; perhaps a key should be added to allow it to do so. (That said, if the path is blocked by shroud, I'd expect it to somehow guess the direction to go - generally it's aiming for a specific location, so the shortest path should be sufficient, I'd think, and that would eventually result in the shroud being cleared.)
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
User avatar
Celtic_Minstrel
Developer
 
Posts: 754
Joined: August 3rd, 2012, 11:26 pm

Re: Adding events mid-scenario

Postby mattsc » October 13th, 2016, 2:16 am

Samonella: Ah, that's interesting. Apparently we never thought of testing the Micro AIs with shroud on, so thanks for trouble shooting this and pointing it out. It's due to how the Goto MAI (and probably others, I need to check that) is set up and a limitation of the current Lua interface (all the Micro AIs are written in Lua).
Spoiler:

So, I'll add a note to the Micro AI wiki page that MAIs generally won't work correctly for shrouded sides. We'll also add an on-screen message that warns the scenario designer when trying to use a Micro AI for a shrouded side.

Samonella wrote:This page says that the ai should completely ignore shroud and fog.

That depends what you mean with should here. It's not like this is a design goal or something. It's just that some functionality of the default AI does not work with shroud. Fog and invisible units are generally respected, I think, although there might be some exceptions.

Thanks again for pointing this out.
mattsc
 
Posts: 951
Joined: October 13th, 2010, 6:14 pm
Location: Canada

Re: Adding events mid-scenario

Postby Samonella » October 13th, 2016, 6:00 am

mattsc wrote:Thanks again for pointing this out.

My genuine pleasure. :D
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Vengeance of a Drake: an RPG
Samonella
 
Posts: 281
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: move_unit question

Postby Sapient » October 13th, 2016, 7:30 am

Samonella wrote:What I want to do is similar to [move_unit], but rather than move the unit all the way to the destination, only move him one turn's distance toward it. I could manage this by using [find_path], but as far as I can tell I would have to check each [step] until finding the last one such that required_turns=1. This seems like a poor solution, especially since I'll be doing this many times for many units.


As you said, you can easily find that information in the [find_path] [step] array... and taking a few peeks into that array should be very speedy, especially when compared to the far greater expense of the initial pathfinding.

However it seems you already solved your problem with micro ai, so congrats. ;)
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Sapient
Developer
 
Posts: 4360
Joined: November 26th, 2005, 7:41 am

Next

Return to WML Workshop

Who is online

Users browsing this forum: No registered users and 1 guest