mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-23 03:15:10 -06:00
Safe death in Barbass Activity.
This commit is contained in:
parent
c2f369b520
commit
7b02c88338
5 changed files with 114 additions and 65 deletions
|
|
@ -12,7 +12,7 @@ class BarbAssaultArea : MapArea {
|
|||
}
|
||||
|
||||
override fun areaEnter(entity: Entity) {
|
||||
zone.zoneType = ZoneType.BARBARIAN_ASSAULT.id
|
||||
zone.zoneType = ZoneType.SAFE.id
|
||||
super.areaEnter(entity)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,24 +2,28 @@ package content.minigame.barbassault
|
|||
|
||||
import content.minigame.barbassault.arena.BarbassaultSession
|
||||
import content.minigame.barbassault.arena.BarbassaultState
|
||||
import content.minigame.barbassault.lobby.BarbassaultLobby
|
||||
import content.minigame.barbassault.lobby.BarbassaultLobby.Companion.waveLobbies
|
||||
import content.minigame.barbassault.lobby.baSession
|
||||
import content.minigame.barbassault.activity
|
||||
import content.minigame.fishingtrawler.FishingTrawlerActivity
|
||||
import core.api.log
|
||||
import core.api.sendMessage
|
||||
import core.game.activity.ActivityManager
|
||||
import core.game.activity.ActivityPlugin
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.impl.PulseManager
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import core.game.world.map.zone.ZoneRestriction
|
||||
import core.game.world.map.zone.ZoneType
|
||||
import core.plugin.Initializable
|
||||
import core.tools.Log
|
||||
|
||||
private val sessions = mutableListOf<BarbassaultSession>()
|
||||
private var activity: BarbassaultActivity? = null
|
||||
@Initializable
|
||||
class BarbassaultActivity : ActivityPlugin("barbassault",true, true, true,
|
||||
open class BarbassaultActivity : ActivityPlugin("barbassault",false, true, true,
|
||||
ZoneRestriction.CANNON,
|
||||
ZoneRestriction.FIRES,
|
||||
ZoneRestriction.FOLLOWERS,
|
||||
|
|
@ -32,8 +36,12 @@ class BarbassaultActivity : ActivityPlugin("barbassault",true, true, true,
|
|||
override fun configure() {
|
||||
GameWorld.Pulser.submit(object : Pulse(10) {
|
||||
override fun pulse(): Boolean {
|
||||
sessions.removeIf {
|
||||
it.state == BarbassaultState.END
|
||||
sessions.removeIf { session ->
|
||||
val shouldRemove = session.state == BarbassaultState.END
|
||||
if (shouldRemove) {
|
||||
log(this.javaClass, Log.FINE, "Removing session: $session")
|
||||
}
|
||||
shouldRemove
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
@ -41,9 +49,24 @@ class BarbassaultActivity : ActivityPlugin("barbassault",true, true, true,
|
|||
}
|
||||
|
||||
override fun start(player: Player?, login: Boolean, vararg args: Any?): Boolean {
|
||||
super.start(player, login, *args)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun enter(e: Entity?): Boolean {
|
||||
return super.enter(e)
|
||||
}
|
||||
override fun death(e: Entity?, killer: Entity?): Boolean{
|
||||
val ename = e?.name
|
||||
log(this.javaClass, Log.FINE,"$ename has died in Barbass")
|
||||
if (e is Player) {
|
||||
val session = e.baSession
|
||||
session?.state = BarbassaultState.DEATH
|
||||
e.getProperties().setTeleportLocation(null)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
override fun newInstance(p: Player?): ActivityPlugin {
|
||||
ActivityManager.register(this)
|
||||
return this
|
||||
|
|
@ -53,6 +76,11 @@ class BarbassaultActivity : ActivityPlugin("barbassault",true, true, true,
|
|||
return Location.create(2593, 5264, 0)
|
||||
}
|
||||
|
||||
//override when !2265 passes (void recovery)
|
||||
fun recover(player: Player){
|
||||
//removeBarbass items
|
||||
//super.recover(player)
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -81,26 +81,23 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> {
|
||||
//block standard teleports.
|
||||
return arrayOf(getRegionBorders(7509))
|
||||
}
|
||||
override fun areaEnter(entity: Entity) {
|
||||
val player = entity as? Player ?: return
|
||||
//change this for tut latter
|
||||
BarbassaultTut.BarbassTutNPCs.forEach {
|
||||
npc -> npc.init()
|
||||
npc -> npc.init()
|
||||
npc.isWalks = false
|
||||
|
||||
}
|
||||
BarbassaultTut.spawnItems()
|
||||
|
||||
return arrayOf(getRegionBorders(7509))
|
||||
}
|
||||
override fun areaEnter(entity: Entity) {
|
||||
//todo move tut maparea to barbtut
|
||||
log(this::class.java, Log.FINE, "ENTERED BARBASS TUT")
|
||||
}
|
||||
|
||||
|
||||
override fun areaLeave(entity: Entity, logout: Boolean) {
|
||||
val player = entity as? Player ?: return
|
||||
closeOverlay(player)
|
||||
exitMiniGame(player)
|
||||
log(this::class.java, Log.FINE, "EXITED BARBASS")
|
||||
log(this::class.java, Log.FINE, "EXITED BARBASS TUT")
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@ import content.minigame.barbassault.lobby.BarbassaultLobby
|
|||
import content.minigame.barbassault.lobby.baSession
|
||||
import core.api.*
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.impl.PulseManager
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.GroundItem
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.communication.CommunicationInfo
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.GameWorld.Pulser
|
||||
import core.game.world.map.Direction
|
||||
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.map.zone.*
|
||||
import core.tools.Log
|
||||
import core.tools.secondsToTicks
|
||||
import core.tools.ticksToSeconds
|
||||
|
|
@ -30,11 +30,10 @@ import org.rs09.consts.Music.ASSAULT_AND_BATTERY_604
|
|||
import org.rs09.consts.NPCs
|
||||
|
||||
|
||||
enum class BarbassaultState { PARTY_CREATION, STARTING, IN_ARENA,FORFEIT, COMPLETE, END }
|
||||
enum class BarbassaultState { PARTY_CREATION, STARTING, IN_ARENA,FORFEIT, COMPLETE,DEATH, END }
|
||||
|
||||
class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutListener, MapArea {
|
||||
constructor(region: DynamicRegion, activity: BarbassaultActivity) : this(activity) {this.region = region; this.base = region.baseLocation}
|
||||
|
||||
lateinit var region: DynamicRegion
|
||||
lateinit var base: Location
|
||||
var currentWave = 1
|
||||
|
|
@ -57,11 +56,11 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
}
|
||||
|
||||
private fun enterArena() {
|
||||
|
||||
state = BarbassaultState.IN_ARENA
|
||||
region.setMusicId(ASSAULT_AND_BATTERY_604)
|
||||
|
||||
for (player in team.allPlayers()) {
|
||||
zone.enter(player)
|
||||
player.baSession?.team?.getRoleForPlayer(player)?.let { equipBARoleIcon(player, it) }
|
||||
player.properties.teleportLocation = team.spawnLocationFor(player) //base.transform(36, 24, 0)
|
||||
|
||||
|
|
@ -93,7 +92,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
}
|
||||
|
||||
private fun startCountdown() {
|
||||
var ticks = secondsToTicks(12)
|
||||
var ticks = secondsToTicks(4)//60
|
||||
|
||||
team.allPlayers().forEach { openOverlay(it, 494);setInterfaceText(it, "60", 494, 0) }
|
||||
GameWorld.Pulser.submit(object : Pulse(1) {
|
||||
|
|
@ -114,7 +113,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
|
||||
team.allPlayers().forEach {
|
||||
setInterfaceText(it, display, 494, 0)
|
||||
// it.sendMessage("Barbarian Assault starts in $display seconds.")
|
||||
//it.sendMessage("Barbarian Assault starts in $display seconds.")
|
||||
}
|
||||
|
||||
return false
|
||||
|
|
@ -152,46 +151,61 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
fun forfet(){
|
||||
state = BarbassaultState.FORFEIT
|
||||
}
|
||||
|
||||
fun endGame(endReason: String){
|
||||
eventBus.clear()
|
||||
scoreManager.resetAll()
|
||||
BarbassaultLobby.TeamToLobby(team,team.wave)
|
||||
state = BarbassaultState.PARTY_CREATION
|
||||
for(player in team.allPlayers()) {
|
||||
PulseManager.cancelDeathTask(player)
|
||||
Pulser.submit(object : Pulse(1, player) {
|
||||
override fun pulse(): Boolean {
|
||||
player.getSkills().restore()
|
||||
return true
|
||||
}
|
||||
})
|
||||
closeInterface(player)
|
||||
openOverlay(player, 256)
|
||||
sendMessage(player,"The game ended early because one of your team-mates $endReason.")
|
||||
BarbTeamManager.updateTeam(player.baSession?.team!!)
|
||||
}
|
||||
}
|
||||
private inner class GamePulse : Pulse(1) {
|
||||
private var roleCallTicks = secondsToTicks(30)
|
||||
private var waveSpawns = secondsToTicks(6)
|
||||
private var waveSpawnTicks = secondsToTicks(6)
|
||||
override fun pulse(): Boolean {
|
||||
|
||||
//if (state != BarbassaultState.IN_ARENA) return true
|
||||
if (state == BarbassaultState.FORFEIT){
|
||||
//team.getLeader()?.let { sendMessage(it.player,"end") }
|
||||
eventBus.clear()
|
||||
scoreManager.resetAll()
|
||||
BarbassaultLobby.TeamToLobby(team,team.wave)
|
||||
state = BarbassaultState.PARTY_CREATION
|
||||
for(player in team.allPlayers()) {
|
||||
closeInterface(player)
|
||||
openOverlay(player, 256)
|
||||
sendMessage(player,"The game ended early because one of your team-mates $endReason.")
|
||||
BarbTeamManager.updateTeam(player.baSession?.team!!)
|
||||
//log(this.javaClass, Log.FINE,state.toString())
|
||||
when(state){
|
||||
BarbassaultState.IN_ARENA -> {
|
||||
eventBus.processEvents() // process events such as npc died to scoring
|
||||
roleCallTicks--
|
||||
waveSpawnTicks--
|
||||
if (roleCallTicks <= 0) {
|
||||
rollNewRoleCalls()
|
||||
roleCallTicks = secondsToTicks(30)
|
||||
}
|
||||
if (waveSpawnTicks <=0 ){
|
||||
//spawn npcs based on wave number
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
}
|
||||
if (state == BarbassaultState.COMPLETE){
|
||||
BarbassaultLobby.TeamToLobby(team,team.wave+1)
|
||||
state = BarbassaultState.PARTY_CREATION
|
||||
for(player in team.allPlayers()) {
|
||||
closeInterface(player)
|
||||
openOverlay(player, 256)
|
||||
BarbTeamManager.updateTeam(player.baSession?.team!!)
|
||||
BarbassaultState.FORFEIT -> {endGame("left"); return true}
|
||||
BarbassaultState.COMPLETE -> {
|
||||
log(this.javaClass, Log.FINE,state.toString())
|
||||
BarbassaultLobby.TeamToLobby(team,team.wave+1)
|
||||
state = BarbassaultState.PARTY_CREATION
|
||||
for(player in team.allPlayers()) {
|
||||
PulseManager.cancelDeathTask(player)
|
||||
closeInterface(player)
|
||||
openOverlay(player, 256)
|
||||
BarbTeamManager.updateTeam(player.baSession?.team!!)
|
||||
}
|
||||
return true // we do not have auto start next wave in 2009
|
||||
}
|
||||
return true // we do not have auto start next wave in 2009
|
||||
BarbassaultState.DEATH -> {endGame("died");return true}
|
||||
BarbassaultState.END -> return true
|
||||
else -> return false
|
||||
}
|
||||
|
||||
eventBus.processEvents()
|
||||
|
||||
roleCallTicks--
|
||||
if (roleCallTicks <= 0) {
|
||||
rollNewRoleCalls()
|
||||
roleCallTicks = secondsToTicks(30)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
@ -199,10 +213,13 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
private fun createArena() {
|
||||
region = DynamicRegion.create(BarbassaultGameArea.BA_ARENA.MAIN)
|
||||
base = region.baseLocation
|
||||
zone.register(getRegionBorders(region.id))
|
||||
zone.zoneType = ZoneType.SAFE.id
|
||||
region.regionZones.add(RegionZone(activity!!, region.borders)) //DONT FORGET THIS STUPID!
|
||||
|
||||
//activity?.zoneType = ZoneType.SAFE.id
|
||||
region.toggleMulticombat()
|
||||
spawnEggCannons()
|
||||
zone.register(getRegionBorders(region.id))
|
||||
}
|
||||
|
||||
private fun destroyArena() {
|
||||
|
|
@ -216,7 +233,6 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
private fun handleLogout(player: Player) {
|
||||
state = BarbassaultState.FORFEIT
|
||||
zone.cleanItems(player,arrayOf(Item(ATTACKER_ICON),Item(DEFENDER_ICON),Item(COLLECTOR_ICON),Item(HEALER_ICON)))
|
||||
|
||||
region.remove(player)
|
||||
team.removePlayer(player)
|
||||
player.locks.unlockTeleport()
|
||||
|
|
@ -229,7 +245,11 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
}
|
||||
}
|
||||
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> = emptyArray()
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> {
|
||||
return arrayOf()
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun getRestrictions(): Array<ZoneRestriction> = arrayOf(
|
||||
ZoneRestriction.CANNON,
|
||||
|
|
@ -246,7 +266,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
val waveNum = player.getAttribute("barbass:wave", 1)
|
||||
val wornIconId = getItemFromEquipment(player, EquipmentSlot.CAPE)?.id
|
||||
val interfaceId = getIconInterfaceId(wornIconId ?: -1)
|
||||
|
||||
//waveLobbies[waveNum].randomWalkableLoc
|
||||
interfaceId?.let {
|
||||
sendMessage(player, "----- Wave: $waveNum -----")
|
||||
openOverlay(player, it)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import core.game.interaction.IntType
|
|||
import core.game.interaction.InteractionListener
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.impl.PulseManager
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
|
|
@ -26,15 +27,17 @@ import org.rs09.consts.Sounds
|
|||
//https://www.youtube.com/watch?v=0d5I97HLUEs ending of video shows we are allowed capes in lap but not wave rooms
|
||||
//"-- Next wave no longer starting"
|
||||
// The game ended early because one of your team-mated died.
|
||||
private var activity: BarbassaultActivity? = null
|
||||
//private var activity: BarbassaultActivity? = null
|
||||
class BarbassaultLobby : InteractionListener, MapArea {
|
||||
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> {
|
||||
return areaBorders
|
||||
}
|
||||
|
||||
override fun areaEnter(entity: Entity) {
|
||||
updatePlayerWave(entity)
|
||||
// openOverlay(entity, 256)
|
||||
openOverlay(entity as Player, 256)
|
||||
PulseManager.cancelDeathTask(entity)
|
||||
// Components.BARBASSAULT_PLAYERSTAT_490
|
||||
}
|
||||
|
||||
|
|
@ -318,6 +321,7 @@ class BarbassaultLobby : InteractionListener, MapArea {
|
|||
if (wave in 0..waveLobbies.size) {
|
||||
val targetLobby = waveLobbies[wave]
|
||||
for (player in team.allPlayers()) {
|
||||
PulseManager.cancelDeathTask(player)
|
||||
teleport(player, targetLobby.randomWalkableLoc)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue