fp: Fix the attack box path finding and hit detection

This commit is contained in:
2023-10-08 17:07:20 +11:00
parent efec333b61
commit ecfe730744
3 changed files with 9 additions and 20 deletions
+4 -17
View File
@@ -1511,27 +1511,13 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
}
if (!has_waypoint_to_defender) {
FP_GameEntity *defender = FP_Game_GetEntity(game, closest_defender.entity);
FP_GameDirection aggro_direction = FP_GameDirection_Count;
DQN_FOR_UINDEX(dir_index, FP_GameDirection_Count) {
FP_GameEntityHandle slot_entity_handle = defender->aggro_slot[dir_index];
FP_GameEntity *slot_entity = FP_Game_GetEntity(game, slot_entity_handle);
if (FP_Game_IsNilEntity(slot_entity)) {
aggro_direction = DQN_CAST(FP_GameDirection)dir_index;
break;
}
}
FP_GameEntity *defender = FP_Game_GetEntity(game, closest_defender.entity);
FP_SentinelListLink<FP_GameWaypoint> *link = FP_SentinelList_MakeBefore(&entity->waypoints,
FP_SentinelList_Front(&entity->waypoints),
game->play.chunk_pool);
FP_GameWaypoint *waypoint = &link->data;
waypoint->entity = defender->handle;
if (aggro_direction != FP_GameDirection_Count) {
waypoint->type = FP_GameWaypointType_Side;
waypoint->type_direction = aggro_direction;
defender->aggro_slot[aggro_direction] = entity->handle;
}
waypoint->type = FP_GameWaypointType_ClosestSide;
}
} else {
if (closest_defender.dist_squared > DQN_SQUARED(aggro_dist_threshold * 2.f)) {
@@ -1667,7 +1653,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
Dqn_f32 arrival_threshold = {};
switch (waypoint->arrive) {
case FP_GameWaypointArrive_Default: {
arrival_threshold = FP_Game_MetersToPixelsNx1(game->play, 0.5f);
Dqn_Rect waypoint_hit_box = FP_Game_CalcEntityWorldHitBox(game, waypoint_entity->handle);
arrival_threshold = waypoint_hit_box.size.w * .5f;
} break;
case FP_GameWaypointArrive_WhenWithinEntitySize: {