summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-10 20:09:42 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-10 20:09:42 -0500
commitc25ab2537cb201dc46b7c1d375dd1c12411fe85c (patch)
tree1b96b9054585390abbc99277572a77a3248f2cde
parent05ee221cd31a782b699cc6d62e0d275364cfd7cc (diff)
downloadtanetane-c25ab2537cb201dc46b7c1d375dd1c12411fe85c.tar.gz
tanetane-c25ab2537cb201dc46b7c1d375dd1c12411fe85c.tar.bz2
tanetane-c25ab2537cb201dc46b7c1d375dd1c12411fe85c.zip
Player movement/input is halted during cutscenes
-rw-r--r--res/scripts/common.lua11
-rw-r--r--res/scripts/default.lua2
-rw-r--r--res/scripts/script0001.lua1
-rw-r--r--res/scripts/test_trigger.lua1
-rw-r--r--src/character_system.cpp12
-rw-r--r--src/character_system.h2
-rw-r--r--src/script_system.cpp3
7 files changed, 30 insertions, 2 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 1841662..b540548 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua
@@ -25,6 +25,13 @@ CharacterState = {
25 RUNNING = 3 25 RUNNING = 3
26} 26}
27 27
28function StartCutscene()
29 local playerId = getPlayerSprite()
30 local playerSprite = getSprite(playerId)
31 playerSprite.controllable = false
32 character():halt(playerId)
33end
34
28function DisplayMessage(msg, name, type) 35function DisplayMessage(msg, name, type)
29 message():displayMessage(msg, name, type) 36 message():displayMessage(msg, name, type)
30end 37end
@@ -38,6 +45,10 @@ end
38function HideCutsceneBars() 45function HideCutsceneBars()
39 WaitForEndOfMessage() 46 WaitForEndOfMessage()
40 message():hideCutsceneBars() 47 message():hideCutsceneBars()
48
49 local playerId = getPlayerSprite()
50 local playerSprite = getSprite(playerId)
51 playerSprite.controllable = true
41end 52end
42 53
43function SetAnimation(spriteName, animName) 54function SetAnimation(spriteName, animName)
diff --git a/res/scripts/default.lua b/res/scripts/default.lua index 6188c36..936a543 100644 --- a/res/scripts/default.lua +++ b/res/scripts/default.lua
@@ -1,5 +1,5 @@
1function default() 1function default()
2 StartCutscene()
2 DisplayMessage("No problem here.", "", SpeakerType.NONE) 3 DisplayMessage("No problem here.", "", SpeakerType.NONE)
3 WaitForEndOfMessage()
4 HideCutsceneBars() 4 HideCutsceneBars()
5end 5end
diff --git a/res/scripts/script0001.lua b/res/scripts/script0001.lua index fcf7029..e5078f2 100644 --- a/res/scripts/script0001.lua +++ b/res/scripts/script0001.lua
@@ -1,4 +1,5 @@
1function script0001() 1function script0001()
2 StartCutscene()
2 SetAnimation("boney", "barking") 3 SetAnimation("boney", "barking")
3 local barkingNoise = LoopSound("barking_at_hallucination.wav") 4 local barkingNoise = LoopSound("barking_at_hallucination.wav")
4 5
diff --git a/res/scripts/test_trigger.lua b/res/scripts/test_trigger.lua index cd64fb8..58325e5 100644 --- a/res/scripts/test_trigger.lua +++ b/res/scripts/test_trigger.lua
@@ -1,4 +1,5 @@
1function test_trigger() 1function test_trigger()
2 StartCutscene()
2 PlaySound("boney_growl.wav") 3 PlaySound("boney_growl.wav")
3 DisplayMessage("Hi! Welcome to the funky zone.", "", SpeakerType.NONE) 4 DisplayMessage("Hi! Welcome to the funky zone.", "", SpeakerType.NONE)
4 WaitForEndOfMessage() 5 WaitForEndOfMessage()
diff --git a/src/character_system.cpp b/src/character_system.cpp index 781b50d..aad8c1b 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -248,6 +248,18 @@ void CharacterSystem::stopRunningSound(Sprite& sprite) {
248 } 248 }
249} 249}
250 250
251void CharacterSystem::halt(int spriteId) {
252 // Because special stuff happens when we stop running, we have to handle the
253 // running case here.
254 Sprite& sprite = game_.getSprite(spriteId);
255 if (sprite.characterState == CharacterState::Running) {
256 stopRunning(spriteId);
257 } else {
258 // Other than that, it is simple to go to Still from Walking or Crouching.
259 setPartyState(spriteId, CharacterState::Still);
260 }
261}
262
251void CharacterSystem::clearSpriteCache() { 263void CharacterSystem::clearSpriteCache() {
252 for (Sprite& sprite : game_.getSprites() | game_.spriteView()) { 264 for (Sprite& sprite : game_.getSprites() | game_.spriteView()) {
253 if (sprite.runningSfxChannel != -1) { 265 if (sprite.runningSfxChannel != -1) {
diff --git a/src/character_system.h b/src/character_system.h index 3933e1b..c6d4e6d 100644 --- a/src/character_system.h +++ b/src/character_system.h
@@ -33,6 +33,8 @@ public:
33 33
34 void startRunning(int spriteId); 34 void startRunning(int spriteId);
35 35
36 void halt(int spriteId);
37
36 void clearSpriteCache() override; 38 void clearSpriteCache() override;
37 39
38private: 40private:
diff --git a/src/script_system.cpp b/src/script_system.cpp index 8fd5028..0fa0c1b 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp
@@ -31,7 +31,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
31 31
32 engine_.new_usertype<CharacterSystem>( 32 engine_.new_usertype<CharacterSystem>(
33 "character", 33 "character",
34 "startRunning", &CharacterSystem::startRunning); 34 "startRunning", &CharacterSystem::startRunning,
35 "halt", &CharacterSystem::halt);
35 36
36 engine_.new_usertype<Mixer>( 37 engine_.new_usertype<Mixer>(
37 "mixer", 38 "mixer",