RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Venenatis.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.UpdatePriority;
6import com.osroyale.game.task.TickableTask;
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.mob.Mob;
18import com.osroyale.game.world.entity.mob.data.LockType;
19import com.osroyale.game.world.entity.mob.npc.Npc;
20import com.osroyale.game.world.entity.mob.prayer.Prayer;
21import com.osroyale.game.world.entity.skill.Skill;
22import com.osroyale.game.world.position.Area;
23import com.osroyale.util.RandomUtils;
24
25import static com.osroyale.game.world.entity.combat.CombatUtil.*;
26
56
57public class Venenatis extends MultiStrategy {
58 private static final PrayerDrain PRAYER_DRAIN = new PrayerDrain();
59 private static final Magic MAGIC = new Magic();
60 private static final Web WEB = new Web();
61
62 private static final CombatStrategy<Npc>[] FULL_STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), NpcMeleeStrategy.get(), MAGIC, MAGIC, PRAYER_DRAIN, WEB);
63 private static final CombatStrategy<Npc>[] NON_MELEE = createStrategyArray(MAGIC, MAGIC, PRAYER_DRAIN, WEB);
64
65 public Venenatis() {
66 currentStrategy = MAGIC;
67 }
68
69 @Override
70 public boolean withinDistance(Npc attacker, Mob defender) {
71 if (currentStrategy == NpcMeleeStrategy.get() && !currentStrategy.withinDistance(attacker, defender) && !defender.prayer.isActive(Prayer.PROTECT_FROM_MAGIC)) {
72 currentStrategy = randomStrategy(NON_MELEE);
73 }
74 return currentStrategy.withinDistance(attacker, defender);
75 }
76
77 @Override
78 public boolean canAttack(Npc attacker, Mob defender) {
79 if (!currentStrategy.canAttack(attacker, defender)) {
80 currentStrategy = randomStrategy(FULL_STRATEGIES);
81 }
82 return currentStrategy.canAttack(attacker, defender);
83 }
84
85 @Override
86 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
87// if (hit.isAccurate() && !Area.inMulti(defender)) { TODO: Gotta make the area multi first
88// hit.modifyDamage(damage -> RandomUtils.inclusive(1, 6));
89// }
90
91 currentStrategy.block(attacker, defender, hit, combatType);
92 defender.getCombat().attack(attacker);
93 }
94
95 @Override
96 public void finishOutgoing(Npc attacker, Mob defender) {
97 CombatStrategy<Npc> strategy = currentStrategy;
98 currentStrategy.finishOutgoing(attacker, defender);
99
100 if (strategy != currentStrategy)
101 return;
102
103 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
104 currentStrategy = randomStrategy(NON_MELEE);
105 } else {
106 currentStrategy = randomStrategy(FULL_STRATEGIES);
107 }
108 }
109
110 private static final class Magic extends NpcMagicStrategy {
111 private static final Animation ANIMATION = new Animation(5322, UpdatePriority.HIGH);
112
113 Magic() {
114 super(CombatProjectile.getDefinition("Earth Wave"));
115 }
116
117 @Override
118 public Animation getAttackAnimation(Npc attacker, Mob defender) {
119 return ANIMATION;
120 }
121
122 @Override
123 public CombatHit[] getHits(Npc attacker, Mob defender) {
124 return new CombatHit[]{nextMagicHit(attacker, defender)};
125 }
126 }
127
128 private static final class Web extends NpcMagicStrategy {
129 private static final Animation ANIMATION = new Animation(5322, UpdatePriority.HIGH);
130 private static final Graphic GRAPHIC = new Graphic(80, true, UpdatePriority.HIGH);
131
132 Web() {
133 super(CombatProjectile.getDefinition("EMPTY"));
134 }
135
136 @Override
137 public boolean canAttack(Npc attacker, Mob defender) {
138 return !defender.locking.locked() && super.canAttack(attacker, defender);
139 }
140
141 @Override
142 public void hit(Npc attacker, Mob defender, Hit hit) {
143 super.hit(attacker, defender, hit);
144 if (!hit.isAccurate())
145 return;
146 if (defender.isPlayer())
147 defender.getPlayer().message("Venenatis hurls her web at you, sticking you to the ground.");
148 defender.graphic(GRAPHIC);
149 defender.locking.lock(5, LockType.WALKING);
150 }
151
152 @Override
153 public void finishOutgoing(Npc attacker, Mob defender) {
154 attacker.getCombat().setCooldown(0);
155 ((Venenatis) attacker.getStrategy()).currentStrategy = RandomUtils.randomExclude(FULL_STRATEGIES, WEB);
156 }
157
158 @Override
159 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
160 return 0;
161 }
162
163 @Override
164 public Animation getAttackAnimation(Npc attacker, Mob defender) {
165 return ANIMATION;
166 }
167
168 @Override
169 public CombatHit[] getHits(Npc attacker, Mob defender) {
170 return new CombatHit[]{nextMagicHit(attacker, defender, 50)};
171 }
172 }
173
174 private static final class PrayerDrain extends NpcMagicStrategy {
175 PrayerDrain() {
176 super(CombatProjectile.getDefinition("EMPTY"));
177 }
178
179 @Override
180 public void hit(Npc attacker, Mob defender, Hit hit) {
181 if (!hit.isAccurate()) return;
182 World.schedule(new TickableTask(true, 1) {
183 @Override
184 protected void tick() {
185 defender.graphic(new Graphic(172, true, UpdatePriority.HIGH));
186 Skill prayer = defender.skills.get(Skill.PRAYER);
187 prayer.modifyLevel(level -> level * 2 / 3);
188 defender.skills.refresh(Skill.PRAYER);
189
190 if (defender.isPlayer())
191 defender.getPlayer().message("Your prayer has been drained!");
192
193 if (tick == ((CombatHit) hit).getHitsplatDelay() - 1)
194 cancel();
195 }
196 });
197 }
198
199 @Override
200 public CombatHit[] getHits(Npc attacker, Mob defender) {
201 int hitDelay = getHitDelay(attacker, defender, CombatType.MAGIC);
202 return new CombatHit[]{nextMagicHit(attacker, defender, 50, hitDelay, RandomUtils.inclusive(1, 3))};
203 }
204 }
205
206}
static void schedule(Task task)
Definition World.java:284
abstract Combat<? extends Mob > getCombat()
CombatStrategy< Npc > getStrategy()
Definition Npc.java:198
void modifyLevel(Function< Integer, Integer > function)
Definition Skill.java:318