Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
authorLyberta <lyberta@lyberta.net>
Sat, 2 Dec 2017 15:55:11 +0000 (18:55 +0300)
committerLyberta <lyberta@lyberta.net>
Sat, 2 Dec 2017 15:55:11 +0000 (18:55 +0300)
1  2 
qcsrc/client/view.qc
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/server/client.qc
qcsrc/server/defs.qh

diff --combined qcsrc/client/view.qc
@@@ -12,6 -12,7 +12,7 @@@
  #include "mutators/events.qh"
  
  #include <common/animdecide.qh>
+ #include <common/deathtypes/all.qh>
  #include <common/ent_cs.qh>
  #include <common/anim.qh>
  #include <common/constants.qh>
@@@ -29,7 -30,6 +30,7 @@@
  
  #include <common/vehicles/all.qh>
  #include <common/weapons/_all.qh>
 +#include <common/mutators/mutator/overkill/okvortex.qh>
  #include <common/viewloc.qh>
  #include <common/minigames/cl_minigames.qh>
  #include <common/minigames/cl_minigames_hud.qh>
@@@ -471,7 -471,7 +472,7 @@@ vector GetCurrentFov(float fov
                {
                        entity wepent = viewmodels[slot];
                        if(wepent.switchweapon == wepent.activeweapon)
 -                      if((wepent.activeweapon == WEP_VORTEX && !WEP_CVAR(vortex, secondary)) || (wepent.activeweapon == WEP_RIFLE && !WEP_CVAR(rifle, secondary))) // do NOT use switchweapon here
 +                      if((wepent.activeweapon == WEP_VORTEX && !WEP_CVAR(vortex, secondary)) || (wepent.activeweapon == WEP_RIFLE && !WEP_CVAR(rifle, secondary)) || (wepent.activeweapon == WEP_OVERKILL_VORTEX && !WEP_CVAR(okvortex, secondary))) // do NOT use switchweapon here
                                zoomdir += button_attack2;
                }
        }
@@@ -663,7 -663,6 +664,7 @@@ float TrueAimCheck(entity wepent
                case WEP_MORTAR: // toss curve
                        return SHOTTYPE_HITWORLD;
                case WEP_VORTEX:
 +              case WEP_OVERKILL_VORTEX:
                case WEP_VAPORIZER:
                        mv = MOVE_NORMAL;
                        break;
@@@ -912,7 -911,8 +913,8 @@@ vector crosshair_getcolor(entity this, 
  
                case 2: // crosshair_color_by_health
                {
-                       float hp = health_stat;
+                       vector v = healtharmor_maxdamage(health_stat, STAT(ARMOR), armorblockpercent, DEATH_WEAPON.m_id);
+                       float hp = floor(v.x + 1);
  
                        //x = red
                        //y = green
@@@ -1188,10 -1188,6 +1190,10 @@@ void HUD_Crosshair(entity this
                                vortex_charge = STAT(VORTEX_CHARGE);
                                vortex_chargepool = STAT(VORTEX_CHARGEPOOL);
  
 +                              float okvortex_charge, okvortex_chargepool;
 +                              okvortex_charge = STAT(OVERKILL_VORTEX_CHARGE);
 +                              okvortex_chargepool = STAT(OVERKILL_VORTEX_CHARGEPOOL);
 +
                                float arc_heat = STAT(ARC_HEAT);
  
                                if(vortex_charge_movingavg == 0) // this should only happen if we have just loaded up the game
                                        ring_rgb = wcross_color;
                                        ring_image = "gfx/crosshair_ring_nexgun.tga";
                                }
 +                              else if (autocvar_crosshair_ring && (wepent.activeweapon == WEP_OVERKILL_VORTEX) && okvortex_charge && autocvar_crosshair_ring_vortex)
 +                              {
 +                                      if (okvortex_chargepool || use_vortex_chargepool) {
 +                                              use_vortex_chargepool = 1;
 +                                              ring_inner_value = okvortex_chargepool;
 +                                      } else {
 +                                              vortex_charge_movingavg = (1 - autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate) * vortex_charge_movingavg + autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate * okvortex_charge;
 +                                              ring_inner_value = bound(0, autocvar_crosshair_ring_vortex_currentcharge_scale * (okvortex_charge - vortex_charge_movingavg), 1);
 +                                      }
 +
 +                                      ring_inner_alpha = autocvar_crosshair_ring_vortex_inner_alpha;
 +                                      ring_inner_rgb = eX * autocvar_crosshair_ring_vortex_inner_color_red + eY * autocvar_crosshair_ring_vortex_inner_color_green + eZ * autocvar_crosshair_ring_vortex_inner_color_blue;
 +                                      ring_inner_image = "gfx/crosshair_ring_inner.tga";
 +
 +                                      // draw the outer ring to show the current charge of the weapon
 +                                      ring_value = okvortex_charge;
 +                                      ring_alpha = autocvar_crosshair_ring_vortex_alpha;
 +                                      ring_rgb = wcross_color;
 +                                      ring_image = "gfx/crosshair_ring_nexgun.tga";
 +                              }
                                else if (autocvar_crosshair_ring && wepent.activeweapon == WEP_MINE_LAYER && WEP_CVAR(minelayer, limit) && autocvar_crosshair_ring_minelayer)
                                {
                                        ring_value = bound(0, STAT(LAYED_MINES) / WEP_CVAR(minelayer, limit), 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to.
@@@ -37,9 -37,9 +37,9 @@@ REGISTER_MUTATOR(ok, expr_evaluate(auto
                WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
                WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
  
 -              WEP_SHOTGUN.mdl = "ok_shotgun";
 -              WEP_MACHINEGUN.mdl = "ok_mg";
 -              WEP_VORTEX.mdl = "ok_sniper";
 +              //WEP_SHOTGUN.mdl = "ok_shotgun";
 +              //WEP_MACHINEGUN.mdl = "ok_mg";
 +              //WEP_VORTEX.mdl = "ok_sniper";
        }
  
        MUTATOR_ONREMOVE
@@@ -120,6 -120,53 +120,6 @@@ MUTATOR_HOOKFUNCTION(ok, ForbidThrowCur
        return true;
  }
  
 -MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
 -{
 -      if(game_stopped)
 -              return;
 -
 -      entity player = M_ARGV(0, entity);
 -
 -      if(IS_DEAD(player) || !IS_PLAYER(player) || STAT(FROZEN, player))
 -              return;
 -
 -      if(PHYS_INPUT_BUTTON_ATCK2(player) && time >= player.jump_interval)
 -      if( !forbidWeaponUse(player)
 -              || (round_handler_IsActive() && !round_handler_IsRoundStarted()) )
 -      {
 -              player.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(player);
 -              makevectors(player.v_angle);
 -
 -              for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
 -              {
 -                      .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;
 -              }
 -      }
 -
 -      PHYS_INPUT_BUTTON_ATCK2(player) = false;
 -}
 -
  MUTATOR_HOOKFUNCTION(ok, PlayerWeaponSelect)
  {
        entity player = M_ARGV(0, entity);
@@@ -158,7 -205,7 +158,7 @@@ MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpa
                        setorigin(wep, ent.origin);
                        setmodel(wep, MDL_OK_HMG);
                        wep.ok_item = true;
-                       wep.noalign = ent.noalign;
+                       wep.noalign = Item_ShouldKeepPosition(ent);
                        wep.cnt = ent.cnt;
                        wep.team = ent.team;
                        wep.respawntime = g_pickup_respawntime_superweapon;
                        setorigin(wep, ent.origin);
                        setmodel(wep, MDL_OK_RPC);
                        wep.ok_item = true;
-                       wep.noalign = ent.noalign;
+                       wep.noalign = Item_ShouldKeepPosition(ent);
                        wep.cnt = ent.cnt;
                        wep.team = ent.team;
                        wep.respawntime = g_pickup_respawntime_superweapon;
@@@ -227,7 -274,7 +227,7 @@@ MUTATOR_HOOKFUNCTION(ok, FilterItem
  
  MUTATOR_HOOKFUNCTION(ok, SetStartItems, CBC_ORDER_LAST)
  {
 -      WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN));
 +      WepSet ok_start_items = (WEPSET(OVERKILL_MACHINEGUN) | WEPSET(OVERKILL_VORTEX) | WEPSET(OVERKILL_SHOTGUN));
  
        if(WEP_RPC.weaponstart > 0) { ok_start_items |= WEPSET(RPC); }
        if(WEP_HMG.weaponstart > 0) { ok_start_items |= WEPSET(HMG); }
@@@ -257,4 -304,3 +257,4 @@@ MUTATOR_HOOKFUNCTION(ok, SetModname
        M_ARGV(0, string) = "Overkill";
        return true;
  }
 +
diff --combined qcsrc/server/client.qc
@@@ -61,8 -61,6 +61,8 @@@
  
  #include "../lib/warpzone/server.qh"
  
 +#include <common/mutators/mutator/overkill/okvortex.qh>
 +
  STATIC_METHOD(Client, Add, void(Client this, int _team))
  {
      ClientConnect(this);
@@@ -656,9 -654,11 +656,11 @@@ void PutPlayerInServer(entity this
  
        PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
  
+       // player was spectator
        if (CS(this).killcount == FRAGS_SPECTATOR) {
                PlayerScore_Clear(this);
                CS(this).killcount = 0;
+               CS(this).startplaytime = time;
        }
  
        for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
@@@ -1758,8 -1758,6 +1760,8 @@@ void SpectateCopy(entity this, entity s
        this.weapons = spectatee.weapons;
        this.vortex_charge = spectatee.vortex_charge;
        this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
 +      this.okvortex_charge = spectatee.okvortex_charge;
 +      this.okvortex_chargepool_ammo = spectatee.okvortex_chargepool_ammo;
        this.hagar_load = spectatee.hagar_load;
        this.arc_heat_percent = spectatee.arc_heat_percent;
        this.minelayer_mines = spectatee.minelayer_mines;
diff --combined qcsrc/server/defs.qh
@@@ -138,7 -138,8 +138,8 @@@ void checkSpectatorBlock(entity this)
  
  float game_completion_ratio; // 0 at start, 1 near end
  .float winning;
- .float jointime; // time of joining
+ .float jointime; // time of connecting
+ .float startplaytime; // time of switching from spectator to player
  .float alivetime; // time of being alive
  .float motd_actived_time; // used for both motd and campaign_message
  
@@@ -325,9 -326,6 +326,9 @@@ float client_cefc_accumulatortime
  .float vortex_charge = _STAT(VORTEX_CHARGE);
  .float vortex_charge_rottime;
  .float vortex_chargepool_ammo = _STAT(VORTEX_CHARGEPOOL);
 +.float okvortex_charge = _STAT(OVERKILL_VORTEX_CHARGE);
 +.float okvortex_charge_rottime;
 +.float okvortex_chargepool_ammo = _STAT(OVERKILL_VORTEX_CHARGEPOOL);
  .float hagar_load = _STAT(HAGAR_LOAD);
  
  .int grab; // 0 = can't grab, 1 = owner can grab, 2 = owner and team mates can grab, 3 = anyone can grab