MCPcopy Create free account
hub / github.com/JACoders/OpenJK / TossClientItems

Function TossClientItems

code/game/g_combat.cpp:128–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126extern gentity_t *WP_DropThermal( gentity_t *ent );
127extern qboolean WP_SaberLose( gentity_t *self, vec3_t throwDir );
128gentity_t *TossClientItems( gentity_t *self )
129{
130 //FIXME: drop left-hand weapon, too?
131 gentity_t *dropped = NULL;
132 gitem_t *item = NULL;
133 int weapon;
134
135 if ( self->client->NPC_class == CLASS_SEEKER
136 || self->client->NPC_class == CLASS_REMOTE
137 || self->client->NPC_class == CLASS_SABER_DROID
138 || self->client->NPC_class == CLASS_VEHICLE
139 || self->client->NPC_class == CLASS_ATST)
140 {
141 // these things are so small that they shouldn't bother throwing anything
142 return NULL;
143 }
144
145 // drop the weapon if not a saber or enemy-only weapon
146 weapon = self->s.weapon;
147 if ( weapon == WP_SABER )
148 {
149 if ( self->weaponModel[0] < 0 )
150 {//don't have one in right hand
151 self->s.weapon = WP_NONE;
152 }
153 else if ( !(self->client->ps.saber[0].saberFlags&SFL_NOT_DISARMABLE)
154 || g_saberPickuppableDroppedSabers->integer )
155 {//okay to drop it
156 if ( WP_SaberLose( self, NULL ) )
157 {
158 self->s.weapon = WP_NONE;
159 }
160 }
161 if ( g_saberPickuppableDroppedSabers->integer )
162 {//drop your left one, too
163 if ( self->weaponModel[1] >= 0 )
164 {//have one in left
165 if ( !(self->client->ps.saber[0].saberFlags&SFL_NOT_DISARMABLE)
166 || g_saberPickuppableDroppedSabers->integer )
167 {//okay to drop it
168 //just drop an item
169 if ( self->client->ps.saber[1].name
170 && self->client->ps.saber[1].name[0] )
171 {//have a valid string to use for saberType
172 //turn it into a pick-uppable item!
173 if ( G_DropSaberItem( self->client->ps.saber[1].name, self->client->ps.saber[1].blade[0].color, self->client->renderInfo.handLPoint, self->client->ps.velocity, self->currentAngles ) != NULL )
174 {//dropped it
175 WP_RemoveSaber( self, 1 );
176 }
177 }
178 }
179 }
180 }
181 }
182 else if ( weapon == WP_BLASTER_PISTOL )
183 {//FIXME: either drop the pistol and make the pickup only give ammo or drop ammo
184 }
185 else if ( weapon == WP_STUN_BATON

Callers 5

player_dieFunction · 0.70
Q3_SetWeaponFunction · 0.70
Rancor_AttackFunction · 0.70
SandCreature_AttackFunction · 0.70
WP_DropWeaponFunction · 0.70

Calls 9

G_DropSaberItemFunction · 0.85
Q_irandFunction · 0.85
WP_SaberLoseFunction · 0.70
WP_RemoveSaberFunction · 0.70
WP_DropThermalFunction · 0.70
FindItemForWeaponFunction · 0.70
Drop_ItemFunction · 0.70
G_ModelIndexFunction · 0.70
FindItemForAmmoFunction · 0.70

Tested by

no test coverage detected