From 065d5dbac17664666d6a83583141d4cdf0bb691c Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 12 Mar 2021 16:41:25 -0500 Subject: Interacting with Kuma and Duster in the finale The hot spring is also a little bigger now, because I'm using an enclosure to keep Lucas in, instead of setting the tiles to being solid or not. #20 --- res/maps/finale.tmx | 3 ++- res/maps/forest.tsx | 71 +++----------------------------------------------- res/scripts/common.lua | 15 +++++++++++ res/scripts/finale.lua | 22 ++++++++++++++++ src/script_system.cpp | 3 ++- 5 files changed, 44 insertions(+), 70 deletions(-) diff --git a/res/maps/finale.tmx b/res/maps/finale.tmx index 5c48c97..be30d18 100644 --- a/res/maps/finale.tmx +++ b/res/maps/finale.tmx @@ -1,5 +1,5 @@ - + @@ -34,6 +34,7 @@ + diff --git a/res/maps/forest.tsx b/res/maps/forest.tsx index bff44a5..633544a 100644 --- a/res/maps/forest.tsx +++ b/res/maps/forest.tsx @@ -1,49 +1,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - + @@ -51,44 +21,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/scripts/common.lua b/res/scripts/common.lua index dbc021c..1d4879f 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua @@ -414,6 +414,14 @@ function SetAnimationSlowdown(spriteName, amount) sprite.animSlowdown = amount end +--- Sets the enclosure zone for a sprite. +-- The sprite will be prevented from exiting the area defined by that zone. +function AddEnclosureZone(spriteName, zone) + local spriteId = getSpriteByAlias(spriteName) + local sprite = getSprite(spriteId) + sprite.enclosureZone = zone +end + --- Removes the enclosure zone for the specified sprite. -- This allows the sprite to move outside of the confines of the zone. function RemoveEnclosureZone(spriteName) @@ -607,3 +615,10 @@ function IsSpriteInZone(spriteName, zoneName) return (pos:x() >= zone.ul:x()) and (pos:x() <= zone.dr:x()) and (pos:y() >= zone.ul:y()) and (pos:y() <= zone.dr:y()) end + +--- Sets the name of the script on the current map that will be executed when the player interacts with this sprite. +function SetInteractionScript(spriteName, scriptName) + local spriteId = getSpriteByAlias(spriteName) + local sprite = getSprite(spriteId) + sprite.interactionScript = scriptName +end diff --git a/res/scripts/finale.lua b/res/scripts/finale.lua index 2493473..7e23336 100644 --- a/res/scripts/finale.lua +++ b/res/scripts/finale.lua @@ -3,15 +3,37 @@ finale = {} function finale.init() character():breakUpParty(getPlayerSprite()) + AddEnclosureZone("lucas", "hotspring_enclosure") + MoveSpriteToWarp("kuma", "kumatora_start") SetDirection("kuma", Direction.UP) SetAnimation("kuma", "swim_still") + MakeSpriteSolid("kuma") + SetInteractionScript("kuma", "talk_to_kuma") MoveSpriteToWarp("duster", "duster_start") SetDirection("duster", Direction.RIGHT) SetAnimation("duster", "swim_still") + MakeSpriteSolid("duster") + SetInteractionScript("duster", "talk_to_duster") MoveSpriteToWarp("boney", "boney_start") SetDirection("boney", Direction.DOWN) SetAnimation("boney", "asleep") end + +function finale.talk_to_kuma() + SetDirection("kuma", Direction.UP) + StartCutscene() + DisplayMessage("* Kumatora doesn't respond.\n\f* She is grumbling to herself, and picking at the grass growing over the wall.", "", SpeakerType.NONE) + WaitForEndOfMessage() + HideCutsceneBars() +end + +function finale.talk_to_duster() + SetDirection("duster", Direction.RIGHT) + StartCutscene() + DisplayMessage("* Duster doesn't respond.\n\f* He is simply staring at his own reflection in the water.", "", SpeakerType.NONE) + WaitForEndOfMessage() + HideCutsceneBars() +end diff --git a/src/script_system.cpp b/src/script_system.cpp index 505957b..b993938 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp @@ -54,7 +54,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { "movementSpeed", &Sprite::movementSpeed, "solid", &Sprite::solid, "behaviourType", &Sprite::behaviourType, - "followSpriteId", &Sprite::followSpriteId); + "followSpriteId", &Sprite::followSpriteId, + "interactionScript", &Sprite::interactionScript); engine_.new_usertype( "message", -- cgit 1.4.1