RuneHive-Game
Loading...
Searching...
No Matches
PureRangeMelee.java
Go to the documentation of this file.
1package com.runehive.content.bot.botclass.impl;
2
3import com.runehive.content.bot.PlayerBot;
4import com.runehive.content.bot.botclass.BotClass;
5import com.runehive.content.consume.FoodData;
6import com.runehive.content.consume.PotionData;
7import com.runehive.content.skill.impl.magic.spell.impl.Vengeance;
8import com.runehive.game.event.impl.ItemClickEvent;
9import com.runehive.game.world.entity.combat.CombatType;
10import com.runehive.game.world.entity.combat.attack.FightType;
11import com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener;
12import com.runehive.game.world.entity.combat.hit.Hit;
13import com.runehive.game.world.entity.mob.Mob;
14import com.runehive.game.world.entity.mob.player.Player;
15import com.runehive.game.world.entity.mob.prayer.Prayer;
16import com.runehive.game.world.entity.skill.Skill;
17import com.runehive.game.world.items.Item;
18import com.runehive.util.RandomUtils;
19import plugin.click.item.EatFoodPlugin;
20
21import static com.runehive.game.world.entity.combat.attack.FormulaFactory.getModifiedMaxHit;
22
23public class PureRangeMelee extends SimplifiedListener<Player> implements BotClass {
24
25 @Override
26 public Item[] inventory() {
27 return new Item[] {
28 new Item(2444), new Item(12695), new Item(3144), new Item(3144),
29 new Item(3024), new Item(3024), new Item(3144), new Item(3144),
30 new Item(3024), new Item(3024), new Item(391), 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(11802), new Item(391), new Item(391),
34 new Item(391), new Item(391), new Item(391), new Item(391)
35 };
36 }
37
38 @Override
39 public Item[] equipment() {
40 return new Item[] { new Item(2900), new Item(10498), new Item(1129), new Item(11978), new Item(892, 125), new Item(3105), new Item(2497), new Item(861), new Item(2491) };
41 }
42
43 @Override
44 public int[] skills() {
45 return new int[] { 75, 1, 99, 80, 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.EAGLE_EYE);
52 bot.getCombat().addListener(this);
53 bot.spellCasting.cast(new Vengeance(), null);
54 bot.getCombat().setFightType(FightType.SHORTBOW_RAPID);
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 not fair...");
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
83
84 @Override
85 public void hit(Player attacker, Mob defender, Hit hit) {
86 int max = getModifiedMaxHit(attacker, defender, CombatType.MELEE);
87
88 boolean hasSpec = attacker.getSpecialPercentage().intValue() >= 50;
89 boolean lowHp = defender.getCurrentHealth() <= defender.getMaximumHealth() * RandomUtils.inclusive(0.50, 0.65);
90 boolean combo = defender.getCurrentHealth() <= defender.getMaximumHealth() * RandomUtils.inclusive(0.50, 0.70)
91 && hit.getDamage() >= max * RandomUtils.inclusive(0.65, 0.75);
92
93 if (!combo && !lowHp)
94 return;
95
96 PlayerBot bot = ((PlayerBot) attacker);
97 bot.schedule(4, () -> {
98 if (bot.equipment.getWeapon().matchesId(861)) {
99 int index = bot.inventory.computeIndexForId(11802);
100 bot.equipment.equip(index);
101 bot.getCombat().setFightType(FightType.GODSWORD_SLASH);
103 }
104
105 if (hasSpec && (lowHp || RandomUtils.success(0.75)))
106 bot.getCombatSpecial().enable(bot);
107
108 bot.schedule(4, () -> {
109 if (!bot.isSpecialActivated() && bot.equipment.getWeapon().matchesId(11802)) {
110 int idx = bot.inventory.computeIndexForId(861);
111 bot.equipment.equip(idx);
112 bot.getCombat().setFightType(FightType.SHORTBOW_RAPID);
114 }
115 });
116 });
117 }
118
119 @Override
120 public void pot(Player target, PlayerBot bot) {
121 int max = target.playerAssistant.getMaxHit(bot, target.getStrategy().getCombatType());
122 if (target.getCurrentHealth() <= Math.floor(target.getMaximumHealth() * 0.35) && max < bot.getCurrentHealth())
123 return;
124
125 if (!bot.potionDelay.elapsed(1250)) {
126 return;
127 }
128
129 PotionData potion;
131
132 if (checkSkill(bot, Skill.PRAYER, 25)) {
133 int index = bot.inventory.computeIndexForId(3024);
134 if (index >= 0) {
135 event = new ItemClickEvent(0, bot.inventory.get(index), index);
137 bot.pot(target, event, potion);
138 }
139 } else {
140 if (checkSkill(bot, Skill.ATTACK, 71)
141 || checkSkill(bot, Skill.STRENGTH, 115)
142 || checkSkill(bot, Skill.DEFENCE, 3)) {
143 int index = bot.inventory.computeIndexForId(12695);
144 if (index >= 0) {
145 event = new ItemClickEvent(0, bot.inventory.get(index), index);
147 bot.pot(target, event, potion);
148 }
149 }
150 if (checkSkill(bot, Skill.RANGED, 108)) {
151 int index = bot.inventory.computeIndexForId(2444);
152 if (index >= 0) {
153 event = new ItemClickEvent(0, bot.inventory.get(index), index);
154 potion = PotionData.RANGE_POTIONS;
155 bot.pot(target, event, potion);
156 }
157 }
158 }
159 }
160
161 @Override
162 public void eat(Player target, PlayerBot bot) {
163 int max = target.playerAssistant.getMaxHit(bot, target.getStrategy().getCombatType());
164 if (bot.getCurrentHealth() > bot.getMaximumHealth() * 0.45 && max < bot.getCurrentHealth())
165 return;
166
167 if (target.getCurrentHealth() <= Math.floor(target.getMaximumHealth() * 0.35) && max < bot.getCurrentHealth())
168 return;
169
170 int index = bot.inventory.computeIndexForId(391);
171 if (index >= 0) {
172 EatFoodPlugin.eat(bot, bot.inventory.get(index), index, FoodData.MANTA);
173 bot.foodRemaining--;
174 }
175
176 if (bot.getCurrentHealth() >= bot.getMaximumHealth() * 0.35)
177 return;
178
179 index = bot.inventory.computeIndexForId(3144);
180 if (index >= 0) {
181 EatFoodPlugin.eat(bot, bot.inventory.get(index), index, FoodData.COOKED_KARAMBWAN);
182 bot.foodRemaining--;
183 }
184 }
185
186 @Override
187 public boolean canOtherAttack(Mob attacker, Player defender) {
188 if (defender.getCombat().isAttacking() && !defender.getCombat().isAttacking(attacker)) {
189 attacker.getPlayer().message("You cannot attack a bot while they are attacking another player.");
190 return false;
191 }
192 return true;
193 }
194
195 @Override
196 public void block(Mob attacker, Player defender, Hit hit, CombatType combatType) {
197 ((PlayerBot) defender).consumableDelay = RandomUtils.inclusive(1, 3);
198 }
199
202
203 if (bot.prayer.isActive(Prayer.EAGLE_EYE))
204 bot.prayer.toggle(Prayer.EAGLE_EYE);
205 }
206
207 private void meleePrayers(PlayerBot bot) {
208 bot.prayer.deactivate(Prayer.EAGLE_EYE);
209
210 if (bot.prayer.isActive(Prayer.ULTIMATE_STRENGTH))
211 bot.prayer.toggle(Prayer.ULTIMATE_STRENGTH);
212
213 if (bot.prayer.isActive(Prayer.STEEL_SKIN))
214 bot.prayer.toggle(Prayer.STEEL_SKIN);
215
216 if (bot.prayer.isActive(Prayer.INCREDIBLE_REFLEXES))
217 bot.prayer.toggle(Prayer.INCREDIBLE_REFLEXES);
218 }
219
220 private boolean checkSkill(PlayerBot bot, int id, int minimum) {
221 return bot.skills.getLevel(id) <= minimum;
222 }
223
224}
boolean checkSkill(PlayerBot bot, int id, int minimum)
void block(Mob attacker, Player defender, Hit hit, CombatType combatType)
boolean canOtherAttack(Mob attacker, Player defender)
void hit(Player attacker, Mob defender, Hit hit)
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
Handles the mob class.
Definition Mob.java:66
int getMaxHit(Mob defender, CombatType type)
Gets the max hit of a combat type.
This class represents a character controlled by a player.
Definition Player.java:125
CombatStrategy< Player > getStrategy()
The combat strategy of the mob.
Definition Player.java:764
Combat< Player > getCombat()
The combat of the mob.
Definition Player.java:759
boolean isActive(Prayer... prayers)
Checks if all given prayers are active.
Represents a trainable and usable skill.
Definition Skill.java:18
static final int PRAYER
The prayer skill id.
Definition Skill.java:36
static final int RANGED
The ranged skill id.
Definition Skill.java:33
static final int DEFENCE
The defence skill id.
Definition Skill.java:24
static final int ATTACK
The attack skill id.
Definition Skill.java:21
static final int STRENGTH
The strength skill id.
Definition Skill.java:27
The container class that represents an item that can be interacted with.
Definition Item.java:21
A static-util class that provides additional functionality for generating pseudo-random numbers.
static int inclusive(int min, int max)
Returns a pseudo-random int value between inclusive min and inclusive max.
static boolean success(double value)
Determines if a pseudorandomly generated double rounded to two decimal places is below or equal to va...
The enumerated type managing consumable potion types.
The enumerated type whose elements represent the fighting types.