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