port HitTarget

This commit is contained in:
rr- 2021-02-20 15:02:56 +01:00
parent 4b029f56df
commit 173f3774d5
5 changed files with 53 additions and 9 deletions

View file

@ -410,7 +410,7 @@
<rect width="12.00" height="12.00" x="98.00" y="129.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="112.00" y="129.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="126.00" y="129.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="140.00" y="129.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="140.00" y="129.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="154.00" y="129.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="168.00" y="129.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="182.00" y="129.00" fill="forestgreen"/>
@ -1001,7 +1001,7 @@
<rect width="11.00" height="11.61" x="620.78" y="367.38" fill="lightpink"/>
<rect width="10.89" height="11.61" x="633.78" y="367.38" fill="forestgreen"/>
<rect width="10.89" height="11.61" x="646.67" y="367.38" fill="lightpink"/>
<rect width="10.83" height="11.61" x="659.56" y="367.38" fill="lightpink"/>
<rect width="10.83" height="11.61" x="659.56" y="367.38" fill="forestgreen"/>
<rect width="10.83" height="11.61" x="672.39" y="367.38" fill="lightpink"/>
<rect width="10.78" height="11.61" x="685.22" y="367.38" fill="lightpink"/>
<rect width="10.86" height="11.52" x="527.82" y="380.99" fill="lightpink"/>
@ -1403,10 +1403,10 @@
<rect width="-0.56" height="0.65" x="696.56" y="534.29" fill="mistyrose"/>
<rect width="0.16" height="-0.94" x="695.12" y="536.94" fill="mistyrose"/>
<rect width="-1.28" height="-0.94" x="697.28" y="536.94" fill="lightpink"/>
<rect width="12.00" height="12.00" x="0.00" y="564.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="570.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (count): 25.53%</text>
<rect width="12.00" height="12.00" x="0.00" y="582.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="588.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (bytesize): 18.99%</text>
<rect width="12.00" height="12.00" x="0.00" y="600.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="606.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (count): 59.06%</text>
<rect width="12.00" height="12.00" x="0.00" y="618.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="624.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (bytesize): 63.89%</text>
<rect width="12.00" height="12.00" x="0.00" y="564.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="570.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (count): 25.68%</text>
<rect width="12.00" height="12.00" x="0.00" y="582.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="588.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (bytesize): 19.09%</text>
<rect width="12.00" height="12.00" x="0.00" y="600.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="606.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (count): 58.92%</text>
<rect width="12.00" height="12.00" x="0.00" y="618.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="624.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (bytesize): 63.79%</text>
<rect width="12.00" height="12.00" x="0.00" y="636.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="642.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (count): 15.41%</text>
<rect width="12.00" height="12.00" x="0.00" y="654.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="660.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (bytesize): 17.12%</text>
</svg>

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Before After
Before After

View file

@ -210,7 +210,7 @@ sub_41A1D0 0x0041A1D0 0x00000027 -
sub_41A200 0x0041A200 0x0000000F -
ItemNearLara 0x0041A210 0x0000008C -
SoundEffects 0x0041A2A0 0x0000006D *
DoBloodSplat 0x0041A310 0x00000059 -
DoBloodSplat 0x0041A310 0x00000059 *
ControlBlood1 0x0041A370 0x0000008B -
ControlExplosion1 0x0041A400 0x0000004C -
Richochet 0x0041A450 0x00000072 *
@ -414,7 +414,7 @@ LaraGetNewTarget 0x004270C0 0x000001D9 +
find_target_point 0x004272A0 0x000000B2 +
AimWeapon 0x00427360 0x000000C1 +
FireWeapon 0x00427430 0x000002F2 +
HitTarget 0x00427730 0x000000E5 *
HitTarget 0x00427730 0x000000E5 +
LaraControl 0x00427850 0x00000372 *
LaraSwapMeshExtra 0x00427BD0 0x00000030 +
AnimateLara 0x00427C00 0x00000244 +

View file

@ -10,6 +10,7 @@
#define StopSoundEffect ((void __cdecl(*)(int32_t sfx_num, PHD_3DPOS *pos))0x0042B300)
#define ItemSparkle ((void __cdecl(*)(ITEM_INFO* item, int meshmask))0x0041A550)
#define Richochet ((void __cdecl(*)(GAME_VECTOR* pos))0x0041A450)
#define DoBloodSplat ((int16_t __cdecl(*)(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE direction, int16_t room_num))0x0041A310)
// clang-format on
void __cdecl FxChainBlock(ITEM_INFO* item);

View file

@ -9,7 +9,6 @@
#define LaraControl ((void __cdecl(*)(int16_t item_num))0x00427850)
#define UpdateLaraRoom ((void __cdecl(*)(ITEM_INFO* item, int height))0x004126A0)
#define ShiftItem ((void __cdecl(*)(ITEM_INFO* item, COLL_INFO *coll))0x00412660)
#define HitTarget ((void __cdecl(*)(ITEM_INFO* item, GAME_VECTOR* hitpos, int damage))0x00427730)
// clang-format on
void __cdecl LaraSwapMeshExtra();
@ -170,6 +169,7 @@ void __cdecl find_target_point(ITEM_INFO* item, GAME_VECTOR* target);
void __cdecl AimWeapon(WEAPON_INFO* winfo, LARA_ARM* arm);
int32_t __cdecl FireWeapon(
int32_t weapon_type, ITEM_INFO* target, ITEM_INFO* src, PHD_ANGLE* angles);
void __cdecl HitTarget(ITEM_INFO* item, GAME_VECTOR* hitpos, int32_t damage);
void __cdecl draw_shotgun();
void __cdecl undraw_shotgun();

View file

@ -456,6 +456,48 @@ int32_t __cdecl FireWeapon(
return -1;
}
void __cdecl HitTarget(ITEM_INFO* item, GAME_VECTOR* hitpos, int32_t damage)
{
if (item->hit_points > 0 && item->hit_points <= damage) {
SaveGame[0].kills++;
}
item->hit_points -= damage;
item->hit_status = 1;
DoBloodSplat(
hitpos->x, hitpos->y, hitpos->z, item->speed, item->pos.y_rot,
item->room_number);
if (item->hit_points > 0) {
switch (item->object_number) {
case O_WOLF:
SoundEffect(20, &item->pos, 0);
break;
case O_BEAR:
SoundEffect(16, &item->pos, 0);
break;
case O_LION:
case O_LIONESS:
SoundEffect(85, &item->pos, 0);
break;
case O_RAT:
SoundEffect(95, &item->pos, 0);
break;
case O_MERCENARY1:
SoundEffect(132, &item->pos, 0);
break;
case O_EVIL_NATLA:
SoundEffect(142, &item->pos, 0);
break;
}
}
}
void Tomb1MInjectGameLaraFire()
{
INJECT(0x00426BD0, LaraGun);
@ -465,4 +507,5 @@ void Tomb1MInjectGameLaraFire()
INJECT(0x004272A0, find_target_point);
INJECT(0x00427360, AimWeapon);
INJECT(0x00427430, FireWeapon);
INJECT(0x00427730, HitTarget);
}