mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-24 11:55:13 -06:00
Collector Eggs:
Check current call Handles eggs
This commit is contained in:
parent
7e06577110
commit
b361c2b2c1
4 changed files with 53 additions and 43 deletions
|
|
@ -1,8 +1,14 @@
|
|||
package content.minigame.barbassault.arena
|
||||
|
||||
|
||||
import content.minigame.barbassault.BAGraphics.BLUE_EGG_BREAK_875
|
||||
import content.minigame.barbassault.BAGraphics.GREEN_EGG_BREAK_873
|
||||
import content.minigame.barbassault.BAGraphics.RED_EGG_BREAK_874
|
||||
import content.minigame.barbassault.BAGraphics.RED_EGG_EXPLOSION_975
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.LureItems
|
||||
import content.minigame.barbassault.arena.BAHornSystem.HornHelper.getHealerHorn
|
||||
import content.minigame.barbassault.arena.BarbAssEvent.EggCollected
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon.Companion.loadEggHopper
|
||||
|
|
@ -13,7 +19,6 @@ 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
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.interaction.QueueStrength
|
||||
|
|
@ -24,9 +29,7 @@ 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
|
||||
import core.game.node.entity.player.info.login.PlayerParser
|
||||
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
|
||||
|
|
@ -34,6 +37,7 @@ import core.game.world.GameWorld.Pulser
|
|||
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.Items
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
|
|
@ -197,15 +201,33 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
on(EggCannon.ALL_EGGS, IntType.GROUNDITEM, "Take") { player, node ->
|
||||
if (node !is GroundItem) return@on true
|
||||
val session = getBASession(player) ?: return@on true
|
||||
if (session.team.getRoleForPlayer(player) != BarbRole.COLLECTOR) {
|
||||
//todo find correct message
|
||||
sendMessage(player,"not a collector")
|
||||
}
|
||||
session.pickUpGroundItem(player, node as BAGroundSpawn)
|
||||
//todo find correct message
|
||||
if (session.team.getRoleForPlayer(player) != BarbRole.COLLECTOR) { sendMessage(player,"not a collector") ; return@on false }
|
||||
|
||||
val currentCall = (session.roleCalls[BarbRole.COLLECTOR] as? BarbassaultSession.CollectorCall)?.required
|
||||
if (node.id != currentCall?.itemId()){
|
||||
handleWrongEgg(player,node)
|
||||
return@on false
|
||||
}
|
||||
val didPickUp = session.pickUpGroundItem(player, node as BAGroundSpawn)
|
||||
if (!didPickUp) { handleWrongEgg(player,node,false) }
|
||||
session.eventBus.emit(EggCollected(player,1))
|
||||
return@on true
|
||||
}
|
||||
}
|
||||
fun handleWrongEgg(player: Player, groundItem: GroundItem,point: Boolean = true){
|
||||
val session = getBASession(player) ?: return
|
||||
if (point) { session.eventBus.emit(EggCollected(player,-1)) }
|
||||
impact(player, 5)
|
||||
val gfx = when (groundItem.id) {
|
||||
Items.GREEN_EGG_10531 -> GREEN_EGG_BREAK_873
|
||||
Items.RED_EGG_10532 -> RED_EGG_BREAK_874
|
||||
Items.BLUE_EGG_10533 -> BLUE_EGG_BREAK_875
|
||||
else -> 874
|
||||
}
|
||||
Graphics(gfx)
|
||||
session.destroyGroundItem(groundItem as BAGroundSpawn)
|
||||
}
|
||||
|
||||
fun handleDropItem(player: Player, node: Node, flag: Boolean? = false): Boolean {
|
||||
val item = node as? Item ?: return false
|
||||
|
|
@ -266,29 +288,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
}
|
||||
}
|
||||
|
||||
fun exitMiniGame(player: Player) {
|
||||
// openOverlay(player,493) // work around to actually close interfaces.
|
||||
//player.interfaceManager.closeOverlay()//maybe im doing this wrong.
|
||||
removeTimer(player, "teleblock")
|
||||
|
||||
|
||||
val barbassItems = arrayListOf(
|
||||
|
||||
Items.WORMS_10515,Items.CRACKERS_10513,Items.TOFU_10514,Items.LOGS_11760,Items.LOGS_11760,Items.HAMMER_2347,Items.DEFENDER_HORN_10538, //Defender Inv Items
|
||||
Items.HEALING_VIAL_10546,Items.HEALING_VIAL1_10545,Items.HEALING_VIAL2_10544,Items.HEALING_VIAL3_10543,Items.HEALING_VIAL4_10542, //Healer Inv Items
|
||||
Items.HEALER_HORN_10526,Items.HEALER_HORN_10527,Items.HEALER_HORN_10528,Items.HEALER_HORN_10529,Items.HEALER_HORN_10530,
|
||||
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 even if they are "not" allowed to be summoned
|
||||
//(player.familiarManager.familiar as? BurdenBeast)?.container?.removeAll(barbassItems)//just in case someone smuggles a pet in.
|
||||
//award points, set Tp location to next wave
|
||||
//or lost game Send back to wave room
|
||||
|
||||
}
|
||||
object BarbAssaultCombat {
|
||||
object BACombatValidation {
|
||||
fun resolveAttackerStyle( attacker: Player, state: BattleState ): AttackerStyle? {
|
||||
return when (state.style) {
|
||||
CombatStyle.MELEE -> when (attacker.properties.attackStyle.style) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@ import content.minigame.barbassault.BA_SESSION_KEY
|
|||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.BAActivity
|
||||
import content.minigame.barbassault.LureItems
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.EggColor.BLUE
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.EggColor.GREEN
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.EggColor.RED
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.LureFood.CRACKERS
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.LureFood.TOFU
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.LureFood.WORMS
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon
|
||||
import content.minigame.barbassault.arena.scenery.GloryHorn
|
||||
import content.minigame.barbassault.getBALevels
|
||||
|
|
@ -208,12 +214,13 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
}
|
||||
}
|
||||
|
||||
fun pickUpGroundItem(player: Player,node:BAGroundSpawn){
|
||||
fun pickUpGroundItem(player: Player,node:BAGroundSpawn): Boolean {
|
||||
if (player.inventory.add(node)) {
|
||||
destroyGroundItem(node)
|
||||
return
|
||||
return true
|
||||
}
|
||||
sendMessage(player,"You don't have enough inventory space to hold that item.")
|
||||
return false
|
||||
}
|
||||
|
||||
fun destroyGroundItem(node: BAGroundSpawn){
|
||||
|
|
@ -602,12 +609,15 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
override val ui: String get() = top
|
||||
}
|
||||
|
||||
enum class EggColor(override val ui: String): HasUIText { RED("Red Eggs"), GREEN("Green Eggs"),BLUE("Blue Eggs") }
|
||||
enum class PoisonFood(override val ui: String): HasUIText { TOFU("Pois. Tofu"), WORMS("Pois. Worms"), MEAT("Pois. Meat") }
|
||||
enum class LureFood(override val ui: String) : HasUIText {
|
||||
TOFU("Tofu"), CRACKERS("Crackers"), WORMS("Worms");
|
||||
fun itemId(): Int = when (this) { WORMS -> Items.WORMS_10515; CRACKERS -> Items.CRACKERS_10513; TOFU -> Items.TOFU_10514 }
|
||||
}
|
||||
enum class EggColor(override val ui: String): HasUIText { RED("Red Eggs"), GREEN("Green Eggs"),BLUE("Blue Eggs");
|
||||
fun itemId(): Int = when (this) { RED -> Items.RED_EGG_10532; GREEN -> Items.GREEN_EGG_10531; BLUE -> Items.BLUE_EGG_10533 }}
|
||||
|
||||
enum class PoisonFood(override val ui: String): HasUIText { TOFU("Pois. Tofu"), WORMS("Pois. Worms"), MEAT("Pois. Meat");
|
||||
fun itemId(): Int = when (this) { TOFU -> Items.POISONED_TOFU_10539; WORMS -> Items.POISONED_WORMS_10540; MEAT -> Items.POISONED_MEAT_10541 }}
|
||||
|
||||
enum class LureFood(override val ui: String) : HasUIText { TOFU("Tofu"), CRACKERS("Crackers"), WORMS("Worms");
|
||||
fun itemId(): Int = when (this) { WORMS -> Items.WORMS_10515; CRACKERS -> Items.CRACKERS_10513; TOFU -> Items.TOFU_10514 }}
|
||||
|
||||
class AttackerCall( override val required: AttackerStyle ) : RoleCall<AttackerStyle>()
|
||||
class HealerCall( override val required: PoisonFood ) : RoleCall<PoisonFood>()
|
||||
class DefenderCall( override val required: LureFood ) : RoleCall<LureFood>()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ 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.BACombatValidation
|
||||
import content.minigame.barbassault.arena.npcs.dropPenanceEggCluster
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.*
|
||||
|
|
@ -42,7 +42,7 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
|
|||
override fun beforeDamageReceived(self: NPC, attacker: Entity, state: BattleState) {
|
||||
val player = attacker as? Player ?: return
|
||||
if (!player.isArtificial) {
|
||||
state.estimatedHit = BarbAssaultCombat.applyAttackValidation(self, player, state)
|
||||
state.estimatedHit = BACombatValidation.applyAttackValidation(self, player, state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ 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.arena.BACombatValidation
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.*
|
||||
import core.api.getItemFromEquipment
|
||||
|
|
@ -39,7 +39,7 @@ class PenanceRangerNPC : NPCBehavior(*PENANCE_RANGER_IDS.toIntArray()) {
|
|||
override fun beforeDamageReceived( self: NPC, attacker: Entity, state: BattleState) {
|
||||
attacker as Player
|
||||
if(!attacker.isArtificial) {
|
||||
state.estimatedHit = BarbAssaultCombat.applyAttackValidation( self, attacker, state )
|
||||
state.estimatedHit = BACombatValidation.applyAttackValidation( self, attacker, state )
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue