Advertisement
Guest User

IsoPlayer_calculateCritChance.java

a guest
Aug 11th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.67 KB | None | 0 0
  1. public int calculateCritChance(IsoGameCharacter target) {
  2.     if (this.bDoShove) {
  3.       int var7 = 35;
  4.       if (target instanceof IsoPlayer) {
  5.         IsoPlayer target_player = (IsoPlayer)target;
  6.         var7 = 20;
  7.         if (GameClient.bClient && !target_player.isLocalPlayer()) {
  8.           var7 = (int)((double)var7 - (double)target_player.remoteStrLvl * 1.5);
  9.           if (target_player.getNutrition().getWeight() < 80.0) {
  10.             var7 = (int)((double)var7 + Math.abs((target_player.getNutrition().getWeight() - 80.0) / 2.0));
  11.           } else {
  12.             var7 = (int)((double)var7 - (target_player.getNutrition().getWeight() - 80.0) / 2.0);
  13.           }
  14.         }
  15.       }
  16.  
  17.       var7 -= this.getMoodles().getMoodleLevel(MoodleType.Endurance) * 5;
  18.       var7 -= this.getMoodles().getMoodleLevel(MoodleType.HeavyLoad) * 5;
  19.       var7 = (int)((double)var7 - (double)this.getMoodles().getMoodleLevel(MoodleType.Panic) * 1.3);
  20.       var7 += this.getPerkLevel(Perks.Strength) * 2;
  21.       return var7;
  22.  
  23.     } else if (this.bDoShove && target.getStateMachine().getCurrent() == StaggerBackState.instance() && target instanceof IsoZombie) {
  24.       return 100;
  25.  
  26.     } else if (this.getPrimaryHandItem() != null && this.getPrimaryHandItem() instanceof HandWeapon) {
  27.       HandWeapon weapon = (HandWeapon)this.getPrimaryHandItem();
  28.       int critChance = (int)weapon.getCriticalChance();
  29.       if (weapon.isAlwaysKnockdown()) {
  30.         return 100;
  31.       } else {
  32.  
  33.         WeaponType weaponType = WeaponType.getWeaponType(this);
  34.         if (weaponType.isRanged) {
  35.           critChance = (int)((float)critChance + (float)weapon.getAimingPerkCritModifier() * ((float)this.getPerkLevel(Perks.Aiming) / 2.0F));
  36.          
  37.           if (this.getBeenMovingFor() > (float)(weapon.getAimingTime() + this.getPerkLevel(Perks.Aiming) * 2)) {
  38.             critChance = (int)((float)critChance - (this.getBeenMovingFor() - (float)(weapon.getAimingTime() + this.getPerkLevel(Perks.Aiming) * 2)));
  39.           }
  40.  
  41.           critChance += this.getPerkLevel(Perks.Aiming) * 3;
  42.  
  43.           float distance = this.DistToProper(target);
  44.           if (distance < 4.0F) {
  45.             critChance = (int)((float)critChance + (4.0F - distance) * 7.0F);
  46.           } else if (distance >= 4.0F) {
  47.             critChance = (int)((float)critChance - (distance - 4.0F) * 7.0F);
  48.           }
  49.  
  50.         } else {
  51.           if (weapon.isTwoHandWeapon() && (this.getPrimaryHandItem() != weapon || this.getSecondaryHandItem() != weapon)) {
  52.             critChance -= critChance / 3;
  53.           }
  54.  
  55.           if (this.chargeTime < 2.0F) {
  56.             critChance -= critChance / 5;
  57.           }
  58.  
  59.           int var8 = this.getPerkLevel(Perks.Blunt);
  60.           if (weapon.getCategories().contains("Axe")) {
  61.             var8 = this.getPerkLevel(Perks.Axe);
  62.           }
  63.  
  64.           if (weapon.getCategories().contains("LongBlade")) {
  65.             var8 = this.getPerkLevel(Perks.LongBlade);
  66.           }
  67.  
  68.           if (weapon.getCategories().contains("Spear")) {
  69.             var8 = this.getPerkLevel(Perks.Spear);
  70.           }
  71.  
  72.           if (weapon.getCategories().contains("SmallBlade")) {
  73.             var8 = this.getPerkLevel(Perks.SmallBlade);
  74.           }
  75.  
  76.           if (weapon.getCategories().contains("SmallBlunt")) {
  77.             var8 = this.getPerkLevel(Perks.SmallBlunt);
  78.           }
  79.  
  80.           critChance += var8 * 3;
  81.           if (target instanceof IsoPlayer) {
  82.             IsoPlayer var6 = (IsoPlayer)target;
  83.             if (GameClient.bClient && !var6.isLocalPlayer()) {
  84.               critChance = (int)((double)critChance - (double)var6.remoteStrLvl * 1.5);
  85.               if (var6.getNutrition().getWeight() < 80.0) {
  86.                 critChance = (int)((double)critChance + Math.abs((var6.getNutrition().getWeight() - 80.0) / 2.0));
  87.               } else {
  88.                 critChance = (int)((double)critChance - (var6.getNutrition().getWeight() - 80.0) / 2.0);
  89.               }
  90.             }
  91.           }
  92.         }
  93.  
  94.         critChance -= this.getMoodles().getMoodleLevel(MoodleType.Endurance) * 5;
  95.         critChance -= this.getMoodles().getMoodleLevel(MoodleType.HeavyLoad) * 5;
  96.         critChance = (int)((double)critChance - (double)this.getMoodles().getMoodleLevel(MoodleType.Panic) * 1.3);
  97.         if (SandboxOptions.instance.Lore.Toughness.getValue() == 1) {
  98.           critChance -= 6;
  99.         }
  100.  
  101.         if (SandboxOptions.instance.Lore.Toughness.getValue() == 3) {
  102.           critChance += 6;
  103.         }
  104.  
  105.         if (critChance < 10) {
  106.           critChance = 10;
  107.         }
  108.  
  109.         if (critChance > 90) {
  110.           critChance = 90;
  111.         }
  112.  
  113.         return critChance;
  114.       }
  115.     } else {
  116.       return 0;
  117.     }
  118.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement