set_accuracy and increase_accuracy inside an effect tag

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
Argesilao2
Posts: 126
Joined: February 18th, 2020, 9:28 pm
Location: Piciule Patrie

set_accuracy and increase_accuracy inside an effect tag

Post by Argesilao2 »

I'm trying to create a unit with a ranged attack that blinds the opponent until their next turn, in Bfw 1.19.4.

this is the attack code:

Code: Select all

	[attack]
        name=lightbeam
        description=_"lightbeam"
        type=arcane
        range=ranged
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
	    {WEAPON_SPECIAL_FLASH} #<----------------
        [/specials]
        damage=1
        number=1
    [/attack]
this is the code of the WEAPON_SPECIAL_FLASH:

Code: Select all

	#define WEAPON_SPECIAL_FLASH
	[dummy]
		id=flash
		name=_"flash"
		description=_"When hits this attack temporarily reduces at 10% the opponent's ability to hit an enemy."
		special_note=_"This attack blind the enemy for a short time, significantly reducing its ability to hit the enemy and its vision range."
	[/dummy]
#enddef
and then I insert these events in the [unit_type] tag

Code: Select all

	
	[event]
		name=attacker hits
		first_time_only=no
		[filter_attack]
			special_id=flash
		[/filter_attack]
		[object]
			[filter]
				id=$second_unit.id
			[/filter]
			duration=turn
			[effect]
				apply_to=attack
				range=melee,ranged
				set_accuracy=-10 #<--------------- LOOK THIS
			[/effect]
			[effect]
				apply_to=vision
				set=1
			[/effect]
			[effect]
				apply_to=status
				add=blind
			[/effect]
			[effect]
				apply_to=halo
				halo="misc/blind-icon.png"
			[/effect]
		[/object]
	[/event]
	
	[event]
		name=defender hits
		first_time_only=no
		[filter_second_attack]
			special_id=flash
		[/filter_second_attack]
		[object]
			[filter]
				id=$unit.id
			[/filter]
			duration=turn
			[effect]
				apply_to=attack
				range=melee,ranged
				set_accuracy=-10  #<--------------- LOOK THIS
			[/effect]
			[effect]
				apply_to=vision
				set=1
			[/effect]
			[effect]
				apply_to=status
				add=blind
			[/effect]
			[effect]
				apply_to=halo
				halo="misc/blind-icon.png"
			[/effect]
		[/object]
	[/event]
	
the problem is this one: using the set_accuracy command in the indicated line I get that the blinded unit's attack has a hit probability decreased by 10%.
Instead, if I replace the set_accuracy command with the increase_accuracy command, with the same value, I get that the hit probability for the blinded unit is 10%.

In short, the set_accuracy it does what increase_accuracy is supposed to do, and vice versa.
User avatar
Ravana
Forum Moderator
Posts: 3314
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: set_accuracy and increase_accuracy inside an effect tag

Post by Ravana »

Assuming this attack did not have accuracy before, add and set have same result.
User avatar
Argesilao2
Posts: 126
Joined: February 18th, 2020, 9:28 pm
Location: Piciule Patrie

Re: set_accuracy and increase_accuracy inside an effect tag

Post by Argesilao2 »

I did some testing, and here are the results:

set_accuracy and increase_accuracy works in the same way and makes the same thing;
both commands work like an increase_accuracy; Ravana is right, the vice versa at the end of my post was my fault. :oops:

increase_accuracy doesn't work if I assign a value in percentage terms (i.e. -10% instead of -10), but, curiously, set_accuracy works, always like increase_accuracy, even with percentage values. :o

That's all.
User avatar
Ravana
Forum Moderator
Posts: 3314
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: set_accuracy and increase_accuracy inside an effect tag

Post by Ravana »

-10% of 0 is 0, so that is correct.
User avatar
Argesilao2
Posts: 126
Joined: February 18th, 2020, 9:28 pm
Location: Piciule Patrie

Re: set_accuracy and increase_accuracy inside an effect tag

Post by Argesilao2 »

Ok.

I had misunderstood the use of accuracy.

Thank you.
Post Reply