Refactored the Player Safety Stronghold

This commit is contained in:
GregF
2024-04-17 07:45:55 +00:00
committed by Ryan
parent 6deadc6f90
commit 0dcdc84f79
17 changed files with 892 additions and 1099 deletions
+19 -11
View File
@@ -223,13 +223,19 @@ abstract class Cutscene(val player: Player) {
logCutscene("Added NPC $id at location LOCAL[$regionX,$regionY,$plane] GLOBAL[${npc.location.x},${npc.location.y},$plane]")
}
fun start()
fun start(){
start(true)
}
fun start(hideMiniMap: Boolean)
{
logCutscene("Starting cutscene for ${player.username}.")
region = RegionManager.forId(player.location.regionId)
base = RegionManager.forId(player.location.regionId).baseLocation
setup()
PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2))
if (hideMiniMap) {
PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2))
}
runStage(player.getCutsceneStage())
setAttribute(player, ATTRIBUTE_CUTSCENE, this)
setAttribute(player, ATTRIBUTE_CUTSCENE_STAGE, 0)
@@ -244,24 +250,26 @@ abstract class Cutscene(val player: Player) {
/**
* Ends this cutscene, fading the screen to black, teleporting the player to the exit location, and then fading it back in and executing the endActions passed to this method.
* @param fade (optional) should the cutscene fade to black?
* @param endActions (optional) a method that executes when the cutscene fully completes
*/
fun end(endActions: (() -> Unit)? = null)
fun end(fade: Boolean = true, endActions: (() -> Unit)? = null)
{
ended = true
fadeToBlack()
if (fade) fadeToBlack()
GameWorld.Pulser.submit(object : Pulse(){
var tick: Int = 0
override fun pulse(): Boolean {
when(tick++)
{
8 -> player.properties.teleportLocation = exitLocation
9 -> fadeFromBlack()
16 -> {
return true
if (fade) {
when (tick++) {
8 -> player.properties.teleportLocation = exitLocation
9 -> fadeFromBlack()
16 -> return true
else -> return false
}
}
return false
else player.properties.teleportLocation = exitLocation
return true
}
override fun stop() {
@@ -821,8 +821,8 @@ public final class GlobalData {
}
/**
* Gets the read plagues.
* @return The plague
* Gets the read plaques.
* @return The plaques
*/
public boolean[] getReadPlaques() {
return readPlaques;
@@ -606,6 +606,72 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
sendDialogue(player, "Wrong pin. Try again.")
}
}
define("setplayerstrong", Privilege.ADMIN, "setplayerstrong <0-4>",
"Set the player progress through the Stronghold of Player Safety test."){player, args ->
/*
* 0 = Not started
* 1 = Received test
* 2 = Completed test, needs to be marked
* 3 = Test marked
* 4 = Dungeon cleared
*/
if(args.size < 2){
notify(player, "Player Stronghold progression currently: ${player.savedData.globalData.testStage}")
return@define
}
val stage = args[1].toIntOrNull() ?: (-1).also { reject(player, "Please enter a valid number") }
if (stage in 0 .. 4){
player.savedData.globalData.testStage = stage
notify(player, "Setting test stage to $stage")
if (stage in 0..2){
setVarp(player, 1203, 0, true)
notify(player, "The poster passage is now hidden")
}
else{
setVarp(player, 1203, 1 shl 29, true)
notify(player, "The poster passage is now usable")
}
if (stage == 4){
setVarbit(player, 4499, 1,true)
notify(player, "The loot has been taken already")
}
else {
setVarbit(player, 4499, 0, true)
notify(player, "The loot can be reacquired")
}
}
else{
reject(player, "Only stages 0-4 are valid")
}
}
define("setplaqueread", Privilege.ADMIN, "setplaqueread <true/false>",
"Set the plaques in the player safety stronghold to read or not read."){player, args ->
if (args.size == 1) {
notify(
player,
"Currently the plaques ${if (player.savedData.globalData.hasReadPlaques()) "have" else "have not"} been read"
)
return@define
}
when(args[1]) {
"true" -> setPlaqueReadStatus(player, true)
"false" -> setPlaqueReadStatus(player, false)
else -> reject(player, "Only true or false can be used")
}
notify(player, "Setting plaques read to: ${args[1]}")
}
}
fun setPlaqueReadStatus(player: Player, status: Boolean){
// For some reason the loop has to be this way to have read write access
for (i in 0 until player.savedData.globalData.readPlaques.size){
player.savedData.globalData.readPlaques[i] = status
}
}
fun showGeBotsearch(player: Player, searchTerm: String)