Fixed Family Crest Chronozon Spawn issue
This commit is contained in:
+19
-6
@@ -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<Unit> {
|
||||
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<Unit> {
|
||||
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<Unit> {
|
||||
}
|
||||
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> {
|
||||
ZoneBuilder.configure(this)
|
||||
return this
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user