Difference between revisions of "Damage reduction"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>Eliteofdelete
(typo)
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Your Character|
 
  
 
function1={{Function|
 
function1={{Function|
Line 15: Line 14:
  
 
function_description=Returns the damage that is deducted as a result of damage reduction effects.|
 
function_description=Returns the damage that is deducted as a result of damage reduction effects.|
 +
 +
code1={{CodeSample|
 +
title=Code Samples|
 +
description=The function will calculate the average damage you will take from each monster in a given location, 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 * (1 - damage_absorption_percent()/100);
 +
  if (totalDamage < 0)
 +
      totalDamage = 0;
 +
  print("For "+opponent+": KoLMafia thinks you will take "+expected_damage(opponent)+" and calculator thinks "+totalDamage, "blue");
 +
return round(totalDamage);
 +
}
 +
 +
void location_damage (location place) {
 +
  print(""+place+" has the following enemies that will deal the following average damage:", "purple");
 +
  foreach mob, freq in appearance_rates(place) //Appearance rates is used to weed out bosses/one time specials/etc
 +
      if (freq > 0)
 +
        print("The average damage a "+mob+" will deal to you is "+damage_calculator(mob)+".", "blue");
 +
     
 +
}
 +
location_damage($location[The Black Forest]);
 +
</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|damage_absorption_percent|raw_damage_absorption}}|
 
see_also={{SeeAlso|damage_absorption_percent|raw_damage_absorption}}|
 
special=Returns 0 when not logged in.
 
special=Returns 0 when not logged in.
 
}}
 
}}
 +
 +
[[Category:Your Character]]

Latest revision as of 06:23, 27 November 2015

Function Syntax

int damage_reduction()

Returns the damage that is deducted as a result of damage reduction effects.

Code Samples

The function will calculate the average damage you will take from each monster in a given location, 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 * (1 - damage_absorption_percent()/100);
   if (totalDamage < 0)
      totalDamage = 0;
   print("For "+opponent+": KoLMafia thinks you will take "+expected_damage(opponent)+" and calculator thinks "+totalDamage, "blue");
return round(totalDamage);
}

void location_damage (location place) {
   print(""+place+" has the following enemies that will deal the following average damage:", "purple");
   foreach mob, freq in appearance_rates(place) //Appearance rates is used to weed out bosses/one time specials/etc
      if (freq > 0) 
         print("The average damage a "+mob+" will deal to you is "+damage_calculator(mob)+".", "blue");
      
}
location_damage($location[The Black Forest]);

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

damage_absorption_percent() | raw_damage_absorption()

Special

Returns 0 when not logged in.