All pastes #467255 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-02 12:39 UTC
rendered paste body
breakondamage is to be used to replace implementations of a function removeaura(aura) (or whatever the function is called) to correct the breaking of Entangling Roots and Fear Effects.

The way in which these auras are removed currently is with a 100% certainty upon a unit taking damage. However, to correctly implement the removing of these auras, it should not be 100% chance on damage but a chance dependant on the damage dealt.

The break chance should work as follows:
If the damage dealt to a unit is over 75% of that units maximum hp, there is a 100% chance for the Root Effect or Fear Effect to be removed.
If the damage is less than 75%, then the chance to remove the effects is the damage-to-maximumhp percentage of 75%
ie. if an attack deals 50% of a units maximum hp, then there is a 50/75 % (33.33%) chance to remove Root Effect or Fear Effect.
Root Effect will NEVER break from damage caused by the Root Effect itself.

Assuming the method to remove auras is called removeaura(), this new function should take its place in the code where Fear and Root effects are concerned.

The method requires 2 variables to be passed to it:
The damage caused when the check is performed to remove the effects
The aura to be removed

--- Pseudo Code ---

breakondamage(damage, aura) {
   // percentage of units max hp dealt in damage
   damage_perc = damage/p_maxhp;
   // calc for break chance based on the damage percentage 
   break_chance = damage_perc/0.75;
   // damage over 75% of a units max hp is a 100% chance
   if (break_chance) > 1 {
      break_chance = 1;
   }

   // remove the aura if a random number
   // from 0-100 is less than the chance to break
   roll = rand(0,100);
   if ((break_chance * 100) >= roll) {
      removeaura(aura);
   }
}