Skip to content

Commit

Permalink
ape: fix vaulting animation
Browse files Browse the repository at this point in the history
Resolves #880.
  • Loading branch information
walkawayy authored Jun 20, 2023
1 parent 442ed2d commit 493287d
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## [Unreleased](https://github.com/rr-/Tomb1Main/compare/stable...develop) - ××××-××-××
- fixed the ape not performing the vault animation when climbing (#880)

## [2.15](https://github.com/rr-/Tomb1Main/compare/2.14...2.15) - 2023-06-08
- added an option to enable TR2+ jump-twist and somersault animations (#88)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
- fixed Scion 1 respawning on load
- fixed triggered flip effects not working if there are no sound devices
- fixed ceiling heights at times being miscalculated, resulting in camera issues and Lara being able to jump into the ceiling
- fixed the ape not performing the vault animation when climbing

#### Cheats
- added a fly cheat
Expand Down
8 changes: 4 additions & 4 deletions src/game/creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt)
item->pos.x_rot = angle;
}
} else {
floor = Room_GetFloor(item->pos.x, item->pos.y, item->pos.z, &room_num);
item->floor =
Room_GetHeight(floor, item->pos.x, item->pos.y, item->pos.z);

if (item->pos.y > item->floor) {
item->pos.y = item->floor;
} else if (item->floor - item->pos.y > STEP_L / 4) {
Expand All @@ -640,10 +644,6 @@ bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt)
}

item->pos.x_rot = 0;

floor = Room_GetFloor(item->pos.x, item->pos.y, item->pos.z, &room_num);
item->floor =
Room_GetHeight(floor, item->pos.x, item->pos.y, item->pos.z);
}

if (item->room_number != room_num) {
Expand Down
102 changes: 56 additions & 46 deletions src/game/objects/creatures/ape.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,77 +48,85 @@ typedef enum {

static BITE_INFO m_ApeBite = { 0, -19, 75, 15 };

void Ape_Setup(OBJECT_INFO *obj)
{
if (!obj->loaded) {
return;
}
obj->initialise = Creature_Initialise;
obj->control = Ape_Control;
obj->collision = Creature_Collision;
obj->shadow_size = UNIT_SHADOW / 2;
obj->hit_points = APE_HITPOINTS;
obj->pivot_length = 250;
obj->radius = APE_RADIUS;
obj->smartness = APE_SMARTNESS;
obj->intelligent = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_index + 52] |= BEB_ROT_Y;
}
static bool Ape_Vault(int16_t item_num, int16_t angle);

void Ape_Vault(int16_t item_num, int16_t angle)
static bool Ape_Vault(int16_t item_num, int16_t angle)
{
ITEM_INFO *item = &g_Items[item_num];
CREATURE_INFO *ape = item->data;
int32_t x = item->pos.x >> WALL_SHIFT;
int32_t y = item->pos.y;
int32_t z = item->pos.z >> WALL_SHIFT;
int16_t room_num = item->room_number;

if (ape->flags & APE_TURN_L_FLAG) {
item->pos.y_rot -= PHD_90;
ape->flags &= ~APE_TURN_L_FLAG;
} else if (item->flags & APE_TURN_R_FLAG) {
} else if (ape->flags & APE_TURN_R_FLAG) {
item->pos.y_rot += PHD_90;
ape->flags &= ~APE_TURN_R_FLAG;
}

int32_t xx = item->pos.z >> WALL_SHIFT;
int32_t yy = item->pos.x >> WALL_SHIFT;
int32_t y = item->pos.y;

Creature_Animate(item_num, angle, 0);

if (item->pos.y > y - STEP_L * 3 / 2) {
return;
return false;
}

int32_t x_floor = item->pos.z >> WALL_SHIFT;
int32_t y_floor = item->pos.x >> WALL_SHIFT;
if (xx == x_floor) {
if (yy == y_floor) {
return;
int32_t x_floor = item->pos.x >> WALL_SHIFT;
int32_t z_floor = item->pos.z >> WALL_SHIFT;

if (z == z_floor) {
if (x == x_floor) {
return false;
}

if (yy < y_floor) {
item->pos.x = (y_floor << WALL_SHIFT) - APE_SHIFT;
item->pos.y_rot = PHD_90;
} else {
item->pos.x = (yy << WALL_SHIFT) + APE_SHIFT;
if (x >= x_floor) {
item->pos.y_rot = -PHD_90;
item->pos.x = (x << WALL_SHIFT) + APE_SHIFT;
} else {
item->pos.y_rot = PHD_90;
item->pos.x = (x_floor << WALL_SHIFT) - APE_SHIFT;
}
} else if (yy == y_floor) {
if (xx < x_floor) {
item->pos.z = (x_floor << WALL_SHIFT) - APE_SHIFT;
} else if (x == x_floor) {
if (z < z_floor) {
item->pos.y_rot = 0;
item->pos.z = (z_floor << WALL_SHIFT) - APE_SHIFT;
} else {
item->pos.z = (xx << WALL_SHIFT) + APE_SHIFT;
item->pos.y_rot = -PHD_180;
item->pos.z = (z << WALL_SHIFT) + APE_SHIFT;
}
}

item->floor = y;
item->pos.y = y;
item->current_anim_state = APE_VAULT;
Item_SwitchToAnim(item, APE_VAULT_ANIM, -1);

if (item->room_number != room_num) {
Item_NewRoom(item_num, room_num);
}

return true;
}

void Ape_Setup(OBJECT_INFO *obj)
{
if (!obj->loaded) {
return;
}
obj->initialise = Creature_Initialise;
obj->control = Ape_Control;
obj->collision = Creature_Collision;
obj->shadow_size = UNIT_SHADOW / 2;
obj->hit_points = APE_HITPOINTS;
obj->pivot_length = 250;
obj->radius = APE_RADIUS;
obj->smartness = APE_SMARTNESS;
obj->intelligent = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_index + 52] |= BEB_ROT_Y;
}

void Ape_Control(int16_t item_num)
Expand Down Expand Up @@ -164,7 +172,7 @@ void Ape_Control(int16_t item_num)
if (ape->flags & APE_TURN_L_FLAG) {
item->pos.y_rot -= PHD_90;
ape->flags &= ~APE_TURN_L_FLAG;
} else if (item->flags & APE_TURN_R_FLAG) {
} else if (ape->flags & APE_TURN_R_FLAG) {
item->pos.y_rot += PHD_90;
ape->flags &= ~APE_TURN_R_FLAG;
}
Expand Down Expand Up @@ -249,7 +257,9 @@ void Ape_Control(int16_t item_num)

if (item->current_anim_state == APE_VAULT) {
Creature_Animate(item_num, angle, 0);
} else {
Ape_Vault(item_num, angle);
} else if (Ape_Vault(item_num, angle)) {
ape->maximum_turn = 0;
item->current_anim_state = APE_VAULT;
Item_SwitchToAnim(item, APE_VAULT_ANIM, -1);
}
}
1 change: 0 additions & 1 deletion src/game/objects/creatures/ape.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
#include <stdint.h>

void Ape_Setup(OBJECT_INFO *obj);
void Ape_Vault(int16_t item_num, int16_t angle);
void Ape_Control(int16_t item_num);

0 comments on commit 493287d

Please sign in to comment.