mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-21 18:35:11 -06:00
Removed BarbassaultPlayerExtensions.kt
Added BAUtils.kt Naming to be more consistent Thank you Ceikry!
This commit is contained in:
parent
08cbf43ad0
commit
85fb2fec63
36 changed files with 291 additions and 280 deletions
|
|
@ -98,10 +98,10 @@ class BarbassBlackBoard {
|
|||
fun updateBlackBoard(player: Player) {
|
||||
player.interfaceManager.open(Component(Components.BARBASSAULT_PLAYERSTAT_490))
|
||||
setInterfaceText(player, player.username, Components.BARBASSAULT_PLAYERSTAT_490, PLAYER_NAME)
|
||||
setInterfaceText(player, player.getBarbWave().toString(), Components.BARBASSAULT_PLAYERSTAT_490, CURRENT_WAVE)
|
||||
setInterfaceText(player, getBAWave(player).toString(), Components.BARBASSAULT_PLAYERSTAT_490, CURRENT_WAVE)
|
||||
|
||||
val playerLevel = player.getBarbLevels()
|
||||
val playerPoints = player.getBarbPoints()
|
||||
val playerLevel = getBALevels(player)
|
||||
val playerPoints = getBAPoints(player)
|
||||
|
||||
for (role in BarbRole.values()) {
|
||||
val level = when (role) {
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package content.minigame.barbassault
|
||||
|
||||
import content.minigame.barbassault.arena.Npcs.dropPenanceEggCluster
|
||||
import content.minigame.barbassault.bots.BarbassBot
|
||||
import content.minigame.barbassault.lobby.BarbassaultLobby
|
||||
import content.minigame.barbassault.bots.BABot
|
||||
import content.minigame.barbassault.lobby.BALobby
|
||||
import core.api.*
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.command.Privilege
|
||||
|
|
@ -13,25 +12,25 @@ import org.rs09.consts.Items
|
|||
import org.rs09.consts.Scenery
|
||||
|
||||
@Initializable
|
||||
class BarbassDevHelper : CommandSet(Privilege.ADMIN) {
|
||||
class BADevHelper : CommandSet(Privilege.ADMIN) {
|
||||
var babotcount = 0
|
||||
|
||||
override fun defineCommands() {
|
||||
define ("maxbarbpoints") { player,_ ->
|
||||
player.addBarbPoints(BarbAssaultPoints(500, 500, 500,500))
|
||||
addBAPoints(player,BarbAssaultPoints(500, 500, 500,500))
|
||||
return@define
|
||||
}
|
||||
define ("setbarbwave") { player,args ->
|
||||
player.setBarbWave(args[1].toInt())
|
||||
setBAWave(player,args[1].toInt())
|
||||
return@define
|
||||
}
|
||||
|
||||
define ("resetbarbpoints") { player,_ ->
|
||||
player.setBarbPoints(BarbAssaultPoints(0, 0, 0,0))
|
||||
setBAPoints(player,BarbAssaultPoints(0, 0, 0,0))
|
||||
return@define
|
||||
}
|
||||
define ("resetbarblevels") { player,_ ->
|
||||
player.setBarbLevels(BarbAssaultLevels(0, 0, 0,0))
|
||||
setBALevels(player,BarbAssaultLevels(0, 0, 0,0))
|
||||
return@define
|
||||
}
|
||||
define("barbgame"){ player,_->
|
||||
|
|
@ -48,27 +47,27 @@ class BarbassDevHelper : CommandSet(Privilege.ADMIN) {
|
|||
return@define
|
||||
}
|
||||
define("eggloot"){ player,_->
|
||||
dropPenanceEggCluster(player)
|
||||
content.minigame.barbassault.arena.npcs.dropPenanceEggCluster(player)
|
||||
return@define
|
||||
}
|
||||
define("cleanfloor"){ player,_->
|
||||
val session = player.baSession ?: return@define
|
||||
val session = getBASession(player) ?: return@define
|
||||
session.clearGroundItems()
|
||||
return@define
|
||||
}
|
||||
define("spawnwave"){ player,_->
|
||||
player.baSession?.spawnNpcWave()
|
||||
getBASession(player)?.spawnNpcWave()
|
||||
return@define
|
||||
}
|
||||
define("spawnwaveforce"){ player,_->
|
||||
player.baSession?.spawnNpcWave(true)
|
||||
getBASession(player)?.spawnNpcWave(true)
|
||||
return@define
|
||||
}
|
||||
define("babot"){ player,_->
|
||||
if (babotcount >= 25) {
|
||||
sendMessage(player, "25 is max amount of BA bots allowed")
|
||||
}else {
|
||||
BarbassBot(BarbassaultLobby.MAIN_LOBBY.randomWalkableLoc)
|
||||
BABot(BALobby.MAIN_LOBBY.randomWalkableLoc)
|
||||
babotcount++
|
||||
}
|
||||
return@define
|
||||
|
|
@ -14,7 +14,7 @@ import org.rs09.consts.Items
|
|||
import org.rs09.consts.NPCs
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
class BarbassaultListeners : InteractionListener {
|
||||
class BAListeners : InteractionListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
// addClimbDest(Location.create(2593, 5261, 0),Location.create(2593, 5261, 0))
|
||||
|
|
@ -47,7 +47,7 @@ fun updateRewardButtons(player: Player, selected: Int = -1) {
|
|||
interfaceUpdate(player,selected)
|
||||
|
||||
//points @ bottom
|
||||
val playerPoints = player.getBarbPoints()
|
||||
val playerPoints = getBAPoints(player)
|
||||
setInterfaceText(player, playerPoints.atk.toString(), 491, 219)
|
||||
setInterfaceText(player, playerPoints.def.toString(), 491, 220)
|
||||
setInterfaceText(player, playerPoints.col.toString(), 491, 221)
|
||||
|
|
@ -62,7 +62,7 @@ fun acceptReward(player:Player, selected :Int){
|
|||
when {
|
||||
reward.item != null -> { addItem(player, reward.item, 1) }
|
||||
// reward.gamble != null -> { }
|
||||
reward.levelUp != null -> { player.increaseBarbRoleLevel(reward.levelUp) }
|
||||
reward.levelUp != null -> { increaseBARoleLevel(player,reward.levelUp) }
|
||||
}
|
||||
removeCost(player, reward)
|
||||
updateRewardButtons(player)
|
||||
|
|
@ -77,8 +77,8 @@ fun rollGambleReward(tier: GambleTier): Item {
|
|||
}
|
||||
|
||||
fun interfaceUpdate(player: Player, selected: Int) {
|
||||
val playerLevels = player.getBarbLevels()
|
||||
val hasQueenKill = player.hasQueenKill()
|
||||
val playerLevels = getBALevels(player)
|
||||
val hasQueenKill = hasQueenKill(player)
|
||||
barbRewardShop.forEach { reward ->
|
||||
val isSelected = reward.buttonChildId == selected
|
||||
val canBuy = canBuyReward(player, reward)
|
||||
|
|
@ -109,9 +109,9 @@ fun interfaceUpdate(player: Player, selected: Int) {
|
|||
}
|
||||
|
||||
fun canBuyReward(player: Player, reward: RewardRow, buying: Boolean = false): Boolean {
|
||||
val points = player.getBarbPoints()
|
||||
val hasQueenKill = player.hasQueenKill()
|
||||
val barbLevels = player.getBarbLevels()
|
||||
val points = getBAPoints(player)
|
||||
val hasQueenKill = hasQueenKill(player)
|
||||
val barbLevels = getBALevels(player)
|
||||
val resolvedCost = reward.cost.resolve(barbLevels)
|
||||
|
||||
fun requireQueenKill(base: Boolean): Boolean {
|
||||
|
|
@ -149,20 +149,20 @@ fun isBarbRewardMaxed(reward: RewardRow, barbLevels: BarbAssaultLevels): Boolean
|
|||
}
|
||||
}
|
||||
fun removeCost(player: Player, reward: RewardRow) {
|
||||
val barbLevels = player.getBarbLevels()
|
||||
val barbLevels = getBALevels(player)
|
||||
val resolvedCost = reward.cost.resolve(barbLevels)
|
||||
|
||||
when (resolvedCost) {
|
||||
is RewardCost.AllRoles -> {
|
||||
if (reward.queenKillText != null) { setAttribute(player,"barbass:queen-kill", 0)}
|
||||
player.removeBarbPoints(BarbAssaultPoints(resolvedCost.amountPerRole, resolvedCost.amountPerRole, resolvedCost.amountPerRole, resolvedCost.amountPerRole))
|
||||
removeBAPoints(player,BarbAssaultPoints(resolvedCost.amountPerRole, resolvedCost.amountPerRole, resolvedCost.amountPerRole, resolvedCost.amountPerRole))
|
||||
}
|
||||
is RewardCost.AnyRole -> { closeInterface(player);gambleDialogReward(player,resolvedCost.minimum) } //player.removeBarbPoints(BarbAssaultPoints(cost.minimum, cost.minimum, cost.minimum, cost.minimum))
|
||||
is RewardCost.Coins -> {
|
||||
if (reward.queenKillText != null) { setAttribute(player,"barbass:queen-kill", 0)}
|
||||
removeItem(player, Item(Items.COINS_995, resolvedCost.amount), Container.INVENTORY)
|
||||
}
|
||||
is RewardCost.Specific -> player.removeBarbPoints(resolvedCost.required)
|
||||
is RewardCost.Specific -> removeBAPoints(player,resolvedCost.required)
|
||||
else -> return
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ import org.rs09.consts.Items
|
|||
import org.rs09.consts.NPCs
|
||||
|
||||
|
||||
class BarbassaultTut: MapArea {
|
||||
class BATutorial: MapArea {
|
||||
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> {
|
||||
//block standard teleports.
|
||||
|
|
@ -3,34 +3,30 @@ package content.minigame.barbassault
|
|||
import content.minigame.barbassault.arena.BarbassaultSession
|
||||
import core.game.node.entity.player.Player
|
||||
|
||||
//thank you Ceikry
|
||||
|
||||
const val BA_SESSION_KEY = "ba-session"
|
||||
|
||||
/**
|
||||
* Gets or sets the player's current Barbarian Assault session.
|
||||
*
|
||||
* This property provides convenient access to the player's active
|
||||
* [BarbassaultSession], if one exists.
|
||||
*
|
||||
* When setting:
|
||||
* - Assigning a non-null value will store the session on the player.
|
||||
* - Assigning `null` will remove the session attribute entirely.
|
||||
* @param player [Player]
|
||||
*
|
||||
* @return The current [BarbassaultSession] if the player is in a session,
|
||||
* or `null` if they are not participating in Barbarian Assault.
|
||||
*/
|
||||
var Player.baSession: BarbassaultSession?
|
||||
get() = getAttribute(BA_SESSION_KEY)
|
||||
set(value) {
|
||||
if (value == null) removeAttribute(BA_SESSION_KEY)
|
||||
else setAttribute(BA_SESSION_KEY, value)
|
||||
}
|
||||
//getBASession(player)
|
||||
fun getBASession(player: Player): BarbassaultSession? = player.getAttribute(BA_SESSION_KEY)
|
||||
|
||||
fun Player.isBAHealer(): Boolean {
|
||||
return baSession?.team?.isHealer(this) == true
|
||||
fun setBASession(player: Player, session: BarbassaultSession?) {
|
||||
if (session == null) {
|
||||
player.removeAttribute(BA_SESSION_KEY)
|
||||
} else {
|
||||
player.setAttribute(BA_SESSION_KEY, session)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the player's current Barbarian Assault points.
|
||||
*
|
||||
* @param player [Player]
|
||||
* @return [BarbAssaultPoints] representing the player's stored points in each role:
|
||||
* - `atk`: Attacker points
|
||||
* - `col`: Collector points
|
||||
|
|
@ -39,20 +35,21 @@ fun Player.isBAHealer(): Boolean {
|
|||
*
|
||||
* Example usage:
|
||||
* ```
|
||||
* val points = player.getBarbPoints()
|
||||
* val points = getBAPoints(player)
|
||||
* println("Attacker points: ${points.atk}")
|
||||
* ```
|
||||
*/
|
||||
fun Player.getBarbPoints(): BarbAssaultPoints = BarbAssaultPoints(
|
||||
getAttribute("barbass:atk-points", 0),
|
||||
getAttribute("barbass:col-points", 0),
|
||||
getAttribute("barbass:def-points", 0),
|
||||
getAttribute("barbass:heal-points", 0)
|
||||
*///getBAPoints(player)
|
||||
fun getBAPoints(player: Player): BarbAssaultPoints = BarbAssaultPoints(
|
||||
player.getAttribute("barbass:atk-points", 0),
|
||||
player.getAttribute("barbass:col-points", 0),
|
||||
player.getAttribute("barbass:def-points", 0),
|
||||
player.getAttribute("barbass:heal-points", 0)
|
||||
)
|
||||
|
||||
/**
|
||||
* Sets the player's Barbarian Assault role points, clamping each to the allowed range (0 to 500)
|
||||
* and saving them to persistent storage.
|
||||
*
|
||||
* @param player [Player]
|
||||
* @param points [BarbAssaultPoints] containing the new point values for each role:
|
||||
* - `atk`: Attacker points
|
||||
* - `col`: Collector points
|
||||
|
|
@ -62,66 +59,63 @@ fun Player.getBarbPoints(): BarbAssaultPoints = BarbAssaultPoints(
|
|||
* Example usage:
|
||||
* ```
|
||||
* val newPoints = BarbAssaultPoints(atk = 120, col = 80, def = 200, heal = 0)
|
||||
* player.setBarbPoints(newPoints)
|
||||
* setBAPoints(player,newPoints)
|
||||
* ```
|
||||
*/
|
||||
fun Player.setBarbPoints(points: BarbAssaultPoints) {
|
||||
fun setBAPoints(player: Player, points: BarbAssaultPoints) {
|
||||
val rolePoints = points.clamped()
|
||||
setAttribute("/save:barbass:atk-points", rolePoints.atk)
|
||||
setAttribute("/save:barbass:col-points", rolePoints.col)
|
||||
setAttribute("/save:barbass:def-points", rolePoints.def)
|
||||
setAttribute("/save:barbass:heal-points", rolePoints.heal)
|
||||
player.setAttribute("/save:barbass:atk-points", rolePoints.atk)
|
||||
player.setAttribute("/save:barbass:col-points", rolePoints.col)
|
||||
player.setAttribute("/save:barbass:def-points", rolePoints.def)
|
||||
player.setAttribute("/save:barbass:heal-points", rolePoints.heal)
|
||||
}
|
||||
/**
|
||||
* Adds Barbarian Assault points to the player.
|
||||
*
|
||||
* @param player [Player]
|
||||
* @param additional The points to be added to the player's current Barbarian Assault points.
|
||||
* Values will be automatically clamped between 0 and 500.
|
||||
*
|
||||
* Example usage:
|
||||
* ```
|
||||
* // Give the player 30 attacker points and 10 collector points
|
||||
* player.addBarbPoints(BarbAssaultPoints(atk = 30, col = 10, def = 0, heal = 0))
|
||||
* addBAPoints(player,BarbAssaultPoints(atk = 30, col = 10, def = 0, heal = 0))
|
||||
* ```
|
||||
*/
|
||||
fun Player.addBarbPoints(additional: BarbAssaultPoints) {
|
||||
setBarbPoints(getBarbPoints() + additional)
|
||||
fun addBAPoints(player: Player,additional: BarbAssaultPoints) {
|
||||
setBAPoints(player,getBAPoints(player) + additional)
|
||||
//todo Add warning message if points hit cap.
|
||||
//"You have maxed out your Healer Honor Points. You should spend them /n
|
||||
//commands."
|
||||
//https://youtu.be/rWRWL5PUj94?t=244
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes Barbarian Assault points from the player.
|
||||
*
|
||||
* @param player [Player]
|
||||
* @param toRemove The points to be subtracted from the player's current Barbarian Assault points.
|
||||
* Values will be clamped so that no role goes below 0.
|
||||
*
|
||||
* Example usage:
|
||||
* ```
|
||||
* // Remove 15 attacker points and 5 defender points
|
||||
* player.removeBarbPoints(BarbAssaultPoints(atk = 15, col = 0, def = 5, heal = 0))
|
||||
* removeBAPoints(BarbAssaultPoints(atk = 15, col = 0, def = 5, heal = 0))
|
||||
* ```
|
||||
*/
|
||||
fun Player.removeBarbPoints(toRemove: BarbAssaultPoints) {
|
||||
setBarbPoints(getBarbPoints() - toRemove)
|
||||
fun removeBAPoints(player: Player, toRemove: BarbAssaultPoints) {
|
||||
setBAPoints(player,getBAPoints(player) - toRemove)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the player has defeated the Penance Queen at least once.
|
||||
*
|
||||
* This is determined by the `"barbass:queen-kill"` attribute,
|
||||
* which tracks the number of successful Queen kills.
|
||||
* @param player [Player]
|
||||
*
|
||||
* @return `true` if the player has one or more Queen kills,
|
||||
* otherwise `false`.
|
||||
*/
|
||||
fun Player.hasQueenKill(): Boolean = getAttribute("barbass:queen-kill", 0) > 0
|
||||
fun hasQueenKill(player: Player): Boolean = player.getAttribute("barbass:queen-kill", 0) > 0
|
||||
|
||||
/**
|
||||
* Retrieves the player's Barbarian Assault role levels from their saved attributes.
|
||||
* Retrieves the player's Barbarian Assault role levels
|
||||
* Defaults to level 1 for any role if not previously set.
|
||||
*
|
||||
* @param player [Player]
|
||||
* @return [BarbAssaultLevels] containing the level for each role:
|
||||
* - `atk`: Attacker level
|
||||
* - `col`: Collector level
|
||||
|
|
@ -130,19 +124,19 @@ fun Player.hasQueenKill(): Boolean = getAttribute("barbass:queen-kill", 0) > 0
|
|||
*
|
||||
* Example usage:
|
||||
* ```
|
||||
* val levels = player.getBarbLevels()
|
||||
* val levels = getBALevels(player)
|
||||
* println("Attacker Level: ${levels.atk}")
|
||||
* ```
|
||||
*/
|
||||
fun Player.getBarbLevels(): BarbAssaultLevels = BarbAssaultLevels(
|
||||
getAttribute("barbass:atk-level", 1),
|
||||
getAttribute("barbass:col-level", 1),
|
||||
getAttribute("barbass:def-level", 1),
|
||||
getAttribute("barbass:heal-level", 1)
|
||||
fun getBALevels(player: Player): BarbAssaultLevels = BarbAssaultLevels(
|
||||
player.getAttribute("barbass:atk-level", 1),
|
||||
player.getAttribute("barbass:col-level", 1),
|
||||
player.getAttribute("barbass:def-level", 1),
|
||||
player.getAttribute("barbass:heal-level", 1)
|
||||
)
|
||||
/**
|
||||
* Sets the player's Barbarian Assault role levels and saves them to persistent attributes.
|
||||
*
|
||||
* Sets the player's Barbarian Assault role levels
|
||||
* @param player [Player]
|
||||
* @param levels The [BarbAssaultLevels] object containing levels for each role:
|
||||
* - `atk`: Attacker level (1–5)
|
||||
* - `col`: Collector level (1–5)
|
||||
|
|
@ -152,20 +146,21 @@ fun Player.getBarbLevels(): BarbAssaultLevels = BarbAssaultLevels(
|
|||
* Example usage:
|
||||
* ```
|
||||
* val newLevels = BarbAssaultLevels(atk = 2, col = 1, def = 3, heal = 1)
|
||||
* player.setBarbLevels(newLevels)
|
||||
* setBALevels(player,newLevels)
|
||||
* ```
|
||||
*/
|
||||
fun Player.setBarbLevels(levels: BarbAssaultLevels) {
|
||||
setAttribute("/save:barbass:atk-level", levels.atk)
|
||||
setAttribute("/save:barbass:col-level", levels.col)
|
||||
setAttribute("/save:barbass:def-level", levels.def)
|
||||
setAttribute("/save:barbass:heal-level", levels.heal)
|
||||
fun setBALevels(player: Player,levels: BarbAssaultLevels) {
|
||||
player.setAttribute("/save:barbass:atk-level", levels.atk)
|
||||
player.setAttribute("/save:barbass:col-level", levels.col)
|
||||
player.setAttribute("/save:barbass:def-level", levels.def)
|
||||
player.setAttribute("/save:barbass:heal-level", levels.heal)
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the level of the specified Barbarian Assault role by 1, up to a maximum of 5.
|
||||
*
|
||||
* Only one role can be increased at a time. The result is clamped to ensure the level does not exceed 5.
|
||||
*
|
||||
* @param player [Player]
|
||||
* @param role The [BarbRole] to increase the level of. Must be one of:
|
||||
* - `BarbRole.ATTACKER`
|
||||
* - `BarbRole.COLLECTOR`
|
||||
|
|
@ -174,40 +169,54 @@ fun Player.setBarbLevels(levels: BarbAssaultLevels) {
|
|||
*
|
||||
* Example usage:
|
||||
* ```
|
||||
* player.increaseBarbRoleLevel(BarbRole.ATTACKER)
|
||||
* increaseBARoleLevel(player,BarbRole.ATTACKER)
|
||||
* ```
|
||||
*/
|
||||
fun Player.increaseBarbRoleLevel(role: BarbRole) {
|
||||
val current = getBarbLevels()
|
||||
fun increaseBARoleLevel(player: Player,role: BarbRole) {
|
||||
val current = getBALevels(player)
|
||||
val newLevels = when (role) {
|
||||
BarbRole.ATTACKER -> current.copy(atk = current.atk + 1)
|
||||
BarbRole.COLLECTOR -> current.copy(col = current.col + 1)
|
||||
BarbRole.DEFENDER -> current.copy(def = current.def + 1)
|
||||
BarbRole.HEALER -> current.copy(heal = current.heal + 1)
|
||||
}.clamped()
|
||||
setBarbLevels(newLevels)
|
||||
setBALevels(player,newLevels)
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the player's current Barbarian Assault wave.
|
||||
*
|
||||
* This value is stored under the `"barbass:wave"` attribute and
|
||||
* represents the wave the player is currently on in a session.
|
||||
* @param player [Player]
|
||||
*
|
||||
* @return The current wave number. Defaults to `1` if no value is set.
|
||||
*/
|
||||
fun Player.getBarbWave(): Int? {
|
||||
return this.getAttribute("barbass:wave", 1)
|
||||
fun getBAWave(player: Player): Int? {
|
||||
return player.getAttribute("barbass:wave", 1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player's current Barbarian Assault wave.
|
||||
*
|
||||
* This stores the wave value under the `"/save:barbass:wave"` attribute,
|
||||
* allowing it to persist.
|
||||
* @param player [Player]
|
||||
*
|
||||
* @param wave The wave number to assign to the player.
|
||||
*/
|
||||
fun Player.setBarbWave(wave: Int){
|
||||
this.setAttribute("/save:barbass:wave", wave)
|
||||
}
|
||||
fun setBAWave(player: Player, wave: Int){
|
||||
player.setAttribute("/save:barbass:wave", wave)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Barbarian Assault role assigned to the player.
|
||||
*
|
||||
* @param player The player whose role should be retrieved.
|
||||
* @return The player's assigned [BarbRole], or `null` if the player is not in a Barbarian Assault session or team.
|
||||
*/
|
||||
fun getBARoleForPlayer(player: Player): BarbRole? {
|
||||
val team = getBASession(player)?.team ?: return null
|
||||
return team.getRoleForPlayer(player)
|
||||
}
|
||||
/**
|
||||
* Checks whether the player currently has the specified Barbarian Assault role.
|
||||
*
|
||||
* @param player The player to check.
|
||||
* @param role The role to compare against.
|
||||
* @return `true` if the player has the specified role, otherwise `false`.
|
||||
*/
|
||||
fun isBARole(player: Player, role: BarbRole) = getBARoleForPlayer(player) == role
|
||||
|
|
@ -27,7 +27,7 @@ class CommanderConnad(player: Player? = null) : DialoguePlugin(player) {
|
|||
return true
|
||||
}
|
||||
override fun handle(componentID: Int, buttonID: Int): Boolean {
|
||||
val barbasspoints = player.getBarbPoints()
|
||||
val barbasspoints = getBAPoints(player)
|
||||
val displayName = player.name.replaceFirstChar { it.uppercaseChar() }
|
||||
|
||||
when (stage) {
|
||||
|
|
@ -77,7 +77,7 @@ class CommanderConnad(player: Player? = null) : DialoguePlugin(player) {
|
|||
77 -> npcl(FacialExpression.ASKING,"I can change it down to wave 1, Are you sure you want that?").also { stage++ }
|
||||
78 -> showTopics(
|
||||
Topic(FacialExpression.FRIENDLY, "Yes, reset my wave to one.",79),
|
||||
Topic(FacialExpression.FRIENDLY, "No, I want to stay on wave ${player?.getBarbWave()}.",10)
|
||||
Topic(FacialExpression.FRIENDLY, "No, I want to stay on wave ${getBAWave(player)}.",10)
|
||||
)
|
||||
79 -> {
|
||||
npcl(FacialExpression.ASKING,"Very well.").also { stage = END_DIALOGUE }
|
||||
|
|
@ -97,8 +97,8 @@ class CommanderConnad(player: Player? = null) : DialoguePlugin(player) {
|
|||
if (player.hasItem(Item(Items.QUEEN_HELP_BOOK_10562))) return 51
|
||||
return 50
|
||||
}
|
||||
private fun areWaveOne(player: Player?): Int {
|
||||
if (player?.getBarbWave() != 1) return 77
|
||||
private fun areWaveOne(player: Player): Int {
|
||||
if (getBAWave(player) != 1) return 77
|
||||
return 75
|
||||
}
|
||||
override fun getIds(): IntArray {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package content.minigame.barbassault
|
|||
|
||||
import content.minigame.barbassault.arena.BarbassaultSession
|
||||
import content.minigame.barbassault.arena.BarbassaultState
|
||||
import content.minigame.barbassault.arena.Npcs.dropPenanceEggCluster
|
||||
import core.api.log
|
||||
import core.game.activity.ActivityManager
|
||||
import core.game.activity.ActivityPlugin
|
||||
|
|
@ -11,23 +10,17 @@ import core.game.node.entity.Entity
|
|||
import core.game.node.entity.combat.CombatStyle
|
||||
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.GroundItemManager
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.zone.ZoneRestriction
|
||||
import core.game.worldevents.holiday.easter.EasterEvent.Companion.EGG_SPAWN_TIME
|
||||
import core.game.worldevents.holiday.easter.EasterEvent.Companion.eggs
|
||||
import core.plugin.Initializable
|
||||
import core.tools.Log
|
||||
import org.rs09.consts.Items
|
||||
|
||||
private val sessions = mutableListOf<BarbassaultSession>()
|
||||
private var activity: BarbassaultActivity? = null
|
||||
private var activity: BAActivity? = null
|
||||
@Initializable
|
||||
open class BarbassaultActivity : ActivityPlugin("barbassault",false, true, true,ZoneRestriction.CANNON,ZoneRestriction.FIRES,ZoneRestriction.FOLLOWERS,ZoneRestriction.RANDOM_EVENTS) {
|
||||
open class BAActivity : ActivityPlugin("barbassault",false, true, true,ZoneRestriction.CANNON,ZoneRestriction.FIRES,ZoneRestriction.FOLLOWERS,ZoneRestriction.RANDOM_EVENTS) {
|
||||
init {
|
||||
activity = this
|
||||
}
|
||||
|
|
@ -62,7 +55,7 @@ open class BarbassaultActivity : ActivityPlugin("barbassault",false, true, true,
|
|||
val ename = e?.name
|
||||
log(this.javaClass, Log.FINE,"$ename has died in Barbass")
|
||||
if (e is Player) {
|
||||
val session = e.baSession
|
||||
val session = getBASession(e)
|
||||
session?.state = BarbassaultState.DEATH
|
||||
e.getProperties().setTeleportLocation(null)
|
||||
return true
|
||||
|
|
@ -91,12 +84,11 @@ open class BarbassaultActivity : ActivityPlugin("barbassault",false, true, true,
|
|||
|
||||
companion object {
|
||||
fun createSession(leader: Player): BarbassaultSession {
|
||||
val activity = ActivityManager.getActivity("barbassault") as BarbassaultActivity
|
||||
val activity = ActivityManager.getActivity("barbassault") as BAActivity
|
||||
val session = BarbassaultSession(activity)
|
||||
sessions += session
|
||||
|
||||
leader.baSession = session
|
||||
|
||||
setBASession(leader,session)
|
||||
|
||||
return session
|
||||
}
|
||||
|
|
@ -2,15 +2,15 @@ package content.minigame.barbassault.arena
|
|||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.LureItems
|
||||
import content.minigame.barbassault.arena.BaHornSystem.HornHelper.getHealerHorn
|
||||
import content.minigame.barbassault.arena.BAHornSystem.HornHelper.getHealerHorn
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon.Companion.loadEggHopper
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon.Companion.loadHopperEggs
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon.Companion.showEggHopperCount
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBarbLevels
|
||||
import content.minigame.barbassault.isBAHealer
|
||||
import content.minigame.barbassault.getBALevels
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.isBARole
|
||||
import core.api.*
|
||||
import core.game.global.action.ClimbActionHandler
|
||||
import core.game.global.action.DropListener
|
||||
|
|
@ -22,8 +22,6 @@ import core.game.node.entity.combat.CombatStyle
|
|||
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.GroundItemManager
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.GameWorld.Pulser
|
||||
|
|
@ -115,7 +113,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
val animationDuration = animationDuration(ClimbActionHandler.CLIMB_UP)
|
||||
player.lock(animationDuration)
|
||||
player.animate(ClimbActionHandler.CLIMB_UP)
|
||||
Pulser.submit(object : Pulse(animationDuration) { override fun pulse(): Boolean {player.baSession?.forfeit(); return true }})
|
||||
Pulser.submit(object : Pulse(animationDuration) { override fun pulse(): Boolean {getBASession(player)?.forfeit(); return true }})
|
||||
}
|
||||
}
|
||||
return@on true
|
||||
|
|
@ -123,7 +121,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
//you healed $heal.count hitpoints.
|
||||
//You've been healed $amount hitpoints and your poison cured.
|
||||
on(Scenery.HEALER_SPRING_20150, IntType.SCENERY, "Drink-from") { player, _ ->
|
||||
if (player.isBAHealer()) {
|
||||
if (isBARole(player, BarbRole.HEALER)) {
|
||||
player.animate(Animation(5407))
|
||||
player.lock(5)
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
|
|
@ -134,7 +132,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
heal(player, healAmount)
|
||||
player.unlock()
|
||||
sendMessage(player,"You've been healed $healAmount hitpoints.")
|
||||
player.baSession?.updateBarbHealerIfaceHPOfPlayer(player)
|
||||
getBASession(player)?.updateBarbHealerIfaceHPOfPlayer(player)
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
|
@ -145,7 +143,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
//"The player's hitpoints are full." //Error message if target player hp is full
|
||||
//sendamount heal for conversion to points at end.
|
||||
on(Scenery.HEALER_SPRING_20150, IntType.SCENERY, "Take-from") { player, _ ->
|
||||
val healLevel = player.getBarbLevels().heal
|
||||
val healLevel = getBALevels(player).heal
|
||||
//emote 5400
|
||||
/* HEALING_VIAL_10546 -- empty
|
||||
HEALING_VIAL1_10545 // 1
|
||||
|
|
@ -159,7 +157,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
//CATALYTIC_RUNE_12851, ELEMENTAL_RUNE_12850
|
||||
|
||||
onUnequip(ROLE_ICON) { player, _ ->
|
||||
if (player.baSession?.state == BarbassaultState.IN_ARENA){
|
||||
if (getBASession(player)?.state == BarbassaultState.IN_ARENA){
|
||||
sendMessage(player, "You can't remove that!") // is there a proper message for this?
|
||||
return@onUnequip false
|
||||
}
|
||||
|
|
@ -167,14 +165,14 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
}
|
||||
|
||||
onEquip(ROLE_ICON) { player, _ ->
|
||||
if (player.baSession?.state == BarbassaultState.IN_ARENA) {
|
||||
if (getBASession(player)?.state == BarbassaultState.IN_ARENA) {
|
||||
sendMessage(player, "You can't remove that!")
|
||||
return@onEquip false
|
||||
}
|
||||
return@onEquip true
|
||||
}
|
||||
on(LureItems, IntType.GROUNDITEM, "Take") { player, node ->
|
||||
val session = player.baSession ?: return@on true
|
||||
val session = getBASession(player) ?: return@on true
|
||||
if (session.team.getRoleForPlayer(player) != BarbRole.DEFENDER) {
|
||||
sendMessage(player,"not a Defender")
|
||||
}
|
||||
|
|
@ -183,7 +181,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
}
|
||||
on(LureItems, IntType.ITEM, "Drop") { player, node ->
|
||||
DropListener.drop(player, node.asItem())
|
||||
val session = player.baSession ?: return@on true
|
||||
val session = getBASession(player) ?: return@on true
|
||||
|
||||
val gItem = player.getAttribute<GroundItem>("droppedItem:${node.id}")
|
||||
(gItem as SessionGroundSpawn).flag = true
|
||||
|
|
@ -194,7 +192,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
}
|
||||
on(EggCannon.ALL_EGGS, IntType.GROUNDITEM, "Take") { player, node ->
|
||||
if (node !is GroundItem) return@on true
|
||||
val session = player.baSession ?: return@on true
|
||||
val session = getBASession(player) ?: return@on true
|
||||
if (session.team.getRoleForPlayer(player) != BarbRole.COLLECTOR) {
|
||||
sendMessage(player,"not a collector")
|
||||
}
|
||||
|
|
@ -224,7 +222,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
fun sessionDestination(player: Player, node: Node, direction: Direction? = null): Location {
|
||||
//work around for running off to org location instead of copy location.
|
||||
//Player Name's Parlor chairs Should fix this!
|
||||
val session = player.baSession ?: return node.location
|
||||
val session = getBASession(player) ?: return node.location
|
||||
val borders = getRegionBorders(session.region.regionId)
|
||||
val base = session.base
|
||||
return Location.create(
|
||||
|
|
@ -297,11 +295,11 @@ object BarbAssaultCombat {
|
|||
}
|
||||
|
||||
fun applyAttackValidation( self: NPC, attacker: Player, state: BattleState ): Int {
|
||||
val session = attacker.baSession ?: return state.estimatedHit
|
||||
val session = getBASession(attacker) ?: return state.estimatedHit
|
||||
val currentCall = session.roleCalls[BarbRole.COLLECTOR]?.toCall
|
||||
//todo read my players level instead of scanning the inventory every time for a horn.
|
||||
|
||||
val hornBonus = (BaHornSystem.HornHelper.getAttackerHorn(attacker)?.ordinal ?: -1) + 2
|
||||
val hornBonus = (BAHornSystem.HornHelper.getAttackerHorn(attacker)?.ordinal ?: -1) + 2
|
||||
val damage = state.estimatedHit + hornBonus
|
||||
val usedStyle = resolveAttackerStyle(attacker, state)
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package content.minigame.barbassault.arena
|
||||
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.inInventory
|
||||
import core.api.sendChat
|
||||
import core.api.sendMessage
|
||||
|
|
@ -9,7 +9,7 @@ import core.game.interaction.InteractionListener
|
|||
import core.game.node.entity.player.Player
|
||||
import org.rs09.consts.Items
|
||||
|
||||
class BaHornSystem : InteractionListener {
|
||||
class BAHornSystem : InteractionListener {
|
||||
|
||||
private val ATTACKER_HORNS = intArrayOf( Items.ATTACKER_HORN_10516, Items.ATTACKER_HORN_10517, Items.ATTACKER_HORN_10518, Items.ATTACKER_HORN_10519, Items.ATTACKER_HORN_10520 )
|
||||
private val HEALER_HORNS = intArrayOf( Items.HEALER_HORN_10526, Items.HEALER_HORN_10527, Items.HEALER_HORN_10528, Items.HEALER_HORN_10529, Items.HEALER_HORN_10530 )
|
||||
|
|
@ -53,8 +53,8 @@ class BaHornSystem : InteractionListener {
|
|||
|
||||
sendChat(player, call.text)
|
||||
when (food) {
|
||||
is BarbassaultSession.PoisonFood -> player.baSession?.onHornCall(player, food)
|
||||
null -> player.baSession?.alertHealers(player)
|
||||
is BarbassaultSession.PoisonFood -> getBASession(player)?.onHornCall(player, food)
|
||||
null -> getBASession(player)?.alertHealers(player)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -76,8 +76,8 @@ class BaHornSystem : InteractionListener {
|
|||
|
||||
sendChat(player, call.text)
|
||||
when (style) {
|
||||
is BarbassaultSession.AttackerStyle -> player.baSession?.onHornCall(player, style)
|
||||
null-> player.baSession?.alertHealers(player)
|
||||
is BarbassaultSession.AttackerStyle -> getBASession(player)?.onHornCall(player, style)
|
||||
null-> getBASession(player)?.alertHealers(player)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -97,8 +97,8 @@ class BaHornSystem : InteractionListener {
|
|||
|
||||
sendChat(player, call.text)
|
||||
when (color) {
|
||||
is BarbassaultSession.EggColor -> player.baSession?.onHornCall(player, color)
|
||||
null -> player.baSession?.alertHealers(player)
|
||||
is BarbassaultSession.EggColor -> getBASession(player)?.onHornCall(player, color)
|
||||
null -> getBASession(player)?.alertHealers(player)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -119,8 +119,8 @@ class BaHornSystem : InteractionListener {
|
|||
|
||||
sendChat(player, call.text)
|
||||
when (lure) {
|
||||
is BarbassaultSession.LureFood -> player.baSession?.onHornCall(player, lure)
|
||||
null -> player.baSession?.alertHealers(player)
|
||||
is BarbassaultSession.LureFood -> getBASession(player)?.onHornCall(player, lure)
|
||||
null -> getBASession(player)?.alertHealers(player)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -3,15 +3,16 @@ package content.minigame.barbassault.arena
|
|||
import content.minigame.barbassault.ALL_BARBASS_ITEMS
|
||||
import content.minigame.barbassault.BA_SESSION_KEY
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.BarbassaultActivity
|
||||
import content.minigame.barbassault.BAActivity
|
||||
import content.minigame.barbassault.LureItems
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon
|
||||
import content.minigame.barbassault.arena.scenery.GloryHorn
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBarbLevels
|
||||
import content.minigame.barbassault.getBarbWave
|
||||
import content.minigame.barbassault.getBALevels
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.getBAWave
|
||||
|
||||
import content.minigame.barbassault.lobby.*
|
||||
import content.minigame.barbassault.lobby.BarbassaultLobby.Companion.waveLobbies
|
||||
import content.minigame.barbassault.lobby.BALobby.Companion.waveLobbies
|
||||
import core.api.*
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.impl.PulseManager
|
||||
|
|
@ -20,7 +21,6 @@ import core.game.node.entity.player.Player
|
|||
import core.game.node.item.GroundItem
|
||||
import core.game.node.item.GroundItemManager
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.config.GroundSpawnLoader
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.GameWorld.Pulser
|
||||
|
|
@ -41,7 +41,7 @@ enum class BarbassaultState { PARTY_CREATION, STARTING, IN_ARENA,FORFEIT, COMPLE
|
|||
data class PenanceNpcTunnel(val type:PenanceType, val x: Int,val y: Int,val z: Int,val direction: Direction) { fun toLocation(): Location = Location(x, y, z) }
|
||||
data class ArenaSpawnItems(val id: Int, val location: Location)
|
||||
|
||||
class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutListener, MapArea {
|
||||
class BarbassaultSession( val activity: BAActivity ? = 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
|
||||
|
|
@ -88,7 +88,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
for (player in team.allPlayers()) {
|
||||
zone.enter(player)
|
||||
|
||||
val pRole = player.baSession?.team?.getRoleForPlayer(player)
|
||||
val pRole = getBASession(player)?.team?.getRoleForPlayer(player)
|
||||
equipBARoleIcon(player, pRole!!)
|
||||
player.properties.teleportLocation = team.spawnLocationFor(player) //base.transform(36, 24, 0)
|
||||
giveRoleItems(player,pRole)
|
||||
|
|
@ -240,7 +240,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
fun endGame(endReason: String){
|
||||
eventBus.clear()
|
||||
scoreManager.resetAll()
|
||||
BarbassaultLobby.TeamToLobby(team,team.wave)
|
||||
BALobby.TeamToLobby(team,team.wave)
|
||||
state = BarbassaultState.PARTY_CREATION
|
||||
for(player in team.allPlayers()) {
|
||||
PulseManager.cancelDeathTask(player)
|
||||
|
|
@ -256,7 +256,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
//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.")
|
||||
BarbTeamManager.updateTeam(player.baSession?.team!!)
|
||||
BarbTeamManager.updateTeam(getBASession(player)?.team!!)
|
||||
}
|
||||
}
|
||||
//MAIN GAME LOOP
|
||||
|
|
@ -280,13 +280,13 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
BarbassaultState.FORFEIT -> { endGame("left"); return true }
|
||||
BarbassaultState.COMPLETE -> {
|
||||
log(this.javaClass, Log.FINE,state.toString())
|
||||
BarbassaultLobby.TeamToLobby(team,team.wave+1)
|
||||
BALobby.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!!)
|
||||
BarbTeamManager.updateTeam(getBASession(player)?.team!!)
|
||||
}
|
||||
return true // we do not have auto start next wave in 2009
|
||||
}
|
||||
|
|
@ -350,7 +350,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
log(this::class.java, Log.FINE, "ENTERED Barbassault Arena")
|
||||
|
||||
val player = entity as? Player ?: return
|
||||
val waveNum = player.getBarbWave()
|
||||
val waveNum = getBAWave(player)
|
||||
val wornIconId = getItemFromEquipment(player, EquipmentSlot.CAPE)?.id
|
||||
val interfaceId = getIconInterfaceId(wornIconId ?: -1)
|
||||
player.fullRestore()
|
||||
|
|
@ -405,7 +405,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) :LogoutLi
|
|||
}
|
||||
|
||||
private fun giveRoleItems(player: Player, role: BarbRole) {
|
||||
val levels = player.getBarbLevels()
|
||||
val levels = getBALevels(player)
|
||||
|
||||
val items = when (role) {
|
||||
BarbRole.ATTACKER -> when (levels.atk) {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package content.minigame.barbassault.arena
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.setComponentVisibility
|
||||
import core.api.setInterfaceText
|
||||
import core.game.component.Component
|
||||
|
|
@ -49,7 +49,7 @@ fun setHealerTeamIfaceSlot(player: Player,slot: Int){
|
|||
}
|
||||
|
||||
fun getPlayerHealerIfaceSlot(player:Player,slot: Int): Player? {
|
||||
val team = player.baSession?.team
|
||||
val team = getBASession(player)?.team
|
||||
val others = team?.allPlayers()?.filter { it != player }
|
||||
return others?.getOrNull(slot)
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ fun getPlayerHealerIfaceSlot(player:Player,slot: Int): Player? {
|
|||
fun HealerIfaceMedicHelp(player: Player, other: Player, toggle: Boolean = false) {
|
||||
if (player == other) return
|
||||
|
||||
val team = player.baSession?.team ?: return
|
||||
val team = getBASession(player)?.team ?: return
|
||||
val mySlot = team.slotOf(player)
|
||||
val otherSlot = team.slotOf(other)
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ fun HealerIfaceMedicHelp(player: Player, other: Player, toggle: Boolean = false)
|
|||
fun HealerIfaceHPUpdatePlayer(player:Player, other:Player ){
|
||||
if (player == other) return
|
||||
|
||||
val team = player.baSession?.team ?: return
|
||||
val team = getBASession(player)?.team ?: return
|
||||
val mySlot = team.slotOf(player)
|
||||
val otherSlot = team.slotOf(other)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ import core.game.node.item.Item
|
|||
import core.game.world.GameWorld
|
||||
|
||||
import core.game.world.map.Location
|
||||
class SessionGroundSpawn(private var session: BarbassaultSession, private var respawnRate: Int, item: Item?,location: Location?,var flag: Boolean? = null) : GroundItem(item, location) {
|
||||
class SessionGroundSpawn(private var session: BarbassaultSession, private var respawnRate: Int, item: Item?, location: Location?,
|
||||
var flag: Boolean? = null) : GroundItem(item, location) {
|
||||
private var active = true
|
||||
private var autoSpawn = true
|
||||
|
||||
override fun toString(): String {
|
||||
return "SessionGroundSpawn [name=$name, respawnRate=$respawnRate, loc=$location]"
|
||||
return "SessionGroundSpawn [name=$name, respawnRate=$respawnRate, loc=$location, flag = $flag]"
|
||||
}
|
||||
|
||||
fun init(): GroundItem {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package content.minigame.barbassault.arena.Npcs
|
||||
package content.minigame.barbassault.arena.npcs
|
||||
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.combat.CombatStyle
|
||||
|
|
@ -3,8 +3,8 @@ package content.minigame.barbassault.arenas.monsters
|
|||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.BarbAssEvent
|
||||
import content.minigame.barbassault.arena.BarbAssaultCombat
|
||||
import content.minigame.barbassault.arena.Npcs.dropPenanceEggCluster
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.arena.npcs.dropPenanceEggCluster
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.*
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.combat.BattleState
|
||||
|
|
@ -12,9 +12,6 @@ import core.game.node.entity.combat.CombatStyle
|
|||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.npc.NPCBehavior
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.GroundItemManager
|
||||
import core.game.node.item.Item
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
|
||||
val PENANCE_FIGHTER_IDS = listOf(
|
||||
|
|
@ -74,7 +71,7 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
|
|||
|
||||
override fun onDeathFinished(self: NPC, killer: Entity) {
|
||||
val player = killer as? Player ?: return
|
||||
val session = player.baSession ?: return
|
||||
val session = getBASession(player) ?: return
|
||||
|
||||
dropPenanceEggCluster(killer,self)
|
||||
session.eventBus.emit(BarbAssEvent.NPCDied(self,player))
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package content.minigame.barbassault.arena.Npcs
|
||||
package content.minigame.barbassault.arena.npcs
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.BarbAssEvent
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.npc.NPCBehavior
|
||||
|
|
@ -37,7 +37,7 @@ class PenanceHealerNPC : NPCBehavior(*PENANCE_HEALER_IDS.toIntArray()) {
|
|||
override fun onDeathFinished(self: NPC, killer: Entity) {
|
||||
super.onDeathFinished(self, killer)
|
||||
val player = killer as? Player ?: return
|
||||
val session = player.baSession ?: return
|
||||
val session = getBASession(player) ?: return
|
||||
|
||||
dropPenanceEggCluster(killer,self)
|
||||
session.eventBus.emit(BarbAssEvent.NPCDied(self,player))
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package content.minigame.barbassault.arena.Npcs
|
||||
package content.minigame.barbassault.arena.npcs
|
||||
|
||||
|
||||
import content.minigame.barbassault.arena.SessionGroundSpawn
|
||||
import content.minigame.barbassault.baSession
|
||||
import core.api.produceGroundItem
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.sendMessage
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
|
|
@ -11,10 +10,19 @@ import core.game.node.item.Item
|
|||
import core.game.world.map.RegionManager
|
||||
import org.rs09.consts.Items
|
||||
|
||||
/**
|
||||
* Drops a cluster of Penance eggs around a target location in Barbarian Assault.
|
||||
*
|
||||
* Eggs are distributed randomly across a 3x3 area centered on the NPC drop location,
|
||||
* or the killer's location if no NPC is provided.
|
||||
*
|
||||
* @param killer The player who triggered the egg drop (must have a BA session).
|
||||
* @param npc Optional NPC used as the center point for the drop location.
|
||||
*/
|
||||
fun dropPenanceEggCluster(killer: Player, npc: NPC? = null) {
|
||||
val center = npc?.dropLocation ?: killer.location
|
||||
val session = killer.baSession ?: return
|
||||
val tiles = center.get3x3Tiles().shuffled()
|
||||
val session = getBASession(killer) ?: return
|
||||
|
||||
val eggs = listOf( Items.RED_EGG_10532, Items.RED_EGG_10532,
|
||||
Items.BLUE_EGG_10533, Items.BLUE_EGG_10533,
|
||||
|
|
@ -24,8 +32,6 @@ fun dropPenanceEggCluster(killer: Player, npc: NPC? = null) {
|
|||
val tile = tiles[i]
|
||||
val thisGroundItem = SessionGroundSpawn(session,60,Item(eggs[i],1),tile)
|
||||
thisGroundItem.init()
|
||||
sendMessage(killer, tile.toString())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package content.minigame.barbassault.arena.Npcs
|
||||
package content.minigame.barbassault.arena.npcs
|
||||
|
||||
import core.api.sendMessage
|
||||
import core.game.node.entity.Entity
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package content.minigame.barbassault.arena.Npcs
|
||||
package content.minigame.barbassault.arena.npcs
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.BarbAssEvent
|
||||
import content.minigame.barbassault.arena.BarbAssaultCombat
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.*
|
||||
import core.api.getItemFromEquipment
|
||||
import core.game.node.entity.Entity
|
||||
|
|
@ -62,7 +62,7 @@ class PenanceRangerNPC : NPCBehavior(*PENANCE_RANGER_IDS.toIntArray()) {
|
|||
override fun onDeathFinished(self: NPC, killer: Entity) {
|
||||
super.onDeathFinished(self, killer)
|
||||
val player = killer as? Player ?: return
|
||||
val session = player.baSession ?: return
|
||||
val session = getBASession(killer) ?: return
|
||||
|
||||
dropPenanceEggCluster(killer,self)
|
||||
session.eventBus.emit(BarbAssEvent.NPCDied(self,player))
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package content.minigame.barbassault.arena.Npcs
|
||||
package content.minigame.barbassault.arena.npcs
|
||||
|
||||
import content.minigame.barbassault.BA_SESSION_KEY
|
||||
import content.minigame.barbassault.BarbRole
|
||||
|
|
@ -7,12 +7,12 @@ import core.game.node.entity.npc.NPC
|
|||
import core.game.node.entity.npc.NPCBehavior
|
||||
import org.rs09.consts.NPCs
|
||||
import content.minigame.barbassault.arena.*
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
|
||||
import core.api.forceWalk
|
||||
import core.api.removeGroundItem
|
||||
import core.api.sendChat
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.GroundItem
|
||||
|
||||
|
||||
val PENANCE_RUNNER_IDS = listOf(
|
||||
|
|
@ -71,7 +71,7 @@ class PenanceRunnerNPC : NPCBehavior(*PENANCE_RUNNER_IDS.toIntArray()) {
|
|||
override fun onDeathFinished(self: NPC, killer: Entity) {
|
||||
super.onDeathFinished(self, killer)
|
||||
val player = killer as? Player ?: return
|
||||
val session = player.baSession ?: return
|
||||
val session = getBASession(player) ?: return
|
||||
|
||||
dropPenanceEggCluster(killer,self)
|
||||
session.eventBus.emit(BarbAssEvent.NPCDied(self,player))
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package content.minigame.barbassault.arena.Npcs
|
||||
package content.minigame.barbassault.arena.npcs
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.npc.NPCBehavior
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package content.minigame.barbassault.arena.scenery
|
||||
|
||||
import content.minigame.barbassault.arena.Npcs.PENANCE_RUNNER_IDS
|
||||
import content.minigame.barbassault.arena.npcs.PENANCE_RUNNER_IDS
|
||||
import core.api.*
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.player.Player
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package content.minigame.barbassault.arena.scenery
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.Npcs.BAGraphics.Blue_EGG_PROJECTILE_978
|
||||
import content.minigame.barbassault.arena.Npcs.BAGraphics.GREEN_EGG_PROJECTILE_977
|
||||
import content.minigame.barbassault.arena.Npcs.BAGraphics.RED_EGG_PROJECTILE_978
|
||||
import content.minigame.barbassault.arena.Npcs.BAGraphics.YELLOW_EGG_PROJECTILE_980
|
||||
import content.minigame.barbassault.arena.Npcs.findClosestNPCIDFromPlayer
|
||||
import content.minigame.barbassault.arena.Npcs.findClosestTargetNPCIDFromNPC
|
||||
import content.minigame.barbassault.arena.npcs.BAGraphics.Blue_EGG_PROJECTILE_978
|
||||
import content.minigame.barbassault.arena.npcs.BAGraphics.GREEN_EGG_PROJECTILE_977
|
||||
import content.minigame.barbassault.arena.npcs.BAGraphics.RED_EGG_PROJECTILE_978
|
||||
import content.minigame.barbassault.arena.npcs.BAGraphics.YELLOW_EGG_PROJECTILE_980
|
||||
import content.minigame.barbassault.arena.npcs.findClosestNPCIDFromPlayer
|
||||
import content.minigame.barbassault.arena.npcs.findClosestTargetNPCIDFromNPC
|
||||
import content.minigame.barbassault.arena.PenanceType
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.*
|
||||
import core.game.component.CloseEvent
|
||||
import core.game.component.Component
|
||||
|
|
@ -47,7 +47,7 @@ class EggCannon : ComponentPlugin() {
|
|||
sendMessage(player, "[BlickySwitch] Activated!")
|
||||
currentSequence.clear()
|
||||
if (player.isAdmin) { //ADMIN ONLY!
|
||||
val eggHopper = player.baSession?.eggHopper
|
||||
val eggHopper = getBASession(player)?.eggHopper
|
||||
eggHopper?.green = 99
|
||||
eggHopper?.red = 99
|
||||
eggHopper?.blue = 99
|
||||
|
|
@ -154,7 +154,7 @@ class EggCannon : ComponentPlugin() {
|
|||
|
||||
fun updateCannonUI(player: Player?){
|
||||
player ?: return
|
||||
val eggHopper = player.baSession?.eggHopper ?: return
|
||||
val eggHopper = getBASession(player)?.eggHopper ?: return
|
||||
val penances = listOf( EggTurret.pHealer, EggTurret.pRunner, EggTurret.pRanger, EggTurret.pFighter )
|
||||
|
||||
penances.forEach { penance ->
|
||||
|
|
@ -184,7 +184,7 @@ class EggCannon : ComponentPlugin() {
|
|||
|
||||
fun openTurretIface(player: Player?) {
|
||||
player ?: return
|
||||
if (player.baSession?.eggHopper?.totalCount() == 0) {
|
||||
if (getBASession(player)?.eggHopper?.totalCount() == 0) {
|
||||
sendDialogueLines(player,"There are no eggs in the hopper.")
|
||||
return
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ class EggCannon : ComponentPlugin() {
|
|||
}
|
||||
fun loadEggHopper(player: Player?){
|
||||
player ?: return
|
||||
val session = player.baSession
|
||||
val session = getBASession(player)
|
||||
val role =session?.team?.getRoleForPlayer(player)
|
||||
if (role != BarbRole.COLLECTOR) {sendMessage(player,"You need to be a Collector to load eggs.");return}
|
||||
ALL_EGGS.forEach { loadHopperEggs(player, it) }
|
||||
|
|
@ -202,14 +202,16 @@ class EggCannon : ComponentPlugin() {
|
|||
}
|
||||
fun loadHopperEggs(player: Player?,itemId: Int ){
|
||||
player ?: return
|
||||
//todo fix egg hopper
|
||||
val session = getBASession(player)
|
||||
val invCount = amountInInventory(player, itemId)
|
||||
val result = player.baSession?.eggHopper?.addEgg(itemId,invCount)
|
||||
val color = player.baSession?.eggHopper?.eggColorMap?.get(itemId)
|
||||
val result = session?.eggHopper?.addEgg(itemId,invCount)
|
||||
val color = session?.eggHopper?.eggColorMap?.get(itemId)
|
||||
val added = result?.get(color) ?: 0
|
||||
//load from collector bag too
|
||||
if(invCount > 0){
|
||||
val result = player.baSession?.eggHopper?.addEgg(itemId,invCount)
|
||||
val color = player.baSession?.eggHopper?.eggColorMap?.get(itemId)
|
||||
val result = session?.eggHopper?.addEgg(itemId,invCount)
|
||||
val color = session?.eggHopper?.eggColorMap?.get(itemId)
|
||||
val added = result?.get(color) ?: 0
|
||||
sendMessage(player,"You load the hopper.")
|
||||
removeItem(player, Item(itemId, added))
|
||||
|
|
@ -218,7 +220,7 @@ class EggCannon : ComponentPlugin() {
|
|||
}
|
||||
fun showEggHopperCount(player: Player?){
|
||||
player ?: return
|
||||
val eggsCount = player.baSession?.eggHopper
|
||||
val eggsCount = getBASession(player)?.eggHopper
|
||||
val poison = eggsCount?.green
|
||||
val explosive = eggsCount?.red
|
||||
val stun = eggsCount?.blue
|
||||
|
|
@ -228,10 +230,11 @@ class EggCannon : ComponentPlugin() {
|
|||
|
||||
//error message CHATBOX "[bold]all of the _PENANCE_ have been killed!"
|
||||
fun fireEgg(player: Player, type: PenanceType, eggType: EggType){
|
||||
val npcId = player.baSession?.currentWaveDefinition?.npcIds?.get(type)
|
||||
val session = getBASession(player)
|
||||
val npcId = session?.currentWaveDefinition?.npcIds?.get(type)
|
||||
val eggCannon = findClosestNPCIDFromPlayer(player,NPCs.EGG_LAUNCHER_5026,2)
|
||||
val target = findClosestTargetNPCIDFromNPC(npcId, eggCannon as NPC ,14)
|
||||
val hopper = player.baSession?.eggHopper ?: return
|
||||
val hopper = session?.eggHopper ?: return
|
||||
|
||||
if (target == null) { sendDialogueLines(player,"There are no targetable Penance ${type.name.lowercase().replaceFirstChar { it.uppercase() }} within firing range.") ;return}
|
||||
if (!eggType.tryConsume(hopper)) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package content.minigame.barbassault.arena.scenery
|
||||
|
||||
import content.minigame.barbassault.arena.BaHornSystem.BaCall
|
||||
import content.minigame.barbassault.arena.BAHornSystem.BaCall
|
||||
import content.minigame.barbassault.arena.BarbassaultSession
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.*
|
||||
import core.game.component.Component
|
||||
import core.game.component.ComponentDefinition
|
||||
|
|
@ -50,7 +50,7 @@ class HornOfGlory : ComponentPlugin() , InteractionListener {
|
|||
val role = pair.first
|
||||
val call = pair.second
|
||||
if(!hornCallLock) {
|
||||
player.baSession?.onHornCall(player, role)
|
||||
getBASession(player)?.onHornCall(player, role)
|
||||
sendChat(player, call.text)
|
||||
player.animate(Animation(5436))
|
||||
player.lock(6)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package content.minigame.barbassault.arena.scenery
|
||||
|
||||
import content.minigame.barbassault.getBarbLevels
|
||||
import content.minigame.barbassault.getBALevels
|
||||
import core.api.EquipmentSlot
|
||||
import core.api.addItem
|
||||
import core.api.getItemFromEquipment
|
||||
|
|
@ -100,7 +100,7 @@ class ItemMachine: InteractionListener {
|
|||
}
|
||||
//Collector//
|
||||
on(Scenery.COLLECTOR_CONVERTER_21250, IntType.SCENERY, "Convert") { player, _ ->
|
||||
val collectorLevel = player.getBarbLevels().col
|
||||
val collectorLevel = getBALevels(player).col
|
||||
if (!hasCape(player, COLLECTOR_ICON)) return@on true
|
||||
|
||||
//Items.RED_EGG_10532
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ package content.minigame.barbassault.bots
|
|||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.BarbassaultState
|
||||
import content.minigame.barbassault.getBARoleForPlayer
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.lobby.BarbassQuickWaveActivity.Companion.addToQueue
|
||||
import content.minigame.barbassault.lobby.BarbassaultLobby.Companion.MAIN_LOBBY
|
||||
import content.minigame.barbassault.lobby.BarbassaultLobby.Companion.QUICK_START
|
||||
import content.minigame.barbassault.lobby.BarbassaultLobby.Companion.waveLobbies
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.lobby.BALobby.Companion.MAIN_LOBBY
|
||||
import content.minigame.barbassault.lobby.BALobby.Companion.QUICK_START
|
||||
import content.minigame.barbassault.lobby.BALobby.Companion.waveLobbies
|
||||
import core.api.forceMove
|
||||
import core.api.getRegionBorders
|
||||
import core.game.bots.CombatBotAssembler
|
||||
|
|
@ -16,7 +17,7 @@ import core.game.node.item.Item
|
|||
import core.game.world.map.Location
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
class BarbassBot(l: Location) : PvMBots(legitimizeLocation(l)){
|
||||
class BABot(l: Location) : PvMBots(legitimizeLocation(l)){
|
||||
init {
|
||||
CombatBotAssembler().gearPCiMeleeBot(this)
|
||||
val icape: Item = this.equipment.get(1)
|
||||
|
|
@ -69,7 +70,7 @@ class BarbassBot(l: Location) : PvMBots(legitimizeLocation(l)){
|
|||
//chill, say somethings, walk around in .walkablearea
|
||||
}
|
||||
private fun doRoleTask() {
|
||||
val myRole = this.baSession?.team?.getRoleForPlayer(this)
|
||||
val myRole = getBARoleForPlayer(this)
|
||||
when (myRole) {
|
||||
BarbRole.ATTACKER -> combathandler.fightNPCs()
|
||||
BarbRole.DEFENDER -> combathandler.handleDefender()
|
||||
|
|
@ -125,7 +126,7 @@ class BarbassBot(l: Location) : PvMBots(legitimizeLocation(l)){
|
|||
if (QUICK_START.insideBorder(this.getLocation())) {
|
||||
return State.WAITING_IN_ROOM
|
||||
}
|
||||
if (this.baSession?.state == BarbassaultState.IN_ARENA) {
|
||||
if (getBASession(this)?.state == BarbassaultState.IN_ARENA) {
|
||||
return State.PLAY_GAME
|
||||
}
|
||||
if (isInLobbyOnly(this.getLocation())) {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package content.minigame.barbassault.bots
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBARoleForPlayer
|
||||
import core.game.interaction.MovementPulse
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.path.Pathfinder
|
||||
|
|
@ -10,7 +10,7 @@ import core.game.world.GameWorld
|
|||
import java.util.*
|
||||
|
||||
|
||||
class BACombatState(val bot: BarbassBot) {
|
||||
class BACombatState(val bot: BABot) {
|
||||
private val Random = Random()
|
||||
private val krng = kotlin.random.Random.Default
|
||||
val randomtype = Random().nextInt(100)
|
||||
|
|
@ -36,7 +36,7 @@ class BACombatState(val bot: BarbassBot) {
|
|||
fun chatter() {
|
||||
bot.sendChat("LETS GOO!")
|
||||
if (krng.nextInt(200) != 0) return
|
||||
val role = bot.baSession?.team?.getRoleForPlayer(bot)
|
||||
val role = getBARoleForPlayer(bot)
|
||||
val messages = when (role) {
|
||||
BarbRole.ATTACKER -> listOf("Call pls", "Wrong style?", "Attacking!")
|
||||
BarbRole.HEALER -> listOf("Need poison", "Healing!", "Healer here","Call pls")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package content.minigame.barbassault.lobby
|
||||
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBarbWave
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.getBAWave
|
||||
import content.minigame.barbassault.lobby.BarbTeamManager.abandonTeam
|
||||
import content.minigame.barbassault.lobby.BarbTeamManager.joinTeam
|
||||
import core.api.closeInterface
|
||||
|
|
@ -20,7 +20,7 @@ class AcceptRoleInterface : ComponentPlugin() {
|
|||
ComponentDefinition.forId(AcceptRole.ID).plugin = this
|
||||
return this
|
||||
}
|
||||
override fun handle(player: Player?,component: Component?, opcode: Int, button: Int, slot: Int, itemId: Int ): Boolean {
|
||||
override fun handle(player: Player,component: Component?, opcode: Int, button: Int, slot: Int, itemId: Int ): Boolean {
|
||||
when (button) {
|
||||
AcceptRole.AcceptButton, AcceptRole.AcceptButtonText -> { handleAccept(player); return true }
|
||||
AcceptRole.DeclineButton, AcceptRole.DeclineButtonText -> { handleDecline(player); return true }
|
||||
|
|
@ -35,7 +35,7 @@ class AcceptRoleInterface : ComponentPlugin() {
|
|||
super.open(player, component)
|
||||
var isopen = true
|
||||
player ?: return
|
||||
val team = player.baSession?.team
|
||||
val team = getBASession(player)?.team
|
||||
val recruit = team?.recruit?.player
|
||||
component?.setCloseEvent{ _, _ -> if (recruit != null && isopen) { closeInterface(recruit); isopen = false }; return@setCloseEvent true }
|
||||
|
||||
|
|
@ -45,8 +45,8 @@ class AcceptRoleInterface : ComponentPlugin() {
|
|||
val slotPlayer: Player? = partySlot?.player
|
||||
|
||||
if (slotPlayer != null) {
|
||||
val formattedRole = slotPlayer.baSession?.team?.getRoleForPlayer(slotPlayer)?.toString()?.lowercase()?.replaceFirstChar { it.uppercase() }?: AcceptRole.defaultText
|
||||
val wave = slotPlayer.getBarbWave()
|
||||
val formattedRole = getBASession(player)?.team?.getRoleForPlayer(slotPlayer)?.toString()?.lowercase()?.replaceFirstChar { it.uppercase() }?: AcceptRole.defaultText
|
||||
val wave = getBAWave(slotPlayer)
|
||||
setInterfaceText(player, slotPlayer.name.capitalizeWords(), AcceptRole.ID, uiSlot.name )
|
||||
setInterfaceText(player, formattedRole, AcceptRole.ID, uiSlot.role )
|
||||
setInterfaceText(player, wave.toString(), AcceptRole.ID, uiSlot.wave )
|
||||
|
|
@ -57,8 +57,8 @@ class AcceptRoleInterface : ComponentPlugin() {
|
|||
}
|
||||
}
|
||||
}
|
||||
private fun handleAccept(player: Player?) {
|
||||
val team = player?.baSession?.team
|
||||
private fun handleAccept(player: Player) {
|
||||
val team = getBASession(player)?.team
|
||||
val recruit = team?.recruit
|
||||
if (!recruit?.accept!!) {
|
||||
sendMessage(player,"The other player hasn't confirmed their role yet.")
|
||||
|
|
@ -84,7 +84,7 @@ class AcceptRoleInterface : ComponentPlugin() {
|
|||
}**/
|
||||
}
|
||||
private fun handleRemove(player: Player, slotIndex: Int){
|
||||
val team = player.baSession?.team
|
||||
val team = getBASession(player)?.team
|
||||
val follower = team?.getSlot(slotIndex)?.player ?: return
|
||||
val uiSlot = AcceptRole.team[slotIndex]
|
||||
|
||||
|
|
@ -97,8 +97,8 @@ class AcceptRoleInterface : ComponentPlugin() {
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun updateRecruitData(player: Player?){
|
||||
val team = player?.baSession?.team
|
||||
fun updateRecruitData(player: Player){
|
||||
val team = getBASession(player)?.team
|
||||
val leader = team?.getLeader()?.player ?: return
|
||||
val recruit = team.recruit
|
||||
val displayName = recruit?.role?.name?.lowercase()?.replaceFirstChar { it.uppercase() } ?: "Unknown"
|
||||
|
|
@ -106,8 +106,8 @@ class AcceptRoleInterface : ComponentPlugin() {
|
|||
setInterfaceText(leader, displayName, AcceptRole.ID,AcceptRole.Status.selectedRole )
|
||||
setInterfaceText(leader, level.toString(), AcceptRole.ID,AcceptRole.Status.levelRole )
|
||||
}
|
||||
fun resetWaitingStatus(player: Player?){
|
||||
val leader = player?.baSession?.team?.getLeader()?.player
|
||||
fun resetWaitingStatus(player: Player){
|
||||
val leader = getBASession(player)?.team?.getLeader()?.player
|
||||
setInterfaceText(leader!!, AcceptRole.waiting, AcceptRole.ID,AcceptRole.Status.selectedRole )
|
||||
setInterfaceText(leader, AcceptRole.waiting, AcceptRole.ID,AcceptRole.Status.levelRole )
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ package content.minigame.barbassault.lobby
|
|||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.BarbassaultState
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBarbWave
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.getBAWave
|
||||
import content.minigame.barbassault.lobby.BarbTeamManager.abandonTeam
|
||||
import content.minigame.barbassault.lobby.BarbTeamManager.createTeam
|
||||
import content.minigame.barbassault.lobby.BarbTeamManager.disbandTeam
|
||||
import content.minigame.barbassault.lobby.BarbassQuickWaveActivity.Companion.addToQueue
|
||||
import content.minigame.barbassault.setBarbWave
|
||||
import content.minigame.barbassault.setBASession
|
||||
import content.minigame.barbassault.setBAWave
|
||||
import core.api.*
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InteractionListener
|
||||
|
|
@ -27,7 +28,7 @@ import org.rs09.consts.Sounds
|
|||
//"-- Next wave no longer starting"
|
||||
// The game ended early because one of your team-mated died.
|
||||
//private var activity: BarbassaultActivity? = null
|
||||
class BarbassaultLobby : InteractionListener, MapArea {
|
||||
class BALobby : InteractionListener, MapArea {
|
||||
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> {
|
||||
return areaBorders
|
||||
|
|
@ -89,7 +90,7 @@ class BarbassaultLobby : InteractionListener, MapArea {
|
|||
override fun defineListeners() {
|
||||
onUseWithPlayer(Items.SCROLL_10512) { leader, _, node ->
|
||||
val follower = node.asPlayer()
|
||||
val session = leader.baSession
|
||||
val session = getBASession(leader)
|
||||
val team = session?.team
|
||||
|
||||
if (team == null) {
|
||||
|
|
@ -97,10 +98,10 @@ class BarbassaultLobby : InteractionListener, MapArea {
|
|||
return@onUseWithPlayer false
|
||||
}
|
||||
|
||||
follower.baSession?.let { return@onUseWithPlayer false } // already on a team
|
||||
getBASession(follower)?.let { return@onUseWithPlayer false } // already on a team
|
||||
|
||||
team.recruit = PendingRecruit(follower)
|
||||
follower.baSession = session
|
||||
setBASession(follower, session)
|
||||
//leader.sendMessage(team.recruit?.player?.username ?: "null")
|
||||
// joinTeam(follower,BarbRole.DEFENDER)
|
||||
|
||||
|
|
@ -124,7 +125,7 @@ class BarbassaultLobby : InteractionListener, MapArea {
|
|||
return@on true
|
||||
}
|
||||
on(Items.SCROLL_10512, IntType.ITEM, "Clear") { player, _ ->
|
||||
val session = player.baSession
|
||||
val session = getBASession(player)
|
||||
val team = session?.team
|
||||
if (team != null) {
|
||||
disbandTeam(session)
|
||||
|
|
@ -150,7 +151,7 @@ class BarbassaultLobby : InteractionListener, MapArea {
|
|||
}
|
||||
|
||||
on(Scenery.LADDER_20193, IntType.SCENERY, "Climb-down") { player, _ ->
|
||||
val session = player.baSession ?: run {
|
||||
val session = getBASession(player) ?: run {
|
||||
player.sendMessage("You are not in a session!")
|
||||
return@on true
|
||||
}
|
||||
|
|
@ -168,7 +169,8 @@ class BarbassaultLobby : InteractionListener, MapArea {
|
|||
if (!capeCheck(player)) { return@on false }
|
||||
//todo Not allowed to enter QuickStart with Scroll
|
||||
if (!QUICK_START.insideBorder(player.location)){
|
||||
player.setBarbWave(1)
|
||||
//todo warning message you are about to reset your wave
|
||||
setBAWave(player,1)
|
||||
handlePlayerOptionDoor(player) { role ->
|
||||
//player.sendMessage("You are a ${role.name.lowercase().replaceFirstChar { it.uppercase() }}.")
|
||||
handleWaveDoor(player, node, 489)
|
||||
|
|
@ -257,9 +259,9 @@ class BarbassaultLobby : InteractionListener, MapArea {
|
|||
if (buttonId == 6) return
|
||||
val playerRole = getRoleFromButton(buttonId) ?: return
|
||||
|
||||
if (player.baSession == null) {createTeam(player)}
|
||||
if (getBASession(player) == null) {createTeam(player)}
|
||||
|
||||
val team = player.baSession?.team ?: return
|
||||
val team = getBASession(player)?.team ?: return
|
||||
team.setRoleForPlayer(player, playerRole)
|
||||
BarbTeamManager.updateTeam(team)
|
||||
sendMessage(player, "You've set your role to ${playerRole.name.lowercase().replaceFirstChar { it.uppercase() }}")
|
||||
|
|
@ -302,7 +304,7 @@ class BarbassaultLobby : InteractionListener, MapArea {
|
|||
fun handleWaveDoor(player: Player, node: Node,iface: Int){
|
||||
val doorLoc = node.location
|
||||
val playerLoc = player.location
|
||||
var wave = player.getBarbWave()
|
||||
var wave = getBAWave(player)
|
||||
if (wave == BARBWAVEDOOR[node.id]) {
|
||||
val insideRoom = playerLoc.y <= doorLoc.y
|
||||
val moveY = if (insideRoom) 1 else -1
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
package content.minigame.barbassault.lobby
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.lobby.BarbTeamManager.createTeam
|
||||
import content.minigame.barbassault.setBASession
|
||||
import core.api.*
|
||||
import core.game.activity.ActivityManager
|
||||
import core.game.activity.ActivityPlugin
|
||||
|
|
@ -102,13 +103,13 @@ open class BarbassQuickWaveActivity : ActivityPlugin("BarbassQuickWave",false, f
|
|||
if (createTeam(teamLeader)){
|
||||
players.forEach { removeQuickQue(it.player) }
|
||||
|
||||
val session = teamLeader.baSession
|
||||
val session = getBASession(teamLeader)
|
||||
val team = session?.team ?: return
|
||||
|
||||
players.forEachIndexed { index, wrapper ->
|
||||
wrapper.let { playerWrapper ->
|
||||
if (wrapper.player != teamLeader) {
|
||||
playerWrapper.player.baSession = session
|
||||
setBASession(playerWrapper.player,session)
|
||||
team.addPlayer(playerWrapper.player)
|
||||
}
|
||||
playerWrapper.role?.let { role ->
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
package content.minigame.barbassault.lobby
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.BarbassaultActivity
|
||||
import content.minigame.barbassault.BAActivity
|
||||
import content.minigame.barbassault.arena.BarbassaultSession
|
||||
import content.minigame.barbassault.arena.BarbassaultState
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBarbLevels
|
||||
import content.minigame.barbassault.getBarbWave
|
||||
import content.minigame.barbassault.getBALevels
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.getBAWave
|
||||
import content.minigame.barbassault.setBASession
|
||||
import core.api.sendMessage
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.world.map.Location
|
||||
|
|
@ -14,10 +15,10 @@ import core.game.world.map.Location
|
|||
data class PartySlot( val index: Int, val player: Player, var role: BarbRole? = null )
|
||||
data class PendingRecruit( var player: Player, var role: BarbRole? = null,var accept:Boolean = false ) {
|
||||
fun roleLevel(): Int = when (role) {
|
||||
BarbRole.ATTACKER -> player.getBarbLevels().atk
|
||||
BarbRole.COLLECTOR -> player.getBarbLevels().col
|
||||
BarbRole.DEFENDER -> player.getBarbLevels().def
|
||||
BarbRole.HEALER -> player.getBarbLevels().heal
|
||||
BarbRole.ATTACKER -> getBALevels(player).atk
|
||||
BarbRole.COLLECTOR -> getBALevels(player).col
|
||||
BarbRole.DEFENDER -> getBALevels(player).def
|
||||
BarbRole.HEALER -> getBALevels(player).heal
|
||||
null -> 1
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +36,7 @@ class BarbTeam(val session: BarbassaultSession, leader: Player) {
|
|||
|
||||
init {
|
||||
slots[LEADER_SLOT] = PartySlot(LEADER_SLOT, leader)
|
||||
wave = leader.getBarbWave()!!
|
||||
wave = getBAWave(leader)!!
|
||||
}
|
||||
|
||||
fun slotOf(player: Player): Int =
|
||||
|
|
@ -130,7 +131,7 @@ data class RoleCounts(val att: Int, val def: Int, val coll: Int, val heal: Int )
|
|||
object BarbTeamManager {
|
||||
|
||||
fun createTeam(leader: Player): Boolean {
|
||||
val session = BarbassaultActivity.createSession(leader)
|
||||
val session = BAActivity.createSession(leader)
|
||||
// if (session.team != null) return false
|
||||
|
||||
val team = BarbTeam(session, leader)
|
||||
|
|
@ -157,7 +158,7 @@ object BarbTeamManager {
|
|||
}
|
||||
|
||||
fun joinTeam(player: Player, role: BarbRole): Boolean {
|
||||
val session = player.baSession ?: return false
|
||||
val session = getBASession(player) ?: return false
|
||||
val team = session.team
|
||||
team.recruit = null
|
||||
if (!team.addPlayer(player)) {
|
||||
|
|
@ -174,14 +175,14 @@ object BarbTeamManager {
|
|||
}
|
||||
|
||||
fun abandonTeam(player: Player) {
|
||||
val session = player.baSession ?: return
|
||||
val session = getBASession(player) ?: return
|
||||
val team = session.team
|
||||
if (team.isLeader(player)) {
|
||||
disbandTeam(session)
|
||||
return
|
||||
}
|
||||
team.removePlayer(player)
|
||||
player.baSession = null
|
||||
setBASession(player,null)
|
||||
updateCurrentTeam(player)
|
||||
updateTeam(team)
|
||||
//session.cancleStartingPhase()
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package content.minigame.barbassault.lobby
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.lobby.CurrentTeam.ROLE_MODEL_MAP
|
||||
import content.minigame.barbassault.lobby.CurrentTeam.modelZoom
|
||||
import core.api.setInterfaceModel
|
||||
|
|
@ -37,7 +37,7 @@ class CurrentTeamInterface : ComponentPlugin() {
|
|||
}
|
||||
}
|
||||
fun updateCurrentTeam(player: Player) {
|
||||
val team = player.baSession?.team
|
||||
val team = getBASession(player)?.team
|
||||
|
||||
for (slotIndex in 0 until BarbTeam.MAX_SLOTS) {
|
||||
val uiSlot = CurrentTeam.team[slotIndex]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package content.minigame.barbassault.lobby
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.baSession
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.setBASession
|
||||
import core.api.*
|
||||
import core.game.component.Component
|
||||
import core.game.component.ComponentDefinition
|
||||
|
|
@ -16,7 +17,7 @@ class RoleSelectInterface : ComponentPlugin() {
|
|||
super.open(player, component)
|
||||
var isopen = true
|
||||
player ?: return
|
||||
val team = player.baSession?.team;
|
||||
val team = getBASession(player)?.team;
|
||||
if (team != null) { team.updateRoleAvailabilityFor(player) }
|
||||
|
||||
component?.setCloseEvent { player, c ->
|
||||
|
|
@ -26,13 +27,13 @@ class RoleSelectInterface : ComponentPlugin() {
|
|||
isopen = false
|
||||
closeInterface(leader)
|
||||
//if team.recruit not on team, team.recruit?.player?.baSession = null
|
||||
team.recruit?.player?.baSession = null
|
||||
setBASession(team.recruit!!.player,null)
|
||||
team.recruit = null
|
||||
}
|
||||
return@setCloseEvent true
|
||||
}
|
||||
|
||||
val leaderData = player.baSession?.team?.getLeader() ?: run {
|
||||
val leaderData = getBASession(player)?.team?.getLeader() ?: run {
|
||||
player.sendMessage("No leader found for your team.")
|
||||
return
|
||||
}
|
||||
|
|
@ -49,7 +50,7 @@ class RoleSelectInterface : ComponentPlugin() {
|
|||
|
||||
override fun handle(player: Player?, component: Component?, opcode: Int, button: Int, slot: Int, itemId: Int): Boolean {
|
||||
if (player == null) return true
|
||||
val team = player.baSession?.team;
|
||||
val team = getBASession(player)?.team;
|
||||
val pending = team?.recruit ?: return true
|
||||
var waitingSelected: BarbRole? = null
|
||||
|
||||
|
|
@ -121,7 +122,7 @@ private fun handleAccept(player: Player){
|
|||
return
|
||||
}
|
||||
private fun handleDecline(player: Player) {
|
||||
val leader = player.baSession?.team?.getLeader()?.player
|
||||
val leader = getBASession(player)?.team?.getLeader()?.player
|
||||
sendMessage(leader!!, "The applicant declined your offer.")
|
||||
closeInterface(player)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue