Recruited units gain object that adds a special to all their attacks
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.
- DopeKiwiWarrior
- Posts: 30
- Joined: January 27th, 2013, 4:04 pm
- Location: Inside your mom, she ate me, send help before I dissolve.
Recruited units gain object that adds a special to all their attacks
Basically I have created an 'attackspeed' leadership aura called fervor. The unit who has it adds 33% to number of attacks of units around. It works around a dummy ability and a weapon special that checks for it. This part works.
However, I need every unit recruited in the game to be affectable by this ability. I found out I should do it through an object in a recruit event (and in prestart for leaders) but I couldn't figure it out so I have two questions:
However, I need every unit recruited in the game to be affectable by this ability. I found out I should do it through an object in a recruit event (and in prestart for leaders) but I couldn't figure it out so I have two questions:
- How to create an object that adds a weapon special to all of its bearer's attacks?
- How to give this object to every leader and every new recruited unit?
Creator of Moonday Era, go check it out! (And critique the hell out of it, because it needs it.)
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Recruited units gain object that adds a special to all their attacks
1. There is a [set_specials] tag in [effect] that does that.
2. For 1.12, You need to use two events. One event has name=recruit,recall and gives the object to $unit. It needs to go into every scenario, so make it a macro that you can include. It will take care of all recruited units and leaders too, after the first scenario. In the first scenario, you also need a start event that gives the object to every unit on the map in order to give one to the leaders initially. (During prestart, I'm pretty sure the leaders can't be affected yet, so that may be part of your problem.)
2. For 1.13, you can just use an [event] with name=unit_placed, and it will take care of everything.
2. For 1.12, You need to use two events. One event has name=recruit,recall and gives the object to $unit. It needs to go into every scenario, so make it a macro that you can include. It will take care of all recruited units and leaders too, after the first scenario. In the first scenario, you also need a start event that gives the object to every unit on the map in order to give one to the leaders initially. (During prestart, I'm pretty sure the leaders can't be affected yet, so that may be part of your problem.)
2. For 1.13, you can just use an [event] with name=unit_placed, and it will take care of everything.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
- DopeKiwiWarrior
- Posts: 30
- Joined: January 27th, 2013, 4:04 pm
- Location: Inside your mom, she ate me, send help before I dissolve.
Re: Recruited units gain object that adds a special to all their attacks
First of all, thanks.beetlenaut wrote: ↑February 26th, 2018, 5:04 am 1. There is a [set_specials] tag in [effect] that does that.
2. For 1.12, You need to use two events. One event has name=recruit,recall and gives the object to $unit. It needs to go into every scenario, so make it a macro that you can include. It will take care of all recruited units and leaders too, after the first scenario. In the first scenario, you also need a start event that gives the object to every unit on the map in order to give one to the leaders initially. (During prestart, I'm pretty sure the leaders can't be affected yet, so that may be part of your problem.)
2. For 1.13, you can just use an [event] with name=unit_placed, and it will take care of everything.
But
- I know about it, but doesn't it affect only the first attack it finds? I want it to apply to every attack of that unit.
- I might have been unclear - I know all the tools, I just need to structure it so the object gets given to the right unit and does what I want. I should have posted the code but right now I can't. I'll try the start event.
Creator of Moonday Era, go check it out! (And critique the hell out of it, because it needs it.)
- James_The_Invisible
- Posts: 534
- Joined: October 28th, 2012, 1:58 pm
- Location: Somewhere in the Northlands, fighting dark forces
- Contact:
Re: Recruited units gain object that adds a special to all their attacks
It should affect all matching attacks. If you want it to be applied to all attacks, you do not have to use any filter.doesn't it affect only the first attack it finds? I want it to apply to every attack of that unit.
My content: For Power series
Ports: Danse Macabre Story of the Wose
Guides: How to translate your UMC
Ports: Danse Macabre Story of the Wose
Guides: How to translate your UMC
- DopeKiwiWarrior
- Posts: 30
- Joined: January 27th, 2013, 4:04 pm
- Location: Inside your mom, she ate me, send help before I dissolve.
Re: Recruited units gain object that adds a special to all their attacks
Alright, thanks. Would you be able to help with my second point?James_The_Invisible wrote: ↑February 26th, 2018, 9:46 amIt should affect all matching attacks. If you want it to be applied to all attacks, you do not have to use any filter.doesn't it affect only the first attack it finds? I want it to apply to every attack of that unit.
Creator of Moonday Era, go check it out! (And critique the hell out of it, because it needs it.)
- James_The_Invisible
- Posts: 534
- Joined: October 28th, 2012, 1:58 pm
- Location: Somewhere in the Northlands, fighting dark forces
- Contact:
Re: Recruited units gain object that adds a special to all their attacks
About code structure? Should look like this:
If the object should be applied to multiple units, you need to store them via [store_unit] to a variable and then iterate over it:
Code: Select all
[event]
name=...
[object]
silent=yes # not needed on Wesnoth 1.13 if you do not use description (and name?) attribute
[filter]
# somehow specify unit the object should be applied to. only first matching unit is actually given the object
[/filter]
[effect]
apply_to=attack
[set_specials]
mode=append # omit this line if you want to replace existing weapon specials
{WEAPON_SPECIAL_X} # does not need to be a macro
[/set_specials]
[/effect]
[/object]
[/event]
Code: Select all
[store_unit]
[filter]
# some filter
[/filter]
variable=x
[/store_unit]
{FOREACH x i}
[object]
[filter]
id=$x[$i].id
[/filter]
...
[/object]
{NEXT i}
{CLEAR_VARIABLE x}
My content: For Power series
Ports: Danse Macabre Story of the Wose
Guides: How to translate your UMC
Ports: Danse Macabre Story of the Wose
Guides: How to translate your UMC
- DopeKiwiWarrior
- Posts: 30
- Joined: January 27th, 2013, 4:04 pm
- Location: Inside your mom, she ate me, send help before I dissolve.
Re: Recruited units gain object that adds a special to all their attacks
Code: Select all
#define ABILITY_FERVOR
[dummy]
id=fervor aura
name= _ "fervor aura"
description= _ "lol"
[/dummy]
#enddef
#define WEAPON_SPECIAL_LATENT_FERVOR
[attacks]
[filter_self]
[filter_adjacent]
ability=fervor aura
[/filter_adjacent]
[/filter_self]
id=latent fervor
name= _ "fervor"
name_inactive = "fervor"
description= _ "This unit is affected by fervor, it attacks 33% more times."
multiply=1.34
[/attacks]
#enddef
#define FERVOR_GIVER
[event]
name=recruit
first_time_only=no
[if]
[not]
[have_unit]
id=$unit.id
ability=fervor aura
[/have_unit]
[/not]
[then]
[modify_unit]
[filter]
id=$unit.id
[/filter]
[object]
silent=no
[effect]
[attack]
[set_specials]
mode=append
[specials]
{WEAPON_SPECIAL_LATENT_FERVOR}
[/specials]
[/set_specials]
[/attack]
[/effect]
description="[censored] object"
[/object]
[/modify_unit]
[/then]
[/if]
[/event]
[event]
name=start
[store_unit]
[filter]
canrecruit=yes
[/filter]
variable=leaders
[/store_unit]
{FOREACH leaders i}
[if]
[not]
[have_unit]
id=$leaders[$i].id
ability=fervor aura
[/have_unit]
[/not]
[then]
[modify_unit]
[filter]
id=$leaders[$i].id
[/filter]
[object]
silent=yes
[effect]
[attack]
[set_specials]
mode=append
[specials]
{WEAPON_SPECIAL_LATENT_FERVOR}
[/specials]
[/set_specials]
[/attack]
[/effect]
[/object]
[/modify_unit]
[/then]
[/if]
{NEXT i}
[clear_variable]
name=leaders
[/clear_variable]
[/event]
#enddef
- The object is only given to the leaders
- The ability works always and doesn't filter for adjacent units
- The weapon special isn't shown, either active or inactive, on units that obtained it through the object
Creator of Moonday Era, go check it out! (And critique the hell out of it, because it needs it.)
- James_The_Invisible
- Posts: 534
- Joined: October 28th, 2012, 1:58 pm
- Location: Somewhere in the Northlands, fighting dark forces
- Contact:
Re: Recruited units gain object that adds a special to all their attacks
About the third issue, you have got the [effect] part wrongly. There should not be nested [attack] tag, you have to use apply_to=attack.
I have never used [object] inside [modify_unit] so I have no idea whether there is a problem. Did you try to insert the object without the [modify_unit] (that is just [object] with [filter])?
I have never used [object] inside [modify_unit] so I have no idea whether there is a problem. Did you try to insert the object without the [modify_unit] (that is just [object] with [filter])?
My content: For Power series
Ports: Danse Macabre Story of the Wose
Guides: How to translate your UMC
Ports: Danse Macabre Story of the Wose
Guides: How to translate your UMC
- DopeKiwiWarrior
- Posts: 30
- Joined: January 27th, 2013, 4:04 pm
- Location: Inside your mom, she ate me, send help before I dissolve.
Re: Recruited units gain object that adds a special to all their attacks
I got it wrong in nesting a [specials] tag in there too. Also I got it wrong that it only gets given to leaders when in reality they were just that more powerful than the regular units. After removing the unnecessary specials tag, it works. Thanks for the help.James_The_Invisible wrote: ↑February 26th, 2018, 7:40 pm About the third issue, you have got the [effect] part wrongly. There should not be nested [attack] tag, you have to use apply_to=attack.
I have never used [object] inside [modify_unit] so I have no idea whether there is a problem. Did you try to insert the object without the [modify_unit] (that is just [object] with [filter])?
Creator of Moonday Era, go check it out! (And critique the hell out of it, because it needs it.)
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Recruited units gain object that adds a special to all their attacks
You shouldn't really be using
[object]
inside [modify_unit]
unless you want the modification to disappear when the unit levels up. (Which is a perfectly valid use case, mind you.)