RuneHive-Game
Loading...
Searching...
No Matches
CrazyArchaeologist.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.npc.boss;
2
3import com.runehive.game.Animation;
4import com.runehive.game.Graphic;
5import com.runehive.game.Projectile;
6import com.runehive.game.UpdatePriority;
7import com.runehive.game.world.World;
8import com.runehive.game.world.entity.combat.CombatType;
9import com.runehive.game.world.entity.combat.attack.FightType;
10import com.runehive.game.world.entity.combat.hit.CombatHit;
11import com.runehive.game.world.entity.combat.hit.Hit;
12import com.runehive.game.world.entity.combat.projectile.CombatProjectile;
13import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
14import com.runehive.game.world.entity.combat.strategy.npc.MultiStrategy;
15import com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
16import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
17import com.runehive.game.world.entity.combat.strategy.npc.NpcRangedStrategy;
18import com.runehive.game.world.entity.mob.Mob;
19import com.runehive.game.world.entity.mob.npc.Npc;
20import com.runehive.game.world.position.Position;
21import com.runehive.util.Utility;
22
23import static com.runehive.game.world.entity.combat.CombatUtil.createStrategyArray;
24import static com.runehive.game.world.entity.combat.CombatUtil.randomStrategy;
25import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
26
27/**
28 * @author Daniel
29 */
30public class CrazyArchaeologist extends MultiStrategy {
31 private static RainAttack RAIN = new RainAttack();
32 private static RangeAttack RANGE = new RangeAttack();
33 private static final CombatStrategy<Npc>[] FULL_STRATEGIES = createStrategyArray(RAIN, RANGE, NpcMeleeStrategy.get(), RANGE, NpcMeleeStrategy.get());
34 private static final CombatStrategy<Npc>[] NON_MELEE = createStrategyArray(RAIN, RANGE, RANGE, RANGE, RANGE);
35
36 private static final String[] MESSAGES = {
37 "I'm Bellock - respect me!",
38 "Get off my site!",
39 "No-one messes with Bellock's dig!",
40 "These ruins are mine!",
41 "Taste my knowledge!",
42 "You belong in a museum!",
43 };
44
46 currentStrategy = randomStrategy(NON_MELEE);
47 }
48
49 @Override
50 public boolean canAttack(Npc attacker, Mob defender) {
51 if (!currentStrategy.withinDistance(attacker, defender)) {
52 currentStrategy = randomStrategy(NON_MELEE);
53 }
54 return currentStrategy.canAttack(attacker, defender);
55 }
56
57 @Override
58 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
59 currentStrategy.block(attacker, defender, hit, combatType);
60 defender.getCombat().attack(attacker);
61 }
62
63 @Override
64 public void finishOutgoing(Npc attacker, Mob defender) {
65 currentStrategy.finishOutgoing(attacker, defender);
66 if (NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
67 currentStrategy = randomStrategy(FULL_STRATEGIES);
68 } else {
69 currentStrategy = randomStrategy(NON_MELEE);
70 }
71 if (currentStrategy != RAIN) {
73 }
74 }
75
76 @Override
77 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
78 return attacker.definition.getAttackDelay();
79 }
80
81 private static class RainAttack extends NpcMagicStrategy {
82
84 super(CombatProjectile.getDefinition("EMPTY"));
85 }
86
87 @Override
88 public void start(Npc attacker, Mob defender, Hit[] hits) {
89 attacker.animate(new Animation(1162, UpdatePriority.VERY_HIGH));
90 attacker.speak("Rain of knowledge!");
91 for (int i = 0; i < 3; i++) {
92 int offsetX = defender.getX() - attacker.getX();
93 int offsetY = defender.getY() - attacker.getY();
94 if (i == 0 || i == 2) {
95 offsetX += i == 0 ? -1 : 1;
96 offsetY++;
97 }
98 World.sendProjectile(new Projectile(1260, 46, 80, 43, 31), attacker.getPosition(), attacker.instance, -1, (byte) offsetX, (byte) offsetY);
99 Position end = new Position(attacker.getX() + offsetX, attacker.getY() + offsetY, 0);
100 World.schedule(3, () -> {
101 if (defender.getPosition().equals(end)) {
102 defender.damage(nextMagicHit(attacker, defender, 23, combatProjectile));
103 }
104 World.sendGraphic(new Graphic(131, UpdatePriority.HIGH), end, attacker.instance);
105 });
106 }
107 }
108
109 @Override
110 public void hit(Npc attacker, Mob defender, Hit hit) {
111 }
112
113 @Override
114 public void attack(Npc attacker, Mob defender, Hit hit) {
115 }
116
117 @Override
118 public CombatHit[] getHits(Npc attacker, Mob defender) {
119 CombatHit hit = nextMagicHit(attacker, defender, 23, combatProjectile);
120 hit.setAccurate(false);
121 return new CombatHit[] {hit};
122 }
123
124 @Override
125 public int modifyAccuracy(Npc attacker, Mob defender, int roll) {
126 return roll + 50_000;
127 }
128
129 }
130
131 private static class RangeAttack extends NpcRangedStrategy {
132 public RangeAttack() {
133 super(getDefinition("Archaeologist Range"));
134 }
135 }
136}
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
static void sendGraphic(Graphic graphic, Position position, int instance)
Sends a graphic to the world.
Definition World.java:268
static void sendProjectile(Projectile projectile, Position position, int instance, int lock, byte offsetX, byte offsetY)
Sends a world projectile.
Definition World.java:295
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
final CombatHit nextMagicHit(T attacker, Mob defender)
int getAttackDelay(Npc attacker, Mob defender, FightType fightType)
void block(Mob attacker, Npc defender, Hit hit, CombatType combatType)
Handles the mob class.
Definition Mob.java:66
void speak(String forceChat)
Sets the mob's forced chat.
Definition Mob.java:127
Represents a non-player character in the in-game world.
Definition Npc.java:29
Combat< Npc > getCombat()
The combat of the mob.
Definition Npc.java:156
Represents a single tile on the game world.
Definition Position.java:14
Handles miscellaneous methods.
Definition Utility.java:27
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.