]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/wepent_experimental
authorMario <mario@smbclan.net>
Thu, 10 Nov 2016 16:05:48 +0000 (02:05 +1000)
committerMario <mario@smbclan.net>
Thu, 10 Nov 2016 16:05:48 +0000 (02:05 +1000)
1  2 
mutators.cfg
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/server/mutators/events.qh
qcsrc/server/player.qc

diff --combined mutators.cfg
index abb74df30eebd389fe39cf431ad2a1d144380a26,b5e9b76df68c7dcc9a962a191b19fe54b63a997e..54517d9f7bb75a7704804b8ceb3f37adc7765f03
@@@ -55,6 -55,22 +55,6 @@@ set g_overkill_filter_armormedium 
  set g_overkill_filter_armorbig 0
  set g_overkill_filter_armorlarge 0
  
 -set g_overkill_ammo_charge 0
 -set g_overkill_ammo_charge_notice 1
 -set g_overkill_ammo_charge_limit 1
 -set g_overkill_ammo_charge_rate 0.5
 -set g_overkill_ammo_charge_rate_vortex 0.5
 -set g_overkill_ammo_charge_rate_machinegun 0.5
 -set g_overkill_ammo_charge_rate_shotgun 0.5
 -set g_overkill_ammo_charge_rate_hmg 0.25
 -set g_overkill_ammo_charge_rate_rpc 1.5
 -set g_overkill_ammo_decharge 0.1
 -set g_overkill_ammo_decharge_machinegun 0.025
 -set g_overkill_ammo_decharge_shotgun 0.15
 -set g_overkill_ammo_decharge_vortex 0.2
 -set g_overkill_ammo_decharge_rpc 1
 -set g_overkill_ammo_decharge_hmg 0.01
 -
  
  // =========
  //  vampire
@@@ -109,8 -125,9 +109,9 @@@ seta cl_spawn_near_teammate 1 "toggle f
  set g_spawn_near_teammate 0 "if set, players prefer spawns near a team mate"
  set g_spawn_near_teammate_distance 640 "max distance to consider a spawn to be near a team mate"
  set g_spawn_near_teammate_ignore_spawnpoint 0 "ignore spawnpoints and spawn right at team mates, if 2, clients can ignore this option"
+ set g_spawn_near_teammate_ignore_spawnpoint_max 10 "if set, test at most this many of the available teammates"
  set g_spawn_near_teammate_ignore_spawnpoint_delay 2.5 "how long to wait before its OK to spawn at a player after someone just spawned at this player"
- set g_spawn_near_teammate_ignore_spawnpoint_delay_death 0 "how long to wait before its OK to spawn at a player after death"
+ set g_spawn_near_teammate_ignore_spawnpoint_delay_death 3 "how long to wait before its OK to spawn at a player after death"
  set g_spawn_near_teammate_ignore_spawnpoint_check_health 1 "only allow spawn at this player if their health is full"
  set g_spawn_near_teammate_ignore_spawnpoint_closetodeath 1 "spawn as close to death location as possible"
  
@@@ -420,4 -437,4 +421,4 @@@ set g_walljump 0 "Enable wall jumping m
  set g_walljump_delay 1 "Minimum delay between wall jumps"
  set g_walljump_force 300 "How far to bounce/jump off the wall"
  set g_walljump_velocity_xy_factor 1.15 "How much to slow down along horizontal axis, higher value = higher deceleration, if factor is < 1, you accelerate by wall jumping"
- set g_walljump_velocity_z_factor 0.5 "Upwards velocity factor, multiplied by normal jump velocity"
+ set g_walljump_velocity_z_factor 0.5 "Upwards velocity factor, multiplied by normal jump velocity"
index 71fb67af894d91c4f8c04aa83816ab357536b5e5,6ec9c23213f132f95e95993202b74494422f3ce2..24d8c87cc0cbbfe1ca97ab8c0ec962c1160b430d
@@@ -736,7 -736,7 +736,7 @@@ void nade_boom(entity this
  
        IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
        {
 -              RemoveGrapplingHook(it.realowner);
 +              RemoveHook(it);
        });
  
        delete(this);
@@@ -785,7 -785,7 +785,7 @@@ void nade_touch(entity this, entity tou
        {
                IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
                {
 -                      RemoveGrapplingHook(it.realowner);
 +                      RemoveHook(it);
                });
                delete(this);
                return;
@@@ -891,7 -891,7 +891,7 @@@ void toss_nade(entity e, bool set_owner
        makevectors(e.v_angle);
  
        // NOTE: always throw from first weapon entity?
 -      W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
 +      W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0);
  
        Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
  
@@@ -1034,8 -1034,6 +1034,8 @@@ void spawn_held_nade(entity player, ent
        if(Nades_from(n.nade_type) == NADE_TYPE_Null)
                n.nade_type = NADE_TYPE_NORMAL.m_id;
  
 +      .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 +
        setmodel(n, MDL_PROJECTILE_NADE);
        //setattachment(n, player, "bip01 l hand");
        n.exteriormodeltoclient = player;
        setthink(n, nade_beep);
        n.nextthink = max(n.wait - 3, time);
        n.projectiledeathtype = DEATH_NADE.m_id;
 +      n.weaponentity_fld = weaponentity;
  
        setmodel(fn, MDL_NADE_VIEW);
 -      .entity weaponentity = weaponentities[0]; // TODO: unhardcode
        setattachment(fn, player.(weaponentity), "");
        fn.realowner = fn.owner = player;
        fn.colormod = Nades_from(n.nade_type).m_color;
        fn.glowmod = player.glowmod;
        setthink(fn, SUB_Remove);
        fn.nextthink = n.wait;
 +      fn.weaponentity_fld = weaponentity;
  
        player.nade = n;
        player.fake_nade = fn;
@@@ -1177,18 -1174,6 +1177,6 @@@ CLASS(NadeOffhand, OffhandWeapon
      METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
      {
        entity held_nade = player.nade;
-               if (held_nade)
-               {
-                       player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
-                       // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
-                       makevectors(player.angles);
-                       held_nade.velocity = player.velocity;
-                       setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
-                       held_nade.angles_y = player.angles.y;
-                       if (time + 0.1 >= held_nade.wait)
-                               toss_nade(player, false, '0 0 0', time + 0.05);
-               }
  
          if (!CanThrowNade(player)) return;
          if (!(time > player.nade_refire)) return;
@@@ -1230,6 -1215,20 +1218,20 @@@ MUTATOR_HOOKFUNCTION(nades, PlayerPreTh
  
        if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
  
+       entity held_nade = player.nade;
+       if (held_nade)
+       {
+               player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
+               // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
+               makevectors(player.angles);
+               held_nade.velocity = player.velocity;
+               setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
+               held_nade.angles_y = player.angles.y;
+               if (time + 0.1 >= held_nade.wait)
+                       toss_nade(player, false, '0 0 0', time + 0.05);
+       }
        if(IS_PLAYER(player))
        {
                if ( autocvar_g_nades_bonus && autocvar_g_nades )
index 0c7e6b027e3e4a355bf53ca9f8e222335628cf56,21a191a0e67c82b080d962ec034fa668fa997324..85beb641f0a91d3db6e1c2becde94a5080d4b96f
@@@ -4,15 -4,24 +4,15 @@@
  #include "rpc.qh"
  
  bool autocvar_g_overkill_powerups_replace;
 -bool autocvar_g_overkill_ammo_charge;
 -float autocvar_g_overkill_ammo_charge_notice;
 -float autocvar_g_overkill_ammo_charge_limit;
  
  bool autocvar_g_overkill_filter_healthmega;
  bool autocvar_g_overkill_filter_armormedium;
  bool autocvar_g_overkill_filter_armorbig;
  bool autocvar_g_overkill_filter_armorlarge;
  
 -.float ok_lastwep;
  .float ok_item;
  
 -.float ok_notice_time;
 -.float ammo_charge[Weapons_MAX];
 -.float ok_use_ammocharge = _STAT(OK_AMMO_CHARGE);
 -.float ok_ammo_charge = _STAT(OK_AMMO_CHARGEPOOL);
 -
 -void(entity ent, float wep) ok_DecreaseCharge;
 +.Weapon ok_lastwep[MAX_WEAPONSLOTS];
  
  void ok_Initialize();
  
@@@ -30,10 -39,59 +30,10 @@@ REGISTER_MUTATOR(ok, cvar("g_overkill"
        }
  }
  
 -MUTATOR_HOOKFUNCTION(ok, W_DecreaseAmmo)
 -{
 -      entity actor = M_ARGV(0, entity);
 -      if (actor.ok_use_ammocharge)
 -      {
 -              ok_DecreaseCharge(actor, PS(actor).m_weapon.m_id);
 -              return true;
 -      }
 -}
 -
 -MUTATOR_HOOKFUNCTION(ok, W_Reload)
 -{
 -      entity actor = M_ARGV(0, entity);
 -      return actor.ok_use_ammocharge;
 -}
 -
  void W_Blaster_Attack(entity, .entity, float, float, float, float, float, float, float, float, float, float);
  spawnfunc(weapon_hmg);
  spawnfunc(weapon_rpc);
  
 -void ok_DecreaseCharge(entity ent, int wep)
 -{
 -      if(!ent.ok_use_ammocharge) return;
 -
 -      entity wepent = Weapons_from(wep);
 -
 -      if (wepent == WEP_Null) return;  // dummy
 -
 -      ent.ammo_charge[wep] -= max(0, cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
 -}
 -
 -void ok_IncreaseCharge(entity ent, int wep)
 -{
 -      entity wepent = Weapons_from(wep);
 -
 -      if (wepent == WEP_Null) return;  // dummy
 -
 -      if(ent.ok_use_ammocharge)
 -      if(!PHYS_INPUT_BUTTON_ATCK(ent)) // not while attacking?
 -              ent.ammo_charge[wep] = min(autocvar_g_overkill_ammo_charge_limit, ent.ammo_charge[wep] + cvar(sprintf("g_overkill_ammo_charge_rate_%s", wepent.netname)) * frametime / W_TICSPERFRAME);
 -}
 -
 -float ok_CheckWeaponCharge(entity ent, int wep)
 -{
 -      if(!ent.ok_use_ammocharge) return true;
 -
 -      entity wepent = Weapons_from(wep);
 -
 -      if(wepent == WEP_Null) return false;  // dummy
 -
 -      return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
 -}
 -
  MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST)
  {
        entity frag_attacker = M_ARGV(1, entity);
@@@ -83,12 -141,7 +83,12 @@@ MUTATOR_HOOKFUNCTION(ok, PlayerDies
  
        ok_DropItem(frag_target, targ);
  
 -      frag_target.ok_lastwep = PS(frag_target).m_switchweapon.m_id;
 +      for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
 +      {
 +              .entity weaponentity = weaponentities[slot];
 +
 +              frag_target.ok_lastwep[slot] = frag_target.(weaponentity).m_switchweapon;
 +      }
  }
  
  MUTATOR_HOOKFUNCTION(ok, MonsterDropItem)
@@@ -119,22 -172,18 +119,22 @@@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink
        if(IS_DEAD(player) || !IS_PLAYER(player) || STAT(FROZEN, player))
                return;
  
 -      if(player.ok_lastwep)
 +      for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
 -              Weapon newwep = Weapons_from(player.ok_lastwep);
 -              if(player.ok_lastwep == WEP_HMG.m_id)
 -                      newwep = WEP_MACHINEGUN;
 -              if(player.ok_lastwep == WEP_RPC.m_id)
 -                      newwep = WEP_VORTEX;
 -              PS(player).m_switchweapon = newwep;
 -              player.ok_lastwep = 0;
 -      }
 +              .entity weaponentity = weaponentities[slot];
 +              entity thiswep = player.(weaponentity);
  
 -      ok_IncreaseCharge(player, PS(player).m_weapon.m_id);
 +              if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null)
 +              {
 +                      Weapon newwep = player.ok_lastwep[slot];
 +                      if(player.ok_lastwep[slot] == WEP_HMG)
 +                              newwep = WEP_MACHINEGUN;
 +                      if(player.ok_lastwep[slot] == WEP_RPC)
 +                              newwep = WEP_VORTEX;
 +                      thiswep.m_switchweapon = newwep;
 +                      player.ok_lastwep[slot] = WEP_Null;
 +              }
 +      }
  
        if(PHYS_INPUT_BUTTON_ATCK2(player))
        if( !forbidWeaponUse(player) || player.weapon_blocked // allow if weapon is blocked
                player.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(player);
                makevectors(player.v_angle);
  
 -              Weapon oldwep = PS(player).m_weapon;
 -              PS(player).m_weapon = WEP_BLASTER;
 -              W_Blaster_Attack(
 -                      player,
 -                      weaponentities[0], // TODO: unhardcode
 -                      WEP_BLASTER.m_id | HITTYPE_SECONDARY,
 -                      WEP_CVAR_SEC(vaporizer, shotangle),
 -                      WEP_CVAR_SEC(vaporizer, damage),
 -                      WEP_CVAR_SEC(vaporizer, edgedamage),
 -                      WEP_CVAR_SEC(vaporizer, radius),
 -                      WEP_CVAR_SEC(vaporizer, force),
 -                      WEP_CVAR_SEC(vaporizer, speed),
 -                      WEP_CVAR_SEC(vaporizer, spread),
 -                      WEP_CVAR_SEC(vaporizer, delay),
 -                      WEP_CVAR_SEC(vaporizer, lifetime)
 -              );
 -              PS(player).m_weapon = oldwep;
 -      }
 -
 -      player.weapon_blocked = false;
 -
 -      player.ok_ammo_charge = player.ammo_charge[PS(player).m_weapon.m_id];
 -
 -      if(player.ok_use_ammocharge)
 -      if(!ok_CheckWeaponCharge(player, PS(player).m_weapon.m_id))
 -      {
 -              if(autocvar_g_overkill_ammo_charge_notice && time > player.ok_notice_time && PHYS_INPUT_BUTTON_ATCK(player) && IS_REAL_CLIENT(player) && PS(player).m_weapon == PS(player).m_switchweapon)
 +              for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
 -                      //Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_OVERKILL_CHARGE);
 -                      player.ok_notice_time = time + 2;
 -                      play2(player, SND(DRYFIRE));
 +                      .entity weaponentity = weaponentities[slot];
 +
 +                      if(player.(weaponentity).m_weapon == WEP_Null && slot != 0)
 +                              continue;
 +
 +                      Weapon oldwep = player.(weaponentity).m_weapon;
 +                      player.(weaponentity).m_weapon = WEP_BLASTER;
 +                      W_Blaster_Attack(
 +                              player,
 +                              weaponentity,
 +                              WEP_BLASTER.m_id | HITTYPE_SECONDARY,
 +                              WEP_CVAR_SEC(vaporizer, shotangle),
 +                              WEP_CVAR_SEC(vaporizer, damage),
 +                              WEP_CVAR_SEC(vaporizer, edgedamage),
 +                              WEP_CVAR_SEC(vaporizer, radius),
 +                              WEP_CVAR_SEC(vaporizer, force),
 +                              WEP_CVAR_SEC(vaporizer, speed),
 +                              WEP_CVAR_SEC(vaporizer, spread),
 +                              WEP_CVAR_SEC(vaporizer, delay),
 +                              WEP_CVAR_SEC(vaporizer, lifetime)
 +                      );
 +                      player.(weaponentity).m_weapon = oldwep;
                }
 -              Weapon wpn = PS(player).m_weapon;
 -              .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 -              if(player.(weaponentity).state != WS_CLEAR)
 -                      w_ready(wpn, player, weaponentity, PHYS_INPUT_BUTTON_ATCK(player) | (PHYS_INPUT_BUTTON_ATCK2(player) << 1));
 -
 -              player.weapon_blocked = true;
        }
  
        PHYS_INPUT_BUTTON_ATCK2(player) = false;
@@@ -178,14 -240,19 +178,14 @@@ MUTATOR_HOOKFUNCTION(ok, PlayerSpawn
  {
        entity player = M_ARGV(0, entity);
  
 -      if(autocvar_g_overkill_ammo_charge)
 -      {
 -              FOREACH(Weapons, it != WEP_Null, LAMBDA(player.ammo_charge[it.m_id] = autocvar_g_overkill_ammo_charge_limit));
 -
 -              player.ok_use_ammocharge = 1;
 -              player.ok_notice_time = time;
 -      }
 -      else
 -              player.ok_use_ammocharge = 0;
 -
        // if player changed their weapon while dead, don't switch to their death weapon
        if(player.impulse)
 -              player.ok_lastwep = 0;
 +      {
 +              for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
 +              {
 +                      player.ok_lastwep[slot] = WEP_Null;
 +              }
 +      }
  }
  
  void self_spawnfunc_weapon_hmg(entity this) { spawnfunc_weapon_hmg(this); }
@@@ -254,6 -321,15 +254,6 @@@ MUTATOR_HOOKFUNCTION(ok, FilterItem
        return true;
  }
  
 -MUTATOR_HOOKFUNCTION(ok, SpectateCopy)
 -{
 -      entity spectatee = M_ARGV(0, entity);
 -      entity client = M_ARGV(1, entity);
 -
 -      client.ammo_charge[PS(client).m_weapon.m_id] = spectatee.ammo_charge[PS(spectatee).m_weapon.m_id];
 -      client.ok_use_ammocharge = spectatee.ok_use_ammocharge;
 -}
 -
  MUTATOR_HOOKFUNCTION(ok, SetStartItems, CBC_ORDER_LAST)
  {
        WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN));
        start_weapons = warmup_start_weapons = ok_start_items;
  }
  
+ MUTATOR_HOOKFUNCTION(ok, SetWeaponArena)
+ {
+       // turn weapon arena off
+       M_ARGV(0, string) = "off";
+ }
  MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString)
  {
        M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
index 3135d4e3d3d629a43b1d3f4c8ca68167bccf1d83,21c8ef9a5c114e92b0650f4ca5b6ec251a14d3a5..5276a64e9392f579c9cf9fe1096d1b531cfc6e0a
@@@ -137,14 -137,12 +137,14 @@@ MUTATOR_HOOKABLE(FormatMessage, EV_Form
  /** returns true if throwing the current weapon shall not be allowed */
  #define EV_ForbidThrowCurrentWeapon(i, o) \
      /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
 +    /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \
      /**/
  MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
  
  /** returns true if dropping the current weapon shall not be allowed at any time including death */
  #define EV_ForbidDropCurrentWeapon(i, o) \
 -    /** player */ i(entity, MUTATOR_ARGV_0_entity) \
 +    /** player */        i(entity, MUTATOR_ARGV_0_entity) \
 +    /** weapon id */     i(int, MUTATOR_ARGV_1_int) \
      /**/
  MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
  
@@@ -361,6 -359,7 +361,7 @@@ MUTATOR_HOOKABLE(PlayerDamage_Calculate
      /** armor     */ i(float,    MUTATOR_ARGV_3_float) \
      /** location  */ i(vector, MUTATOR_ARGV_4_vector) \
      /** deathtype */ i(int,    MUTATOR_ARGV_5_int) \
+     /** potential_damage     */ i(float,    MUTATOR_ARGV_6_float) \
      /**/
  MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
  
   * Called by W_DecreaseAmmo
   */
  #define EV_W_DecreaseAmmo(i, o) \
 -    /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
 +    /** actor */            i(entity, MUTATOR_ARGV_0_entity) \
 +    /** weapon entity */    i(entity, MUTATOR_ARGV_1_entity) \
      /**/
  MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo);
  
diff --combined qcsrc/server/player.qc
index f466c4dde1cd996030227084cb06b78df89bab7c,904447c218418c936f5f933cce7cf13062813c61..4a4d1301f58c25aa4f9220ca81c17c717f55b0f8
@@@ -24,7 -24,6 +24,7 @@@
  #include "../common/effects/qc/all.qh"
  #include "../common/mutators/mutator/waypoints/waypointsprites.qh"
  #include "../common/triggers/include.qh"
 +#include "../common/wepent.qh"
  
  #include "weapons/weaponstats.qh"
  
@@@ -491,7 -490,6 +491,7 @@@ void PlayerDamage(entity this, entity i
  
        valid_damage_for_weaponstats = 0;
        Weapon awep = WEP_Null;
 +      .entity weaponentity = weaponentities[0]; // TODO: unhardcode
  
        if(vbot || IS_REAL_CLIENT(this))
        if(abot || IS_REAL_CLIENT(attacker))
        if(DIFF_TEAM(this, attacker))
        {
                if(DEATH_ISSPECIAL(deathtype))
 -                      awep = PS(attacker).m_weapon;
 +                      awep = attacker.(weaponentity).m_weapon;
                else
                        awep = DEATH_WEAPONOF(deathtype);
                valid_damage_for_weaponstats = 1;
        da = da - max(this.armorvalue, 0);
        if(valid_damage_for_weaponstats)
        {
 -              WeaponStats_LogDamage(awep.m_id, abot, PS(this).m_weapon.m_id, vbot, dh + da);
 +              WeaponStats_LogDamage(awep.m_id, abot, this.(weaponentity).m_weapon.m_id, vbot, dh + da);
        }
-       if (dh + da)
+       if (damage)
        {
-               MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype);
+               MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype, damage);
        }
  
        if (this.health < 1)
                }
  
                if(valid_damage_for_weaponstats)
 -                      WeaponStats_LogKill(awep.m_id, abot, PS(this).m_weapon.m_id, vbot);
 +                      WeaponStats_LogKill(awep.m_id, abot, this.(weaponentity).m_weapon.m_id, vbot);
  
                if(autocvar_sv_gentle < 1)
                if(sound_allowed(MSG_BROADCAST, attacker))
                MUTATOR_CALLHOOK(PlayerDies, inflictor, attacker, this, deathtype, damage);
                excess = M_ARGV(4, float);
  
 -              Weapon wep = PS(this).m_weapon;
 -              /*for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
 +              Weapon wep = this.(weaponentity).m_weapon;
 +              for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
 -                      .entity weaponentity = weaponentities[slot];
 -                      wep.wr_playerdeath(wep, this, weaponentity);
 -              }*/
 -              .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 -              wep.wr_playerdeath(wep, this, weaponentity);
 +                      .entity went = weaponentities[slot];
 +                      wep.wr_playerdeath(wep, this, went);
 +              }
  
 -              RemoveGrapplingHook(this);
 +              RemoveGrapplingHooks(this);
  
                Portal_ClearAllLater(this);
  
                // clear waypoints
                WaypointSprite_PlayerDead(this);
                // throw a weapon
 -              SpawnThrownWeapon(this, this.origin + (this.mins + this.maxs) * 0.5, PS(this).m_switchweapon.m_id);
 +              for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
 +              {
 +                      .entity went = weaponentities[slot];
 +                      SpawnThrownWeapon(this, this.origin + (this.mins + this.maxs) * 0.5, this.(went).m_switchweapon.m_id, went);
 +              }
  
                // become fully visible
                this.alpha = default_player_alpha;