Fixed Family Crest Chronozon Spawn issue

This commit is contained in:
GregF 2024-05-13 15:22:45 +00:00 committed by Ryan
parent f501468ead
commit 66978b23ee
2 changed files with 21 additions and 14 deletions

View file

@ -1,4 +1,4 @@
package plugin.quest.members.familycrest package content.region.misthalin.varrock.quest.familycrest
import core.game.node.entity.Entity 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.game.world.map.zone.ZoneBuilder
import core.plugin.Initializable import core.plugin.Initializable
import core.plugin.Plugin import core.plugin.Plugin
import content.region.misthalin.varrock.quest.familycrest.ChronozonNPC import core.api.getQuestStage
import core.game.node.item.Item import core.api.hasAnItem
import org.rs09.consts.Items import org.rs09.consts.Items
import org.rs09.consts.NPCs import org.rs09.consts.NPCs
@ -23,7 +23,7 @@ class ChronozonCaveZone: MapZone("FC ChronozoneZone", true), Plugin<Unit> {
var chronozon = ChronozonNPC(NPCs.CHRONOZON_667, spawnLoc) var chronozon = ChronozonNPC(NPCs.CHRONOZON_667, spawnLoc)
override fun configure() { 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 { override fun move(e: Entity?, from: Location?, to: Location?): Boolean {
@ -34,8 +34,9 @@ class ChronozonCaveZone: MapZone("FC ChronozoneZone", true), Plugin<Unit> {
if (e != null) { if (e != null) {
if (e.isPlayer) { if (e.isPlayer) {
val player = e as Player val player = e as Player
if (player.questRepository.getQuest("Family Crest").getStage(e) in (19..99) && if (getQuestStage(player,"Family Crest") in (19..99) &&
!player.hasItem(Item(Items.CREST_PART_781))){ !hasAnItem(player, Items.CREST_PART_781).exists()
){
// Chronozon is allowed to spawn (quest stage right and the player doesn't have the crest part) // Chronozon is allowed to spawn (quest stage right and the player doesn't have the crest part)
// Now check there is not one already // Now check there is not one already
if(!RegionManager.getLocalNpcs(spawnLoc, 5).contains(chronozon)){ if(!RegionManager.getLocalNpcs(spawnLoc, 5).contains(chronozon)){
@ -50,6 +51,18 @@ class ChronozonCaveZone: MapZone("FC ChronozoneZone", true), Plugin<Unit> {
} }
return false 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<Unit> { override fun newInstance(arg: Unit?): Plugin<Unit> {
ZoneBuilder.configure(this) ZoneBuilder.configure(this)
return this return this

View file

@ -29,14 +29,6 @@ class ChronozonNPC(id: Int, location: Location?) : AbstractNPC(NPCs.CHRONOZON_66
return intArrayOf(NPCs.CHRONOZON_667) return intArrayOf(NPCs.CHRONOZON_667)
} }
override fun handleTickActions() {
super.handleTickActions()
if (!targetplayer.isActive || targetplayer.getLocation().getDistance(getLocation()) > 15) {
clear()
}
}
override fun checkImpact(state: BattleState?) { override fun checkImpact(state: BattleState?) {
if (state != null) { if (state != null) {
if(amountOfAirDamageTaken == 0 || amountOfWaterDamageTaken == 0 || if(amountOfAirDamageTaken == 0 || amountOfWaterDamageTaken == 0 ||
@ -82,6 +74,8 @@ class ChronozonNPC(id: Int, location: Location?) : AbstractNPC(NPCs.CHRONOZON_66
if(killer == targetplayer) { if(killer == targetplayer) {
if (targetplayer.questRepository.getStage("Family Crest") != 20){ if (targetplayer.questRepository.getStage("Family Crest") != 20){
targetplayer.questRepository.getQuest("Family Crest").setStage(targetplayer, 20) targetplayer.questRepository.getQuest("Family Crest").setStage(targetplayer, 20)
// Make sure to despawn Chronozon
this.clear()
} }
} }
clear() clear()