about summary refs log tree commit diff stats
path: root/data/maps/daedalus/rooms/Pyramid 5.txtpb
blob: 42e8a52364a5d8520c4102a2ea0f49b1a0da325c (plain) (blame)
1
2
3
4
5
6
7
8
9
name: "Pyramid 5"
panel_display_name: "Pyramid"
panels {
  name: "ROYAL"
  path: "Panels/Pyramid/pyramid_5"
  clue: "royal"
  answer: "king"
  symbols: EXAMPLE
}
d='n229' href='#n229'>229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
SpeakerType = {
  NONE = 0,
  MAN = 1,
  WOMAN = 2,
  BOY = 3,
  GIRL = 4,
  NONHUMAN = 5
}

Direction = {
  UP = 0,
  UP_RIGHT = 1,
  RIGHT = 2,
  DOWN_RIGHT = 3,
  DOWN = 4,
  DOWN_LEFT = 5,
  LEFT = 6,
  UP_LEFT = 7
}

CharacterState = {
  STILL = 0,
  WALKING = 1,
  CROUCHING = 2,
  RUNNING = 3
}

SpriteLayer = {
  NORMAL = 0,
  ABOVE = 1
}

CutsceneOptions = {
  DO_NOT_CHANGE_ANIMATION = 1 -- Prevents player party animation being set to "frozen" at the start of a cutscene or "still" at the end
}

ChangeMapOptions = {
  DO_NOT_FADE = 1 -- Prevents fading to and from black
}

gamestate = {}

--- Yields until the specified amount of time has passed.
-- @param time in milliseconds
function Delay(time)
  while time > 0 do
    time = time - coroutine.yield()
  end
end

--- Starts a cutscene.
-- This takes care of showing the cutscene bars, as well as halting character
-- movement. It does not block. See CutsceneOptions for modifiers.
function StartCutscene(options)
  options = options or 0

  local playerId = getPlayerSprite()
  local playerSprite = getSprite(playerId)
  playerSprite.controllable = false
  character():halt(playerId)

  if (options & CutsceneOptions.DO_NOT_CHANGE_ANIMATION == 0) then
    SetPartyAnimation(playerId, "frozen")
  end

  message():displayCutsceneBars()

  local allSprites = getAllSprites()
  for k,v in pairs(allSprites) do
    getSprite(v).paused = true
  end
end

--- Queues a message for display.
-- Non-blocking! If you want to block until the message has been fully
-- revealed, use WaitForEndOfMessage().
-- @param msg the text of the message
-- @param name the name of the character speaking (leave blank to not show a character name)
-- @param type the SpeakerType for the character, which determines which beep sound is played, if any
function DisplayMessage(msg, name, type)
  message():displayMessage(msg, name, type)
end

--- Queues a choice prompt for the player.
-- This should be called after DisplayMessage(), as it is not valid for a choice
-- prompt to be the first line of the text box. This also does not block. You
-- should use WaitForEndOfMessage() after this.
-- @param one the text of the first option
-- @param two the text of the second option
function ShowChoice(one, two)
  message():showChoice(one, two)
end

--- Gets the result of the last choice prompt.
-- @return 0 for the left choice, 1 for the right choice
function GetChoiceSelection()
  return message():getChoiceSelection()
end

--- Yields until all queued messages / choice prompts have been dismissed.
-- This does not hide the cutscene bars, nor does it wait for them to hide.
function WaitForEndOfMessage()
  while (message().isMessageActive) do
    coroutine.yield()
  end
end

--- Hides the cutscene bars.
-- This also re-enables player movement. See CutsceneOptions for modifiers.
function HideCutsceneBars(options)
  options = options or 0

  WaitForEndOfMessage()
  message():hideCutsceneBars()

  local playerId = getPlayerSprite()
  local playerSprite = getSprite(playerId)
  playerSprite.controllable = true

  if (options & CutsceneOptions.DO_NOT_CHANGE_ANIMATION == 0) then
    SetPartyAnimation(playerId, "still")
  end

  local allSprites = getAllSprites()
  for k,v in pairs(allSprites) do
    getSprite(v).paused = false
  end
end

function GetPosition(spriteName)
  local spriteId = getSpriteByAlias(spriteName)
  local sprite = getSprite(spriteId)
  return sprite.loc
end

function SetPosition(spriteName, x, y)
  local spriteId = getSpriteByAlias(spriteName)
  transform():moveSprite(spriteId, vec2i.new(x, y))
end

function SetDirection(spriteName, dir)
  local spriteId = getSpriteByAlias(spriteName)
  animation():setSpriteDirection(spriteId, dir)
end

function SetAnimation(spriteName, animName)
  local spriteId = getSpriteByAlias(spriteName)
  animation():setSpriteAnimation(spriteId, animName)
end

function WaitForAnimation(spriteName)
  local spriteId = getSpriteByAlias(spriteName)
  local sprite = getSprite(spriteId)
  repeat
    coroutine.yield()
  until sprite.animFinished
end

function Halt(spriteName)
  local spriteId = getSpriteByAlias(spriteName)
  character():halt(spriteId)
end

function PlaySound(filename)
  mixer():playSound("../res/sfx/" .. filename)
end

function LoopSound(filename)
  return mixer():loopSound("../res/sfx/" .. filename)
end

function StopSound(soundId)
  mixer():stopChannel(soundId)
end

function FadeToBlack(length)
  effect():fadeScreen(length, 1.0)
  repeat
    coroutine.yield()
  until effect():isScreenFadeComplete()
end

function RemoveFadeout(length)
  effect():fadeScreen(length, 0.0)
  repeat
    coroutine.yield()
  until effect():isScreenFadeComplete()
end

function FadeMap(length, amount)
  effect():fadeMap(length, amount)
end

function WaitForMapFade()
  while not effect():isMapFadeComplete() do
    coroutine.yield()
  end
end

function ShakeCamera(period)
  effect():shakeCamera(period)
end

function StopShakingCamera()
  effect():stopShakingCamera()
end

function PanToSprite(spriteName, length)
  local spriteId = getSpriteByAlias(spriteName)
  camera():panToSprite(spriteId, length)
end

function WaitForPan()
  while camera():isPanning() do
    coroutine.yield()
  end
end

function ReturnCamera(length)
  local playerId = getPlayerSprite()
  camera():panToSprite(playerId, length)

  while camera():isPanning() do
    coroutine.yield()
  end

  camera():setFollowingSprite(playerId)
  camera():unlockCamera()
end

function SetPartyDirection(spriteId, direction)
  animation():setSpriteDirection(spriteId, direction)

  local sprite = getSprite(spriteId)

  for i=1,#sprite.followers do
    animation():setSpriteDirection(sprite.followers[i], direction)
  end
end

function SetPartyAnimation(spriteId, animName)
  animation():setSpriteAnimation(spriteId, animName)

  local sprite = getSprite(spriteId)

  for i=1,#sprite.followers do
    animation():setSpriteAnimation(sprite.followers[i], animName)
  end
end

function ChangeMap(map, warp, options)
  options = options or 0

  local playerId = getPlayerSprite()
  local playerSprite = getSprite(playerId)
  local direction = playerSprite.dir

  playerSprite.controllable = false
  if (options & ChangeMapOptions.DO_NOT_FADE == 0) then
    FadeToBlack(150)
  end
  loadMap(map)
  character():transplantParty(playerId, getWarpPoint(warp), direction)

  coroutine.yield()
  if (options & ChangeMapOptions.DO_NOT_FADE == 0) then
    RemoveFadeout(150)
  end
  playerSprite.controllable = true
end

function CreateAnimatedSpriteAtPosition(alias, character, x, y, animName, direction, layer)
  local spriteId = emplaceSprite(alias)
  transform():initSprite(spriteId, x, y, layer)
  animation():initSprite(spriteId, "../res/sprites/" .. character .. "_anim.txt")
  animation():setSpriteDirection(spriteId, direction)
  animation():setSpriteAnimation(spriteId, animName)
end

function DestroyNamedSprite(alias)
  local spriteId = getSpriteByAlias(alias)
  destroySprite(spriteId)
end

function AliasForSpriteExpression(spriteName)
  return "expression (" .. spriteName .. ")"
end

function ShowExpression(spriteName, expression)
  local spriteId = getSpriteByAlias(spriteName)
  local sprite = getSprite(spriteId)
  local animFrame = sprite:getCurrentFrame()
  local x = sprite.loc:x()
  local y = sprite.loc:y() - animFrame.center:y()

  CreateAnimatedSpriteAtPosition(AliasForSpriteExpression(spriteName), "expression", x, y, expression, Direction.DOWN, SpriteLayer.ABOVE)
end

function RemoveExpression(spriteName)
  DestroyNamedSprite(AliasForSpriteExpression(spriteName))
end

--- Turns on clipping for the player.
-- This allows walking through solid objects. For debug only!
function StartClipping()
  local playerId = getPlayerSprite()
  local playerSprite = getSprite(playerId)
  playerSprite.clipping = true
end

--- Turns off clipping for the player.
-- For debug only!
function StopClipping()
  local playerId = getPlayerSprite()
  local playerSprite = getSprite(playerId)
  playerSprite.clipping = false
end

--- Turns off crouching (and thus running) for the player.
function PreventCrouching()
  local playerId = getPlayerSprite()
  local playerSprite = getSprite(playerId)
  playerSprite.cantCrouch = true
end

--- Undoes the effect of PreventCrouching().
function AllowCrouching()
  local playerId = getPlayerSprite()
  local playerSprite = getSprite(playerId)
  playerSprite.cantCrouch = false
end