summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--res/maps/hallucination_interior.tmx1
-rw-r--r--res/scripts/hallucination_interior.lua7
-rw-r--r--src/character_system.cpp17
-rw-r--r--src/game.cpp3
-rw-r--r--src/main.cpp3
-rw-r--r--src/map.cpp2
-rw-r--r--src/map.h1
-rw-r--r--src/sprite.h2
8 files changed, 35 insertions, 1 deletions
diff --git a/res/maps/hallucination_interior.tmx b/res/maps/hallucination_interior.tmx index 7e012eb..1077cf5 100644 --- a/res/maps/hallucination_interior.tmx +++ b/res/maps/hallucination_interior.tmx
@@ -159,6 +159,7 @@
159 <object id="7" name="switch_claus" type="sprite" x="864" y="784"> 159 <object id="7" name="switch_claus" type="sprite" x="864" y="784">
160 <properties> 160 <properties>
161 <property name="animation" value="claus"/> 161 <property name="animation" value="claus"/>
162 <property name="bumpPlayerScript" value="lets_switch_places"/>
162 <property name="enclosureZone" value="switch_claus_enclosure"/> 163 <property name="enclosureZone" value="switch_claus_enclosure"/>
163 <property name="interactionScript" value="lets_switch_places"/> 164 <property name="interactionScript" value="lets_switch_places"/>
164 <property name="movementSpeed" type="int" value="1"/> 165 <property name="movementSpeed" type="int" value="1"/>
diff --git a/res/scripts/hallucination_interior.lua b/res/scripts/hallucination_interior.lua index 96b90a6..c265a46 100644 --- a/res/scripts/hallucination_interior.lua +++ b/res/scripts/hallucination_interior.lua
@@ -270,6 +270,7 @@ end
270function hallucination_interior.lets_switch_places() 270function hallucination_interior.lets_switch_places()
271 StartCutscene() 271 StartCutscene()
272 272
273 FaceTowardSprite("switch_claus", "lucas")
273 FacePartyTowardSprite("lucas", "switch_claus") 274 FacePartyTowardSprite("lucas", "switch_claus")
274 Halt("switch_claus") 275 Halt("switch_claus")
275 SetAnimation("switch_claus", "talk") 276 SetAnimation("switch_claus", "talk")
@@ -280,9 +281,13 @@ function hallucination_interior.lets_switch_places()
280 281
281 if GetChoiceSelection() == 0 then 282 if GetChoiceSelection() == 0 then
282 DisplayMessage("* You'd like that, wouldn't you?\n\f* ...no. That's too easy.\n\fI'm not letting you off that easy.\n\f* It should've been you, right?\nYou feel guilty, right?\n\f* Well guess what, Lucas?\n\fYou're going to live with that for the rest of your life.\n\f* You know why?\n\f* Because you're going to live, Lucas!\n\fYOU'RE. GOING. TO. LIVE!", "Claus", SpeakerType.MAN) 283 DisplayMessage("* You'd like that, wouldn't you?\n\f* ...no. That's too easy.\n\fI'm not letting you off that easy.\n\f* It should've been you, right?\nYou feel guilty, right?\n\f* Well guess what, Lucas?\n\fYou're going to live with that for the rest of your life.\n\f* You know why?\n\f* Because you're going to live, Lucas!\n\fYOU'RE. GOING. TO. LIVE!", "Claus", SpeakerType.MAN)
283 SetAnimation("switch_claus", "still")
284 HideCutsceneBars() 284 HideCutsceneBars()
285
286 SetAnimation("switch_claus", "still")
285 else 287 else
286 -- TODO: let's switch places 288 -- TODO: let's switch places
287 end 289 end
290
291 -- Just so we can get away, for now.
292 hallucination_interior.switch_claus_lose_interest()
288end 293end
diff --git a/src/character_system.cpp b/src/character_system.cpp index 48d2a33..548bd9d 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -18,6 +18,7 @@ void CharacterSystem::addSpriteToParty(int leaderId, int followerId) {
18 Sprite& leader = game_.getSprite(leaderId); 18 Sprite& leader = game_.getSprite(leaderId);
19 Sprite& follower = game_.getSprite(followerId); 19 Sprite& follower = game_.getSprite(followerId);
20 follower.orientable = false; 20 follower.orientable = false;
21 follower.leaderId = leaderId;
21 22
22 vec2i targetPos = leader.loc; 23 vec2i targetPos = leader.loc;
23 24
@@ -83,6 +84,7 @@ void CharacterSystem::breakUpParty(int leaderId) {
83 for (int followerId : followers) { 84 for (int followerId : followers) {
84 Sprite& follower = game_.getSprite(followerId); 85 Sprite& follower = game_.getSprite(followerId);
85 follower.trail.clear(); 86 follower.trail.clear();
87 follower.leaderId = -1;
86 } 88 }
87} 89}
88 90
@@ -153,6 +155,7 @@ void CharacterSystem::tick(double dt) {
153 // Check collision. 155 // Check collision.
154 CollisionResult collision = game_.getSystem<TransformSystem>().checkCollision(spriteId, sprite.loc, pLoc, sprite.movementDir); 156 CollisionResult collision = game_.getSystem<TransformSystem>().checkCollision(spriteId, sprite.loc, pLoc, sprite.movementDir);
155 bool blocked = collision.horiz.blocked || collision.vert.blocked; 157 bool blocked = collision.horiz.blocked || collision.vert.blocked;
158 int colliderSpriteId = (collision.horiz.colliderSprite == -1) ? collision.vert.colliderSprite : collision.horiz.colliderSprite;
156 159
157 if (collision.horiz.blocked && !sprite.clipping) { 160 if (collision.horiz.blocked && !sprite.clipping) {
158 pLoc.x() = sprite.loc.x();//(newColPosDR * map.getTileSize() - (collisionBox / 2)).x() - 1; 161 pLoc.x() = sprite.loc.x();//(newColPosDR * map.getTileSize() - (collisionBox / 2)).x() - 1;
@@ -179,6 +182,20 @@ void CharacterSystem::tick(double dt) {
179 game_.getMixer().playSound("../res/sfx/bump.wav"); 182 game_.getMixer().playSound("../res/sfx/bump.wav");
180 } 183 }
181 184
185 if (colliderSpriteId != -1 && !sprite.bumpPlayerScript.empty()) {
186 Sprite& collider = game_.getSprite(colliderSpriteId);
187 bool bumpedPlayer = collider.player;
188
189 if (!bumpedPlayer && collider.leaderId != -1) {
190 Sprite& colliderLeader = game_.getSprite(collider.leaderId);
191 bumpedPlayer = colliderLeader.player;
192 }
193
194 if (bumpedPlayer) {
195 game_.getSystem<ScriptSystem>().runScript(game_.getMap().getName(), sprite.bumpPlayerScript);
196 }
197 }
198
182 // Move everything 199 // Move everything
183 if (pLoc != sprite.loc) { 200 if (pLoc != sprite.loc) {
184 game_.getSystem<TransformSystem>().moveSprite(spriteId, pLoc); 201 game_.getSystem<TransformSystem>().moveSprite(spriteId, pLoc);
diff --git a/src/game.cpp b/src/game.cpp index bedd934..80ff506 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -72,6 +72,9 @@ void Game::loadMap(std::string filename) {
72 if (p.wander) { 72 if (p.wander) {
73 getSprite(spriteId).behaviourType = BehaviourType::Wander; 73 getSprite(spriteId).behaviourType = BehaviourType::Wander;
74 } 74 }
75 if (!p.bumpPlayerScript.empty()) {
76 getSprite(spriteId).bumpPlayerScript = p.bumpPlayerScript;
77 }
75 } 78 }
76 if (!p.enclosureZone.empty()) { 79 if (!p.enclosureZone.empty()) {
77 getSprite(spriteId).enclosureZone = p.enclosureZone; 80 getSprite(spriteId).enclosureZone = p.enclosureZone;
diff --git a/src/main.cpp b/src/main.cpp index 9cc25bb..051c4d1 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -48,6 +48,7 @@ void loop(Renderer& renderer, std::mt19937& rng) {
48 48
49 int kumaSprite = game.emplaceSprite("kuma"); 49 int kumaSprite = game.emplaceSprite("kuma");
50 game.getSystem<TransformSystem>().initSprite(kumaSprite, warpLoc); 50 game.getSystem<TransformSystem>().initSprite(kumaSprite, warpLoc);
51 game.getSystem<TransformSystem>().setUpCollision(kumaSprite, {-8, -8}, {12, 8}, false);
51 game.getSystem<AnimationSystem>().initSprite(kumaSprite, "../res/sprites/kuma_anim.txt"); 52 game.getSystem<AnimationSystem>().initSprite(kumaSprite, "../res/sprites/kuma_anim.txt");
52 game.getSystem<AnimationSystem>().setSpriteDirection(kumaSprite, Direction::down); 53 game.getSystem<AnimationSystem>().setSpriteDirection(kumaSprite, Direction::down);
53 game.getSprite(kumaSprite).normallyHasShadow = true; 54 game.getSprite(kumaSprite).normallyHasShadow = true;
@@ -56,6 +57,7 @@ void loop(Renderer& renderer, std::mt19937& rng) {
56 57
57 int dusterSprite = game.emplaceSprite("duster"); 58 int dusterSprite = game.emplaceSprite("duster");
58 game.getSystem<TransformSystem>().initSprite(dusterSprite, warpLoc); 59 game.getSystem<TransformSystem>().initSprite(dusterSprite, warpLoc);
60 game.getSystem<TransformSystem>().setUpCollision(dusterSprite, {-8, -8}, {12, 8}, false);
59 game.getSystem<AnimationSystem>().initSprite(dusterSprite, "../res/sprites/duster_anim.txt"); 61 game.getSystem<AnimationSystem>().initSprite(dusterSprite, "../res/sprites/duster_anim.txt");
60 game.getSystem<AnimationSystem>().setSpriteDirection(dusterSprite, Direction::down); 62 game.getSystem<AnimationSystem>().setSpriteDirection(dusterSprite, Direction::down);
61 game.getSprite(dusterSprite).normallyHasShadow = true; 63 game.getSprite(dusterSprite).normallyHasShadow = true;
@@ -64,6 +66,7 @@ void loop(Renderer& renderer, std::mt19937& rng) {
64 66
65 int boneySprite = game.emplaceSprite("boney"); 67 int boneySprite = game.emplaceSprite("boney");
66 game.getSystem<TransformSystem>().initSprite(boneySprite, warpLoc); 68 game.getSystem<TransformSystem>().initSprite(boneySprite, warpLoc);
69 game.getSystem<TransformSystem>().setUpCollision(boneySprite, {-8, -8}, {12, 8}, false);
67 game.getSystem<AnimationSystem>().initSprite(boneySprite, "../res/sprites/boney_anim.txt"); 70 game.getSystem<AnimationSystem>().initSprite(boneySprite, "../res/sprites/boney_anim.txt");
68 game.getSystem<AnimationSystem>().setSpriteDirection(boneySprite, Direction::down); 71 game.getSystem<AnimationSystem>().setSpriteDirection(boneySprite, Direction::down);
69 game.getSprite(boneySprite).normallyHasShadow = true; 72 game.getSprite(boneySprite).normallyHasShadow = true;
diff --git a/src/map.cpp b/src/map.cpp index 32203e5..a170288 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -119,6 +119,8 @@ Map::Map(std::string_view name) : name_(name) {
119 p.mirrorAxis = property.getIntValue(); 119 p.mirrorAxis = property.getIntValue();
120 } else if (property.getName() == "mirrorSprite") { 120 } else if (property.getName() == "mirrorSprite") {
121 p.spriteToMirror = property.getStringValue(); 121 p.spriteToMirror = property.getStringValue();
122 } else if (property.getName() == "bumpPlayerScript") {
123 p.bumpPlayerScript = property.getStringValue();
122 } 124 }
123 } 125 }
124 126
diff --git a/src/map.h b/src/map.h index eb926c7..9418aad 100644 --- a/src/map.h +++ b/src/map.h
@@ -27,6 +27,7 @@ struct Prototype {
27 std::string animName; 27 std::string animName;
28 Direction dir = Direction::down; 28 Direction dir = Direction::down;
29 std::string interactionScript; 29 std::string interactionScript;
30 std::string bumpPlayerScript;
30 bool shadow = false; 31 bool shadow = false;
31 bool wander = false; 32 bool wander = false;
32 int movementSpeed = -1; 33 int movementSpeed = -1;
diff --git a/src/sprite.h b/src/sprite.h index 10dd3a8..f631652 100644 --- a/src/sprite.h +++ b/src/sprite.h
@@ -81,6 +81,7 @@ public:
81 vec2i collisionSize; 81 vec2i collisionSize;
82 std::string interactionScript; 82 std::string interactionScript;
83 std::string walkthroughScript; 83 std::string walkthroughScript;
84 std::string bumpPlayerScript;
84 std::string enclosureZone; 85 std::string enclosureZone;
85 86
86 // Animation (internals) 87 // Animation (internals)
@@ -109,6 +110,7 @@ public:
109 bool orientable = false; 110 bool orientable = false;
110 int movementSpeed = 0; // 1 is slow (good for NPCs), 2 is Lucas's default walking speed 111 int movementSpeed = 0; // 1 is slow (good for NPCs), 2 is Lucas's default walking speed
111 std::vector<int> followers; 112 std::vector<int> followers;
113 int leaderId = -1;
112 std::deque<Movement> trail; 114 std::deque<Movement> trail;
113 bool trailsAreHalved = false; 115 bool trailsAreHalved = false;
114 CharacterState characterState = CharacterState::Still; 116 CharacterState characterState = CharacterState::Still;