diff --git a/Server/src/main/content/minigame/barbassault/arena/BarbassEvent.kt b/Server/src/main/content/minigame/barbassault/arena/BarbassEvent.kt index 8689376cb..b07d0223a 100644 --- a/Server/src/main/content/minigame/barbassault/arena/BarbassEvent.kt +++ b/Server/src/main/content/minigame/barbassault/arena/BarbassEvent.kt @@ -8,6 +8,9 @@ sealed class BarbAssEvent { data class EggCollected(val player: Player, val count: Int) : BarbAssEvent() data class HitpointsHealed(val player: Player, val amount: Int) : BarbAssEvent() data class WrongPoisonUsed(val player: Player) : BarbAssEvent() + data class WrongAttack(val self: NPC, val attacker: Player) : BarbAssEvent() { + + } } class BarbAssEventBus { 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 2e5152b15..f95d520fb 100644 --- a/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceFighterNPC.kt +++ b/Server/src/main/content/minigame/barbassault/arena/monsters/PenanceFighterNPC.kt @@ -3,12 +3,13 @@ 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.BarbassaultSession import content.minigame.barbassault.lobby.baSession import core.api.* -import core.game.container.impl.EquipmentContainer 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.combat.ImpactHandler import core.game.node.entity.npc.NPC import core.game.node.entity.npc.NPCBehavior import core.game.node.entity.player.Player @@ -39,58 +40,56 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) { } 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 attackStyle = attacker.properties.attackStyle.style val combatType = state.style - when (combatType) { - CombatStyle.MELEE -> { - when (attackStyle) { - 0 -> sendMessage(attacker, "Melee: Accurate") - 1 -> sendMessage(attacker, "Melee: Aggressive") - 2 -> sendMessage(attacker, "Melee: Controlled") - 3 -> sendMessage(attacker, "Melee: Defensive") - else -> { - toDamage = 0 - sendMessage(attacker, "Melee: Unknown 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 -> { - val arrows = attacker.equipment.get(EquipmentContainer.SLOT_ARROWS).name - sendMessage(attacker, "Ranged attack, Arrows: $arrows") - - val ammunitionID = state.ammunition.itemId - when(ammunitionID){ - 882 -> "bronze" - 884 -> "iron" - 886 -> "steel" - 888 -> "mithril" - else -> { - toDamage = 0 - sendMessage(attacker,"Only allowed to use provided arrows.")} + 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 -> { - val castSpell = state.spell.spellId - when(castSpell){ - 1,10,24,45 -> sendMessage(attacker, "Magic spell: Air") - 4,14,27,48 -> sendMessage(attacker, "Magic spell: Water") - 6,17,66,52 -> sendMessage(attacker, "Magic spell: Earth") - 8,20,38,55 -> sendMessage(attacker, "Magic spell: Fire") - else -> { - toDamage = 0 - } + 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 } override fun onCreation (self: NPC) {