Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit b3d1880

Browse files
committed
wade - onwater state changes fixing;
1 parent 1a49832 commit b3d1880

File tree

1 file changed

+26
-41
lines changed

1 file changed

+26
-41
lines changed

src/state_control/state_control_Lara.cpp

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim)
10531053
case TR_STATE_LARA_WADE_FORWARD:
10541054
ent->character->rotate_speed_mult = 0.4f;
10551055
ent->dir_flag = ENT_MOVE_FORWARD;
1056+
ent->move_type = MOVE_ON_FLOOR;
10561057

10571058
if(ent->character->height_info.quicksand)
10581059
{
@@ -1076,7 +1077,8 @@ int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim)
10761077
}
10771078
else if(curr_fc->water)
10781079
{
1079-
if((curr_fc->transition_level - curr_fc->floor_hit.point[2] <= ent->character->wade_depth))
1080+
float depth = curr_fc->transition_level - curr_fc->floor_hit.point[2];
1081+
if(depth <= ent->character->wade_depth)
10801082
{
10811083
// run / walk case
10821084
if((cmd->move[0] == 1) && (!state->wall_collide))
@@ -1088,27 +1090,20 @@ int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim)
10881090
ss_anim->next_state = TR_STATE_LARA_STOP;
10891091
}
10901092
}
1091-
else if(curr_fc->transition_level - curr_fc->floor_hit.point[2] > (ent->character->height - ent->character->swim_depth))
1092-
{
1093-
// swim case
1094-
if(curr_fc->transition_level - curr_fc->floor_hit.point[2] > ent->character->height + ent->character->max_step_up_height)
1095-
{
1096-
Entity_SetAnimation(ent, ANIM_TYPE_BASE, TR_ANIMATION_LARA_START_FREE_FALL, 0); // swim underwater
1097-
}
1098-
else
1099-
{
1100-
Entity_SetAnimation(ent, ANIM_TYPE_BASE, TR_ANIMATION_LARA_ONWATER_IDLE, 0); // swim onwater
1101-
ent->move_type = MOVE_ON_WATER;
1102-
pos[2] = curr_fc->transition_level;
1103-
}
1104-
}
1105-
else if(curr_fc->transition_level - curr_fc->floor_hit.point[2] > ent->character->wade_depth) // wade case
1093+
else if(depth <= ent->character->height - ent->character->swim_depth)
11061094
{
1095+
// wade case
11071096
if((cmd->move[0] != 1) || (state->wall_collide))
11081097
{
11091098
ss_anim->next_state = TR_STATE_LARA_STOP;
11101099
}
11111100
}
1101+
else
1102+
{
1103+
Entity_SetAnimation(ent, ANIM_TYPE_BASE, TR_ANIMATION_LARA_ONWATER_SWIM_FORWARD, 0);
1104+
ss_anim->next_state = TR_STATE_LARA_ONWATER_FORWARD;
1105+
ent->move_type = MOVE_ON_WATER;
1106+
}
11121107
}
11131108
else // no water, stay or run / walk
11141109
{
@@ -1138,16 +1133,16 @@ int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim)
11381133
vec3_mul_scalar(global_offset, ent->transform + 4, -WALK_BACK_OFFSET);
11391134
global_offset[2] += ent->bf->bb_max[2];
11401135
i = Character_CheckNextStep(ent, global_offset, &next_fc);
1141-
if(ent->move_type == MOVE_FREE_FALLING)
1142-
{
1143-
Entity_SetAnimation(ent, ANIM_TYPE_BASE, TR_ANIMATION_LARA_START_FREE_FALL, 0);
1144-
}
1145-
else if(curr_fc->water && (curr_fc->floor_hit.point[2] + ent->character->height < curr_fc->transition_level))
1136+
if(curr_fc->water && (!curr_fc->floor_hit.hit || (curr_fc->floor_hit.point[2] + ent->character->height - ent->character->swim_depth < curr_fc->transition_level)))
11461137
{
11471138
Entity_SetAnimation(ent, ANIM_TYPE_BASE, TR_ANIMATION_LARA_ONWATER_SWIM_BACK, 0);
11481139
ss_anim->next_state = TR_STATE_LARA_ONWATER_BACK;
11491140
ent->move_type = MOVE_ON_WATER;
11501141
}
1142+
else if(ent->move_type == MOVE_FREE_FALLING)
1143+
{
1144+
Entity_SetAnimation(ent, ANIM_TYPE_BASE, TR_ANIMATION_LARA_START_FREE_FALL, 0);
1145+
}
11511146
else if((i < CHARACTER_STEP_DOWN_BIG) || (i > CHARACTER_STEP_UP_BIG))
11521147
{
11531148
ent->dir_flag = ENT_STAY;
@@ -1197,11 +1192,7 @@ int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim)
11971192
if(next_fc.floor_hit.hit && (next_fc.floor_hit.point[2] > pos[2] - ent->character->max_step_up_height) && (next_fc.floor_hit.point[2] <= pos[2] + ent->character->max_step_up_height))
11981193
//if(curr_fc->leg_l_floor.hit && (curr_fc->leg_l_floor.point[2] > pos[2] - ent->character->max_step_up_height) && (curr_fc->leg_l_floor.point[2] <= pos[2] + ent->character->max_step_up_height))
11991194
{
1200-
if(!curr_fc->water || (curr_fc->floor_hit.point[2] + ent->character->height > curr_fc->transition_level)) // if (floor_hit.hit == 0) then we went to MOVE_FREE_FALLING.
1201-
{
1202-
// continue walking
1203-
}
1204-
else
1195+
if(curr_fc->water && (!curr_fc->floor_hit.hit || (curr_fc->floor_hit.point[2] - curr_fc->transition_level > ent->character->height - ent->character->swim_depth)))
12051196
{
12061197
ss_anim->next_state = TR_STATE_LARA_ONWATER_LEFT;
12071198
ss_anim->onEndFrame = ent_to_on_water;
@@ -1235,11 +1226,7 @@ int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim)
12351226
if(next_fc.floor_hit.hit && (next_fc.floor_hit.point[2] > pos[2] - ent->character->max_step_up_height) && (next_fc.floor_hit.point[2] <= pos[2] + ent->character->max_step_up_height))
12361227
//if(curr_fc->leg_r_floor.hit && (curr_fc->leg_r_floor.point[2] > pos[2] - ent->character->max_step_up_height) && (curr_fc->leg_r_floor.point[2] <= pos[2] + ent->character->max_step_up_height))
12371228
{
1238-
if(!curr_fc->water || (curr_fc->floor_hit.point[2] + ent->character->height > curr_fc->transition_level)) // if (floor_hit.hit == 0) then we went to MOVE_FREE_FALLING.
1239-
{
1240-
// continue walking
1241-
}
1242-
else
1229+
if(curr_fc->water && (!curr_fc->floor_hit.hit || (curr_fc->floor_hit.point[2] - curr_fc->transition_level > ent->character->height - ent->character->swim_depth)))
12431230
{
12441231
ss_anim->next_state = TR_STATE_LARA_ONWATER_RIGHT;
12451232
ss_anim->onEndFrame = ent_to_on_water;
@@ -2644,17 +2631,14 @@ int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim)
26442631
ss_anim->next_state = TR_STATE_LARA_UNDERWATER_FORWARD;
26452632
ss_anim->onEndFrame = ent_set_underwater; // dive
26462633
}
2634+
else if(curr_fc->floor_hit.hit && (curr_fc->transition_level - curr_fc->floor_hit.point[2] < ent->character->height - ent->character->swim_depth))
2635+
{
2636+
ss_anim->next_state = TR_STATE_LARA_WADE_FORWARD;
2637+
ss_anim->onEndFrame = ent_set_on_floor; // to wade
2638+
}
26472639
else if((cmd->move[0] == 1) && !clean_action)
26482640
{
2649-
if(!curr_fc->floor_hit.hit || (pos[2] - ent->character->height > curr_fc->floor_hit.point[2]- ent->character->swim_depth))
2650-
{
2651-
//ent->current_state = ent->current_state; // swim forward
2652-
}
2653-
else
2654-
{
2655-
ss_anim->next_state = TR_STATE_LARA_WADE_FORWARD;
2656-
ss_anim->onEndFrame = ent_set_on_floor; // to wade
2657-
}
2641+
ss_anim->next_state = current_state;
26582642
}
26592643
else
26602644
{
@@ -3147,9 +3131,10 @@ int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim)
31473131
switch(ss_anim->current_animation)
31483132
{
31493133
case TR_ANIMATION_LARA_STAY_JUMP_SIDES:
3150-
ent->no_fix_skeletal_parts = BODY_PART_HANDS_2 | BODY_PART_HANDS_3 | BODY_PART_LEGS_3 | BODY_PART_HEAD;
3134+
ent->no_fix_skeletal_parts = BODY_PART_HANDS | BODY_PART_LEGS | BODY_PART_HEAD;
31513135
break;
31523136

3137+
case TR_ANIMATION_LARA_LANDING_HARD:
31533138
case TR_ANIMATION_LARA_CROUCH_TO_STAND:
31543139
ent->no_fix_skeletal_parts = BODY_PART_HANDS | BODY_PART_LEGS;
31553140
break;

0 commit comments

Comments
 (0)