MCPcopy Create free account
hub / github.com/assaultcube/AC / pickupeffects

Function pickupeffects

source/src/entities.cpp:295–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293// picked up the item (in multiplayer someone may grab it before you).
294
295void pickupeffects(int n, playerent *d)
296{
297 if(!ents.inrange(n)) return;
298 entity &e = ents[n];
299 e.spawned = false;
300 if(!d) return;
301 d->pickup(e.type);
302 if (m_lss && e.type == I_GRENADE) d->pickup(e.type); // get 2
303 itemstat *is = d->itemstats(e.type);
304 if(d!=player1 && d->type!=ENT_BOT) return;
305 if(is)
306 {
307 if(d==player1)
308 {
309 audiomgr.playsoundc(is->sound);
310 if(identexists("onPickup"))
311 {
312 // onPickup arg1: 0: clips, ammo box, 2: grenade, health, 4: helmet, armour, 6: akimbo
313 if(is) exechook(HOOK_SP, "onPickup", "%d %d", e.type - 3, m_lss && e.type == I_GRENADE ? 2 : is->add);
314 }
315 }
316 else audiomgr.playsound(is->sound, d);
317 }
318
319 weapon *w = NULL;
320 switch(e.type)
321 {
322 case I_AKIMBO: w = d->weapons[GUN_AKIMBO]; break;
323 case I_CLIPS: w = d->weapons[GUN_PISTOL]; break;
324 case I_AMMO: w = d->primweap; break;
325 case I_GRENADE: w = d->weapons[GUN_GRENADE]; break;
326 }
327 if(w) w->onammopicked();
328}
329
330// these functions are called when the client touches the item
331

Callers 2

parsemessagesFunction · 0.85
trypickupFunction · 0.85

Calls 8

identexistsFunction · 0.85
exechookFunction · 0.85
inrangeMethod · 0.80
pickupMethod · 0.80
itemstatsMethod · 0.80
playsoundcMethod · 0.80
playsoundMethod · 0.80
onammopickedMethod · 0.45

Tested by

no test coverage detected