RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
CrazyArchaeologist.java
1package com.osroyale.game.world.entity.combat.strategy.npc.boss;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.Graphic;
5import com.osroyale.game.Projectile;
6import com.osroyale.game.UpdatePriority;
7import com.osroyale.game.world.World;
8import com.osroyale.game.world.entity.combat.CombatType;
9import com.osroyale.game.world.entity.combat.attack.FightType;
10import com.osroyale.game.world.entity.combat.hit.CombatHit;
11import com.osroyale.game.world.entity.combat.hit.Hit;
12import com.osroyale.game.world.entity.combat.projectile.CombatProjectile;
13import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
14import com.osroyale.game.world.entity.combat.strategy.npc.MultiStrategy;
15import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
16import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
17import com.osroyale.game.world.entity.combat.strategy.npc.NpcRangedStrategy;
18import com.osroyale.game.world.entity.mob.Mob;
19import com.osroyale.game.world.entity.mob.npc.Npc;
20import com.osroyale.game.world.position.Position;
21import com.osroyale.util.Utility;
22
23import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
24import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
25import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
26
66
67public class CrazyArchaeologist extends MultiStrategy {
68 private static RainAttack RAIN = new RainAttack();
69 private static RangeAttack RANGE = new RangeAttack();
70 private static final CombatStrategy<Npc>[] FULL_STRATEGIES = createStrategyArray(RAIN, RANGE, NpcMeleeStrategy.get(), RANGE, NpcMeleeStrategy.get());
71 private static final CombatStrategy<Npc>[] NON_MELEE = createStrategyArray(RAIN, RANGE, RANGE, RANGE, RANGE);
72
73 private static final String[] MESSAGES = {
74 "I'm Bellock - respect me!",
75 "Get off my site!",
76 "No-one messes with Bellock's dig!",
77 "These ruins are mine!",
78 "Taste my knowledge!",
79 "You belong in a museum!",
80 };
81
82 public CrazyArchaeologist() {
83 currentStrategy = randomStrategy(NON_MELEE);
84 }
85
86 @Override
87 public boolean canAttack(Npc attacker, Mob defender) {
88 if (!currentStrategy.withinDistance(attacker, defender)) {
89 currentStrategy = randomStrategy(NON_MELEE);
90 }
91 return currentStrategy.canAttack(attacker, defender);
92 }
93
94 @Override
95 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
96 currentStrategy.block(attacker, defender, hit, combatType);
97 defender.getCombat().attack(attacker);
98 }
99
100 @Override
101 public void finishOutgoing(Npc attacker, Mob defender) {
102 currentStrategy.finishOutgoing(attacker, defender);
103 if (NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
104 currentStrategy = randomStrategy(FULL_STRATEGIES);
105 } else {
106 currentStrategy = randomStrategy(NON_MELEE);
107 }
108 if (currentStrategy != RAIN) {
109 attacker.speak(Utility.randomElement(MESSAGES));
110 }
111 }
112
113 @Override
114 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
115 return attacker.definition.getAttackDelay();
116 }
117
118 private static class RainAttack extends NpcMagicStrategy {
119
120 RainAttack() {
121 super(CombatProjectile.getDefinition("EMPTY"));
122 }
123
124 @Override
125 public void start(Npc attacker, Mob defender, Hit[] hits) {
126 attacker.animate(new Animation(1162, UpdatePriority.VERY_HIGH));
127 attacker.speak("Rain of knowledge!");
128 for (int i = 0; i < 3; i++) {
129 int offsetX = defender.getX() - attacker.getX();
130 int offsetY = defender.getY() - attacker.getY();
131 if (i == 0 || i == 2) {
132 offsetX += i == 0 ? -1 : 1;
133 offsetY++;
134 }
135 World.sendProjectile(new Projectile(1260, 46, 80, 43, 31), attacker.getPosition(), attacker.instance, -1, (byte) offsetX, (byte) offsetY);
136 Position end = new Position(attacker.getX() + offsetX, attacker.getY() + offsetY, 0);
137 World.schedule(3, () -> {
138 if (defender.getPosition().equals(end)) {
139 defender.damage(nextMagicHit(attacker, defender, 23, combatProjectile));
140 }
141 World.sendGraphic(new Graphic(131, UpdatePriority.HIGH), end, attacker.instance);
142 });
143 }
144 }
145
146 @Override
147 public void hit(Npc attacker, Mob defender, Hit hit) {
148 }
149
150 @Override
151 public void attack(Npc attacker, Mob defender, Hit hit) {
152 }
153
154 @Override
155 public CombatHit[] getHits(Npc attacker, Mob defender) {
156 CombatHit hit = nextMagicHit(attacker, defender, 23, combatProjectile);
157 hit.setAccurate(false);
158 return new CombatHit[] {hit};
159 }
160
161 @Override
162 public int modifyAccuracy(Npc attacker, Mob defender, int roll) {
163 return roll + 50_000;
164 }
165
166 }
167
168 private static class RangeAttack extends NpcRangedStrategy {
169 public RangeAttack() {
170 super(getDefinition("Archaeologist Range"));
171 }
172 }
173}
static void sendGraphic(Graphic graphic, Position position, int instance)
Definition World.java:305
static void schedule(Task task)
Definition World.java:284
static void sendProjectile(Projectile projectile, Position position, int instance, int lock, byte offsetX, byte offsetY)
Definition World.java:332
void speak(String forceChat)
Definition Mob.java:164
abstract Combat<? extends Mob > getCombat()
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285