WML problem : weapon special : defense
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.
WML problem : weapon special : defense
Hello
I am planning to make this weapon_special for a mage unit which works in one of the two following ways:
First of all the attack always hits (well this is the easy part) and
a) ½ the defenders defense during the attack is added to the defenders resistance to the type of damage being dealt
b) the defenders defense is reduced from the damage directly, before resistance is normally applied
Example
So in otherwords we could have an attack doing 10 damage of type arcane, and a defender with 40% defense, 10% resistance to arcane.
In variation:
a) the chance to hit would be 100%, but defenders resistance would be 30%
10 damage * ((100 - (( 0.5 * 40 ) + 10))/100) or in simpler terms, 10 * 0.7 , 7 damage.
b) the chance to hit would be 100%, but damage would be reduced by 40% before resistances
in simpler terms 10 damage * 0.6 * 0.9 = 5.4 damage
Any ideas?
I am planning to make this weapon_special for a mage unit which works in one of the two following ways:
First of all the attack always hits (well this is the easy part) and
a) ½ the defenders defense during the attack is added to the defenders resistance to the type of damage being dealt
b) the defenders defense is reduced from the damage directly, before resistance is normally applied
Example
So in otherwords we could have an attack doing 10 damage of type arcane, and a defender with 40% defense, 10% resistance to arcane.
In variation:
a) the chance to hit would be 100%, but defenders resistance would be 30%
10 damage * ((100 - (( 0.5 * 40 ) + 10))/100) or in simpler terms, 10 * 0.7 , 7 damage.
b) the chance to hit would be 100%, but damage would be reduced by 40% before resistances
in simpler terms 10 damage * 0.6 * 0.9 = 5.4 damage
Any ideas?

Re: WML problem : weapon special : defense
I think you can do all of this manipulating stored unit data. According to this, store_unit stores resistance, defence, and attack. So you can just do an attacker hits event that will first heal the defender and then change his hp with store/unstore unit. It does sound a bit like a workaround though, perhaps there's a better way 

Oh, I'm sorry, did I break your concentration?
Re: WML problem : weapon special : defense
in an attack event store the location of the second unit ($x2,$y2)
http://wiki.wesnoth.org/InternalActions ... cations.5D
Then modify the units damage based on the defense of the second unit
then in an attack end event restore attack damage to normal.
http://wiki.wesnoth.org/InternalActions ... cations.5D
Then modify the units damage based on the defense of the second unit
Code: Select all
{FOREACH unit.attack i}
{VARIABLE_OP unit.attack[$i].damage multiply $second_unit.defense.$stored_location.terrain}
{NEXT i}
The stored_location.terrain may have to be in brackets so it is calculated first, not entirely sure. If so it should look like this $($stored_location.terrain).
Re: WML problem : weapon special : defense
Thanks for help. I decided to try and do this "disable ZOC" special first, because it involves similar unit modifications, and is (or so I think) easier to do, so maybe when I get this done, I got a better grasp on how to follow your instructions to this opint 
