1package com.osroyale.content.bot.botclass.impl;
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;
21import java.util.concurrent.TimeUnit;
23import static com.osroyale.game.world.entity.combat.attack.FormulaFactory.getModifiedMaxHit;
25public class AGSRuneMelee
extends SimplifiedListener<Player> implements BotClass {
28 public Item[] inventory() {
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(11802),
new Item(557, 500),
new Item(560, 500),
new Item(9075, 500)
41 public Item[] equipment() {
42 return new Item[] {
new Item(10828),
new Item(10551),
new Item(1079),
new Item(3105),
new Item(4587),
new Item(12954),
new Item(1725),
new Item(2550),
new Item(7462),
new Item(6570) };
46 public int[] skills() {
47 return new int[] { 99, 99, 99, 99, 99, 99, 99 };
51 public void initCombat(Player target, PlayerBot 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);
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);
68 if (bot.isSpecialActivated() && target.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
69 bot.speak(
"That's such bullshit...");
70 bot.getCombatSpecial().disable(bot,
false);
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);
80 if (bot.spellCasting.vengeanceDelay.elapsedTime(TimeUnit.SECONDS) >= 30) {
81 bot.spellCasting.cast(
new Vengeance(),
null);
86 public void endFight(PlayerBot bot) {
87 bot.prayer.deactivate(Prayer.PROTECT_ITEM, Prayer.SMITE, Prayer.PIETY);
91 public void hit(Player attacker, Mob defender, Hit hit) {
92 int max = getModifiedMaxHit(attacker, defender, CombatType.MELEE);
94 boolean hasRoom = attacker.inventory.getFreeSlots() > 0;
95 boolean hasSpec = attacker.getSpecialPercentage().intValue() >= 50;
96 boolean lowHp = defender.getCurrentHealth() <= defender.getMaximumHealth() * RandomUtils.inclusive(0.50, 0.65);
97 boolean combo = defender.getCurrentHealth() <= defender.getMaximumHealth() * RandomUtils.inclusive(0.50, 0.70)
98 && hit.getDamage() >= max * RandomUtils.inclusive(0.65, 0.75);
100 if (!hasRoom || (!combo && !lowHp))
103 PlayerBot bot = ((PlayerBot) attacker);
104 bot.schedule(4, () -> {
105 if (bot.equipment.getWeapon().matchesId(4587)) {
106 int index = bot.inventory.computeIndexForId(11802);
107 bot.equipment.equip(index);
108 bot.getCombat().setFightType(FightType.GODSWORD_SLASH);
111 if (hasSpec && (lowHp || RandomUtils.success(0.75)))
112 bot.getCombatSpecial().enable(bot);
114 bot.schedule(4, () -> {
115 if (!bot.isSpecialActivated() && bot.equipment.getWeapon().matchesId(11802)) {
116 int idx = bot.inventory.computeIndexForId(4587);
117 bot.equipment.equip(idx);
118 idx = bot.inventory.computeIndexForId(12954);
119 bot.equipment.equip(idx);
120 bot.getCombat().setFightType(FightType.SCIMITAR_SLASH);
127 public void pot(Player target, PlayerBot bot) {
128 if (target.getCurrentHealth() <= Math.floor(target.getMaximumHealth() * 0.35))
131 if (!bot.potionDelay.elapsed(1250)) {
136 ItemClickEvent event;
138 if (checkSkill(bot, Skill.PRAYER, 40)) {
139 int index = bot.inventory.computeIndexForId(3024);
141 event =
new ItemClickEvent(0, bot.inventory.get(index), index);
142 potion = PotionData.SUPER_RESTORE_POTIONS;
143 bot.pot(target, event, potion);
145 }
else if (checkSkill(bot, Skill.ATTACK, 115)
146 || checkSkill(bot, Skill.STRENGTH, 115)
147 || checkSkill(bot, Skill.DEFENCE, 115)) {
148 int index = bot.inventory.computeIndexForId(12695);
150 event =
new ItemClickEvent(0, bot.inventory.get(index), index);
151 potion = PotionData.SUPER_COMBAT_POTION;
152 bot.pot(target, event, potion);
158 public void eat(Player target, PlayerBot bot) {
159 int max = target.playerAssistant.getMaxHit(bot, target.getStrategy().getCombatType());
160 if (bot.getCurrentHealth() > bot.getMaximumHealth() * 0.45 && max < bot.getCurrentHealth())
163 if (target.getCurrentHealth() <= Math.floor(target.getMaximumHealth() * 0.35) && max < bot.getCurrentHealth())
166 int index = bot.inventory.computeIndexForId(391);
168 EatFoodPlugin.eat(bot, bot.inventory.get(index), index, FoodData.MANTA);
172 if (bot.getCurrentHealth() >= bot.getMaximumHealth() * 0.35)
175 index = bot.inventory.computeIndexForId(3144);
177 EatFoodPlugin.eat(bot, bot.inventory.get(index), index, FoodData.COOKED_KARAMBWAN);
183 public boolean canOtherAttack(Mob attacker, Player defender) {
184 if (defender.getCombat().isAttacking() && !defender.getCombat().isAttacking(attacker)) {
185 attacker.getPlayer().message(
"You cannot attack a bot while they are attacking another player.");
192 public void block(Mob attacker, Player defender, Hit hit, CombatType combatType) {
193 ((PlayerBot) defender).consumableDelay = RandomUtils.inclusive(1, 3);
196 private boolean checkSkill(PlayerBot bot,
int id,
int minimum) {
197 return bot.skills.getLevel(
id) < minimum;