mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-28 05:45:10 -06:00
egg hopper work
This commit is contained in:
parent
e85833ffd9
commit
cc5d74a557
3 changed files with 37 additions and 33 deletions
|
|
@ -107,7 +107,6 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
}
|
||||
on(Scenery.EGG_HOPPER_20264, IntType.SCENERY, "Load","Look-in") { player, node ->
|
||||
val loc = player.location
|
||||
|
||||
val optionClicked = player.getAttribute<String>("interact:option")?.lowercase() ?: return@on false
|
||||
when(optionClicked){
|
||||
"load" -> loadEggHopper(player)
|
||||
|
|
@ -128,6 +127,8 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
return@on true
|
||||
}
|
||||
setDest(IntType.SCENERY, intArrayOf(Scenery.EGG_HOPPER_20264), "use","Load","Look-in") { player, node ->
|
||||
//work around for running off to org location instead of copy location.
|
||||
//Player Name's Parlor chairs Should fix this!
|
||||
return@setDest sessionDestination(player as Player,node,Direction.SOUTH)
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +277,8 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
})
|
||||
}
|
||||
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 borders = getRegionBorders(session.region.regionId)
|
||||
val base = session.base
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ fun getWaveDefinition(index: Int): WaveDefinition {
|
|||
}
|
||||
|
||||
data class WaveDefinition( val caps: SpawnCaps, val npcIds: Map<PenanceType, Int> )
|
||||
enum class PenanceType { HEALER, RUNNER, FIGHTER, RANGER }
|
||||
enum class PenanceType { HEALER, RUNNER, FIGHTER, RANGER, QUEEN }
|
||||
data class SpawnCaps(val rangers: Int, val fighters: Int, val runners: Int, val healers: Int)
|
||||
val waves = listOf(
|
||||
private val waves = listOf(
|
||||
WaveDefinition( //Wave tut
|
||||
SpawnCaps(rangers = 1, fighters = 1, runners = 1, healers = 1),
|
||||
mapOf(
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ 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.PenanceType
|
||||
|
|
@ -94,10 +95,6 @@ class EggHopper : ComponentPlugin() {
|
|||
fun consumeBlue(): Boolean { if (blue <= 0) return false; blue--; return true }
|
||||
fun consumeYellow(): Boolean { if (yellow <= 0) return false; yellow--; return true }
|
||||
}
|
||||
enum class EggType( val consume: EggHopper.() -> Boolean, val action: String,val key: String) {
|
||||
GREEN({ consumeGreen() }, "poison","green"), RED({ consumeRed() }, "explosive", "red"), BLUE({ consumeBlue() }, "stun", "blue");
|
||||
fun tryConsume(hopper: EggHopper): Boolean = hopper.consume()
|
||||
}
|
||||
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
ComponentDefinition.forId(EggTurret.ID).plugin = this
|
||||
|
|
@ -126,36 +123,29 @@ class EggHopper : ComponentPlugin() {
|
|||
|
||||
checkEasterEgg(player, button)
|
||||
|
||||
when(button){
|
||||
EggTurret.close -> closeTurretIface(player)
|
||||
EggTurret.queenBtn -> sendMessage(player,"Shoot Omega at Queen")
|
||||
else -> shootNormalEggs(button, player)
|
||||
}
|
||||
if (button ==EggTurret.close ){ closeTurretIface(player); return true}
|
||||
shootNormalEggs(button,player)
|
||||
return true
|
||||
}
|
||||
|
||||
fun shootNormalEggs(button: Int, player: Player?) {
|
||||
player ?: return
|
||||
val hopper = player.baSession?.eggHopper ?: return
|
||||
|
||||
val (type, eggType) = listOf(
|
||||
PenanceType.HEALER to EggTurret.pHealerBtns,
|
||||
PenanceType.RUNNER to EggTurret.pRunnerBtns,
|
||||
PenanceType.FIGHTER to EggTurret.pFighterBtns,
|
||||
PenanceType.RANGER to EggTurret.pRangerBtns
|
||||
PenanceType.RANGER to EggTurret.pRangerBtns,
|
||||
).firstNotNullOfOrNull { (type, colors) ->
|
||||
when (button) {
|
||||
colors.GREEN -> type to EggType.GREEN
|
||||
colors.RED -> type to EggType.RED
|
||||
colors.BLUE -> type to EggType.BLUE
|
||||
else -> null
|
||||
else -> type to EggType.YELLOW
|
||||
}
|
||||
} ?: return
|
||||
|
||||
if (!eggType.tryConsume(hopper)) {
|
||||
sendMessage(player, "There are no ${eggType.key} eggs in the hopper.")
|
||||
return
|
||||
}
|
||||
} ?: if (button == EggTurret.queenBtn) {
|
||||
PenanceType.QUEEN to EggType.YELLOW
|
||||
} else return
|
||||
|
||||
sendMessage(player, "Shoot ${eggType.action} at $type.")
|
||||
fireEgg(player, type, eggType)
|
||||
|
|
@ -168,18 +158,18 @@ class EggHopper : ComponentPlugin() {
|
|||
val penances = listOf( EggTurret.pHealer, EggTurret.pRunner, EggTurret.pRanger, EggTurret.pFighter )
|
||||
|
||||
penances.forEach { penance ->
|
||||
val colors = listOf( "green" to penance.GREEN,"red" to penance.RED, "blue" to penance.BLUE)
|
||||
colors.forEach { (colorName, componentId) ->
|
||||
val value = when(colorName) {
|
||||
"green" -> eggHopper.green
|
||||
"red" -> eggHopper.red
|
||||
"blue" -> eggHopper.blue
|
||||
else -> 0
|
||||
}
|
||||
val components = listOf(
|
||||
EggType.GREEN to penance.GREEN,
|
||||
EggType.RED to penance.RED,
|
||||
EggType.BLUE to penance.BLUE
|
||||
)
|
||||
|
||||
components.forEach { (eggType, componentId) ->
|
||||
val value = eggType.getCount(eggHopper)
|
||||
setInterfaceText(player, value.toString(), EggTurret.ID, componentId)
|
||||
}
|
||||
}
|
||||
setInterfaceText(player,eggHopper.yellow.toString(),EggTurret.ID,EggTurret.OMEGA)
|
||||
setInterfaceText( player, EggType.YELLOW.getCount(eggHopper).toString(), EggTurret.ID, EggTurret.OMEGA )
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -241,23 +231,34 @@ class EggHopper : ComponentPlugin() {
|
|||
val npcId = player.baSession?.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
|
||||
|
||||
if (target == null) { sendDialogueLines(player,"There are no targetable Penance ${type.name} within firing range.") ;return}
|
||||
if (!eggType.tryConsume(hopper)) {
|
||||
sendMessage(player, "There are no ${eggType.name.lowercase()} eggs in the hopper.")
|
||||
return
|
||||
}
|
||||
//queueScript { }
|
||||
player.animate(Animation(5428))
|
||||
eggCannon.face(target)
|
||||
eggCannon.animate(Animation(5426))
|
||||
|
||||
if (eggType.key == "green" ){ spawnProjectile(eggCannon,target as Entity,GREEN_EGG_PROJECTILE_977) }
|
||||
if (eggType.key == "red" ){ spawnProjectile(eggCannon,target as Entity,RED_EGG_PROJECTILE_978) }
|
||||
if (eggType.key == "blue" ){ spawnProjectile(eggCannon,target as Entity,Blue_EGG_PROJECTILE_978) }
|
||||
spawnProjectile(eggCannon,target as Entity,eggType.projectileGFX)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum class EggType(val consume: EggHopper.EggHopper.() -> Boolean, val action: String, val projectileGFX: Int, val getAmount: EggHopper.EggHopper.() -> Int) {
|
||||
GREEN({ consumeGreen() }, "poison",GREEN_EGG_PROJECTILE_977, { green }),
|
||||
RED({ consumeRed() }, "explosive", RED_EGG_PROJECTILE_978, { red }),
|
||||
BLUE({ consumeBlue() }, "stun", Blue_EGG_PROJECTILE_978, { blue }),
|
||||
YELLOW({consumeYellow()},"Omega",YELLOW_EGG_PROJECTILE_980, { yellow });
|
||||
|
||||
fun tryConsume(hopper: EggHopper.EggHopper): Boolean = hopper.consume()
|
||||
fun getCount(hopper: EggHopper.EggHopper) = hopper.getAmount()
|
||||
}
|
||||
data class EggColors(val GREEN: Int, val RED: Int, val BLUE: Int)
|
||||
object EggTurret {
|
||||
const val ID = 495
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue