Abilities clause
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.
- hermestrismi
- Posts: 626
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Abilities clause
Hi.
It has been months since the last time I had been here.
Anyway. I created a [dummy] ability, with an event inside its macro, and I used it for both [unit_type] and [modifications] (to add it to another unit) but for some reasons the ability works for the unit_type but only shows its name and description when I used it inside any new created unit (via [unit] [modifications]
And for the unit
I think that the problem is related to [+abilities] so i need to be sure how to implent it correcrly
It has been months since the last time I had been here.
Anyway. I created a [dummy] ability, with an event inside its macro, and I used it for both [unit_type] and [modifications] (to add it to another unit) but for some reasons the ability works for the unit_type but only shows its name and description when I used it inside any new created unit (via [unit] [modifications]
Code: Select all
#define ABILITY_EXPLOSION_DEATH
[dummy]
id=explo_death
name=_"explosion"
description=_".."
[/dummy]
[/abilities]
[event]
...
[/event]
[+abilities]
Code: Select all
[unit]
...
[modifications]
[object]
[effect]
apply_to=new_ability
[abilities]
{ABILITY_EXPLOSION_DEATH}
[/abilities]
[/effect]
[/object]
[/modifications]
[/unit]
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
Re: Abilities clause
You don't need to use [+abilities], use:
or
[+abilities] is for:
Code: Select all
[abilities]
MACRO>
keys of ability
[/abilities]
[abilities]
<MACRO
[/abilities]
Code: Select all
MACRO>
[abilities]
keys of ability
[/abilities]
<MACRO
Code: Select all
[abilities]
some keys
[/abilities]
MACRO>
[+abilities]
more keys of the SAME ability, or the same keys which will replace the previous keys with the new values
[/abilities]
<MACRO
Re: Abilities clause
You cant support both modifications and unit_type at the same time. In order to place [event] under [unit] you need to handle
[/abilities]
[/effect]
[/object]
[/modifications]
In order to place [event] under [unit_type] you need to handle
[/abilities]
So macro for first use case would have
[/dummy]
[/abilities]
[/effect]
[/object]
[/modifications]
[event]
...
[/event]
[+modifications]
[+object]
[+effect]
[+abilities]
[/abilities]
[/effect]
[/object]
[/modifications]
In order to place [event] under [unit_type] you need to handle
[/abilities]
So macro for first use case would have
[/dummy]
[/abilities]
[/effect]
[/object]
[/modifications]
[event]
...
[/event]
[+modifications]
[+object]
[+effect]
[+abilities]
Re: Abilities clause
You only describe first point of https://wiki.wesnoth.org/SyntaxWML#Tag_Amendment_Syntax. Ability macros rely on second point, weapon special macros on third point too.Toranks wrote: ↑June 20th, 2023, 3:10 am You don't need to use [+abilities], use:
orCode: Select all
[abilities] MACRO> keys of ability [/abilities] [abilities] <MACRO [/abilities]
[+abilities] is for:Code: Select all
MACRO> [abilities] keys of ability [/abilities] <MACRO
Code: Select all
[abilities] some keys [/abilities] MACRO> [+abilities] more keys of the SAME ability, or the same keys which will replace the previous keys with the new values [/abilities] <MACRO
- hermestrismi
- Posts: 626
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: Abilities clause
I tried many ways to implent it but still the same problemRavana wrote: ↑June 20th, 2023, 6:32 amYou only describe first point of https://wiki.wesnoth.org/SyntaxWML#Tag_Amendment_Syntax. Ability macros rely on second point, weapon special macros on third point too.Toranks wrote: ↑June 20th, 2023, 3:10 am You don't need to use [+abilities], use:
orCode: Select all
[abilities] MACRO> keys of ability [/abilities] [abilities] <MACRO [/abilities]
[+abilities] is for:Code: Select all
MACRO> [abilities] keys of ability [/abilities] <MACRO
Code: Select all
[abilities] some keys [/abilities] MACRO> [+abilities] more keys of the SAME ability, or the same keys which will replace the previous keys with the new values [/abilities] <MACRO
Ps: I took this ability from RotL in case there is a problem with the event
the macro file
the modified unit
PS2: playing wesnoth for yeeeeaars and I realised only now that an ability cannot added to both modifications and unit_type loooool
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
Re: Abilities clause
As https://wiki.wesnoth.org/SingleUnitWML says A [unit][event] requires a non-empty id= attribute.
Re: Abilities clause
I tested that this successfully poisons units. (wesnoth -p your code snippets, remove wrapping pre event for easier testing, update x,y to be on map, add id)
Code: Select all
# lua wesnoth.require("wml-utils").handle_event_commands(wml.load("~add-ons/EventLoader/action.cfg"))
[unit]
id="CortonNecromancertest"
name=_"Corton"
side=1
type="Dark Adept"
x=14
y=21
[modifications]
[object]
[effect]
apply_to="new_ability"
[abilities]
[dummy]
description=_"When this unit is destroyed, a toxic gas is unleashed, poisoning all surrounding enemy units in the process. Non-living units are immune."
id="ROLpoisoning"
name=_"poisoning"
[/dummy]
[/abilities]
[/effect]
[/object]
[/modifications]
[event]
first_time_only=no
name="die"
id="_"
[filter]
ability="ROLpoisoning"
[/filter]
[store_unit]
kill=no
variable="units"
[filter]
[filter_adjacent]
x="$x1"
y="$y1"
[/filter_adjacent]
[not]
[filter_wml]
[status]
not_living=yes
[/status]
[/filter_wml]
[/not]
[and]
[not]
side="$unit.side"
[/not]
[/and]
[/filter]
[/store_unit]
[set_variable]
name="i"
value=0
[/set_variable]
[while]
[variable]
less_than="$units.length"
name="i"
[/variable]
[do]
[set_variable]
name="units[$i].status.poisoned"
value=yes
[/set_variable]
[unstore_unit]
color="255,0,0"
find_vacant=no
text=_"poisoned"
variable="units[$i]"
[/unstore_unit]
[set_variable]
add=1
name="i"
[/set_variable]
[/do]
[/while]
[clear_variable]
name="i"
[/clear_variable]
[kill]
x="$x1"
y="$y1"
[/kill]
[/event]
[/unit]
- hermestrismi
- Posts: 626
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: Abilities clause
thank youRavana wrote: ↑June 20th, 2023, 4:35 pm I tested that this successfully poisons units. (wesnoth -p your code snippets, remove wrapping pre event for easier testing, update x,y to be on map, add id)
Code: Select all
# lua wesnoth.require("wml-utils").handle_event_commands(wml.load("~add-ons/EventLoader/action.cfg")) [unit] id="CortonNecromancertest" name=_"Corton" side=1 type="Dark Adept" x=14 y=21 [modifications] [object] [effect] apply_to="new_ability" [abilities] [dummy] description=_"When this unit is destroyed, a toxic gas is unleashed, poisoning all surrounding enemy units in the process. Non-living units are immune." id="ROLpoisoning" name=_"poisoning" [/dummy] [/abilities] [/effect] [/object] [/modifications] [event] first_time_only=no name="die" id="_" [filter] ability="ROLpoisoning" [/filter] [store_unit] kill=no variable="units" [filter] [filter_adjacent] x="$x1" y="$y1" [/filter_adjacent] [not] [filter_wml] [status] not_living=yes [/status] [/filter_wml] [/not] [and] [not] side="$unit.side" [/not] [/and] [/filter] [/store_unit] [set_variable] name="i" value=0 [/set_variable] [while] [variable] less_than="$units.length" name="i" [/variable] [do] [set_variable] name="units[$i].status.poisoned" value=yes [/set_variable] [unstore_unit] color="255,0,0" find_vacant=no text=_"poisoned" variable="units[$i]" [/unstore_unit] [set_variable] add=1 name="i" [/set_variable] [/do] [/while] [clear_variable] name="i" [/clear_variable] [kill] x="$x1" y="$y1" [/kill] [/event] [/unit]
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin