Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int getDamage(MonsterBattleWrapper user, MonsterBattleWrapper target, Battle battle) {
- /*
- https://www.pokewiki.de/Schaden
- */
- boolean isCrit = true; // fuck
- /* ===== BASE DAMAGE ===== */
- // Helping Hand increased damage by 50%.
- float helpingHand = (user.helpingHand) ? 1.5f : 1f;
- // User's held item may increase damage.
- float itemFactor = this.itemEffect(user.currentHeldItem, user);
- // Charge increases power of Electric-type moves by 100%.
- float charge = (user.charge && this.type.equals(Type.get("electric"))) ? 2f : 1f;
- // Mud Sport cuts damage dealt by Electric-type moves in half.
- float mudSport = (battle.mudSport && this.type.equals(Type.get("electric"))) ? 0.5f : 1f;
- // Water Sport cuts damage dealt by Fire-type moves in half.
- float waterSport = (battle.waterSport && this.type.equals(Type.get("fire"))) ? 0.5f : 1f;
- // User's ability may increase damage dealt based on type or usage method.
- float abilityFactorBaseDamageUser = user.currentAbility.effectOnBaseDamageDealing(this, user, target);
- // Target's ability may decrease damage dealt based on type or usage method.
- float abilityFactorBaseDamageTarget = target.currentAbility.effectOnBaseDamageReceiving(this, user, target);
- // Putting it all together.
- float baseDamage =
- helpingHand *
- this.getBaseDamage() *
- itemFactor *
- charge *
- mudSport *
- waterSport *
- abilityFactorBaseDamageUser *
- abilityFactorBaseDamageTarget;
- /* ===== FACTOR F1 ===== */
- // Burning decreases the power of physical moves by 50%, except when the user has the ability Guts.
- float burnPenalty = (user.primaryCondition() == PrimaryCondition.BURN && this.damageClass == DamageClass.PHYSICAL && !user.currentAbility.equals(Ability.get("guts"))) ? 0.5f : 1f;
- // Reflect reduces physical damage by 50%; Light Screen does the same for special damage.
- // NOTICE: When the move Brick Break is used, Reflect and Light Screen cease to exist before damage calculation.
- float shieldFactor = this.getShieldFactor(target, battle, isCrit);
- // Moves that hit several targets simultaneously only deal 75% damage in battles with more than two Monsters.
- float multiBattlePenalty = battle.getDamageMultiplier(this);
- // Weather may increase or decrease damage.
- float weatherFactor = this.weatherMultiplier(battle);
- // 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%.
- float flashFireFactor = 1f; // I just can't right now
- // Putting it all together.
- float f1 =
- burnPenalty *
- shieldFactor *
- multiBattlePenalty *
- weatherFactor *
- flashFireFactor;
- /* ===== FACTOR F2 ===== */
- // Carrying a Life Orb increases attack damage by 30%.
- float lifeOrbFactor = (user.currentHeldItem.item.equals(Item.get("life_orb"))) ? 1.3f : 1f;
- // Using the same attack in succession while holding a Metronome will increase its damage.
- float metronomeFactor = 1f; // fuck
- // Me First increases attack damage by 50%.
- float meFirstFactor = 1f; // fuck
- // Putting it all together.
- float f2 =
- lifeOrbFactor *
- metronomeFactor *
- meFirstFactor;
- /* ===== FLOAT F3 ===== */
- // Solid Rock and Filter will cut incoming damage in half if the attack is super effective.
- float solidRockAndFilterFactor = ((this.type.getDamageMultiplier(target) > 1f) &&
- (target.currentAbility.equals(Ability.get("solid_rock")) || target.currentAbility.equals(Ability.get("filter")))) ? 0.5f : 1f;
- // Using a super effective move while holding an Expert Belt will increase damage by 20%.
- float expertBeltFactor = ((this.type.getDamageMultiplier(target) > 1f) && user.currentHeldItem.item.equals(Item.get("expert_belt"))) ? 1.2f : 1f;
- // Tinted Lens doubles the effectiveness of not-very-effective moves.
- float tintedLensFactor = ((this.type.getDamageMultiplier(target) < 1f) && user.currentAbility.equals(Ability.get("tinted_lens"))) ? 2f : 1f;
- // Certain berries cut damage from super effective moves in half.
- float berryFactor = 1f; // fuck
- // Putting it all together.
- float f3 =
- solidRockAndFilterFactor *
- expertBeltFactor *
- tintedLensFactor *
- berryFactor;
- /* ===== ATTACK and DEFENSE ===== */
- // NOTICE: If the attack is Foul Play, the target's attack stat will be used instead of the user's.
- // ✔︎ NOTICE: Psyshock, Psystrike, and Secret Sword use the user's *special* attack, but the target's *physical* defense.
- // NOTICE: Sacred Sword ignores target's positive defense changes.
- // NOTICE: Something something Flower Gift
- boolean physicalOffense = false; // determines whether to use physical (true) or special (false) attack stat
- boolean physicalDefense = false;
- if (this.damageClass == DamageClass.PHYSICAL) {
- physicalOffense = true;
- physicalDefense = true;
- }
- if (this.idName.equals("psyshock") || this.idName.equals("psystrike") || this.idName.equals("secret_sword")) {
- physicalDefense = true;
- }
- float baseA; // already has modifier built in
- float baseD;
- if (physicalOffense) {
- if (this.idName.equals("foul_play")) {
- baseA = target.getStat(Statistic.ATTACK);
- }
- else {
- baseA = user.getStat(Statistic.ATTACK);
- }
- }
- else {
- baseA = user.getStat(Statistic.SPECIAL_ATTACK);
- }
- if (physicalDefense) {
- baseD = target.getStat(Statistic.DEFENSE);
- }
- else {
- baseD = target.getStat(Statistic.SPECIAL_DEFENSE);
- }
- float abilityAttackFactor = 1f; // fuck
- float itemAttackFactor = 1f; // fuck
- // Deep Sea Scale, Eviolite, Metal Powder, Marvel Scale, Assault Vest, Flower Gift, weather=sandstorm, Soul Dew
- float miscMod = 1f; // fuck
- float att = baseA * abilityAttackFactor * itemAttackFactor;
- float def = baseD * miscMod;
- /* ===== CRIT MULTIPLIER ===== */
- // screw the trinary operator; this code is convoluted enough already
- float critMultiplier;
- if (isCrit) {
- if (user.currentAbility.equals(Ability.get("sniper"))) {
- critMultiplier = 2f;
- }
- else {
- critMultiplier = 1.5f;
- }
- }
- else {
- critMultiplier = 1f;
- }
- /* ===== SAME TYPE ATTACK BONUS ===== */
- float stab;
- if (user.currentTypes.contains(this.type)) {
- if (user.currentAbility.equals(Ability.get("adaptability"))) {
- stab = 2f;
- }
- else {
- stab = 1.5f;
- }
- }
- else {
- stab = 1f;
- }
- /* ===== RESULT ===== */
- 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;
- System.out.println("BaseDamage: " + baseDamage);
- System.out.println("DamageMultiplier: " + this.type.getDamageMultiplier(target));
- System.out.println("F1: " + f1 + " | F2: " + f2 + " | F3: " + f3);
- System.out.println("Att: " + att + " | Def: " + def);
- System.out.println("User Level: " + user.level());
- System.out.println("Target Level: " + target.level());
- System.out.println("User HP: " + user.getStat(Statistic.HEALTH));
- System.out.println("Target HP: " + target.getStat(Statistic.HEALTH));
- return (int) Math.round(result); // temporary
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement