mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-25 04:15:14 -06:00
Catapult firing
This commit is contained in:
parent
7c8aa93ce0
commit
dcc4fe2ccf
4 changed files with 34 additions and 21 deletions
|
|
@ -81,6 +81,16 @@ object CastleWars {
|
|||
val damagedCatapultIds: IntArray = intArrayOf(catapultDamaged1, catapultDamaged2)
|
||||
val allCatapultIds: IntArray = intArrayOf(catapult, catapultAlt, catapultDamaged1, catapultDamaged2)
|
||||
|
||||
fun getOperationalCatapultId(team: CastleWarsTeam): Int = when (team) {
|
||||
CastleWarsTeam.SARADOMIN -> catapultAlt
|
||||
CastleWarsTeam.ZAMORAK -> catapult
|
||||
}
|
||||
|
||||
fun getDamagedCatapultId(team: CastleWarsTeam): Int = when (team) {
|
||||
CastleWarsTeam.SARADOMIN -> catapultDamaged2
|
||||
CastleWarsTeam.ZAMORAK -> catapultDamaged1
|
||||
}
|
||||
|
||||
// Trapdoors - allow going down from 2nd floor to respawn room
|
||||
const val saradominTrapdoor: Int = 4471 // Saradomin castle trapdoor
|
||||
const val zamorakTrapdoor: Int = 4472 // Zamorak castle trapdoor
|
||||
|
|
@ -179,4 +189,4 @@ object CastleWars {
|
|||
const val gameTimeMinutes = GAME_TIME_MINUTES
|
||||
const val gameCooldownMinutes = GAME_COOLDOWN_MINUTES
|
||||
val ropeAliveTicks = ROPE_DURATION_TICKS
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ import core.game.node.scenery.Scenery
|
|||
import core.game.node.scenery.SceneryBuilder
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.game.world.update.flag.chunk.ObjectUpdateFlag
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import core.game.world.update.flag.chunk.ObjectUpdateFlag
|
||||
import core.tools.ticksPerMinute
|
||||
import org.rs09.consts.Items
|
||||
|
||||
|
|
@ -179,9 +179,9 @@ object CastleWarsGameState {
|
|||
val saradominFlagStandLocation: Location = Location.create(2429, 3074, 3)
|
||||
val zamorakFlagStandLocation: Location = Location.create(2370, 3133, 3)
|
||||
|
||||
// Catapult locations (on standard floor, z=0)
|
||||
val saradominCatapultLocation: Location = Location.create(2426, 3073, 0)
|
||||
val zamorakCatapultLocation: Location = Location.create(2373, 3134, 0)
|
||||
// Catapult locations (battlement scenery anchor tiles on the battlefield side, z=0)
|
||||
val saradominCatapultLocation: Location = Location.create(2413, 3088, 0)
|
||||
val zamorakCatapultLocation: Location = Location.create(2384, 3117, 0)
|
||||
|
||||
// Respawn locations
|
||||
val saradominRespawnLocation: Location get() = CastleWarsRespawnArea.saradominRespawnRoom.randomWalkableLoc
|
||||
|
|
@ -266,8 +266,14 @@ object CastleWarsGameState {
|
|||
for (key in boulderLocations.keys) {
|
||||
updateBoulderScenery(key, BoulderState.COLLAPSED)
|
||||
}
|
||||
replaceCatapultScenery(saradominCatapultLocation, CastleWars.catapult)
|
||||
replaceCatapultScenery(zamorakCatapultLocation, CastleWars.catapult)
|
||||
replaceCatapultScenery(
|
||||
saradominCatapultLocation,
|
||||
CastleWars.getOperationalCatapultId(CastleWarsTeam.SARADOMIN)
|
||||
)
|
||||
replaceCatapultScenery(
|
||||
zamorakCatapultLocation,
|
||||
CastleWars.getOperationalCatapultId(CastleWarsTeam.ZAMORAK)
|
||||
)
|
||||
resetBattlefield()
|
||||
}
|
||||
|
||||
|
|
@ -1430,8 +1436,8 @@ object CastleWarsGameState {
|
|||
when (team) {
|
||||
CastleWarsTeam.SARADOMIN -> saradominCatapultOperational = false
|
||||
CastleWarsTeam.ZAMORAK -> zamorakCatapultOperational = false
|
||||
} // Replace with damaged catapult scenery (4385 or 4386 have "Repair" option)
|
||||
replaceCatapultScenery(location, CastleWars.catapultDamaged1)
|
||||
}
|
||||
replaceCatapultScenery(location, CastleWars.getDamagedCatapultId(team))
|
||||
updateAllOverlays()
|
||||
}
|
||||
|
||||
|
|
@ -1480,7 +1486,7 @@ object CastleWarsGameState {
|
|||
CastleWarsTeam.SARADOMIN -> saradominCatapultOperational = true
|
||||
CastleWarsTeam.ZAMORAK -> zamorakCatapultOperational = true
|
||||
}
|
||||
replaceCatapultScenery(location, CastleWars.catapult)
|
||||
replaceCatapultScenery(location, CastleWars.getOperationalCatapultId(team))
|
||||
updateAllOverlays()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package content.minigame.castlewars
|
||||
|
||||
import core.game.world.map.Location
|
||||
import org.rs09.consts.Components
|
||||
|
||||
/**
|
||||
|
|
@ -36,9 +35,7 @@ object CatapultConfig {
|
|||
const val DEFAULT_X = CastleWarsConstants.CATAPULT_DEFAULT_X
|
||||
const val DEFAULT_Y = CastleWarsConstants.CATAPULT_DEFAULT_Y
|
||||
const val CENTER_OFFSET = 15
|
||||
|
||||
val SARADOMIN_BASE = Location.create(2426, 3073, 0)
|
||||
val ZAMORAK_BASE = Location.create(2373, 3134, 0)
|
||||
const val HORIZONTAL_TILE_SCALE = 2
|
||||
|
||||
const val SOUND_FIRE = 1440
|
||||
const val SOUND_IMPACT = 851
|
||||
|
|
@ -82,10 +79,10 @@ enum class CatapultButton(val buttonId: Int, val deltaX: Int, val deltaY: Int) {
|
|||
* Enum representing team-specific catapult configurations.
|
||||
* Handles coordinate transformations based on team orientation.
|
||||
*/
|
||||
enum class CatapultTeam(val baseLocation: Location) {
|
||||
SARADOMIN(CatapultConfig.SARADOMIN_BASE) {
|
||||
enum class CatapultTeam {
|
||||
SARADOMIN {
|
||||
override fun calculateTargetX(catapultX: Int, interfaceX: Int): Int {
|
||||
return catapultX + (interfaceX - CatapultConfig.CENTER_OFFSET)
|
||||
return catapultX + ((interfaceX - CatapultConfig.CENTER_OFFSET) * CatapultConfig.HORIZONTAL_TILE_SCALE)
|
||||
}
|
||||
|
||||
override fun calculateTargetY(catapultY: Int, interfaceY: Int): Int {
|
||||
|
|
@ -93,9 +90,9 @@ enum class CatapultTeam(val baseLocation: Location) {
|
|||
}
|
||||
},
|
||||
|
||||
ZAMORAK(CatapultConfig.ZAMORAK_BASE) {
|
||||
ZAMORAK {
|
||||
override fun calculateTargetX(catapultX: Int, interfaceX: Int): Int {
|
||||
return catapultX - (interfaceX - CatapultConfig.CENTER_OFFSET)
|
||||
return catapultX - ((interfaceX - CatapultConfig.CENTER_OFFSET) * CatapultConfig.HORIZONTAL_TILE_SCALE)
|
||||
}
|
||||
|
||||
override fun calculateTargetY(catapultY: Int, interfaceY: Int): Int {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import core.tools.RandomFunction
|
|||
/**
|
||||
* Handles firing the catapult and dealing impact damage.
|
||||
*/
|
||||
class CatapultFiringHandler { // TODO: i dont think this even works.. at all even
|
||||
class CatapultFiringHandler {
|
||||
|
||||
/**
|
||||
* Fires the catapult at the specified coordinates.
|
||||
|
|
@ -50,7 +50,7 @@ class CatapultFiringHandler { // TODO: i dont think this even works.. at all eve
|
|||
sendMessage(player, "You fire the catapult!")
|
||||
}
|
||||
|
||||
private fun calculateTargetLocation(team: CatapultTeam, catapultLocation: Location, coord: Coordinate): Location {
|
||||
internal fun calculateTargetLocation(team: CatapultTeam, catapultLocation: Location, coord: Coordinate): Location {
|
||||
val targetX = team.calculateTargetX(catapultLocation.x, coord.x)
|
||||
val targetY = team.calculateTargetY(catapultLocation.y, coord.y)
|
||||
return Location.create(targetX, targetY, 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue