summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--res/maps/hallucination_mirror.tmx3
-rw-r--r--res/scripts/common.lua10
-rw-r--r--res/scripts/hallucination_mirror.lua22
-rw-r--r--src/script_system.cpp9
4 files changed, 42 insertions, 2 deletions
diff --git a/res/maps/hallucination_mirror.tmx b/res/maps/hallucination_mirror.tmx index a9aadff..1c5eee2 100644 --- a/res/maps/hallucination_mirror.tmx +++ b/res/maps/hallucination_mirror.tmx
@@ -1,5 +1,5 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="48" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="8" nextobjectid="11"> 2<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="48" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="8" nextobjectid="12">
3 <properties> 3 <properties>
4 <property name="maskZone" value="mask"/> 4 <property name="maskZone" value="mask"/>
5 </properties> 5 </properties>
@@ -113,6 +113,7 @@
113 </properties> 113 </properties>
114 <point/> 114 <point/>
115 </object> 115 </object>
116 <object id="11" name="mirror_sight" type="zone" x="176" y="128" width="176" height="48"/>
116 </objectgroup> 117 </objectgroup>
117 <layer id="4" name="Upper" width="48" height="16"> 118 <layer id="4" name="Upper" width="48" height="16">
118 <properties> 119 <properties>
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 2a2ce35..d0ea6b5 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua
@@ -542,3 +542,13 @@ function ExitAreaTransition()
542 effect():circleTransition(1, 0.0) 542 effect():circleTransition(1, 0.0)
543 Delay(1000) 543 Delay(1000)
544end 544end
545
546--- Checks whether a sprite is in a zone.
547-- @param spriteName the name of the sprite to locate
548-- @param zoneName the name of the zone on the current map to use as a boundary
549function IsSpriteInZone(spriteName, zoneName)
550 local pos = GetPosition(spriteName)
551 local zone = getMap():getZone(zoneName)
552
553 return (pos:x() >= zone.ul:x()) and (pos:x() <= zone.dr:x()) and (pos:y() >= zone.ul:y()) and (pos:y() <= zone.dr:y())
554end
diff --git a/res/scripts/hallucination_mirror.lua b/res/scripts/hallucination_mirror.lua index 6e2ef55..bf1faba 100644 --- a/res/scripts/hallucination_mirror.lua +++ b/res/scripts/hallucination_mirror.lua
@@ -1,5 +1,27 @@
1hallucination_mirror = {} 1hallucination_mirror = {}
2 2
3function hallucination_mirror.init()
4 coroutine.yield()
5 -- This routine makes the player's party face the mirror if they are standing
6 -- in front of it for a few (5) seconds. The fact that this has to run
7 -- continuously makes it a bit complicated, and is why we keep checking that
8 -- we're on the same map.
9 while getMap():getName() == "hallucination_mirror" do
10 if IsSpriteInZone("lucas", "mirror_sight") and IsSpriteInZone("kuma", "mirror_sight") and IsSpriteInZone("duster", "mirror_sight") and IsSpriteInZone("boney", "mirror_sight") then
11 timer = 5000 -- milliseconds
12 while timer > 0 and getSprite(getPlayerSprite()).characterState == CharacterState.STILL and getMap():getName() == "hallucination_mirror" do
13 timer = timer - coroutine.yield()
14 end
15
16 if timer <= 0 and getSprite(getPlayerSprite()).characterState == CharacterState.STILL and getMap():getName() == "hallucination_mirror" then
17 SetPartyDirection(getPlayerSprite(), Direction.UP)
18 end
19 end
20
21 coroutine.yield()
22 end
23end
24
3function hallucination_mirror.mailbox() 25function hallucination_mirror.mailbox()
4 StartCutscene() 26 StartCutscene()
5 DisplayMessage("* The mailbox lid is open...\n* Peek inside?", "", SpeakerType.NONE) 27 DisplayMessage("* The mailbox lid is open...\n* Peek inside?", "", SpeakerType.NONE)
diff --git a/src/script_system.cpp b/src/script_system.cpp index 3325b79..50ea60a 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp
@@ -22,6 +22,11 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
22 "x", [] (const vec2i& v) { return v.x(); }, 22 "x", [] (const vec2i& v) { return v.x(); },
23 "y", [] (const vec2i& v) { return v.y(); }); 23 "y", [] (const vec2i& v) { return v.y(); });
24 24
25 engine_.new_usertype<Zone>(
26 "zone",
27 "ul", &Zone::ul,
28 "dr", &Zone::dr);
29
25 engine_.new_usertype<SpriteFrame>( 30 engine_.new_usertype<SpriteFrame>(
26 "spriteframe", 31 "spriteframe",
27 "center", &SpriteFrame::center, 32 "center", &SpriteFrame::center,
@@ -117,9 +122,11 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
117 122
118 engine_.new_usertype<Map>( 123 engine_.new_usertype<Map>(
119 "map", 124 "map",
125 "getName", &Map::getName,
120 "getWarpPoint", &Map::getWarpPoint, 126 "getWarpPoint", &Map::getWarpPoint,
121 "hasMusic", &Map::hasMusic, 127 "hasMusic", &Map::hasMusic,
122 "getMusic", &Map::getMusic); 128 "getMusic", &Map::getMusic,
129 "getZone", &Map::getZone);
123 130
124 engine_.set_function( 131 engine_.set_function(
125 "message", 132 "message",