void ent_func_ladder();
void ent_trigger_push();
void ent_target_push();
+void ent_conveyor();
void CSQC_Ent_Update(float bIsNewEntity)
{
float t;
case ENT_CLIENT_LADDER: ent_func_ladder(); break;
case ENT_CLIENT_TRIGGER_PUSH: ent_trigger_push(); break;
case ENT_CLIENT_TARGET_PUSH: ent_target_push(); break;
+ case ENT_CLIENT_CONVEYOR: ent_conveyor(); break;
default:
//error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
var float autocvar_crosshair_rpc_alpha = 1;
var float autocvar_crosshair_rpc_size = 1;
float autocvar_cl_nade_timer;
+float autocvar_speedmeter;
float hud;
float view_quality;
float framecount;
+
+.float jumppadcount;
../server/mutators/mutator_multijump.qc
../server/t_halflife.qc
../server/t_jumppads.qc
+../server/t_plats.qc
../common/nades.qc
../common/buffs.qc
const float ENT_CLIENT_LADDER = 61;
const float ENT_CLIENT_TRIGGER_PUSH = 62;
const float ENT_CLIENT_TARGET_PUSH = 63;
+const float ENT_CLIENT_CONVEYOR = 64;
const float ENT_CLIENT_HEALING_ORB = 80;
}
}
-#ifdef SVQC
- if (!(self.lastflags & FL_ONGROUND))
+ if (!WAS_ONGROUND(self))
{
- if (autocvar_speedmeter)
+ if(autocvar_speedmeter)
dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
- if (self.lastground < time - 0.3)
+ if(self.lastground < time - 0.3)
{
- self.velocity_x *= (1 - autocvar_sv_friction_on_land);
- self.velocity_y *= (1 - autocvar_sv_friction_on_land);
+ self.velocity_x *= (1 - PHYS_FRICTION_ONLAND);
+ self.velocity_y *= (1 - PHYS_FRICTION_ONLAND);
}
- if (self.jumppadcount > 1)
+ if(self.jumppadcount > 1)
dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
self.jumppadcount = 0;
}
-#endif
self.velocity_z += mjumpheight;
#endif
void PM_walk(float buttons_prev, float maxspd_mod)
{
-#ifdef SVQC
- if (!(self.lastflags & FL_ONGROUND))
+ if (!WAS_ONGROUND(self))
{
if (autocvar_speedmeter)
dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
if (self.lastground < time - 0.3)
- self.velocity *= (1 - autocvar_sv_friction_on_land);
+ self.velocity *= (1 - PHYS_FRICTION_ONLAND);
if (self.jumppadcount > 1)
dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
self.jumppadcount = 0;
}
-#endif
// walking
makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
}
#endif
-#ifdef SVQC
// conveyors: first fix velocity
if (self.conveyor.state)
self.velocity -= self.conveyor.movedir;
-#endif
#ifdef SVQC
MUTATOR_CALLHOOK(PlayerPhysics);
if (IS_ONGROUND(self))
self.lastground = time;
-#ifdef SVQC
// conveyors: then break velocity again
if (self.conveyor.state)
self.velocity += self.conveyor.movedir;
-#endif
+
+#ifdef SVQC
self.lastflags = self.flags;
+#elif defined(CSQC)
+ self.lastflags = self.pmove_flags;
+#endif
+
self.lastclassname = self.classname;
}
// Client/server mappings
+.entity conveyor;
+
#ifdef CSQC
float player_multijump;
#define PHYS_WORLD_ANGLES(s) input_angles
#define PHYS_INPUT_TIMELENGTH input_timelength
+ #define PHYS_INPUT_FRAMETIME serverdeltatime
#define PHYS_INPUT_MOVEVALUES(s) input_movevalues
#define SET_ONGROUND(s) s.pmove_flags |= PMF_ONGROUND
#define UNSET_ONGROUND(s) s.pmove_flags &= ~PMF_ONGROUND
+ #define WAS_ONGROUND(s) !!(s.lastflags & PMF_ONGROUND)
+
#define ITEMS(s) getstati(STAT_ITEMS, 0, 24)
#define PHYS_AMMO_FUEL(s) getstati(STAT_FUEL)
#define PHYS_AIRSTRAFEACCELERATE getstatf(STAT_MOVEVARS_AIRSTRAFEACCELERATE)
#define PHYS_ENTGRAVITY(s) getstatf(STAT_MOVEVARS_ENTGRAVITY)
#define PHYS_FRICTION getstatf(STAT_MOVEVARS_FRICTION)
+ #define PHYS_FRICTION_ONLAND getstatf(STAT_MOVEVARS_FRICTION_ONLAND)
#define PHYS_GRAVITY getstatf(STAT_MOVEVARS_GRAVITY)
#define PHYS_HIGHSPEED getstatf(STAT_MOVEVARS_HIGHSPEED)
#define PHYS_JUMPVELOCITY getstatf(STAT_MOVEVARS_JUMPVELOCITY)
#define PHYS_WORLD_ANGLES(s) s.angles
#define PHYS_INPUT_TIMELENGTH frametime
+ #define PHYS_INPUT_FRAMETIME sys_frametime
#define PHYS_INPUT_MOVEVALUES(s) s.movement
// TODO: cache
#define SET_ONGROUND(s) s.flags |= FL_ONGROUND
#define UNSET_ONGROUND(s) s.flags &= ~FL_ONGROUND
+ #define WAS_ONGROUND(s) !!((s).lastflags & FL_ONGROUND)
+
#define ITEMS(s) s.items
#define PHYS_AMMO_FUEL(s) s.ammo_fuel
#define PHYS_AIRSTRAFEACCELERATE autocvar_sv_airstrafeaccelerate
#define PHYS_ENTGRAVITY(s) s.gravity
#define PHYS_FRICTION autocvar_sv_friction
+ #define PHYS_FRICTION_ONLAND autocvar_sv_friction_on_land
#define PHYS_GRAVITY autocvar_sv_gravity
#define PHYS_HIGHSPEED autocvar_g_movement_highspeed
#define PHYS_JUMPVELOCITY autocvar_sv_jumpvelocity
// 189 empty?
// 190 empty?
// 191 empty?
-// 192 empty?
+const float STAT_MOVEVARS_FRICTION_ONLAND = 192;
const float STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS = 193;
const float STAT_MOVEVARS_JUMPSPEEDCAP_MAX = 194;
const float STAT_MOVEVARS_JUMPSPEEDCAP_MIN = 195;
float( float b, ... ) max = #95;
float(float minimum, float val, float maximum) bound = #96;
float(float f, float f) pow = #97;
+entity(entity start, .entity fld, entity match) findentity = #98;
entity(entity start, .float fld, float match) findfloat = #98;
float(string s) checkextension = #99;
// FrikaC and Telejano range #100-#199
typedef vector(entity player, entity spot, vector current) spawn_evalfunc_t;
.spawn_evalfunc_t spawn_evalfunc;
-.entity conveyor;
-
string modname;
.float missile_flags;
return f;
}
-#define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
-
const string STR_PLAYER = "player";
const string STR_SPECTATOR = "spectator";
const string STR_OBSERVER = "observer";
+#ifdef SVQC
+
.float dmgtime2;
void generic_plat_blocked()
{
InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
}
+#endif
+
void conveyor_think()
{
+#ifdef CSQC
+ float dt = time - self.move_time;
+ self.move_time = time;
+ if(dt <= 0) { return; }
+#endif
entity e;
// set myself as current conveyor where possible
{
for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
if(!e.conveyor.state)
+#ifdef SVQC
if(isPushable(e))
+#elif defined(CSQC)
+ if(e.isplayermodel)
+#endif
{
vector emin = e.absmin;
vector emax = e.absmax;
for(e = world; (e = findentity(e, conveyor, self)); )
{
+#ifdef SVQC
if(IS_CLIENT(e)) // doing it via velocity has quite some advantages
continue; // done in SV_PlayerPhysics
+#elif defined(CSQC)
+ if(e.isplayermodel)
+ continue;
+#endif
- setorigin(e, e.origin + self.movedir * sys_frametime);
+ setorigin(e, e.origin + self.movedir * PHYS_INPUT_FRAMETIME);
move_out_of_solid(e);
+#ifdef SVQC
UpdateCSQCProjectile(e);
+#endif
/*
// stupid conveyor code
tracebox(e.origin, e.mins, e.maxs, e.origin + self.movedir * sys_frametime, MOVE_NORMAL, e);
}
}
+#ifdef SVQC
self.nextthink = time;
+#endif
}
+#ifdef SVQC
+
void conveyor_use()
{
self.state = !self.state;
+
+ self.SendFlags |= 2;
}
void conveyor_reset()
{
self.state = (self.spawnflags & 1);
+
+ self.SendFlags |= 2;
+}
+
+float conveyor_send(entity to, float sf)
+{
+ WriteByte(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
+ WriteByte(MSG_ENTITY, sf);
+
+ if(sf & 1)
+ {
+ WriteByte(MSG_ENTITY, self.warpzone_isboxy);
+ WriteCoord(MSG_ENTITY, self.origin_x);
+ WriteCoord(MSG_ENTITY, self.origin_y);
+ WriteCoord(MSG_ENTITY, self.origin_z);
+
+ WriteCoord(MSG_ENTITY, self.mins_x);
+ WriteCoord(MSG_ENTITY, self.mins_y);
+ WriteCoord(MSG_ENTITY, self.mins_z);
+ WriteCoord(MSG_ENTITY, self.maxs_x);
+ WriteCoord(MSG_ENTITY, self.maxs_y);
+ WriteCoord(MSG_ENTITY, self.maxs_z);
+
+ WriteCoord(MSG_ENTITY, self.movedir_x);
+ WriteCoord(MSG_ENTITY, self.movedir_y);
+ WriteCoord(MSG_ENTITY, self.movedir_z);
+
+ WriteByte(MSG_ENTITY, self.speed);
+ WriteByte(MSG_ENTITY, self.state);
+
+ WriteString(MSG_ENTITY, self.targetname);
+ WriteString(MSG_ENTITY, self.target);
+ }
+
+ if(sf & 2)
+ WriteByte(MSG_ENTITY, self.state);
+
+ return TRUE;
}
void conveyor_init()
}
else
self.state = 1;
+
+ Net_LinkEntity(self, 0, FALSE, conveyor_send);
+
+ self.SendFlags |= 1;
}
void spawnfunc_trigger_conveyor()
self.movetype = MOVETYPE_NONE;
conveyor_init();
}
+
+#elif defined(CSQC)
+
+void conveyor_init()
+{
+ self.draw = conveyor_think;
+ self.drawmask = MASK_NORMAL;
+
+ self.movetype = MOVETYPE_NONE;
+ self.model = "";
+ self.solid = SOLID_TRIGGER;
+ self.move_origin = self.origin;
+ self.move_time = time;
+}
+
+void ent_conveyor()
+{
+ float sf = ReadByte();
+
+ if(sf & 1)
+ {
+ self.warpzone_isboxy = ReadByte();
+ self.origin_x = ReadCoord();
+ self.origin_y = ReadCoord();
+ self.origin_z = ReadCoord();
+ setorigin(self, self.origin);
+
+ self.mins_x = ReadCoord();
+ self.mins_y = ReadCoord();
+ self.mins_z = ReadCoord();
+ self.maxs_x = ReadCoord();
+ self.maxs_y = ReadCoord();
+ self.maxs_z = ReadCoord();
+ setsize(self, self.mins, self.maxs);
+
+ self.movedir_x = ReadCoord();
+ self.movedir_y = ReadCoord();
+ self.movedir_z = ReadCoord();
+
+ self.speed = ReadByte();
+ self.state = ReadByte();
+
+ self.targetname = strzone(ReadString());
+ self.target = strzone(ReadString());
+
+ conveyor_init();
+ }
+
+ if(sf & 2)
+ self.state = ReadByte();
+}
+
+#endif
{
return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, self, other);
}
+
+
+void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
+{
+ float eps = 0.0625;
+ tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
+ if (trace_startsolid)
+ return;
+ if (trace_fraction < 1)
+ {
+ // hit something
+ // adjust origin in the other direction...
+ setorigin(e,e.origin - by * (1 - trace_fraction));
+ }
+}
+
+float WarpZoneLib_MoveOutOfSolid(entity e)
+{
+ vector o, m0, m1;
+
+ o = e.origin;
+ traceline(o, o, MOVE_WORLDONLY, e);
+ if (trace_startsolid)
+ return FALSE;
+
+ tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
+ if (!trace_startsolid)
+ return TRUE;
+
+ m0 = e.mins;
+ m1 = e.maxs;
+ e.mins = '0 0 0';
+ e.maxs = '0 0 0';
+ WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m0_x);
+ e.mins_x = m0_x;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m1_x);
+ e.maxs_x = m1_x;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m0_y);
+ e.mins_y = m0_y;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m1_y);
+ e.maxs_y = m1_y;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m0_z);
+ e.mins_z = m0_z;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m1_z);
+ e.maxs_z = m1_z;
+ setorigin(e, e.origin);
+
+ tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
+ if (trace_startsolid)
+ {
+ setorigin(e, o);
+ return FALSE;
+ }
+
+ return TRUE;
+}
#ifndef BITXOR_ASSIGN
# define BITXOR_ASSIGN(a,b) ((a) = ((a) | (b)) - ((a) & (b)))
#endif
+
+float WarpZoneLib_MoveOutOfSolid(entity e);
+#define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
-void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
-{
- float eps = 0.0625;
- tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
- if (trace_startsolid)
- return;
- if (trace_fraction < 1)
- {
- // hit something
- // adjust origin in the other direction...
- setorigin(e,e.origin - by * (1 - trace_fraction));
- }
-}
-
-float WarpZoneLib_MoveOutOfSolid(entity e)
-{
- vector o, m0, m1;
-
- o = e.origin;
- traceline(o, o, MOVE_WORLDONLY, e);
- if (trace_startsolid)
- return FALSE;
-
- tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
- if (!trace_startsolid)
- return TRUE;
-
- m0 = e.mins;
- m1 = e.maxs;
- e.mins = '0 0 0';
- e.maxs = '0 0 0';
- WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m0_x);
- e.mins_x = m0_x;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m1_x);
- e.maxs_x = m1_x;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m0_y);
- e.mins_y = m0_y;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m1_y);
- e.maxs_y = m1_y;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m0_z);
- e.mins_z = m0_z;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m1_z);
- e.maxs_z = m1_z;
- setorigin(e, e.origin);
-
- tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
- if (trace_startsolid)
- {
- setorigin(e, o);
- return FALSE;
- }
-
- return TRUE;
-}
-
void WarpZoneLib_ExactTrigger_Init()
{
vector mi, ma;