MapAreas can now reference their associated zones to dynamically add/remove borders
Random Events can no longer spawn in fishing trawler Players can no longer have multiple random events spawned in/active at a time
This commit is contained in:
@@ -2,6 +2,8 @@ package api
|
||||
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.zone.MapZone
|
||||
import core.game.world.map.zone.RegionZone
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import core.game.world.map.zone.ZoneRestriction
|
||||
|
||||
@@ -10,9 +12,21 @@ import core.game.world.map.zone.ZoneRestriction
|
||||
* Optionally-overridable methods include [getRestrictions], [areaEnter], [areaLeave] and [entityStep]
|
||||
*/
|
||||
interface MapArea {
|
||||
var zone: MapZone
|
||||
get(){
|
||||
return zoneMaps[this.javaClass.simpleName + "MapArea"]!!
|
||||
}
|
||||
set(value) {
|
||||
zoneMaps[this.javaClass.simpleName + "MapArea"] = value
|
||||
}
|
||||
|
||||
fun defineAreaBorders() : Array<ZoneBorders>
|
||||
fun getRestrictions() : Array<ZoneRestriction> {return arrayOf()}
|
||||
fun areaEnter(entity: Entity) {}
|
||||
fun areaLeave(entity: Entity, logout: Boolean) {}
|
||||
fun entityStep(entity: Entity, location: Location, lastLocation: Location) {}
|
||||
|
||||
companion object {
|
||||
val zoneMaps = HashMap<String, MapZone>()
|
||||
}
|
||||
}
|
||||
+28
-1
@@ -1,7 +1,10 @@
|
||||
package rs09.game.content.activity.fishingtrawler
|
||||
|
||||
import api.LogoutListener
|
||||
import api.MapArea
|
||||
import api.getRegionBorders
|
||||
import core.game.component.Component
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.scenery.Scenery
|
||||
import core.game.node.scenery.SceneryBuilder
|
||||
import core.game.node.entity.npc.NPC
|
||||
@@ -12,6 +15,8 @@ import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.build.DynamicRegion
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import core.game.world.map.zone.ZoneRestriction
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Plugin
|
||||
import core.tools.*
|
||||
@@ -20,6 +25,7 @@ import org.rs09.consts.Items
|
||||
import rs09.game.node.entity.player.info.stats.FISHING_TRAWLER_GAMES_WON
|
||||
import rs09.game.node.entity.player.info.stats.FISHING_TRAWLER_SHIPS_SANK
|
||||
import rs09.game.node.entity.player.info.stats.STATS_BASE
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.tools.secondsToTicks
|
||||
import rs09.tools.ticksToSeconds
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -38,7 +44,7 @@ private const val HOLE_SOUTH_Y = 23
|
||||
private const val LEAKING_ID = 2167
|
||||
private const val PATCHED_ID = 2168
|
||||
|
||||
class FishingTrawlerSession(val activity: FishingTrawlerActivity? = null) : LogoutListener {
|
||||
class FishingTrawlerSession(val activity: FishingTrawlerActivity? = null) : LogoutListener, MapArea {
|
||||
constructor(region: DynamicRegion, activity: FishingTrawlerActivity) : this(activity) {this.region = region; this.base = region.baseLocation}
|
||||
var players: ArrayList<Player> = ArrayList()
|
||||
var netRipped = false
|
||||
@@ -77,6 +83,7 @@ class FishingTrawlerSession(val activity: FishingTrawlerActivity? = null) : Logo
|
||||
player.setAttribute("ft-session",this)
|
||||
player.stateManager.set(EntityState.TELEBLOCK,timeLeft)
|
||||
}
|
||||
zone.register(getRegionBorders(region.id))
|
||||
}
|
||||
|
||||
fun swapBoatType(fromRegion: Int){
|
||||
@@ -129,6 +136,7 @@ class FishingTrawlerSession(val activity: FishingTrawlerActivity? = null) : Logo
|
||||
session.boatSank = true
|
||||
session.isActive = false
|
||||
session.swapBoatType(7755)
|
||||
session.zone.unregister(getRegionBorders(session.region.id))
|
||||
}
|
||||
|
||||
if(RandomFunction.random(100) <= 9){
|
||||
@@ -142,6 +150,7 @@ class FishingTrawlerSession(val activity: FishingTrawlerActivity? = null) : Logo
|
||||
player.properties.teleportLocation = Location.create(2666, 3162, 0)
|
||||
player.incrementAttribute("/save:$STATS_BASE:$FISHING_TRAWLER_GAMES_WON")
|
||||
}
|
||||
session.zone.unregister(getRegionBorders(session.region.id))
|
||||
}
|
||||
|
||||
for(player in session.players){
|
||||
@@ -275,4 +284,22 @@ class FishingTrawlerSession(val activity: FishingTrawlerActivity? = null) : Logo
|
||||
player.location = Location.create(2667, 3161, 0)
|
||||
session.players.remove(player)
|
||||
}
|
||||
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> {
|
||||
return arrayOf()
|
||||
}
|
||||
|
||||
override fun getRestrictions(): Array<ZoneRestriction> {
|
||||
return arrayOf(ZoneRestriction.CANNON, ZoneRestriction.FIRES, ZoneRestriction.RANDOM_EVENTS)
|
||||
}
|
||||
|
||||
override fun areaEnter(entity: Entity) {
|
||||
super.areaEnter(entity)
|
||||
SystemLogger.logInfo("ENTERED FTZ")
|
||||
}
|
||||
|
||||
override fun areaLeave(entity: Entity, logout: Boolean) {
|
||||
super.areaLeave(entity, logout)
|
||||
SystemLogger.logInfo("EXITED FTZ")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ class RandomEventManager(val player: Player? = null) : LoginListener, EventHook<
|
||||
nextSpawn = GameWorld.ticks + 3000
|
||||
return
|
||||
}
|
||||
if (getAttribute<RandomEventNPC?>(player, "re-npc", null) != null) return
|
||||
val currentAction = player.pulseManager.current.toString()
|
||||
val ame: RandomEvents = if(currentAction.contains("WoodcuttingSkillPulse") && Random.nextBoolean()){
|
||||
RandomEvents.TREE_SPIRIT
|
||||
|
||||
@@ -54,6 +54,10 @@ abstract class RandomEventNPC(id: Int) : NPC(id) {
|
||||
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
if(player.getAttribute<RandomEventNPC?>("re-npc", null) != this){
|
||||
terminate()
|
||||
return
|
||||
}
|
||||
if (!player.getAttribute("random:pause", false)) {
|
||||
ticksLeft--
|
||||
}
|
||||
@@ -76,6 +80,7 @@ abstract class RandomEventNPC(id: Int) : NPC(id) {
|
||||
timerPaused = false
|
||||
spawnLocation ?: terminate()
|
||||
location = spawnLocation
|
||||
player.setAttribute("re-npc", this)
|
||||
super.init()
|
||||
}
|
||||
|
||||
@@ -100,5 +105,10 @@ abstract class RandomEventNPC(id: Int) : NPC(id) {
|
||||
player.graphics(SMOKE_GRAPHICS)
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
super.clear()
|
||||
if(player.getAttribute<RandomEventNPC?>("re-npc", null) == this) player.removeAttribute("re-npc")
|
||||
}
|
||||
|
||||
abstract fun talkTo(npc: NPC)
|
||||
}
|
||||
@@ -112,6 +112,8 @@ object ClassScanner {
|
||||
}
|
||||
for(border in clazz.defineAreaBorders()) zone.register(border)
|
||||
ZoneBuilder.configure(zone)
|
||||
SystemLogger.logInfo("Configured zone: ${clazz.javaClass.simpleName + "MapArea"}")
|
||||
MapArea.zoneMaps[clazz.javaClass.simpleName + "MapArea"] = zone
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
SystemLogger.logErr("Error loading content: ${it.simpleName}, ${e.localizedMessage}")
|
||||
|
||||
Reference in New Issue
Block a user