mirror of
https://github.com/LostArtefacts/TR2X.git
synced 2024-12-02 19:06:47 +00:00
port Lara_Push
This commit is contained in:
parent
b9760f29ce
commit
f1bfe52d3e
@ -69,10 +69,10 @@
|
||||
</g>
|
||||
<g transform="translate(0 116)">
|
||||
<text x="0" y="7.50">Tomb2.exe progress according to the physical function order:</text>
|
||||
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">46.14% (562)</tspan> · <tspan class="known">51.40% (626)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
|
||||
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">46.22% (563)</tspan> · <tspan class="known">51.31% (625)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
|
||||
<g transform="translate(0 20)">
|
||||
<rect width="344.67" height="6" x="0" y="0" class="decompiled"/>
|
||||
<rect width="383.93" height="6" x="344.67" y="0" class="known"/>
|
||||
<rect width="345.29" height="6" x="0" y="0" class="decompiled"/>
|
||||
<rect width="383.31" height="6" x="345.29" y="0" class="known"/>
|
||||
<rect width="18.40" height="6" x="728.60" y="0" class="unused"/>
|
||||
</g>
|
||||
<g transform="translate(0 31)">
|
||||
@ -236,7 +236,7 @@
|
||||
<rect width="12" height="12" x="105" y="45" class="decompiled"><title>void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
|
||||
<rect width="12" height="12" x="120" y="45" class="decompiled"><title>void __cdecl Door_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
|
||||
<rect width="12" height="12" x="135" y="45" class="decompiled"><title>void __cdecl Object_Collision_Trap(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
|
||||
<rect width="12" height="12" x="150" y="45" class="known"><title>void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push);</title></rect>
|
||||
<rect width="12" height="12" x="150" y="45" class="decompiled"><title>void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push);</title></rect>
|
||||
<rect width="12" height="12" x="165" y="45" class="known"><title>int32_t __cdecl Item_TestBoundsCollide(const ITEM_INFO *src_item, const ITEM_INFO *dst_item, int32_t radius);</title></rect>
|
||||
<rect width="12" height="12" x="180" y="45" class="known"><title>int32_t __cdecl Item_TestPosition(int16_t *bounds, ITEM_INFO *src_item, ITEM_INFO *dst_item);</title></rect>
|
||||
<rect width="12" height="12" x="195" y="45" class="known"><title>void __cdecl Item_AlignPosition(XYZ_32 *vec, ITEM_INFO *src_item, ITEM_INFO *dst_item);</title></rect>
|
||||
@ -1298,10 +1298,10 @@
|
||||
</g>
|
||||
<g transform="translate(0 546)">
|
||||
<text x="0" y="7.50">Tomb2.exe progress according to the function sizes:</text>
|
||||
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">42.90%</tspan> · <tspan class="known">56.77%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
|
||||
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">43.13%</tspan> · <tspan class="known">56.54%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
|
||||
<g transform="translate(0 20)">
|
||||
<rect width="320.48" height="6" x="0" y="0" class="decompiled"/>
|
||||
<rect width="424.07" height="6" x="320.48" y="0" class="known"/>
|
||||
<rect width="322.18" height="6" x="0" y="0" class="decompiled"/>
|
||||
<rect width="422.38" height="6" x="322.18" y="0" class="known"/>
|
||||
<rect width="2.44" height="6" x="744.56" y="0" class="unused"/>
|
||||
</g>
|
||||
<g transform="translate(0 31)">
|
||||
@ -1408,7 +1408,7 @@
|
||||
<rect width="22.47" height="22.91" x="294.58" y="326.21" class="decompiled"><title>const int16_t *__cdecl Output_InsertObjectG3(const int16_t *obj_ptr, int32_t num, SORT_TYPE sort_type);</title></rect>
|
||||
<rect width="22.47" height="22.88" x="294.58" y="352.12" class="decompiled"><title>void __cdecl Lara_GetJointAbsPosition_I(ITEM_INFO *item, XYZ_32 *vec, int16_t *frame1, int16_t *frame2, int32_t frac, int32_t rate);</title></rect>
|
||||
<rect width="21.61" height="23.28" x="320.05" y="0" class="known"><title>void __cdecl BanditControl(int16_t item_num);</title></rect>
|
||||
<rect width="21.61" height="23.11" x="320.05" y="26.28" class="known"><title>void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push);</title></rect>
|
||||
<rect width="21.61" height="23.11" x="320.05" y="26.28" class="decompiled"><title>void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push);</title></rect>
|
||||
<rect width="21.61" height="22.84" x="320.05" y="52.39" class="decompiled"><title>int32_t __cdecl LOS_CheckSmashable(const GAME_VECTOR *start, GAME_VECTOR *target);</title></rect>
|
||||
<rect width="21.61" height="22.81" x="320.05" y="78.23" class="decompiled"><title>void __fastcall Output_GTMapA(int32_t y0, int32_t y1, uint8_t *tex_page); // actually, __watcall, which is esoteric and rarely supported</title></rect>
|
||||
<rect width="21.61" height="22.57" x="320.05" y="104.04" class="known"><title>void __cdecl S_CalculateLight(int32_t x, int32_t y, int32_t z, int16_t room_num);</title></rect>
|
||||
|
Before Width: | Height: | Size: 361 KiB After Width: | Height: | Size: 361 KiB |
@ -2751,7 +2751,7 @@ typedef struct __unaligned {
|
||||
0x004138E0 0x0055 + void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
|
||||
0x00413940 0x0077 + void __cdecl Door_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
|
||||
0x004139C0 0x0067 + void __cdecl Object_Collision_Trap(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
|
||||
0x00413A30 0x0306 - void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push);
|
||||
0x00413A30 0x0306 + void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push);
|
||||
0x00413D40 0x00CB - int32_t __cdecl Item_TestBoundsCollide(const ITEM_INFO *src_item, const ITEM_INFO *dst_item, int32_t radius);
|
||||
0x00413E10 0x0137 - int32_t __cdecl Item_TestPosition(int16_t *bounds, ITEM_INFO *src_item, ITEM_INFO *dst_item);
|
||||
0x00413F50 0x013B - void __cdecl Item_AlignPosition(XYZ_32 *vec, ITEM_INFO *src_item, ITEM_INFO *dst_item);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "game/box.h"
|
||||
#include "game/items.h"
|
||||
#include "game/lara/lara_misc.h"
|
||||
#include "game/math.h"
|
||||
#include "game/random.h"
|
||||
#include "global/const.h"
|
||||
|
@ -12,6 +12,21 @@
|
||||
|
||||
#define MAX_BADDIE_COLLISION 20
|
||||
|
||||
static void __cdecl Lara_TakeHit_Impl(
|
||||
ITEM_INFO *const lara_item, const int32_t dx, const int32_t dz);
|
||||
|
||||
static void __cdecl Lara_TakeHit_Impl(
|
||||
ITEM_INFO *const lara_item, const int32_t dx, const int32_t dz)
|
||||
{
|
||||
const PHD_ANGLE hit_angle = lara_item->rot.y + PHD_180 - Math_Atan(dz, dx);
|
||||
g_Lara.hit_direction = Math_GetDirection(hit_angle);
|
||||
if (g_Lara.hit_frame == 0) {
|
||||
Sound_Effect(SFX_LARA_INJURY, &lara_item->pos, SPM_NORMAL);
|
||||
}
|
||||
g_Lara.hit_frame++;
|
||||
CLAMPG(g_Lara.hit_frame, 34);
|
||||
}
|
||||
|
||||
void __cdecl Lara_GetCollisionInfo(ITEM_INFO *item, COLL_INFO *coll)
|
||||
{
|
||||
coll->facing = g_Lara.move_angle;
|
||||
@ -1000,13 +1015,7 @@ void __cdecl Lara_TakeHit(
|
||||
{
|
||||
const int32_t dx = g_Lara.spaz_effect->pos.x - lara_item->pos.x;
|
||||
const int32_t dz = g_Lara.spaz_effect->pos.z - lara_item->pos.z;
|
||||
const PHD_ANGLE hit_angle = lara_item->rot.y + PHD_180 - Math_Atan(dz, dx);
|
||||
g_Lara.hit_direction = Math_GetDirection(hit_angle);
|
||||
if (g_Lara.hit_frame == 0) {
|
||||
Sound_Effect(SFX_LARA_INJURY, &lara_item->pos, SPM_NORMAL);
|
||||
}
|
||||
g_Lara.hit_frame++;
|
||||
CLAMPG(g_Lara.hit_frame, 34);
|
||||
Lara_TakeHit_Impl(lara_item, dx, dz);
|
||||
g_Lara.spaz_effect_count--;
|
||||
}
|
||||
|
||||
@ -1068,3 +1077,80 @@ void __cdecl Lara_BaddieCollision(ITEM_INFO *lara_item, COLL_INFO *coll)
|
||||
|
||||
g_Inv_Chosen = -1;
|
||||
}
|
||||
|
||||
void __cdecl Lara_Push(
|
||||
const ITEM_INFO *const item, ITEM_INFO *const lara_item,
|
||||
COLL_INFO *const coll, const bool spaz_on, const bool big_push)
|
||||
{
|
||||
int32_t dx = lara_item->pos.x - item->pos.x;
|
||||
int32_t dz = lara_item->pos.z - item->pos.z;
|
||||
const int32_t c = Math_Cos(item->rot.y);
|
||||
const int32_t s = Math_Sin(item->rot.y);
|
||||
int32_t rx = (c * dx - s * dz) >> W2V_SHIFT;
|
||||
int32_t rz = (c * dz + s * dx) >> W2V_SHIFT;
|
||||
|
||||
const int16_t *bounds = Item_GetBestFrame(item);
|
||||
int32_t min_x = bounds[FBBOX_MIN_X];
|
||||
int32_t max_x = bounds[FBBOX_MAX_X];
|
||||
int32_t min_z = bounds[FBBOX_MIN_Z];
|
||||
int32_t max_z = bounds[FBBOX_MAX_Z];
|
||||
|
||||
if (big_push) {
|
||||
max_x += coll->radius;
|
||||
min_z -= coll->radius;
|
||||
max_z += coll->radius;
|
||||
min_x -= coll->radius;
|
||||
}
|
||||
|
||||
if (rx < min_x || rx > max_x || rz < min_z || rz > max_z) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t l = rx - min_x;
|
||||
int32_t r = max_x - rx;
|
||||
int32_t t = max_z - rz;
|
||||
int32_t b = rz - min_z;
|
||||
|
||||
if (l <= r && l <= t && l <= b) {
|
||||
rx -= l;
|
||||
} else if (r <= l && r <= t && r <= b) {
|
||||
rx += r;
|
||||
} else if (t <= l && t <= r && t <= b) {
|
||||
rz += t;
|
||||
} else {
|
||||
rz = min_z;
|
||||
}
|
||||
|
||||
lara_item->pos.x = item->pos.x + ((rz * s + rx * c) >> W2V_SHIFT);
|
||||
lara_item->pos.z = item->pos.z + ((rz * c - rx * s) >> W2V_SHIFT);
|
||||
|
||||
rz = (bounds[FBBOX_MAX_Z] + bounds[FBBOX_MIN_Z]) / 2;
|
||||
rx = (bounds[FBBOX_MAX_X] + bounds[FBBOX_MIN_X]) / 2;
|
||||
dx -= (c * rx + s * rz) >> W2V_SHIFT;
|
||||
dz -= (c * rz - s * rx) >> W2V_SHIFT;
|
||||
|
||||
if (spaz_on && bounds[FBBOX_MAX_Y] - bounds[FBBOX_MIN_Y] > STEP_L) {
|
||||
Lara_TakeHit_Impl(lara_item, dx, dz);
|
||||
}
|
||||
|
||||
int16_t old_facing = coll->facing;
|
||||
coll->bad_pos = NO_BAD_POS;
|
||||
coll->bad_neg = -STEPUP_HEIGHT;
|
||||
coll->bad_ceiling = 0;
|
||||
coll->facing = Math_Atan(
|
||||
lara_item->pos.z - coll->old.z, lara_item->pos.x - coll->old.x);
|
||||
Collide_GetCollisionInfo(
|
||||
coll, lara_item->pos.x, lara_item->pos.y, lara_item->pos.z,
|
||||
lara_item->room_num, LARA_HEIGHT);
|
||||
coll->facing = old_facing;
|
||||
|
||||
if (coll->coll_type != COLL_NONE) {
|
||||
lara_item->pos.x = coll->old.x;
|
||||
lara_item->pos.z = coll->old.z;
|
||||
} else {
|
||||
coll->old.x = lara_item->pos.x;
|
||||
coll->old.y = lara_item->pos.y;
|
||||
coll->old.z = lara_item->pos.z;
|
||||
Item_UpdateRoom(lara_item, -10);
|
||||
}
|
||||
}
|
||||
|
@ -50,3 +50,6 @@ void __cdecl Lara_GetJointAbsPosition_I(
|
||||
|
||||
void __cdecl Lara_BaddieCollision(ITEM_INFO *lara_item, COLL_INFO *coll);
|
||||
void __cdecl Lara_TakeHit(ITEM_INFO *lara_item, const COLL_INFO *coll);
|
||||
void __cdecl Lara_Push(
|
||||
const ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, bool spaz_on,
|
||||
bool big_push);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "game/objects/common.h"
|
||||
|
||||
#include "game/lara/lara_misc.h"
|
||||
#include "global/funcs.h"
|
||||
#include "global/vars.h"
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "game/objects/general/door.h"
|
||||
|
||||
#include "game/lara/lara_misc.h"
|
||||
#include "global/funcs.h"
|
||||
#include "global/vars.h"
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define W2V_SHIFT 14
|
||||
#define WALL_L 1024
|
||||
#define WALL_SHIFT 10
|
||||
#define STEP_L (WALL_L / 4)
|
||||
#define STEP_L (WALL_L / 4) // = 256
|
||||
#define NO_HEIGHT (-32512)
|
||||
#define NO_BAD_POS (-NO_HEIGHT) // = 32512
|
||||
#define NO_BAD_NEG (NO_HEIGHT) // = -32512
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
// clang-format off
|
||||
#define Output_InsertInventoryBackground ((void __cdecl (*)(const int16_t *obj_ptr))0x00401D50)
|
||||
#define Lara_Push ((void __cdecl (*)(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push))0x00413A30)
|
||||
#define Item_TestBoundsCollide ((int32_t __cdecl (*)(const ITEM_INFO *src_item, const ITEM_INFO *dst_item, int32_t radius))0x00413D40)
|
||||
#define Item_TestPosition ((int32_t __cdecl (*)(int16_t *bounds, ITEM_INFO *src_item, ITEM_INFO *dst_item))0x00413E10)
|
||||
#define Item_AlignPosition ((void __cdecl (*)(XYZ_32 *vec, ITEM_INFO *src_item, ITEM_INFO *dst_item))0x00413F50)
|
||||
|
@ -519,6 +519,7 @@ static void Inject_Lara_Misc(const bool enable)
|
||||
INJECT(enable, 0x0042B8E0, Lara_GetJointAbsPosition_I);
|
||||
INJECT(enable, 0x00413640, Lara_BaddieCollision);
|
||||
INJECT(enable, 0x004137E0, Lara_TakeHit);
|
||||
INJECT(enable, 0x00413A30, Lara_Push);
|
||||
}
|
||||
|
||||
static void Inject_Lara_State(const bool enable)
|
||||
|
Loading…
Reference in New Issue
Block a user