]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/qc_physics_prehax
authorMario <zacjardine@y7mail.com>
Mon, 16 Mar 2015 14:00:45 +0000 (01:00 +1100)
committerMario <zacjardine@y7mail.com>
Mon, 16 Mar 2015 14:00:45 +0000 (01:00 +1100)
1  2 
qcsrc/client/effects.qc
qcsrc/common/triggers/func/breakable.qc
qcsrc/common/triggers/target/spawn.qc
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc

diff --combined qcsrc/client/effects.qc
index e9bce8f979df565549bf00c2e4955852ffc8cf95,95623505b83e297d2a7e63e12a4f78e378838d5b..0cc1e20f6c2c7d7836874ac3945bffd913ce2539
@@@ -12,6 -12,9 +12,6 @@@
  .string fx_texture;
  .float  fx_lifetime;
  
 -void SUB_Remove()
 -{ remove(self); }
 -
  void b_draw()
  {
      //Draw_CylindricLine(self.fx_start, self.fx_end, self.fx_with, self.fx_texture, 0, time * 3, '1 1 1', 0.7, DRAWFLAG_ADDITIVE, view_origin);
@@@ -43,7 -46,9 +43,9 @@@ void cl_effects_lightningarc(vector fro
      if(length < 1)
          return;
  
-     steps      = floor(length / seglength);
+     // Use at most 16 te_lightning1 segments, as these eat up beam list segments.
+     // TODO: Change this to R_BeginPolygon code, then we no longer have this limit.
+     steps      = min(16, floor(length / seglength));
      if(steps < 1)
      {
          te_lightning1(world,from,to);
@@@ -61,8 -66,9 +63,9 @@@
              dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
              pos = pos_l +  dirnew * steplength;
              te_lightning1(world,pos_l,pos);
-             if(random() < branchfactor)
-                 cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
+             // WTF endless recursion if branchfactor is 1.0 (possibly due to adding branchfactor_add). FIXME
+             // if(random() < branchfactor)
+             //     cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
  
              pos_l = pos;
          }
index 5ce34b5f471f68f531fccd2bbd96e96a77c98f81,0000000000000000000000000000000000000000..9c371b5d420ddd9e9c3c1deda7f13eb110de9de7
mode 100644,000000..100644
--- /dev/null
@@@ -1,289 -1,0 +1,315 @@@
-               self.model = "";
 +#ifdef SVQC
 +#include "../../../server/weapons/common.qh"
 +
 +.entity sprite;
 +
 +.float dmg;
 +.float dmg_edge;
 +.float dmg_radius;
 +.float dmg_force;
 +.float debrismovetype;
 +.float debrissolid;
 +.vector debrisvelocity;
 +.vector debrisvelocityjitter;
 +.vector debrisavelocityjitter;
 +.float debristime;
 +.float debristimejitter;
 +.float debrisfadetime;
 +.float debrisdamageforcescale;
 +.float debrisskin;
 +
 +.string mdl_dead; // or "" to hide when broken
 +.string debris; // space separated list of debris models
 +// other fields:
 +//   mdl = particle effect name
 +//   count = particle effect multiplier
 +//   targetname = target to trigger to unbreak the model
 +//   target = targets to trigger when broken
 +//   health = amount of damage it can take
 +//   spawnflags:
 +//     1 = start disabled (needs to be triggered to activate)
 +//     2 = indicate damage
 +// notes:
 +//   for mdl_dead to work, origin must be set (using a common/origin brush).
 +//   Otherwise mdl_dead will be displayed at the map origin, and nobody would
 +//   want that!
 +
 +void func_breakable_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force);
 +
 +//
 +// func_breakable
 +// - basically func_assault_destructible for general gameplay use
 +//
 +void LaunchDebris (string debrisname, vector force)
 +{
 +      entity dbr = spawn();
 +      setorigin(dbr, self.absmin
 +                 + '1 0 0' * random() * (self.absmax.x - self.absmin.x)
 +                 + '0 1 0' * random() * (self.absmax.y - self.absmin.y)
 +                 + '0 0 1' * random() * (self.absmax.z - self.absmin.z));
 +      setmodel (dbr, debrisname );
 +      dbr.skin = self.debrisskin;
 +      dbr.colormap = self.colormap; // inherit team colors
 +      dbr.owner = self; // do not be affected by our own explosion
 +      dbr.movetype = self.debrismovetype;
 +      dbr.solid = self.debrissolid;
 +      if(dbr.solid != SOLID_BSP) // SOLID_BSP has exact collision, MAYBE this works? TODO check this out
 +              setsize(dbr, '0 0 0', '0 0 0'); // needed for performance, until engine can deal better with it
 +      dbr.velocity_x = self.debrisvelocity.x + self.debrisvelocityjitter.x * crandom();
 +      dbr.velocity_y = self.debrisvelocity.y + self.debrisvelocityjitter.y * crandom();
 +      dbr.velocity_z = self.debrisvelocity.z + self.debrisvelocityjitter.z * crandom();
 +      self.velocity = self.velocity + force * self.debrisdamageforcescale;
 +      dbr.avelocity_x = random()*self.debrisavelocityjitter.x;
 +      dbr.avelocity_y = random()*self.debrisavelocityjitter.y;
 +      dbr.avelocity_z = random()*self.debrisavelocityjitter.z;
 +      dbr.damageforcescale = self.debrisdamageforcescale;
 +      if(dbr.damageforcescale)
 +              dbr.takedamage = DAMAGE_YES;
 +      SUB_SetFade(dbr, time + self.debristime + crandom() * self.debristimejitter, self.debrisfadetime);
 +}
 +
 +void func_breakable_colormod()
 +{
 +      float h;
 +      if (!(self.spawnflags & 2))
 +              return;
 +      h = self.health / self.max_health;
 +      if(h < 0.25)
 +              self.colormod = '1 0 0';
 +      else if(h <= 0.75)
 +              self.colormod = '1 0 0' + '0 1 0' * (2 * h - 0.5);
 +      else
 +              self.colormod = '1 1 1';
 +
 +      CSQCMODEL_AUTOUPDATE();
 +}
 +
 +void func_breakable_look_destroyed()
 +{
 +      float floorZ;
 +
 +      if(self.solid == SOLID_BSP) // in case a misc_follow moved me, save the current origin first
 +              self.dropped_origin = self.origin;
 +
 +      if(self.mdl_dead == "")
++              self.effects |= EF_NODRAW;
 +      else {
 +              if (self.origin == '0 0 0')     {       // probably no origin brush, so don't spawn in the middle of the map..
 +                      floorZ = self.absmin.z;
 +                      setorigin(self,((self.absmax+self.absmin)*.5));
 +                      self.origin_z = floorZ;
 +              }
 +              setmodel(self, self.mdl_dead);
++              self.effects &= ~EF_NODRAW;
 +      }
 +
++      CSQCMODEL_AUTOUPDATE();
++
 +      self.solid = SOLID_NOT;
 +}
 +
 +void func_breakable_look_restore()
 +{
 +      setmodel(self, self.mdl);
++      self.effects &= ~EF_NODRAW;
++
 +      if(self.mdl_dead != "") // only do this if we use mdl_dead, to behave better with misc_follow
 +              setorigin(self, self.dropped_origin);
++
++      CSQCMODEL_AUTOUPDATE();
++
 +      self.solid = SOLID_BSP;
 +}
 +
 +void func_breakable_behave_destroyed()
 +{
 +      self.health = self.max_health;
 +      self.takedamage = DAMAGE_NO;
 +      self.bot_attack = false;
 +      self.event_damage = func_null;
 +      self.state = 1;
 +      func_breakable_colormod();
++      if (self.noise1)
++              stopsound (self, CH_TRIGGER_SINGLE);
 +}
 +
 +void func_breakable_behave_restore()
 +{
 +      self.health = self.max_health;
 +      if(self.sprite)
 +      {
 +              WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
 +              WaypointSprite_UpdateHealth(self.sprite, self.health);
 +      }
 +      self.takedamage = DAMAGE_AIM;
 +      self.bot_attack = true;
 +      self.event_damage = func_breakable_damage;
 +      self.state = 0;
 +      self.nextthink = 0; // cancel auto respawn
 +      func_breakable_colormod();
++      if (self.noise1)
++              sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
++}
++
++void func_breakable_init_for_player(entity player)
++{
++      if (self.noise1 && self.state == 0 && clienttype(player) == CLIENTTYPE_REAL)
++      {
++              msg_entity = player;
++              soundto (MSG_ONE, self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
++      }
 +}
 +
 +void func_breakable_destroyed()
 +{
 +      func_breakable_look_destroyed();
 +      func_breakable_behave_destroyed();
 +
 +      CSQCMODEL_AUTOUPDATE();
 +}
 +
 +void func_breakable_restore()
 +{
 +      func_breakable_look_restore();
 +      func_breakable_behave_restore();
 +
 +      CSQCMODEL_AUTOUPDATE();
 +}
 +
 +vector debrisforce; // global, set before calling this
 +void func_breakable_destroy() {
 +      float n, i;
 +      string oldmsg;
 +
 +      activator = self.owner;
 +      self.owner = world; // set by W_PrepareExplosionByDamage
 +
 +      // now throw around the debris
 +      n = tokenize_console(self.debris);
 +      for(i = 0; i < n; ++i)
 +              LaunchDebris(argv(i), debrisforce);
 +
 +      func_breakable_destroyed();
 +
 +      if(self.noise)
 +              sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
 +
 +      if(self.dmg)
 +              RadiusDamage(self, activator, self.dmg, self.dmg_edge, self.dmg_radius, self, world, self.dmg_force, DEATH_HURTTRIGGER, world);
 +
 +      if(self.cnt)
 +              pointparticles(self.cnt, self.absmin * 0.5 + self.absmax * 0.5, '0 0 0', self.count);
 +
 +      if(self.respawntime)
 +      {
 +              self.think = func_breakable_restore;
 +              self.nextthink = time + self.respawntime + crandom() * self.respawntimejitter;
 +      }
 +
 +      oldmsg = self.message;
 +      self.message = "";
 +      SUB_UseTargets();
 +      self.message = oldmsg;
 +}
 +
 +void func_breakable_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 +{
 +      if(self.state == 1)
 +              return;
 +      if(self.spawnflags & DOOR_NOSPLASH)
 +              if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
 +                      return;
 +      if(self.team)
 +              if(attacker.team == self.team)
 +                      return;
 +      self.health = self.health - damage;
 +      if(self.sprite)
 +      {
 +              WaypointSprite_Ping(self.sprite);
 +              WaypointSprite_UpdateHealth(self.sprite, self.health);
 +      }
 +      func_breakable_colormod();
 +
 +      if(self.health <= 0)
 +      {
 +              debrisforce = force;
 +              W_PrepareExplosionByDamage(attacker, func_breakable_destroy);
 +      }
 +}
 +
 +void func_breakable_reset()
 +{
 +      self.team = self.team_saved;
 +      func_breakable_look_restore();
 +      if(self.spawnflags & 1)
 +              func_breakable_behave_destroyed();
 +      else
 +              func_breakable_behave_restore();
 +
 +      CSQCMODEL_AUTOUPDATE();
 +}
 +
 +// destructible walls that can be used to trigger target_objective_decrease
 +void spawnfunc_func_breakable()
 +{
 +      float n, i;
 +      if(!self.health)
 +              self.health = 100;
 +      self.max_health = self.health;
 +
 +      // yes, I know, MOVETYPE_NONE is not available here, not that one would want it here anyway
 +      if(!self.debrismovetype) self.debrismovetype = MOVETYPE_BOUNCE;
 +      if(!self.debrissolid) self.debrissolid = SOLID_NOT;
 +      if(self.debrisvelocity == '0 0 0') self.debrisvelocity = '0 0 140';
 +      if(self.debrisvelocityjitter == '0 0 0') self.debrisvelocityjitter = '70 70 70';
 +      if(self.debrisavelocityjitter == '0 0 0') self.debrisavelocityjitter = '600 600 600';
 +      if(!self.debristime) self.debristime = 3.5;
 +      if(!self.debristimejitter) self.debristime = 2.5;
 +
 +      if(self.mdl != "")
 +              self.cnt = particleeffectnum(self.mdl);
 +      if(self.count == 0)
 +              self.count = 1;
 +
 +      if(self.message == "")
 +              self.message = "got too close to an explosion";
 +      if(self.message2 == "")
 +              self.message2 = "was pushed into an explosion by";
 +      if(!self.dmg_radius)
 +              self.dmg_radius = 150;
 +      if(!self.dmg_force)
 +              self.dmg_force = 200;
 +
 +      self.mdl = self.model;
 +      SetBrushEntityModel();
 +
 +      self.use = func_breakable_restore;
 +
 +      // precache all the models
 +      if (self.mdl_dead)
 +              precache_model(self.mdl_dead);
 +      n = tokenize_console(self.debris);
 +      for(i = 0; i < n; ++i)
 +              precache_model(argv(i));
 +      if(self.noise)
 +              precache_sound(self.noise);
++      if(self.noise1)
++              precache_sound(self.noise1);
 +
 +      self.team_saved = self.team;
 +      self.dropped_origin = self.origin;
 +
 +      self.reset = func_breakable_reset;
 +      func_breakable_reset();
 +
++      self.init_for_player_needed = 1;
++      self.init_for_player = func_breakable_init_for_player;
++
 +      CSQCMODEL_AUTOINIT();
 +}
 +
 +// for use in maps with a "model" key set
 +void spawnfunc_misc_breakablemodel() {
 +      spawnfunc_func_breakable();
 +}
 +#endif
index 98a3209cc546e18af722de4799d41e5c831a71bc,0000000000000000000000000000000000000000..7b183553da1a8adc4c293d188c929886e9798ca1
mode 100644,000000..100644
--- /dev/null
@@@ -1,347 -1,0 +1,350 @@@
 +#if defined(CSQC)
 +#elif defined(MENUQC)
 +#elif defined(SVQC)
 +      #include "../../../dpdefs/progsdefs.qh"
 +    #include "../../../dpdefs/dpextensions.qh"
 +    #include "../../util.qh"
 +    #include "../../../server/defs.qh"
 +#endif
 +
 +#ifdef SVQC
 +
 +// spawner entity
 +// "classname" "target_spawn"
 +// "message" "fieldname value fieldname value ..."
 +// "spawnflags"
 +//   1 = call the spawn function
 +//   2 = trigger on map load
 +
 +float target_spawn_initialized;
 +.void() target_spawn_spawnfunc;
 +float target_spawn_spawnfunc_field;
 +.entity target_spawn_activator;
 +.float target_spawn_id;
 +float target_spawn_count;
 +
 +void target_spawn_helper_setmodel()
 +{
 +      setmodel(self, self.model);
 +}
 +
 +void target_spawn_helper_setsize()
 +{
 +      setsize(self, self.mins, self.maxs);
 +}
 +
 +void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity t3, entity t4, entity act)
 +{
 +      float i, n, valuefieldpos;
 +      string key, value, valuefield, valueoffset, valueoffsetrandom;
 +      entity valueent;
 +      vector data, data2;
 +      entity oldself;
 +      entity oldactivator;
 +
 +      n = tokenize_console(msg);
 +
 +      for(i = 0; i < n-1; i += 2)
 +      {
 +              key = argv(i);
 +              value = argv(i+1);
 +              if(key == "$")
 +              {
 +                      data.x = -1;
 +                      data.y = FIELD_STRING;
 +              }
 +              else
 +              {
 +                      data = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", key)));
 +                      if(data.y == 0) // undefined field, i.e., invalid type
 +                      {
 +                              print("target_spawn: invalid/unknown entity key ", key, " specified, ignored!\n");
 +                              continue;
 +                      }
 +              }
 +              if(substring(value, 0, 1) == "$")
 +              {
 +                      value = substring(value, 1, strlen(value) - 1);
 +                      if(substring(value, 0, 1) == "$")
 +                      {
 +                              // deferred replacement
 +                              // do nothing
 +                              // useful for creating target_spawns with this!
 +                      }
 +                      else
 +                      {
 +                              // replace me!
 +                              valuefieldpos = strstrofs(value, "+", 0);
 +                              valueoffset = "";
 +                              if(valuefieldpos != -1)
 +                              {
 +                                      valueoffset = substring(value, valuefieldpos + 1, strlen(value) - valuefieldpos - 1);
 +                                      value = substring(value, 0, valuefieldpos);
 +                              }
 +
 +                              valuefieldpos = strstrofs(valueoffset, "+", 0);
 +                              valueoffsetrandom = "";
 +                              if(valuefieldpos != -1)
 +                              {
 +                                      valueoffsetrandom = substring(valueoffset, valuefieldpos + 1, strlen(valueoffset) - valuefieldpos - 1);
 +                                      valueoffset = substring(valueoffset, 0, valuefieldpos);
 +                              }
 +
 +                              valuefieldpos = strstrofs(value, ".", 0);
 +                              valuefield = "";
 +                              if(valuefieldpos != -1)
 +                              {
 +                                      valuefield = substring(value, valuefieldpos + 1, strlen(value) - valuefieldpos - 1);
 +                                      value = substring(value, 0, valuefieldpos);
 +                              }
 +
 +                              if(value == "self")
 +                              {
 +                                      valueent = self;
 +                                      value = "";
 +                              }
 +                              else if(value == "activator")
 +                              {
 +                                      valueent = act;
 +                                      value = "";
 +                              }
 +                              else if(value == "other")
 +                              {
 +                                      valueent = other;
 +                                      value = "";
 +                              }
 +                              else if(value == "pusher")
 +                              {
 +                                      if(time < act.pushltime)
 +                                              valueent = act.pusher;
 +                                      else
 +                                              valueent = world;
 +                                      value = "";
 +                              }
 +                              else if(value == "target")
 +                              {
 +                                      valueent = e;
 +                                      value = "";
 +                              }
 +                              else if(value == "killtarget")
 +                              {
 +                                      valueent = kt;
 +                                      value = "";
 +                              }
 +                              else if(value == "target2")
 +                              {
 +                                      valueent = t2;
 +                                      value = "";
 +                              }
 +                              else if(value == "target3")
 +                              {
 +                                      valueent = t3;
 +                                      value = "";
 +                              }
 +                              else if(value == "target4")
 +                              {
 +                                      valueent = t4;
 +                                      value = "";
 +                              }
 +                              else if(value == "time")
 +                              {
 +                                      valueent = world;
 +                                      value = ftos(time);
 +                              }
 +                              else
 +                              {
 +                                      print("target_spawn: invalid/unknown variable replacement ", value, " specified, ignored!\n");
 +                                      continue;
 +                              }
 +
 +                              if(valuefield == "")
 +                              {
 +                                      if(value == "")
 +                                              value = ftos(num_for_edict(valueent));
 +                              }
 +                              else
 +                              {
 +                                      if(value != "")
 +                                      {
 +                                              print("target_spawn: try to get a field of a non-entity, ignored!\n");
 +                                              continue;
 +                                      }
 +                                      data2 = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", valuefield)));
 +                                      if(data2_y == 0) // undefined field, i.e., invalid type
 +                                      {
 +                                              print("target_spawn: invalid/unknown entity key replacement ", valuefield, " specified, ignored!\n");
 +                                              continue;
 +                                      }
 +                                      value = getentityfieldstring(data2_x, valueent);
 +                              }
 +
 +                              if(valueoffset != "")
 +                              {
 +                                      switch(data.y)
 +                                      {
 +                                              case FIELD_STRING:
 +                                                      value = strcat(value, valueoffset);
 +                                                      break;
 +                                              case FIELD_FLOAT:
 +                                                      value = ftos(stof(value) + stof(valueoffset));
 +                                                      break;
 +                                              case FIELD_VECTOR:
 +                                                      value = vtos(stov(value) + stov(valueoffset));
 +                                                      break;
 +                                              default:
 +                                                      print("target_spawn: only string, float and vector fields can do calculations, calculation ignored!\n");
 +                                                      break;
 +                                      }
 +                              }
 +
 +                              if(valueoffsetrandom != "")
 +                              {
 +                                      switch(data.y)
 +                                      {
 +                                              case FIELD_FLOAT:
 +                                                      value = ftos(stof(value) + random() * stof(valueoffsetrandom));
 +                                                      break;
 +                                              case FIELD_VECTOR:
 +                                                      data2 = stov(valueoffsetrandom);
 +                                                      value = vtos(stov(value) + random() * data2_x * '1 0 0' + random() * data2_y * '0 1 0' + random() * data2_z * '0 0 1');
 +                                                      break;
 +                                              default:
 +                                                      print("target_spawn: only float and vector fields can do random calculations, calculation ignored!\n");
 +                                                      break;
 +                                      }
 +                              }
 +                      }
 +              }
 +              if(key == "$")
 +              {
 +                      if(substring(value, 0, 1) == "_")
 +                              value = strcat("target_spawn_helper", value);
 +                      putentityfieldstring(target_spawn_spawnfunc_field, e, value);
 +
 +                      oldself = self;
 +                      oldactivator = activator;
 +
 +                      self = e;
 +                      activator = act;
 +
 +                      self.target_spawn_spawnfunc();
 +
 +                      self = oldself;
 +                      activator = oldactivator;
++
++                      // We called an external function, so we have to re-tokenize msg.
++                      n = tokenize_console(msg);
 +              }
 +              else
 +              {
 +                      if(data.y == FIELD_VECTOR)
 +                              value = strreplace("'", "", value); // why?!?
 +                      putentityfieldstring(data.x, e, value);
 +              }
 +      }
 +}
 +
 +void target_spawn_useon(entity e)
 +{
 +      self.target_spawn_activator = activator;
 +      target_spawn_edit_entity(
 +              e,
 +              self.message,
 +              find(world, targetname, self.killtarget),
 +              find(world, targetname, self.target2),
 +              find(world, targetname, self.target3),
 +              find(world, targetname, self.target4),
 +              activator
 +      );
 +}
 +
 +float target_spawn_cancreate()
 +{
 +      float c;
 +      entity e;
 +
 +      c = self.count;
 +      if(c == 0) // no limit?
 +              return 1;
 +
 +      ++c; // increase count to not include MYSELF
 +      for(e = world; (e = findfloat(e, target_spawn_id, self.target_spawn_id)); --c)
 +              ;
 +
 +      // if c now is 0, we have AT LEAST the given count (maybe more), so don't spawn any more
 +      if(c == 0)
 +              return 0;
 +      return 1;
 +}
 +
 +void target_spawn_use()
 +{
 +      entity e;
 +
 +      if(self.target == "")
 +      {
 +              // spawn new entity
 +              if(!target_spawn_cancreate())
 +                      return;
 +              e = spawn();
 +              target_spawn_useon(e);
 +              e.target_spawn_id = self.target_spawn_id;
 +      }
 +      else if(self.target == "*activator")
 +      {
 +              // edit entity
 +              if(activator)
 +                      target_spawn_useon(activator);
 +      }
 +      else
 +      {
 +              // edit entity
 +              for(e = world; (e = find(e, targetname, self.target)); )
 +                      target_spawn_useon(e);
 +      }
 +}
 +
 +void target_spawn_spawnfirst()
 +{
 +      activator = self.target_spawn_activator;
 +      if(self.spawnflags & 2)
 +              target_spawn_use();
 +}
 +
 +void initialize_field_db()
 +{
 +      if(!target_spawn_initialized)
 +      {
 +              float n, i;
 +              string fn;
 +              vector prev, new;
 +              float ft;
 +
 +              n = numentityfields();
 +              for(i = 0; i < n; ++i)
 +              {
 +                      fn = entityfieldname(i);
 +                      ft = entityfieldtype(i);
 +                      new = i * '1 0 0' + ft * '0 1 0' + '0 0 1';
 +                      prev = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", fn)));
 +                      if(prev.y == 0)
 +                      {
 +                              db_put(TemporaryDB, strcat("/target_spawn/field/", fn), vtos(new));
 +                              if(fn == "target_spawn_spawnfunc")
 +                                      target_spawn_spawnfunc_field = i;
 +                      }
 +              }
 +
 +              target_spawn_initialized = 1;
 +      }
 +}
 +
 +void spawnfunc_target_spawn()
 +{
 +      initialize_field_db();
 +      self.use = target_spawn_use;
 +      self.message = strzone(strreplace("'", "\"", self.message));
 +      self.target_spawn_id = ++target_spawn_count;
 +      InitializeEntity(self, target_spawn_spawnfirst, INITPRIO_LAST);
 +}
 +#endif
index 424abc33beab48906baaa4893a79f7d76f2651f5,3bc5cc762f231b2e92f8df7dfdfe4b05e9d55bb1..a49268d194fb872826ca878f575612f796ed5931
@@@ -9,6 -9,7 +9,6 @@@
  #include "portals.qh"
  #include "teamplay.qh"
  #include "playerdemo.qh"
 -#include "secret.qh"
  
  #include "bot/bot.qh"
  #include "bot/navigation.qh"
  #include "weapons/weaponsystem.qh"
  
  #include "../common/net_notice.qh"
 +#include "../common/physics.qh"
 +
 +#include "../common/triggers/subs.qh"
 +#include "../common/triggers/triggers.qh"
 +#include "../common/triggers/trigger/secret.qh"
  
  #include "../common/monsters/sv_monsters.qh"
  
@@@ -1253,6 -1249,13 +1253,13 @@@ void ClientConnect (void
        if(IS_REAL_CLIENT(self))
                sv_notice_join();
  
+       for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
+               entity oldself = self;
+               self = e;
+               e.init_for_player(oldself);
+               self = oldself;
+       }
        MUTATOR_CALLHOOK(ClientConnect);
  }
  /*
@@@ -1658,17 -1661,55 +1665,17 @@@ void SetZoomState(float z
  
  void GetPressedKeys(void) {
        MUTATOR_CALLHOOK(GetPressedKeys);
 -      if (self.movement.x > 0) // get if movement keys are pressed
 -      {       // forward key pressed
 -              self.pressedkeys |= KEY_FORWARD;
 -              self.pressedkeys &= ~KEY_BACKWARD;
 -      }
 -      else if (self.movement.x < 0)
 -      {       // backward key pressed
 -              self.pressedkeys |= KEY_BACKWARD;
 -              self.pressedkeys &= ~KEY_FORWARD;
 -      }
 -      else
 -      {       // no x input
 -              self.pressedkeys &= ~KEY_FORWARD;
 -              self.pressedkeys &= ~KEY_BACKWARD;
 -      }
 -
 -      if (self.movement.y > 0)
 -      {       // right key pressed
 -              self.pressedkeys |= KEY_RIGHT;
 -              self.pressedkeys &= ~KEY_LEFT;
 -      }
 -      else if (self.movement.y < 0)
 -      {       // left key pressed
 -              self.pressedkeys |= KEY_LEFT;
 -              self.pressedkeys &= ~KEY_RIGHT;
 -      }
 -      else
 -      {       // no y input
 -              self.pressedkeys &= ~KEY_RIGHT;
 -              self.pressedkeys &= ~KEY_LEFT;
 -      }
 -
 -      if (self.BUTTON_JUMP) // get if jump and crouch keys are pressed
 -              self.pressedkeys |= KEY_JUMP;
 -      else
 -              self.pressedkeys &= ~KEY_JUMP;
 -      if (self.BUTTON_CROUCH)
 -              self.pressedkeys |= KEY_CROUCH;
 -      else
 -              self.pressedkeys &= ~KEY_CROUCH;
 -
 -      if (self.BUTTON_ATCK)
 -              self.pressedkeys |= KEY_ATCK;
 -      else
 -              self.pressedkeys &= ~KEY_ATCK;
 -      if (self.BUTTON_ATCK2)
 -              self.pressedkeys |= KEY_ATCK2;
 -      else
 -              self.pressedkeys &= ~KEY_ATCK2;
 +      #define X(var,bit,flag) (flag ? var |= bit : var &= ~bit)
 +      X(self.pressedkeys, KEY_FORWARD,        PHYS_INPUT_MOVEVALUES(self)_x > 0);
 +      X(self.pressedkeys, KEY_BACKWARD,       PHYS_INPUT_MOVEVALUES(self)_x < 0);
 +      X(self.pressedkeys, KEY_RIGHT,          PHYS_INPUT_MOVEVALUES(self)_y > 0);
 +      X(self.pressedkeys, KEY_LEFT,           PHYS_INPUT_MOVEVALUES(self)_y < 0);
 +
 +      X(self.pressedkeys, KEY_JUMP,           PHYS_INPUT_BUTTON_JUMP(self));
 +      X(self.pressedkeys, KEY_CROUCH,         PHYS_INPUT_BUTTON_CROUCH(self));
 +      X(self.pressedkeys, KEY_ATCK,           PHYS_INPUT_BUTTON_ATCK(self));
 +      X(self.pressedkeys, KEY_ATCK2,          PHYS_INPUT_BUTTON_ATCK2(self));
 +      #undef X
  }
  
  /*
diff --combined qcsrc/server/defs.qh
index f27f503408a6b2b24a39c93f3db063dbc658072b,822c5163c384c1476656d825ab0a009f549ac406..c430029d0c31ce95513bf835599a425bb2f0c1ed
@@@ -46,6 -46,8 +46,6 @@@ float g_jetpack
  float sv_clones;
  float sv_foginterval;
  
 -entity        activator;
 -
  float player_count;
  float currentbots;
  float bots_would_leave;
@@@ -68,6 -70,21 +68,6 @@@ float server_is_dedicated
  //.string     map;
  
  //.float      worldtype;
 -.float        delay;
 -.float        wait;
 -.float        lip;
 -//.float      light_lev;
 -.float        speed;
 -//.float      style;
 -//.float      skill;
 -.float        sounds;
 -.string  platmovetype;
 -.float platmovetype_start, platmovetype_end;
 -
 -.string killtarget;
 -
 -.vector       pos1, pos2;
 -.vector       mangle;
  
  .float        pain_finished;                  //Added by Supajoe
  .float        pain_frame;                     //"
  .float        invincible_finished;
  .float        superweapons_finished;
  
 -.vector               finaldest, finalangle;          //plat.qc stuff
 -.void()               think1;
 -.float state;
 -.float                t_length, t_width;
 -
 -.vector destvec;              // for rain
 -.vector destvec2;             // for train
 -.float cnt;           // for rain
 +.float cnt; // used in too many places
  .float count;
  //.float cnt2;
  
  .float fade_time;
  .float fade_rate;
  
 -// player animation state
 -.float animstate_startframe;
 -.float animstate_numframes;
 -.float animstate_framerate;
 -.float animstate_starttime;
 -.float animstate_endtime;
 -.float animstate_override;
 -.float animstate_looping;
 -
  // weapon animation vectors:
  .vector anim_fire1;
  .vector anim_fire2;
@@@ -177,13 -210,26 +177,13 @@@ const int W_TICSPERFRAME = 2
  
  void weapon_defaultspawnfunc(float wpn);
  
 -.vector dest1, dest2;
 -
  float gameover;
  float intermission_running;
  float intermission_exittime;
  float alreadychangedlevel;
  
 -// Keys player is holding
 -.float itemkeys;
 -// message delay for func_door locked by keys and key locks
 -// this field is used on player entities
 -.float key_door_messagetime;
 -
 -
  .float version;
  
 -//swamp
 -.float in_swamp;              // bool
 -.entity swampslug;            // Uses this to release from swamp ("untouch" fix)
 -
  // footstep interval
  .float nextstep;
  
@@@ -238,6 -284,10 +238,6 @@@ float default_weapon_alpha
  
  .float version_nagtime;
  
 -const int NUM_JUMPPADSUSED = 3;
 -.float jumppadcount;
 -.entity jumppadsused[NUM_JUMPPADSUSED];
 -
  string gamemode_name;
  
  float startitem_failed;
@@@ -397,6 -447,11 +397,6 @@@ float round_starttime; //point in time 
  .float stat_game_starttime;
  .float stat_round_starttime;
  
 -.float stat_sv_airaccel_qw;
 -.float stat_sv_airstrafeaccel_qw;
 -.float stat_sv_airspeedlimit_nonqw;
 -.float stat_sv_maxspeed;
 -
  void W_Porto_Remove (entity p);
  
  .int projectiledeathtype;
  // may be useful to all weapons
  .float bulletcounter;
  
 -void target_voicescript_next(entity pl);
 -void target_voicescript_clear(entity pl);
 -
 -.string target2;
 -.string target3;
 -.string target4;
 -.string curvetarget;
 -.float target_random;
 -.float trigger_reverse;
 -
  // Nexball
  .entity ballcarried; // Also used for keepaway
  .float metertime;
@@@ -529,6 -594,8 +529,6 @@@ void PlayerUseKey()
  typedef vector(entity player, entity spot, vector current) spawn_evalfunc_t;
  .spawn_evalfunc_t spawn_evalfunc;
  
 -.entity conveyor;
 -
  string modname;
  
  .float missile_flags;
@@@ -556,4 -623,8 +556,8 @@@ const int MIF_GUIDED_TAG = 128
  .string playernick;
  .float elos;
  .float ranks;
+ .float init_for_player_needed;
+ .void(entity) init_for_player;
  #endif
diff --combined qcsrc/server/g_world.qc
index d1808d988d2e32bcb2fbdd8298bae5f62d6e53f8,04f8ff7b38afbf7551a2a162bf1153acc043c6cd..007644084a0ea27fe88c7b0f676b8f3b3bad6580
@@@ -32,6 -32,7 +32,6 @@@
      #include "ipban.qh"
      #include "race.qh"
      #include "antilag.qh"
 -    #include "secret.qh"
  #endif
  
  const float LATENCY_THINKRATE = 10;
@@@ -313,15 -314,21 +313,21 @@@ void cvar_changes_init(
                // does nothing visible
                BADCVAR("captureleadlimit_override");
                BADCVAR("g_balance_kill_delay");
+               BADCVAR("g_ca_point_limit");
                BADCVAR("g_ca_point_leadlimit");
                BADCVAR("g_ctf_captimerecord_always");
                BADCVAR("g_ctf_flag_glowtrails");
                BADCVAR("g_ctf_flag_pickup_verbosename");
                BADCVAR("g_domination_point_leadlimit");
                BADCVAR("g_forced_respawn");
+               BADCVAR("g_freezetag_point_limit");
+               BADCVAR("g_freezetag_point_leadlimit");
                BADCVAR("g_keyhunt_point_leadlimit");
                BADPREFIX("g_mod_");
+               BADCVAR("g_invasion_point_limit");
                BADCVAR("g_nexball_goalleadlimit");
+               BADCVAR("g_tdm_point_limit");
+               BADCVAR("g_tdm_point_leadlimit");
                BADCVAR("leadlimit_and_fraglimit");
                BADCVAR("leadlimit_override");
                BADCVAR("pausable");
@@@ -567,7 -574,6 +573,7 @@@ void Nagger_Init()
  void ClientInit_Spawn();
  void WeaponStats_Init();
  void WeaponStats_Shutdown();
 +void Physics_AddStats();
  void spawnfunc_worldspawn (void)
  {
        float fd, l, i, j, n;
        addstat(STAT_FROZEN, AS_INT, frozen);
        addstat(STAT_REVIVE_PROGRESS, AS_FLOAT, revive_progress);
  
 -      // g_movementspeed hack
 -      addstat(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW, AS_FLOAT, stat_sv_airspeedlimit_nonqw);
 -      addstat(STAT_MOVEVARS_MAXSPEED, AS_FLOAT, stat_sv_maxspeed);
 -      addstat(STAT_MOVEVARS_AIRACCEL_QW, AS_FLOAT, stat_sv_airaccel_qw);
 -      addstat(STAT_MOVEVARS_AIRSTRAFEACCEL_QW, AS_FLOAT, stat_sv_airstrafeaccel_qw);
 +      // physics
 +      Physics_AddStats();
  
        // secrets
        addstat(STAT_SECRETS_TOTAL, AS_FLOAT, stat_secrets_total);