daily pastebin goal
51%
SHARE
TWEET

Move.getDamage() [unfinished]

RandomGuy32 Aug 18th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public int getDamage(MonsterBattleWrapper user, MonsterBattleWrapper target, Battle battle) {
  2.     /*
  3.     https://www.pokewiki.de/Schaden
  4.      */
  5.  
  6.     boolean isCrit = true; // fuck
  7.  
  8.     /* ===== BASE DAMAGE ===== */
  9.  
  10.     // Helping Hand increased damage by 50%.
  11.     float helpingHand = (user.helpingHand) ? 1.5f : 1f;
  12.  
  13.     // User's held item may increase damage.
  14.     float itemFactor = this.itemEffect(user.currentHeldItem, user);
  15.  
  16.     // Charge increases power of Electric-type moves by 100%.
  17.     float charge = (user.charge && this.type.equals(Type.get("electric"))) ? 2f : 1f;
  18.  
  19.     // Mud Sport cuts damage dealt by Electric-type moves in half.
  20.     float mudSport = (battle.mudSport && this.type.equals(Type.get("electric"))) ? 0.5f : 1f;
  21.  
  22.     // Water Sport cuts damage dealt by Fire-type moves in half.
  23.     float waterSport = (battle.waterSport && this.type.equals(Type.get("fire"))) ? 0.5f : 1f;
  24.  
  25.     // User's ability may increase damage dealt based on type or usage method.
  26.     float abilityFactorBaseDamageUser = user.currentAbility.effectOnBaseDamageDealing(this, user, target);
  27.  
  28.     // Target's ability may decrease damage dealt based on type or usage method.
  29.     float abilityFactorBaseDamageTarget = target.currentAbility.effectOnBaseDamageReceiving(this, user, target);
  30.  
  31.     // Putting it all together.
  32.     float baseDamage =
  33.             helpingHand *
  34.             this.getBaseDamage() *
  35.             itemFactor *
  36.             charge *
  37.             mudSport *
  38.             waterSport *
  39.             abilityFactorBaseDamageUser *
  40.             abilityFactorBaseDamageTarget;
  41.  
  42.     /* ===== FACTOR F1 ===== */
  43.  
  44.     // Burning decreases the power of physical moves by 50%, except when the user has the ability Guts.
  45.     float burnPenalty = (user.primaryCondition() == PrimaryCondition.BURN && this.damageClass == DamageClass.PHYSICAL && !user.currentAbility.equals(Ability.get("guts"))) ? 0.5f : 1f;
  46.  
  47.     // Reflect reduces physical damage by 50%; Light Screen does the same for special damage.
  48.     // NOTICE: When the move Brick Break is used, Reflect and Light Screen cease to exist before damage calculation.
  49.     float shieldFactor = this.getShieldFactor(target, battle, isCrit);
  50.  
  51.     // Moves that hit several targets simultaneously only deal 75% damage in battles with more than two Monsters.
  52.     float multiBattlePenalty = battle.getDamageMultiplier(this);
  53.  
  54.     // Weather may increase or decrease damage.
  55.     float weatherFactor = this.weatherMultiplier(battle);
  56.  
  57.     // When a Monster with Flash Fire gets hit by a Fire-type attack, all Fire-type attacks it subsequently uses will be boosted by 50%.
  58.     float flashFireFactor = 1f;     // I just can't right now
  59.  
  60.     // Putting it all together.
  61.     float f1 =
  62.             burnPenalty *
  63.             shieldFactor *
  64.             multiBattlePenalty *
  65.             weatherFactor *
  66.             flashFireFactor;
  67.  
  68.     /* ===== FACTOR F2 ===== */
  69.  
  70.     // Carrying a Life Orb increases attack damage by 30%.
  71.     float lifeOrbFactor = (user.currentHeldItem.item.equals(Item.get("life_orb"))) ? 1.3f : 1f;
  72.  
  73.     // Using the same attack in succession while holding a Metronome will increase its damage.
  74.     float metronomeFactor = 1f;     // fuck
  75.  
  76.     // Me First increases attack damage by 50%.
  77.     float meFirstFactor = 1f;   // fuck
  78.  
  79.     // Putting it all together.
  80.     float f2 =
  81.             lifeOrbFactor *
  82.             metronomeFactor *
  83.             meFirstFactor;
  84.  
  85.     /* ===== FLOAT F3 ===== */
  86.  
  87.     // Solid Rock and Filter will cut incoming damage in half if the attack is super effective.
  88.     float solidRockAndFilterFactor = ((this.type.getDamageMultiplier(target) > 1f) &&
  89.             (target.currentAbility.equals(Ability.get("solid_rock")) || target.currentAbility.equals(Ability.get("filter")))) ? 0.5f : 1f;
  90.  
  91.     // Using a super effective move while holding an Expert Belt will increase damage by 20%.
  92.     float expertBeltFactor = ((this.type.getDamageMultiplier(target) > 1f) && user.currentHeldItem.item.equals(Item.get("expert_belt"))) ? 1.2f : 1f;
  93.  
  94.     // Tinted Lens doubles the effectiveness of not-very-effective moves.
  95.     float tintedLensFactor = ((this.type.getDamageMultiplier(target) < 1f) && user.currentAbility.equals(Ability.get("tinted_lens"))) ? 2f : 1f;
  96.  
  97.     // Certain berries cut damage from super effective moves in half.
  98.     float berryFactor = 1f;     // fuck
  99.  
  100.     // Putting it all together.
  101.     float f3 =
  102.             solidRockAndFilterFactor *
  103.             expertBeltFactor *
  104.             tintedLensFactor *
  105.             berryFactor;
  106.  
  107.     /* ===== ATTACK and DEFENSE ===== */
  108.  
  109.     // NOTICE: If the attack is Foul Play, the target's attack stat will be used instead of the user's.
  110.     // ✔︎ NOTICE: Psyshock, Psystrike, and Secret Sword use the user's *special* attack, but the target's *physical* defense.
  111.     // NOTICE: Sacred Sword ignores target's positive defense changes.
  112.     // NOTICE: Something something Flower Gift
  113.  
  114.     boolean physicalOffense = false;    // determines whether to use physical (true) or special (false) attack stat
  115.     boolean physicalDefense = false;
  116.  
  117.     if (this.damageClass == DamageClass.PHYSICAL) {
  118.         physicalOffense = true;
  119.         physicalDefense = true;
  120.     }
  121.     if (this.idName.equals("psyshock") || this.idName.equals("psystrike") || this.idName.equals("secret_sword")) {
  122.         physicalDefense = true;
  123.     }
  124.  
  125.     float baseA;    // already has modifier built in
  126.     float baseD;
  127.  
  128.     if (physicalOffense) {
  129.         if (this.idName.equals("foul_play")) {
  130.             baseA = target.getStat(Statistic.ATTACK);
  131.         }
  132.         else {
  133.             baseA = user.getStat(Statistic.ATTACK);
  134.         }
  135.     }
  136.     else {
  137.         baseA = user.getStat(Statistic.SPECIAL_ATTACK);
  138.     }
  139.    
  140.     if (physicalDefense) {
  141.         baseD = target.getStat(Statistic.DEFENSE);
  142.     }
  143.     else {
  144.         baseD = target.getStat(Statistic.SPECIAL_DEFENSE);
  145.     }
  146.  
  147.     float abilityAttackFactor = 1f; // fuck
  148.     float itemAttackFactor = 1f;    // fuck
  149.  
  150.     // Deep Sea Scale, Eviolite, Metal Powder, Marvel Scale, Assault Vest, Flower Gift, weather=sandstorm, Soul Dew
  151.     float miscMod = 1f; // fuck
  152.  
  153.     float att = baseA * abilityAttackFactor * itemAttackFactor;
  154.     float def = baseD * miscMod;
  155.  
  156.     /* ===== CRIT MULTIPLIER ===== */
  157.     // screw the trinary operator; this code is convoluted enough already
  158.     float critMultiplier;
  159.     if (isCrit) {
  160.         if (user.currentAbility.equals(Ability.get("sniper"))) {
  161.             critMultiplier = 2f;
  162.         }
  163.         else {
  164.             critMultiplier = 1.5f;
  165.         }
  166.     }
  167.     else {
  168.         critMultiplier = 1f;
  169.     }
  170.  
  171.     /* ===== SAME TYPE ATTACK BONUS ===== */
  172.     float stab;
  173.     if (user.currentTypes.contains(this.type)) {
  174.         if (user.currentAbility.equals(Ability.get("adaptability"))) {
  175.             stab = 2f;
  176.         }
  177.         else {
  178.             stab = 1.5f;
  179.         }
  180.     }
  181.     else {
  182.         stab = 1f;
  183.     }
  184.  
  185.     /* ===== RESULT ===== */
  186.     float result = ((user.level() * 0.4f + 2) * baseDamage * (att / (50 * def)) * f1 + 2) * critMultiplier * f2 * (MathUtil.randomInt(85, 100) / 100f) * stab * this.type.getDamageMultiplier(target) * f3;
  187.  
  188.     System.out.println("BaseDamage: " + baseDamage);
  189.     System.out.println("DamageMultiplier: " + this.type.getDamageMultiplier(target));
  190.     System.out.println("F1: " + f1 + " | F2: " + f2 + " | F3: " + f3);
  191.     System.out.println("Att: " + att + " | Def: " + def);
  192.     System.out.println("User Level: " + user.level());
  193.     System.out.println("Target Level: " + target.level());
  194.     System.out.println("User HP: " + user.getStat(Statistic.HEALTH));
  195.     System.out.println("Target HP: " + target.getStat(Statistic.HEALTH));
  196.  
  197.     return (int) Math.round(result);    // temporary
  198. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top