+#include "../common/physics.qh"
+
#if defined(CSQC)
#include "../dpdefs/csprogsdefs.qh"
#include "defs.qh"
#include "../server/t_items.qh"
#elif defined(MENUQC)
#elif defined(SVQC)
+ #include "../server/autocvars.qh"
#endif
+#ifdef SVQC
+#define GRAVITY_UNAFFECTED_BY_TICRATE autocvar_sv_gameplayfix_gravityunaffectedbyticrate
+
+#define TICRATE sys_frametime
+#elif defined(CSQC)
#define GRAVITY_UNAFFECTED_BY_TICRATE (getstati(STAT_MOVEFLAGS) & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
+#define TICRATE ticrate
+#endif
+
.entity move_groundentity; // FIXME add move_groundnetworkentity?
.float move_suspendedinair;
.float move_didgravity;
if(GRAVITY_UNAFFECTED_BY_TICRATE)
{
if(self.gravity)
- self.move_velocity_z -= 0.5 * dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.move_velocity_z -= 0.5 * dt * self.gravity * PHYS_GRAVITY;
else
- self.move_velocity_z -= 0.5 * dt * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.move_velocity_z -= 0.5 * dt * PHYS_GRAVITY;
}
else
{
if(self.gravity)
- self.move_velocity_z -= dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.move_velocity_z -= dt * self.gravity * PHYS_GRAVITY;
else
- self.move_velocity_z -= dt * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.move_velocity_z -= dt * PHYS_GRAVITY;
}
}
bouncefac = self.move_bounce_factor; if(!bouncefac) bouncefac = 0.5;
bouncestop = self.move_bounce_stopspeed; if(!bouncestop) bouncestop = 60 / 800;
if(self.gravity)
- bouncestop *= self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+ bouncestop *= self.gravity * PHYS_GRAVITY;
else
- bouncestop *= getstatf(STAT_MOVEVARS_GRAVITY);
+ bouncestop *= PHYS_GRAVITY;
self.move_velocity = _Movetype_ClipVelocity(self.move_velocity, trace_plane_normal, 1 + bouncefac);
if(!(self.move_flags & FL_ONGROUND))
{
if(self.gravity)
- self.move_velocity_z -= 0.5 * dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.move_velocity_z -= 0.5 * dt * self.gravity * PHYS_GRAVITY;
else
- self.move_velocity_z -= 0.5 * dt * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.move_velocity_z -= 0.5 * dt * PHYS_GRAVITY;
}
_Movetype_CheckWaterTransition(self);
break;
case MOVETYPE_NOCLIP:
_Movetype_CheckWater(self);
- self.move_origin = self.move_origin + ticrate * self.move_velocity;
- self.move_angles = self.move_angles + ticrate * self.move_avelocity;
+ self.move_origin = self.move_origin + TICRATE * self.move_velocity;
+ self.move_angles = self.move_angles + TICRATE * self.move_avelocity;
_Movetype_LinkEdict(false);
break;
case MOVETYPE_STEP:
void Movetype_Physics_MatchServer(bool sloppy)
{
- Movetype_Physics_MatchTicrate(ticrate, sloppy);
+ Movetype_Physics_MatchTicrate(TICRATE, sloppy);
}
void Movetype_Physics_MatchTicrate(float tr, bool sloppy) // SV_Physics_Entity
if(GRAVITY_UNAFFECTED_BY_TICRATE)
{
if(self.gravity)
- self.velocity_z -= 0.5 * dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.velocity_z -= 0.5 * dt * self.gravity * PHYS_GRAVITY;
else
- self.velocity_z -= 0.5 * dt * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.velocity_z -= 0.5 * dt * PHYS_GRAVITY;
}
else
{
if(self.gravity)
- self.velocity_z -= dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.velocity_z -= dt * self.gravity * PHYS_GRAVITY;
else
- self.velocity_z -= dt * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.velocity_z -= dt * PHYS_GRAVITY;
}
}
if(GRAVITY_UNAFFECTED_BY_TICRATE)
{
if(self.gravity)
- self.velocity_z -= 0.5 * dt * self.gravity * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.velocity_z -= 0.5 * dt * self.gravity * PHYS_GRAVITY;
else
- self.velocity_z -= 0.5 * dt * getstatf(STAT_MOVEVARS_GRAVITY);
+ self.velocity_z -= 0.5 * dt * PHYS_GRAVITY;
}
}
}
-// ================================================================
-// Official capture the flag game mode coding, reworked by Samual
-// Last updated: September, 2012
-// ================================================================
+#include "../../client/movetypes.qh"
void ctf_FakeTimeLimit(entity e, float t)
{
if(current_height) // make sure we can actually do this arcing path
{
targpos = (to + ('0 0 1' * current_height));
- WarpZone_TraceLine(flag.origin, targpos, MOVE_NOMONSTERS, flag);
+ WarpZone_TraceLine(flag.move_origin, targpos, MOVE_NOMONSTERS, flag);
if(trace_fraction < 1)
{
//print("normal arc line failed, trying to find new pos...");
WarpZone_TraceLine(to, targpos, MOVE_NOMONSTERS, flag);
targpos = (trace_endpos + FLAG_PASS_ARC_OFFSET);
- WarpZone_TraceLine(flag.origin, targpos, MOVE_NOMONSTERS, flag);
+ WarpZone_TraceLine(flag.move_origin, targpos, MOVE_NOMONSTERS, flag);
if(trace_fraction < 1) { targpos = to; /* print(" ^1FAILURE^7, reverting to original direction.\n"); */ }
/*else { print(" ^3SUCCESS^7, using new arc line.\n"); } */
}
}
else { targpos = to; }
- //flag.angles = normalize(('0 1 0' * to_y) - ('0 1 0' * from_y));
+ //flag.move_angles = normalize(('0 1 0' * to_y) - ('0 1 0' * from_y));
vector desired_direction = normalize(targpos - from);
- if(turnrate) { flag.velocity = (normalize(normalize(flag.velocity) + (desired_direction * autocvar_g_ctf_pass_turnrate)) * autocvar_g_ctf_pass_velocity); }
- else { flag.velocity = (desired_direction * autocvar_g_ctf_pass_velocity); }
+ if(turnrate) { flag.move_velocity = (normalize(normalize(flag.move_velocity) + (desired_direction * autocvar_g_ctf_pass_turnrate)) * autocvar_g_ctf_pass_velocity); }
+ else { flag.move_velocity = (desired_direction * autocvar_g_ctf_pass_velocity); }
}
float ctf_CheckPassDirection(vector head_center, vector passer_center, vector passer_angle, vector nearest_to_passer)
player = (player ? player : flag.pass_sender);
// main
- flag.movetype = MOVETYPE_TOSS;
+ flag.move_movetype = MOVETYPE_TOSS;
flag.takedamage = DAMAGE_YES;
- flag.angles = '0 0 0';
+ flag.move_angles = '0 0 0';
flag.health = flag.max_flag_health;
flag.ctf_droptime = time;
flag.ctf_dropper = player;
if(player.vehicle)
{
setattachment(flag, player.vehicle, "");
- setorigin(flag, VEHICLE_FLAG_OFFSET);
+ flag.move_origin = VEHICLE_FLAG_OFFSET;
flag.scale = VEHICLE_FLAG_SCALE;
}
else
{
setattachment(flag, player, "");
- setorigin(flag, FLAG_CARRY_OFFSET);
+ flag.move_origin = VEHICLE_FLAG_OFFSET;
}
- flag.movetype = MOVETYPE_NONE;
+ flag.move_movetype = MOVETYPE_NONE;
flag.takedamage = DAMAGE_NO;
flag.solid = SOLID_NOT;
- flag.angles = '0 0 0';
+ flag.move_angles = '0 0 0';
flag.ctf_status = FLAG_CARRY;
// messages and sounds
// reset the flag
setattachment(flag, world, "");
- setorigin(flag, player.origin + FLAG_DROP_OFFSET);
+ flag.move_origin = player.origin + FLAG_DROP_OFFSET;
flag.owner.flagcarried = world;
flag.owner = world;
flag.solid = SOLID_TRIGGER;
flag.ctf_dropper = player;
flag.ctf_droptime = time;
- flag.flags = FL_ITEM | FL_NOTARGET; // clear FL_ONGROUND for MOVETYPE_TOSS
+ flag.move_flags = FL_ITEM | FL_NOTARGET; // clear FL_ONGROUND for MOVETYPE_TOSS
+ flag.flags = flag.move_flags;
switch(droptype)
{
ctf_CalculatePassVelocity(flag, targ_origin, player.origin, false);
// main
- flag.movetype = MOVETYPE_FLY;
+ flag.move_movetype = MOVETYPE_FLY;
flag.takedamage = DAMAGE_NO;
flag.pass_sender = player;
flag.pass_target = receiver;
makevectors((player.v_angle.y * '0 1 0') + (bound(autocvar_g_ctf_throw_angle_min, player.v_angle.x, autocvar_g_ctf_throw_angle_max) * '1 0 0'));
flag_velocity = (('0 0 1' * autocvar_g_ctf_throw_velocity_up) + ((v_forward * autocvar_g_ctf_throw_velocity_forward) * ((player.items & IT_STRENGTH) ? autocvar_g_ctf_throw_strengthmultiplier : 1)));
- flag.velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, false);
+ flag.move_velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, false);
ctf_Handle_Drop(flag, player, droptype);
break;
}
case DROP_RESET:
{
- flag.velocity = '0 0 0'; // do nothing
+ flag.move_velocity = '0 0 0'; // do nothing
break;
}
default:
case DROP_NORMAL:
{
- flag.velocity = W_CalculateProjectileVelocity(player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false);
+ flag.move_velocity = W_CalculateProjectileVelocity(player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false);
ctf_Handle_Drop(flag, player, droptype);
break;
}
PlayerScore_Add(player, SP_CTF_CAPTIME, new_time - old_time);
// effects
- pointparticles(particleeffectnum(flag.capeffect), flag.origin, '0 0 0', 1);
- //shockwave_spawn("models/ctf/shockwavetransring.md3", flag.origin - '0 0 15', -0.8, 0, 1);
+ pointparticles(particleeffectnum(flag.capeffect), flag.move_origin, '0 0 0', 1);
+ //shockwave_spawn("models/ctf/shockwavetransring.md3", flag.move_origin - '0 0 15', -0.8, 0, 1);
// other
if(capturetype == CAPTURE_NORMAL)
if(player.vehicle)
{
setattachment(flag, player.vehicle, "");
- setorigin(flag, VEHICLE_FLAG_OFFSET);
+ flag.move_origin = VEHICLE_FLAG_OFFSET;
flag.scale = VEHICLE_FLAG_SCALE;
}
else
{
setattachment(flag, player, "");
- setorigin(flag, FLAG_CARRY_OFFSET);
+ flag.move_origin = FLAG_CARRY_OFFSET;
}
// flag setup
- flag.movetype = MOVETYPE_NONE;
+ flag.move_movetype = MOVETYPE_NONE;
flag.takedamage = DAMAGE_NO;
flag.solid = SOLID_NOT;
- flag.angles = '0 0 0';
+ flag.move_angles = '0 0 0';
flag.ctf_status = FLAG_CARRY;
switch(pickuptype)
void ctf_FlagDamage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
{
+ self.move_velocity = self.velocity;
if(ITEM_DAMAGE_NEEDKILL(deathtype))
{
// automatically kill the flag and return it
}
}
-void ctf_FlagThink()
+void ctf_FlagUpdate()
{
// declarations
entity tmp_entity;
- self.nextthink = time + FLAG_THINKRATE; // only 5 fps, more is unnecessary.
-
// captureshield
if(self == ctf_worldflaglist) // only for the first flag
FOR_EACH_CLIENT(tmp_entity)
// sanity checks
if(self.mins != FLAG_MIN || self.maxs != FLAG_MAX) { // reset the flag boundaries in case it got squished
dprint("wtf the flag got squashed?\n");
- tracebox(self.origin, FLAG_MIN, FLAG_MAX, self.origin, MOVE_NOMONSTERS, self);
+ tracebox(self.move_origin, FLAG_MIN, FLAG_MAX, self.move_origin, MOVE_NOMONSTERS, self);
if(!trace_startsolid || self.noalign) // can we resize it without getting stuck?
setsize(self, FLAG_MIN, FLAG_MAX); }
{
case FLAG_DROPPED:
{
- self.angles = '0 0 0';
+ self.move_angles = '0 0 0';
break;
}
{
for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
if(tmp_entity.ctf_status == FLAG_DROPPED)
- if(vlen(self.origin - tmp_entity.origin) < autocvar_g_ctf_dropped_capture_radius)
+ if(vlen(self.move_origin - tmp_entity.move_origin) < autocvar_g_ctf_dropped_capture_radius)
if(time > tmp_entity.ctf_droptime + autocvar_g_ctf_dropped_capture_delay)
ctf_Handle_Capture(self, tmp_entity, CAPTURE_DROPPED);
}
vector midpoint = ((self.absmin + self.absmax) * 0.5);
if(pointcontents(midpoint) == CONTENT_WATER)
{
- self.velocity = self.velocity * 0.5;
+ self.move_velocity = self.move_velocity * 0.5;
if(pointcontents(midpoint + FLAG_FLOAT_OFFSET) == CONTENT_WATER)
- { self.velocity_z = autocvar_g_ctf_flag_dropped_floatinwater; }
+ { self.move_velocity_z = autocvar_g_ctf_flag_dropped_floatinwater; }
else
- { self.movetype = MOVETYPE_FLY; }
+ { self.move_movetype = MOVETYPE_FLY; }
}
- else if(self.movetype == MOVETYPE_FLY) { self.movetype = MOVETYPE_TOSS; }
+ else if(self.move_movetype == MOVETYPE_FLY) { self.move_movetype = MOVETYPE_TOSS; }
}
if(autocvar_g_ctf_flag_return_dropped)
{
- if((vlen(self.origin - self.ctf_spawnorigin) <= autocvar_g_ctf_flag_return_dropped) || (autocvar_g_ctf_flag_return_dropped == -1))
+ if((vlen(self.move_origin - self.ctf_spawnorigin) <= autocvar_g_ctf_flag_return_dropped) || (autocvar_g_ctf_flag_return_dropped == -1))
{
self.health = 0;
ctf_CheckFlagReturn(self, RETURN_DROPPED);
{
vector targ_origin = ((self.pass_target.absmin + self.pass_target.absmax) * 0.5);
targ_origin = WarpZone_RefSys_TransformOrigin(self.pass_target, self, targ_origin); // origin of target as seen by the flag (us)
- WarpZone_TraceLine(self.origin, targ_origin, MOVE_NOMONSTERS, self);
+ WarpZone_TraceLine(self.move_origin, targ_origin, MOVE_NOMONSTERS, self);
if((self.pass_target == world)
|| (self.pass_target.deadflag != DEAD_NO)
|| (self.pass_target.flagcarried)
- || (vlen(self.origin - targ_origin) > autocvar_g_ctf_pass_radius)
+ || (vlen(self.move_origin - targ_origin) > autocvar_g_ctf_pass_radius)
|| ((trace_fraction < 1) && (trace_ent != self.pass_target))
|| (time > self.ctf_droptime + autocvar_g_ctf_pass_timelimit))
{
else
{
// still a viable target, go for it
- ctf_CalculatePassVelocity(self, targ_origin, self.origin, true);
+ ctf_CalculatePassVelocity(self, targ_origin, self.move_origin, true);
}
return;
}
}
}
+void ctf_FlagThink()
+{
+ self.nextthink = time;
+
+ if(time >= self.ctf_thinkrate)
+ {
+ self.ctf_thinkrate = time + FLAG_THINKRATE;
+ ctf_FlagUpdate();
+ }
+
+ //Movetype_Physics_NoMatchServer();
+ Movetype_Physics_MatchTicrate(sys_frametime, 0);
+}
+
void ctf_FlagTouch()
{
if(gameover) { return; }
{
if(time > self.wait) // if we haven't in a while, play a sound/effect
{
- pointparticles(particleeffectnum(self.toucheffect), self.origin, '0 0 0', 1);
+ pointparticles(particleeffectnum(self.toucheffect), self.move_origin, '0 0 0', 1);
sound(self, CH_TRIGGER, self.snd_flag_touch, VOL_BASE, ATTEN_NORM);
self.wait = time + FLAG_TOUCHRATE;
}
// reset the flag
setattachment(flag, world, "");
- setorigin(flag, flag.ctf_spawnorigin);
+ flag.move_origin = flag.ctf_spawnorigin;
- flag.movetype = ((flag.noalign) ? MOVETYPE_NONE : MOVETYPE_TOSS);
+ flag.move_movetype = ((flag.noalign) ? MOVETYPE_NONE : MOVETYPE_TOSS);
flag.takedamage = DAMAGE_NO;
flag.health = flag.max_flag_health;
flag.solid = SOLID_TRIGGER;
- flag.velocity = '0 0 0';
- flag.angles = flag.mangle;
- flag.flags = FL_ITEM | FL_NOTARGET;
+ flag.move_velocity = '0 0 0';
+ flag.move_angles = flag.mangle;
+ flag.move_flags = FL_ITEM | FL_NOTARGET;
+ flag.flags = flag.move_flags;
flag.ctf_status = FLAG_BASE;
flag.owner = world;
self.bot_basewaypoint = self.nearestwaypoint;
// waypointsprites
+ // move_origin isnt accessible just yet
WaypointSprite_SpawnFixed(((self.team == NUM_TEAM_1) ? "redbase" : "bluebase"), self.origin + FLAG_WAYPOINT_OFFSET, self, wps_flagbase, RADARICON_FLAG, colormapPaletteColor(self.team - 1, false));
WaypointSprite_UpdateTeamRadar(self.wps_flagbase, RADARICON_FLAG, colormapPaletteColor(self.team - 1, false));
// captureshield setup
ctf_CaptureShield_Spawn(self);
+
+ self.move_origin = self.origin;
+ self.move_angles = self.angles;
+ self.move_velocity = self.velocity;
}
void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
flag.items = ((teamnumber) ? IT_KEY2 : IT_KEY1); // IT_KEY2: gold key (redish enough) - IT_KEY1: silver key (bluish enough)
flag.classname = "item_flag_team";
flag.target = "###item###"; // wut?
- flag.flags = FL_ITEM | FL_NOTARGET;
+ flag.move_flags = FL_ITEM | FL_NOTARGET;
+ flag.flags = flag.move_flags;
flag.solid = SOLID_TRIGGER;
flag.takedamage = DAMAGE_NO;
flag.damageforcescale = autocvar_g_ctf_flag_damageforcescale;
flag.teleportable = TELEPORT_NORMAL;
flag.damagedbytriggers = autocvar_g_ctf_flag_return_when_unreachable;
flag.damagedbycontents = autocvar_g_ctf_flag_return_when_unreachable;
- flag.velocity = '0 0 0';
+ flag.move_velocity = '0 0 0';
flag.mangle = flag.angles;
flag.reset = ctf_Reset;
flag.touch = ctf_FlagTouch;
+ flag.move_touch = flag.touch;
flag.think = ctf_FlagThink;
flag.nextthink = time + FLAG_THINKRATE;
flag.ctf_status = FLAG_BASE;
+ flag.move_time = time;
// appearence
if(flag.model == "") { flag.model = ((teamnumber) ? autocvar_g_ctf_flag_red_model : autocvar_g_ctf_flag_blue_model); }
{
flag.dropped_origin = flag.origin;
flag.noalign = true;
- flag.movetype = MOVETYPE_NONE;
+ flag.move_movetype = MOVETYPE_NONE;
}
else // drop to floor, automatically find a platform and set that as spawn origin
{
flag.noalign = false;
self = flag;
droptofloor();
- flag.movetype = MOVETYPE_TOSS;
+ flag.move_movetype = MOVETYPE_TOSS;
}
InitializeEntity(flag, ctf_DelayedFlagSetup, INITPRIO_SETLOCATION);
f = ctf_worldflaglist;
while (f)
{
- fo = f.origin;
+ fo = f.move_origin;
s = s + fo;
f = f.ctf_worldflagnext;
}
{
if(df_radius)
{
- if(vlen(org-head.origin)<df_radius)
+ if(vlen(org-head.move_origin)<df_radius)
navigation_routerating(head, ratingscale, 10000);
}
else
// If the flag carrier reached the base switch to defense
mf = havocbot_ctf_find_flag(self);
if(mf.ctf_status!=FLAG_BASE)
- if(vlen(ef.origin - mf.dropped_origin) < 300)
+ if(vlen(ef.move_origin - mf.dropped_origin) < 300)
{
havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_DEFENSE);
return;
if(mf.tag_entity)
pos = mf.tag_entity.origin;
else
- pos = mf.origin;
+ pos = mf.move_origin;
// Try to get it if closer than the enemy base
if(vlen(self.origin-ef.dropped_origin)>vlen(self.origin-pos))
if(ef.tag_entity)
pos = ef.tag_entity.origin;
else
- pos = ef.origin;
+ pos = ef.move_origin;
if(vlen(pos-mf.dropped_origin)>700)
{
else
{
setattachment(vh_player.flagcarried, vh_vehicle, "");
- setorigin(vh_player.flagcarried, VEHICLE_FLAG_OFFSET);
+ vh_player.flagcarried.move_origin = VEHICLE_FLAG_OFFSET;
vh_player.flagcarried.scale = VEHICLE_FLAG_SCALE;
- //vh_player.flagcarried.angles = '0 0 0';
+ //vh_player.flagcarried.move_angles = '0 0 0';
}
return true;
}
if(vh_player.flagcarried)
{
setattachment(vh_player.flagcarried, vh_player, "");
- setorigin(vh_player.flagcarried, FLAG_CARRY_OFFSET);
+ vh_player.flagcarried.move_origin = VEHICLE_FLAG_OFFSET;
vh_player.flagcarried.scale = FLAG_SCALE;
- vh_player.flagcarried.angles = '0 0 0';
+ vh_player.flagcarried.move_angles = '0 0 0';
return true;
}
case FLAG_PASSING:
{
// lock the flag, game is over
- flag.movetype = MOVETYPE_NONE;
+ flag.move_movetype = MOVETYPE_NONE;
flag.takedamage = DAMAGE_NO;
flag.solid = SOLID_NOT;
flag.nextthink = false; // stop thinking