Skip to content

Commit

Permalink
tr2: port Object_SetupBaddyObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 15, 2024
1 parent 07e23d2 commit 92ed8d5
Show file tree
Hide file tree
Showing 60 changed files with 1,493 additions and 157 deletions.
152 changes: 76 additions & 76 deletions docs/tr2/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 35 additions & 35 deletions docs/tr2/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3076,7 +3076,7 @@ typedef enum {
0x00417E90 0x0519 + void __cdecl Dragon_Control(int16_t back_num);
0x004183E0 0x0114 + void __cdecl Bartoli_Initialise(int16_t item_num);
0x00418500 0x0193 + void __cdecl Bartoli_Control(int16_t item_num);
0x004186A0 0x0287 -R void __cdecl DinoControl(int16_t item_num);
0x004186A0 0x0287 - void __cdecl TRex_Control(int16_t item_num);

# game/draw.c
0x00418950 0x0037 + int32_t __cdecl Game_DrawCinematic(void);
Expand Down Expand Up @@ -3114,8 +3114,8 @@ typedef enum {
0x0041C0F0 0x0048 -R void __cdecl AddDynamicLight(int32_t x, int32_t y, int32_t z, int32_t intensity, int32_t falloff);

# game/eel.c
0x0041C140 0x019D -R void __cdecl BigEelControl(int16_t item_num);
0x0041C2E0 0x01E1 -R void __cdecl EelControl(int16_t item_num);
0x0041C140 0x019D - void __cdecl BigEel_Control(int16_t item_num);
0x0041C2E0 0x01E1 - void __cdecl Eel_Control(int16_t item_num);

# game/effects.c
0x0041C4D0 0x008C + int32_t __cdecl Lara_IsNearItem(PHD_3DPOS *pos, int32_t distance);
Expand Down Expand Up @@ -3176,15 +3176,15 @@ typedef enum {

# game/enemies.c
0x0041DB50 0x0076 -R int16_t __cdecl Knife(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE yrot, int16_t room_num);
0x0041DBD0 0x040B -R void __cdecl Cult2Control(int16_t item_num);
0x0041E000 0x04A1 -R void __cdecl MonkControl(int16_t item_num);
0x0041E4D0 0x05BD -R void __cdecl Worker3Control(int16_t item_num);
0x0041EAE0 0x03F7 -R void __cdecl DrawXianLord(ITEM *item);
0x0041DBD0 0x040B - void __cdecl Cultist2_Control(int16_t item_num);
0x0041E000 0x04A1 - void __cdecl Monk_Control(int16_t item_num);
0x0041E4D0 0x05BD -R void __cdecl Worker3_Control(int16_t item_num);
0x0041EAE0 0x03F7 - void __cdecl XianKnight_Draw(const ITEM *item);
0x0041EEE0 0x00A8 -R void __cdecl XianDamage(ITEM *item, CREATURE *xian, int32_t damage);
0x0041EF90 0x0058 -R void __cdecl InitialiseXianLord(int16_t item_num);
0x0041EFF0 0x0590 -R void __cdecl XianLordControl(int16_t item_num);
0x0041EF90 0x0058 - void __cdecl XianKnight_Initialise(int16_t item_num);
0x0041EFF0 0x0590 -R void __cdecl XianSpearman_Control(int16_t item_num);
0x0041F5D0 0x0098 -R void __cdecl WarriorSparkleTrail(ITEM *item);
0x0041F670 0x03BA -R void __cdecl WarriorControl(int16_t item_num);
0x0041F670 0x03BA - void __cdecl XianKnight_Control(int16_t item_num);

# game/gameflow.c
0x0041FA60 0x01E9 + int32_t __cdecl GF_LoadScriptFile(const char *fname);
Expand Down Expand Up @@ -3530,8 +3530,8 @@ typedef enum {
0x00433D20 0x0137 -R int32_t __cdecl TestBlockPush(ITEM *item, int32_t block_height, uint16_t quadrant);
0x00433E70 0x0225 -R int32_t __cdecl TestBlockPull(ITEM *item, int32_t block_height, uint16_t quadrant);
0x004340B0 0x00BB + void __cdecl Room_AlterFloorHeight(ITEM *item, int32_t height);
0x00434170 0x0022 -R void __cdecl DrawMovableBlock(ITEM *item);
0x004341A0 0x006B -R void __cdecl DrawUnclippedItem(ITEM *item);
0x00434170 0x0022 -R void __cdecl DrawMovableBlock(const ITEM *item);
0x004341A0 0x006B - void __cdecl Object_DrawUnclippedItem(const ITEM *item);

# game/objects.c
0x00434210 0x00DB -R void __cdecl EarthQuake(int16_t item_num);
Expand Down Expand Up @@ -3582,15 +3582,15 @@ typedef enum {
0x00435F90 0x00B9 -R int16_t __cdecl GunHit(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE yrot, int16_t room_num);
0x00436050 0x00A7 -R int16_t __cdecl GunMiss(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE yrot, int16_t room_num);
0x00436100 0x01C4 -R int32_t __cdecl ShotLara(ITEM *item, AI_INFO *info, BITE *gun, int16_t extra_rotation, int32_t damage);
0x004362D0 0x0043 -R void __cdecl InitialiseCult1(int16_t item_num);
0x00436320 0x0401 -R void __cdecl Cult1Control(int16_t item_num);
0x00436750 0x0050 -R void __cdecl InitialiseCult3(int16_t item_num);
0x004367A0 0x053C -R void __cdecl Cult3Control(int16_t item_num);
0x00436D10 0x03CA -R void __cdecl Worker1Control(int16_t item_num);
0x00437110 0x042A -R void __cdecl Worker2Control(int16_t item_num);
0x00437570 0x030B -R void __cdecl BanditControl(int16_t item_num);
0x004378B0 0x0408 -R void __cdecl Bandit2Control(int16_t item_num);
0x00437CF0 0x0172 -R void __cdecl WinstonControl(int16_t item_num);
0x004362D0 0x0043 - void __cdecl Cultist1_Initialise(int16_t item_num);
0x00436320 0x0401 - void __cdecl Cultist1_Control(int16_t item_num);
0x00436750 0x0050 - void __cdecl Cultist3_Initialise(int16_t item_num);
0x004367A0 0x053C - void __cdecl Cultist3_Control(int16_t item_num);
0x00436D10 0x03CA - void __cdecl Worker1_Control(int16_t item_num);
0x00437110 0x042A - void __cdecl Worker2_Control(int16_t item_num);
0x00437570 0x030B - void __cdecl Bandit1_Control(int16_t item_num);
0x004378B0 0x0408 - void __cdecl Bandit2_Control(int16_t item_num);
0x00437CF0 0x0172 - void __cdecl Winston_Control(int16_t item_num);

# game/pickup.c
0x00437E70 0x0480 + void __cdecl Pickup_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
Expand All @@ -3606,7 +3606,7 @@ typedef enum {
0x00438EC0 0x0023 -R void __cdecl SecretControl(int16_t item_num);

# game/rat.c
0x00438EF0 0x01DC -R void __cdecl MouseControl(int16_t item_num);
0x00438EF0 0x01DC - void __cdecl Mouse_Control(int16_t item_num);

# game/savegame.c
0x004390E0 0x0062 *R void __cdecl InitialiseStartInfo(void);
Expand All @@ -3622,16 +3622,16 @@ typedef enum {
0x0043A280 0x015F + int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);
0x0043A3E0 0x0061 -R void __cdecl InitialiseGameFlags(void);
0x0043A450 0x0027 -R void __cdecl InitialiseLevelFlags(void);
0x0043A480 0x103B - void __cdecl Object_SetupBaddyObjects(void);
0x0043A480 0x103B + void __cdecl Object_SetupBaddyObjects(void);
0x0043B4C0 0x05FD - void __cdecl Object_SetupTrapObjects(void);
0x0043BAC0 0x0C4C - void __cdecl Object_SetupGeneralObjects(void);
0x0043C710 0x0068 + void __cdecl Object_SetupAllObjects(void);
0x0043C780 0x00CE -R void __cdecl GetCarriedItems(void);

# game/shark.c
0x0043C850 0x0116 -R void __cdecl JellyControl(int16_t item_num);
0x0043C970 0x021B -R void __cdecl BaracuddaControl(int16_t item_num);
0x0043CBA0 0x027C -R void __cdecl SharkControl(int16_t item_num);
0x0043C850 0x0116 -R void __cdecl Jelly_Control(int16_t item_num);
0x0043C970 0x021B -R void __cdecl Baracudda_Control(int16_t item_num);
0x0043CBA0 0x027C -R void __cdecl Shark_Control(int16_t item_num);

# game/skidoo.c
0x0043CE30 0x0040 -R void __cdecl InitialiseSkidoo(int16_t item_num);
Expand All @@ -3651,11 +3651,11 @@ typedef enum {
0x0043E2A0 0x0233 -R int32_t __cdecl SkidooCheckGetOff(void);
0x0043E4E0 0x011B -R void __cdecl SkidooGuns(void);
0x0043E600 0x0440 -R int32_t __cdecl SkidooControl(void);
0x0043EA60 0x02D5 -R void __cdecl DrawSkidoo(ITEM *item);
0x0043ED40 0x007F -R void __cdecl InitialiseSkidman(int16_t item_num);
0x0043EDD0 0x03E2 -R void __cdecl SkidManControl(int16_t rider_num);
0x0043EA60 0x02D5 -R void __cdecl SkidooArmed_Draw(const ITEM *item);
0x0043ED40 0x007F -R void __cdecl SkidooDriver_Initialise(int16_t item_num);
0x0043EDD0 0x03E2 - void __cdecl SkidooDriver_Control(int16_t rider_num);
0x0043F1D0 0x0119 -R void __cdecl SkidmanPush(ITEM *item, ITEM *lara_item, int32_t radius);
0x0043F2F0 0x0081 -R void __cdecl SkidmanCollision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
0x0043F2F0 0x0081 - void __cdecl SkidooDriver_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);

# game/sound.c
0x0043F380 0x0031 * int32_t __cdecl Music_GetRealTrack(int32_t track);
Expand All @@ -3672,9 +3672,9 @@ typedef enum {
0x0043FF60 0x005D -R void __cdecl BaddieBiteEffect(ITEM *item, BITE *bite);

# game/spider.c
0x0043FFC0 0x00AC -R void __cdecl SpiderLeap(int16_t item_num, int16_t angle);
0x00440070 0x0206 -R void __cdecl SpiderControl(int16_t item_num);
0x00440290 0x01A5 -R void __cdecl BigSpiderControl(int16_t item_num);
0x0043FFC0 0x00AC - void __cdecl Spider_Leap(int16_t item_num, int16_t angle);
0x00440070 0x0206 - void __cdecl Spider_Control(int16_t item_num);
0x00440290 0x01A5 - void __cdecl BigSpider_Control(int16_t item_num);

# game/text.c
0x00440450 0x002C + void __cdecl Text_Init(void);
Expand Down Expand Up @@ -3737,8 +3737,8 @@ typedef enum {
0x00442F40 0x010B + void __cdecl Ember_Control(int16_t fx_num);

# game/yeti.c
0x00443050 0x02CA -R void __cdecl GiantYetiControl(int16_t item_num);
0x00443350 0x05ED -R void __cdecl YetiControl(int16_t item_num);
0x00443050 0x02CA - void __cdecl GiantYeti_Control(int16_t item_num);
0x00443350 0x05ED - void __cdecl Yeti_Control(int16_t item_num);

0x00443990 0x01B8 +R void __cdecl BGND_Make640x480(uint8_t *bitmap, RGB_888 *palette);
0x00443B50 0x00B9 +R int32_t __cdecl BGND_AddTexture(int32_t tile_idx, BYTE *bitmap, int32_t pal_index, RGB_888 *bmp_pal);
Expand Down
4 changes: 4 additions & 0 deletions src/tr2/game/objects/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ OBJECT *Object_GetObject(GAME_OBJECT_ID object_id)
return &g_Objects[object_id];
}

void Object_DrawDummyItem(const ITEM *const item)
{
}

void __cdecl Object_Collision(
const int16_t item_num, ITEM *const lara_item, COLL_INFO *const coll)
{
Expand Down
2 changes: 2 additions & 0 deletions src/tr2/game/objects/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

#include <libtrx/game/objects/common.h>

void Object_DrawDummyItem(const ITEM *item);

void __cdecl Object_Collision(
int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
92 changes: 92 additions & 0 deletions src/tr2/game/objects/creatures/bandit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "game/objects/creatures/bandit.h"

#include "game/creature.h"
#include "game/objects/common.h"
#include "global/funcs.h"
#include "global/vars.h"

#include <assert.h>

#define BANDIT1_HITPOINTS 45
#define BANDIT2_HITPOINTS 50
#define BANDIT_RADIUS (WALL_L / 10) // = 102

void Bandit1_Setup(void)
{
OBJECT *const obj = Object_GetObject(O_BANDIT_1);
if (!obj->loaded) {
return;
}

obj->control = Bandit1_Control;
obj->collision = Creature_Collision;

obj->hit_points = BANDIT1_HITPOINTS;
obj->radius = BANDIT_RADIUS;
obj->shadow_size = UNIT_SHADOW / 2;
obj->pivot_length = 0;

obj->intelligent = 1;
obj->save_anim = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_flags = 1;

g_AnimBones[obj->bone_idx + 24] |= BF_ROT_Y;
g_AnimBones[obj->bone_idx + 32] |= BF_ROT_Y;
}

void Bandit2_Setup(void)
{
OBJECT *const obj = Object_GetObject(O_BANDIT_2);
if (!obj->loaded) {
return;
}

obj->control = Bandit2_Control;
obj->collision = Creature_Collision;

obj->hit_points = BANDIT2_HITPOINTS;
obj->radius = BANDIT_RADIUS;
obj->shadow_size = UNIT_SHADOW / 2;
obj->pivot_length = 0;

obj->intelligent = 1;
obj->save_anim = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_flags = 1;

g_AnimBones[obj->bone_idx + 24] |= BF_ROT_Y;
g_AnimBones[obj->bone_idx + 32] |= BF_ROT_Y;
}

void Bandit2B_Setup(void)
{
OBJECT *const obj = Object_GetObject(O_BANDIT_2B);
if (!obj->loaded) {
return;
}

const OBJECT *const ref_obj = Object_GetObject(O_BANDIT_2);
assert(ref_obj->loaded);
obj->anim_idx = ref_obj->anim_idx;
obj->frame_base = ref_obj->frame_base;

obj->control = Bandit2_Control;
obj->collision = Creature_Collision;

obj->hit_points = BANDIT2_HITPOINTS;
obj->radius = BANDIT_RADIUS;
obj->shadow_size = UNIT_SHADOW / 2;
obj->pivot_length = 0;

obj->intelligent = 1;
obj->save_anim = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_flags = 1;

g_AnimBones[obj->bone_idx + 24] |= BF_ROT_Y;
g_AnimBones[obj->bone_idx + 32] |= BF_ROT_Y;
}
5 changes: 5 additions & 0 deletions src/tr2/game/objects/creatures/bandit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

void Bandit1_Setup(void);
void Bandit2_Setup(void);
void Bandit2B_Setup(void);
34 changes: 34 additions & 0 deletions src/tr2/game/objects/creatures/barracuda.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "game/objects/creatures/barracuda.h"

#include "game/creature.h"
#include "game/objects/common.h"
#include "global/funcs.h"
#include "global/vars.h"

#define BARRACUDA_HITPOINTS 12
#define BARRACUDA_RADIUS (WALL_L / 5) // = 204

void Barracuda_Setup(void)
{
OBJECT *const obj = Object_GetObject(O_BARRACUDA);
if (!obj->loaded) {
return;
}

obj->control = Baracudda_Control;
obj->collision = Creature_Collision;

obj->hit_points = BARRACUDA_HITPOINTS;
obj->radius = BARRACUDA_RADIUS;
obj->shadow_size = UNIT_SHADOW / 2;
obj->pivot_length = 200;

obj->intelligent = 1;
obj->water_creature = 1;
obj->save_anim = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_flags = 1;

g_AnimBones[obj->bone_idx + 24] |= BF_ROT_Y;
}
3 changes: 3 additions & 0 deletions src/tr2/game/objects/creatures/barracuda.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void Barracuda_Setup(void);
14 changes: 14 additions & 0 deletions src/tr2/game/objects/creatures/bartoli.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ static bool M_CheckLaraProximity(const ITEM *const origin_item)
return dx < BARTOLI_RANGE && dz < BARTOLI_RANGE;
}

void Bartoli_Setup(void)
{
OBJECT *const obj = Object_GetObject(O_BARTOLI);
if (!obj->loaded) {
return;
}

obj->initialise = Bartoli_Initialise;
obj->control = Bartoli_Control;

obj->save_flags = 1;
obj->save_anim = 1;
}

void __cdecl Bartoli_Initialise(const int16_t item_num)
{
ITEM *const item = Item_Get(item_num);
Expand Down
2 changes: 2 additions & 0 deletions src/tr2/game/objects/creatures/bartoli.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

#include <stdint.h>

void Bartoli_Setup(void);

void __cdecl Bartoli_Initialise(int16_t item_num);
void __cdecl Bartoli_Control(int16_t item_num);
26 changes: 26 additions & 0 deletions src/tr2/game/objects/creatures/big_eel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "game/objects/creatures/big_eel.h"

#include "game/creature.h"
#include "game/objects/common.h"
#include "global/const.h"
#include "global/funcs.h"

#define BIG_EEL_HITPOINTS 20

void BigEel_Setup(void)
{
OBJECT *const obj = Object_GetObject(O_BIG_EEL);
if (!obj->loaded) {
return;
}

obj->control = BigEel_Control;
obj->collision = Creature_Collision;

obj->hit_points = BIG_EEL_HITPOINTS;

obj->water_creature = 1;
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
}
3 changes: 3 additions & 0 deletions src/tr2/game/objects/creatures/big_eel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void BigEel_Setup(void);
29 changes: 29 additions & 0 deletions src/tr2/game/objects/creatures/big_spider.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "game/objects/creatures/big_spider.h"

#include "game/creature.h"
#include "game/objects/common.h"
#include "global/funcs.h"

#define BIG_SPIDER_HITPOINTS 40
#define BIG_SPIDER_RADIUS (WALL_L / 3) // = 341

void BigSpider_Setup(void)
{
OBJECT *const obj = Object_GetObject(O_BIG_SPIDER);
if (!obj->loaded) {
return;
}

obj->control = BigSpider_Control;
obj->collision = Creature_Collision;

obj->hit_points = BIG_SPIDER_HITPOINTS;
obj->radius = BIG_SPIDER_RADIUS;
obj->shadow_size = UNIT_SHADOW / 2;

obj->intelligent = 1;
obj->save_anim = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_flags = 1;
}
3 changes: 3 additions & 0 deletions src/tr2/game/objects/creatures/big_spider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void BigSpider_Setup(void);
Loading

0 comments on commit 92ed8d5

Please sign in to comment.