RuneHive-Game
Loading...
Searching...
No Matches
MeleeMaxHit.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.maxhit;
2
3import com.runehive.game.world.entity.combat.attack.FightStyle;
4import com.runehive.game.world.entity.mob.Mob;
5import com.runehive.game.world.entity.mob.prayer.Prayer;
6import com.runehive.game.world.entity.skill.Skill;
7
8/**
9 * @author Origin
10 * @Since January 16 2022
11 */
12public class MeleeMaxHit {
13
14 public static int maxHit(Mob player) {
15 /**
16 * Max Hit
17 *
18 */
19
20 int maxHit = (int) Math.floor(getBaseDamage(player) * slayerPerkBonus(player));
21
22 /**
23 * Random Stuff
24 */
25
26 /* if (CombatFactory.fullDharoks(player)) {
27 double lostHp = player.maxHp() - player.hp();
28 maxHit *= (1 + ((lostHp /100) * (player.maxHp() / 100)));
29 } */
30
31 return (int) Math.floor(maxHit);
32 }
33
34 public static int getBaseDamage(Mob player) {
35 return (int) (Math.floor(0.5 + (getEffectiveStrength(player)) * (getStrengthBonus(player) + 64) + 320) / 640.0);
36 }
37
38 public static int getStrengthBonus(Mob player) {
39 return player.getBonus(9);
40 }
41
42 public static int getStrengthLevel(Mob player) {
43 return player.skills.getLevel(Skill.STRENGTH);
44 }
45
46 private static double getPrayerBonus(Mob player) {
47 /**
48 * Prayer Bonus
49 *
50 */
51 double prayerBonus = 1;
52 if (player.prayer.isActive(Prayer.THICK_SKIN))
53 prayerBonus += 1.05D; // 5% def level boost
54 else if (player.prayer.isActive(Prayer.ROCK_SKIN))
55 prayerBonus += 1.10D; // 10% def level boost
56 else if (player.prayer.isActive(Prayer.STEEL_SKIN))
57 prayerBonus += 1.15D; // 15% def level boost
58 else if (player.prayer.isActive(Prayer.CHIVALRY))
59 prayerBonus += 1.20D; // 20% def level boost
60 else if (player.prayer.isActive(Prayer.PIETY))
61 prayerBonus += 1.25D; // 25% def level boost
62 return prayerBonus;
63 }
64
65 public static int getStyleBonus(Mob player) {
66 FightStyle style = player.getCombat().getFightType().getStyle();
67 return style.equals(FightStyle.AGGRESSIVE) ? 3 : style.equals(FightStyle.ACCURATE) ? 1 : 0;
68 }
69
70 public static double slayerPerkBonus(Mob player) {
71 // SlayerTask target = player.getPlayer().slayer.getTask();
72
73 double slayerPerkBonus = 1.0;
74
75 /**
76 * Do slayer shit here
77 */
78 return slayerPerkBonus;
79 }
80
81 public static double getOtherBonus(Mob player, boolean includeNpcMax) {
82
83 //FightStyle style = player.getCombat().getFightType().getStyle();
84 double otherBonus = 1;
85 //boolean target = player.getCombat().getDefender().isNpc();
86
87 /**
88 * Other bonuses
89 *
90 */
91
92 /* if (FormulaUtils.voidMelee(player) || FormulaUtils.wearingEliteVoid(player)) {
93 otherBonus *= 1.10;
94 }
95
96 var wearingAnyBlackMask = FormulaUtils.wearingBlackMask(player) || FormulaUtils.wearingBlackMaskImbued(player) || player.getEquipment().wearingSlayerHelm();
97
98 if(wearingAnyBlackMask && target != null && target.isNpc() && includeNpcMax) {
99 NPC npc = target.getAsNpc();
100 if(npc.id() == NpcIdentifiers.COMBAT_DUMMY) {
101 otherBonus *= 1.1667;
102 }
103
104 if(Slayer.creatureMatches(player, npc.id())) {
105 otherBonus *= 1.1667;
106 }
107 }
108
109 if(player.getEquipment().hasAt(EquipSlot.AMULET, SALVE_AMULET) && !wearingAnyBlackMask && target != null && includeNpcMax) {
110 if(target.isNpc() && target.getAsNpc().id() == NpcIdentifiers.COMBAT_DUMMY) {
111 otherBonus *= 1.16;
112 }
113
114 if(FormulaUtils.isUndead(target)) {
115 otherBonus *= 1.16;
116 }
117 }
118
119 if(player.getEquipment().hasAt(EquipSlot.AMULET, SALVE_AMULETI) && !wearingAnyBlackMask && target != null && includeNpcMax) {
120 if(target.isNpc() && target.getAsNpc().id() == NpcIdentifiers.COMBAT_DUMMY) {
121 otherBonus *= 1.20;
122 }
123
124 if(FormulaUtils.isUndead(target)) {
125 otherBonus *= 1.20;
126 }
127 }
128
129 if(player.getEquipment().hasAt(EquipSlot.AMULET, SALVE_AMULET_E) && !wearingAnyBlackMask && target != null && includeNpcMax) {
130 if(target.isNpc() && target.getAsNpc().id() == NpcIdentifiers.COMBAT_DUMMY) {
131 otherBonus *= 1.20;
132 }
133
134 if(FormulaUtils.isUndead(target)) {
135 otherBonus *= 1.20;
136 }
137 }
138
139 if(player.getEquipment().hasAt(EquipSlot.AMULET, SALVE_AMULETEI) && !wearingAnyBlackMask && target != null && includeNpcMax) {
140 if(target.isNpc() && target.getAsNpc().id() == NpcIdentifiers.COMBAT_DUMMY) {
141 otherBonus *= 1.20;
142 }
143
144 if(FormulaUtils.isUndead(target)) {
145 otherBonus *= 1.20;
146 }
147 }
148
149 if (player.getEquipment().hasAt(EquipSlot.WEAPON, RED_SLAYER_HELMET_I) && target != null && target.isNpc() && includeNpcMax) {
150 otherBonus *= 1.10;
151 }
152
153 if (FormulaUtils.wearingTwistedSlayerHelmetI(player) && target != null && target.isNpc() && includeNpcMax) {
154 otherBonus *= 1.10;
155 }
156
157 if(player.getEquipment().hasAt(EquipSlot.WEAPON, ARCLIGHT) && target != null && includeNpcMax) {
158 if(target.isNpc() && target.getAsNpc().id() == NpcIdentifiers.COMBAT_DUMMY) {
159 otherBonus *= 1.70;
160 }
161
162 if(FormulaUtils.isDemon(target)) {
163 otherBonus *= 1.70;
164 }
165 }
166
167 if(player.getEquipment().hasAt(EquipSlot.WEAPON, DARKLIGHT) && target != null && includeNpcMax) {
168 if(target.isNpc() && target.getAsNpc().id() == NpcIdentifiers.COMBAT_DUMMY) {
169 otherBonus *= 1.60;
170 }
171
172 if(FormulaUtils.isDemon(target)) {
173 otherBonus *= 1.60;
174 }
175 }
176
177 if(player.getEquipment().hasAt(EquipSlot.WEAPON, DARKLIGHT) && target != null && includeNpcMax) {
178 if(target.isNpc() && target.getAsNpc().id() == NpcIdentifiers.COMBAT_DUMMY) {
179 otherBonus *= 1.175;
180 }
181
182 if(target.isNpc() && target.getAsNpc().def() != null && (target.getAsNpc().def().name.equalsIgnoreCase("Kurask") || target.getAsNpc().def().name.equalsIgnoreCase("Turoth"))) {
183 otherBonus *= 1.175;
184 }
185 }
186
187 if (FormulaUtils.obbyArmour(player) && FormulaUtils.hasObbyWeapon(player)) {
188 otherBonus *= 1.10;
189 }
190
191 if(FormulaUtils.berserkerNecklace(player) && FormulaUtils.hasObbyWeapon(player)) {
192 otherBonus *= 1.10;
193 }
194
195 if (player.getCombat().getFightType().getAttackType() == AttackType.CRUSH) {
196 if (player.getEquipment().hasAt(EquipSlot.HEAD, INQUISITORS_GREAT_HELM) || player.getEquipment().hasAt(EquipSlot.BODY, INQUISITORS_HAUBERK) || player.getEquipment().hasAt(EquipSlot.LEGS, INQUISITORS_PLATESKIRT)) {
197 otherBonus *= 1.05;
198 }
199 }
200
201 if(player.getEquipment().hasAt(EquipSlot.WEAPON, DRAGON_HUNTER_LANCE) && target != null && includeNpcMax) {
202 if(target.isNpc() && target.getAsNpc().id() == NpcIdentifiers.COMBAT_DUMMY) {
203 otherBonus *= 1.20;
204 }
205
206 if(FormulaUtils.isDragon(target)) {
207 otherBonus *= 1.20;
208 }
209 }
210
211 //• Gadderhammer: 1.25 or 2.0 vs shades
212 if(player.getEquipment().hasAt(EquipSlot.WEAPON, GADDERHAMMER)) {
213 if(target != null && target.isNpc()) {
214 NPC npc = target.getAsNpc();
215 NpcDefinition def = npc.def();
216 var isShade = def != null && def.name.equalsIgnoreCase("Shade");
217 otherBonus *= isShade ? 1.25 : 2.00;
218 }
219 }
220
221 if (FormulaUtils.hasViggorasChainMace(player) && target != null && target.isNpc() && includeNpcMax) {
222 otherBonus *= 1.50;
223 }*/
224
225 return otherBonus;
226 }
227
228 public static int getEffectiveStrength(Mob player) {
229 return (int) (Math.floor(((((getStrengthLevel(player)) * getPrayerBonus(player)) + getStyleBonus(player)) + 8) * getOtherBonus(player, true)));
230 }
231}
static double getOtherBonus(Mob player, boolean includeNpcMax)
Handles the mob class.
Definition Mob.java:66
abstract Combat<? extends Mob > getCombat()
The combat of the mob.
boolean isActive(Prayer... prayers)
Checks if all given prayers are active.
Represents a trainable and usable skill.
Definition Skill.java:18
static final int STRENGTH
The strength skill id.
Definition Skill.java:27
int getLevel(int id)
Gets the level of a skill.
The enumerated type whose elements represent the fighting styles.