Xalzar's WML Headaches
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.
- skeptical_troll
- Posts: 500
- Joined: August 31st, 2015, 11:06 pm
Re: Xalzar's WML Headaches
This could be quite slow but a way is:
start from the border scanning the whole map with [filter_radius] which avoids your units, obtaining a huge array.
Than store all locations which are not in that array and don't have one of your units. It should give what you want, I think.
start from the border scanning the whole map with [filter_radius] which avoids your units, obtaining a huge array.
Than store all locations which are not in that array and don't have one of your units. It should give what you want, I think.
Re: Xalzar's WML Headaches
To be safe, you should use the map edges since some maps don't have borders.
Something like this should work I think:
Something like this should work I think:
Code: Select all
[store_map_dimensions]
[/store_map_dimensions]
[store_locations]
[not]
x=1
[or]
y=1
[/or]
[or]
x=$map_size.width
[/or]
[or]
y=$map_size.height
[/or]
[not]
[filter]
# put encirclement-type unit filter here
[/filter]
[/not]
radius="$($map_size.width * $map_size.height)"
[filter_radius]
[not]
[filter]
# put encirclement-type unit filter here
[/filter]
[/not]
[/filter_radius]
[/not]
[not]
[filter]
# put encirclement-type unit filter here
[/filter]
[/not]
variable=encircled
[/store_locations]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Xalzar's WML Headaches
Hi again! So, I've run into a problem and I don't find the solution anywhere.
I have a weapon special "dummy" with an event incorporated (multiple events really, but it's irrelevant).
I'm still working on it to make it work properly, but it functions if I put the special in a unit's attack.
I also have an AMLA system which adds, removes, changes attacks and other unit parameters.
If I try to add an attack with that weapon special, there's an error which says like this: "closing tag [/attack] not valid for [effect] tag etc.".
Now, the special structure is like this:
If I remove [/attack] and [+attack] the error is solved, but I get the attack with a "dummy" special and no event.
I've never understood how [/x] [+x] tags work in abilities, so I've always just copied from preexisting works (seriously, where it is written how do they work?).
So, apparently events in abilities and specials are not supported inside [effect]? How can I include these "special" specials in AMLAs or other instances of [effect]?
Side question: does the effect of traits apply only on unit creation? Example: strong trait adds melee damage only on attacks already present and not on attacks gained afterwards? 'Cause it seems that way.
I have a weapon special "dummy" with an event incorporated (multiple events really, but it's irrelevant).
I'm still working on it to make it work properly, but it functions if I put the special in a unit's attack.
I also have an AMLA system which adds, removes, changes attacks and other unit parameters.
If I try to add an attack with that weapon special, there's an error which says like this: "closing tag [/attack] not valid for [effect] tag etc.".
Now, the special structure is like this:
Code: Select all
[dummy]
...
[/dummy]
[/specials]
[/attack]
[event]
1
...
[fire_event]
3
[/fire_event]
[fire_event]
5
[/fire_event]
[remove_event]
id=3,5
[/remove_event]
[/event]
[event]
2
...
[fire_event]
id=4
[/fire_event]
[fire_event]
id=5
[/fire_event]
[/then]
[remove_event]
id=4,5
[/remove_event]
[/event]
[event]
3...
[/event]
[event]
4...
[/event]
[event]
5...
[/event]
[+attack]
[+specials]
I've never understood how [/x] [+x] tags work in abilities, so I've always just copied from preexisting works (seriously, where it is written how do they work?).
So, apparently events in abilities and specials are not supported inside [effect]? How can I include these "special" specials in AMLAs or other instances of [effect]?
Side question: does the effect of traits apply only on unit creation? Example: strong trait adds melee damage only on attacks already present and not on attacks gained afterwards? 'Cause it seems that way.
Re: Xalzar's WML Headaches
I think using
It makes sense if used like this:
where the ABILITY_AE_MAG_FURY needs to expand to both a [dummy] tag inside the [abilities] tag, and also to an [event] tag outside the [abilities] tag. So the macro uses
[/x][+x]
is probably some evil that started as a way to make macros look nice, using the SyntaxWML#Tag_Amendment_Syntax. Avoid using it unless you have to.It makes sense if used like this:
Code: Select all
[unit_type]
id=AE_mag_Blood_Warrior
name= _ "Blood Warrior"
race=orc
...
[abilities]
{ABILITY_AE_MAG_FURY}
[dummy]
id=AE_mag_bloodlust_5
name= _ "bloodlust +5"
description=_"This is some other ability that's unrelated to the Fury ability."
[/dummy]
[/abilities]
...
[/abilities][event]...[/event][+abilities]
to add its event and then reopen the [abilities] tag so that any other ability, such as Bloodlust, is still in what looks like the same [abilities] tag.Re: Xalzar's WML Headaches
I won't say it is evil for all the cases, consider the next example:octalot wrote: ↑June 7th, 2019, 9:09 am I think using[/x][+x]
is probably some evil that started as a way to make macros look nice, using the SyntaxWML#Tag_Amendment_Syntax. Avoid using it unless you have to.
Code: Select all
{GENERIC_UNIT 1 Footpad $x1 $y1}
[+unit]
gender=female
[/unit]
It is not related to the
effect
. event
is not supported in abilities or specials at all. However, as octalot pointed out, there is a way to make it look like the event is defined inside those tags by using the amendment syntax inside macroses.The wiki says:
You can't include events in AMLAs or effects. You could include them inThe [event] Tag
This tag is a subtag of the [scenario], [unit_type] and [era]
scenario
, unit_type
or era
, depending on the add-on type (SP/MP) and availability of the weapon special (available to any unit or only to a specific unit type).I can confirm that. I am not sure if it will be easy to fix, since it is not obvious what effect must go first in a general case. Considering that effects may change a lot of different things and custom traits are also possible.
Author of SP scenario Dragon Fight and SP campaign Captured by a Nightmare.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.
Re: Xalzar's WML Headaches
Thank you both for the pointers! Now I understand [/x] and [+x] tags and why it gives me error, expecially in light of:
I tried to add [/effect] [+effect] and then [/advancement] [+advancement] and then [/unit_type] [+unit_type] but then [unit] gave me the problem so I decided to stop...
That almost worked though!
Followup question: how can I give the possibility to customize recruitable (or just-recruited) units to players and AI alike? I used AMLAs because AI is able to use those but if there is something better which gives no problems with events inside abilities I'm all ears.
which I mistakenly totally didn't think relevant in this case.The [event] Tag
This tag is a subtag of the [scenario], [unit_type] and [era]
I tried to add [/effect] [+effect] and then [/advancement] [+advancement] and then [/unit_type] [+unit_type] but then [unit] gave me the problem so I decided to stop...
That almost worked though!
Followup question: how can I give the possibility to customize recruitable (or just-recruited) units to players and AI alike? I used AMLAs because AI is able to use those but if there is something better which gives no problems with events inside abilities I'm all ears.
Re: Xalzar's WML Headaches
For a human player you probably want aXalzar wrote: ↑June 7th, 2019, 1:56 pm Followup question: how can I give the possibility to customize recruitable (or just-recruited) units to players and AI alike? I used AMLAs because AI is able to use those but if there is something better which gives no problems with events inside abilities I'm all ears.
recruit
event that opens a dialog box with available customizations. See message
and option
https://wiki.wesnoth.org/InterfaceActio ... message.5D For an AI player you could also use a
recruit
event, but instead of a dialog box there should be a scripted logic. The logic may be deterministic or it may use RNG to introduce some diversity.Author of SP scenario Dragon Fight and SP campaign Captured by a Nightmare.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.
Re: Xalzar's WML Headaches
Thanks again!
Yeah it was my first choice since it's more elegant and easier to implement for human players than other options. But in the end...sergey wrote: ↑June 7th, 2019, 2:37 pm For a human player you probably want arecruit
event that opens a dialog box with available customizations. Seemessage
andoption
https://wiki.wesnoth.org/InterfaceActio ... message.5D
...AMLAs were chosen because it seemed easier to implement for AI players (while being decent for humans), but maybe with some clever logics I can mimic sensible choices for our future overlords. I'll definitively study more AIWML and similar pages to see if something there could help me.
Re: Xalzar's WML Headaches
By default the AI chooses advancements randomly, at least it is writtent here https://github.com/wesnoth/wesnoth/blob ... pp#L35-L36
I suggest you to stick with a similar approach and don't end up creating a skynet If you know scenario conditions in beforehand (AI units, player units, map, etc) you could tweak your AI with a relatively simple code. Anyway, you probably want your code to be as simple as possible, to make it testable and maintainable.
Author of SP scenario Dragon Fight and SP campaign Captured by a Nightmare.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.
Re: Xalzar's WML Headaches
You can use the dummy ability as a filter for the event, and then put the event itself in whichever of [scenario], [unit_type] or [era] seems easiest. For example, the AE_mag_bloodlust_5 ability. The ability itself is a dummy one, but there's a [die] event which uses [filter_second] to only trigger when the killer has the ability (in
die
events the killer is the second unit).Code: Select all
[event]
name=die
id=AE_mag_bonecollector_bloodwarrior_event
first_time_only=no
[filter]
[not]
race=undead
[or]
race=mechanical
[/or]
[or]
race=AE_mag_magical
[/or]
[/not]
[/filter]
[filter_second]
ability=AE_mag_bloodlust_5
[/filter_second]
[delay]
time=100
[/delay]
[heal_unit]
[filter]
x,y=$x2,$y2
[/filter]
amount=5
animate=yes
[/heal_unit]
[/event]
Re: Xalzar's WML Headaches
Thanks again!
But yeah, a recruit event for AIs with random choice of customization corrected by gold availability, previous recruitment choices and preselected AI behaviour is what I'm thinking now.
Eheh...
Yeah, that's what I was realizing I have to do ultimately. Even if I switch to message-options instead of AMLAs, [effect] is always in the way so the special events need to be incorporated in the unit. Also, there would be essentially no difference from now (in terms of code weight) since the [advancement]s are already written in the unit code, including the event (even if it does not exist in the game because the corresponding special is not selected)...so, better have it written where it does work.
Unfortunately I cannot use variations since the customization is quite complex and I would need dozens of variations (often even more) per unit.octalot wrote: ↑June 7th, 2019, 11:19 pm The implementation of the RECRUIT_UNIT_VARIATIONS macro shows how to add a random [effect] to recruited units.
But yeah, a recruit event for AIs with random choice of customization corrected by gold availability, previous recruitment choices and preselected AI behaviour is what I'm thinking now.
Re: Xalzar's WML Headaches
Quick question: how can I avoid triggering an event if the side is controlled by AI if the 'controller' key of a StandardSideFilter is disabled in MP?
https://wiki.wesnoth.org/StandardSideFilter
The premise of this problem is that the AI side is not fixed necessarily (so I can't filter for the side number), and the AI side doesn't need messages with options (which the human players can see and interact with! ) but specifically tailored different events.
https://wiki.wesnoth.org/StandardSideFilter
The premise of this problem is that the AI side is not fixed necessarily (so I can't filter for the side number), and the AI side doesn't need messages with options (which the human players can see and interact with! ) but specifically tailored different events.
Re: Xalzar's WML Headaches
Whether side is AI or not depends on who looks - 1.14 decided that it is private information whether side is played by AI or something else.
I guess you need something like to ask playing side whether it is AI.
I guess you need something like
Code: Select all
local is_ai = wesnoth.synchronize_choice(
function()
return false
end,
function()
return true
end)
Re: Xalzar's WML Headaches
@Ravana: Thanks! But...is Lua the only solution, really? And it really does not cause OOS?
The problem is that I've never learned Lua and I am unable to try to do it at the moment, due to time constraints. But I'd really like a quick fix to ease testing my code without constantly manually clicking the options for the AI.
In case there is no other way, I'd like to know...is that code workable? How should I insert it in my code? (I need it inside an [event])
The problem is that I've never learned Lua and I am unable to try to do it at the moment, due to time constraints. But I'd really like a quick fix to ease testing my code without constantly manually clicking the options for the AI.
In case there is no other way, I'd like to know...is that code workable? How should I insert it in my code? (I need it inside an [event])