Weapon special code not working as intended
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.
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Weapon special code not working as intended
I tried making a weapon special for an assasssin type unit that doubles it's attack damage when it starts the turn undetected, but it doesn't seem to do anything.
This is the code I use:
I tried converting it into an ability and that seems to work more or less:
But of course I'd rather have it as a special.
Any help would be appreciated.
This is the code I use:
Code: Select all
#define WEAPON_SPECIAL_PREPARATION
[dummy]
id=assassprep
name=preparation
description="Is this unit starts their turn hidden, it will do double damage with this weapon"
active_on=offense
[/dummy]
[/specials]
[event]
name=side turn
[modify_unit]
[filter]
[has_attack]
special_id=assassprep
[/has_attack]
side=$side_number
[filter_vision]
visible=no
[filter_side]
[enemy_of]
side=$side_number
[/enemy_of]
[/filter_side]
[/filter_vision]
[/filter]
[object]
id=assassprepbonus
duration=turn_end
take_only_once=no
[effect]
apply_to=attack
increase_damage=100%
[/effect]
[/object]
[/modify_unit]
[/event]
[+specials]
#enddef
Code: Select all
#define ABILITY_PREPARATION
[dummy]
id=assassprep
[/dummy]
[/abilities]
[event]
name=side turn
[modify_unit]
[filter]
ability=assassprep
side=$side_number
[filter_vision]
visible=no
[filter_side]
[enemy_of]
side=$side_number
[/enemy_of]
[/filter_side]
[/filter_vision]
[/filter]
[object]
id=assassprepbonus
duration=turn_end
take_only_once=no
[effect]
apply_to=attack
increase_damage=100%
[/effect]
[/object]
[/modify_unit]
[/event]
Any help would be appreciated.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Weapon special code not working as intended
Thanks, but that's sadly not really what I'm looking for. With this, if I see this right, the attack bonus would not simply be removed at the end of the turn but instead be allowed to persist until the next turn. Of course you could change this with another event, but I don't really want to have this many turn end/start events running as it slows stuff down.Ravana wrote: ↑November 2nd, 2019, 2:01 pm You could check if https://github.com/ProditorMagnus/Agele ... uprise.cfg works for you.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Re: Weapon special code not working as intended
Then main issue is that your events are only allowed to fire once. Also make sure you are testing with 1.15.2 or newer (for special_id).
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Weapon special code not working as intended
Thanks, I didn't notice that at all.
Those weren't the actual reasons why the code failed though.
As I found out via trial and error, it seems that events from weapon specials simply aren't considered by the engine.
I put the exact event code (with your corrections) into an abilities tag and put it on the unit with the special and it worked exactly as intended.
Not sure if this is a bug or not, but it's kind of unintuitive this way.
Those weren't the actual reasons why the code failed though.
As I found out via trial and error, it seems that events from weapon specials simply aren't considered by the engine.
I put the exact event code (with your corrections) into an abilities tag and put it on the unit with the special and it worked exactly as intended.
Not sure if this is a bug or not, but it's kind of unintuitive this way.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Re: Weapon special code not working as intended
[event] is not valid subtag of [attack].
So
[/dummy]
[/specials]
[/attack]
should be used.
So
[/dummy]
[/specials]
[/attack]
should be used.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Weapon special code not working as intended
By undetected, you mean due to a
Untested, might have a wrong key somewhere.
[hides]
ability, right? Wouldn't this be doable with just a single event placed in the [unit_type]
? Something like this:Code: Select all
[event]
name=turn start
[filter]
type=Your_Assassin
[not]
status=uncovered
[/not]
[/filter]
[object]
duration=turn
[filter]
type=Your_Assassin
[not]
status=uncovered
[/not]
[/filter]
[effect]
apply_to=attack
increase_damage=100%
[/effect]
[/object]
[/event]
Re: Weapon special code not working as intended
[object] has limitation of "The first unit found that matches the filter will be given the object."
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Weapon special code not working as intended
Ahh, right, so you'd need to rearrange it slightly to use
[modify_unit]
:Code: Select all
[modify_unit]
[filter]
type=Your_Assassin
[not]
status=uncovered
[/not]
[/filter]
[object]
duration=turn
[effect]
apply_to=attack
increase_damage=100%
[/effect]
[/object]
[/modify_unit]
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Weapon special code not working as intended
Thanks, after closing the attack tag before the event and then reopening it, the whole thing works exactly as intended.
I didn't try the [unit_type] method since I really prefer to have all my ability/special text in my macros file since I may want to apply these things to more than one character and also want people to be able to copy stuff without wading through all my unit files.
Also, I think uncovered doesn't actually care about visibility, just actions taken (to prevent hiding). At least that's what it says on the wiki.
Here's the code in case anyone ever comes upon the same problem:
I didn't try the [unit_type] method since I really prefer to have all my ability/special text in my macros file since I may want to apply these things to more than one character and also want people to be able to copy stuff without wading through all my unit files.
Also, I think uncovered doesn't actually care about visibility, just actions taken (to prevent hiding). At least that's what it says on the wiki.
Here's the code in case anyone ever comes upon the same problem:
Code: Select all
#define WEAPON_SPECIAL_PREPARATION
[dummy]
id=assassprep
name=preparation
description="Is this unit starts their turn hidden, it will do double damage with this weapon"
active_on=offense
[/dummy]
[/specials]
[/attack]
[event]
name=side turn
id=assassprepevent
first_time_only=no
[modify_unit]
[filter]
[has_attack]
special=assassprep
[/has_attack]
side=$side_number
[filter_vision]
visible=no
[filter_side]
[enemy_of]
side=$side_number
[/enemy_of]
[/filter_side]
[/filter_vision]
[/filter]
[object]
id=assassprepbonus
duration=turn end
take_only_once=no
[effect]
apply_to=attack
special=assassprep
increase_damage=100%
[/effect]
[/object]
[/modify_unit]
[/event]
[+attack]
[+specials]
#enddef
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.