Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements TeleportOpponentToNearestSafeLocation #165

Merged
merged 2 commits into from
Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/DETHRACE/common/opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,32 @@ void TeleportOpponentToNearestSafeLocation(tOpponent_spec* pOpponent_spec) {
int section_counter;
int found_safe_place;
LOG_TRACE("(%p)", pOpponent_spec);
NOT_IMPLEMENTED();

found_safe_place = 0;
section_no = FindNearestPathSection(&pOpponent_spec->car_spec->car_master_actor->t.t.translate.t, &direction_v, &intersect, &distance);
if (section_no < 0) {
return;
}
pOpponent_spec->last_in_view = 0;
TurnOpponentPhysicsOff(pOpponent_spec);
section_direction = BrVector3Dot(&pOpponent_spec->car_spec->direction, &direction_v) < 0.0f;
ClearOpponentsProjectedRoute(pOpponent_spec);
AddToOpponentsProjectedRoute(pOpponent_spec, section_no, section_direction);
TopUpRandomRoute(pOpponent_spec, -1);
section_counter = 1;
while (!found_safe_place) {
BrVector3Copy(&pOpponent_spec->car_spec->car_master_actor->t.t.translate.t, &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[pOpponent_spec->next_sections[section_counter].section_no].node_indices[pOpponent_spec->next_sections[section_counter].direction]].p);
CalcOpponentConspicuousnessWithAViewToCheatingLikeFuck(pOpponent_spec);
if (pOpponent_spec->player_to_oppo_d > gIn_view_distance) {
found_safe_place = 1;
}
section_counter++;
if (pOpponent_spec->nnext_sections <= section_counter) {
ShiftOpponentsProjectedRoute(pOpponent_spec, section_counter - 1);
section_counter = 0;
TopUpRandomRoute(pOpponent_spec, -1);
}
}
}

// IDA: void __usercall ChooseNewObjective(tOpponent_spec *pOpponent_spec@<EAX>, int pMust_choose_one@<EDX>)
Expand Down