RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ZerkerMelee.java
1package com.osroyale.content.bot.botclass.impl;
2
3import com.osroyale.content.bot.PlayerBot;
4import com.osroyale.content.bot.botclass.BotClass;
5import com.osroyale.content.consume.FoodData;
6import com.osroyale.content.consume.PotionData;
7import com.osroyale.content.skill.impl.magic.spell.impl.Vengeance;
8import com.osroyale.game.event.impl.ItemClickEvent;
9import com.osroyale.game.world.entity.combat.CombatType;
10import com.osroyale.game.world.entity.combat.attack.FightType;
11import com.osroyale.game.world.entity.combat.attack.listener.SimplifiedListener;
12import com.osroyale.game.world.entity.combat.hit.Hit;
13import com.osroyale.game.world.entity.mob.Mob;
14import com.osroyale.game.world.entity.mob.player.Player;
15import com.osroyale.game.world.entity.mob.prayer.Prayer;
16import com.osroyale.game.world.entity.skill.Skill;
17import com.osroyale.game.world.items.Item;
18import com.osroyale.util.RandomUtils;
19import plugin.click.item.EatFoodPlugin;
20
21import java.util.concurrent.TimeUnit;
22
23import static com.osroyale.game.world.entity.combat.attack.FormulaFactory.getModifiedMaxHit;
24
25public class ZerkerMelee extends SimplifiedListener<Player> implements BotClass {
26
27 @Override
28 public Item[] inventory() {
29 return new Item[] {
30 new Item(5698), new Item(21003), new Item(12695), new Item(3024),
31 new Item(3024), new Item(3024), new Item(3024), new Item(3144),
32 new Item(3144), new Item(3144), new Item(3144), new Item(3144),
33 new Item(3144), new Item(560, 150), new Item(9075, 150), new Item(557, 300),
34 new Item(391), new Item(391), new Item(391), new Item(391),
35 new Item(391), new Item(391), new Item(391), new Item(391),
36 new Item(391), new Item(391), new Item(391), new Item(391)
37 };
38 }
39
40 @Override
41 public Item[] equipment() {
42 return new Item[] {
43 new Item(6570),
44 new Item(11128),
45 new Item(10551),
46 new Item(3751),
47 new Item(1079),
48 new Item(8850),
49 new Item(4131),
50 new Item(2550),
51 new Item(7462),
52 new Item(4587)
53 };
54 }
55
56 @Override
57 public int[] skills() {
58 return new int[] { 75, 45, 99, 99, 1, 52, 1 };
59 }
60
61 @Override
62 public void initCombat(Player target, PlayerBot bot) {
63 pot(target, bot);
64 bot.prayer.toggle(Prayer.PROTECT_ITEM, Prayer.PIETY);
65 bot.getCombat().addListener(this);
66 bot.spellCasting.cast(new Vengeance(), null);
67 bot.getCombat().setFightType(FightType.SCIMITAR_SLASH);
68 }
69
70 @Override
71 public void handleCombat(Player target, PlayerBot bot) {
72 if (!bot.prayer.isActive(Prayer.SMITE) && target.prayer.isActive(Prayer.SMITE)) {
73 bot.prayer.toggle(Prayer.SMITE);
74 bot.speak("Let's smite then...");
75 } else if (bot.prayer.isActive(Prayer.SMITE) && !target.prayer.isActive(Prayer.SMITE)) {
76 bot.prayer.toggle(Prayer.SMITE);
77 }
78
79 if (bot.isSpecialActivated() && target.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
80 bot.speak("That's such bullshit...");
81 bot.getCombatSpecial().disable(bot, false);
82 bot.endFight();
83 }
84
85 if (!bot.prayer.isActive(Prayer.PROTECT_FROM_MELEE) && target.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
86 bot.prayer.toggle(Prayer.PROTECT_FROM_MELEE);
87 } else if (bot.prayer.isActive(Prayer.PROTECT_FROM_MELEE) && !target.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
88 bot.prayer.toggle(Prayer.PROTECT_FROM_MELEE);
89 }
90
91 if (bot.spellCasting.vengeanceDelay.elapsedTime(TimeUnit.SECONDS) >= 30) {
92 bot.spellCasting.cast(new Vengeance(), null);
93 }
94 }
95
96 @Override
97 public void endFight(PlayerBot bot) {
98 bot.prayer.deactivate(Prayer.PROTECT_ITEM, Prayer.SMITE, Prayer.PIETY);
99 }
100
101 @Override
102 public void hit(Player attacker, Mob defender, Hit hit) {
103 int max = getModifiedMaxHit(attacker, defender, CombatType.MELEE);
104 max = attacker.getCombat().modifyDamage(defender, max);
105
106 boolean hasRoom = attacker.inventory.getFreeSlots() > 0;
107 boolean hasSpec = attacker.getSpecialPercentage().intValue() >= 25;
108 boolean lowHp = defender.getCurrentHealth() <= defender.getMaximumHealth() * RandomUtils.inclusive(0.50, 0.65);
109 boolean combo = defender.getCurrentHealth() <= defender.getMaximumHealth() * RandomUtils.inclusive(0.50, 0.70)
110 && hit.getDamage() >= max * RandomUtils.inclusive(0.65, 0.75);
111
112 if (!combo && !lowHp)
113 return;
114
115 PlayerBot bot = ((PlayerBot) attacker);
116 bot.schedule(4, () -> {
117 if (bot.equipment.getWeapon().matchesId(4587)) {
118 boolean useMaul = hasRoom && (!hasSpec || RandomUtils.success(0.50));
119 if (useMaul) {
120 int index = bot.inventory.computeIndexForId(21103);
121 bot.equipment.equip(index);
122 bot.getCombat().setFightType(FightType.ELDER_MAUL_PUMMEL);
123 } else {
124 int index = bot.inventory.computeIndexForId(5698);
125 bot.equipment.equip(index);
126 bot.getCombat().setFightType(FightType.DRAGON_DAGGER_LUNGE);
127 }
128 }
129
130 if (bot.equipment.getWeapon().matchesId(5698) && hasSpec && (lowHp || RandomUtils.success(0.75)))
131 bot.getCombatSpecial().enable(bot);
132
133 bot.schedule(4, () -> {
134 if (!bot.isSpecialActivated() && bot.equipment.getWeapon().matchesId(5698)) {
135 int idx = bot.inventory.computeIndexForId(4587);
136 bot.equipment.equip(idx);
137 idx = bot.inventory.computeIndexForId(8850);
138 bot.equipment.equip(idx);
139 bot.getCombat().setFightType(FightType.SCIMITAR_SLASH);
140 }
141 });
142 });
143 }
144
145 @Override
146 public void pot(Player target, PlayerBot bot) {
147 if (target.getCurrentHealth() <= Math.floor(target.getMaximumHealth() * 0.35))
148 return;
149
150 if (!bot.potionDelay.elapsed(1250)) {
151 return;
152 }
153
154 PotionData potion;
155 ItemClickEvent event;
156
157 if (checkSkill(bot, Skill.PRAYER, 40)) {
158 int index = bot.inventory.computeIndexForId(3024);
159 if (index >= 0) {
160 event = new ItemClickEvent(0, bot.inventory.get(index), index);
161 potion = PotionData.SUPER_RESTORE_POTIONS;
162 bot.pot(target, event, potion);
163 }
164 } else if (checkSkill(bot, Skill.ATTACK, 115)
165 || checkSkill(bot, Skill.STRENGTH, 115)
166 || checkSkill(bot, Skill.DEFENCE, 115)) {
167 int index = bot.inventory.computeIndexForId(12695);
168 if (index >= 0) {
169 event = new ItemClickEvent(0, bot.inventory.get(index), index);
170 potion = PotionData.SUPER_COMBAT_POTION;
171 bot.pot(target, event, potion);
172 }
173 }
174 }
175
176 @Override
177 public void eat(Player target, PlayerBot bot) {
178 int max = target.playerAssistant.getMaxHit(bot, target.getStrategy().getCombatType());
179 if (bot.getCurrentHealth() > bot.getMaximumHealth() * 0.45 && max < bot.getCurrentHealth())
180 return;
181
182 if (target.getCurrentHealth() <= Math.floor(target.getMaximumHealth() * 0.35) && max < bot.getCurrentHealth())
183 return;
184
185 int index = bot.inventory.computeIndexForId(391);
186 if (index >= 0) {
187 EatFoodPlugin.eat(bot, bot.inventory.get(index), index, FoodData.MANTA);
188 bot.foodRemaining--;
189 }
190
191 if (bot.getCurrentHealth() >= bot.getMaximumHealth() * 0.35)
192 return;
193
194 index = bot.inventory.computeIndexForId(3144);
195 if (index >= 0) {
196 EatFoodPlugin.eat(bot, bot.inventory.get(index), index, FoodData.COOKED_KARAMBWAN);
197 bot.foodRemaining--;
198 }
199 }
200
201 @Override
202 public boolean canOtherAttack(Mob attacker, Player defender) {
203 if (defender.getCombat().isAttacking() && !defender.getCombat().isAttacking(attacker)) {
204 attacker.getPlayer().message("You cannot attack a bot while they are attacking another player.");
205 return false;
206 }
207 return true;
208 }
209
210 @Override
211 public void block(Mob attacker, Player defender, Hit hit, CombatType combatType) {
212 ((PlayerBot) defender).consumableDelay = RandomUtils.inclusive(1, 3);
213 }
214
215 private boolean checkSkill(PlayerBot bot, int id, int minimum) {
216 return bot.skills.getLevel(id) < minimum;
217 }
218
219}