Skip to content

Commit 9c3b23a

Browse files
committed
potion landing effects
1 parent 07ba10e commit 9c3b23a

11 files changed

Lines changed: 120 additions & 76 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ Sound effects
2626
- Nethervoid ambience [found here](https://freesound.org/people/Sonicfreak/)
2727
- Graveyard ambience [found here](https://freesound.org/people/phoenixsoftware/)
2828
- Underhell ambience [found here](https://freesound.org/people/looplicator/)
29+
- Shatter sound [found here](https://freesound.org/people/ccen18/sounds/686849/)

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
bugs
22
----
33
throwing potions
4-
smashing potion sound
54
thing_clone
65
item thrown onto exit
76
item thrown onto water

data/sounds.tgz

10.5 KB
Binary file not shown.

src/sounds.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ void sounds_load(Gamep g)
1414
(void) sound_load(0.2F, "data/sounds/interface/mouse_click.ogg", "click");
1515
(void) sound_load(0.5F, "data/sounds/interface/error.ogg", "error");
1616
(void) sound_load(1.0F, "data/sounds/impacts/player_oof.ogg", "player_oof");
17+
(void) sound_load(1.0F, "data/sounds/impacts/glass_shatter.ogg", "glass_shatter");
1718
(void) sound_load(1.0F, "data/sounds/impacts/player_hit.ogg", "player_hit");
1819
(void) sound_load(1.0F, "data/sounds/impacts/player_ouch.ogg", "player_ouch");
1920
(void) sound_load(1.0F, "data/sounds/impacts/monst_death.ogg", "monst_death");

src/thing_fall.cpp

Lines changed: 76 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
// Try to find a spot close to where we landed that is ok to exist in.
4141
// i.e. no landing inside walls.
4242
//
43-
static auto thing_choose_landing_spot(Gamep g, Levelsp v, Levelp l, Thingp t) -> bpoint
43+
static auto thing_choose_landing_spot(Gamep g, Levelsp v, Levelp l, Thingp me) -> bpoint
4444
{
4545
TRACE();
4646

47-
auto at = thing_at(t);
47+
auto at = thing_at(me);
4848
int dist = 1;
4949

5050
for (;;) {
@@ -73,55 +73,55 @@ static auto thing_choose_landing_spot(Gamep g, Levelsp v, Levelp l, Thingp t) ->
7373
//
7474
// How much damage does the thing take on falling.
7575
//
76-
static auto thing_fall_damage(Gamep g, Levelsp v, Levelp l, Thingp t) -> int
76+
static auto thing_fall_damage(Gamep g, Levelsp v, Levelp l, Thingp me) -> int
7777
{
7878
TRACE();
7979

8080
int fall_dmg = 0;
8181

82-
if (thing_is_player(t)) {
82+
if (thing_is_player(me)) {
8383
fall_dmg = PCG_RANDOM_RANGE(6, 30);
84-
} else if (thing_is_mob(t) || thing_is_monst(t)) {
85-
fall_dmg = PCG_RANDOM_RANGE(6, thing_health(g, v, l, t) / 2);
84+
} else if (thing_is_mob(me) || thing_is_monst(me)) {
85+
fall_dmg = PCG_RANDOM_RANGE(6, thing_health(g, v, l, me) / 2);
8686
} else {
8787
fall_dmg = d4();
8888
}
8989

90-
if (thing_is_falling_continues(t)) {
90+
if (thing_is_falling_continues(me)) {
9191
fall_dmg *= 2;
9292
}
9393

9494
//
9595
// Landing in lava is bad
9696
//
97-
if (level_is_lava(g, v, l, thing_at(t)) != nullptr) {
98-
if (! thing_is_immune_to(g, v, l, t, THING_EVENT_FIRE_DAMAGE)) {
97+
if (level_is_lava(g, v, l, thing_at(me)) != nullptr) {
98+
if (! thing_is_immune_to(g, v, l, me, THING_EVENT_FIRE_DAMAGE)) {
9999
fall_dmg *= 4;
100100
}
101101
}
102102

103103
//
104104
// Water dampens the fall
105105
//
106-
if (level_is_water(g, v, l, thing_at(t)) != nullptr) {
107-
if (thing_is_immune_to(g, v, l, t, THING_EVENT_WATER_DAMAGE)) {
106+
if (level_is_water(g, v, l, thing_at(me)) != nullptr) {
107+
if (thing_is_immune_to(g, v, l, me, THING_EVENT_WATER_DAMAGE)) {
108108
fall_dmg /= 2;
109109
}
110110
}
111111

112112
//
113113
// Deep water dampens it further
114114
//
115-
if (level_is_deep_water(g, v, l, thing_at(t)) != nullptr) {
116-
if (thing_is_immune_to(g, v, l, t, THING_EVENT_WATER_DAMAGE)) {
115+
if (level_is_deep_water(g, v, l, thing_at(me)) != nullptr) {
116+
if (thing_is_immune_to(g, v, l, me, THING_EVENT_WATER_DAMAGE)) {
117117
fall_dmg /= 2;
118118
}
119119
}
120120

121121
//
122122
// Amplify or nullify due to weight
123123
//
124-
auto w = thing_weight(t);
124+
auto w = thing_weight(me);
125125
if (w <= WEIGHT_FEATHER) {
126126
fall_dmg = 0;
127127
} else if (w >= WEIGHT_HEAVY) {
@@ -134,35 +134,42 @@ static auto thing_fall_damage(Gamep g, Levelsp v, Levelp l, Thingp t) -> int
134134
//
135135
// Complete the fall to the next level. If this is the player we also change level.
136136
//
137-
static void thing_fall_end(Gamep g, Levelsp v, Levelp l, Thingp t)
137+
static void thing_fall_end(Gamep g, Levelsp v, Levelp l, Thingp me)
138138
{
139-
THING_DBG(t, "fall end");
139+
THING_DBG(me, "fall end");
140140
TRACE_INDENT();
141141

142142
auto *next_level = level_select_get_next_level_down(g, v, l);
143143
if (next_level == nullptr) {
144144
if (g_opt_tests) {
145-
THING_DBG(t, "no level to fall onto");
145+
THING_DBG(me, "no level to fall onto");
146146
} else {
147-
thing_err(t, "no level to fall onto");
147+
thing_err(me, "no level to fall onto");
148148
}
149149
return;
150150
}
151151

152152
if (next_level == l) {
153153
ThingEvent e {
154-
.reason = "by falling into nothing", //
155-
.event_type = THING_EVENT_FALL, //
156-
.damage = thing_fall_damage(g, v, l, t), //
154+
.reason = "by falling into nothing", //
155+
.event_type = THING_EVENT_FALL, //
156+
.damage = thing_fall_damage(g, v, l, me), //
157157
};
158158

159-
THING_DBG(t, "dead due to falling into nothing");
159+
THING_DBG(me, "dead due to falling into nothing");
160160
TRACE_INDENT();
161161

162-
thing_dead(g, v, l, t, e);
162+
thing_dead(g, v, l, me, e);
163163
return;
164164
}
165165

166+
//
167+
// Splash!
168+
//
169+
if (level_is_water(g, v, l, thing_at(me))) {
170+
thing_sound_play(g, v, l, me, "splash");
171+
}
172+
166173
//
167174
// You cannot fall out of boss levels
168175
//
@@ -174,7 +181,7 @@ static void thing_fall_end(Gamep g, Levelsp v, Levelp l, Thingp t)
174181
//
175182
// Choose a new landing spot for the thing
176183
//
177-
if (! thing_warp_to(g, v, next_level, t, thing_choose_landing_spot(g, v, next_level, t))) {
184+
if (! thing_warp_to(g, v, next_level, me, thing_choose_landing_spot(g, v, next_level, me))) {
178185
topcon("You fail to find the ground!");
179186
}
180187
break;
@@ -195,71 +202,71 @@ static void thing_fall_end(Gamep g, Levelsp v, Levelp l, Thingp t)
195202
// Ensure we always land at the entrance for boss levels
196203
//
197204
if (level_is_boss_level(g, v, next_level)) {
198-
thing_level_warp_to_entrance(g, v, next_level, t);
205+
thing_level_warp_to_entrance(g, v, next_level, me);
199206
}
200207

201-
if (thing_is_player(t)) {
208+
if (thing_is_player(me)) {
202209
level_scroll_warp_to_focus(g, v, l);
203210
}
204211

205212
ThingEvent e {
206-
.reason = "by falling", //
207-
.event_type = THING_EVENT_FALL, //
208-
.damage = thing_fall_damage(g, v, l, t), //
213+
.reason = "by falling", //
214+
.event_type = THING_EVENT_FALL, //
215+
.damage = thing_fall_damage(g, v, l, me), //
209216
};
210217

211218
//
212219
// "You tumble into the vuid"
213220
//
214-
if (thing_is_player(t)) {
215-
player_fell(g, v, l, next_level, t);
221+
if (thing_is_player(me)) {
222+
player_fell(g, v, l, next_level, me);
216223
}
217224

218-
auto *t_level = game_level_get(g, v, t->level_num);
225+
auto *t_level = game_level_get(g, v, me->level_num);
219226
if (t_level != nullptr) {
220227
l = t_level;
221228
} else {
222-
thing_err(t, "fell into nothing");
229+
thing_err(me, "fell into nothing");
223230
}
224231

225-
if (level_is_chasm(g, v, t_level, thing_at(t)) != nullptr) {
232+
if (level_is_chasm(g, v, t_level, thing_at(me)) != nullptr) {
226233
//
227234
// If we keep on falling through chasms again and again though,
228235
// we need to break the potential fall loop.
229236
//
230-
if (thing_is_falling_continues(t)) {
231-
if (! thing_is_able_to_fall_repeatedly(t)) {
237+
if (thing_is_falling_continues(me)) {
238+
if (! thing_is_able_to_fall_repeatedly(me)) {
232239
e.reason = "repeated falling";
233240

234-
THING_DBG(t, "dead due to repeated falling");
241+
THING_DBG(me, "dead due to repeated falling");
235242
TRACE_INDENT();
236243

237-
thing_dead(g, v, l, t, e);
244+
thing_dead(g, v, l, me, e);
238245
}
239246
}
240247

241248
//
242249
// Keep falling with no damage if over a chasm.
243250
//
244-
THING_DBG(t, "over a chasm again; keep falling");
251+
THING_DBG(me, "over a chasm again; keep falling");
245252
TRACE_INDENT();
246-
thing_is_falling_continues_set(g, v, l, t);
247-
thing_is_spawned_set(g, v, l, t);
253+
thing_is_falling_continues_set(g, v, l, me);
254+
thing_is_spawned_set(g, v, l, me);
248255
} else {
249256
//
250257
// "You take n damage from falling"
251258
//
252-
thing_damage(g, v, l, t, e);
253-
thing_is_falling_continues_unset(g, v, l, t);
259+
thing_damage(g, v, l, me, e);
260+
thing_is_falling_continues_unset(g, v, l, me);
254261
}
255262

256263
//
257264
// Falling can be good
258265
//
259-
if (thing_is_burning(t)) {
260-
thing_is_burning_unset(g, v, l, t);
266+
if (thing_is_burning(me)) {
267+
thing_is_burning_unset(g, v, l, me);
261268

262-
if (thing_is_player(t)) {
269+
if (thing_is_player(me)) {
263270
topcon(UI_GOOD_FMT_STR "You extinguish the flames as you fall!" UI_RESET_FMT);
264271
}
265272
}
@@ -268,33 +275,33 @@ static void thing_fall_end(Gamep g, Levelsp v, Levelp l, Thingp t)
268275
//
269276
// Falling time step
270277
//
271-
void thing_fall_time_step(Gamep g, Levelsp v, Levelp l, Thingp t, int time_step)
278+
void thing_fall_time_step(Gamep g, Levelsp v, Levelp l, Thingp me, int time_step)
272279
{
273280
TRACE();
274281

275-
(void) thing_is_falling_incr(g, v, l, t, time_step);
282+
(void) thing_is_falling_incr(g, v, l, me, time_step);
276283

277284
if (compiler_unused) {
278-
THING_DBG(t, "fall incr %u", thing_is_falling(t));
285+
THING_DBG(me, "fall incr %u", thing_is_falling(me));
279286
}
280287
}
281288

282289
//
283290
// Check if we're done falling
284291
//
285-
void thing_fall_end_check(Gamep g, Levelsp v, Levelp l, Thingp t)
292+
void thing_fall_end_check(Gamep g, Levelsp v, Levelp l, Thingp me)
286293
{
287294
TRACE();
288295

289296
if (compiler_unused) {
290-
THING_DBG(t, "fall %u", thing_is_falling(t));
297+
THING_DBG(me, "fall %u", thing_is_falling(me));
291298
TRACE_INDENT();
292299
}
293300

294301
//
295302
// Fallen for long enough?
296303
//
297-
bool fall_finished = thing_is_falling(t) >= THING_FALL_ANIM_MS;
304+
bool fall_finished = thing_is_falling(me) >= THING_FALL_ANIM_MS;
298305

299306
//
300307
// If the player cannot see the thing fall, then complete the fall to avoid
@@ -303,8 +310,8 @@ void thing_fall_end_check(Gamep g, Levelsp v, Levelp l, Thingp t)
303310
if (! fall_finished) {
304311
auto *player = thing_player(g);
305312
if (player != nullptr) {
306-
if (t != player) {
307-
if (! thing_vision_can_see_tile(g, v, l, player, thing_at(t))) {
313+
if (me != player) {
314+
if (! thing_vision_can_see_tile(g, v, l, player, thing_at(me))) {
308315
fall_finished = true;
309316
}
310317
}
@@ -315,27 +322,27 @@ void thing_fall_end_check(Gamep g, Levelsp v, Levelp l, Thingp t)
315322
// Fall complete?
316323
//
317324
if (fall_finished) {
318-
thing_fall_end(g, v, l, t);
325+
thing_fall_end(g, v, l, me);
319326

320-
auto *t_level = game_level_get(g, v, t->level_num);
327+
auto *t_level = game_level_get(g, v, me->level_num);
321328
if (t_level == nullptr) {
322-
thing_err(t, "fell into nothing");
329+
thing_err(me, "fell into nothing");
323330
}
324331

325-
thing_is_falling_set(g, v, t_level, t, false);
332+
thing_is_falling_set(g, v, t_level, me, false);
326333

327-
if (thing_is_player(t)) {
328-
if (level_is_chasm(g, v, t_level, thing_at(t)) != nullptr) {
329-
THING_DBG(t, "fell again");
334+
if (thing_is_player(me)) {
335+
if (level_is_chasm(g, v, t_level, thing_at(me)) != nullptr) {
336+
THING_DBG(me, "fell again");
330337
TRACE_INDENT();
331338
(void) level_tick_begin_requested(g, v, t_level, "player fell again");
332339
}
333340

334341
//
335342
// This seems rather cruel, but...
336343
//
337-
if (level_is_lava(g, v, t_level, thing_at(t)) != nullptr) {
338-
THING_DBG(t, "fell into lava");
344+
if (level_is_lava(g, v, t_level, thing_at(me)) != nullptr) {
345+
THING_DBG(me, "fell into lava");
339346
TRACE_INDENT();
340347
(void) level_tick_begin_requested(g, v, t_level, "player fell into lava");
341348
}
@@ -346,25 +353,25 @@ void thing_fall_end_check(Gamep g, Levelsp v, Levelp l, Thingp t)
346353
//
347354
// Begin falling
348355
//
349-
void thing_fall(Gamep g, Levelsp v, Levelp l, Thingp t)
356+
void thing_fall(Gamep g, Levelsp v, Levelp l, Thingp me)
350357
{
351358
TRACE();
352359

353360
//
354361
// Fall at the end of the move, or it just looks odd with things falling
355362
// through the floor before they get to the chasm
356363
//
357-
if (thing_is_moving(t)) {
364+
if (thing_is_moving(me)) {
358365
return;
359366
}
360367

361-
if (! thing_is_able_to_fall(t)) {
368+
if (! thing_is_able_to_fall(me)) {
362369
return;
363370
}
364371

365-
if (thing_is_able_to_fall_sound(t)) {
366-
thing_sound_play(g, v, l, t, "fall");
372+
if (thing_is_able_to_fall_sound(me)) {
373+
thing_sound_play(g, v, l, me, "fall");
367374
}
368375

369-
thing_is_falling_set(g, v, l, t, true);
376+
thing_is_falling_set(g, v, l, me, true);
370377
}

src/thing_jump.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ void thing_is_jumping_set(Gamep g, Levelsp v, Levelp l, Thingp me, bool val)
3737
thing_on_jump_begin(g, v, l, me);
3838
} else {
3939
thing_on_jump_end(g, v, l, me);
40+
41+
//
42+
// Splash!
43+
//
44+
if (level_is_water(g, v, l, thing_at(me))) {
45+
thing_sound_play(g, v, l, me, "splash");
46+
}
4047
}
4148
}
4249

0 commit comments

Comments
 (0)