mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-21 18:35:11 -06:00
Horn of Glory Acttualy works now
This commit is contained in:
parent
2cea22e8d1
commit
f6936ab2dc
3 changed files with 38 additions and 26 deletions
|
|
@ -16,10 +16,8 @@ import core.api.*
|
|||
import core.game.global.action.ClimbActionHandler
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.interaction.InteractionListeners
|
||||
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
|
||||
|
|
@ -34,7 +32,6 @@ import core.game.world.map.Direction
|
|||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import org.rs09.consts.Animations
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
fun updateRoleUI() {
|
||||
team.allPlayers().forEach { player ->
|
||||
val wave = team.wave.toString()
|
||||
val role = team.getRoleForPlayer(player) ?: return@forEach
|
||||
val role = team.getRoleForPlayer(player)
|
||||
val call = roleCalls[role] ?: return@forEach
|
||||
|
||||
|
||||
|
|
@ -521,19 +521,38 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
private val hornTargets = mapOf( BarbRole.COLLECTOR to BarbRole.ATTACKER, BarbRole.ATTACKER to BarbRole.COLLECTOR ,
|
||||
BarbRole.HEALER to BarbRole.DEFENDER, BarbRole.DEFENDER to BarbRole.HEALER )
|
||||
|
||||
fun onHornCall(player: Player, calledValue: Any) {
|
||||
val callerRole = team.getRoleForPlayer(player) ?: return
|
||||
val targetRole = hornTargets[callerRole] ?: return
|
||||
val call = roleCalls[targetRole] ?: return
|
||||
|
||||
private fun dispatchCall(call: Any, calledValue: Any) {
|
||||
when (call) {
|
||||
is AttackerCall -> if (calledValue is AttackerStyle) call.call(calledValue)
|
||||
is HealerCall -> if (calledValue is PoisonFood) call.call(calledValue)
|
||||
is DefenderCall -> if (calledValue is LureFood) call.call(calledValue)
|
||||
is CollectorCall -> if (calledValue is EggColor) call.call(calledValue)
|
||||
}
|
||||
}
|
||||
|
||||
fun onHornCall(player: Player, calledValue: Any) {
|
||||
val callerRole = team.getRoleForPlayer(player)
|
||||
val targetRole = hornTargets[callerRole] ?: return
|
||||
val call = roleCalls[targetRole] ?: return
|
||||
|
||||
dispatchCall(call,calledValue)
|
||||
updateRoleUI()
|
||||
}
|
||||
|
||||
fun onHornGloryCall(calledValue: Any) {
|
||||
val targetRole = when (calledValue) {
|
||||
is AttackerStyle -> BarbRole.ATTACKER
|
||||
is PoisonFood -> BarbRole.HEALER
|
||||
is LureFood -> BarbRole.DEFENDER
|
||||
is EggColor -> BarbRole.COLLECTOR
|
||||
else -> return
|
||||
}
|
||||
|
||||
val call = roleCalls[targetRole] ?: return
|
||||
dispatchCall(call,calledValue)
|
||||
updateRoleUI()
|
||||
}
|
||||
|
||||
fun onAttackerHit(style: AttackerStyle) {
|
||||
val call = roleCalls[BarbRole.ATTACKER] as? AttackerCall ?: return
|
||||
call.check(style)
|
||||
|
|
|
|||
|
|
@ -20,23 +20,20 @@ import org.rs09.consts.Scenery
|
|||
@Initializable
|
||||
class HornOfGlory : ComponentPlugin() , InteractionListener {
|
||||
var hornCallLock = false
|
||||
val CallMap = mapOf(
|
||||
private val CallMap = mapOf(
|
||||
GloryHorn.CONTROLED_BRONZE_WIND to (BarbassaultSession.AttackerStyle.STYLE_1 to BaCall.ATTACKER_STYLE_1),
|
||||
GloryHorn.ACCURATE_IRON_WATER to (BarbassaultSession.AttackerStyle.STYLE_2 to BaCall.ATTACKER_STYLE_2),
|
||||
GloryHorn.AGGRISSIVE_STEEL_EARTH to (BarbassaultSession.AttackerStyle.STYLE_3 to BaCall.ATTACKER_STYLE_3),
|
||||
GloryHorn.DEFENSIVE_MITHRIL_FIRE to (BarbassaultSession.AttackerStyle.STYLE_4 to BaCall.ATTACKER_STYLE_4),
|
||||
|
||||
GloryHorn.POISON_TOFU to ("Poison tofu" to BaCall.HEALER_TOFU),
|
||||
GloryHorn.POISON_WORMS to ("Poison worms" to BaCall.HEALER_WORMS),
|
||||
GloryHorn.POISON_MEAT to ("Poison meat" to BaCall.HEALER_MEAT),
|
||||
|
||||
GloryHorn.RED_EGG to ("Red egg" to BaCall.COLLECTOR_RED),
|
||||
GloryHorn.GREEN_EGG to ("Green egg" to BaCall.COLLECTOR_GREEN),
|
||||
GloryHorn.BLUE_EGG to ("Blue egg" to BaCall.COLLECTOR_BLUE),
|
||||
|
||||
GloryHorn.FOOD_TOFU to (BarbassaultSession.LureFood.TOFU to BaCall.DEFENDER_TOFU),
|
||||
GloryHorn.POISON_TOFU to (BarbassaultSession.PoisonFood.TOFU to BaCall.HEALER_TOFU),
|
||||
GloryHorn.POISON_WORMS to (BarbassaultSession.PoisonFood.WORMS to BaCall.HEALER_WORMS),
|
||||
GloryHorn.POISON_MEAT to (BarbassaultSession.PoisonFood.MEAT to BaCall.HEALER_MEAT),
|
||||
GloryHorn.RED_EGG to (BarbassaultSession.EggColor.RED to BaCall.COLLECTOR_RED),
|
||||
GloryHorn.GREEN_EGG to (BarbassaultSession.EggColor.GREEN to BaCall.COLLECTOR_GREEN),
|
||||
GloryHorn.BLUE_EGG to (BarbassaultSession.EggColor.BLUE to BaCall.COLLECTOR_BLUE),
|
||||
GloryHorn.FOOD_TOFU to (BarbassaultSession.LureFood.TOFU to BaCall.DEFENDER_TOFU),
|
||||
GloryHorn.FOOD_CRACKERS to (BarbassaultSession.LureFood.CRACKERS to BaCall.DEFENDER_CRACKERS),
|
||||
GloryHorn.FOOD_WORMS to (BarbassaultSession.LureFood.WORMS to BaCall.DEFENDER_WORMS),
|
||||
GloryHorn.FOOD_WORMS to (BarbassaultSession.LureFood.WORMS to BaCall.DEFENDER_WORMS)
|
||||
)
|
||||
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
|
|
@ -46,12 +43,11 @@ class HornOfGlory : ComponentPlugin() , InteractionListener {
|
|||
|
||||
override fun handle(player: Player?,component: Component?, opcode: Int, button: Int, slot: Int, itemId: Int ): Boolean {
|
||||
player ?: return true
|
||||
val pair = CallMap[button] ?: return true
|
||||
val role = pair.first
|
||||
val call = pair.second
|
||||
val (gameValue, uiCall) = CallMap[button] ?: return true
|
||||
|
||||
if(!hornCallLock) {
|
||||
getBASession(player)?.onHornCall(player, role)
|
||||
sendChat(player, call.text)
|
||||
getBASession(player)?.onHornGloryCall(gameValue)
|
||||
sendChat(player, uiCall.text)
|
||||
player.animate(Animation(5436))
|
||||
player.lock(6)
|
||||
hornCallLock = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue