RuneHive-Game
Loading...
Searching...
No Matches
KalphiteQueenRangedStrategy.kt
Go to the documentation of this file.
1package org.jire.runehiveps.kalphitequeen
2
3import com.runehive.game.Animation
4import com.runehive.game.Projectile
5import com.runehive.game.world.entity.combat.hit.CombatHit
6import com.runehive.game.world.entity.combat.hit.Hit
7import com.runehive.game.world.entity.combat.projectile.CombatProjectile
8import com.runehive.game.world.entity.combat.strategy.npc.NpcRangedStrategy
9import com.runehive.game.world.entity.mob.Mob
10import com.runehive.game.world.entity.mob.npc.Npc
11import com.runehive.game.world.entity.mob.player.Player
12import com.runehive.game.world.entity.skill.Skill
13import com.runehive.game.world.region.RegionManager
14
15/**
16 * @author Jire
17 */
18internal class KalphiteQueenRangedStrategy(anim: Int, proj: Int) : NpcRangedStrategy(
19 CombatProjectile(
20 "KalphiteQueen-RangedStrategy-$anim-$proj", 31, null,
21 Animation(anim), null, null,
22 Projectile(proj, 30, 60, 25, 0, 16, 128)
23 )
24) {
25
26 private val attackAnimation = Animation(anim)
27
28 override fun getAttackAnimation(attacker: Npc, defender: Mob): Animation = attackAnimation
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(from: Mob, to: Mob, onProjectileLand: Runnable?) = 0
36
37 private fun sendAttack(attacker: Npc, target: Mob, hits: Array<out Hit>, first: Boolean) {
38 super.sendProjectile(attacker, target) {
39 if (!first) target.damage(*hits)
40 if (target is Player && hits.any { it.isAccurate }) {
41 target.skills.get(Skill.PRAYER).modifyLevel { it - 1 }
42 target.skills.refresh(Skill.PRAYER)
43 //target.message("Your prayer has been drained!")
44 }
45 RegionManager.forNearbyPlayer(target, 1) {
46 if (target != it && canAttack(attacker, it)) {
47 sendAttack(attacker, it, hits, false)
48 }
49 }
50 }
51 }
52
53 override fun isAlwaysAccurate() = true
54
55 override fun getHits(attacker: Npc?, defender: Mob?): Array<CombatHit> {
56 val hit = nextRangedHit(attacker, defender, 31, combatProjectile)
57 hit.isAccurate = true
58 return arrayOf(hit)
59 }
60
61 companion object {
62 val phase1 = KalphiteQueenRangedStrategy(6240, 288)
63 val phase2 = KalphiteQueenRangedStrategy(6234, 289)
64 }
65
66}