Implemented Rick Turpentine and Drunken Dwarf random events
This commit is contained in:
@@ -4,10 +4,12 @@ import org.rs09.consts.Items
|
||||
import content.global.ame.events.MysteriousOldManNPC
|
||||
import content.global.ame.events.certer.CerterNPC
|
||||
import content.global.ame.events.drilldemon.SeargentDamienNPC
|
||||
import content.global.ame.events.drunkendwarf.DrunkenDwarfNPC
|
||||
import content.global.ame.events.evilbob.EvilBobNPC
|
||||
import content.global.ame.events.evilchicken.EvilChickenNPC
|
||||
import content.global.ame.events.freakyforester.FreakyForesterNPC
|
||||
import content.global.ame.events.genie.GenieNPC
|
||||
import content.global.ame.events.rickturpentine.RickTurpentineNPC
|
||||
import content.global.ame.events.rivertroll.RiverTrollRENPC
|
||||
import content.global.ame.events.rockgolem.RockGolemRENPC
|
||||
import content.global.ame.events.sandwichlady.SandwichLadyRENPC
|
||||
@@ -42,6 +44,8 @@ enum class RandomEvents(val npc: RandomEventNPC, val loot: WeightBasedTable? = n
|
||||
DRILL_DEMON(npc = SeargentDamienNPC()),
|
||||
EVIL_CHICKEN(npc = EvilChickenNPC()),
|
||||
EVIL_BOB(npc = EvilBobNPC(), skillIds = intArrayOf(Skills.FISHING, Skills.MAGIC)),
|
||||
DRUNKEN_DWARF(npc = DrunkenDwarfNPC()),
|
||||
RICK_TURPENTINE(npc = RickTurpentineNPC(), loot = CERTER.loot),
|
||||
SURPRISE_EXAM(npc = MysteriousOldManNPC(), type = "sexam"),
|
||||
FREAKY_FORESTER(npc = FreakyForesterNPC(), skillIds = intArrayOf(Skills.WOODCUTTING)),
|
||||
TREE_SPIRIT(npc = TreeSpiritRENPC(), skillIds = intArrayOf(Skills.WOODCUTTING)),
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package content.global.ame.events.drunkendwarf
|
||||
|
||||
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 DrunkenDwarfBehavior : NPCBehavior(NPCs.DRUNKEN_DWARF_956) {
|
||||
override fun beforeAttackFinalized(self: NPC, victim: Entity, state: BattleState) {
|
||||
state.estimatedHit = RandomFunction.getRandom(3)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package content.global.ame.events.drunkendwarf
|
||||
|
||||
import core.api.addItemOrDrop
|
||||
import core.game.dialogue.DialogueFile
|
||||
import core.game.dialogue.FacialExpression
|
||||
import core.game.system.timer.impl.AntiMacro
|
||||
import org.rs09.consts.Items
|
||||
|
||||
class DrunkenDwarfDialogue : DialogueFile() {
|
||||
override fun handle(componentID: Int, buttonID: Int) {
|
||||
when (stage) {
|
||||
0 -> npcl(FacialExpression.OLD_DRUNK_RIGHT, "I 'new it were you matey! 'Ere, have some ob the good stuff!").also { stage++ }
|
||||
1 -> {
|
||||
addItemOrDrop(player!!, Items.BEER_1917)
|
||||
addItemOrDrop(player!!, Items.KEBAB_1971)
|
||||
AntiMacro.terminateEventNpc(player!!)
|
||||
end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package content.global.ame.events.drunkendwarf
|
||||
|
||||
import content.global.ame.RandomEventNPC
|
||||
import core.api.*
|
||||
import core.api.utils.WeightBasedTable
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.NPCs
|
||||
import org.rs09.consts.Sounds
|
||||
|
||||
class DrunkenDwarfNPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(NPCs.DRUNKEN_DWARF_956) {
|
||||
private val phrases = arrayOf("Oi, are you der @name!","Dunt ignore your matey!","Aww comeon, talk to ikle me @name!")
|
||||
private var attackPhrase = false
|
||||
private var attackDelay = 0
|
||||
private var lastPhraseTime = 0
|
||||
|
||||
private fun sendPhrases() {
|
||||
if (getWorldTicks() > lastPhraseTime + 5) {
|
||||
playGlobalAudio(this.location, Sounds.DWARF_WHISTLE_2297)
|
||||
sendChat(this, phrases.random().replace("@name",player.username.capitalize()))
|
||||
this.face(player)
|
||||
lastPhraseTime = getWorldTicks()
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
super.init()
|
||||
playGlobalAudio(this.location, Sounds.DWARF_WHISTLE_2297)
|
||||
sendChat(this, "'Ello der ${player.username.capitalize()}! *hic*")
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
if (RandomFunction.roll(20) && !attackPhrase)
|
||||
sendPhrases()
|
||||
if (ticksLeft <= 10) {
|
||||
ticksLeft = 10
|
||||
if (!attackPhrase)
|
||||
sendChat("I hates you, ${player.username.capitalize()}!").also { attackPhrase = true }
|
||||
if (attackDelay <= getWorldTicks())
|
||||
this.attack(player)
|
||||
}
|
||||
super.tick()
|
||||
}
|
||||
|
||||
override fun talkTo(npc: NPC) {
|
||||
attackDelay = getWorldTicks() + 10
|
||||
this.pulseManager.clear()
|
||||
openDialogue(player, DrunkenDwarfDialogue(), this.asNpc())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package content.global.ame.events.rickturpentine
|
||||
|
||||
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 RickTurpentineBehavior : NPCBehavior(NPCs.RICK_TURPENTINE_2476) {
|
||||
override fun beforeAttackFinalized(self: NPC, victim: Entity, state: BattleState) {
|
||||
state.estimatedHit = RandomFunction.getRandom(3)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package content.global.ame.events.rickturpentine
|
||||
|
||||
import core.api.addItemOrDrop
|
||||
import core.game.dialogue.DialogueFile
|
||||
import core.game.dialogue.FacialExpression
|
||||
import core.game.system.timer.impl.AntiMacro
|
||||
|
||||
class RickTurpentineDialogue : DialogueFile() {
|
||||
override fun handle(componentID: Int, buttonID: Int) {
|
||||
when (stage) {
|
||||
0 -> npcl(FacialExpression.NEUTRAL, "Today is your lucky day, " + (if (player!!.isMale) "sirrah!" else "madam!") + " I am donating to the victims of crime to atone for my past actions!").also { stage++ }
|
||||
1 -> {
|
||||
AntiMacro.rollEventLoot(player!!).forEach { addItemOrDrop(player!!, it.id, it.amount) }
|
||||
AntiMacro.terminateEventNpc(player!!)
|
||||
end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package content.global.ame.events.rickturpentine
|
||||
|
||||
import content.global.ame.RandomEventNPC
|
||||
import core.api.*
|
||||
import core.api.utils.WeightBasedTable
|
||||
import core.game.node.entity.npc.NPC
|
||||
import org.rs09.consts.NPCs
|
||||
|
||||
class RickTurpentineNPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(NPCs.RICK_TURPENTINE_2476) {
|
||||
private var attackDelay = 0
|
||||
|
||||
override fun init() {
|
||||
super.init()
|
||||
sendChat("Good day to you, " + (if(player.isMale) "milord " else "milady ") + player.username.capitalize() + ".")
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
if (ticksLeft <= 10) {
|
||||
ticksLeft = 10
|
||||
if (attackDelay <= getWorldTicks())
|
||||
this.attack(player)
|
||||
}
|
||||
super.tick()
|
||||
}
|
||||
|
||||
override fun talkTo(npc: NPC) {
|
||||
attackDelay = getWorldTicks() + 10
|
||||
this.pulseManager.clear()
|
||||
openDialogue(player, RickTurpentineDialogue(), this.asNpc())
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package core.game.node.entity.combat
|
||||
|
||||
import content.global.ame.RandomEventNPC
|
||||
import content.global.handlers.item.equipment.special.SalamanderSwingHandler
|
||||
import core.game.container.impl.EquipmentContainer
|
||||
import core.game.interaction.MovementPulse
|
||||
@@ -132,7 +133,7 @@ class CombatPulse(
|
||||
if (handler == null) {
|
||||
handler = entity.getSwingHandler(true)
|
||||
}
|
||||
if (!v.isAttackable(entity, handler!!.type, true)) {
|
||||
if (!v.isAttackable(entity, handler!!.type, true) && entity != getAttribute<RandomEventNPC?>(v, AntiMacro.EVENT_NPC, null)) {
|
||||
return true
|
||||
}
|
||||
if (!swing(entity, victim, handler)) {
|
||||
@@ -440,6 +441,8 @@ class CombatPulse(
|
||||
if (DeathTask.isDead(victim) || DeathTask.isDead(entity)) {
|
||||
return true
|
||||
}
|
||||
if (entity is NPC)
|
||||
entity.asNpc().behavior.beforeAttackFinalized(entity, victim, state)
|
||||
if (impact || getDelay() == 0) {
|
||||
if (state.estimatedHit != 0 && victim is NPC && entity is Player) {
|
||||
val n = victim.asNpc()
|
||||
|
||||
Reference in New Issue
Block a user