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