Weapon special code not working as intended

The place to post your WML questions and answers.

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.
Post Reply
User avatar
Nyanyanyan
Posts: 73
Joined: May 11th, 2018, 10:40 pm

Weapon special code not working as intended

Post by Nyanyanyan »

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:

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
I tried converting it into an ability and that seems to work more or less:

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]
But of course I'd rather have it as a special.
Any help would be appreciated.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
User avatar
Nyanyanyan
Posts: 73
Joined: May 11th, 2018, 10:40 pm

Re: Weapon special code not working as intended

Post by Nyanyanyan »

Ravana wrote: November 2nd, 2019, 2:01 pm You could check if https://github.com/ProditorMagnus/Agele ... uprise.cfg works for you.
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.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Weapon special code not working as intended

Post by Ravana »

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).
User avatar
Nyanyanyan
Posts: 73
Joined: May 11th, 2018, 10:40 pm

Re: Weapon special code not working as intended

Post by Nyanyanyan »

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.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Weapon special code not working as intended

Post by Ravana »

[event] is not valid subtag of [attack].

So
[/dummy]
[/specials]
[/attack]
should be used.
User avatar
Celtic_Minstrel
Developer
Posts: 2214
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Weapon special code not working as intended

Post by Celtic_Minstrel »

By undetected, you mean due to a [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]
Untested, might have a wrong key somewhere.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Weapon special code not working as intended

Post by Ravana »

[object] has limitation of "The first unit found that matches the filter will be given the object."
User avatar
Celtic_Minstrel
Developer
Posts: 2214
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Weapon special code not working as intended

Post by Celtic_Minstrel »

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]
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Nyanyanyan
Posts: 73
Joined: May 11th, 2018, 10:40 pm

Re: Weapon special code not working as intended

Post by Nyanyanyan »

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:

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.
Post Reply