Rev 1 | Rev 20 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 18 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "pedestrn.h" |
1 | #include "pedestrn.h" |
2 | #include " |
2 | #include "brender.h" |
3 | #include "car.h" |
3 | #include "car.h" |
4 | #include "constants.h" |
4 | #include "constants.h" |
5 | #include "displays.h" |
5 | #include "displays.h" |
6 | #include "errors.h" |
6 | #include "errors.h" |
7 | #include "globvars.h" |
7 | #include "globvars.h" |
Line 17... | Line 17... | ||
17 | #include "piping.h" |
17 | #include "piping.h" |
18 | #include "powerup.h" |
18 | #include "powerup.h" |
19 | #include "pratcam.h" |
19 | #include "pratcam.h" |
20 | #include "raycast.h" |
20 | #include "raycast.h" |
21 | #include "replay.h" |
21 | #include "replay.h" |
- | 22 | #include "shortcut.h" |
|
22 | #include "sound.h" |
23 | #include "sound.h" |
23 | #include "spark.h" |
24 | #include "spark.h" |
24 | #include "structur.h" |
25 | #include "structur.h" |
25 | #include "trig.h" |
26 | #include "trig.h" |
26 | #include "utility.h" |
27 | #include "utility.h" |
Line 435... | Line 436... | ||
435 | BrActorRemove(the_ped_gib->actor); |
436 | BrActorRemove(the_ped_gib->actor); |
436 | } |
437 | } |
437 | BrActorAdd(pPedestrian->actor, the_ped_gib->actor); |
438 | BrActorAdd(pPedestrian->actor, the_ped_gib->actor); |
438 | the_ped_gib->actor->render_style = BR_RSTYLE_FACES; |
439 | the_ped_gib->actor->render_style = BR_RSTYLE_FACES; |
439 | BrMatrix34Identity(&the_ped_gib->actor->t.t.mat); |
440 | BrMatrix34Identity(&the_ped_gib->actor->t.t.mat); |
440 | the_ped_gib->actor->t.t.translate.t.v[ |
441 | the_ped_gib->actor->t.t.translate.t.v[Y] += pPedestrian->actor->t.t.mat.m[1][1] * 2.f / (pPedestrian->height2 * 3.f); |
441 | the_ped_gib->actor->t.t.translate.t.v[ |
442 | the_ped_gib->actor->t.t.translate.t.v[Z] = 0.01f; |
442 | the_ped_gib->actor->material = gPed_gib_materials[0].materials[0]; |
443 | the_ped_gib->actor->material = gPed_gib_materials[0].materials[0]; |
443 | the_ped_gib->gib_index = 0; |
444 | the_ped_gib->gib_index = 0; |
444 | the_ped_gib->parent_index = GET_PEDESTRIAN_INDEX(pPedestrian); |
445 | the_ped_gib->parent_index = GET_PEDESTRIAN_INDEX(pPedestrian); |
445 | MungeModelSize(the_ped_gib->actor, gExploding_ped_scale[0]); |
446 | MungeModelSize(the_ped_gib->actor, gExploding_ped_scale[0]); |
446 | exploded = 1; |
447 | exploded = 1; |
Line 477... | Line 478... | ||
477 | BrActorRemove(the_ped_gib->actor); |
478 | BrActorRemove(the_ped_gib->actor); |
478 | } |
479 | } |
479 | BrActorAdd(pPedestrian->actor, the_ped_gib->actor); |
480 | BrActorAdd(pPedestrian->actor, the_ped_gib->actor); |
480 | the_ped_gib->actor->render_style = BR_RSTYLE_FACES; |
481 | the_ped_gib->actor->render_style = BR_RSTYLE_FACES; |
481 | BrMatrix34Identity(&the_ped_gib->actor->t.t.mat); |
482 | BrMatrix34Identity(&the_ped_gib->actor->t.t.mat); |
482 | the_ped_gib->actor->t.t.translate.t.v[ |
483 | the_ped_gib->actor->t.t.translate.t.v[Y] += pPedestrian->actor->t.t.mat.m[1][1] / (pPedestrian->height2 * 2.f); |
483 | do { |
484 | do { |
484 | next_gib_index = IRandomBetween(0, gPed_gib_materials[the_ped_gib->size].count - 1); |
485 | next_gib_index = IRandomBetween(0, gPed_gib_materials[the_ped_gib->size].count - 1); |
485 | } while (gPed_gib_maxes[the_ped_gib->size][next_gib_index] <= gPed_gib_counts[the_ped_gib->size][next_gib_index]); |
486 | } while (gPed_gib_maxes[the_ped_gib->size][next_gib_index] <= gPed_gib_counts[the_ped_gib->size][next_gib_index]); |
486 | gPed_gib_counts[the_ped_gib->size][next_gib_index]++; |
487 | gPed_gib_counts[the_ped_gib->size][next_gib_index]++; |
487 | the_ped_gib->actor->material = gPed_gib_materials[the_ped_gib->size].materials[next_gib_index]; |
488 | the_ped_gib->actor->material = gPed_gib_materials[the_ped_gib->size].materials[next_gib_index]; |
Line 569... | Line 570... | ||
569 | } else { |
570 | } else { |
570 | the_ped_gib->actor->t.t.mat.m[0][0] = -1.f / pedestrian->width; |
571 | the_ped_gib->actor->t.t.mat.m[0][0] = -1.f / pedestrian->width; |
571 | the_ped_gib->actor->t.t.mat.m[1][1] = -1.f / pedestrian->height2; |
572 | the_ped_gib->actor->t.t.mat.m[1][1] = -1.f / pedestrian->height2; |
572 | } |
573 | } |
573 | 574 | ||
574 | the_ped_gib->actor->t.t.translate.t.v[ |
575 | the_ped_gib->actor->t.t.translate.t.v[X] += the_ped_gib->x_speed * pFrame_period / pedestrian->width; |
575 | the_ped_gib->actor->t.t.translate.t.v[ |
576 | the_ped_gib->actor->t.t.translate.t.v[Y] += the_ped_gib->y_speed * pFrame_period / pedestrian->height2; |
576 | the_ped_gib->y_speed -= gFrame_period * gGravity_multiplier * 1.420289855072464e-6; |
577 | the_ped_gib->y_speed -= gFrame_period * gGravity_multiplier * 1.420289855072464e-6; |
577 | AddPedGibToPipingSession(i, &the_ped_gib->actor->t.t.mat, the_ped_gib->size, the_ped_gib->gib_index, the_ped_gib->parent_index); |
578 | AddPedGibToPipingSession(i, &the_ped_gib->actor->t.t.mat, the_ped_gib->size, the_ped_gib->gib_index, the_ped_gib->parent_index); |
578 | } |
579 | } |
579 | } else if (the_ped_gib->size == 0) { |
580 | } else if (the_ped_gib->size == 0) { |
580 | frame = (the_time - the_ped_gib->start_time) / 100 - 1; |
581 | frame = (the_time - the_ped_gib->start_time) / 100 - 1; |
Line 587... | Line 588... | ||
587 | if (frame < gPed_gib_materials[0].count) { |
588 | if (frame < gPed_gib_materials[0].count) { |
588 | the_ped_gib->actor->t.t.mat.m[0][0] = 1.f / gPedestrian_array[the_ped_gib->parent_index].width; |
589 | the_ped_gib->actor->t.t.mat.m[0][0] = 1.f / gPedestrian_array[the_ped_gib->parent_index].width; |
589 | the_ped_gib->actor->t.t.mat.m[1][1] = 1.f / gPedestrian_array[the_ped_gib->parent_index].height2; |
590 | the_ped_gib->actor->t.t.mat.m[1][1] = 1.f / gPedestrian_array[the_ped_gib->parent_index].height2; |
590 | the_ped_gib->actor->material = gPed_gib_materials[0].materials[frame]; |
591 | the_ped_gib->actor->material = gPed_gib_materials[0].materials[frame]; |
591 | MungeModelSize(the_ped_gib->actor, gExploding_ped_scale[frame]); |
592 | MungeModelSize(the_ped_gib->actor, gExploding_ped_scale[frame]); |
592 | if (frame == 1 && the_ped_gib->actor->t.t.translate.t.v[ |
593 | if (frame == 1 && the_ped_gib->actor->t.t.translate.t.v[Z] == 0.01f) { |
593 | the_ped_gib->actor->t.t.translate.t.v[ |
594 | the_ped_gib->actor->t.t.translate.t.v[Z] = -0.01f; |
594 | } |
595 | } |
595 | AddPedGibToPipingSession(i, &the_ped_gib->actor->t.t.mat, the_ped_gib->size, frame, the_ped_gib->parent_index); |
596 | AddPedGibToPipingSession(i, &the_ped_gib->actor->t.t.mat, the_ped_gib->size, frame, the_ped_gib->parent_index); |
596 | } else { |
597 | } else { |
597 | the_ped_gib->size = -1; |
598 | the_ped_gib->size = -1; |
598 | BrActorRemove(the_ped_gib->actor); |
599 | BrActorRemove(the_ped_gib->actor); |
Line 699... | Line 700... | ||
699 | pPedestrian->irreversable = 1; |
700 | pPedestrian->irreversable = 1; |
700 | // fall through |
701 | // fall through |
701 | case ePed_instruc_point: |
702 | case ePed_instruc_point: |
702 | BrVector3Copy(&pPedestrian->to_pos, &instruction->data.point_data.position); |
703 | BrVector3Copy(&pPedestrian->to_pos, &instruction->data.point_data.position); |
703 | BrVector3Sub(&pPedestrian->direction, &pPedestrian->to_pos, &pPedestrian->actor->t.t.translate.t); |
704 | BrVector3Sub(&pPedestrian->direction, &pPedestrian->to_pos, &pPedestrian->actor->t.t.translate.t); |
704 | if (pPedestrian->to_pos.v[ |
705 | if (pPedestrian->to_pos.v[Y] >= 500.f) { |
705 | pPedestrian->direction.v[ |
706 | pPedestrian->direction.v[Y] = 0.f; |
706 | } |
707 | } |
707 | if (Vector3IsZero(&pPedestrian->direction) && instruction != gInitial_instruction) { |
708 | if (Vector3IsZero(&pPedestrian->direction) && instruction != gInitial_instruction) { |
708 | if (gInitial_instruction == NULL) { |
709 | if (gInitial_instruction == NULL) { |
709 | gInitial_instruction = instruction; |
710 | gInitial_instruction = instruction; |
710 | } |
711 | } |
Line 813... | Line 814... | ||
813 | return result; |
814 | return result; |
814 | } |
815 | } |
815 | 816 | ||
816 | // IDA: void __usercall MungePedestrianSequence(tPedestrian_data *pPedestrian@<EAX>, int pAction_changed@<EDX>) |
817 | // IDA: void __usercall MungePedestrianSequence(tPedestrian_data *pPedestrian@<EAX>, int pAction_changed@<EDX>) |
817 | void MungePedestrianSequence(tPedestrian_data* pPedestrian, int pAction_changed) { |
818 | void MungePedestrianSequence(tPedestrian_data* pPedestrian, int pAction_changed) { |
818 |
|
819 | tPedestrian_action* the_action; |
819 | int i; |
820 | int i; |
820 | int the_sequence; |
821 | int the_sequence; |
821 | int current_looping; |
822 | int current_looping; |
822 | br_scalar ped_movement_angle; |
823 | br_scalar ped_movement_angle; |
823 | float heading_difference; |
824 | float heading_difference; |
824 | tPedestrian_sequence* sequence_ptr; |
825 | tPedestrian_sequence* sequence_ptr; |
825 | LOG_TRACE("(%p, %d)", pPedestrian, pAction_changed); |
826 | LOG_TRACE("(%p, %d)", pPedestrian, pAction_changed); |
826 | 827 | ||
827 | if (pPedestrian->ref_number < 100) { |
828 | if (pPedestrian->ref_number < 100) { |
828 | ped_movement_angle = FastScalarArcTan2(pPedestrian->direction.v[ |
829 | ped_movement_angle = FastScalarArcTan2(pPedestrian->direction.v[X], pPedestrian->direction.v[Z]); |
829 | if (ped_movement_angle < pPedestrian->car_to_ped) { |
830 | if (ped_movement_angle < pPedestrian->car_to_ped) { |
830 | ped_movement_angle += 360.f; |
831 | ped_movement_angle += 360.f; |
831 | } |
832 | } |
832 | heading_difference = ped_movement_angle - pPedestrian->car_to_ped; |
833 | heading_difference = ped_movement_angle - pPedestrian->car_to_ped; |
833 | } else { |
834 | } else { |
Line 865... | Line 866... | ||
865 | 866 | ||
866 | if (pPedestrian->actor->parent != gDont_render_actor) { |
867 | if (pPedestrian->actor->parent != gDont_render_actor) { |
867 | BrActorRelink(gDont_render_actor, pPedestrian->actor); |
868 | BrActorRelink(gDont_render_actor, pPedestrian->actor); |
868 | pPedestrian->actor->render_style = BR_RSTYLE_NONE; |
869 | pPedestrian->actor->render_style = BR_RSTYLE_NONE; |
869 | pPedestrian->mid_air = 1; |
870 | pPedestrian->mid_air = 1; |
870 | if (pPedestrian->to_pos.v[ |
871 | if (pPedestrian->to_pos.v[Y] < 500.f) { |
871 | pPedestrian->to_pos.v[ |
872 | pPedestrian->to_pos.v[Y] += 1000.4f; |
872 | } |
873 | } |
873 | BrVector3Set(&pPedestrian->offset, 0.f, 0.f, 0.f); |
874 | BrVector3Set(&pPedestrian->offset, 0.f, 0.f, 0.f); |
874 | } |
875 | } |
875 | } |
876 | } |
876 | 877 | ||
Line 1043... | Line 1044... | ||
1043 | 1044 | ||
1044 | old_parent = NULL; |
1045 | old_parent = NULL; |
1045 | CalcPedWidthNHeight(pPedestrian, pPedestrian->colour_map, &pPedestrian->height2, &pPedestrian->width); |
1046 | CalcPedWidthNHeight(pPedestrian, pPedestrian->colour_map, &pPedestrian->height2, &pPedestrian->width); |
1046 | the_frame = &pPedestrian->sequences[pPedestrian->current_sequence].frames[MAX(pPedestrian->current_frame, 0)]; |
1047 | the_frame = &pPedestrian->sequences[pPedestrian->current_sequence].frames[MAX(pPedestrian->current_frame, 0)]; |
1047 | if (pPedestrian->ref_number >= 100 && pPedestrian->current_action == pPedestrian->fatal_car_impact_action) { |
1048 | if (pPedestrian->ref_number >= 100 && pPedestrian->current_action == pPedestrian->fatal_car_impact_action) { |
1048 | x_offset = the_frame->offset.v[ |
1049 | x_offset = the_frame->offset.v[X] * 2.0f; |
1049 | y_offset = the_frame->offset.v[ |
1050 | y_offset = the_frame->offset.v[Y]; |
1050 | pPedestrian->height2 *= 2.0f; |
1051 | pPedestrian->height2 *= 2.0f; |
1051 | pPedestrian->width *= 2.0f; |
1052 | pPedestrian->width *= 2.0f; |
1052 | } else { |
1053 | } else { |
1053 | x_offset = the_frame->offset.v[ |
1054 | x_offset = the_frame->offset.v[X]; |
1054 | y_offset = the_frame->offset.v[ |
1055 | y_offset = the_frame->offset.v[Y]; |
1055 | } |
1056 | } |
1056 | pPedestrian->flipped = the_frame->flipped; |
1057 | pPedestrian->flipped = the_frame->flipped; |
1057 | if (pPedestrian->actor->parent != gDont_render_actor) { |
1058 | if (pPedestrian->actor->parent != gDont_render_actor) { |
1058 | old_parent = pPedestrian->actor->parent; |
1059 | old_parent = pPedestrian->actor->parent; |
1059 | BrActorRelink(gDont_render_actor, pPedestrian->actor); |
1060 | BrActorRelink(gDont_render_actor, pPedestrian->actor); |
Line 1081... | Line 1082... | ||
1081 | / (br_scalar)(pPedestrian->sequences[pPedestrian->current_sequence].looping_frame_start - 1) * 180.0f)) |
1082 | / (br_scalar)(pPedestrian->sequences[pPedestrian->current_sequence].looping_frame_start - 1) * 180.0f)) |
1082 | * pPedestrian->jump_magnitude; |
1083 | * pPedestrian->jump_magnitude; |
1083 | } |
1084 | } |
1084 | if (old_parent != NULL) { |
1085 | if (old_parent != NULL) { |
1085 | BrMatrix34PostTranslate(&pPedestrian->actor->t.t.mat, |
1086 | BrMatrix34PostTranslate(&pPedestrian->actor->t.t.mat, |
1086 | old_parent->t.t.translate.t.v[ |
1087 | old_parent->t.t.translate.t.v[X] + x_offset, |
1087 | old_parent->t.t.translate.t.v[ |
1088 | old_parent->t.t.translate.t.v[Y] + y_offset, |
1088 | old_parent->t.t.translate.t.v[ |
1089 | old_parent->t.t.translate.t.v[Z]); |
1089 | BrActorRelink(old_parent, pPedestrian->actor); |
1090 | BrActorRelink(old_parent, pPedestrian->actor); |
1090 | BrVector3Accumulate(&pPedestrian->actor->t.t.translate.t, &pPedestrian->offset); |
1091 | BrVector3Accumulate(&pPedestrian->actor->t.t.translate.t, &pPedestrian->offset); |
1091 | } else if (pPedestrian->spin_period == 0.0f) { |
1092 | } else if (pPedestrian->spin_period == 0.0f) { |
1092 | BrMatrix34PostTranslate(&pPedestrian->actor->t.t.mat, |
1093 | BrMatrix34PostTranslate(&pPedestrian->actor->t.t.mat, |
1093 | pPedestrian->pos.v[ |
1094 | pPedestrian->pos.v[X] + x_offset - pPedestrian->offset.v[X], |
1094 | pPedestrian->pos.v[ |
1095 | pPedestrian->pos.v[Y] + y_offset - pPedestrian->offset.v[Y], |
1095 | pPedestrian->pos.v[ |
1096 | pPedestrian->pos.v[Z]); |
1096 | BrVector3Set(&pPedestrian->offset, x_offset, y_offset, 0.0f); |
1097 | BrVector3Set(&pPedestrian->offset, x_offset, y_offset, 0.0f); |
1097 | } else { |
1098 | } else { |
1098 | BrMatrix34PostTranslate(&pPedestrian->actor->t.t.mat, |
1099 | BrMatrix34PostTranslate(&pPedestrian->actor->t.t.mat, |
1099 | pPedestrian->offset.v[ |
1100 | pPedestrian->offset.v[X] + x_offset, |
1100 | pPedestrian->offset.v[ |
1101 | pPedestrian->offset.v[Y] + y_offset, |
1101 | pPedestrian->offset.v[ |
1102 | pPedestrian->offset.v[Z]); |
1102 | } |
1103 | } |
1103 | gCurrent_lollipop_index = AddToLollipopQueue(pPedestrian->actor, gCurrent_lollipop_index); |
1104 | gCurrent_lollipop_index = AddToLollipopQueue(pPedestrian->actor, gCurrent_lollipop_index); |
1104 | } |
1105 | } |
1105 | 1106 | ||
1106 | // IDA: void __usercall ChangeActionTo(tPedestrian_data *pPedestrian@<EAX>, int pAction_index@<EDX>, int pRedo_frames_etc@<EBX>) |
1107 | // IDA: void __usercall ChangeActionTo(tPedestrian_data *pPedestrian@<EAX>, int pAction_index@<EDX>, int pRedo_frames_etc@<EBX>) |
Line 1226... | Line 1227... | ||
1226 | LOG_TRACE("(%p, %f, %p)", pPedestrian, pDanger_level, pDanger_direction); |
1227 | LOG_TRACE("(%p, %f, %p)", pPedestrian, pDanger_level, pDanger_direction); |
1227 | 1228 | ||
1228 | if (gAttracted_pedestrians) { |
1229 | if (gAttracted_pedestrians) { |
1229 | BrVector3Scale(pDanger_direction, pDanger_direction, -1.f); |
1230 | BrVector3Scale(pDanger_direction, pDanger_direction, -1.f); |
1230 | } |
1231 | } |
1231 | old_y = pPedestrian->actor->t.t.translate.t.v[ |
1232 | old_y = pPedestrian->actor->t.t.translate.t.v[Y]; |
1232 | if (pPedestrian->current_action != pPedestrian->fatal_car_impact_action |
1233 | if (pPedestrian->current_action != pPedestrian->fatal_car_impact_action |
1233 | && pPedestrian->current_action != pPedestrian->fatal_ground_impact_action |
1234 | && pPedestrian->current_action != pPedestrian->fatal_ground_impact_action |
1234 | && pPedestrian->current_action != pPedestrian->giblets_action) { |
1235 | && pPedestrian->current_action != pPedestrian->giblets_action) { |
1235 | the_action = &pPedestrian->action_list[pPedestrian->current_action]; |
1236 | the_action = &pPedestrian->action_list[pPedestrian->current_action]; |
1236 | if (!pPedestrian->done_initial) { |
1237 | if (!pPedestrian->done_initial) { |
Line 1279... | Line 1280... | ||
1279 | if (PercentageChance(100 / (gVesuvians_last_time != 0 ? gVesuvians_last_time : 1))) { |
1280 | if (PercentageChance(100 / (gVesuvians_last_time != 0 ? gVesuvians_last_time : 1))) { |
1280 | BurstPedestrian(pPedestrian, .001f, 0); |
1281 | BurstPedestrian(pPedestrian, .001f, 0); |
1281 | } |
1282 | } |
1282 | gVesuvians_this_time++; |
1283 | gVesuvians_this_time++; |
1283 | } |
1284 | } |
1284 | if (pPedestrian->to_pos.v[ |
1285 | if (pPedestrian->to_pos.v[Y] < 500.f) { |
1285 | pPedestrian->falling_speed = 0.f; |
1286 | pPedestrian->falling_speed = 0.f; |
1286 | pPedestrian->mid_air = 0; |
1287 | pPedestrian->mid_air = 0; |
1287 | } else { |
1288 | } else { |
1288 | BrVector3Copy(&cast_point, &pPedestrian->actor->t.t.translate.t); |
1289 | BrVector3Copy(&cast_point, &pPedestrian->actor->t.t.translate.t); |
1289 | if (cast_point.v[ |
1290 | if (cast_point.v[Y] >= 500.f) { |
1290 | cast_point.v[ |
1291 | cast_point.v[Y] -= 999.6f; |
1291 | pPedestrian->pos.v[ |
1292 | pPedestrian->pos.v[Y] = pPedestrian->actor->t.t.translate.t.v[Y] = FindYVerticallyBelow2(&cast_point); |
1292 | pPedestrian->falling_speed = 0.f; |
1293 | pPedestrian->falling_speed = 0.f; |
1293 | pPedestrian->mid_air = 0; |
1294 | pPedestrian->mid_air = 0; |
1294 | pPedestrian->spin_period = 0; |
1295 | pPedestrian->spin_period = 0; |
1295 | BrVector3Set(&pPedestrian->offset, 0.f, 0.f, 0.f); |
1296 | BrVector3Set(&pPedestrian->offset, 0.f, 0.f, 0.f); |
1296 | } else { |
1297 | } else { |
1297 | if (pPedestrian->current_speed == 0.f && !pPedestrian->mid_air) { |
1298 | if (pPedestrian->current_speed == 0.f && !pPedestrian->mid_air) { |
1298 | pPedestrian->mid_air = 0; |
1299 | pPedestrian->mid_air = 0; |
1299 | } else { |
1300 | } else { |
1300 | cast_point.v[ |
1301 | cast_point.v[Y] = old_y + .4f; |
1301 | new_y = FindYVerticallyBelow2(&cast_point); |
1302 | new_y = FindYVerticallyBelow2(&cast_point); |
1302 | if (new_y > old_y) { |
1303 | if (new_y > old_y) { |
1303 | pPedestrian->spin_period = 0.f; |
1304 | pPedestrian->spin_period = 0.f; |
1304 | BrVector3Set(&pPedestrian->offset, 0.f, 0.f, 0.f); |
1305 | BrVector3Set(&pPedestrian->offset, 0.f, 0.f, 0.f); |
1305 | pPedestrian->mid_air = 0; |
1306 | pPedestrian->mid_air = 0; |
1306 | pPedestrian->falling_speed = 0.f; |
1307 | pPedestrian->falling_speed = 0.f; |
1307 | pPedestrian->pos.v[ |
1308 | pPedestrian->pos.v[Y] = pPedestrian->actor->t.t.translate.t.v[Y] = new_y; |
1308 | } else { |
1309 | } else { |
1309 | grav_times_period = ped_gravity * gFrame_period; |
1310 | grav_times_period = ped_gravity * gFrame_period; |
1310 | pPedestrian->falling_speed += grav_times_period; |
1311 | pPedestrian->falling_speed += grav_times_period; |
1311 | pPedestrian->actor->t.t.translate.t.v[ |
1312 | pPedestrian->actor->t.t.translate.t.v[Y] -= gFrame_period * pPedestrian->falling_speed; |
1312 | pPedestrian->pos.v[ |
1313 | pPedestrian->pos.v[Y] = pPedestrian->actor->t.t.translate.t.v[Y]; |
1313 | if (pPedestrian->spin_period != 0.f) { |
1314 | if (pPedestrian->spin_period != 0.f) { |
1314 | pPedestrian->offset.v[ |
1315 | pPedestrian->offset.v[Y] -= gFrame_period * pPedestrian->falling_speed; |
1315 | } |
1316 | } |
1316 | if (pPedestrian->hit_points > 0 |
1317 | if (pPedestrian->hit_points > 0 |
1317 | && pPedestrian->falling_sound >= 0 |
1318 | && pPedestrian->falling_sound >= 0 |
1318 | && pPedestrian->falling_speed >= 0.0008f) { |
1319 | && pPedestrian->falling_speed >= 0.0008f) { |
1319 | DRS3StopSound(pPedestrian->last_sound); |
1320 | DRS3StopSound(pPedestrian->last_sound); |
Line 1332... | Line 1333... | ||
1332 | 0, |
1333 | 0, |
1333 | the_pitch, |
1334 | the_pitch, |
1334 | &pPedestrian->pos); |
1335 | &pPedestrian->pos); |
1335 | pPedestrian->falling_sound = -1; |
1336 | pPedestrian->falling_sound = -1; |
1336 | } |
1337 | } |
1337 | if (new_y <= pPedestrian->actor->t.t.translate.t.v[ |
1338 | if (new_y <= pPedestrian->actor->t.t.translate.t.v[Y]) { |
1338 | pPedestrian->mid_air = 1; |
1339 | pPedestrian->mid_air = 1; |
1339 | } else { |
1340 | } else { |
1340 | pPedestrian->pos.v[ |
1341 | pPedestrian->pos.v[Y] = pPedestrian->actor->t.t.translate.t.v[Y] = new_y; |
1341 | if (pPedestrian->spin_period != 0.f) { |
1342 | if (pPedestrian->spin_period != 0.f) { |
1342 | pPedestrian->offset.v[ |
1343 | pPedestrian->offset.v[Y] = pPedestrian->pos.v[Y]; |
1343 | } |
1344 | } |
1344 | if (pPedestrian->hit_points < 0) { |
1345 | if (pPedestrian->hit_points < 0) { |
1345 | BrVector3Copy(&pPedestrian->to_pos, &pPedestrian->pos); |
1346 | BrVector3Copy(&pPedestrian->to_pos, &pPedestrian->pos); |
1346 | } |
1347 | } |
1347 | damage = (pPedestrian->falling_speed - 0.0015f) * 100000.f; |
1348 | damage = (pPedestrian->falling_speed - 0.0015f) * 100000.f; |
Line 1394... | Line 1395... | ||
1394 | most_dangerous = 0.f; |
1395 | most_dangerous = 0.f; |
1395 | ped_pos = &pPedestrian->actor->t.t.translate.t; |
1396 | ped_pos = &pPedestrian->actor->t.t.translate.t; |
1396 | for (i = 0; i < gNum_active_cars; i++) { |
1397 | for (i = 0; i < gNum_active_cars; i++) { |
1397 | car = gActive_car_list[i]; |
1398 | car = gActive_car_list[i]; |
1398 | if (car->driver == eDriver_local_human) { |
1399 | if (car->driver == eDriver_local_human) { |
1399 | camera_view_angle = FastScalarArcTan2(ped_pos->v[ |
1400 | camera_view_angle = FastScalarArcTan2(ped_pos->v[X] - gCamera_to_world.m[3][X], ped_pos->v[Z] - gCamera_to_world.m[3][Z]); |
1400 | pPedestrian->car_to_ped = camera_view_angle; |
1401 | pPedestrian->car_to_ped = camera_view_angle; |
1401 | } |
1402 | } |
1402 | if (gBlind_pedestrians) { |
1403 | if (gBlind_pedestrians) { |
1403 | return car->keys.horn ? 100.f : 0.f; |
1404 | return car->keys.horn ? 100.f : 0.f; |
1404 | } |
1405 | } |
1405 | distance_squared = (ped_pos->v[ |
1406 | distance_squared = (ped_pos->v[X] - car->pos.v[X]) * (ped_pos->v[X] - car->pos.v[X]) |
1406 | + 10.f * (ped_pos->v[ |
1407 | + 10.f * (ped_pos->v[Y] - car->pos.v[Y]) * 10.f * (ped_pos->v[Y] - car->pos.v[Y]) |
1407 | + (ped_pos->v[ |
1408 | + (ped_pos->v[Z] - car->pos.v[Z]) * (ped_pos->v[Z] - car->pos.v[Z]); |
1408 | if (distance_squared < gMax_distance_squared) { |
1409 | if (distance_squared < gMax_distance_squared) { |
1409 | car_movement_angle = FastScalarArcTan2(car->direction.v[ |
1410 | car_movement_angle = FastScalarArcTan2(car->direction.v[X], car->direction.v[Z]); |
1410 | car_to_pedestrian_angle = FastScalarArcTan2(ped_pos->v[ |
1411 | car_to_pedestrian_angle = FastScalarArcTan2(ped_pos->v[X] - car->pos.v[X], ped_pos->v[Z] - car->pos.v[Z]); |
1411 | if (car_to_pedestrian_angle > car_movement_angle) { |
1412 | if (car_to_pedestrian_angle > car_movement_angle) { |
1412 | car_movement_angle += 360.f; |
1413 | car_movement_angle += 360.f; |
1413 | } |
1414 | } |
1414 | heading_difference = car_movement_angle - car_to_pedestrian_angle; |
1415 | heading_difference = car_movement_angle - car_to_pedestrian_angle; |
1415 | if (heading_difference > 180.f) { |
1416 | if (heading_difference > 180.f) { |
Line 1466... | Line 1467... | ||
1466 | if (fabsf(pPedestrian->current_speed) >= fabsf(pCar->speed)) { |
1467 | if (fabsf(pPedestrian->current_speed) >= fabsf(pCar->speed)) { |
1467 | BrVector3Scale(&ped_move_in_global, &pPedestrian->direction, -fabsf(pPedestrian->current_speed)); |
1468 | BrVector3Scale(&ped_move_in_global, &pPedestrian->direction, -fabsf(pPedestrian->current_speed)); |
1468 | } else { |
1469 | } else { |
1469 | BrVector3Scale(&ped_move_in_global, &pCar->direction, fabsf(pCar->speed)); |
1470 | BrVector3Scale(&ped_move_in_global, &pCar->direction, fabsf(pCar->speed)); |
1470 | } |
1471 | } |
1471 | if (fabsf(ped_move_in_global.v[ |
1472 | if (fabsf(ped_move_in_global.v[X]) < 5e-5f || fabsf(ped_move_in_global.v[Z]) < 5e-5f) { |
1472 | return ePed_hit_unknown; |
1473 | return ePed_hit_unknown; |
1473 | } |
1474 | } |
1474 | BrActorToActorMatrix34(&global_to_car, gDont_render_actor, pCar_actor); |
1475 | BrActorToActorMatrix34(&global_to_car, gDont_render_actor, pCar_actor); |
1475 | BrMatrix34ApplyV(&ped_move_in_car, &ped_move_in_global, &global_to_car); |
1476 | BrMatrix34ApplyV(&ped_move_in_car, &ped_move_in_global, &global_to_car); |
1476 | if (ped_move_in_car.v[ |
1477 | if (ped_move_in_car.v[X] >= 0.f) { |
1477 | x = pCar_bounds_max_x - pMin_ped_bounds_car->v[ |
1478 | x = pCar_bounds_max_x - pMin_ped_bounds_car->v[X]; |
1478 | } else { |
1479 | } else { |
1479 | x = pCar_bounds_min_x - pMax_ped_bounds_car->v[ |
1480 | x = pCar_bounds_min_x - pMax_ped_bounds_car->v[X]; |
1480 | } |
1481 | } |
1481 | if (ped_move_in_car.v[ |
1482 | if (ped_move_in_car.v[Z] >= 0.f) { |
1482 | z = pCar_bounds_max_z - pMin_ped_bounds_car->v[ |
1483 | z = pCar_bounds_max_z - pMin_ped_bounds_car->v[Z]; |
1483 | } else { |
1484 | } else { |
1484 | z = pCar_bounds_min_z - pMax_ped_bounds_car->v[ |
1485 | z = pCar_bounds_min_z - pMax_ped_bounds_car->v[Z]; |
1485 | } |
1486 | } |
1486 | 1487 | ||
1487 | if (ped_move_in_car.v[ |
1488 | if (ped_move_in_car.v[Z] != 0.f) { |
1488 | t = z / ped_move_in_car.v[ |
1489 | t = z / ped_move_in_car.v[Z] * ped_move_in_car.v[X]; |
1489 | } |
1490 | } |
1490 | if (ped_move_in_car.v[ |
1491 | if (ped_move_in_car.v[Z] == 0.f || t + pPed_x < pCar_bounds_min_x || t + pPed_x > pCar_bounds_max_x) { |
1491 | if (ped_move_in_car.v[ |
1492 | if (ped_move_in_car.v[X] == 0.f) { |
1492 | return ePed_hit_unknown; |
1493 | return ePed_hit_unknown; |
1493 | } |
1494 | } |
1494 | t = x / ped_move_in_car.v[ |
1495 | t = x / ped_move_in_car.v[X]; |
1495 | z_to_use = t * ped_move_in_car.v[ |
1496 | z_to_use = t * ped_move_in_car.v[Z]; |
1496 | if (z_to_use + pPed_z < pCar_bounds_min_z || z_to_use + pPed_z > pCar_bounds_max_z) { |
1497 | if (z_to_use + pPed_z < pCar_bounds_min_z || z_to_use + pPed_z > pCar_bounds_max_z) { |
1497 | return ePed_hit_unknown; |
1498 | return ePed_hit_unknown; |
1498 | } |
1499 | } |
1499 | x_to_use = x; |
1500 | x_to_use = x; |
1500 | if (ped_move_in_car.v[ |
1501 | if (ped_move_in_car.v[X] >= 0.f) { |
1501 | result = ePed_hit_rside; |
1502 | result = ePed_hit_rside; |
1502 | } else { |
1503 | } else { |
1503 | result = ePed_hit_lside; |
1504 | result = ePed_hit_lside; |
1504 | } |
1505 | } |
1505 | } else { |
1506 | } else { |
1506 | z_to_use = z; |
1507 | z_to_use = z; |
1507 | if (ped_move_in_car.v[ |
1508 | if (ped_move_in_car.v[Z] >= 0.f) { |
1508 | result = ePed_hit_back; |
1509 | result = ePed_hit_back; |
1509 | } else { |
1510 | } else { |
1510 | result = ePed_hit_front; |
1511 | result = ePed_hit_front; |
1511 | } |
1512 | } |
1512 | } |
1513 | } |
1513 | BrVector3Set(&scaled_car_direction, 1.01f * x_to_use, 0.f, 1.01f * z_to_use); |
1514 | BrVector3Set(&scaled_car_direction, 1.01f * x_to_use, 0.f, 1.01f * z_to_use); |
1514 | BrMatrix34TApplyV(&scaled_ped_direction, &scaled_car_direction, &global_to_car); |
1515 | BrMatrix34TApplyV(&scaled_ped_direction, &scaled_car_direction, &global_to_car); |
1515 | scaled_ped_direction.v[ |
1516 | scaled_ped_direction.v[Y] = 0.f; |
1516 | if (pCar->speed == 0.f || gFrame_period * fabsf(pCar->speed) > BrVector3Length(&scaled_ped_direction) / 10.f) { |
1517 | if (pCar->speed == 0.f || gFrame_period * fabsf(pCar->speed) > BrVector3Length(&scaled_ped_direction) / 10.f) { |
1517 | BrVector3Accumulate(&pPedestrian->actor->t.t.translate.t, &scaled_ped_direction); |
1518 | BrVector3Accumulate(&pPedestrian->actor->t.t.translate.t, &scaled_ped_direction); |
1518 | BrVector3Accumulate(&pPedestrian->pos, &scaled_ped_direction); |
1519 | BrVector3Accumulate(&pPedestrian->pos, &scaled_ped_direction); |
1519 | } |
1520 | } |
1520 | return result; |
1521 | return result; |
Line 1542... | Line 1543... | ||
1542 | 1543 | ||
1543 | size_sqr = pSize + .05f; |
1544 | size_sqr = pSize + .05f; |
1544 | dist_sqr = size_sqr * WORLD_SCALE * size_sqr * WORLD_SCALE; |
1545 | dist_sqr = size_sqr * WORLD_SCALE * size_sqr * WORLD_SCALE; |
1545 | squish = 0; |
1546 | squish = 0; |
1546 | for (wheel = 0; wheel < COUNT_OF(pCar->blood_remaining); wheel++) { |
1547 | for (wheel = 0; wheel < COUNT_OF(pCar->blood_remaining); wheel++) { |
1547 | ped_m_x = pCar->wpos[wheel].v[ |
1548 | ped_m_x = pCar->wpos[wheel].v[X] - pPed_car->v[X] * WORLD_SCALE; |
1548 | ped_m_z = pCar->wpos[wheel].v[ |
1549 | ped_m_z = pCar->wpos[wheel].v[Z] - pPed_car->v[Z] * WORLD_SCALE; |
1549 | if (pCar->blood_remaining[wheel] == 0.f && ped_m_x * ped_m_x + ped_m_z * ped_m_z < dist_sqr) { |
1550 | if (pCar->blood_remaining[wheel] == 0.f && ped_m_x * ped_m_x + ped_m_z * ped_m_z < dist_sqr) { |
1550 | pCar->blood_remaining[wheel] = SRandomBetween(2.f, 8.f); |
1551 | pCar->blood_remaining[wheel] = SRandomBetween(2.f, 8.f); |
1551 | pCar->special_start[wheel] = *pPed_glob; |
1552 | pCar->special_start[wheel] = *pPed_glob; |
1552 | squish = 1; |
1553 | squish = 1; |
1553 | } |
1554 | } |
Line 1673... | Line 1674... | ||
1673 | } |
1674 | } |
1674 | BrActorToActorMatrix34(&ped_to_car, pPedestrian->actor, car_actor); |
1675 | BrActorToActorMatrix34(&ped_to_car, pPedestrian->actor, car_actor); |
1675 | BrMatrix34ApplyP(&min_ped_bounds_car, &min_ped_bounds, &ped_to_car); |
1676 | BrMatrix34ApplyP(&min_ped_bounds_car, &min_ped_bounds, &ped_to_car); |
1676 | BrMatrix34ApplyP(&max_ped_bounds_car, &max_ped_bounds, &ped_to_car); |
1677 | BrMatrix34ApplyP(&max_ped_bounds_car, &max_ped_bounds, &ped_to_car); |
1677 | // use gross_dismiss as temporary |
1678 | // use gross_dismiss as temporary |
1678 | if (max_ped_bounds_car.v[ |
1679 | if (max_ped_bounds_car.v[X] < min_ped_bounds_car.v[X]) { |
1679 | SwapValuesUsingTemporary(max_ped_bounds_car.v[ |
1680 | SwapValuesUsingTemporary(max_ped_bounds_car.v[X], min_ped_bounds_car.v[X], gross_dismiss); |
1680 | } |
1681 | } |
1681 | if (max_ped_bounds_car.v[ |
1682 | if (max_ped_bounds_car.v[Y] < min_ped_bounds_car.v[Y]) { |
1682 | SwapValuesUsingTemporary(max_ped_bounds_car.v[ |
1683 | SwapValuesUsingTemporary(max_ped_bounds_car.v[Y], min_ped_bounds_car.v[Y], gross_dismiss); |
1683 | } |
1684 | } |
1684 | if (max_ped_bounds_car.v[ |
1685 | if (max_ped_bounds_car.v[Z] < min_ped_bounds_car.v[Z]) { |
1685 | SwapValuesUsingTemporary(max_ped_bounds_car.v[ |
1686 | SwapValuesUsingTemporary(max_ped_bounds_car.v[Z], min_ped_bounds_car.v[Z], gross_dismiss); |
1686 | } |
1687 | } |
1687 | car_bounds_min_x = the_car->bounds[0].min.v[ |
1688 | car_bounds_min_x = the_car->bounds[0].min.v[X]; |
1688 | car_bounds_max_x = the_car->bounds[0].max.v[ |
1689 | car_bounds_max_x = the_car->bounds[0].max.v[X]; |
1689 | car_bounds_min_z = the_car->bounds[0].min.v[ |
1690 | car_bounds_min_z = the_car->bounds[0].min.v[Z]; |
1690 | car_bounds_max_z = the_car->bounds[0].max.v[ |
1691 | car_bounds_max_z = the_car->bounds[0].max.v[Z]; |
1691 | prev_car_bounds_min_x = car_bounds_min_x - the_car->velocity_car_space.v[ |
1692 | prev_car_bounds_min_x = car_bounds_min_x - the_car->velocity_car_space.v[X] * scalar_frame_time; |
1692 | prev_car_bounds_max_x = car_bounds_max_x - the_car->velocity_car_space.v[ |
1693 | prev_car_bounds_max_x = car_bounds_max_x - the_car->velocity_car_space.v[X] * scalar_frame_time; |
1693 | prev_car_bounds_min_z = car_bounds_min_z - the_car->velocity_car_space.v[ |
1694 | prev_car_bounds_min_z = car_bounds_min_z - the_car->velocity_car_space.v[Z] * scalar_frame_time; |
1694 | prev_car_bounds_max_z = car_bounds_max_z - the_car->velocity_car_space.v[ |
1695 | prev_car_bounds_max_z = car_bounds_max_z - the_car->velocity_car_space.v[Z] * scalar_frame_time; |
1695 | if (!proximity_rayed) { |
1696 | if (!proximity_rayed) { |
1696 | if (!fated) { |
1697 | if (!fated) { |
1697 | if (the_car->velocity_car_space.v[ |
1698 | if (the_car->velocity_car_space.v[X] <= 0.0f) { |
1698 | if (the_car->velocity_car_space.v[ |
1699 | if (the_car->velocity_car_space.v[Z] <= 0.0f) { |
1699 | if (max_ped_bounds_car.v[ |
1700 | if (max_ped_bounds_car.v[X] <= car_bounds_min_x |
1700 | || min_ped_bounds_car.v[ |
1701 | || min_ped_bounds_car.v[X] >= prev_car_bounds_max_x |
1701 | || max_ped_bounds_car.v[ |
1702 | || max_ped_bounds_car.v[Z] <= car_bounds_min_z |
1702 | || min_ped_bounds_car.v[ |
1703 | || min_ped_bounds_car.v[Z] >= prev_car_bounds_max_z |
1703 | || (min_ped_bounds_car.v[ |
1704 | || (min_ped_bounds_car.v[X] > car_bounds_max_x |
1704 | && max_ped_bounds_car.v[ |
1705 | && max_ped_bounds_car.v[Z] < prev_car_bounds_min_z |
1705 | && prev_car_bounds_max_x - car_bounds_max_x != 0.0f |
1706 | && prev_car_bounds_max_x - car_bounds_max_x != 0.0f |
1706 | && (prev_car_bounds_min_z - car_bounds_min_z) / (prev_car_bounds_max_x - car_bounds_max_x) > (max_ped_bounds_car.v[ |
1707 | && (prev_car_bounds_min_z - car_bounds_min_z) / (prev_car_bounds_max_x - car_bounds_max_x) > (max_ped_bounds_car.v[Z] - car_bounds_min_z) / (min_ped_bounds_car.v[X] - car_bounds_max_x)) |
1707 | || (max_ped_bounds_car.v[ |
1708 | || (max_ped_bounds_car.v[X] < prev_car_bounds_min_x |
1708 | && min_ped_bounds_car.v[ |
1709 | && min_ped_bounds_car.v[Z] > car_bounds_max_z |
1709 | && car_bounds_min_x - prev_car_bounds_min_x != 0.0f |
1710 | && car_bounds_min_x - prev_car_bounds_min_x != 0.0f |
1710 | && (car_bounds_max_z - prev_car_bounds_max_z) / (car_bounds_min_x - prev_car_bounds_min_x) > (min_ped_bounds_car.v[ |
1711 | && (car_bounds_max_z - prev_car_bounds_max_z) / (car_bounds_min_x - prev_car_bounds_min_x) > (min_ped_bounds_car.v[Z] - prev_car_bounds_max_z) / (max_ped_bounds_car.v[X] - prev_car_bounds_min_x))) { |
1711 | continue; |
1712 | continue; |
1712 | } |
1713 | } |
1713 | } else if (max_ped_bounds_car.v[ |
1714 | } else if (max_ped_bounds_car.v[X] <= car_bounds_min_x |
1714 | || min_ped_bounds_car.v[ |
1715 | || min_ped_bounds_car.v[X] >= prev_car_bounds_max_x |
1715 | || max_ped_bounds_car.v[ |
1716 | || max_ped_bounds_car.v[Z] <= prev_car_bounds_min_z |
1716 | || min_ped_bounds_car.v[ |
1717 | || min_ped_bounds_car.v[Z] >= car_bounds_max_z |
1717 | || (max_ped_bounds_car.v[ |
1718 | || (max_ped_bounds_car.v[X] < prev_car_bounds_min_x |
1718 | && max_ped_bounds_car.v[ |
1719 | && max_ped_bounds_car.v[Z] < car_bounds_min_z |
1719 | && car_bounds_min_x - prev_car_bounds_min_x != 0.0f |
1720 | && car_bounds_min_x - prev_car_bounds_min_x != 0.0f |
1720 | && ((car_bounds_min_z - prev_car_bounds_min_z) / (car_bounds_min_x - prev_car_bounds_min_x) < (max_ped_bounds_car.v[ |
1721 | && ((car_bounds_min_z - prev_car_bounds_min_z) / (car_bounds_min_x - prev_car_bounds_min_x) < (max_ped_bounds_car.v[Z] - prev_car_bounds_min_z) / (max_ped_bounds_car.v[X] - prev_car_bounds_min_x))) |
1721 | || (min_ped_bounds_car.v[ |
1722 | || (min_ped_bounds_car.v[X] > car_bounds_max_x |
1722 | && min_ped_bounds_car.v[ |
1723 | && min_ped_bounds_car.v[Z] > prev_car_bounds_max_z |
1723 | && prev_car_bounds_max_x - car_bounds_max_x != 0.0f |
1724 | && prev_car_bounds_max_x - car_bounds_max_x != 0.0f |
1724 | && (prev_car_bounds_max_z - car_bounds_max_z) / (prev_car_bounds_max_x - car_bounds_max_x) < (min_ped_bounds_car.v[ |
1725 | && (prev_car_bounds_max_z - car_bounds_max_z) / (prev_car_bounds_max_x - car_bounds_max_x) < (min_ped_bounds_car.v[Z] - car_bounds_max_z) / (min_ped_bounds_car.v[X] - car_bounds_max_x))) { |
1725 | continue; |
1726 | continue; |
1726 | } |
1727 | } |
1727 | } else if (the_car->velocity_car_space.v[ |
1728 | } else if (the_car->velocity_car_space.v[Z] <= 0.0f) { |
1728 | if (max_ped_bounds_car.v[ |
1729 | if (max_ped_bounds_car.v[X] <= prev_car_bounds_min_x |
1729 | || min_ped_bounds_car.v[ |
1730 | || min_ped_bounds_car.v[X] >= car_bounds_max_x |
1730 | || max_ped_bounds_car.v[ |
1731 | || max_ped_bounds_car.v[Z] <= car_bounds_min_z |
1731 | || min_ped_bounds_car.v[ |
1732 | || min_ped_bounds_car.v[Z] >= prev_car_bounds_max_z |
1732 | || (max_ped_bounds_car.v[ |
1733 | || (max_ped_bounds_car.v[X] < car_bounds_min_x |
1733 | && max_ped_bounds_car.v[ |
1734 | && max_ped_bounds_car.v[Z] < prev_car_bounds_min_z |
1734 | && prev_car_bounds_min_x - car_bounds_min_x != 0.0f |
1735 | && prev_car_bounds_min_x - car_bounds_min_x != 0.0f |
1735 | && (prev_car_bounds_min_z - car_bounds_min_z) / (prev_car_bounds_min_x - car_bounds_min_x) < (max_ped_bounds_car.v[ |
1736 | && (prev_car_bounds_min_z - car_bounds_min_z) / (prev_car_bounds_min_x - car_bounds_min_x) < (max_ped_bounds_car.v[Z] - car_bounds_min_z) / (max_ped_bounds_car.v[X] - car_bounds_min_x)) |
1736 | || (min_ped_bounds_car.v[ |
1737 | || (min_ped_bounds_car.v[X] > prev_car_bounds_max_x |
1737 | && min_ped_bounds_car.v[ |
1738 | && min_ped_bounds_car.v[Z] > car_bounds_max_z |
1738 | && car_bounds_max_x - prev_car_bounds_max_x != 0.0f |
1739 | && car_bounds_max_x - prev_car_bounds_max_x != 0.0f |
1739 | && (car_bounds_max_z - prev_car_bounds_max_z) / (car_bounds_max_x - prev_car_bounds_max_x) < (min_ped_bounds_car.v[ |
1740 | && (car_bounds_max_z - prev_car_bounds_max_z) / (car_bounds_max_x - prev_car_bounds_max_x) < (min_ped_bounds_car.v[Z] - prev_car_bounds_max_z) / (min_ped_bounds_car.v[X] - prev_car_bounds_max_x))) { |
1740 | continue; |
1741 | continue; |
1741 | } |
1742 | } |
1742 | } else if (max_ped_bounds_car.v[ |
1743 | } else if (max_ped_bounds_car.v[X] <= prev_car_bounds_min_x |
1743 | || min_ped_bounds_car.v[ |
1744 | || min_ped_bounds_car.v[X] >= car_bounds_max_x |
1744 | || max_ped_bounds_car.v[ |
1745 | || max_ped_bounds_car.v[Z] <= prev_car_bounds_min_z |
1745 | || min_ped_bounds_car.v[ |
1746 | || min_ped_bounds_car.v[Z] >= car_bounds_max_z |
1746 | || (min_ped_bounds_car.v[ |
1747 | || (min_ped_bounds_car.v[X] > prev_car_bounds_max_x |
1747 | && max_ped_bounds_car.v[ |
1748 | && max_ped_bounds_car.v[Z] < car_bounds_min_z |
1748 | && car_bounds_max_x - prev_car_bounds_max_x != 0.0f |
1749 | && car_bounds_max_x - prev_car_bounds_max_x != 0.0f |
1749 | && (car_bounds_min_z - prev_car_bounds_min_z) / (car_bounds_max_x - prev_car_bounds_max_x) > (max_ped_bounds_car.v[ |
1750 | && (car_bounds_min_z - prev_car_bounds_min_z) / (car_bounds_max_x - prev_car_bounds_max_x) > (max_ped_bounds_car.v[Z] - prev_car_bounds_min_z) / (min_ped_bounds_car.v[X] - prev_car_bounds_max_x)) |
1750 | || (max_ped_bounds_car.v[ |
1751 | || (max_ped_bounds_car.v[X] < car_bounds_min_x |
1751 | && min_ped_bounds_car.v[ |
1752 | && min_ped_bounds_car.v[Z] > prev_car_bounds_max_z |
1752 | && prev_car_bounds_min_x - car_bounds_min_x != 0.0f |
1753 | && prev_car_bounds_min_x - car_bounds_min_x != 0.0f |
1753 | && (prev_car_bounds_max_z - car_bounds_max_z) / (prev_car_bounds_min_x - car_bounds_min_x) > (min_ped_bounds_car.v[ |
1754 | && (prev_car_bounds_max_z - car_bounds_max_z) / (prev_car_bounds_min_x - car_bounds_min_x) > (min_ped_bounds_car.v[Z] - car_bounds_max_z) / (max_ped_bounds_car.v[X] - car_bounds_min_x))) { |
1754 | continue; |
1755 | continue; |
1755 | } |
1756 | } |
1756 | } |
1757 | } |
1757 | proximity_rayed = 0; |
1758 | proximity_rayed = 0; |
1758 | } |
1759 | } |
1759 | if (pPedestrian->fate != (tCar_spec*)the_car |
1760 | if (pPedestrian->fate != (tCar_spec*)the_car |
1760 | && !proximity_rayed |
1761 | && !proximity_rayed |
1761 | && (the_car->bounds[0].max.v[ |
1762 | && (the_car->bounds[0].max.v[Y] < min_ped_bounds_car.v[Y] |
1762 | || the_car->bounds[0].min.v[ |
1763 | || the_car->bounds[0].min.v[Y] > max_ped_bounds_car.v[Y])) { |
1763 | continue; |
1764 | continue; |
1764 | } |
1765 | } |
1765 | pPedestrian->fate = NULL; |
1766 | pPedestrian->fate = NULL; |
1766 | if (pPedestrian->current_action == pPedestrian->fatal_car_impact_action |
1767 | if (pPedestrian->current_action == pPedestrian->fatal_car_impact_action |
1767 | || pPedestrian->current_action == pPedestrian->fatal_ground_impact_action) { |
1768 | || pPedestrian->current_action == pPedestrian->fatal_ground_impact_action) { |
Line 1776... | Line 1777... | ||
1776 | continue; |
1777 | continue; |
1777 | } |
1778 | } |
1778 | break; |
1779 | break; |
1779 | } |
1780 | } |
1780 | pPedestrian->killers_ID = the_car->car_ID; |
1781 | pPedestrian->killers_ID = the_car->car_ID; |
1781 | ped_centre_x = (max_ped_bounds_car.v[ |
1782 | ped_centre_x = (max_ped_bounds_car.v[X] + min_ped_bounds_car.v[X]) / 2.0f; |
1782 | ped_centre_y = (max_ped_bounds_car.v[ |
1783 | ped_centre_y = (max_ped_bounds_car.v[Z] + min_ped_bounds_car.v[Z]) / 2.0f; |
1783 | if (proximity_rayed) { |
1784 | if (proximity_rayed) { |
1784 | hit_pos = ePed_hit_unknown; |
1785 | hit_pos = ePed_hit_unknown; |
1785 | } else { |
1786 | } else { |
1786 | hit_pos = MoveToEdgeOfCar(pPedestrian, |
1787 | hit_pos = MoveToEdgeOfCar(pPedestrian, |
1787 | the_car, |
1788 | the_car, |
Line 1850... | Line 1851... | ||
1850 | } |
1851 | } |
1851 | } |
1852 | } |
1852 | } else { |
1853 | } else { |
1853 | if (FancyATossOffMate(pPedestrian, the_car, impact_speed)) { |
1854 | if (FancyATossOffMate(pPedestrian, the_car, impact_speed)) { |
1854 | pPedestrian->mid_air = 1; |
1855 | pPedestrian->mid_air = 1; |
1855 | if (pPedestrian->to_pos.v[ |
1856 | if (pPedestrian->to_pos.v[Y] < 500.0f) { |
1856 | pPedestrian->to_pos.v[ |
1857 | pPedestrian->to_pos.v[Y] += 1000.4f; |
1857 | } |
1858 | } |
1858 | pPedestrian->falling_speed -= impact_speed * 0.02f; |
1859 | pPedestrian->falling_speed -= impact_speed * 0.02f; |
1859 | if (pPedestrian->falling_speed > -0.001f) { |
1860 | if (pPedestrian->falling_speed > -0.001f) { |
1860 | pPedestrian->falling_speed = -0.001f; |
1861 | pPedestrian->falling_speed = -0.001f; |
1861 | } |
1862 | } |
1862 | tossing = 1; |
1863 | tossing = 1; |
1863 | pPedestrian->actor->t.t.translate.t.v[ |
1864 | pPedestrian->actor->t.t.translate.t.v[Y] += impact_speed * 15.0f; |
1864 | pPedestrian->pos = pPedestrian->actor->t.t.translate.t; |
1865 | pPedestrian->pos = pPedestrian->actor->t.t.translate.t; |
1865 | } else { |
1866 | } else { |
1866 | pPedestrian->actor->render_style = BR_RSTYLE_NONE; |
1867 | pPedestrian->actor->render_style = BR_RSTYLE_NONE; |
1867 | BrActorRelink(car_actor, pPedestrian->actor); |
1868 | BrActorRelink(car_actor, pPedestrian->actor); |
1868 | } |
1869 | } |
Line 1923... | Line 1924... | ||
1923 | } |
1924 | } |
1924 | BrVector3Set(&up, 0.f, 1.f, 0.f); |
1925 | BrVector3Set(&up, 0.f, 1.f, 0.f); |
1925 | if (billiards_shot) { |
1926 | if (billiards_shot) { |
1926 | credits_value *= 4; |
1927 | credits_value *= 4; |
1927 | PratcamEvent(30); |
1928 | PratcamEvent(30); |
1928 | DoFancyHeadup( |
1929 | DoFancyHeadup(kFancyHeadupNiceShotSir); |
1929 | } else if (fabsf(the_car->omega.v[ |
1930 | } else if (fabsf(the_car->omega.v[X]) <= 5.0f |
1930 | && fabsf(the_car->omega.v[ |
1931 | && fabsf(the_car->omega.v[Z]) <= 5.0f |
1931 | && BrVector3Dot(&the_car->car_master_actor->t.t.look_up.up, &up) >= 0.1f |
1932 | && BrVector3Dot(&the_car->car_master_actor->t.t.look_up.up, &up) >= 0.1f |
1932 | && pPedestrian->offset.v[1] >= -0.1f) { |
1933 | && pPedestrian->offset.v[1] >= -0.1f) { |
1933 | if (((hit_pos != ePed_hit_lside && hit_pos != ePed_hit_rside) |
1934 | if (((hit_pos != ePed_hit_lside && hit_pos != ePed_hit_rside) |
1934 | || (fabsf(the_car->velocity_car_space.v[ |
1935 | || (fabsf(the_car->velocity_car_space.v[X]) <= fabsf(the_car->velocity_car_space.v[Z]) |
1935 | && fabsf(the_car->omega.v[ |
1936 | && fabsf(the_car->omega.v[Y] / the_car->velocity_car_space.v[Z]) <= 600.0f)) |
1936 | && (hit_pos != ePed_hit_back || the_car->velocity_car_space.v[ |
1937 | && (hit_pos != ePed_hit_back || the_car->velocity_car_space.v[Z] <= 0.0f)) { |
1937 | if (gCurrent_ped_multiplier >= 2) { |
1938 | if (gCurrent_ped_multiplier >= 2) { |
1938 | DoFancyHeadup(gCurrent_ped_multiplier + kFancyHeadup2xComboBonus - 2); |
1939 | DoFancyHeadup(gCurrent_ped_multiplier + kFancyHeadup2xComboBonus - 2); |
1939 | } else { |
1940 | } else { |
1940 | PratcamEvent(30); |
1941 | PratcamEvent(30); |
1941 | if (exploded) { |
1942 | if (exploded) { |
Line 2063... | Line 2064... | ||
2063 | pPedestrian->done_initial = 0; |
2064 | pPedestrian->done_initial = 0; |
2064 | } |
2065 | } |
2065 | if (gAction_replay_mode) { |
2066 | if (gAction_replay_mode) { |
2066 | old_frame = pPedestrian->current_frame; |
2067 | old_frame = pPedestrian->current_frame; |
2067 | pPedestrian->car_to_ped = FastScalarArcTan2( |
2068 | pPedestrian->car_to_ped = FastScalarArcTan2( |
2068 | pPedestrian->pos.v[ |
2069 | pPedestrian->pos.v[X] - gCamera_to_world.m[3][X], |
2069 | pPedestrian->pos.v[ |
2070 | pPedestrian->pos.v[Z] - gCamera_to_world.m[3][Z]); |
2070 | MungePedestrianSequence(pPedestrian, 0); |
2071 | MungePedestrianSequence(pPedestrian, 0); |
2071 | if (old_frame <= pPedestrian->sequences[pPedestrian->current_sequence].number_of_frames) { |
2072 | if (old_frame <= pPedestrian->sequences[pPedestrian->current_sequence].number_of_frames) { |
2072 | pPedestrian->current_frame = old_frame; |
2073 | pPedestrian->current_frame = old_frame; |
2073 | } else { |
2074 | } else { |
2074 | pPedestrian->current_frame = 0; |
2075 | pPedestrian->current_frame = 0; |
Line 2187... | Line 2188... | ||
2187 | void SquirtPathVertex(br_vertex* pFirst_vertex, br_vector3* pPoint) { |
2188 | void SquirtPathVertex(br_vertex* pFirst_vertex, br_vector3* pPoint) { |
2188 | LOG_TRACE("(%p, %p)", pFirst_vertex, pPoint); |
2189 | LOG_TRACE("(%p, %p)", pFirst_vertex, pPoint); |
2189 | 2190 | ||
2190 | pFirst_vertex[0].p = *pPoint; |
2191 | pFirst_vertex[0].p = *pPoint; |
2191 | pFirst_vertex[1].p = *pPoint; |
2192 | pFirst_vertex[1].p = *pPoint; |
2192 | pFirst_vertex[1].p.v[ |
2193 | pFirst_vertex[1].p.v[Y] += .1f; |
2193 | pFirst_vertex[2].p = *pPoint; |
2194 | pFirst_vertex[2].p = *pPoint; |
2194 | pFirst_vertex[2].p.v[ |
2195 | pFirst_vertex[2].p.v[X] += -.05f; |
2195 | pFirst_vertex[2].p.v[ |
2196 | pFirst_vertex[2].p.v[Y] += .05f; |
2196 | pFirst_vertex[2].p.v[ |
2197 | pFirst_vertex[2].p.v[Z] += -.05f; |
2197 | pFirst_vertex[3].p = *pPoint; |
2198 | pFirst_vertex[3].p = *pPoint; |
2198 | pFirst_vertex[3].p.v[ |
2199 | pFirst_vertex[3].p.v[X] += .05f; |
2199 | pFirst_vertex[3].p.v[ |
2200 | pFirst_vertex[3].p.v[Y] += .05f; |
2200 | pFirst_vertex[3].p.v[ |
2201 | pFirst_vertex[3].p.v[Z] += .05f; |
2201 | } |
2202 | } |
2202 | 2203 | ||
2203 | // IDA: void __cdecl ResetAllPedestrians() |
2204 | // IDA: void __cdecl ResetAllPedestrians() |
2204 | void ResetAllPedestrians(void) { |
2205 | void ResetAllPedestrians(void) { |
2205 | int i; |
2206 | int i; |
Line 2223... | Line 2224... | ||
2223 | pPedestrian->actor->render_style = BR_RSTYLE_NONE; |
2224 | pPedestrian->actor->render_style = BR_RSTYLE_NONE; |
2224 | BrActorRelink(gDont_render_actor, pPedestrian->actor); |
2225 | BrActorRelink(gDont_render_actor, pPedestrian->actor); |
2225 | } |
2226 | } |
2226 | pPedestrian->mid_air = 0; |
2227 | pPedestrian->mid_air = 0; |
2227 | BrVector3Set(&cast_point, |
2228 | BrVector3Set(&cast_point, |
2228 | pPedestrian->pos.v[ |
2229 | pPedestrian->pos.v[X], |
2229 | pPedestrian->pos.v[ |
2230 | pPedestrian->pos.v[Y] + 0.4f, |
2230 | pPedestrian->pos.v[ |
2231 | pPedestrian->pos.v[Z]); |
2231 | new_y = FindYVerticallyBelow2(&cast_point); |
2232 | new_y = FindYVerticallyBelow2(&cast_point); |
2232 | pPedestrian->actor->t.t.translate.t.v[ |
2233 | pPedestrian->actor->t.t.translate.t.v[Y] = pPedestrian->pos.v[Y] = new_y; |
2233 | pPedestrian->spin_period = 0.f; |
2234 | pPedestrian->spin_period = 0.f; |
2234 | sequence = &pPedestrian->sequences[pPedestrian->current_sequence]; |
2235 | sequence = &pPedestrian->sequences[pPedestrian->current_sequence]; |
2235 | if (sequence->number_of_frames == sequence->looping_frame_start) { |
2236 | if (sequence->number_of_frames == sequence->looping_frame_start) { |
2236 | pPedestrian->current_frame = sequence->number_of_frames - 1; |
2237 | pPedestrian->current_frame = sequence->number_of_frames - 1; |
2237 | pPedestrian->done_initial = 0; |
2238 | pPedestrian->done_initial = 0; |
Line 2295... | Line 2296... | ||
2295 | pPedestrian->fate = NULL; |
2296 | pPedestrian->fate = NULL; |
2296 | gInitial_instruction = NULL; |
2297 | gInitial_instruction = NULL; |
2297 | PedestrianNextInstruction(pPedestrian, 0.f, 1, 0); |
2298 | PedestrianNextInstruction(pPedestrian, 0.f, 1, 0); |
2298 | BrVector3Copy(&pPedestrian->from_pos, &pPedestrian->actor->t.t.translate.t); |
2299 | BrVector3Copy(&pPedestrian->from_pos, &pPedestrian->actor->t.t.translate.t); |
2299 | MungePedModel(pPedestrian); |
2300 | MungePedModel(pPedestrian); |
2300 | pPedestrian->pos.v[ |
2301 | pPedestrian->pos.v[Y] += pPedestrian->sequences[pPedestrian->current_sequence].frames[0].offset.v[Y]; |
2301 | } |
2302 | } |
2302 | 2303 | ||
2303 | // IDA: void __usercall MungePedestrians(tU32 pFrame_period@<EAX>) |
2304 | // IDA: void __usercall MungePedestrians(tU32 pFrame_period@<EAX>) |
2304 | void MungePedestrians(tU32 pFrame_period) { |
2305 | void MungePedestrians(tU32 pFrame_period) { |
2305 | int i; |
2306 | int i; |
Line 2333... | Line 2334... | ||
2333 | } |
2334 | } |
2334 | // BrVector3(&br_vector3_00550ac0, 0.f, 0.f, 0.f); |
2335 | // BrVector3(&br_vector3_00550ac0, 0.f, 0.f, 0.f); |
2335 | if (gAction_replay_mode) { |
2336 | if (gAction_replay_mode) { |
2336 | for (i = 0; i < gPed_count; i++) { |
2337 | for (i = 0; i < gPed_count; i++) { |
2337 | the_pedestrian = &gPedestrian_array[i]; |
2338 | the_pedestrian = &gPedestrian_array[i]; |
2338 | x_delta = fabsf(the_pedestrian->pos.v[ |
2339 | x_delta = fabsf(the_pedestrian->pos.v[X] - gCamera_to_world.m[3][X]); |
2339 | z_delta = fabsf(the_pedestrian->pos.v[ |
2340 | z_delta = fabsf(the_pedestrian->pos.v[Z] - gCamera_to_world.m[3][Z]); |
2340 | if ((the_pedestrian->actor->parent != gDont_render_actor || (x_delta <= ACTIVE_PED_DXDZ && z_delta <= ACTIVE_PED_DXDZ)) |
2341 | if ((the_pedestrian->actor->parent != gDont_render_actor || (x_delta <= ACTIVE_PED_DXDZ && z_delta <= ACTIVE_PED_DXDZ)) |
2341 | && (gPedestrians_on || the_pedestrian->ref_number >= 100) |
2342 | && (gPedestrians_on || the_pedestrian->ref_number >= 100) |
2342 | && the_pedestrian->hit_points != -100) { |
2343 | && the_pedestrian->hit_points != -100) { |
2343 | gCurrent_lollipop_index = -1; |
2344 | gCurrent_lollipop_index = -1; |
2344 | DoPedestrian(the_pedestrian, i); |
2345 | DoPedestrian(the_pedestrian, i); |
2345 | } |
2346 | } |
2346 | } |
2347 | } |
2347 | } else { |
2348 | } else { |
2348 | for (i = 0; i < gPed_count; i++) { |
2349 | for (i = 0; i < gPed_count; i++) { |
2349 | the_pedestrian = &gPedestrian_array[i]; |
2350 | the_pedestrian = &gPedestrian_array[i]; |
2350 | x_delta = fabsf(the_pedestrian->pos.v[ |
2351 | x_delta = fabsf(the_pedestrian->pos.v[X] - gCamera_to_world.m[3][X]); |
2351 | z_delta = fabsf(the_pedestrian->pos.v[ |
2352 | z_delta = fabsf(the_pedestrian->pos.v[Z] - gCamera_to_world.m[3][Z]); |
2352 | if (the_pedestrian->actor->parent == gDont_render_actor |
2353 | if (the_pedestrian->actor->parent == gDont_render_actor |
2353 | && (x_delta > ACTIVE_PED_DXDZ || z_delta > ACTIVE_PED_DXDZ)) { |
2354 | && (x_delta > ACTIVE_PED_DXDZ || z_delta > ACTIVE_PED_DXDZ)) { |
2354 | the_pedestrian->active = 0; |
2355 | the_pedestrian->active = 0; |
2355 | } else if (the_pedestrian->hit_points == -100) { |
2356 | } else if (the_pedestrian->hit_points == -100) { |
2356 | if (the_pedestrian->respawn_time == 0) { |
2357 | if (the_pedestrian->respawn_time == 0) { |
Line 2407... | Line 2408... | ||
2407 | // This is done such that the "Peds visible on map" powerup draws far away items. |
2408 | // This is done such that the "Peds visible on map" powerup draws far away items. |
2408 | // (far away animated pedestrians would otherwise remain invisible on the map) |
2409 | // (far away animated pedestrians would otherwise remain invisible on the map) |
2409 | br_scalar x_delta; |
2410 | br_scalar x_delta; |
2410 | br_scalar z_delta; |
2411 | br_scalar z_delta; |
2411 | int ped_respawn_animate; |
2412 | int ped_respawn_animate; |
2412 | x_delta = fabsf(the_pedestrian->pos.v[ |
2413 | x_delta = fabsf(the_pedestrian->pos.v[X] - gCamera_to_world.m[3][X]); |
2413 | z_delta = fabsf(the_pedestrian->pos.v[ |
2414 | z_delta = fabsf(the_pedestrian->pos.v[Z] - gCamera_to_world.m[3][Z]); |
2414 | ped_respawn_animate = x_delta <= ACTIVE_PED_DXDZ && z_delta <= ACTIVE_PED_DXDZ; |
2415 | ped_respawn_animate = x_delta <= ACTIVE_PED_DXDZ && z_delta <= ACTIVE_PED_DXDZ; |
2415 | #else |
2416 | #else |
2416 | #define ped_respawn_animate 1 |
2417 | #define ped_respawn_animate 1 |
2417 | #endif |
2418 | #endif |
2418 | if (the_pedestrian->hit_points == -100) { |
2419 | if (the_pedestrian->hit_points == -100) { |
Line 2953... | Line 2954... | ||
2953 | face_count = 0; |
2954 | face_count = 0; |
2954 | point_count = 0; |
2955 | point_count = 0; |
2955 | for (j = 0; j < pInstruc_count; j++) { |
2956 | for (j = 0; j < pInstruc_count; j++) { |
2956 | if (pInstructions[j].type == ePed_instruc_point || pInstructions[j].type == ePed_instruc_xpoint) { |
2957 | if (pInstructions[j].type == ePed_instruc_point || pInstructions[j].type == ePed_instruc_xpoint) { |
2957 | the_point = pInstructions[j].data.point_data.position; |
2958 | the_point = pInstructions[j].data.point_data.position; |
2958 | if (the_point.v[ |
2959 | if (the_point.v[Y] < 500.f) { |
2959 | the_mat = gPath_mat_normal; |
2960 | the_mat = gPath_mat_normal; |
2960 | } else { |
2961 | } else { |
2961 | the_point.v[ |
2962 | the_point.v[Y] -= 999.6f; |
2962 | the_point.v[ |
2963 | the_point.v[Y] = FindYVerticallyBelow2(&the_point); |
2963 | if (the_point.v[ |
2964 | if (the_point.v[Y] < -100.f) { |
2964 | the_point.v[ |
2965 | the_point.v[Y] = 1000.f; |
2965 | the_point.v[ |
2966 | the_point.v[Y] = FindYVerticallyBelow2(&the_point); |
2966 | } |
2967 | } |
2967 | if (point_count == 0 || pInstructions[j - 1].data.point_data.position.v[ |
2968 | if (point_count == 0 || pInstructions[j - 1].data.point_data.position.v[Y] < 500.f) { |
2968 | the_mat = gPath_mat_normal; |
2969 | the_mat = gPath_mat_normal; |
2969 | } else { |
2970 | } else { |
2970 | the_mat = gPath_mat_calc; |
2971 | the_mat = gPath_mat_calc; |
2971 | } |
2972 | } |
2972 | } |
2973 | } |
Line 3000... | Line 3001... | ||
3000 | } |
3001 | } |
3001 | point_count++; |
3002 | point_count++; |
3002 | last_vertex_count = vertex_count; |
3003 | last_vertex_count = vertex_count; |
3003 | if (j == pInit_instruc) { |
3004 | if (j == pInit_instruc) { |
3004 | the_model->vertices[vertex_count].p = the_point; |
3005 | the_model->vertices[vertex_count].p = the_point; |
3005 | the_model->vertices[vertex_count].p.v[ |
3006 | the_model->vertices[vertex_count].p.v[Y] += .3f; |
3006 | the_model->vertices[vertex_count].p.v[ |
3007 | the_model->vertices[vertex_count].p.v[Z] += .05f; |
3007 | the_model->vertices[vertex_count + 1].p = the_point; |
3008 | the_model->vertices[vertex_count + 1].p = the_point; |
3008 | the_model->vertices[vertex_count + 1].p.v[ |
3009 | the_model->vertices[vertex_count + 1].p.v[Y] += .3f; |
3009 | the_model->vertices[vertex_count + 1].p.v[ |
3010 | the_model->vertices[vertex_count + 1].p.v[Z] += -.05f; |
3010 | the_model->vertices[vertex_count + 2].p = the_point; |
3011 | the_model->vertices[vertex_count + 2].p = the_point; |
3011 | the_model->vertices[vertex_count + 2].p.v[ |
3012 | the_model->vertices[vertex_count + 2].p.v[Y] += .3f; |
3012 | the_model->vertices[vertex_count + 2].p.v[ |
3013 | the_model->vertices[vertex_count + 2].p.v[X] += .05f; |
3013 | the_model->vertices[vertex_count + 3].p = the_point; |
3014 | the_model->vertices[vertex_count + 3].p = the_point; |
3014 | the_model->vertices[vertex_count + 3].p.v[ |
3015 | the_model->vertices[vertex_count + 3].p.v[Y] += .3f; |
3015 | the_model->vertices[vertex_count + 3].p.v[ |
3016 | the_model->vertices[vertex_count + 3].p.v[X] += -.05f; |
3016 | vertex_count += 4; |
3017 | vertex_count += 4; |
3017 | the_model->faces[face_count].vertices[0] = vertex_count - 8; |
3018 | the_model->faces[face_count].vertices[0] = vertex_count - 8; |
3018 | the_model->faces[face_count].vertices[1] = vertex_count - 4; |
3019 | the_model->faces[face_count].vertices[1] = vertex_count - 4; |
3019 | the_model->faces[face_count].vertices[2] = vertex_count - 3; |
3020 | the_model->faces[face_count].vertices[2] = vertex_count - 3; |
3020 | the_model->faces[face_count].material = gInit_pos_mat_calc; |
3021 | the_model->faces[face_count].material = gInit_pos_mat_calc; |
Line 3068... | Line 3069... | ||
3068 | for (j = 0, the_instruction = the_pedestrian->instruction_list; j < the_pedestrian->number_of_instructions; j++, the_instruction++) { |
3069 | for (j = 0, the_instruction = the_pedestrian->instruction_list; j < the_pedestrian->number_of_instructions; j++, the_instruction++) { |
3069 | switch (the_instruction->type) { |
3070 | switch (the_instruction->type) { |
3070 | case ePed_instruc_point: |
3071 | case ePed_instruc_point: |
3071 | fprintf(f, "\tpoint\n"); |
3072 | fprintf(f, "\tpoint\n"); |
3072 | fprintf(f, "\t%.3f,%.3f,%.3f\n", |
3073 | fprintf(f, "\t%.3f,%.3f,%.3f\n", |
3073 | the_instruction->data.point_data.position.v[ |
3074 | the_instruction->data.point_data.position.v[X], |
3074 | the_instruction->data.point_data.position.v[ |
3075 | the_instruction->data.point_data.position.v[Y], |
3075 | the_instruction->data.point_data.position.v[ |
3076 | the_instruction->data.point_data.position.v[Z]); |
3076 | break; |
3077 | break; |
3077 | case ePed_instruc_xpoint: |
3078 | case ePed_instruc_xpoint: |
3078 | fprintf(f, "\txpoint\n"); |
3079 | fprintf(f, "\txpoint\n"); |
3079 | fprintf(f, "\t%.3f,%.3f,%.3f\n", |
3080 | fprintf(f, "\t%.3f,%.3f,%.3f\n", |
3080 | the_instruction->data.point_data.position.v[ |
3081 | the_instruction->data.point_data.position.v[X], |
3081 | the_instruction->data.point_data.position.v[ |
3082 | the_instruction->data.point_data.position.v[Y], |
3082 | the_instruction->data.point_data.position.v[ |
3083 | the_instruction->data.point_data.position.v[Z]); |
3083 | break; |
3084 | break; |
3084 | case ePed_instruc_bchoice: |
3085 | case ePed_instruc_bchoice: |
3085 | fprintf(f, "\tbchoice\n"); |
3086 | fprintf(f, "\tbchoice\n"); |
3086 | fprintf(f, "%d", the_instruction->data.choice_data.number_of_choices); |
3087 | fprintf(f, "%d", the_instruction->data.choice_data.number_of_choices); |
3087 | for (k = 0, the_choice = the_instruction->data.choice_data.choices; k < the_instruction->data.choice_data.number_of_choices; k++, the_choice++) { |
3088 | for (k = 0, the_choice = the_instruction->data.choice_data.choices; k < the_instruction->data.choice_data.number_of_choices; k++, the_choice++) { |
Line 3415... | Line 3416... | ||
3415 | LOG_TRACE("()"); |
3416 | LOG_TRACE("()"); |
3416 | 3417 | ||
3417 | gPed_instrucs[gPed_instruc_count].type = ePed_instruc_point; |
3418 | gPed_instrucs[gPed_instruc_count].type = ePed_instruc_point; |
3418 | gPed_instrucs[gPed_instruc_count].data.point_data.irreversable = 0; |
3419 | gPed_instrucs[gPed_instruc_count].data.point_data.irreversable = 0; |
3419 | gPed_instrucs[gPed_instruc_count].data.point_data.position = *gOur_pos; |
3420 | gPed_instrucs[gPed_instruc_count].data.point_data.position = *gOur_pos; |
3420 | gPed_instrucs[gPed_instruc_count].data.point_data.position.v[ |
3421 | gPed_instrucs[gPed_instruc_count].data.point_data.position.v[Y] += 1000.4f; |
3421 | gPed_instruc_count++; |
3422 | gPed_instruc_count++; |
3422 | MungeShowPedPath(); |
3423 | MungeShowPedPath(); |
3423 | } |
3424 | } |
3424 | 3425 | ||
3425 | // IDA: void __cdecl DropPedPointAir() |
3426 | // IDA: void __cdecl DropPedPointAir() |
Line 3448... | Line 3449... | ||
3448 | DropPedPointAir2(); |
3449 | DropPedPointAir2(); |
3449 | NewTextHeadupSlot(4, 0, 2000, -1, "Dropped initial auto-y pedestrian point"); |
3450 | NewTextHeadupSlot(4, 0, 2000, -1, "Dropped initial auto-y pedestrian point"); |
3450 | } |
3451 | } |
3451 | 3452 | ||
3452 | // IDA: br_uint_32 __cdecl KillActorsModel(br_actor *pActor, void *pArg) |
3453 | // IDA: br_uint_32 __cdecl KillActorsModel(br_actor *pActor, void *pArg) |
3453 |
|
3454 | br_uintptr_t KillActorsModel(br_actor* pActor, void* pArg) { |
3454 | LOG_TRACE("(%p, %p)", pActor, pArg); |
3455 | LOG_TRACE("(%p, %p)", pActor, pArg); |
3455 | 3456 | ||
3456 | if (pActor->model != NULL) { |
3457 | if (pActor->model != NULL) { |
3457 | BrModelRemove(pActor->model); |
3458 | BrModelRemove(pActor->model); |
3458 | BrModelFree(pActor->model); |
3459 | BrModelFree(pActor->model); |
Line 3490... | Line 3491... | ||
3490 | min_distance = BR_SCALAR_MAX; |
3491 | min_distance = BR_SCALAR_MAX; |
3491 | for (i = 0; i < gPed_count; i++) { |
3492 | for (i = 0; i < gPed_count; i++) { |
3492 | for (j = 0; j < gPedestrian_array[i].number_of_instructions; j++) { |
3493 | for (j = 0; j < gPedestrian_array[i].number_of_instructions; j++) { |
3493 | if (gPedestrian_array[i].instruction_list[j].type == ePed_instruc_point || gPedestrian_array[i].instruction_list[j].type == ePed_instruc_xpoint) { |
3494 | if (gPedestrian_array[i].instruction_list[j].type == ePed_instruc_point || gPedestrian_array[i].instruction_list[j].type == ePed_instruc_xpoint) { |
3494 | the_point = gPedestrian_array[i].instruction_list[j].data.point_data.position; |
3495 | the_point = gPedestrian_array[i].instruction_list[j].data.point_data.position; |
3495 | if (the_point.v[ |
3496 | if (the_point.v[Y] >= 500.f) { |
3496 | the_point.v[ |
3497 | the_point.v[Y] -= 999.6f; |
3497 | the_point.v[ |
3498 | the_point.v[Y] = FindYVerticallyBelow2(&the_point); |
3498 | if (the_point.v[ |
3499 | if (the_point.v[Y] < -100.f) { |
3499 | the_point.v[ |
3500 | the_point.v[Y] = 1000.f; |
3500 | the_point.v[ |
3501 | the_point.v[Y] = FindYVerticallyBelow2(&the_point); |
3501 | } |
3502 | } |
3502 | } |
3503 | } |
3503 | the_distance = Vector3DistanceSquared(&the_point, gOur_pos); |
3504 | the_distance = Vector3DistanceSquared(&the_point, gOur_pos); |
3504 | if (the_distance < min_distance) { |
3505 | if (the_distance < min_distance) { |
3505 | *pPed_index = i; |
3506 | *pPed_index = i; |
Line 3587... | Line 3588... | ||
3587 | LOG_TRACE("()"); |
3588 | LOG_TRACE("()"); |
3588 | 3589 | ||
3589 | if (gPed_instruc_count == 0) { |
3590 | if (gPed_instruc_count == 0) { |
3590 | GetPedPos(&the_ped, &the_point); |
3591 | GetPedPos(&the_ped, &the_point); |
3591 | gPedestrian_array[the_ped].instruction_list[the_point].data.point_data.position = *gOur_pos; |
3592 | gPedestrian_array[the_ped].instruction_list[the_point].data.point_data.position = *gOur_pos; |
3592 | gPedestrian_array[the_ped].instruction_list[the_point].data.point_data.position.v[ |
3593 | gPedestrian_array[the_ped].instruction_list[the_point].data.point_data.position.v[Y] += 1000.4f; |
3593 | WriteOutPeds(); |
3594 | WriteOutPeds(); |
3594 | DisposePedPaths(); |
3595 | DisposePedPaths(); |
3595 | ShowPedPaths(); |
3596 | ShowPedPaths(); |
3596 | } |
3597 | } |
3597 | } |
3598 | } |
Line 3768... | Line 3769... | ||
3768 | gProximity_rays[i].car, |
3769 | gProximity_rays[i].car, |
3769 | GET_PEDESTRIAN_INDEX(gProximity_rays[i].ped), |
3770 | GET_PEDESTRIAN_INDEX(gProximity_rays[i].ped), |
3770 | gProximity_rays[i].start_time); |
3771 | gProximity_rays[i].start_time); |
3771 | car_model = gProximity_rays[i].car->car_model_actors[gProximity_rays[i].car->principal_car_actor].actor->model; |
3772 | car_model = gProximity_rays[i].car->car_model_actors[gProximity_rays[i].car->principal_car_actor].actor->model; |
3772 | 3773 | ||
3773 | BrVector3Set(&car_add_c, 0.f, (car_model->bounds.max.v[ |
3774 | BrVector3Set(&car_add_c, 0.f, (car_model->bounds.max.v[Y] - car_model->bounds.min.v[Y]) / -5.f, 0.f); |
3774 | BrMatrix34ApplyV(&car_add, &car_add_c, &gProximity_rays[i].car->car_master_actor->t.t.mat); |
3775 | BrMatrix34ApplyV(&car_add, &car_add_c, &gProximity_rays[i].car->car_master_actor->t.t.mat); |
3775 | BrVector3Add(&car_pos, &gProximity_rays[i].car->pos, &car_add); |
3776 | BrVector3Add(&car_pos, &gProximity_rays[i].car->pos, &car_add); |
3776 | DRMatrix34TApplyP(&car_pos_cam, &car_pos, &gCamera_to_world); |
3777 | DRMatrix34TApplyP(&car_pos_cam, &car_pos, &gCamera_to_world); |
3777 | 3778 | ||
3778 | BrVector3Set(&ped_add, 0.f, gProximity_rays[i].ped->actor->t.t.mat.m[1][1] / 2.f, 0.f); |
3779 | BrVector3Set(&ped_add, 0.f, gProximity_rays[i].ped->actor->t.t.mat.m[1][1] / 2.f, 0.f); |
Line 3783... | Line 3784... | ||
3783 | distance = BrVector3Length(&r1); |
3784 | distance = BrVector3Length(&r1); |
3784 | BrVector3Normalise(&r1, &r1); |
3785 | BrVector3Normalise(&r1, &r1); |
3785 | 3786 | ||
3786 | from_pos = car_pos_cam; |
3787 | from_pos = car_pos_cam; |
3787 | 3788 | ||
3788 | seed = the_time + ped_pos.v[ |
3789 | seed = the_time + ped_pos.v[X] + ped_pos.v[Y] + ped_pos.v[Z] + car_pos.v[X] + car_pos.v[Y] + car_pos.v[Z]; |
3789 | srand(seed); |
3790 | srand(seed); |
3790 | 3791 | ||
3791 | t = 0.f; |
3792 | t = 0.f; |
3792 | do { |
3793 | do { |
3793 | BrVector3Scale(&ray, &r1, t); |
3794 | BrVector3Scale(&ray, &r1, t); |
3794 | BrVector3Add(&to_pos, &ray, &car_pos_cam); |
3795 | BrVector3Add(&to_pos, &ray, &car_pos_cam); |
3795 | to_pos.v[ |
3796 | to_pos.v[X] += SRandomPosNeg(0.1f); |
3796 | to_pos.v[ |
3797 | to_pos.v[Y] += SRandomPosNeg(0.1f); |
3797 | to_pos.v[ |
3798 | to_pos.v[Z] += SRandomPosNeg(0.1f); |
3798 | DrawLine3D(&to_pos, &from_pos, pRender_screen, pDepth_buffer, gProx_ray_shade_table); |
3799 | DrawLine3D(&to_pos, &from_pos, pRender_screen, pDepth_buffer, gProx_ray_shade_table); |
3799 | from_pos = to_pos; |
3800 | from_pos = to_pos; |
3800 | t += 0.05f; |
3801 | t += 0.05f; |
3801 | } while (t < distance); |
3802 | } while (t < distance); |
3802 | DrawLine3D(&ped_pos_cam, &from_pos, pRender_screen, pDepth_buffer, gProx_ray_shade_table); |
3803 | DrawLine3D(&ped_pos_cam, &from_pos, pRender_screen, pDepth_buffer, gProx_ray_shade_table); |