RuneHive-Game
Loading...
Searching...
No Matches
KalphiteQueenMagicStrategy.kt
Go to the documentation of this file.
1package org.jire.runehiveps.kalphitequeen
2
3import com.runehive.game.Animation
4import com.runehive.game.Graphic
5import com.runehive.game.Projectile
6import com.runehive.game.world.entity.combat.hit.CombatHit
7import com.runehive.game.world.entity.combat.hit.Hit
8import com.runehive.game.world.entity.combat.projectile.CombatProjectile
9import com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy
10import com.runehive.game.world.entity.mob.Mob
11import com.runehive.game.world.entity.mob.npc.Npc
12import com.runehive.game.world.region.RegionManager
13
14/**
15 * @author Jire
16 */
17internal class KalphiteQueenMagicStrategy(
18 anim: Int,
19 graphic: Int,
20) : NpcMagicStrategy(
21 CombatProjectile(
22 "KalphiteQueen-MagicStrategy-$anim-$graphic", 31, null,
23 Animation(anim), Graphic(graphic), Graphic(281),
24 Projectile(280, 70, 90, 60, 43, 16, 128)
25 )
26) {
27
28 override fun getAttackAnimation(attacker: Npc, defender: Mob): Animation = Animation.RESET
29
30 override fun start(attacker: Npc, defender: Mob, hits: Array<out Hit>) {
31 super.start(attacker, defender, hits)
32 sendAttack(attacker, defender, hits, true)
33 }
34
35 override fun sendProjectile(
36 attacker: Npc,
37 hits: Array<out Hit>,
38 from: Mob,
39 to: Mob,
40 onProjectileLand: Runnable?
41 ) = 0
42
43 private fun sendAttack(attacker: Npc, target: Mob, hits: Array<out Hit>, first: Boolean) {
44 super.sendProjectile(attacker, hits, attacker, target) {
45 if (!first) target.damage(*hits)
46 RegionManager.forNearbyPlayer(target, 1) {
47 if (target != it && canAttack(attacker, it)) {
48 sendAttack(attacker, it, hits, false)
49 }
50 }
51 }
52 }
53
54 override fun isAlwaysAccurate() = true
55
56 override fun getHits(attacker: Npc, defender: Mob): Array<CombatHit> {
57 val hit = nextMagicHit(attacker, defender, combatProjectile)
58 hit.isAccurate = true
59 return arrayOf(hit)
60 }
61
62 companion object {
63 val phase1 = KalphiteQueenMagicStrategy(1173, 278)
64 val phase2 = KalphiteQueenMagicStrategy(6234, 279)
65 }
66
67}