diff --git a/Server/src/main/content/minigame/barbassault/BarbassaultListeners.kt b/Server/src/main/content/minigame/barbassault/BarbassaultListeners.kt index a375e9fa5..db4c25f49 100644 --- a/Server/src/main/content/minigame/barbassault/BarbassaultListeners.kt +++ b/Server/src/main/content/minigame/barbassault/BarbassaultListeners.kt @@ -18,35 +18,38 @@ const val BARBASSAULT_ACCEPT_ROLE_492 = 492 const val BARBASSAULT_SELECT_ROLE_493 = 493 class BarbassaultListeners : InteractionListener { - //CommandSet(Privilege.ADMIN) override fun defineListeners() { on(Scenery.LADDER_20226, IntType.SCENERY, "Climb-down") { player, _ -> // if (GameWorld.settings?.enable_barbassault != true) return@on false + //todo players are allowed to wear capes in to the lobby, But not the Wave Rooms + //todo No summonings in lobby if (joinError(player)) return@on true val loc = Location(2593 , 5261 ) - teleport(player, loc) // find ladder code latter + teleport(player, loc) + //todo ladder code or add climb down animation. return@on true } on(Scenery.LADDER_20227, IntType.SCENERY, "Climb-up") { player, _ -> - //Remove Roster/scroll + //todo remove BarbassItems IE: Scroll val loc = Location(2535 , 3572 ) player.inventory.removeAll(Items.SCROLL_10512) teleport(player, loc) // find ladder code latter + //todo ladder code or climb up animation return@on true } on(Scenery.BLACKBOARD_20134, IntType.SCENERY, "Read") { player, _ -> //emote 5354 - //Remove Roster/scroll - // openOverlay(player, Components.BARBASSAULT_PLAYERSTAT_490) + //todo Are we suppose to animate while reading? updateBlackBoard(player) return@on true } on(NPCs.COMMANDER_CONNAD_5029, IntType.NPC, "Get-rewards") { player, _ -> + //todo remove this varbit? I think I was testing. setVarbit(player, 3256, 200) player.interfaceManager.open(Component(Components.BARBASSAULT_REWARD_SHOP_491)) return@on true @@ -57,13 +60,12 @@ class BarbassaultListeners : InteractionListener { return@on true } - } private fun capeCheck(player: Player): String? { val wornCape = getItemFromEquipment(player, EquipmentSlot.CAPE)?.id ?: -1 - - if (wornCape != -1) return "No CAPES!!!" // find correct message + if (wornCape != -1) return "Capes are not permitted." + //todo find authentic "no capes allowed" message return null } private fun forbiddenItemsCheck(player: Player): String? { @@ -84,6 +86,7 @@ class BarbassaultListeners : InteractionListener { Items.STEAM_RUNE_4694, Items.SOUL_RUNE_566, Items.NATURE_RUNE_561 + //todo extend not allowed items list. //add food //add ammo //summoning pouches diff --git a/Server/src/main/content/minigame/barbassault/arena/BaHornSystem.kt b/Server/src/main/content/minigame/barbassault/arena/BaHornSystem.kt index 930983898..21290889c 100644 --- a/Server/src/main/content/minigame/barbassault/arena/BaHornSystem.kt +++ b/Server/src/main/content/minigame/barbassault/arena/BaHornSystem.kt @@ -129,6 +129,7 @@ class BaHornSystem : InteractionListener { object HornHelper { //I should set a value in my players session instead of scanning the inventory every time for a horn. + //multiple horn IDs suggest retail would use a gearSet check to apply a damage modifier. fun getAttackerHorn(player: Player): AttackerHorn? = AttackerHorn.values().firstOrNull { inInventory(player, it.itemId) } fun getHealerHorn(player: Player): HealerHorn? = HealerHorn.values().firstOrNull { inInventory(player, it.itemId) } fun getCollectorBag(player: Player): CollectionBag? = CollectionBag.values().firstOrNull { inInventory(player, it.itemId) } diff --git a/Server/src/main/content/minigame/barbassault/arena/BarbassaultGameArea.kt b/Server/src/main/content/minigame/barbassault/arena/BarbassaultGameArea.kt index 5e0dc6052..a25ec3dab 100644 --- a/Server/src/main/content/minigame/barbassault/arena/BarbassaultGameArea.kt +++ b/Server/src/main/content/minigame/barbassault/arena/BarbassaultGameArea.kt @@ -1,5 +1,6 @@ package content.minigame.barbassault.arena +import content.minigame.barbassault.BarbRole import content.minigame.barbassault.BarbassaultTut import content.minigame.barbassault.CaptainCainDialogue.Companion.TORSO_PRICE import content.minigame.barbassault.arena.BaHornSystem.HornHelper.getHealerHorn @@ -11,12 +12,16 @@ import content.minigame.barbassault.getBarbLevels import content.minigame.barbassault.lobby.baSession import core.api.* import core.game.component.Component +import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle import core.game.interaction.IntType import core.game.interaction.InteractionListener import core.game.interaction.QueueStrength import core.game.node.Node import core.game.node.entity.Entity +import core.game.node.entity.combat.BattleState +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.entity.player.info.LogType import core.game.node.entity.player.info.PlayerMonitor @@ -341,6 +346,7 @@ fun exitMiniGame(player: Player) { Items.POISONED_WORMS_10540,Items.POISONED_TOFU_10539,Items.POISONED_MEAT_10541, ) // removeAll(player, barbassItems) + // region.clean //todo should probably make sure familiars can't smuggle items out //(player.familiarManager.familiar as? BurdenBeast)?.container?.removeAll(barbassItems)//just in case someone smuggles a pet in. @@ -348,6 +354,55 @@ fun exitMiniGame(player: Player) { //or lost game Send back to wave room } +object BarbAssaultCombat { + fun resolveAttackerStyle( attacker: Player, state: BattleState ): AttackerStyle? { + return when (state.style) { + CombatStyle.MELEE -> when (attacker.properties.attackStyle.style) { + 2 -> AttackerStyle.STYLE_1 // Controlled + 0 -> AttackerStyle.STYLE_2 // Accurate + 1 -> AttackerStyle.STYLE_3 // Aggressive + 3 -> AttackerStyle.STYLE_4 // Defensive + else -> null + } + CombatStyle.RANGE -> when (state.ammunition.itemId) { + 882 -> AttackerStyle.STYLE_1 // bronze + 884 -> AttackerStyle.STYLE_2 // iron + 886 -> AttackerStyle.STYLE_3 // steel + 888 -> AttackerStyle.STYLE_4 // mithril + else -> null + } + CombatStyle.MAGIC -> when (state.spell.spellId) { + 1, 10, 24, 45 -> AttackerStyle.STYLE_1 // Air + 4, 14, 27, 48 -> AttackerStyle.STYLE_2 // Water + 6, 17, 66, 52 -> AttackerStyle.STYLE_3 // Earth + 8, 20, 38, 55 -> AttackerStyle.STYLE_4 // Fire + else -> null + } + else -> null + } + } + + fun applyAttackValidation( self: NPC, attacker: Player, state: BattleState ): Int { + val session = attacker.baSession ?: 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 damage = state.estimatedHit + hornBonus + val usedStyle = resolveAttackerStyle(attacker, state) + + if (usedStyle == null) { sendMessage(attacker, "That attack is not allowed."); return 0 } + + if (usedStyle != currentCall) { + sendMessage(attacker, "Wrong attack style!") + impact(attacker, 1) + session.eventBus.emit(BarbAssEvent.WrongAttack(self, attacker)) + return 0 + } + return damage + } +} + diff --git a/Server/src/main/content/minigame/barbassault/arena/BarbassaultSession.kt b/Server/src/main/content/minigame/barbassault/arena/BarbassaultSession.kt index 73e6cfccd..9062b8376 100644 --- a/Server/src/main/content/minigame/barbassault/arena/BarbassaultSession.kt +++ b/Server/src/main/content/minigame/barbassault/arena/BarbassaultSession.kt @@ -28,19 +28,6 @@ import org.rs09.consts.Items import org.rs09.consts.Music.ASSAULT_AND_BATTERY_604 import org.rs09.consts.NPCs -/* -Player -└─ attribute "baSession" : BarbassaultSession? - ├─ state : BarbassaultState (STARTING, IN_ARENA, END) - ├─ arena : DynamicRegion / MapArea - ├─ lifecycle : start → play → end - └─ team : BarbTeam? - ├─ leader : Player - ├─ slots : List - └─ recruit : PendingRecruit? - └─ player : Player - └─ role : BarbRole? -*/ enum class BarbassaultState { PARTY_CREATION, STARTING, IN_ARENA,FORFEIT, COMPLETE, END } diff --git a/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceFighterNPC.kt b/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceFighterNPC.kt index f95d520fb..e0ea33ca4 100644 --- a/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceFighterNPC.kt +++ b/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceFighterNPC.kt @@ -3,6 +3,7 @@ package content.minigame.barbassault.arenas.monsters import content.minigame.barbassault.BarbRole import content.minigame.barbassault.arena.BaHornSystem import content.minigame.barbassault.arena.BarbAssEvent +import content.minigame.barbassault.arena.BarbAssaultCombat import content.minigame.barbassault.arena.BarbassaultSession import content.minigame.barbassault.lobby.baSession import core.api.* @@ -38,62 +39,13 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) { override fun getXpMultiplier(self: NPC, attacker: Entity): Double { return 0.0 } - override fun beforeDamageReceived(self: NPC, attacker: Entity, state: BattleState) { + override fun beforeDamageReceived( self: NPC, attacker: Entity, state: BattleState) { attacker as Player - val currentCall = attacker.baSession?.roleCalls?.get(BarbRole.COLLECTOR)?.toCall //STYLE_1 to STYLE_4 - - val firstBefore = state.estimatedHit - //I should read my players level instead of scanning the inventory every time for a horn. - var toDamage = firstBefore + (BaHornSystem.HornHelper.getAttackerHorn(attacker)?.ordinal?.plus(1) ?: 0) +1 - //if wrong attack recoil 1 damage to player. - val combatType = state.style - val usedStyle: Comparable<*>? = when (combatType) { - - CombatStyle.MELEE -> { - when (attacker.properties.attackStyle.style) { - 2 -> BarbassaultSession.AttackerStyle.STYLE_1 // Controlled - 0 -> BarbassaultSession.AttackerStyle.STYLE_2 // Accurate - 1 -> BarbassaultSession.AttackerStyle.STYLE_3 // Aggressive - 3 -> BarbassaultSession.AttackerStyle.STYLE_4 // Defensive - else -> null - } - } - - CombatStyle.RANGE -> { - when (state.ammunition.itemId) { - 882 -> BarbassaultSession.AttackerStyle.STYLE_1 // bronze - 884 -> BarbassaultSession.AttackerStyle.STYLE_2 // iron - 886 -> BarbassaultSession.AttackerStyle.STYLE_3 // steel - 888 -> BarbassaultSession.AttackerStyle.STYLE_4 // mithril - else -> null - } - } - - CombatStyle.MAGIC -> { - when (state.spell.spellId) { - 1, 10, 24, 45 -> BarbassaultSession.AttackerStyle.STYLE_1 // Air - 4, 14, 27, 48 -> BarbassaultSession.AttackerStyle.STYLE_2 // Water - 6, 17, 66, 52 -> BarbassaultSession.AttackerStyle.STYLE_3 // Earth - 8, 20, 38, 55 -> BarbassaultSession.AttackerStyle.STYLE_4 // Fire - else -> null - } - } - else -> null - } - - if (usedStyle == null) {sendMessage(attacker, "That attack is not allowed.")} - - if (usedStyle != currentCall) { - sendMessage(attacker, "Wrong attack style!"); toDamage = 0; - impact(attacker,1) - attacker.baSession?.eventBus?.emit(BarbAssEvent.WrongAttack(self,attacker)) - } - - - state.estimatedHit = toDamage + state.estimatedHit = BarbAssaultCombat.applyAttackValidation( self, attacker, state ) } + override fun onCreation (self: NPC) { - self.setAttribute("agg_radius",2) + self.setAttribute("agg_radius",6) self.isWalks = true self.isNeverWalks = false self.walkRadius = 64 diff --git a/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceRangerNPC.kt b/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceRangerNPC.kt index b7df12f1c..dd581cf46 100644 --- a/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceRangerNPC.kt +++ b/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceRangerNPC.kt @@ -2,14 +2,17 @@ package content.minigame.barbassault.arena.monsters import content.minigame.barbassault.BarbRole import content.minigame.barbassault.arena.BarbAssEvent +import content.minigame.barbassault.arena.BarbAssaultCombat import content.minigame.barbassault.lobby.baSession import core.api.* import core.api.getItemFromEquipment import core.game.node.entity.Entity +import core.game.node.entity.combat.BattleState 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.world.update.flag.context.Graphics import org.rs09.consts.NPCs //20730 = rangers cast val PENANCE_RANGER_IDS = listOf( @@ -27,22 +30,27 @@ val PENANCE_RANGER_IDS = listOf( class PenanceRangerNPC : NPCBehavior(*PENANCE_RANGER_IDS.toIntArray()) { override fun canBeAttackedBy(self: NPC, attacker: Entity, style: CombatStyle, shouldSendMessage: Boolean): Boolean { if (attacker is Player && getItemFromEquipment(attacker, EquipmentSlot.CAPE)?.id != 10556) { + //todo make list of not allowed weapons to attack IE: Crystal bow, Karils Crossbow sendMessage(attacker, "These Penance are immune to your attacks.") return false } return true } + override fun beforeDamageReceived( self: NPC, attacker: Entity, state: BattleState) { + attacker as Player + state.estimatedHit = BarbAssaultCombat.applyAttackValidation( self, attacker, state ) + } override fun getXpMultiplier(self: NPC, attacker: Entity): Double { return 0.0 } override fun onCreation (self: NPC) { - self.setAttribute("agg_radius",2) + self.setAttribute("agg_radius",6) self.isWalks = true self.isNeverWalks = false self.walkRadius = 64 self.isAggressive = true - + self.definition.combatGraphics[1] = Graphics(866, 25, 0) self.setAttribute("barbass-role",BarbRole.ATTACKER) self.definition.combatDistance = 8