Dancer_A

Ruby Edit

Mar 4th, 2017 (edited)
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.41 KB | None | 0 0
  1.         private int dmg_target(Game_Unit target)
  2.         {
  3.             Data_Weapon weapon = this.attacker_weapon;
  4.             // Checks if weapon is magic
  5.             bool magic_attack = attacker.check_magic_attack(weapon, Distance);
  6.             bool imbue = (magic_attack && attacker.actor.power_type() == Power_Types.Strength);
  7.             bool is_staff = weapon.is_staff();
  8.             Game_Actor actor2 = target.actor;
  9.             Data_Weapon weapon2 = actor2.weapon;
  10.             int total_damage, target_def;
  11.             int actor_dmg, weapon_dmg, skill_dmg, support_dmg;
  12.             WeaponTriangle tri = Combat.weapon_triangle(attacker, target, weapon, weapon2, Distance); // moved to up here
  13.             // Staff
  14.             if (is_staff)
  15.             {
  16.                 actor_dmg = attacker.atk_pow(weapon, magic_attack);
  17.                 weapon_dmg = weapon.Mgt;
  18.                 skill_dmg = 0;
  19.                 attacker.dmg_staff_skill(
  20.                     ref skill_dmg, ref weapon_dmg, ref actor_dmg,
  21.                     target, magic_attack, Distance);
  22.                 support_dmg = support_bonus(Combat_Stat_Labels.Dmg);
  23.                 target_def = 0;
  24.                 tri = WeaponTriangle.Nothing; // it's a staff, weapon triangle has to be nothing
  25.             }
  26.             // Weapon
  27.             else
  28.             {
  29.                 var target_stats = this.target_stats();
  30.                 target_def = magic_attack ?
  31.                     target_stats.res() : target_stats.def();
  32.                 target_def = (weapon.Ignores_Def() ? target_def / 2 : target_def);
  33.                 if (weapon.Halves_HP())
  34.                 {
  35.                     int total_weapon_damage = target_def + (int)Math.Ceiling(target.actor.hp / 2.0f);
  36.                     actor_dmg = (int)Math.Ceiling(total_weapon_damage / 2.0f);
  37.                     weapon_dmg = (int)Math.Floor(total_weapon_damage / 2.0f);
  38.                 }
  39.                 else
  40.                 {
  41.                     actor_dmg = weapon.Ignores_Pow() ?
  42.                         0 : ((int)(attacker.atk_pow(weapon, magic_attack) *
  43.                             (imbue ? Constants.Combat.MAGIC_WEAPON_STR_RATE : 1)));
  44.                     weapon_dmg = (int)(weapon.Mgt * (imbue ? Constants.Combat.MAGIC_WEAPON_MGT_RATE : 1));
  45.                     if (weapon.Ignores_Def())
  46.                         weapon_dmg += target_def;
  47.                 }
  48.                 // Weapon triangle is handled here instead
  49.                 skill_dmg = 0;
  50.                 if (tri != WeaponTriangle.Nothing)
  51.                     skill_dmg += Weapon_Triangle.DMG_BONUS * (tri == WeaponTriangle.Advantage ? 1 : -1) *
  52.                         Combat.weapon_triangle_mult(attacker, target, weapon, weapon2, Distance);
  53.  
  54.                 int effectiveness = weapon.effective_multiplier(attacker, target);
  55.                 skill_dmg += (weapon_dmg + skill_dmg) * (effectiveness - 1);
  56.                 support_dmg = support_bonus(Combat_Stat_Labels.Dmg);
  57.                 attacker.dmg_skill(
  58.                     ref skill_dmg, ref weapon_dmg, ref actor_dmg, ref support_dmg,
  59.                     ref target_def, weapon, target, weapon2, magic_attack,
  60.                     Distance);
  61.             }
  62.             total_damage = actor_dmg + weapon_dmg + skill_dmg + support_dmg - target_def;
  63.             int result = attacker.dmg_target_skill(target, weapon, Distance, Math.Max(0, total_damage), tri);
  64.             return result;
  65.         }
Add Comment
Please, Sign In to add comment