RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
PureMelee.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 static com.osroyale.game.world.entity.combat.attack.FormulaFactory.getModifiedMaxHit;
22
23public class PureMelee extends SimplifiedListener<Player> implements BotClass {
24
25 @Override
26 public Item[] inventory() {
27 return new Item[] {
28 new Item(12695), new Item(391), new Item(391), new Item(391),
29 new Item(3024), new Item(391), new Item(391), new Item(391),
30 new Item(3024), new Item(391), new Item(391), new Item(391),
31 new Item(3024), new Item(391), new Item(391), new Item(391),
32 new Item(3024), new Item(391), new Item(391), new Item(391),
33 new Item(391), new Item(391), new Item(13652), new Item(3144),
34 new Item(3144), new Item(3144), new Item(3144), new Item(3144)
35 };
36 }
37
38 @Override
39 public Item[] equipment() {
40 return new Item[] { new Item(662), new Item(6107), new Item(6108), new Item(3105), new Item(7458), new Item(6570), new Item(3842), new Item(2550), new Item(1725), new Item(4587) };
41 }
42
43 @Override
44 public int[] skills() {
45 return new int[] { 60, 1, 99, 99, 99, 52, 1 };
46 }
47
48 @Override
49 public void initCombat(Player target, PlayerBot bot) {
50 pot(target, bot);
51 bot.prayer.toggle(Prayer.PROTECT_ITEM, Prayer.ULTIMATE_STRENGTH, Prayer.STEEL_SKIN, Prayer.INCREDIBLE_REFLEXES);
52 bot.getCombat().addListener(this);
53 bot.spellCasting.cast(new Vengeance(), null);
54 bot.getCombat().setFightType(FightType.SCIMITAR_SLASH);
55 }
56
57 @Override
58 public void handleCombat(Player target, PlayerBot bot) {
59 if (!bot.prayer.isActive(Prayer.SMITE) && target.prayer.isActive(Prayer.SMITE)) {
60 bot.prayer.toggle(Prayer.SMITE);
61 bot.speak("Let's smite then...");
62 } else if (bot.prayer.isActive(Prayer.SMITE) && !target.prayer.isActive(Prayer.SMITE)) {
63 bot.prayer.toggle(Prayer.SMITE);
64 }
65
66 if (bot.isSpecialActivated() && target.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
67 bot.speak("That's such bullshit...");
68 bot.getCombatSpecial().disable(bot, false);
69 bot.endFight();
70 }
71
72 if (!bot.prayer.isActive(Prayer.PROTECT_FROM_MELEE) && target.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
73 bot.prayer.toggle(Prayer.PROTECT_FROM_MELEE);
74 } else if (bot.prayer.isActive(Prayer.PROTECT_FROM_MELEE) && !target.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
75 bot.prayer.toggle(Prayer.PROTECT_FROM_MELEE);
76 }
77 }
78
79 @Override
80 public void endFight(PlayerBot bot) {
81 bot.prayer.deactivate(Prayer.PROTECT_ITEM, Prayer.SMITE, Prayer.ULTIMATE_STRENGTH, Prayer.STEEL_SKIN, Prayer.INCREDIBLE_REFLEXES);
82 }
83
84 @Override
85 public void hit(Player attacker, Mob defender, Hit hit) {
86 int max = getModifiedMaxHit(attacker, defender, CombatType.MELEE);
87
88 boolean hasRoom = attacker.inventory.getFreeSlots() > 0;
89 boolean hasSpec = attacker.getSpecialPercentage().intValue() >= 50;
90 boolean lowHp = defender.getCurrentHealth() <= defender.getMaximumHealth() * RandomUtils.inclusive(0.50, 0.65);
91 boolean combo = defender.getCurrentHealth() <= defender.getMaximumHealth() * RandomUtils.inclusive(0.50, 0.70)
92 && hit.getDamage() >= max * RandomUtils.inclusive(0.65, 0.75);
93
94 if (!hasSpec || !hasRoom || (!combo && !lowHp))
95 return;
96
97 PlayerBot bot = ((PlayerBot) attacker);
98 bot.schedule(4, () -> {
99 if (bot.equipment.getWeapon().matchesId(4587)) {
100 int index = bot.inventory.computeIndexForId(13652);
101 bot.equipment.equip(index);
102 bot.getCombat().setFightType(FightType.CLAWS_SLASH);
103 }
104
105 bot.getCombatSpecial().enable(bot);
106 bot.schedule(4, () -> {
107 if (!bot.isSpecialActivated() && bot.equipment.getWeapon().matchesId(13652)) {
108 int idx = bot.inventory.computeIndexForId(4587);
109 bot.equipment.equip(idx);
110 idx = bot.inventory.computeIndexForId(3842);
111 bot.equipment.equip(idx);
112 bot.getCombat().setFightType(FightType.SCIMITAR_SLASH);
113 }
114 });
115 });
116 }
117
118 @Override
119 public void pot(Player target, PlayerBot bot) {
120 int max = target.playerAssistant.getMaxHit(bot, target.getStrategy().getCombatType());
121 if (target.getCurrentHealth() <= Math.floor(target.getMaximumHealth() * 0.35) && max < bot.getCurrentHealth())
122 return;
123
124 if (!bot.potionDelay.elapsed(1250)) {
125 return;
126 }
127
128 PotionData potion;
129 ItemClickEvent event;
130
131 if (checkSkill(bot, Skill.PRAYER, 25)) {
132 int index = bot.inventory.computeIndexForId(3024);
133 if (index >= 0) {
134 event = new ItemClickEvent(0, bot.inventory.get(index), index);
135 potion = PotionData.SUPER_RESTORE_POTIONS;
136 bot.pot(target, event, potion);
137 }
138 } else if (checkSkill(bot, Skill.ATTACK, 71)
139 || checkSkill(bot, Skill.STRENGTH, 115)
140 || checkSkill(bot, Skill.DEFENCE, 3)) {
141 int index = bot.inventory.computeIndexForId(12695);
142 if (index >= 0) {
143 event = new ItemClickEvent(0, bot.inventory.get(index), index);
144 potion = PotionData.SUPER_COMBAT_POTION;
145 bot.pot(target, event, potion);
146 }
147 }
148 }
149
150 @Override
151 public void eat(Player target, PlayerBot bot) {
152 int max = target.playerAssistant.getMaxHit(bot, target.getStrategy().getCombatType());
153 if (bot.getCurrentHealth() > bot.getMaximumHealth() * 0.45 && max < bot.getCurrentHealth())
154 return;
155
156 if (target.getCurrentHealth() <= Math.floor(target.getMaximumHealth() * 0.35) && max < bot.getCurrentHealth())
157 return;
158
159 int index = bot.inventory.computeIndexForId(391);
160 if (index >= 0) {
161 EatFoodPlugin.eat(bot, bot.inventory.get(index), index, FoodData.MANTA);
162 bot.foodRemaining--;
163 }
164
165 if (bot.getCurrentHealth() >= bot.getMaximumHealth() * 0.35)
166 return;
167
168 index = bot.inventory.computeIndexForId(3144);
169 if (index >= 0) {
170 EatFoodPlugin.eat(bot, bot.inventory.get(index), index, FoodData.COOKED_KARAMBWAN);
171 bot.foodRemaining--;
172 }
173 }
174
175 @Override
176 public boolean canOtherAttack(Mob attacker, Player defender) {
177 if (defender.getCombat().isAttacking() && !defender.getCombat().isAttacking(attacker)) {
178 attacker.getPlayer().message("You cannot attack a bot while they are attacking another player.");
179 return false;
180 }
181 return true;
182 }
183
184 @Override
185 public void block(Mob attacker, Player defender, Hit hit, CombatType combatType) {
186 ((PlayerBot) defender).consumableDelay = RandomUtils.inclusive(1, 3);
187 }
188
189 private boolean checkSkill(PlayerBot bot, int id, int minimum) {
190 return bot.skills.getLevel(id) < minimum;
191 }
192
193}