tr2/effects: fix spawning air bubbles in fly state

Resolves #2115.
This commit is contained in:
Marcin Kurczewski 2024-12-30 12:25:49 +01:00
parent 96169fcdee
commit 87eab42c8b
5 changed files with 28 additions and 21 deletions

View file

@ -22,6 +22,7 @@
- fixed some enemies not looking at Lara (#2080, regression from 0.6)
- fixed the camera getting stuck at the start of Home Sweet Home (#2129, regression from 0.7)
- fixed assault course timer not paused in the inventory (#2153, regression from 0.6)
- fixed Lara spawning air bubbles above water surfaces during the fly cheat (#2115, regression from 0.3)
- improved the animation of Lara's braid (#2094)
## [0.7.1](https://github.com/LostArtefacts/TRX/compare/tr2-0.7...tr2-0.7.1) - 2024-12-17

View file

@ -1,17 +1,14 @@
#include "game/item_actions/bubbles.h"
#include "game/collide.h"
#include "game/effects.h"
#include "game/random.h"
#include "game/sound.h"
#include "global/const.h"
#include "game/spawn.h"
#include "global/vars.h"
#include <stdint.h>
void ItemAction_Bubbles(ITEM *item)
{
// XXX: until we get Robolara, it makes sense for her to breathe underwater
// 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)) {
return;
@ -24,23 +21,10 @@ void ItemAction_Bubbles(ITEM *item)
Sound_Effect(SFX_LARA_BUBBLES, &item->pos, SPM_UNDERWATER);
XYZ_32 offset = {
.x = 0,
.y = 0,
.z = 50,
};
XYZ_32 offset = { .x = 0, .y = 0, .z = 50 };
Collide_GetJointAbsPosition(item, &offset, LM_HEAD);
for (int i = 0; i < count; i++) {
int16_t effect_num = Effect_Create(item->room_num);
if (effect_num != NO_EFFECT) {
EFFECT *effect = Effect_Get(effect_num);
effect->pos.x = offset.x;
effect->pos.y = offset.y;
effect->pos.z = offset.z;
effect->object_id = O_BUBBLES_1;
effect->frame_num = -((Random_GetDraw() * 3) / 0x8000);
effect->speed = 10 + ((Random_GetDraw() * 6) / 0x8000);
}
for (int32_t i = 0; i < count; i++) {
Spawn_Bubble(&offset, item->room_num);
}
}

View file

@ -34,6 +34,20 @@ void M_ShootAtLara(EFFECT *effect)
effect->rot.y += (Random_GetControl() - 0x4000) / 0x40;
}
void Spawn_Bubble(const XYZ_32 *const pos, const int16_t room_num)
{
const int16_t effect_num = Effect_Create(room_num);
if (effect_num == NO_EFFECT) {
return;
}
EFFECT *const effect = Effect_Get(effect_num);
effect->pos = *pos;
effect->object_id = O_BUBBLES_1;
effect->frame_num = -((Random_GetDraw() * 3) / 0x8000);
effect->speed = 10 + ((Random_GetDraw() * 6) / 0x8000);
}
void Spawn_Splash(ITEM *item)
{
int16_t wh = Room_GetWaterHeight(

View file

@ -4,6 +4,8 @@
void Spawn_Splash(ITEM *item);
void Spawn_Bubble(const XYZ_32 *pos, int16_t room_num);
int16_t Spawn_Blood(
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t direction,
int16_t room_num);

View file

@ -84,6 +84,12 @@ static M_FUNC m_Actions[] = {
void M_Bubbles(ITEM *const item)
{
// XXX: until we get RoboLara, it makes sense for her to breathe underwater
if (g_Lara.water_status == LWS_CHEAT
&& !(g_Rooms[g_LaraItem->room_num].flags & RF_UNDERWATER)) {
return;
}
const int32_t count = (Random_GetDraw() * 3) / 0x8000;
if (count == 0) {
return;