mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-22 19:05:11 -06:00
small changes
This commit is contained in:
parent
34b4eb7223
commit
36811828e0
2 changed files with 44 additions and 123 deletions
|
|
@ -51,6 +51,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
|
||||
val sessionNpcs = mutableListOf<NPC>()
|
||||
var currentNPCCount = SpawnCaps(0,0,0,0)
|
||||
|
||||
var npcTunnel: List<PenanceNpcTunnel> = listOf(
|
||||
PenanceNpcTunnel(PenanceType.RANGER,location(17,47,0),location(18,46,0),Direction.SOUTH),
|
||||
PenanceNpcTunnel(PenanceType.FIGHTER,location(23,48,0),location(24,47,0),Direction.SOUTH),
|
||||
|
|
@ -92,13 +93,10 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
region.setMusicId(ASSAULT_AND_BATTERY_604)
|
||||
|
||||
for (player in team.allPlayers()) {
|
||||
zone.enter(player)
|
||||
|
||||
val pRole = getBASession(player)?.team?.getRoleForPlayer(player)
|
||||
equipBARoleIcon(player, pRole!!)
|
||||
player.properties.teleportLocation = team.spawnLocationFor(player) //base.transform(36, 24, 0)
|
||||
player.properties.teleportLocation = team.spawnLocationFor(player)
|
||||
giveRoleItems(player,pRole)
|
||||
|
||||
registerLogoutListener(player, "ba-logout") { handleLogout(player) }
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +151,8 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
|
||||
Pulser.submit(countdownPulse!!)
|
||||
}
|
||||
private fun InitEvents(){
|
||||
|
||||
private fun InitEvents() {
|
||||
eventBus.register(BarbAssEvent.NPCDied::class.java) { event ->
|
||||
val tracker = scoreManager.trackerFor(event.killer)
|
||||
val npcRoleType = event.npc.getAttribute<BarbRole>("barbass-role")
|
||||
|
|
@ -180,6 +179,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
tracker.healerStats.wrongPoisonUsed++
|
||||
}
|
||||
}
|
||||
|
||||
fun setCaveBlocked(node: Node, blocked: Boolean) {
|
||||
val tunnel = npcTunnel.firstOrNull { t -> base.transform(t.caveLocation) == node.location } ?: return
|
||||
|
||||
|
|
@ -193,12 +193,14 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
fun isCaveBlocked(type: PenanceType): Boolean {
|
||||
return caveBlocked[type] == true
|
||||
}
|
||||
|
||||
fun forceWaveSpawn(force: Boolean = false){
|
||||
tryPenanceSpawn(PenanceType.RANGER,force)
|
||||
tryPenanceSpawn(PenanceType.FIGHTER,force)
|
||||
tryPenanceSpawn(PenanceType.RUNNER,force)
|
||||
tryPenanceSpawn(PenanceType.HEALER,force)
|
||||
}
|
||||
|
||||
fun tryPenanceSpawn(type: PenanceType, force: Boolean = false): Boolean {
|
||||
val current = currentNPCCount[type]
|
||||
val cap = currentWaveDefinition.caps[type]
|
||||
|
|
@ -217,7 +219,6 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
}
|
||||
|
||||
fun tryGroundItemSpawn(){
|
||||
val leader = team.getLeader()?.player ?: return
|
||||
val groundItems = GroundItemManager.getItems()
|
||||
|
||||
arenaSpawnItems.forEach { spawnItem ->
|
||||
|
|
@ -277,9 +278,8 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
closeInterface(player)
|
||||
openOverlay(player, 256)
|
||||
//https://youtu.be/MpYZG3qkFUA?t=387
|
||||
//todo dialogbox message not sendMessage
|
||||
//Dialogbox: " The game ended because on of your team-mates exited early.
|
||||
sendMessage(player,"The game ended early because one of your team-mates $endReason.")
|
||||
//todo do not send message to person who exited the game.
|
||||
player.dialogueInterpreter.sendDialogue("The game ended early because one of your team-mates $endReason.")
|
||||
BarbTeamManager.updateTeam(getBASession(player)?.team!!)
|
||||
}
|
||||
}
|
||||
|
|
@ -290,13 +290,13 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
|
||||
private var baseSpawnTicks = secondsToTicks(6)
|
||||
private var waveSpawnTicks = SpawnCaps( baseSpawnTicks, baseSpawnTicks, baseSpawnTicks, baseSpawnTicks )
|
||||
private var groundSpawnTicks = baseSpawnTicks
|
||||
|
||||
override fun pulse(): Boolean {
|
||||
when(state){
|
||||
BarbassaultState.IN_ARENA -> {
|
||||
eventBus.processEvents()
|
||||
|
||||
roleCallTicks--; groundSpawnTicks--
|
||||
roleCallTicks--
|
||||
if (roleCallTicks <= 0) { rollNewRoleCalls(); roleCallTicks = baseCallTicks }
|
||||
|
||||
for (type in PenanceType.values()) {
|
||||
|
|
@ -306,7 +306,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
}
|
||||
|
||||
}
|
||||
BarbassaultState.FORFEIT -> { endGame("left"); return true }
|
||||
BarbassaultState.FORFEIT -> { endGame("exited early."); return true }
|
||||
BarbassaultState.COMPLETE -> {
|
||||
log(this.javaClass, Log.FINE,state.toString())
|
||||
BALobby.TeamToLobby(team,team.wave+1)
|
||||
|
|
@ -319,7 +319,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
}
|
||||
return true // we do not have auto start next wave in 2009
|
||||
}
|
||||
BarbassaultState.DEATH -> { endGame("died"); return true }
|
||||
BarbassaultState.DEATH -> { endGame("died."); return true }
|
||||
BarbassaultState.END -> return true
|
||||
else -> return false
|
||||
}
|
||||
|
|
@ -332,8 +332,6 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
base = region.baseLocation
|
||||
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))
|
||||
|
|
@ -355,34 +353,22 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
player.locks.unlockTeleport()
|
||||
|
||||
player.location = waveLobbies[team.wave].randomWalkableLoc
|
||||
//player.location = Location.create(2593, 5264, 0)
|
||||
|
||||
if (team.allPlayers().isEmpty()) { // might be redundant
|
||||
/* if (team.allPlayers().isEmpty()) { // might be redundant
|
||||
player.properties.teleportLocation = Location.create(2593, 5264, 0)
|
||||
endSession()
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> {
|
||||
return arrayOf()
|
||||
}
|
||||
|
||||
override fun getRestrictions(): Array<ZoneRestriction> = arrayOf(
|
||||
ZoneRestriction.CANNON,
|
||||
ZoneRestriction.FIRES,
|
||||
ZoneRestriction.RANDOM_EVENTS,
|
||||
ZoneRestriction.TELEPORT
|
||||
)
|
||||
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> = arrayOf()
|
||||
override fun getRestrictions(): Array<ZoneRestriction> = arrayOf( ZoneRestriction.CANNON, ZoneRestriction.FIRES, ZoneRestriction.RANDOM_EVENTS, ZoneRestriction.TELEPORT )
|
||||
|
||||
override fun areaEnter(entity: Entity) {
|
||||
val player = entity as? Player ?: return
|
||||
log(this::class.java, Log.FINE, "ENTERED Barbassault Arena")
|
||||
val waveNum = getBAWave(player)
|
||||
val wornIconId = getItemFromEquipment(player, EquipmentSlot.CAPE)?.id
|
||||
val interfaceId = getIconInterfaceId(wornIconId ?: -1)
|
||||
val interfaceId = getRoleInterfaceId(getBASession(player)!!.team.getRoleForPlayer(player))
|
||||
player.fullRestore()
|
||||
//waveLobbies[waveNum].randomWalkableLoc
|
||||
//todo consolidate logic.
|
||||
interfaceId?.let {
|
||||
sendMessage(player, "----- Wave: $waveNum -----")
|
||||
|
|
@ -401,114 +387,52 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
player.fullRestore()
|
||||
destroyArena()
|
||||
}
|
||||
fun sessionNPCSpawn(id: Int, location: Location, direction: Direction, vararg objects: Any): NPC? {
|
||||
val npc = NPC.create(id, base.transform(location), direction, *objects)
|
||||
npc.init()
|
||||
sessionNpcs.add(npc)
|
||||
return npc
|
||||
}
|
||||
fun produceGroundSpawnItem(rate:Int,item: Item,location: Location): BAGroundSpawn {
|
||||
val thisGroundItem = BAGroundSpawn(this,rate,item,base.transform(location))
|
||||
thisGroundItem.init()
|
||||
return thisGroundItem
|
||||
}
|
||||
fun sessionNPCSpawn(id: Int, location: Location, direction: Direction, vararg objects: Any): NPC? = NPC.create(id, base.transform(location), direction, *objects)?.also { it.init(); sessionNpcs.add(it) }
|
||||
fun produceGroundSpawnItem(rate:Int,item: Item,location: Location): BAGroundSpawn = BAGroundSpawn(this, rate, item, base.transform(location)).also { it.init() }
|
||||
|
||||
fun spawnEggCannons() {
|
||||
eggCannonNpcWest = sessionNPCSpawn( NPCs.EGG_LAUNCHER_5026, base.transform(21, 34, 0), Direction.NORTH )
|
||||
//eggCannonNpcWest?.
|
||||
if (team.wave == 10) return
|
||||
eggCannonNpcEast = sessionNPCSpawn( NPCs.EGG_LAUNCHER_5026, base.transform(40, 34, 0), Direction.NORTH )
|
||||
}
|
||||
|
||||
fun clearGroundItems(){
|
||||
//BAgroundItems
|
||||
//thisGroundItem.isActive = false
|
||||
BAgroundItems.forEach { item ->
|
||||
item.isActive = false
|
||||
item.setRespawnRate(-1)
|
||||
item.isAutoSpawn = false
|
||||
GroundItemManager.destroy(item)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun giveRoleItems(player: Player, role: BarbRole) {
|
||||
val attackerHorns = intArrayOf(Items.ATTACKER_HORN_10516,Items.ATTACKER_HORN_10517,Items.ATTACKER_HORN_10518,Items.ATTACKER_HORN_10519,Items.ATTACKER_HORN_10520)
|
||||
val healerHorns = intArrayOf(Items.HEALER_HORN_10526,Items.HEALER_HORN_10527,Items.HEALER_HORN_10528,Items.HEALER_HORN_10529,Items.HEALER_HORN_10530)
|
||||
val collectorBags = intArrayOf(Items.COLLECTION_BAG_10521,Items.COLLECTION_BAG_10522,Items.COLLECTION_BAG_10523,Items.COLLECTION_BAG_10524,Items.COLLECTION_BAG_10525)
|
||||
fun levelIndex(level: Int): Int { return (level.coerceIn(1, 5) - 1) }
|
||||
|
||||
val levels = getBALevels(player)
|
||||
|
||||
val items = when (role) {
|
||||
BarbRole.ATTACKER -> when (levels.atk) {
|
||||
1 -> intArrayOf(Items.ATTACKER_HORN_10516)
|
||||
2 -> intArrayOf(Items.ATTACKER_HORN_10517)
|
||||
3 -> intArrayOf(Items.ATTACKER_HORN_10518)
|
||||
4 -> intArrayOf(Items.ATTACKER_HORN_10519)
|
||||
5 -> intArrayOf(Items.ATTACKER_HORN_10520)
|
||||
else -> intArrayOf(Items.ATTACKER_HORN_10516)
|
||||
}
|
||||
|
||||
BarbRole.DEFENDER -> when (levels.def) {
|
||||
|
||||
else -> intArrayOf(Items.DEFENDER_HORN_10538)
|
||||
}
|
||||
|
||||
BarbRole.HEALER -> when (levels.heal) {
|
||||
1 -> intArrayOf(Items.HEALER_HORN_10526)
|
||||
2 -> intArrayOf(Items.HEALER_HORN_10527)
|
||||
3 -> intArrayOf(Items.HEALER_HORN_10528)
|
||||
4 -> intArrayOf(Items.HEALER_HORN_10529)
|
||||
5 -> intArrayOf(Items.HEALER_HORN_10530)
|
||||
else -> intArrayOf(Items.HEALER_HORN_10526)
|
||||
}
|
||||
|
||||
BarbRole.COLLECTOR -> when (levels.col) {
|
||||
1 -> intArrayOf(Items.COLLECTION_BAG_10521,Items.COLLECTOR_HORN_10560)
|
||||
2 -> intArrayOf(Items.COLLECTION_BAG_10522,Items.COLLECTOR_HORN_10560)
|
||||
3 -> intArrayOf(Items.COLLECTION_BAG_10523,Items.COLLECTOR_HORN_10560)
|
||||
4 -> intArrayOf(Items.COLLECTION_BAG_10524,Items.COLLECTOR_HORN_10560)
|
||||
5 -> intArrayOf(Items.COLLECTION_BAG_10525,Items.COLLECTOR_HORN_10560)
|
||||
else -> intArrayOf(Items.COLLECTION_BAG_10521,Items.COLLECTOR_HORN_10560)
|
||||
}
|
||||
BarbRole.ATTACKER -> intArrayOf( attackerHorns[levelIndex(levels.atk)] )
|
||||
BarbRole.DEFENDER -> intArrayOf( Items.DEFENDER_HORN_10538 )
|
||||
BarbRole.HEALER -> intArrayOf( healerHorns[levelIndex(levels.heal)] )
|
||||
BarbRole.COLLECTOR -> intArrayOf( collectorBags[levelIndex(levels.col)], Items.COLLECTOR_HORN_10560 )
|
||||
}
|
||||
|
||||
items.forEach { id ->
|
||||
player.inventory.add(Item(id, 1))
|
||||
}
|
||||
items.forEach { player.inventory.add(Item(it, 1)) }
|
||||
}
|
||||
|
||||
private fun equipBARoleIcon(player: Player, role: BarbRole) {
|
||||
val BA_ROLE_CAPE = mapOf( BarbRole.ATTACKER to 10556, BarbRole.DEFENDER to 10558, BarbRole.COLLECTOR to 10557, BarbRole.HEALER to 10559 )
|
||||
val itemId = BA_ROLE_CAPE[role] ?: return
|
||||
player.equipment.add(Item(itemId),true,false)
|
||||
//player.getEquipment().add(Item(itemId), true)
|
||||
}
|
||||
private fun getIconInterfaceId(itemId: Int): Int? {
|
||||
return when (itemId) {
|
||||
ATTACKER_ICON -> Components.BARBASSAULT_OVER_ATT_485
|
||||
COLLECTOR_ICON -> Components.BARBASSAULT_OVER_COL_486
|
||||
DEFENDER_ICON -> Components.BARBASSAULT_OVER_DEF_487
|
||||
HEALER_ICON -> Components.BARBASSAULT_OVER_HEAL_488
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun broadcast(message: String) {
|
||||
team.allPlayers().forEach {
|
||||
sendMessage(it, message)
|
||||
}
|
||||
}
|
||||
fun broadcastToRole(role: BarbRole, message: String) {
|
||||
team.getPlayersByRole(role).forEach {
|
||||
sendMessage(it, message)
|
||||
}
|
||||
}
|
||||
fun updateBarbHealerIfaceHPOfPlayer(player: Player){
|
||||
team.getPlayersByRole(BarbRole.HEALER).forEach {
|
||||
HealerIfaceHPUpdatePlayer(it, player)
|
||||
}
|
||||
}
|
||||
fun alertHealers(player:Player){
|
||||
team.getPlayersByRole(BarbRole.HEALER).forEach {
|
||||
HealerIfaceMedicHelp(it,player)
|
||||
}
|
||||
}
|
||||
private fun broadcast(message: String) = team.allPlayers().forEach { sendMessage(it, message) }
|
||||
fun broadcastToRole(role: BarbRole, message: String) = team.getPlayersByRole(role).forEach { sendMessage(it, message) }
|
||||
|
||||
fun updateBarbHealerIfaceHPOfPlayer(player: Player) = team.getPlayersByRole(BarbRole.HEALER).forEach { HealerIfaceHPUpdatePlayer(it, player)}
|
||||
fun alertHealers(player:Player) = team.getPlayersByRole(BarbRole.HEALER).forEach { HealerIfaceMedicHelp(it,player) }
|
||||
|
||||
fun updateAttackerUI(player: Player, call: AttackerCall) {
|
||||
val style = call.called
|
||||
|
|
@ -534,7 +458,6 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
|
||||
when (role) {
|
||||
BarbRole.ATTACKER -> {
|
||||
//make sure wave is using wring childid.
|
||||
updateAttackerUI(player, call as AttackerCall)
|
||||
setInterfaceText(player, "Wave $wave" , Components.BARBASSAULT_OVER_ATT_485, 2)
|
||||
setInterfaceText(player, call.crossRoleDisplay(), Components.BARBASSAULT_OVER_ATT_485, 7)
|
||||
|
|
@ -557,8 +480,8 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
}
|
||||
}
|
||||
}
|
||||
// may need to use this instead of my current method of, entering area, set icon -> set overlay based on icon
|
||||
fun getRoleInterface(role: BarbRole): Int? {
|
||||
|
||||
fun getRoleInterfaceId(role: BarbRole): Int? {
|
||||
return when (role) {
|
||||
BarbRole.ATTACKER -> Components.BARBASSAULT_OVER_ATT_485
|
||||
BarbRole.COLLECTOR -> Components.BARBASSAULT_OVER_COL_486
|
||||
|
|
@ -566,6 +489,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
BarbRole.HEALER -> Components.BARBASSAULT_OVER_HEAL_488
|
||||
}
|
||||
}
|
||||
|
||||
fun rollNewRoleCalls() {
|
||||
roleCalls[BarbRole.ATTACKER] = AttackerCall(AttackerStyle.values().random())
|
||||
roleCalls[BarbRole.HEALER] = HealerCall(PoisonFood.values().random())
|
||||
|
|
@ -594,12 +518,9 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
}
|
||||
}
|
||||
|
||||
private val hornTargets = mapOf(
|
||||
BarbRole.COLLECTOR to BarbRole.ATTACKER,
|
||||
BarbRole.ATTACKER to BarbRole.COLLECTOR ,
|
||||
BarbRole.HEALER to BarbRole.DEFENDER,
|
||||
BarbRole.DEFENDER to BarbRole.HEALER
|
||||
)
|
||||
private val hornTargets = mapOf( BarbRole.COLLECTOR to BarbRole.ATTACKER, BarbRole.ATTACKER to BarbRole.COLLECTOR ,
|
||||
BarbRole.HEALER to BarbRole.DEFENDER, BarbRole.DEFENDER to BarbRole.HEALER )
|
||||
|
||||
fun onHornCall(player: Player, calledValue: Any) {
|
||||
val callerRole = team.getRoleForPlayer(player) ?: return
|
||||
val targetRole = hornTargets[callerRole] ?: return
|
||||
|
|
|
|||
|
|
@ -85,9 +85,9 @@ class BarbTeam(val session: BarbassaultSession, leader: Player) {
|
|||
return slots.filterNotNull().map { it.player }.filter { getRoleForPlayer(it) == barbRole }
|
||||
}
|
||||
|
||||
fun getRoleForPlayer(player: Player): BarbRole? {
|
||||
fun getRoleForPlayer(player: Player): BarbRole {
|
||||
val idx = slotOf(player)
|
||||
return slots.getOrNull(idx)?.role
|
||||
return slots.getOrNull(idx)?.role!!
|
||||
}
|
||||
|
||||
fun getLeader(): PartySlot? {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue