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

Function PlayerSpewGuidebot

Descent3/Player.cpp:2739–2794  ·  view source on GitHub ↗

Spews a guidebot

Source from the content-addressed store, hash-verified

2737
2738// Spews a guidebot
2739void PlayerSpewGuidebot(object *parent, int type, int id) {
2740 int objnum;
2741 object *obj;
2742 int model_num = Object_info[ROBOT_GUIDEBOT].render_handle;
2743 float size;
2744
2745 if (stricmp(Ships[Players[parent->id].ship_index].name, "Black Pyro") == 0) {
2746 // Only spew red GB if merc is installed
2747 extern bool MercInstalled();
2748 if (MercInstalled())
2749 model_num = Object_info[ROBOT_GUIDEBOTRED].render_handle;
2750 }
2751
2752 PageInPolymodel(model_num, OBJ_ROBOT, &size);
2753
2754 objnum = ObjCreate(OBJ_DEBRIS, 0, parent->roomnum, &parent->pos, &parent->orient);
2755
2756 if (objnum < 0 || objnum > Highest_object_index) {
2757 mprintf(0, "WARNING: No object slots. Dead GB not created!\n");
2758 return;
2759 }
2760
2761 obj = &Objects[objnum];
2762
2763 // Set polygon-object-specific data
2764 obj->rtype.pobj_info.model_num = model_num;
2765 obj->rtype.pobj_info.subobj_flags = 0xFFFFFFFF;
2766
2767 // Set physics data for this object
2768
2769 obj->mtype.phys_info.velocity = parent->mtype.phys_info.velocity + parent->orient.fvec * 30.0;
2770
2771 vm_MakeZero(&obj->mtype.phys_info.rotthrust);
2772
2773 obj->size = Object_info[ROBOT_GUIDEBOT].size;
2774 obj->mtype.phys_info.mass = 40.0;
2775 obj->mtype.phys_info.drag = .001f;
2776
2777 obj->mtype.phys_info.flags = (PF_GRAVITY | PF_BOUNCE | PF_FIXED_ROT_VELOCITY);
2778 obj->mtype.phys_info.coeff_restitution = .25f;
2779
2780 obj->mtype.phys_info.rotvel.x = (float)((120000.0f * (float)(D3_RAND_MAX / 2 - ps_rand())) / (float)(D3_RAND_MAX / 2));
2781 obj->mtype.phys_info.rotvel.y = (float)((120000.0f * (float)(D3_RAND_MAX / 2 - ps_rand())) / (float)(D3_RAND_MAX / 2));
2782 obj->mtype.phys_info.rotvel.z = (float)((120000.0f * (float)(D3_RAND_MAX / 2 - ps_rand())) / (float)(D3_RAND_MAX / 2));
2783
2784 obj->mtype.phys_info.num_bounces = 5;
2785
2786 obj->movement_type = MT_PHYSICS;
2787
2788 ASSERT(obj != Player_object);
2789 obj->type = OBJ_DEBRIS;
2790 SetObjectControlType(obj, CT_DEBRIS); // become debris while exploding
2791 obj->lifeleft = 5.0 + ((ps_rand() % 50) * .05);
2792 obj->flags |= OF_USES_LIFELEFT;
2793 DemoWriteObjLifeLeft(obj);
2794}
2795
2796// Spews an object in a random direction

Callers 1

PlayerSpewObjectFunction · 0.85

Calls 7

MercInstalledFunction · 0.85
PageInPolymodelFunction · 0.85
ObjCreateFunction · 0.85
vm_MakeZeroFunction · 0.85
ps_randFunction · 0.85
SetObjectControlTypeFunction · 0.85
DemoWriteObjLifeLeftFunction · 0.85

Tested by

no test coverage detected