Damage absorption percent: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Grotfang
Conform to template
imported>Eliteofdelete
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{#vardefine:name|damage_absorption_percent}}
{{
{{#vardefine:return_type|float}}
#vardefine:name|damage_absorption_percent}}{{
#vardefine:return_type|float}}{{


{{FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=Your Character|


function1={{Function|
function1={{Function|
Line 14: Line 14:


function_description=Returns the total percentage of damage absorption of all your gear and effects.|
function_description=Returns the total percentage of damage absorption of all your gear and effects.|
code1={{CodeSample|
title=Code Samples|
description=The function will calculate the average damage you will take from a given monster, if you are hit.|
code=
<syntaxhighlight>
int damage_calculator (monster opponent) {
  int myMoxie = my_buffedstat($stat[moxie]);
  int monsterAttack = monster_attack(opponent);
  int bonusDamage = monsterAttack-myMoxie;
  if (bonusDamage < 0)
      bonusDamage = 0;
  float totalDamage = bonusDamage + monsterAttack*.225 - damage_reduction();
  totalDamage = totalDamage * damage_absorption_percent()/100;
  if (totalDamage < 0)
      totalDamage = 0;
return round(totalDamage);
}
print("The average damage a black panther will deal to you is "+damage_calculator($monster[black panther])+".", "blue");
</syntaxhighlight>|
moreinfo=
The formula used to calculate damage can be found [http://kol.coldfront.net/thekolwiki/index.php/Weapon_Damage#Monster_Damage_Formula Here] Note: The example does not take in account using a shield with the passive Hero of the Half-Shell.
}}|


see_also={{SeeAlso|raw_damage_absorption|damage_reduction}}|
see_also={{SeeAlso|raw_damage_absorption|damage_reduction}}|
special=Returns 0 when not logged in.
special=Returns 0 when not logged in.
}}
}}
[[Category:Your Character]]

Latest revision as of 08:48, 11 January 2015

Function Syntax

float damage_absorption_percent()

Returns the total percentage of damage absorption of all your gear and effects.

Code Samples

The function will calculate the average damage you will take from a given monster, if you are hit.

int damage_calculator (monster opponent) {
   int myMoxie = my_buffedstat($stat[moxie]);
   int monsterAttack = monster_attack(opponent);
   int bonusDamage = monsterAttack-myMoxie;
   if (bonusDamage < 0)
      bonusDamage = 0;
   float totalDamage = bonusDamage + monsterAttack*.225 - damage_reduction();
   totalDamage = totalDamage * damage_absorption_percent()/100;
   if (totalDamage < 0)
      totalDamage = 0;
return round(totalDamage);
}
print("The average damage a black panther will deal to you is "+damage_calculator($monster[black panther])+".", "blue");

The formula used to calculate damage can be found Here Note: The example does not take in account using a shield with the passive Hero of the Half-Shell.

See Also

raw_damage_absorption() | damage_reduction()

Special

Returns 0 when not logged in.