From 66978b23ee6fdd7437ef2bd92e45dc5c804dbe1b Mon Sep 17 00:00:00 2001 From: GregF Date: Mon, 13 May 2024 15:22:45 +0000 Subject: [PATCH] Fixed Family Crest Chronozon Spawn issue --- .../quest/familycrest/ChronozonCaveZone.kt | 25 ++++++++++++++----- .../varrock/quest/familycrest/ChronozonNPC.kt | 10 ++------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Server/src/main/content/region/misthalin/varrock/quest/familycrest/ChronozonCaveZone.kt b/Server/src/main/content/region/misthalin/varrock/quest/familycrest/ChronozonCaveZone.kt index fc2655329..792f8da09 100644 --- a/Server/src/main/content/region/misthalin/varrock/quest/familycrest/ChronozonCaveZone.kt +++ b/Server/src/main/content/region/misthalin/varrock/quest/familycrest/ChronozonCaveZone.kt @@ -1,4 +1,4 @@ -package plugin.quest.members.familycrest +package content.region.misthalin.varrock.quest.familycrest import core.game.node.entity.Entity @@ -10,8 +10,8 @@ import core.game.world.map.zone.ZoneBorders import core.game.world.map.zone.ZoneBuilder import core.plugin.Initializable import core.plugin.Plugin -import content.region.misthalin.varrock.quest.familycrest.ChronozonNPC -import core.game.node.item.Item +import core.api.getQuestStage +import core.api.hasAnItem import org.rs09.consts.Items import org.rs09.consts.NPCs @@ -23,7 +23,7 @@ class ChronozonCaveZone: MapZone("FC ChronozoneZone", true), Plugin { var chronozon = ChronozonNPC(NPCs.CHRONOZON_667, spawnLoc) override fun configure() { - register(ZoneBorders(3082, 9929, 3091, 9940)) + register(ZoneBorders(3079, 9927, 3095, 9944)) } override fun move(e: Entity?, from: Location?, to: Location?): Boolean { @@ -34,8 +34,9 @@ class ChronozonCaveZone: MapZone("FC ChronozoneZone", true), Plugin { if (e != null) { if (e.isPlayer) { val player = e as Player - if (player.questRepository.getQuest("Family Crest").getStage(e) in (19..99) && - !player.hasItem(Item(Items.CREST_PART_781))){ + if (getQuestStage(player,"Family Crest") in (19..99) && + !hasAnItem(player, Items.CREST_PART_781).exists() + ){ // Chronozon is allowed to spawn (quest stage right and the player doesn't have the crest part) // Now check there is not one already if(!RegionManager.getLocalNpcs(spawnLoc, 5).contains(chronozon)){ @@ -50,6 +51,18 @@ class ChronozonCaveZone: MapZone("FC ChronozoneZone", true), Plugin { } return false } + + + override fun leave(e: Entity?, logout: Boolean): Boolean { + if (e!!.isPlayer){ + if (RegionManager.getLocalPlayers(spawnLoc, 5).size <= 0){ + // There are no other players close by + chronozon.clear() + } + } + return super.leave(e, logout) + } + override fun newInstance(arg: Unit?): Plugin { ZoneBuilder.configure(this) return this diff --git a/Server/src/main/content/region/misthalin/varrock/quest/familycrest/ChronozonNPC.kt b/Server/src/main/content/region/misthalin/varrock/quest/familycrest/ChronozonNPC.kt index 6bdbc0d27..0e8fcac05 100644 --- a/Server/src/main/content/region/misthalin/varrock/quest/familycrest/ChronozonNPC.kt +++ b/Server/src/main/content/region/misthalin/varrock/quest/familycrest/ChronozonNPC.kt @@ -29,14 +29,6 @@ class ChronozonNPC(id: Int, location: Location?) : AbstractNPC(NPCs.CHRONOZON_66 return intArrayOf(NPCs.CHRONOZON_667) } - override fun handleTickActions() { - super.handleTickActions() - if (!targetplayer.isActive || targetplayer.getLocation().getDistance(getLocation()) > 15) { - clear() - } - - } - override fun checkImpact(state: BattleState?) { if (state != null) { if(amountOfAirDamageTaken == 0 || amountOfWaterDamageTaken == 0 || @@ -82,6 +74,8 @@ class ChronozonNPC(id: Int, location: Location?) : AbstractNPC(NPCs.CHRONOZON_66 if(killer == targetplayer) { if (targetplayer.questRepository.getStage("Family Crest") != 20){ targetplayer.questRepository.getQuest("Family Crest").setStage(targetplayer, 20) + // Make sure to despawn Chronozon + this.clear() } } clear()