]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/killother 327/head
authorMario <mario@smbclan.net>
Thu, 23 Jun 2016 20:24:59 +0000 (06:24 +1000)
committerMario <mario@smbclan.net>
Thu, 23 Jun 2016 20:24:59 +0000 (06:24 +1000)
1  2 
qcsrc/common/mutators/mutator/buffs/buffs.qc
qcsrc/common/mutators/mutator/sandbox/sandbox.qc
qcsrc/common/vehicles/sv_vehicles.qc

index de32df9683483ab1f9d4280f558e20b30cdd5ef2,1507a5f13c3d577fb91ced23d9cbf8efa04ca158..921cd03cd39dadbcf043cdfbcb8a203644f1ea02
@@@ -92,12 -92,12 +92,12 @@@ REGISTER_MUTATOR(buffs, cvar("g_buffs")
        }
  }
  
 -bool buffs_BuffModel_Customize(entity this)
 +bool buffs_BuffModel_Customize(entity this, entity client)
  {
        entity player, myowner;
        bool same_team;
  
 -      player = WaypointSprite_getviewentity(other);
 +      player = WaypointSprite_getviewentity(client);
        myowner = this.owner;
        same_team = (SAME_TEAM(player, myowner) || SAME_TEAM(player, myowner));
  
        if(MUTATOR_CALLHOOK(BuffModel_Customize, this, player))
                return false;
  
 -      if(player == myowner || (IS_SPEC(other) && other.enemy == myowner))
 +      if(player == myowner || (IS_SPEC(client) && client.enemy == myowner))
        {
                // somewhat hide the model, but keep the glow
                this.effects = 0;
@@@ -222,7 -222,7 +222,7 @@@ void buff_Respawn(entity this
        sound(this, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
  }
  
 -void buff_Touch(entity this)
 +void buff_Touch(entity this, entity toucher)
  {
        if(gameover) { return; }
  
                return;
        }
  
 -      if((this.team && DIFF_TEAM(other, this))
 -      || (STAT(FROZEN, other))
 -      || (other.vehicle)
 +      if((this.team && DIFF_TEAM(toucher, this))
 +      || (STAT(FROZEN, toucher))
 +      || (toucher.vehicle)
        || (!this.buff_active)
        )
        {
                return;
        }
  
 -      if(MUTATOR_CALLHOOK(BuffTouch, this, other))
 +      if(MUTATOR_CALLHOOK(BuffTouch, this, toucher))
                return;
 -      other = M_ARGV(1, entity);
 +      toucher = M_ARGV(1, entity);
  
 -      if(!IS_PLAYER(other))
 -              return; // incase mutator changed other
 +      if(!IS_PLAYER(toucher))
 +              return; // incase mutator changed toucher
  
 -      if (other.buffs)
 +      if (toucher.buffs)
        {
 -              if (other.cvar_cl_buffs_autoreplace && other.buffs != this.buffs)
 +              if (toucher.cvar_cl_buffs_autoreplace && toucher.buffs != this.buffs)
                {
 -                      int buffid = buff_FirstFromFlags(other.buffs).m_id;
 -                      //Send_Notification(NOTIF_ONE, other, MSG_MULTI, ITEM_BUFF_DROP, other.buffs);
 -                      Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ITEM_BUFF_LOST, other.netname, buffid);
 +                      int buffid = buff_FirstFromFlags(toucher.buffs).m_id;
 +                      //Send_Notification(NOTIF_ONE, toucher, MSG_MULTI, ITEM_BUFF_DROP, toucher.buffs);
 +                      Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ITEM_BUFF_LOST, toucher.netname, buffid);
  
 -                      other.buffs = 0;
 -                      //sound(other, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
 +                      toucher.buffs = 0;
 +                      //sound(toucher, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
                }
                else { return; } // do nothing
        }
  
 -      this.owner = other;
 +      this.owner = toucher;
        this.buff_active = false;
        this.lifetime = 0;
        int buffid = buff_FirstFromFlags(this.buffs).m_id;
 -      Send_Notification(NOTIF_ONE, other, MSG_MULTI, ITEM_BUFF_GOT, buffid);
 -      Send_Notification(NOTIF_ALL_EXCEPT, other, MSG_INFO, INFO_ITEM_BUFF, other.netname, buffid);
 +      Send_Notification(NOTIF_ONE, toucher, MSG_MULTI, ITEM_BUFF_GOT, buffid);
 +      Send_Notification(NOTIF_ALL_EXCEPT, toucher, MSG_INFO, INFO_ITEM_BUFF, toucher.netname, buffid);
  
        Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
 -      sound(other, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTN_NORM);
 -      other.buffs |= (this.buffs);
 +      sound(toucher, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTN_NORM);
 +      toucher.buffs |= (this.buffs);
  }
  
  float buff_Available(entity buff)
@@@ -390,9 -390,9 +390,9 @@@ void buff_Reset(entity this
                buff_Respawn(this);
  }
  
 -float buff_Customize(entity this)
 +bool buff_Customize(entity this, entity client)
  {
 -      entity player = WaypointSprite_getviewentity(other);
 +      entity player = WaypointSprite_getviewentity(client);
        if(!this.buff_active || (this.team && DIFF_TEAM(player, this)))
        {
                this.alpha = 0.3;
@@@ -626,6 -626,7 +626,7 @@@ MUTATOR_HOOKFUNCTION(buffs, PlayerSpawn
        entity player = M_ARGV(0, entity);
  
        player.buffs = 0;
+       player.buff_time = 0;
        // reset timers here to prevent them continuing after re-spawn
        player.buff_disability_time = 0;
        player.buff_disability_effect_time = 0;
@@@ -708,6 -709,7 +709,7 @@@ MUTATOR_HOOKFUNCTION(buffs, PlayerUseKe
                Send_Notification(NOTIF_ALL_EXCEPT, player, MSG_INFO, INFO_ITEM_BUFF_LOST, player.netname, buffid);
  
                player.buffs = 0;
+               player.buff_time = 0; // already notified
                sound(player, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
                return true;
        }
@@@ -870,7 -872,7 +872,7 @@@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreTh
        // 2: notify carrier as well
        int buff_lost = 0;
  
-       if(player.buff_time)
+       if(player.buff_time && player.buffs)
        if(time >= player.buff_time)
        {
                player.buff_time = 0;
                if(player.buffs)
                {
                        int buffid = buff_FirstFromFlags(player.buffs).m_id;
-                       Send_Notification(NOTIF_ALL_EXCEPT, player, MSG_INFO, INFO_ITEM_BUFF_LOST, player.netname, buffid);
-                       if(buff_lost >= 2)
+                       if(buff_lost == 2)
                        {
                                Send_Notification(NOTIF_ONE, player, MSG_MULTI, ITEM_BUFF_DROP, buffid); // TODO: special timeout message?
                                sound(player, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
                        }
+                       else
+                               Send_Notification(NOTIF_ALL_EXCEPT, player, MSG_INFO, INFO_ITEM_BUFF_LOST, player.netname, buffid);
                        player.buffs = 0;
                }
        }
                        if(boxesoverlap(player.absmin - pickup_size, player.absmax + pickup_size, it.absmin, it.absmax))
                        {
                                if(gettouch(it))
 -                              {
 -                                      entity oldother = other;
 -                                      other = player;
 -                                      gettouch(it)(it);
 -                                      other = oldother;
 -                              }
 +                                      gettouch(it)(it, player);
                        }
                });
        }
index cb930785921ebc0f0f760c3010f1d8c071d71c02,1805d720117c9bf60725937a6005479fb59a3f4e..973ff3151c739b2b5aec2cdc0c56ca83eedc8c1e
@@@ -34,7 -34,7 +34,7 @@@ float object_count
  .string material;
  
  .float touch_timer;
 -void sandbox_ObjectFunction_Touch(entity this)
 +void sandbox_ObjectFunction_Touch(entity this, entity toucher)
  {
        // apply material impact effects
  
@@@ -46,7 -46,7 +46,7 @@@
  
        // make particle count and sound volume depend on impact speed
        float intensity;
 -      intensity = vlen(this.velocity) + vlen(other.velocity);
 +      intensity = vlen(this.velocity) + vlen(toucher.velocity);
        if(intensity) // avoid divisions by 0
                intensity /= 2; // average the two velocities
        if (!(intensity >= autocvar_g_sandbox_object_material_velocity_min))
@@@ -142,25 -142,23 +142,23 @@@ void sandbox_ObjectAttach_Remove(entit
  {
        // detaches any object attached to e
  
-       entity head;
-       for(head = NULL; (head = find(head, classname, "object")); )
+       FOREACH_ENTITY_ENT(owner, e,
        {
-               if(head.owner == e)
-               {
-                       vector org;
-                       org = gettaginfo(head, 0);
-                       setattachment(head, NULL, "");
-                       head.owner = NULL;
-                       // objects change origin and angles when detached, so apply previous position
-                       setorigin(head, org);
-                       head.angles = e.angles; // don't allow detached objects to spin or roll
-                       head.solid = head.old_solid; // restore persisted solidity
-                       head.movetype = head.old_movetype; // restore persisted physics
-                       head.takedamage = DAMAGE_AIM;
-               }
-       }
+               if(it.classname != "object") continue;
+               vector org;
+               org = gettaginfo(it, 0);
+               setattachment(it, NULL, "");
+               it.owner = NULL;
+               // objects change origin and angles when detached, so apply previous position
+               setorigin(it, org);
+               it.angles = e.angles; // don't allow detached objects to spin or roll
+               it.solid = it.old_solid; // restore persisted solidity
+               it.movetype = it.old_movetype; // restore persisted physics
+               it.takedamage = DAMAGE_AIM;
+       });
  }
  
  entity sandbox_ObjectSpawn(entity this, float database)
@@@ -462,7 -460,7 +460,7 @@@ MUTATOR_HOOKFUNCTION(sandbox, SV_ParseC
                switch(argv(1))
                {
                        entity e;
-                       float i;
+                       int j;
                        string s;
  
                        // ---------------- COMMAND: HELP ----------------
                                                        if(e.material)  strunzone(e.material);
                                                        if(argv(3))
                                                        {
-                                                               for (i = 1; i <= 5; i++) // precache material sounds, 5 in total
-                                                                       precache_sound(strcat("object/impact_", argv(3), "_", ftos(i), ".wav"));
+                                                               for (j = 1; j <= 5; j++) // precache material sounds, 5 in total
+                                                                       precache_sound(strcat("object/impact_", argv(3), "_", ftos(j), ".wav"));
                                                                e.material = strzone(argv(3));
                                                        }
                                                        else
                                                case "attachments":
                                                        // this should show the same info as 'mesh' but for attachments
                                                        s = "";
-                                                       entity head;
-                                                       i = 0;
-                                                       for(head = NULL; (head = find(head, classname, "object")); )
+                                                       j = 0;
+                                                       FOREACH_ENTITY_ENT(owner, e,
                                                        {
-                                                               if(head.owner == e)
-                                                               {
-                                                                       ++i; // start from 1
-                                                                       gettaginfo(e, head.tag_index);
-                                                                       s = strcat(s, "^1attachment ", ftos(i), "^7 has mesh \"^3", head.model, "^7\" at animation frame ^3", ftos(head.frame));
-                                                                       s = strcat(s, "^7 and is attached to bone \"^5", gettaginfo_name, "^7\", ");
-                                                               }
-                                                       }
-                                                       if(i) // object contains attachments
-                                                               print_to(player, strcat("^2SANDBOX - INFO: ^7Object contains the following ^1", ftos(i), "^7 attachment(s): ", s));
+                                                               if(it.classname != "object") continue;
+                                                               ++j; // start from 1
+                                                               gettaginfo(e, it.tag_index);
+                                                               s = strcat(s, "^1attachment ", ftos(j), "^7 has mesh \"^3", it.model, "^7\" at animation frame ^3", ftos(it.frame));
+                                                               s = strcat(s, "^7 and is attached to bone \"^5", gettaginfo_name, "^7\", ");
+                                                       });
+                                                       if(j) // object contains attachments
+                                                               print_to(player, strcat("^2SANDBOX - INFO: ^7Object contains the following ^1", ftos(j), "^7 attachment(s): ", s));
                                                        else
                                                                print_to(player, "^2SANDBOX - INFO: ^7Object contains no attachments");
                                                        return true;
index c3a1ec6c9b8e9b194541612cbe1d7adf9cea266f,28ba057c0d41ad3fdefb84b2081fd42fb5a80cc0..fb6fd94871fbe10af4e6446dfb4ba5ce456d2ec9
@@@ -179,33 -179,28 +179,33 @@@ void vehicles_projectile_damage(entity 
        }
  }
  
 -void vehicles_projectile_explode(entity this)
 +void vehicles_projectile_explode(entity this, entity toucher)
  {
 -      if(this.owner && other != NULL)
 +      if(this.owner && toucher != NULL)
        {
 -              if(other == this.owner.vehicle)
 +              if(toucher == this.owner.vehicle)
                        return;
  
 -              if(other == this.owner.vehicle.tur_head)
 +              if(toucher == this.owner.vehicle.tur_head)
                        return;
        }
  
 -      PROJECTILE_TOUCH(this);
 +      PROJECTILE_TOUCH(this, toucher);
  
        this.event_damage = func_null;
 -      RadiusDamage (this, this.realowner, this.shot_dmg, 0, this.shot_radius, this, NULL, this.shot_force, this.totalfrags, other);
 +      RadiusDamage (this, this.realowner, this.shot_dmg, 0, this.shot_radius, this, NULL, this.shot_force, this.totalfrags, toucher);
  
        remove (this);
  }
  
 +void vehicles_projectile_explode_think(entity this)
 +{
 +      vehicles_projectile_explode(this, NULL);
 +}
 +
  void vehicles_projectile_explode_use(entity this, entity actor, entity trigger)
  {
 -      vehicles_projectile_explode(this);
 +      vehicles_projectile_explode(this, trigger);
  }
  
  entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound,
@@@ -269,11 -264,6 +269,11 @@@ void vehicles_gib_explode(entity this
        remove(this);
  }
  
 +void vehicles_gib_touch(entity this, entity toucher)
 +{
 +      vehicles_gib_explode(this);
 +}
 +
  void vehicles_gib_think(entity this)
  {
        this.alpha -= 0.1;
@@@ -303,7 -293,7 +303,7 @@@ entity vehicle_tossgib(entity this, ent
        {
                setthink(_gib, vehicles_gib_explode);
                _gib.nextthink = time + random() * _explode;
 -              settouch(_gib, vehicles_gib_explode);
 +              settouch(_gib, vehicles_gib_touch);
        }
        else
        {
@@@ -827,21 -817,21 +827,21 @@@ void vehicles_exit(entity vehic, bool e
        vehicles_exit_running = false;
  }
  
 -void vehicles_touch(entity this)
 +void vehicles_touch(entity this, entity toucher)
  {
 -      if(MUTATOR_CALLHOOK(VehicleTouch, this, other))
 +      if(MUTATOR_CALLHOOK(VehicleTouch, this, toucher))
                return;
  
        // Vehicle currently in use
        if(this.owner)
        {
                if(!forbidWeaponUse(this.owner))
 -              if(other != NULL)
 -              if((this.origin_z + this.maxs_z) > (other.origin_z))
 -              if(vehicles_crushable(other))
 +              if(toucher != NULL)
 +              if((this.origin_z + this.maxs_z) > (toucher.origin_z))
 +              if(vehicles_crushable(toucher))
                {
                        if(vdist(this.velocity, >=, 30))
 -                              Damage(other, this, this.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, '0 0 0', normalize(other.origin - this.origin) * autocvar_g_vehicles_crush_force);
 +                              Damage(toucher, this, this.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, '0 0 0', normalize(toucher.origin - this.origin) * autocvar_g_vehicles_crush_force);
  
                        return; // Dont do selfdamage when hitting "soft targets".
                }
        if(autocvar_g_vehicles_enter)
                return;
  
 -      vehicles_enter(other, this);
 +      vehicles_enter(toucher, this);
  }
  
  bool vehicle_impulse(entity this, int imp)
@@@ -894,7 -884,7 +894,7 @@@ void vehicles_enter(entity pl, entity v
  
        if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO)
        if(veh.vehicle_flags & VHF_MULTISLOT)
-       if(veh.owner)
+       if(veh.owner && SAME_TEAM(pl, veh))
        {
                if(!veh.gunner1)
                if(time >= veh.gun1.phase)