RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Wyrm.java
1package com.osroyale.game.world.entity.combat.strategy.npc.boss;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.UpdatePriority;
5import com.osroyale.game.task.Task;
6import com.osroyale.game.world.World;
7import com.osroyale.game.world.entity.combat.CombatType;
8import com.osroyale.game.world.entity.combat.attack.FightType;
9import com.osroyale.game.world.entity.combat.hit.CombatHit;
10import com.osroyale.game.world.entity.combat.hit.Hit;
11import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
12import com.osroyale.game.world.entity.combat.strategy.npc.MultiStrategy;
13import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
14import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
15import com.osroyale.game.world.entity.mob.Mob;
16import com.osroyale.game.world.entity.mob.npc.Npc;
17
18import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
19import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
20import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
21
59
60public class Wyrm extends MultiStrategy {
61 private static final Melee MELEE = new Melee();
62 private static final Magic MAGIC = new Magic();
63
64 private static final CombatStrategy<Npc>[] STRATEGIES = createStrategyArray(MAGIC, MELEE);
65 private int attackCount = 0;
66
67 public Wyrm() {
68 this.currentStrategy = randomStrategy(STRATEGIES);
69 }
70
71 @Override
72 public boolean withinDistance(Npc attacker, Mob defender) {
73 if (!currentStrategy.withinDistance(attacker, defender)) {
74 currentStrategy = MAGIC;
75 }
76 return currentStrategy.withinDistance(attacker, defender);
77 }
78 @Override
79 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
80 hit.getDamage();
81 if (defender.definition.getId() == 8610) {
82 World.schedule(new Task(1) {
83 @Override
84 protected void execute() {
85 defender.transform(8611);
86 }
87 });
88 }
89 }
90
91 @Override
92 public boolean canAttack(Npc attacker, Mob defender) {
93 if (!currentStrategy.canAttack(attacker, defender)) {
94 currentStrategy = MAGIC;
95 } else currentStrategy = MELEE;
96 return currentStrategy.canAttack(attacker, defender);
97 }
98 @Override
99 public void finishOutgoing(Npc attacker, Mob defender) {
100 currentStrategy.finishOutgoing(attacker, defender);
101 if (NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
102 currentStrategy = MELEE;
103 } else {
104 currentStrategy = MAGIC;
105 }
106 }
107
108 @Override
109 public void hit(Npc attacker, Mob defender, Hit hit) {
110 super.hit(attacker, defender, hit);
111 }
112
113 @Override
114 public int modifyDefensive(Mob attacker, Npc defender, int roll) {
115 return (int) (roll * 2.3);
116 }
117
118 private static final class Melee extends NpcMeleeStrategy {
119 private static final Animation ANIMATION = new Animation(8271, UpdatePriority.HIGH);
120
121 @Override
122 public int getAttackDistance(Npc attacker, FightType fightType) {
123 return 1;
124 }
125
126 @Override
127 public Animation getAttackAnimation(Npc attacker, Mob defender) {
128 return ANIMATION;
129 }
130
131 @Override
132 public CombatHit[] getHits(Npc attacker, Mob defender) {
133 return new CombatHit[]{nextMeleeHit(attacker, defender)};
134 }
135 }
136
137 private static class Magic extends NpcMagicStrategy {
138 private static final Animation ANIMATION = new Animation(8270, UpdatePriority.HIGH);
139
140 private Magic() {
141 super(getDefinition("Wyrm Magic"));
142 }
143
144 @Override
145 public CombatHit[] getHits(Npc attacker, Mob defender) {
146 CombatHit combatHit = nextMagicHit(attacker, defender, 31);
147 combatHit.setAccurate(true);
148 return new CombatHit[]{combatHit};
149 }
150
151 @Override
152 public Animation getAttackAnimation(Npc attacker, Mob defender) {
153 return ANIMATION;
154 }
155
156 @Override
157 public int getAttackDistance(Npc attacker, FightType fightType) {
158 return 5;
159 }
160 }
161
162}
static void schedule(Task task)
Definition World.java:284