Detaches a subobject from the player ship
| 2695 | |
| 2696 | // Detaches a subobject from the player ship |
| 2697 | void DeadPlayerShipHit(object *obj, int hit_room, vector *hitpt, float magnitude) { |
| 2698 | fvi_info hit_data; |
| 2699 | fvi_query fq; |
| 2700 | vector hitvec, hitpt2; |
| 2701 | int subobjnum = -1; |
| 2702 | |
| 2703 | // vector from hitpoint to object center position |
| 2704 | hitvec = obj->pos - (*hitpt); |
| 2705 | hitpt2 = *hitpt; |
| 2706 | |
| 2707 | // get first subobject to be hit when looking for a hit subobject. |
| 2708 | hit_data.hit_type[0] = HIT_SPHERE_2_POLY_OBJECT; |
| 2709 | |
| 2710 | while (hit_data.hit_type[0] != HIT_NONE) { |
| 2711 | fq.p0 = &hitpt2; |
| 2712 | fq.p1 = &obj->pos; |
| 2713 | fq.startroom = hit_room; |
| 2714 | fq.rad = obj->size; |
| 2715 | fq.thisobjnum = obj - Objects; |
| 2716 | fq.ignore_obj_list = NULL; |
| 2717 | fq.flags = FQ_CHECK_OBJS | FQ_OBJ_BACKFACE | FQ_ONLY_PLAYER_OBJ; |
| 2718 | |
| 2719 | fvi_FindIntersection(&fq, &hit_data); |
| 2720 | |
| 2721 | if (hit_data.hit_type[0] == HIT_SPHERE_2_POLY_OBJECT) { |
| 2722 | // we probably hit a subobject of the player object. |
| 2723 | // NOTE: we should check if the hit object is still the player object! |
| 2724 | subobjnum = hit_data.hit_subobject[0]; |
| 2725 | } else if (hit_data.hit_type[0] != HIT_NONE) { |
| 2726 | hitpt2 = hit_data.hit_pnt; |
| 2727 | hit_data.hit_type[0] = HIT_NONE; |
| 2728 | } |
| 2729 | } |
| 2730 | |
| 2731 | if (subobjnum > -1) { |
| 2732 | // we hit a subobject. new debris object, and delete this subobject from the player model. note that |
| 2733 | // we should must the suobject handle to the polymodel when we're done. |
| 2734 | PlayerShipSpewPart(obj, subobjnum, magnitude); |
| 2735 | } |
| 2736 | } |
| 2737 | |
| 2738 | // Spews a guidebot |
| 2739 | void PlayerSpewGuidebot(object *parent, int type, int id) { |
nothing calls this directly
no test coverage detected