diff options
Diffstat (limited to 'res/scripts')
| -rw-r--r-- | res/scripts/common.lua | 54 | ||||
| -rw-r--r-- | res/scripts/underwater_start.lua | 21 |
2 files changed, 75 insertions, 0 deletions
| diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 23b881a..123f2a0 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua | |||
| @@ -38,6 +38,10 @@ ChangeMapOptions = { | |||
| 38 | DO_NOT_FADE = 1 -- Prevents fading to and from black | 38 | DO_NOT_FADE = 1 -- Prevents fading to and from black |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | PathfindingOptions = { | ||
| 42 | CARDINAL_DIRECTIONS_ONLY = 1 | ||
| 43 | } | ||
| 44 | |||
| 41 | gamestate = {} | 45 | gamestate = {} |
| 42 | 46 | ||
| 43 | --- Yields until the specified amount of time has passed. | 47 | --- Yields until the specified amount of time has passed. |
| @@ -127,6 +131,23 @@ function HideCutsceneBars(options) | |||
| 127 | end | 131 | end |
| 128 | end | 132 | end |
| 129 | 133 | ||
| 134 | --- Unpauses a sprite's movement. | ||
| 135 | -- Use this during cutscenes to allow the sprite's movement to be controlled | ||
| 136 | -- either by the InputSystem or the BehaviourSystem. | ||
| 137 | function UnpauseSprite(spriteName) | ||
| 138 | local spriteId = getSpriteByAlias(spriteName) | ||
| 139 | local sprite = getSprite(spriteId) | ||
| 140 | sprite.paused = false | ||
| 141 | end | ||
| 142 | |||
| 143 | --- Re-pauses a sprite's movement. | ||
| 144 | -- Use this after UnpauseSprite() when you are done moving the sprite. | ||
| 145 | function PauseSprite(spriteName) | ||
| 146 | local spriteId = getSpriteByAlias(spriteName) | ||
| 147 | local sprite = getSprite(spriteId) | ||
| 148 | sprite.paused = true | ||
| 149 | end | ||
| 150 | |||
| 130 | function GetPosition(spriteName) | 151 | function GetPosition(spriteName) |
| 131 | local spriteId = getSpriteByAlias(spriteName) | 152 | local spriteId = getSpriteByAlias(spriteName) |
| 132 | local sprite = getSprite(spriteId) | 153 | local sprite = getSprite(spriteId) |
| @@ -216,6 +237,12 @@ function WaitForPan() | |||
| 216 | end | 237 | end |
| 217 | end | 238 | end |
| 218 | 239 | ||
| 240 | function CameraFollowSprite(spriteName) | ||
| 241 | local spriteId = getSpriteByAlias(spriteName) | ||
| 242 | camera():setFollowingSprite(spriteId) | ||
| 243 | camera():unlockCamera() | ||
| 244 | end | ||
| 245 | |||
| 219 | function ReturnCamera(length) | 246 | function ReturnCamera(length) |
| 220 | local playerId = getPlayerSprite() | 247 | local playerId = getPlayerSprite() |
| 221 | camera():panToSprite(playerId, length) | 248 | camera():panToSprite(playerId, length) |
| @@ -359,3 +386,30 @@ function SetAnimationSlowdown(spriteName, amount) | |||
| 359 | local sprite = getSprite(spriteId) | 386 | local sprite = getSprite(spriteId) |
| 360 | sprite.animSlowdown = amount | 387 | sprite.animSlowdown = amount |
| 361 | end | 388 | end |
| 389 | |||
| 390 | --- Removes the enclosure zone for the specified sprite. | ||
| 391 | -- This allows the sprite to move outside of the confines of the zone. | ||
| 392 | function RemoveEnclosureZone(spriteName) | ||
| 393 | local spriteId = getSpriteByAlias(spriteName) | ||
| 394 | local sprite = getSprite(spriteId) | ||
| 395 | sprite.enclosureZone = "" | ||
| 396 | end | ||
| 397 | |||
| 398 | --- Set a sprite on a path to the specified location. | ||
| 399 | function DirectSpriteToLocation(spriteName, warpPoint, options) | ||
| 400 | options = options or 0 | ||
| 401 | |||
| 402 | local spriteId = getSpriteByAlias(spriteName) | ||
| 403 | local dest = getMap():getWarpPoint(warpPoint) | ||
| 404 | |||
| 405 | behaviour():directSpriteToLocation(spriteId, dest, options) | ||
| 406 | end | ||
| 407 | |||
| 408 | --- Blocks until the specified sprite has completed their path. | ||
| 409 | function WaitForSpritePath(spriteName) | ||
| 410 | local spriteId = getSpriteByAlias(spriteName) | ||
| 411 | |||
| 412 | while (behaviour():isFollowingPath(spriteId)) do | ||
| 413 | coroutine.yield() | ||
| 414 | end | ||
| 415 | end | ||
| diff --git a/res/scripts/underwater_start.lua b/res/scripts/underwater_start.lua index 56b0b5e..7259d05 100644 --- a/res/scripts/underwater_start.lua +++ b/res/scripts/underwater_start.lua | |||
| @@ -9,5 +9,26 @@ function underwater_start.talk_to_fish1() | |||
| 9 | StartCutscene() | 9 | StartCutscene() |
| 10 | DisplayMessage("* You deserved what she did to you.", "Fish", SpeakerType.BOY) | 10 | DisplayMessage("* You deserved what she did to you.", "Fish", SpeakerType.BOY) |
| 11 | WaitForEndOfMessage() | 11 | WaitForEndOfMessage() |
| 12 | |||
| 13 | Delay(500) | ||
| 14 | |||
| 15 | PanToSprite("fish1", 1000) | ||
| 16 | WaitForPan() | ||
| 17 | |||
| 18 | Delay(500) | ||
| 19 | |||
| 20 | UnpauseSprite("fish1") | ||
| 21 | RemoveEnclosureZone("fish1") | ||
| 22 | DirectSpriteToLocation("fish1", "fish_destination", PathfindingOptions.CARDINAL_DIRECTIONS_ONLY) | ||
| 23 | CameraFollowSprite("fish1") | ||
| 24 | WaitForSpritePath("fish1") | ||
| 25 | |||
| 26 | Delay(1000) | ||
| 27 | DestroyNamedSprite("fish1") | ||
| 28 | |||
| 29 | Delay(500) | ||
| 30 | |||
| 31 | ReturnCamera(1000) | ||
| 32 | |||
| 12 | HideCutsceneBars() | 33 | HideCutsceneBars() |
| 13 | end \ No newline at end of file | 34 | end \ No newline at end of file |
