Implemented swarm random event

This commit is contained in:
Zerken 2023-10-27 12:49:25 +00:00 committed by Ryan
parent fee56ae528
commit b7851e7671
4 changed files with 46 additions and 1 deletions

View file

@ -5395,6 +5395,7 @@
"examine": "Insects buzzing around.",
"melee_animation": "0",
"range_animation": "0",
"combat_audio": "819,821,820",
"defence_animation": "0",
"magic_animation": "0",
"death_animation": "0",
@ -5404,7 +5405,7 @@
"lifepoints": "10",
"strength_level": "1",
"id": "411",
"aggressive": "true",
"aggressive": "false",
"range_level": "1",
"attack_level": "1"
},

View file

@ -14,6 +14,7 @@ import content.global.ame.events.rivertroll.RiverTrollRENPC
import content.global.ame.events.rockgolem.RockGolemRENPC
import content.global.ame.events.sandwichlady.SandwichLadyRENPC
import content.global.ame.events.shade.ShadeRENPC
import content.global.ame.events.swarm.SwarmNPC
import content.global.ame.events.treespirit.TreeSpiritRENPC
import content.global.ame.events.zombie.ZombieRENPC
@ -43,6 +44,7 @@ enum class RandomEvents(val npc: RandomEventNPC, val loot: WeightBasedTable? = n
)),
DRILL_DEMON(npc = SeargentDamienNPC()),
EVIL_CHICKEN(npc = EvilChickenNPC()),
SWARM(npc = SwarmNPC()),
EVIL_BOB(npc = EvilBobNPC(), skillIds = intArrayOf(Skills.FISHING, Skills.MAGIC)),
DRUNKEN_DWARF(npc = DrunkenDwarfNPC()),
RICK_TURPENTINE(npc = RickTurpentineNPC(), loot = CERTER.loot),

View file

@ -0,0 +1,28 @@
package content.global.ame.events.swarm
import content.global.ame.RandomEventNPC
import core.api.playGlobalAudio
import core.api.utils.WeightBasedTable
import core.game.node.entity.npc.NPC
import core.tools.minutesToTicks
import org.rs09.consts.NPCs
import org.rs09.consts.Sounds
class SwarmNPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(NPCs.SWARM_411) {
override fun init() {
super.init()
this.setAttribute("no-spawn-return", true)
this.attack(player)
playGlobalAudio(this.location, Sounds.SWARM_APPEAR_818)
this.ticksLeft = minutesToTicks(60)
}
override fun tick() {
super.tick()
if (!this.inCombat())
this.attack(player)
}
override fun talkTo(npc: NPC) {
}
}

View file

@ -0,0 +1,14 @@
package content.global.ame.events.swarm
import core.game.node.entity.Entity
import core.game.node.entity.combat.BattleState
import core.game.node.entity.npc.NPC
import core.game.node.entity.npc.NPCBehavior
import core.tools.RandomFunction
import org.rs09.consts.NPCs
class SwarmNPCBehavior : NPCBehavior(NPCs.SWARM_411) {
override fun beforeAttackFinalized(self: NPC, victim: Entity, state: BattleState) {
state.estimatedHit = RandomFunction.getRandom(1)
}
}