mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Fixed hostile random events attacking other players
Fixed players being able to attack hostile random events for other players Hostile random events now authentically only reward 1/16th xp (except for pheasants, which give 0 xp)
This commit is contained in:
parent
2cf8392691
commit
1b85808885
11 changed files with 60 additions and 11 deletions
|
|
@ -3,9 +3,15 @@ package content.global.ame
|
|||
import content.global.ame.events.MysteriousOldManNPC
|
||||
import core.api.playGlobalAudio
|
||||
import core.api.poofClear
|
||||
import core.api.sendMessage
|
||||
import core.api.utils.WeightBasedTable
|
||||
import core.game.interaction.MovementPulse
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.combat.CombatStyle
|
||||
import core.game.node.entity.impl.PulseType
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.npc.agg.AggressiveBehavior
|
||||
import core.game.node.entity.npc.agg.AggressiveHandler
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.world.map.Location
|
||||
|
|
@ -13,10 +19,11 @@ import core.game.world.map.RegionManager
|
|||
import core.game.world.map.path.Pathfinder
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import core.integrations.discord.Discord
|
||||
import core.api.utils.WeightBasedTable
|
||||
import core.tools.secondsToTicks
|
||||
import core.tools.ticksToCycles
|
||||
import org.rs09.consts.Sounds
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.min
|
||||
import kotlin.random.Random
|
||||
import kotlin.reflect.full.createInstance
|
||||
|
||||
|
|
@ -66,7 +73,6 @@ abstract class RandomEventNPC(id: Int) : NPC(id) {
|
|||
if (!player.getAttribute("random:pause", false)) {
|
||||
ticksLeft--
|
||||
}
|
||||
|
||||
if (!pulseManager.hasPulseRunning() && !finalized) {
|
||||
follow()
|
||||
}
|
||||
|
|
@ -87,6 +93,11 @@ abstract class RandomEventNPC(id: Int) : NPC(id) {
|
|||
location = spawnLocation
|
||||
player.setAttribute("re-npc", this)
|
||||
super.init()
|
||||
super.aggressiveHandler = AggressiveHandler(this, object : AggressiveBehavior() {
|
||||
override fun canSelectTarget(entity: Entity, target: Entity): Boolean {
|
||||
return target == player
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
open fun onTimeUp() {
|
||||
|
|
@ -118,4 +129,19 @@ abstract class RandomEventNPC(id: Int) : NPC(id) {
|
|||
}
|
||||
|
||||
abstract fun talkTo(npc: NPC)
|
||||
}
|
||||
|
||||
override fun isAttackable(entity: Entity, style: CombatStyle, message: Boolean): Boolean {
|
||||
if (entity != player) {
|
||||
if (entity is Player) {
|
||||
sendMessage(entity, "It isn't interested in fighting you.") //TODO authentic message
|
||||
}
|
||||
return false
|
||||
}
|
||||
return super.isAttackable(entity, style, message)
|
||||
}
|
||||
|
||||
fun idForCombatLevel(ids: List<Int>, player: Player): Int {
|
||||
val index = min(ids.size, ceil(player.properties.currentCombatLevel / 20.0).toInt()) - 1
|
||||
return ids[index]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package content.global.ame.events
|
||||
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.npc.NPCBehavior
|
||||
import org.rs09.consts.NPCs
|
||||
|
||||
class HostileRandomEventBehavior : NPCBehavior(
|
||||
NPCs.EVIL_CHICKEN_2463, NPCs.EVIL_CHICKEN_2464, NPCs.EVIL_CHICKEN_2465, NPCs.EVIL_CHICKEN_2466, NPCs.EVIL_CHICKEN_2467, NPCs.EVIL_CHICKEN_2468,
|
||||
NPCs.RIVER_TROLL_391, NPCs.RIVER_TROLL_392, NPCs.RIVER_TROLL_393, NPCs.RIVER_TROLL_394, NPCs.RIVER_TROLL_395, NPCs.RIVER_TROLL_396,
|
||||
NPCs.ROCK_GOLEM_413, NPCs.ROCK_GOLEM_414, NPCs.ROCK_GOLEM_415, NPCs.ROCK_GOLEM_416, NPCs.ROCK_GOLEM_417, NPCs.ROCK_GOLEM_418,
|
||||
NPCs.SHADE_425, NPCs.SHADE_426, NPCs.SHADE_427, NPCs.SHADE_428, NPCs.SHADE_429, NPCs.SHADE_430, NPCs.SHADE_431,
|
||||
NPCs.TREE_SPIRIT_438, NPCs.TREE_SPIRIT_439, NPCs.TREE_SPIRIT_440, NPCs.TREE_SPIRIT_441, NPCs.TREE_SPIRIT_442, NPCs.TREE_SPIRIT_443,
|
||||
NPCs.ZOMBIE_419, NPCs.ZOMBIE_420, NPCs.ZOMBIE_421, NPCs.ZOMBIE_422, NPCs.ZOMBIE_423, NPCs.ZOMBIE_424
|
||||
) {
|
||||
override fun getXpMultiplier(self: NPC, attacker: Entity): Double {
|
||||
return super.getXpMultiplier(self, attacker) / 16.0
|
||||
}
|
||||
}
|
||||
|
|
@ -32,4 +32,8 @@ class StrangePlantBehavior() : NPCBehavior(NPCs.STRANGE_PLANT_408) {
|
|||
override fun onDeathStarted(self: NPC, killer: Entity) {
|
||||
AntiMacro.terminateEventNpc(killer.asPlayer())
|
||||
}
|
||||
}
|
||||
|
||||
override fun getXpMultiplier(self: NPC, attacker: Entity): Double {
|
||||
return super.getXpMultiplier(self, attacker) / 16.0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package content.global.ame.events.supriseexam
|
||||
package content.global.ame.events.surpriseexam
|
||||
|
||||
import core.game.component.Component
|
||||
import core.game.dialogue.FacialExpression
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package content.global.ame.events
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import content.global.ame.events.supriseexam.SurpriseExamUtils
|
||||
import content.global.ame.events.surpriseexam.SurpriseExamUtils
|
||||
import core.game.dialogue.DialogueFile
|
||||
import core.game.system.timer.impl.AntiMacro
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package content.global.ame.events.supriseexam
|
||||
package content.global.ame.events.surpriseexam
|
||||
|
||||
import core.game.dialogue.DialogueFile
|
||||
import core.tools.END_DIALOGUE
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package content.global.ame.events.supriseexam
|
||||
package content.global.ame.events.surpriseexam
|
||||
|
||||
import core.game.node.entity.npc.NPC
|
||||
import org.rs09.consts.Components
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package content.global.ame.events.supriseexam
|
||||
package content.global.ame.events.surpriseexam
|
||||
|
||||
import core.game.component.Component
|
||||
import core.game.node.entity.player.Player
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package content.global.ame.events.supriseexam
|
||||
package content.global.ame.events.surpriseexam
|
||||
|
||||
import core.Server
|
||||
import core.api.*
|
||||
|
|
@ -489,7 +489,7 @@ public abstract class Entity extends Node {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if an entity can continue it's attack.
|
||||
* Checks if an entity can continue its attack.
|
||||
* @param target the target.
|
||||
* @param style the style.
|
||||
* @return {@code True} if so.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue