1 #include "weaponsystem.qh"
3 #include "selection.qh"
5 #include "../command/common.qh"
6 #include "../mutators/_mod.qh"
7 #include "../round_handler.qh"
8 #include <common/t_items.qh>
9 #include <common/animdecide.qh>
10 #include <common/constants.qh>
11 #include <common/monsters/_mod.qh>
12 #include <common/notifications/all.qh>
13 #include <common/util.qh>
14 #include <common/weapons/_all.qh>
15 #include <common/state.qh>
16 #include <lib/csqcmodel/sv_model.qh>
17 #include <common/wepent.qh>
21 .float weapon_frametime;
23 float W_WeaponRateFactor(entity this)
26 if(g_weaponratefactor > 0)
27 t = 1.0 / g_weaponratefactor;
29 MUTATOR_CALLHOOK(WeaponRateFactor, t, this);
35 float W_WeaponSpeedFactor(entity this)
37 float t = 1.0 * g_weaponspeedfactor;
39 MUTATOR_CALLHOOK(WeaponSpeedFactor, t, this);
46 bool CL_Weaponentity_CustomizeEntityForClient(entity this, entity client)
48 this.viewmodelforclient = this.owner;
49 if (IS_SPEC(client) && client.enemy == this.owner) this.viewmodelforclient = client;
53 vector CL_Weapon_GetShotOrg(int wpn)
55 entity wi = Weapons_from(wpn);
57 CL_WeaponEntity_SetModel(e, wi.mdl, false);
58 vector ret = e.movedir;
59 CL_WeaponEntity_SetModel(e, "", false);
69 void CL_Weaponentity_Think(entity this)
71 this.nextthink = time;
72 if (intermission_running) this.frame = this.anim_idle.x;
73 .entity weaponentity = this.weaponentity_fld;
74 if (this.owner.(weaponentity) != this)
76 // owner has new gun; remove old one
77 if (this.weaponchild) delete(this.weaponchild);
81 if (IS_DEAD(this.owner))
83 // owner died; disappear
85 if (this.weaponchild) this.weaponchild.model = "";
88 if (this.w_weaponname != this.weaponname
89 || this.w_dmg != this.modelindex
90 || this.w_deadflag != this.deadflag)
92 // owner changed weapons; update appearance
93 this.w_weaponname = this.weaponname;
94 this.w_dmg = this.modelindex;
95 this.w_deadflag = this.deadflag;
97 CL_WeaponEntity_SetModel(this, this.weaponname, true);
100 this.alpha = -1; // TODO: don't render this entity at all
102 if (this.owner.alpha == default_player_alpha) this.m_alpha = default_weapon_alpha;
103 else if (this.owner.alpha != 0) this.m_alpha = this.owner.alpha;
104 else this.m_alpha = 1;
106 if (this.weaponchild)
108 this.weaponchild.alpha = this.alpha;
109 this.weaponchild.effects = this.effects;
113 void CL_ExteriorWeaponentity_Think(entity this)
115 this.nextthink = time;
116 .entity weaponentity = this.weaponentity_fld;
117 entity w_ent = this.owner.(weaponentity);
118 if (this.owner.exteriorweaponentity != this)
123 if (IS_DEAD(this.owner))
128 if (this.weaponname != w_ent.weaponname || this.dmg != w_ent.modelindex
129 || this.deadflag != w_ent.deadflag)
131 this.weaponname = w_ent.weaponname;
132 this.dmg = w_ent.modelindex;
133 this.deadflag = w_ent.deadflag;
134 if (w_ent.weaponname != "")
136 _setmodel(this, W_Model(strcat("v_", w_ent.weaponname, ".md3")));
137 setsize(this, '0 0 0', '0 0 0');
139 else this.model = "";
142 if ((tag_found = gettagindex(this.owner, "tag_weapon")))
144 this.tag_index = tag_found;
145 this.tag_entity = this.owner;
149 setattachment(this, this.owner, "bip01 r hand");
152 this.effects = this.owner.effects;
153 this.effects |= EF_LOWPRECISION;
154 this.effects = this.effects & EFMASK_CHEAP; // eat performance
155 if (this.owner.alpha == default_player_alpha) this.alpha = default_weapon_alpha;
156 else if (this.owner.alpha != 0) this.alpha = this.owner.alpha;
159 Weapon wep = this.owner.(weaponentity).m_weapon;
160 if (wep) this.glowmod = weaponentity_glowmod(wep, this.owner, this.owner.clientcolors, this.owner.(weaponentity));
161 this.colormap = this.owner.colormap;
163 CSQCMODEL_AUTOUPDATE(this);
166 // spawning weaponentity for client
167 void CL_SpawnWeaponentity(entity actor, .entity weaponentity)
169 entity view = actor.(weaponentity) = new(weaponentity);
170 view.solid = SOLID_NOT;
172 setmodel(view, MDL_Null); // precision set when changed
173 setorigin(view, '0 0 0');
174 view.weaponentity_fld = weaponentity;
175 setthink(view, CL_Weaponentity_Think);
176 view.nextthink = time;
177 view.viewmodelforclient = actor;
178 setcefc(view, CL_Weaponentity_CustomizeEntityForClient);
182 if (weaponentity == weaponentities[0]) // only one exterior model, thank you very much
184 entity exterior = actor.exteriorweaponentity = new(exteriorweaponentity);
185 exterior.solid = SOLID_NOT;
186 exterior.owner = actor;
187 exterior.weaponentity_fld = weaponentity;
188 setorigin(exterior, '0 0 0');
189 setthink(exterior, CL_ExteriorWeaponentity_Think);
190 exterior.nextthink = time;
192 CSQCMODEL_AUTOINIT(exterior);
197 void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire)
199 actor.(weaponentity).m_weapon = WEP_Null;
200 actor.(weaponentity).m_switchingweapon = WEP_Null;
201 entity this = actor.(weaponentity);
204 this.state = WS_CLEAR;
209 void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire)
211 entity this = actor.(weaponentity);
212 if (this) this.state = WS_READY;
213 weapon_thinkf(actor, weaponentity, WFRAME_IDLE, 1000000, w_ready);
218 bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary, .entity weaponentity)
220 if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
222 if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
223 else ammo = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
224 if (ammo) return true;
225 // always keep the Mine Layer if we placed mines, so that we can detonate them
226 if (thiswep == WEP_MINE_LAYER)
228 IL_EACH(g_mines, it.owner == actor && it.weaponentity_fld == weaponentity,
234 if (thiswep == WEP_SHOTGUN)
235 if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow
237 if (thiswep == actor.(weaponentity).m_switchweapon && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
239 sound(actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
240 actor.prevdryfire = time;
243 // check if the other firing mode has enough ammo
244 bool ammo_other = false;
245 if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
246 else ammo_other = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
249 if (time - actor.prevwarntime > 1)
255 ITEM_WEAPON_PRIMORSEC,
261 actor.prevwarntime = time;
263 else // this weapon is totally unable to fire, switch to another one
265 W_SwitchToOtherWeapon(actor, weaponentity);
272 bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime)
274 if (actor.weaponentity == NULL) return true;
275 if (!weapon_prepareattack_checkammo(thiswep, actor, secondary, weaponentity)) return false;
277 // if sv_ready_restart_after_countdown is set, don't allow the player to shoot
278 // if all players readied up and the countdown is running
279 if (time < game_starttime || time < actor.race_penalty) return false;
281 if (timeout_status == TIMEOUT_ACTIVE) // don't allow the player to shoot while game is paused
284 // do not even think about shooting if switching
285 if (actor.(weaponentity).m_switchweapon != actor.(weaponentity).m_weapon) return false;
289 int slot = weaponslot(weaponentity);
290 // don't fire if previous attack is not finished
291 if (ATTACK_FINISHED(actor, slot) > time + actor.(weaponentity).weapon_frametime * 0.5) return false;
292 entity this = actor.(weaponentity);
293 // don't fire while changing weapon
294 if (this.state != WS_READY) return false;
299 void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary, float attacktime)
301 entity this = actor.(weaponentity);
302 if (this == NULL) return;
303 this.state = WS_INUSE;
305 actor.spawnshieldtime = min(actor.spawnshieldtime, time); // kill spawn shield when you fire
307 // if the weapon hasn't been firing continuously, reset the timer
310 int slot = weaponslot(weaponentity);
311 if (ATTACK_FINISHED(actor, slot) < time - this.weapon_frametime * 1.5)
313 ATTACK_FINISHED(actor, slot) = time;
314 // dprint("resetting attack finished to ", ftos(time), "\n");
316 ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * W_WeaponRateFactor(actor);
318 this.bulletcounter += 1;
319 // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n");
322 bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime)
324 if (weapon_prepareattack_check(thiswep, actor, weaponentity, secondary, attacktime))
326 weapon_prepareattack_do(actor, weaponentity, secondary, attacktime);
332 void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim);
335 * @param t defer thinking until time + t
336 * @param func next think function
338 void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,
339 .entity weaponentity, int fire) func)
341 entity this = actor.(weaponentity);
342 if (this == NULL) return;
344 if (fr == WFRAME_DONTCHANGE)
351 restartanim = fr != WFRAME_IDLE;
354 vector of = v_forward;
360 if (fr == WFRAME_IDLE) a = this.anim_idle;
361 else if (fr == WFRAME_FIRE1) a = this.anim_fire1;
362 else if (fr == WFRAME_FIRE2) a = this.anim_fire2;
363 else // if (fr == WFRAME_RELOAD)
364 a = this.anim_reload;
365 a.z *= g_weaponratefactor;
371 if (this.weapon_think == w_ready && func != w_ready && this.state == WS_RAISE) backtrace(
372 "Tried to override initial weapon think function - should this really happen?");
374 t *= W_WeaponRateFactor(actor);
376 // VorteX: haste can be added here
377 if (this.weapon_think == w_ready)
379 this.weapon_nextthink = time;
380 // dprint("started firing at ", ftos(time), "\n");
382 if (this.weapon_nextthink < time - this.weapon_frametime * 1.5
383 || this.weapon_nextthink > time + this.weapon_frametime * 1.5)
385 this.weapon_nextthink = time;
386 // dprint("reset weapon animation timer at ", ftos(time), "\n");
388 this.weapon_nextthink += t;
389 this.weapon_think = func;
390 // dprint("next ", ftos(this.weapon_nextthink), "\n");
394 FOREACH_CLIENT(true, LAMBDA(
395 if(it == actor || (IS_SPEC(it) && it.enemy == actor))
396 wframe_send(it, this, a, restartanim);
400 if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
402 bool primary_melee = boolean(fr == WFRAME_FIRE1 && (this.m_weapon.spawnflags & WEP_TYPE_MELEE_PRI));
403 bool secondary_melee = boolean(fr == WFRAME_FIRE2 && (this.m_weapon.spawnflags & WEP_TYPE_MELEE_SEC));
404 int act = (primary_melee || secondary_melee)
408 animdecide_setaction(actor, act, restartanim);
410 else if (actor.anim_upper_action == ANIMACTION_SHOOT || actor.anim_upper_action == ANIMACTION_MELEE)
412 actor.anim_upper_action = 0;
416 bool forbidWeaponUse(entity player)
418 if (time < game_starttime && !autocvar_sv_ready_restart_after_countdown) return true;
419 if (round_handler_IsActive() && !round_handler_IsRoundStarted()) return true;
420 if (player.player_blocked) return true;
421 if (gameover) return true;
422 if (STAT(FROZEN, player)) return true;
423 if (player.weapon_blocked) return true;
424 if (MUTATOR_CALLHOOK(ForbidWeaponUse, player)) return true;
428 .bool hook_switchweapon;
430 void W_WeaponFrame(Player actor, .entity weaponentity)
433 TC(PlayerState, PS(actor));
434 entity this = actor.(weaponentity);
435 if (frametime) this.weapon_frametime = frametime;
437 if (!this || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands
440 if (forbidWeaponUse(actor))
442 if (this.state != WS_CLEAR)
444 Weapon wpn = this.m_weapon;
445 w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
450 if (this.m_switchweapon == WEP_Null)
452 this.m_weapon = WEP_Null;
453 this.m_switchingweapon = WEP_Null;
454 this.state = WS_CLEAR;
455 this.weaponname = "";
456 // actor.items &= ~IT_AMMO;
460 makevectors(actor.v_angle);
461 vector fo = v_forward; // save them in case the weapon think functions change it
466 if (this.m_weapon != this.m_switchweapon)
471 LOG_WARNF("unhandled weaponentity (%i) state for player (%i): %d", this, actor, this.state);
479 Weapon newwep = this.m_switchweapon;
480 this.m_switchingweapon = newwep;
482 // the two weapon entities will notice this has changed and update their models
483 this.m_weapon = newwep;
484 this.weaponname = newwep.mdl;
485 this.bulletcounter = 0;
486 newwep.wr_setup(newwep, actor, weaponentity);
487 this.state = WS_RAISE;
489 // set our clip load to the load of the weapon we switched to, if it's reloadable
490 if ((newwep.spawnflags & WEP_FLAG_RELOADABLE) && newwep.reloading_ammo) // prevent accessing undefined cvars
492 this.clip_load = this.(weapon_load[this.m_switchweapon.m_id]);
493 this.clip_size = newwep.reloading_ammo;
497 this.clip_load = this.clip_size = 0;
500 weapon_thinkf(actor, weaponentity, WFRAME_IDLE, newwep.switchdelay_raise, w_ready);
505 // in dropping phase we can switch at any time
506 this.m_switchingweapon = this.m_switchweapon;
512 this.m_switchingweapon = this.m_switchweapon;
513 entity oldwep = this.m_weapon;
515 // set up weapon switch think in the future, and start drop anim
516 if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + this.weapon_frametime * 0.5)
518 sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
519 this.state = WS_DROP;
520 weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear);
527 // LordHavoc: network timing test code
528 // if (actor.button0)
529 // print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor, slot)), " >= ", ftos(this.weapon_nextthink), "\n");
531 Weapon w = this.m_weapon;
533 // call the think code which may fire the weapon
534 // and do so multiple times to resolve framerate dependency issues if the
535 // server framerate is very low and the weapon fire rate very high
536 for (int c = 0; c < W_TICSPERFRAME; ++c)
538 if (w != WEP_Null && !(actor.weapons & WepSet_FromWeapon(w)))
540 if (this.m_weapon == this.m_switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
548 bool block_weapon = false;
550 bool key_pressed = PHYS_INPUT_BUTTON_HOOK(actor) && !actor.vehicle;
551 Weapon off = actor.offhand;
552 if (off && !(actor.weapons & WEPSET(HOOK)))
554 if (off.offhand_think) off.offhand_think(off, actor, key_pressed);
558 if (key_pressed && this.m_switchweapon != WEP_HOOK && !actor.hook_switchweapon)
559 W_SwitchWeapon(actor, WEP_HOOK, weaponentity);
560 actor.hook_switchweapon = key_pressed;
562 block_weapon = (this.m_weapon == h && (PHYS_INPUT_BUTTON_ATCK(actor) || key_pressed));
563 h.wr_think(h, actor, weaponentity, block_weapon ? 1 : 0);
573 Weapon e = this.m_weapon;
577 e.wr_think(e, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
581 e.wr_gonethink(e, actor, weaponentity);
585 if (time + this.weapon_frametime * 0.5 >= this.weapon_nextthink)
587 if (this.weapon_think)
592 Weapon wpn = this.m_weapon;
593 this.weapon_think(wpn, actor, weaponentity,
594 PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
598 bprint("\{1}^1ERROR: undefined weapon think function for ", actor.netname, "\n");
604 void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector offset)
607 flash.angles_z = random() * 360;
609 entity view = actor.(weaponentity);
610 entity exterior = actor.exteriorweaponentity;
612 if (gettagindex(view, "shot")) setattachment(flash, view, "shot");
613 else setattachment(flash, view, "tag_shot");
614 setorigin(flash, offset);
616 entity xflash = spawn();
617 copyentity(flash, xflash);
619 flash.viewmodelforclient = actor;
621 if (view.oldorigin.x > 0)
623 setattachment(xflash, exterior, "");
624 setorigin(xflash, view.oldorigin + offset);
628 if (gettagindex(exterior, "shot")) setattachment(xflash, exterior, "shot");
629 else setattachment(xflash, exterior, "tag_shot");
630 setorigin(xflash, offset);
634 void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity)
636 if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor, actor.(weaponentity))) return;
638 if ((actor.items & IT_UNLIMITED_WEAPON_AMMO) && !wep.reloading_ammo) return;
640 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
641 if (wep.reloading_ammo)
643 actor.(weaponentity).clip_load -= ammo_use;
644 actor.(weaponentity).(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.(weaponentity).clip_load;
646 else if (wep.ammo_field != ammo_none)
648 actor.(wep.ammo_field) -= ammo_use;
649 if (actor.(wep.ammo_field) < 0)
652 "W_DecreaseAmmo(%.2f): '%s' subtracted too much %s from '%s', resulting with '%.2f' left... "
653 "Please notify Samual immediately with a copy of this backtrace!\n",
656 GetAmmoPicture(wep.ammo_field),
658 actor.(wep.ammo_field)
664 // weapon reloading code
666 .float reload_ammo_amount, reload_ammo_min, reload_time;
667 .float reload_complain;
668 .string reload_sound;
670 void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int fire)
672 // finish the reloading process, and do the ammo transfer
674 Weapon wpn = actor.(weaponentity).m_weapon;
676 actor.(weaponentity).clip_load = actor.(weaponentity).old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
678 // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load
679 if (!actor.(weaponentity).reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_field == ammo_none)
681 actor.(weaponentity).clip_load = actor.(weaponentity).reload_ammo_amount;
685 // make sure we don't add more ammo than we have
686 float load = min(actor.(weaponentity).reload_ammo_amount - actor.(weaponentity).clip_load, actor.(wpn.ammo_field));
687 actor.(weaponentity).clip_load += load;
688 actor.(wpn.ammo_field) -= load;
690 actor.(weaponentity).(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.(weaponentity).clip_load;
692 // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,
693 // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
694 // so your weapon is disabled for a few seconds without reason
696 // ATTACK_FINISHED(actor, slot) -= actor.(weaponentity).reload_time - 1;
698 w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
701 void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound)
703 TC(Sound, sent_sound);
704 // set global values to work with
705 Weapon e = actor.(weaponentity).m_weapon;
707 if (MUTATOR_CALLHOOK(W_Reload, actor)) return;
709 actor.(weaponentity).reload_ammo_min = sent_ammo_min;
710 actor.(weaponentity).reload_ammo_amount = e.reloading_ammo;
711 actor.(weaponentity).reload_time = e.reloading_time;
712 if (actor.reload_sound) strunzone(actor.reload_sound);
713 actor.reload_sound = strzone(Sound_fixpath(sent_sound));
715 // don't reload weapons that don't have the RELOADABLE flag
716 if (!(e.spawnflags & WEP_FLAG_RELOADABLE))
719 "Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");
723 // return if reloading is disabled for this weapon
724 if (!actor.(weaponentity).reload_ammo_amount) return;
726 // our weapon is fully loaded, no need to reload
727 if (actor.(weaponentity).clip_load >= actor.(weaponentity).reload_ammo_amount) return;
729 // no ammo, so nothing to load
730 if (e.ammo_field != ammo_none)
732 if (!actor.(e.ammo_field) && actor.(weaponentity).reload_ammo_min)
734 if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
736 if (IS_REAL_CLIENT(actor) && actor.reload_complain < time)
738 play2(actor, SND(UNAVAILABLE));
739 sprint(actor, strcat("You don't have enough ammo to reload the ^2", actor.(weaponentity).m_weapon.m_name, "\n"));
740 actor.reload_complain = time + 1;
742 // switch away if the amount of ammo is not enough to keep using this weapon
743 if (!(e.wr_checkammo1(e, actor, weaponentity) + e.wr_checkammo2(e, actor, weaponentity)))
745 actor.(weaponentity).clip_load = -1; // reload later
746 W_SwitchToOtherWeapon(actor, weaponentity);
753 entity this = actor.(weaponentity);
756 if (this.wframe == WFRAME_RELOAD) return;
758 // allow switching away while reloading, but this will cause a new reload!
759 this.state = WS_READY;
762 // now begin the reloading process
764 _sound(actor, CH_WEAPON_SINGLE, actor.reload_sound, VOL_BASE, ATTEN_NORM);
766 // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,
767 // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
768 // so your weapon is disabled for a few seconds without reason
770 // ATTACK_FINISHED(actor, slot) = max(time, ATTACK_FINISHED(actor, slot)) + actor.(weaponentity).reload_time + 1;
772 weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, this.reload_time, W_ReloadedAndReady);
774 if (this.clip_load < 0) this.clip_load = 0;
775 this.old_clip_load = this.clip_load;
776 this.clip_load = this.(weapon_load[this.m_weapon.m_id]) = -1;
779 void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity)
781 Weapon w = Weapons_from(weapon_type);
782 weapon_dropevent_item = weapon_item;
783 w.event(w, player, weaponentity);