diff options
Diffstat (limited to 'res/scripts')
| -rw-r--r-- | res/scripts/common.lua | 42 | ||||
| -rw-r--r-- | res/scripts/hallucination_interior.lua | 44 |
2 files changed, 85 insertions, 1 deletions
| diff --git a/res/scripts/common.lua b/res/scripts/common.lua index d0ea6b5..f984667 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua | |||
| @@ -34,7 +34,8 @@ SpriteLayer = { | |||
| 34 | BehaviourType = { | 34 | BehaviourType = { |
| 35 | NONE = 0, | 35 | NONE = 0, |
| 36 | WANDER = 1, | 36 | WANDER = 1, |
| 37 | PATH = 2 | 37 | PATH = 2, |
| 38 | FOLLOW = 3 | ||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | CutsceneOptions = { | 41 | CutsceneOptions = { |
| @@ -440,6 +441,13 @@ function WaitForSpritePath(spriteName) | |||
| 440 | end | 441 | end |
| 441 | end | 442 | end |
| 442 | 443 | ||
| 444 | --- Sets a sprite to wander. | ||
| 445 | function StartWandering(spriteName) | ||
| 446 | local spriteId = getSpriteByAlias(spriteName) | ||
| 447 | local sprite = getSprite(spriteId) | ||
| 448 | sprite.behaviourType = BehaviourType.WANDER | ||
| 449 | end | ||
| 450 | |||
| 443 | --- Turns off the sprite's behaviour. | 451 | --- Turns off the sprite's behaviour. |
| 444 | function DisableBehaviour(spriteName) | 452 | function DisableBehaviour(spriteName) |
| 445 | local spriteId = getSpriteByAlias(spriteName) | 453 | local spriteId = getSpriteByAlias(spriteName) |
| @@ -447,6 +455,23 @@ function DisableBehaviour(spriteName) | |||
| 447 | sprite.behaviourType = BehaviourType.NONE | 455 | sprite.behaviourType = BehaviourType.NONE |
| 448 | end | 456 | end |
| 449 | 457 | ||
| 458 | --- Directs a sprite to start following a target sprite. | ||
| 459 | function FollowSprite(spriteName, targetName) | ||
| 460 | local spriteId = getSpriteByAlias(spriteName) | ||
| 461 | local targetId = getSpriteByAlias(targetName) | ||
| 462 | local sprite = getSprite(spriteId) | ||
| 463 | sprite.followSpriteId = targetId | ||
| 464 | sprite.behaviourType = BehaviourType.FOLLOW | ||
| 465 | end | ||
| 466 | |||
| 467 | --- Makes a sprite stop following whatever sprite it was following. | ||
| 468 | function StopFollowingSprite(spriteName) | ||
| 469 | local spriteId = getSpriteByAlias(spriteName) | ||
| 470 | local sprite = getSprite(spriteId) | ||
| 471 | sprite.followSpriteId = -1 | ||
| 472 | sprite.behaviourType = BehaviourType.NONE | ||
| 473 | end | ||
| 474 | |||
| 450 | --- Fades out the currently playing music. | 475 | --- Fades out the currently playing music. |
| 451 | -- This does not block. If you want it to block, call Delay for the same amount | 476 | -- This does not block. If you want it to block, call Delay for the same amount |
| 452 | -- of time. | 477 | -- of time. |
| @@ -479,6 +504,21 @@ function EnablePlayerControl() | |||
| 479 | end | 504 | end |
| 480 | 505 | ||
| 481 | --- Makes the specified sprite face toward the †arget sprite. | 506 | --- Makes the specified sprite face toward the †arget sprite. |
| 507 | -- This version of the function uses any of the eight directions. | ||
| 508 | -- @param spriteName the name of the sprite to change the direction of | ||
| 509 | -- @param targetName the name of the sprite to face toward | ||
| 510 | function FaceTowardSprite(spriteName, targetName) | ||
| 511 | local spriteId = getSpriteByAlias(spriteName) | ||
| 512 | local targetId = getSpriteByAlias(targetName) | ||
| 513 | local sprite = getSprite(spriteId) | ||
| 514 | local target = getSprite(targetId) | ||
| 515 | local diff = vec2i.new(target.loc:x() - sprite.loc:x(), target.loc:y() - sprite.loc:y()) | ||
| 516 | local dir = directionFacingPoint(diff) | ||
| 517 | |||
| 518 | SetDirection(spriteName, dir) | ||
| 519 | end | ||
| 520 | |||
| 521 | --- Makes the specified sprite face toward the †arget sprite. | ||
| 482 | -- This version of the function uses the closest cardinal direction. | 522 | -- This version of the function uses the closest cardinal direction. |
| 483 | -- @param spriteName the name of the sprite to change the direction of | 523 | -- @param spriteName the name of the sprite to change the direction of |
| 484 | -- @param targetName the name of the sprite to face toward | 524 | -- @param targetName the name of the sprite to face toward |
| diff --git a/res/scripts/hallucination_interior.lua b/res/scripts/hallucination_interior.lua index f009196..0622453 100644 --- a/res/scripts/hallucination_interior.lua +++ b/res/scripts/hallucination_interior.lua | |||
| @@ -226,3 +226,47 @@ function hallucination_interior.mailbox_time_passage() | |||
| 226 | 226 | ||
| 227 | EnablePlayerControl() | 227 | EnablePlayerControl() |
| 228 | end | 228 | end |
| 229 | |||
| 230 | function hallucination_interior.switch_claus_attention() | ||
| 231 | gamestate.switch_claus_lost_interest = false | ||
| 232 | |||
| 233 | Halt("switch_claus") | ||
| 234 | DisableBehaviour("switch_claus") | ||
| 235 | ShowExpression("switch_claus", "surprise") | ||
| 236 | FaceTowardSprite("switch_claus", "lucas") | ||
| 237 | Delay(1000) | ||
| 238 | |||
| 239 | RemoveExpression("switch_claus") | ||
| 240 | |||
| 241 | if gamestate.switch_claus_lost_interest then | ||
| 242 | SetMovementSpeed("switch_claus", 1) | ||
| 243 | StartWandering("switch_claus") | ||
| 244 | else | ||
| 245 | SetMovementSpeed("switch_claus", 2) | ||
| 246 | |||
| 247 | if IsSpriteInZone("switch_claus", "switch_claus_hidden") then | ||
| 248 | MakeSpriteNotSolid("lucas") | ||
| 249 | DirectSpriteToLocation("switch_claus", "switch_claus_rsvp") | ||
| 250 | MakeSpriteSolid("lucas") | ||
| 251 | WaitForSpritePath("switch_claus") | ||
| 252 | end | ||
| 253 | |||
| 254 | if gamestate.switch_claus_lost_interest then | ||
| 255 | SetMovementSpeed("switch_claus", 1) | ||
| 256 | StartWandering("switch_claus") | ||
| 257 | else | ||
| 258 | FollowSprite("switch_claus", "lucas") | ||
| 259 | end | ||
| 260 | end | ||
| 261 | end | ||
| 262 | |||
| 263 | function hallucination_interior.switch_claus_lose_interest() | ||
| 264 | gamestate.switch_claus_lost_interest = true | ||
| 265 | |||
| 266 | SetMovementSpeed("switch_claus", 1) | ||
| 267 | StartWandering("switch_claus") | ||
| 268 | end | ||
| 269 | |||
| 270 | function hallucination_interior.lets_switch_places() | ||
| 271 | -- TODO: let's switch places | ||
| 272 | end | ||
