TRX/src/game/effect_routines/bubbles.c

47 lines
1.2 KiB
C
Raw Normal View History

2022-03-24 15:05:44 +01:00
#include "game/effect_routines/bubbles.h"
2022-05-14 11:40:28 +02:00
#include "game/collide.h"
2022-05-05 11:56:29 +02:00
#include "game/effects.h"
2022-03-24 15:05:44 +01:00
#include "game/random.h"
#include "game/sound.h"
#include "global/const.h"
2022-03-24 15:05:44 +01:00
#include "global/vars.h"
#include <stdint.h>
2024-09-24 00:09:15 +02:00
void FX_Bubbles(ITEM *item)
2022-03-24 15:05:44 +01:00
{
// XXX: until we get Robolara, it makes sense for her to breathe underwater
if (g_Lara.water_status == LWS_CHEAT
&& !(g_RoomInfo[g_LaraItem->room_num].flags & RF_UNDERWATER)) {
2022-03-24 15:05:44 +01:00
return;
}
int32_t count = (Random_GetDraw() * 3) / 0x8000;
if (!count) {
return;
}
Sound_Effect(SFX_LARA_BUBBLES, &item->pos, SPM_UNDERWATER);
XYZ_32 offset = {
.x = 0,
.y = 0,
.z = 50,
};
2022-05-14 11:40:28 +02:00
Collide_GetJointAbsPosition(item, &offset, LM_HEAD);
2022-03-24 15:05:44 +01:00
for (int i = 0; i < count; i++) {
int16_t fx_num = Effect_Create(item->room_num);
2022-03-24 15:05:44 +01:00
if (fx_num != NO_ITEM) {
2024-09-24 00:09:15 +02:00
FX *fx = &g_Effects[fx_num];
2022-03-24 15:05:44 +01:00
fx->pos.x = offset.x;
fx->pos.y = offset.y;
fx->pos.z = offset.z;
2024-09-13 21:52:16 +02:00
fx->object_id = O_BUBBLES_1;
fx->frame_num = -((Random_GetDraw() * 3) / 0x8000);
2022-03-24 15:05:44 +01:00
fx->speed = 10 + ((Random_GetDraw() * 6) / 0x8000);
}
}
}