MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoZoomEffect

Function DoZoomEffect

Descent3/WeaponFire.cpp:2696–2751  ·  view source on GitHub ↗

Zooms in for this weapon

Source from the content-addressed store, hash-verified

2694
2695// Zooms in for this weapon
2696void DoZoomEffect(player_weapon *pw, uint8_t clear) {
2697 if (pw->firing_time < .5) {
2698 Players[Player_num].turn_scalar = 1.0;
2699 Render_FOV = D3_DEFAULT_FOV;
2700
2701 if (!clear)
2702 DoZoomStay();
2703 return;
2704 }
2705
2706 Players[Player_num].turn_scalar = .3f;
2707
2708 if (pw->firing_time > 1.0) {
2709 // We are fully zoomed in
2710
2711 Players[Player_num].flags |= PLAYER_FLAGS_ZOOMED;
2712 Render_FOV = ZOOM_FOV_TARGET;
2713 Zoom_fov_time = ZOOM_STAY_TIME;
2714
2715 // See if we hit anything
2716 // Cast a ray to see what we've hit
2717 Players[Player_num].flags &= ~PLAYER_FLAGS_BULLSEYE;
2718 object *obj = &Objects[Players[Player_num].objnum];
2719 int fate; // Collision type for response code
2720 fvi_info hit_info; // Hit information
2721 fvi_query fq; // Movement query
2722 vector dest = obj->pos + (obj->orient.fvec * 5000.0);
2723
2724 fq.p0 = &obj->pos;
2725 fq.startroom = obj->roomnum;
2726 fq.p1 = &dest;
2727 fq.rad = .0001f;
2728 fq.thisobjnum = Objects - obj;
2729 fq.ignore_obj_list = NULL;
2730 fq.flags = FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS | FQ_IGNORE_WEAPONS;
2731
2732 fate = fvi_FindIntersection(&fq, &hit_info);
2733
2734 Players[Player_num].zoom_distance = vm_VectorDistance(&obj->pos, &hit_info.hit_pnt);
2735
2736 if (fate == HIT_SPHERE_2_POLY_OBJECT || fate == HIT_OBJECT) {
2737 object *hit_obj = &Objects[hit_info.hit_object[0]];
2738 if (hit_obj->type == OBJ_ROBOT || hit_obj->type == OBJ_PLAYER ||
2739 (hit_obj->type == OBJ_BUILDING && hit_obj->ai_info))
2740 Players[Player_num].flags |= PLAYER_FLAGS_BULLSEYE;
2741 }
2742 return;
2743 }
2744
2745 // calculate zoom effect
2746 float norm = (pw->firing_time - .5) * 2;
2747
2748 Render_FOV = (ZOOM_FOV_TARGET * norm) + ((1.0 - norm) * D3_DEFAULT_FOV);
2749
2750 return;
2751}
2752
2753// Called when a player dies or switches weapons to clear out any active weapon stuff

Callers 2

ClearPlayerFiringFunction · 0.85
FireWeaponFromPlayerFunction · 0.85

Calls 3

DoZoomStayFunction · 0.85
fvi_FindIntersectionFunction · 0.85
vm_VectorDistanceFunction · 0.50

Tested by

no test coverage detected