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

Function PlayerSpewObject

Descent3/Player.cpp:2797–2823  ·  view source on GitHub ↗

Spews an object in a random direction

Source from the content-addressed store, hash-verified

2795
2796// Spews an object in a random direction
2797void PlayerSpewObject(object *objp, int timed, int room, vector *pos, matrix *orient) {
2798 ASSERT((!(Game_mode & GM_MULTI)) || (Netgame.local_role == LR_SERVER));
2799
2800 ObjSetPos(objp, pos, room, orient, true);
2801
2802 // Set random velocity for powerups
2803 objp->mtype.phys_info.velocity.x = ((ps_rand() / (float)D3_RAND_MAX) - .5f) * 40.0; // +20 to -20
2804 objp->mtype.phys_info.velocity.z = ((ps_rand() / (float)D3_RAND_MAX) - .5f) * 40.0; // +20 to -20
2805 objp->mtype.phys_info.velocity.y = ((ps_rand() / (float)D3_RAND_MAX) - .5f) * 40.0; // +20 to -20
2806
2807 // Send object to other players
2808 if (Game_mode & GM_MULTI) {
2809 if (Netgame.flags & NF_COOP)
2810 timed = 0;
2811
2812 if (Netgame.local_role == LR_SERVER) {
2813 if (timed == 2) {
2814 objp->flags |= OF_USES_LIFELEFT;
2815 objp->lifeleft = 20.0;
2816 } else if (timed == 1) {
2817 objp->flags |= OF_USES_LIFELEFT;
2818 objp->lifeleft = 180.0;
2819 }
2820 DemoWriteObjLifeLeft(objp);
2821 }
2822 }
2823}
2824
2825// Spews an object in a random direction
2826// Returns the new object

Callers 1

PlayerSpewInventoryFunction · 0.85

Calls 7

ObjSetPosFunction · 0.85
ps_randFunction · 0.85
DemoWriteObjLifeLeftFunction · 0.85
PlayerSpewGuidebotFunction · 0.85
ObjCreateFunction · 0.85
MultiSendObjectFunction · 0.85
InitObjectScriptsFunction · 0.85

Tested by

no test coverage detected