set g_balance_contents_drowndelay 10 // time under water before a player begins drowning
set g_balance_contents_playerdamage_drowning 20 // damage per second for while player is drowning
set g_balance_contents_playerdamage_lava 50 // damage per second for while player is inside lava
+set g_balance_contents_playerdamage_lava_burn 0 // extra burning damage after leaving lava
+set g_balance_contents_playerdamage_lava_burn_time 2.5 // time across which the damage is applied (note: not dps!)
set g_balance_contents_playerdamage_slime 30 // damage per second for while player is inside slime
set g_balance_contents_projectiledamage 10000 // instantly kill projectiles upon touching lava/slime
set g_maxpushtime 8.0 "timeout for kill credit when your damage knocks someone into a death trap"
set g_balance_contents_drowndelay 10 // time under water before a player begins drowning
set g_balance_contents_playerdamage_drowning 20 // damage per second for while player is drowning
set g_balance_contents_playerdamage_lava 50 // damage per second for while player is inside lava
+set g_balance_contents_playerdamage_lava_burn 0 // extra burning damage after leaving lava
+set g_balance_contents_playerdamage_lava_burn_time 2.5 // time across which the damage is applied (note: not dps!)
set g_balance_contents_playerdamage_slime 30 // damage per second for while player is inside slime
set g_balance_contents_projectiledamage 10000 // instantly kill projectiles upon touching lava/slime
set g_maxpushtime 8.0 "timeout for kill credit when your damage knocks someone into a death trap"
set g_balance_contents_drowndelay 10 // time under water before a player begins drowning
set g_balance_contents_playerdamage_drowning 20 // damage per second for while player is drowning
set g_balance_contents_playerdamage_lava 50 // damage per second for while player is inside lava
+set g_balance_contents_playerdamage_lava_burn 0 // extra burning damage after leaving lava
+set g_balance_contents_playerdamage_lava_burn_time 2.5 // time across which the damage is applied (note: not dps!)
set g_balance_contents_playerdamage_slime 30 // damage per second for while player is inside slime
set g_balance_contents_projectiledamage 10000 // instantly kill projectiles upon touching lava/slime
set g_maxpushtime 8.0 "timeout for kill credit when your damage knocks someone into a death trap"
set g_balance_contents_drowndelay 10 // time under water before a player begins drowning
set g_balance_contents_playerdamage_drowning 20 // damage per second for while player is drowning
set g_balance_contents_playerdamage_lava 50 // damage per second for while player is inside lava
+set g_balance_contents_playerdamage_lava_burn 0 // extra burning damage after leaving lava
+set g_balance_contents_playerdamage_lava_burn_time 2.5 // time across which the damage is applied (note: not dps!)
set g_balance_contents_playerdamage_slime 30 // damage per second for while player is inside slime
set g_balance_contents_projectiledamage 10000 // instantly kill projectiles upon touching lava/slime
set g_maxpushtime 8.0 "timeout for kill credit when your damage knocks someone into a death trap"
set g_balance_contents_drowndelay 10 // time under water before a player begins drowning
set g_balance_contents_playerdamage_drowning 20 // damage per second for while player is drowning
set g_balance_contents_playerdamage_lava 50 // damage per second for while player is inside lava
+set g_balance_contents_playerdamage_lava_burn 0 // extra burning damage after leaving lava
+set g_balance_contents_playerdamage_lava_burn_time 2.5 // time across which the damage is applied (note: not dps!)
set g_balance_contents_playerdamage_slime 30 // damage per second for while player is inside slime
set g_balance_contents_projectiledamage 10000 // instantly kill projectiles upon touching lava/slime
set g_maxpushtime 8.0 "timeout for kill credit when your damage knocks someone into a death trap"
set g_balance_contents_drowndelay 10 // time under water before a player begins drowning
set g_balance_contents_playerdamage_drowning 20 // damage per second for while player is drowning
set g_balance_contents_playerdamage_lava 50 // damage per second for while player is inside lava
+set g_balance_contents_playerdamage_lava_burn 0 // extra burning damage after leaving lava
+set g_balance_contents_playerdamage_lava_burn_time 2.5 // time across which the damage is applied (note: not dps!)
set g_balance_contents_playerdamage_slime 30 // damage per second for while player is inside slime
set g_balance_contents_projectiledamage 10000 // instantly kill projectiles upon touching lava/slime
set g_maxpushtime 8.0 "timeout for kill credit when your damage knocks someone into a death trap"
-fftepp -flno -futf8 -fno-bail-on-werror -fftepp-predefs \
-frelaxed-switch -freturn-assignments \
$(QCCFLAGS_WATERMARK) \
+ -DNDEBUG=1 \
$(QCCFLAGS_FEATURES) \
$(QCCFLAGS_EXTRA)
{
SELFPARAM();
float starttime = STAT(GAMESTARTTIME);
- float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
+ float roundstarttime = STAT(ROUNDSTARTTIME);
if(roundstarttime == -1)
{
Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTOP);
void Announcer_Gamestart()
{
float startTime = STAT(GAMESTARTTIME);
- float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
+ float roundstarttime = STAT(ROUNDSTARTTIME);
if(roundstarttime > startTime)
startTime = roundstarttime;
// Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
void Announcer_Time()
{
- float timelimit = getstatf(STAT_TIMELIMIT);
+ float timelimit = STAT(TIMELIMIT);
float timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time);
float warmup_timeleft = 0;
float uid2name_dialog;
-.bool csqcmodel_isdead; // used by shownames and miscfunctions (float getplayerisdead(float) {}) to know when a player is dead
+.bool csqcmodel_isdead; // used by shownames and miscfunctions (entcs_IsDead) to know when a player is dead
#define player_currententnum (spectatee_status > 0 ? spectatee_status : player_localnum + 1)
}
}
- t = GetPlayerColorForce(self.owner.sv_entnum);
+ t = entcs_GetTeamColor(self.owner.sv_entnum);
switch(self.HookType)
{
case NUM_TEAM_2: tex = "particles/hook_blue"; rgb = '0.3 0.3 1'; break;
case NUM_TEAM_3: tex = "particles/hook_yellow"; rgb = '1 1 0.3'; break;
case NUM_TEAM_4: tex = "particles/hook_pink"; rgb = '1 0.3 1'; break;
- default: tex = "particles/hook_white"; rgb = getcsqcplayercolor(self.sv_entnum); break;
+ default: tex = "particles/hook_white"; rgb = entcs_GetColor(self.sv_entnum - 1); break;
}
break;
case NET_ENT_CLIENT_ARC_BEAM: // todo
float stringwidth_colors(string s, vector theSize);
float stringwidth_nocolors(string s, vector theSize);
-float GetPlayerColorForce(int i);
-int GetPlayerColor(int i);
-string GetPlayerName(int i);
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag);
.int panel_showflags;
}
int rows = 0, columns, row, column;
- float nade_cnt = getstatf(STAT_NADE_BONUS), nade_score = getstatf(STAT_NADE_BONUS_SCORE);
+ float nade_cnt = STAT(NADE_BONUS), nade_score = STAT(NADE_BONUS_SCORE);
bool draw_nades = (nade_cnt > 0 || nade_score > 0);
float nade_statuschange_elapsedtime;
int total_ammo_count;
prev_health = 0;
prev_armor = 0;
}
- fuel = getstati(STAT_FUEL);
+ fuel = STAT(FUEL);
}
else
{
if(spectatee_status == -1)
s = _("^1Observing");
else
- s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(current_player));
+ s = sprintf(_("^1Spectating: ^7%s"), entcs_GetName(current_player));
drawInfoMessage(s);
if(spectatee_status == -1)
switch(i)
{
case 0:
- stat = getstati(STAT_REDALIVE);
+ stat = STAT(REDALIVE);
pic = "player_red.tga";
color = '1 0 0';
break;
case 1:
- stat = getstati(STAT_BLUEALIVE);
+ stat = STAT(BLUEALIVE);
pic = "player_blue.tga";
color = '0 0 1';
break;
case 2:
- stat = getstati(STAT_YELLOWALIVE);
+ stat = STAT(YELLOWALIVE);
pic = "player_yellow.tga";
color = '1 1 0';
break;
default:
case 3:
- stat = getstati(STAT_PINKALIVE);
+ stat = STAT(PINKALIVE);
pic = "player_pink.tga";
color = '1 0 1';
break;
int redflag, blueflag, yellowflag, pinkflag, neutralflag; // current status
float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime, yellowflag_statuschange_elapsedtime, pinkflag_statuschange_elapsedtime, neutralflag_statuschange_elapsedtime; // time since the status changed
bool ctf_oneflag; // one-flag CTF mode enabled/disabled
- int stat_items = getstati(STAT_CTF_FLAGSTATUS, 0, 24);
+ int stat_items = STAT(CTF_FLAGSTATUS);
float fs, fs2, fs3, size1, size2;
vector e1, e2;
int stat_items;
stat_items = getstati(STAT_ITEMS, 0, 24);
- nb_pb_starttime = getstatf(STAT_NB_METERSTART);
+ nb_pb_starttime = STAT(NB_METERSTART);
if (stat_items & IT_KEY1)
mod_active = 1;
drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
} else if(race_status == 2) {
- if(race_status_name == GetPlayerName(player_localnum) || !race_myrank || race_myrank < rank)
+ if(race_status_name == entcs_GetName(player_localnum) || !race_myrank || race_myrank < rank)
drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankgreen", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
else
drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankyellow", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
switch(i)
{
case 0:
- stat = getstatf(STAT_DOM_PPS_RED);
+ stat = STAT(DOM_PPS_RED);
pic = "dom_icon_red";
color = '1 0 0';
break;
case 1:
- stat = getstatf(STAT_DOM_PPS_BLUE);
+ stat = STAT(DOM_PPS_BLUE);
pic = "dom_icon_blue";
color = '0 0 1';
break;
case 2:
- stat = getstatf(STAT_DOM_PPS_YELLOW);
+ stat = STAT(DOM_PPS_YELLOW);
pic = "dom_icon_yellow";
color = '1 1 0';
break;
default:
case 3:
- stat = getstatf(STAT_DOM_PPS_PINK);
+ stat = STAT(DOM_PPS_PINK);
pic = "dom_icon_pink";
color = '1 0 1';
break;
}
- float pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
+ float pps_ratio = stat / STAT(DOM_TOTAL_PPS);
if(mySize.x/mySize.y > aspect_ratio)
{
void HUD_Powerups()
{
int allItems = getstati(STAT_ITEMS, 0, 24);
- int allBuffs = getstati(STAT_BUFFS, 0, 24);
+ int allBuffs = STAT(BUFFS);
int strengthTime, shieldTime, superTime;
// Initialize items
strengthTime = bound(0, STAT(STRENGTH_FINISHED) - time, 99);
shieldTime = bound(0, STAT(INVINCIBLE_FINISHED) - time, 99);
- superTime = bound(0, getstatf(STAT_SUPERWEAPONS_FINISHED) - time, 99);
+ superTime = bound(0, STAT(SUPERWEAPONS_FINISHED) - time, 99);
if(allItems & IT_UNLIMITED_SUPERWEAPONS)
superTime = 99;
vector keysize;
keysize = eX * mySize.x * (1/3.0) + eY * mySize.y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
- float pressedkeys;
- pressedkeys = getstatf(STAT_PRESSED_KEYS);
+ int pressedkeys = STAT(PRESSED_KEYS);
if(autocvar_hud_panel_pressedkeys_attack)
{
{
if (!tm.m_entcs_private) continue;
if (entcs_is_self(tm)) continue;
- color2 = GetPlayerColor(tm.sv_entnum);
+ color2 = entcs_GetTeam(tm.sv_entnum);
//if(color == NUM_SPECTATOR || color == color2)
draw_teamradar_player(tm.origin, tm.angles, Team_ColorRGB(color2));
}
{
rgb = '1 1 0';
drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
- s = GetPlayerName(player_localnum);
+ s = entcs_GetName(player_localnum);
score = 7;
}
else
}
if (team_count)
score_color = Team_ColorRGB(pl.team) * 0.8;
- s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
+ s = textShortenToWidth(entcs_GetName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
pos.y += fontsize.y;
string timer;
float timelimit, elapsedTime, timeleft, minutesLeft;
- timelimit = getstatf(STAT_TIMELIMIT);
+ timelimit = STAT(TIMELIMIT);
timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time);
timeleft = ceil(timeleft);
for(i = 0; i < maxclients; ++i)
{
e = playerslots[i];
- if(GetPlayerName(i) == "")
+ if(entcs_GetName(i) == "")
{
if(e.sort_prev)
{
e.ping_packetloss = 0;
e.ping_movementloss = 0;
//e.gotscores = 0; // we might already have the scores...
- SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
+ SetTeam(e, entcs_GetTeam(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
RegisterPlayer(e);
HUD_UpdatePlayerPos(e);
}
if(is_new)
{
- float teamnum = GetPlayerColor(entnum - 1);
+ float teamnum = entcs_GetTeam(entnum - 1);
if(autocvar_cl_spawn_event_particles)
{
else
{
serverprevtime = time;
- serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+ serverdeltatime = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
time = serverprevtime + serverdeltatime;
}
strunzone(grecordholder[pos-1]);
grecordholder[pos-1] = strzone(ReadString());
grecordtime[pos-1] = ReadInt24_t();
- if(grecordholder[pos-1] == GetPlayerName(player_localnum))
+ if(grecordholder[pos-1] == entcs_GetName(player_localnum))
race_myrank = pos;
break;
case RACE_NET_SERVER_STATUS:
}
}
-// TODO: entcs
-float getplayeralpha(int pl)
-{
- entity e = CSQCModel_server2csqc(pl + 1);
- return (e) ? e.alpha : 1;
-}
-
-// TODO: entcs
-vector getcsqcplayercolor(int pl)
-{
- entity e = CSQCModel_server2csqc(pl);
- return (e && e.colormap > 0) ? colormapPaletteColor(((e.colormap >= 1024) ? e.colormap : stof(getplayerkeyvalue(e.colormap - 1, "colors"))) & 0x0F, true) : '1 1 1';
-}
-
-// TODO: entcs
-bool getplayerisdead(int pl)
-{
- entity e = CSQCModel_server2csqc(pl + 1);
- return e ? e.csqcmodel_isdead : false;
-}
-
/** engine callback */
void URI_Get_Callback(int id, float status, string data)
{
vector rotate(vector v, float a);
-string ColorTranslateRGB(string s);
-
// decolorizes and team colors the player name when needed
string playername(string thename, float teamid);
void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
-float getplayeralpha(float pl);
-
-vector getcsqcplayercolor(float pl);
-
-float getplayerisdead(float pl);
-
const int MAX_ACCURACY_LEVELS = 10;
float acc_lev[MAX_ACCURACY_LEVELS];
vector acc_col[MAX_ACCURACY_LEVELS];
#include "weapons/projectile.qc" // TODO
+#include "../common/anim.qc"
#include "../common/animdecide.qc"
#include "../common/effects/effectinfo.qc"
#include "../common/ent_cs.qc"
continue;
if(without_me && pl.sv_entnum == player_localnum)
continue;
- QUICKMENU_ENTRY(GetPlayerName(pl.sv_entnum), sprintf(cmd, GetPlayerName(pl.sv_entnum)))
+ QUICKMENU_ENTRY(entcs_GetName(pl.sv_entnum), sprintf(cmd, entcs_GetName(pl.sv_entnum)))
}
return;
QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
QUICKMENU_ENTRY(CTX(_("QMCMD^Restart the map")), "vcall restart")
QUICKMENU_ENTRY(CTX(_("QMCMD^End match")), "vcall endmatch")
- if(getstatf(STAT_TIMELIMIT) > 0)
+ if(STAT(TIMELIMIT) > 0)
{
QUICKMENU_ENTRY(CTX(_("QMCMD^Reduce match time")), "vcall reducematchtime")
QUICKMENU_ENTRY(CTX(_("QMCMD^Extend match time")), "vcall extendmatchtime")
for(pl = players.sort_next; pl; pl = pl.sort_next)
{
num += 1;
- Team = GetPlayerColor(pl.sv_entnum);
+ Team = entcs_GetTeam(pl.sv_entnum);
if(SetTeam(pl, Team))
{
tmp = pl.sort_prev;
float HUD_ComparePlayerScores(entity left, entity right)
{
float vl, vr, r;
- vl = GetPlayerColor(left.sv_entnum);
- vr = GetPlayerColor(right.sv_entnum);
+ vl = entcs_GetTeam(left.sv_entnum);
+ vr = entcs_GetTeam(right.sv_entnum);
if(!left.gotscores)
vl = NUM_SPECTATOR;
hud_field_icon2_rgb = colormapPaletteColor(f % 16, 1);
}
}
- return GetPlayerName(pl.sv_entnum);
+ return entcs_GetName(pl.sv_entnum);
case SP_FRAGS:
f = pl.(scores[SP_KILLS]);
string str;
int field;
float is_spec;
- is_spec = (GetPlayerColor(pl.sv_entnum) == NUM_SPECTATOR);
+ is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR);
if((rgb == '1 1 1') && (!is_spec)) {
rgb.x = autocvar_scoreboard_color_bg_r + 0.5;
string val;
// get monster stats
- stat_monsters_killed = getstatf(STAT_MONSTERS_KILLED);
- stat_monsters_total = getstatf(STAT_MONSTERS_TOTAL);
+ stat_monsters_killed = STAT(MONSTERS_KILLED);
+ stat_monsters_total = STAT(MONSTERS_TOTAL);
// get secrets stats
- stat_secrets_found = getstatf(STAT_SECRETS_FOUND);
- stat_secrets_total = getstatf(STAT_SECRETS_TOTAL);
+ stat_secrets_found = STAT(SECRETS_FOUND);
+ stat_secrets_total = STAT(SECRETS_TOTAL);
// get number of rows
if(stat_secrets_total)
return pos;
float is_spec;
- is_spec = (GetPlayerColor(pl.sv_entnum) == NUM_SPECTATOR);
+ is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR);
vector hl_rgb;
hl_rgb.x = autocvar_scoreboard_color_bg_r + 0.5;
hl_rgb.y = autocvar_scoreboard_color_bg_g + 0.5;
continue;
n = grecordholder[i];
p = count_ordinal(i+1);
- if(grecordholder[i] == GetPlayerName(player_localnum))
+ if(grecordholder[i] == entcs_GetName(player_localnum))
drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize.y, hl_rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
else if(!(i % 2) && scoreboard_highlight)
drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize.y, hl_rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
// Print info string
float tl, fl, ll;
str = sprintf(_("playing ^3%s^7 on ^2%s^7"), MapInfo_Type_ToText(gametype), shortmapname);
- tl = getstatf(STAT_TIMELIMIT);
- fl = getstatf(STAT_FRAGLIMIT);
- ll = getstatf(STAT_LEADLIMIT);
+ tl = STAT(TIMELIMIT);
+ fl = STAT(FRAGLIMIT);
+ ll = STAT(LEADLIMIT);
if(gametype == MAPINFO_TYPE_LMS)
{
if(tl > 0)
drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, true, hud_fontsize)), str, hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
// print information about respawn status
- float respawn_time = getstatf(STAT_RESPAWN_TIME);
+ float respawn_time = STAT(RESPAWN_TIME);
if(!intermission)
if(respawn_time)
{
for (int i = 0; i < maxclients; ++i)
{
entity e = new(shownames_tag);
+ make_pure(e);
e.sv_entnum = i + 1;
LL_PUSH(shownames_ent, e);
}
if (autocvar_hud_shownames_antioverlap)
{
// fade tag out if another tag that is closer to you overlaps
- LL_EACH(shownames_ent, true, LAMBDA(
- entity entcs = entcs_receiver(i);
- if (!entcs || it == this) continue;
+ LL_EACH(shownames_ent, it != this && entcs_receiver(i), LAMBDA(
vector eo = project_3d_to_2d(it.origin);
if (eo.z < 0 || eo.x < 0 || eo.y < 0 || eo.x > vid_conwidth || eo.y > vid_conheight) continue;
eo.z = 0;
// multiply by player alpha
if (!this.sameteam || (this.sv_entnum == player_localentnum))
{
- float f = getplayeralpha(this.sv_entnum - 1);
+ float f = entcs_GetAlpha(this.sv_entnum - 1);
if (f == 0) f = 1;
if (f < 0) f = 0;
// FIXME: alpha is negative when dead, breaking death fade
DRAWFLAG_NORMAL);
}
}
- string s = GetPlayerName(this.sv_entnum - 1);
+ string s = entcs_GetName(this.sv_entnum - 1);
if ((autocvar_hud_shownames_decolorize == 1 && teamplay)
- || autocvar_hud_shownames_decolorize == 2) s = playername(s, GetPlayerColor(this.sv_entnum - 1));
+ || autocvar_hud_shownames_decolorize == 2) s = playername(s, entcs_GetTeam(this.sv_entnum - 1));
drawfontscale = '1 1 0' * resize;
s = textShortenToWidth(s, namewidth, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors);
float width = stringwidth(s, true, '1 1 0' * autocvar_hud_shownames_fontsize);
if (!autocvar_hud_shownames) return;
LL_EACH(shownames_ent, true, LAMBDA(
entity entcs = entcs_receiver(i);
- if (!entcs) continue;
+ if (!entcs)
+ {
+ make_pure(it);
+ continue;
+ }
+ make_impure(it);
+ if (entcs.think) WITH(entity, self, entcs, entcs.think());
+ else
+ {
+ LOG_WARNING("entcs.think == null");
+ eprint(entcs);
+ }
if (entcs.m_entcs_private)
{
it.healthvalue = entcs.healthvalue;
it.armorvalue = 0;
it.sameteam = false;
}
- bool dead = getplayerisdead(i);
+ bool dead = entcs_IsDead(i) || entcs_IsSpectating(i);
if (!it.csqcmodel_isdead && entcs.has_origin) setorigin(it, entcs.origin);
it.csqcmodel_isdead = dead;
Draw_ShowNames(it);
#include "mutators/events.qh"
+#include "../common/anim.qh"
#include "../common/constants.qh"
#include "../common/debug.qh"
#include "../common/mapinfo.qh"
#include "../lib/warpzone/client.qh"
#include "../lib/warpzone/common.qh"
+#define EFMASK_CHEAP (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NODRAW | EF_NOSHADOW | EF_SELECTABLE | EF_TELEPORT_BIT)
+
+float autocvar_cl_viewmodel_scale;
+
+bool autocvar_cl_bobmodel;
+float autocvar_cl_bobmodel_speed;
+float autocvar_cl_bobmodel_side;
+float autocvar_cl_bobmodel_up;
+
+float autocvar_cl_followmodel;
+float autocvar_cl_followmodel_side_speed;
+float autocvar_cl_followmodel_side_highpass;
+float autocvar_cl_followmodel_side_highpass1;
+float autocvar_cl_followmodel_side_limit;
+float autocvar_cl_followmodel_side_lowpass;
+float autocvar_cl_followmodel_up_speed;
+float autocvar_cl_followmodel_up_highpass;
+float autocvar_cl_followmodel_up_highpass1;
+float autocvar_cl_followmodel_up_limit;
+float autocvar_cl_followmodel_up_lowpass;
+
+float autocvar_cl_leanmodel;
+float autocvar_cl_leanmodel_side_speed;
+float autocvar_cl_leanmodel_side_highpass;
+float autocvar_cl_leanmodel_side_highpass1;
+float autocvar_cl_leanmodel_side_lowpass;
+float autocvar_cl_leanmodel_side_limit;
+float autocvar_cl_leanmodel_up_speed;
+float autocvar_cl_leanmodel_up_highpass;
+float autocvar_cl_leanmodel_up_highpass1;
+float autocvar_cl_leanmodel_up_lowpass;
+float autocvar_cl_leanmodel_up_limit;
+
+#define lowpass(value, frac, ref_store, ret) do \
+{ \
+ float __frac = bound(0, frac, 1); \
+ ret = ref_store = ref_store * (1 - __frac) + (value) * __frac; \
+} while (0)
+
+#define lowpass_limited(value, frac, limit, ref_store, ret) do \
+{ \
+ float __ignore; lowpass(value, frac, ref_store, __ignore); \
+ ret = ref_store = bound((value) - (limit), ref_store, (value) + (limit)); \
+} while (0)
+
+#define highpass(value, frac, ref_store, ret) do \
+{ \
+ float __f; lowpass(value, frac, ref_store, __f); \
+ ret = (value) - __f; \
+} while (0)
+
+#define highpass_limited(value, frac, limit, ref_store, ret) do \
+{ \
+ float __f; lowpass_limited(value, frac, limit, ref_store, __f); \
+ ret = (value) - __f; \
+} while (0)
+
+#define lowpass3(value, fracx, fracy, fracz, ref_store, ref_out) do \
+{ \
+ lowpass(value.x, fracx, ref_store.x, ref_out.x); \
+ lowpass(value.y, fracy, ref_store.y, ref_out.y); \
+ lowpass(value.z, fracz, ref_store.z, ref_out.z); \
+} while (0)
+
+#define highpass3(value, fracx, fracy, fracz, ref_store, ref_out) do \
+{ \
+ highpass(value.x, fracx, ref_store.x, ref_out.x); \
+ highpass(value.y, fracy, ref_store.y, ref_out.y); \
+ highpass(value.z, fracz, ref_store.z, ref_out.z); \
+} while (0)
+
+#define highpass3_limited(value, fracx, limitx, fracy, limity, fracz, limitz, ref_store, ref_out) do \
+{ \
+ highpass_limited(value.x, fracx, limitx, ref_store.x, ref_out.x); \
+ highpass_limited(value.y, fracy, limity, ref_store.y, ref_out.y); \
+ highpass_limited(value.z, fracz, limitz, ref_store.z, ref_out.z); \
+} while (0)
+
+void viewmodel_animate(entity this)
+{
+ static float prevtime;
+ float frametime = (time - prevtime) * STAT(MOVEVARS_TIMESCALE);
+ prevtime = time;
+
+ if (autocvar_chase_active) return;
+ if (getstati(STAT_HEALTH) <= 0) return;
+
+ entity view = CSQCModel_server2csqc(player_localentnum - 1);
+
+ bool clonground = !(view.anim_implicit_state & ANIMIMPLICITSTATE_INAIR);
+ static bool oldonground;
+ static float hitgroundtime;
+ static float lastongroundtime;
+ if (clonground)
+ {
+ float f = time; // cl.movecmd[0].time
+ if (!oldonground)
+ hitgroundtime = f;
+ lastongroundtime = f;
+ }
+ oldonground = clonground;
+
+ vector gunorg = '0 0 0', gunangles = '0 0 0';
+ static vector gunorg_prev = '0 0 0', gunangles_prev = '0 0 0';
+
+ bool teleported = view.csqcmodel_teleported;
+
+ // 1. if we teleported, clear the frametime... the lowpass will recover the previous value then
+ if (teleported)
+ {
+ // try to fix the first highpass; result is NOT
+ // perfect! TODO find a better fix
+ gunangles_prev = view_angles;
+ gunorg_prev = view_origin;
+ }
+
+ static vector gunorg_highpass = '0 0 0';
+
+ // 2. for the gun origin, only keep the high frequency (non-DC) parts, which is "somewhat like velocity"
+ gunorg_highpass += gunorg_prev;
+ highpass3_limited(view_origin,
+ frametime * autocvar_cl_followmodel_side_highpass1, autocvar_cl_followmodel_side_limit,
+ frametime * autocvar_cl_followmodel_side_highpass1, autocvar_cl_followmodel_side_limit,
+ frametime * autocvar_cl_followmodel_up_highpass1, autocvar_cl_followmodel_up_limit,
+ gunorg_highpass, gunorg);
+ gunorg_prev = view_origin;
+ gunorg_highpass -= gunorg_prev;
+
+ static vector gunangles_highpass = '0 0 0';
+
+ // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
+ gunangles_highpass += gunangles_prev;
+ PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
+ YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
+ ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
+ highpass3_limited(view_angles,
+ frametime * autocvar_cl_leanmodel_up_highpass1, autocvar_cl_leanmodel_up_limit,
+ frametime * autocvar_cl_leanmodel_side_highpass1, autocvar_cl_leanmodel_side_limit,
+ 0, 0,
+ gunangles_highpass, gunangles);
+ gunangles_prev = view_angles;
+ gunangles_highpass -= gunangles_prev;
+
+ // 3. calculate the RAW adjustment vectors
+ gunorg.x *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_side_speed : 0);
+ gunorg.y *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_side_speed : 0);
+ gunorg.z *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_up_speed : 0);
+
+ PITCH(gunangles) *= (autocvar_cl_leanmodel ? -autocvar_cl_leanmodel_up_speed : 0);
+ YAW(gunangles) *= (autocvar_cl_leanmodel ? -autocvar_cl_leanmodel_side_speed : 0);
+ ROLL(gunangles) = 0;
+
+ static vector gunorg_adjustment_highpass;
+ static vector gunorg_adjustment_lowpass;
+ static vector gunangles_adjustment_highpass;
+ static vector gunangles_adjustment_lowpass;
+
+ // 4. perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
+ // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
+ highpass3(gunorg,
+ frametime * autocvar_cl_followmodel_side_highpass,
+ frametime * autocvar_cl_followmodel_side_highpass,
+ frametime * autocvar_cl_followmodel_up_highpass,
+ gunorg_adjustment_highpass, gunorg);
+ lowpass3(gunorg,
+ frametime * autocvar_cl_followmodel_side_lowpass,
+ frametime * autocvar_cl_followmodel_side_lowpass,
+ frametime * autocvar_cl_followmodel_up_lowpass,
+ gunorg_adjustment_lowpass, gunorg);
+ // we assume here: PITCH = 0, YAW = 1, ROLL = 2
+ highpass3(gunangles,
+ frametime * autocvar_cl_leanmodel_up_highpass,
+ frametime * autocvar_cl_leanmodel_side_highpass,
+ 0,
+ gunangles_adjustment_highpass, gunangles);
+ lowpass3(gunangles,
+ frametime * autocvar_cl_leanmodel_up_lowpass,
+ frametime * autocvar_cl_leanmodel_side_lowpass,
+ 0,
+ gunangles_adjustment_lowpass, gunangles);
+ float xyspeed = bound(0, vlen(vec2(view.velocity)), 400);
+
+ // vertical view bobbing code
+ // TODO: cl_bob
+
+ // horizontal view bobbing code
+ // TODO: cl_bob2
+
+ // fall bobbing code
+ // causes the view to swing down and back up when touching the ground
+ // TODO: cl_bobfall
+
+ // gun model bobbing code
+ if (autocvar_cl_bobmodel)
+ {
+ // calculate for swinging gun model
+ // the gun bobs when running on the ground, but doesn't bob when you're in the air.
+ // Sajt: I tried to smooth out the transitions between bob and no bob, which works
+ // for the most part, but for some reason when you go through a message trigger or
+ // pick up an item or anything like that it will momentarily jolt the gun.
+ vector forward, right, up;
+ float bspeed;
+ float t = 1;
+ float s = time * autocvar_cl_bobmodel_speed;
+ if (clonground)
+ {
+ if (time - hitgroundtime < 0.2)
+ {
+ // just hit the ground, speed the bob back up over the next 0.2 seconds
+ t = time - hitgroundtime;
+ t = bound(0, t, 0.2);
+ t *= 5;
+ }
+ }
+ else
+ {
+ // recently left the ground, slow the bob down over the next 0.2 seconds
+ t = time - lastongroundtime;
+ t = 0.2 - bound(0, t, 0.2);
+ t *= 5;
+ }
+ bspeed = xyspeed * 0.01;
+ MAKEVECTORS(makevectors, view_angles, forward, right, up);
+ float bobr = bspeed * autocvar_cl_bobmodel_side * autocvar_cl_viewmodel_scale * sin(s) * t;
+ gunorg += bobr * right;
+ float bobu = bspeed * autocvar_cl_bobmodel_up * autocvar_cl_viewmodel_scale * cos(s * 2) * t;
+ gunorg += bobu * up;
+ }
+ vector v = rotate(gunorg, YAW(view_angles) * DEG2RAD); // rotate world coordinates to relative ones
+ v.z = gunorg.z;
+ this.origin += v;
+ gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
+ this.angles += gunangles;
+}
+
+.vector viewmodel_origin, viewmodel_angles;
+.float weapon_nextthink;
+.float weapon_eta_last;
+.float weapon_switchdelay;
+
+void viewmodel_draw(entity this)
+{
+ int mask = (intermission || (getstati(STAT_HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
+ float a = this.alpha;
+ int c = stof(getplayerkeyvalue(current_player, "colors"));
+ vector g;
+ Weapon wep = Weapons_from(activeweapon);
+ if (!(g = wep.wr_glow(wep))) g = colormapPaletteColor(c & 0x0F, true) * 2;
+ entity me = CSQCModel_server2csqc(player_localentnum - 1);
+ int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
+ | EF_NODEPTHTEST)
+ &~ (EF_FULLBRIGHT); // can mask team color, so get rid of it
+ for (entity e = this; e; e = e.weaponchild)
+ {
+ e.drawmask = mask;
+ e.alpha = a;
+ e.colormap = 256 + c; // colormap == 0 is black, c == 0 is white
+ e.glowmod = g;
+ e.csqcmodel_effects = fx;
+ WITH(entity, self, e, CSQCModel_Effects_Apply());
+ }
+ {
+ static string name_last;
+ string name = Weapons_from(activeweapon).mdl;
+ if (name != name_last)
+ {
+ name_last = name;
+ CL_WeaponEntity_SetModel(this, name);
+ this.viewmodel_origin = this.origin;
+ this.viewmodel_angles = this.angles;
+ }
+ anim_update(this);
+ if (!this.animstate_override)
+ anim_set(this, this.anim_idle, true, false, false);
+ }
+ float f = 0; // 0..1; 0: fully active
+ float eta = (this.weapon_nextthink - time) / STAT(WEAPONRATEFACTOR);
+ if (eta <= 0) f = this.weapon_eta_last;
+ else switch (this.state)
+ {
+ case WS_RAISE:
+ {
+ f = eta / max(eta, this.weapon_switchdelay);
+ break;
+ }
+ case WS_DROP:
+ {
+ f = 1 - eta / max(eta, this.weapon_switchdelay);
+ break;
+ }
+ case WS_CLEAR:
+ {
+ f = 1;
+ break;
+ }
+ }
+ this.weapon_eta_last = f;
+ this.origin = this.viewmodel_origin;
+ this.angles = this.viewmodel_angles;
+ this.angles_x = (-90 * f * f);
+ viewmodel_animate(this);
+ setorigin(this, this.origin);
+}
+
+entity viewmodel;
+STATIC_INIT(viewmodel) {
+ viewmodel = new(viewmodel);
+ make_pure(viewmodel);
+ viewmodel.draw = viewmodel_draw;
+}
+
entity porto;
vector polyline[16];
void Porto_Draw(entity this)
return SHOTTYPE_HITWORLD;
if(n > maxclients)
return SHOTTYPE_HITWORLD;
- t = GetPlayerColor(n - 1);
+ t = entcs_GetTeam(n - 1);
if(teamplay)
if(t == myteam)
return SHOTTYPE_HITTEAM;
vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * getstati(STAT_VIEWHEIGHT));
- vecs = decompressShotOrigin(getstati(STAT_SHOTORG));
+ vecs = decompressShotOrigin(STAT(SHOTORG));
traceline(traceorigin, traceorigin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
trueaimpoint = trace_endpos;
{
// accumulate damage with each stat update
static float damage_total_prev = 0;
- float damage_total = getstati(STAT_DAMAGE_DEALT_TOTAL);
+ float damage_total = STAT(DAMAGE_DEALT_TOTAL);
float unaccounted_damage_new = COMPARE_INCREASING(damage_total, damage_total_prev);
damage_total_prev = damage_total;
static float damage_dealt_time_prev = 0;
- float damage_dealt_time = getstatf(STAT_HIT_TIME);
+ float damage_dealt_time = STAT(HIT_TIME);
if (damage_dealt_time != damage_dealt_time_prev)
{
unaccounted_damage += unaccounted_damage_new;
}
static float typehit_time_prev = 0;
- float typehit_time = getstatf(STAT_TYPEHIT_TIME);
+ float typehit_time = STAT(TYPEHIT_TIME);
if (COMPARE_INCREASING(typehit_time, typehit_time_prev) > autocvar_cl_hitsound_antispam_time)
{
sound(world, CH_INFO, SND_TYPEHIT, VOL_BASE, ATTN_NONE);
if(autocvar_crosshair_pickup)
{
- float stat_pickup_time = getstatf(STAT_LAST_PICKUP);
+ float stat_pickup_time = STAT(LAST_PICKUP);
if(pickup_crosshair_time < stat_pickup_time)
{
ring_scale = autocvar_crosshair_ring_size;
float weapon_clipload, weapon_clipsize;
- weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);
- weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);
+ weapon_clipload = STAT(WEAPON_CLIPLOAD);
+ weapon_clipsize = STAT(WEAPON_CLIPSIZE);
float ok_ammo_charge, ok_ammo_chargepool;
- ok_ammo_charge = getstatf(STAT_OK_AMMO_CHARGE);
- ok_ammo_chargepool = getstatf(STAT_OK_AMMO_CHARGEPOOL);
+ ok_ammo_charge = STAT(OK_AMMO_CHARGE);
+ ok_ammo_chargepool = STAT(OK_AMMO_CHARGEPOOL);
float vortex_charge, vortex_chargepool;
- vortex_charge = getstatf(STAT_VORTEX_CHARGE);
- vortex_chargepool = getstatf(STAT_VORTEX_CHARGEPOOL);
+ vortex_charge = STAT(VORTEX_CHARGE);
+ vortex_chargepool = STAT(VORTEX_CHARGEPOOL);
float arc_heat = STAT(ARC_HEAT);
}
else if (autocvar_crosshair_ring && activeweapon == WEP_MINE_LAYER.m_id && minelayer_maxmines && autocvar_crosshair_ring_minelayer)
{
- ring_value = bound(0, getstati(STAT_LAYED_MINES) / minelayer_maxmines, 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.
+ ring_value = bound(0, STAT(LAYED_MINES) / minelayer_maxmines, 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.
ring_alpha = autocvar_crosshair_ring_minelayer_alpha;
ring_rgb = wcross_color;
ring_image = "gfx/crosshair_ring.tga";
}
- else if (activeweapon == WEP_HAGAR.m_id && getstati(STAT_HAGAR_LOAD) && autocvar_crosshair_ring_hagar)
+ else if (activeweapon == WEP_HAGAR.m_id && STAT(HAGAR_LOAD) && autocvar_crosshair_ring_hagar)
{
- ring_value = bound(0, getstati(STAT_HAGAR_LOAD) / hagar_maxrockets, 1);
+ ring_value = bound(0, STAT(HAGAR_LOAD) / hagar_maxrockets, 1);
ring_alpha = autocvar_crosshair_ring_hagar_alpha;
ring_rgb = wcross_color;
ring_image = "gfx/crosshair_ring.tga";
rgb = MUTATOR_ARGV(0, vector);
a = MUTATOR_ARGV(0, float);
}
- else if(getstati(STAT_FROZEN))
+ else if(STAT(FROZEN))
{
- rgb = ((getstatf(STAT_REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * getstatf(STAT_REVIVE_PROGRESS)) + ('0 1 1' * getstatf(STAT_REVIVE_PROGRESS) * -1)) : '0.25 0.90 1');
+ rgb = ((STAT(REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * STAT(REVIVE_PROGRESS)) + ('0 1 1' * STAT(REVIVE_PROGRESS) * -1)) : '0.25 0.90 1');
}
drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, rgb, autocvar_hud_colorflash_alpha * a, DRAWFLAG_ADDITIVE);
if(!intermission)
- if(getstatf(STAT_NADE_TIMER) && autocvar_cl_nade_timer) // give nade top priority, as it's a matter of life and death
+ if(STAT(NADE_TIMER) && autocvar_cl_nade_timer) // give nade top priority, as it's a matter of life and death
{
- DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", getstatf(STAT_NADE_TIMER), '0.25 0.90 1' + ('1 0 0' * getstatf(STAT_NADE_TIMER)) - ('0 1 1' * getstatf(STAT_NADE_TIMER)), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
+ DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(NADE_TIMER), '0.25 0.90 1' + ('1 0 0' * STAT(NADE_TIMER)) - ('0 1 1' * STAT(NADE_TIMER)), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
drawstring_aspect(eY * 0.64 * vid_conheight, ((autocvar_cl_nade_timer == 2) ? _("Nade timer") : ""), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL);
}
- else if(getstatf(STAT_REVIVE_PROGRESS))
+ else if(STAT(REVIVE_PROGRESS))
{
- DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", getstatf(STAT_REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
+ DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE);
drawstring_aspect(eY * 0.64 * vid_conheight, _("Revival progress"), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL);
}
++framecount;
stats_get();
- hud = getstati(STAT_HUD);
+ hud = STAT(HUD);
if(hud != HUD_NORMAL && lasthud == HUD_NORMAL)
vh_notice_time = time + autocvar_cl_vehicles_notify_time;
current_player = player_localentnum - 1;
else // then player_localentnum is the vehicle I'm driving
current_player = player_localnum;
- myteam = GetPlayerColor(current_player);
+ myteam = entcs_GetTeam(current_player);
if(myteam != prev_myteam)
{
prev_myteam = myteam;
}
- ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+ ticrate = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
float is_dead = (getstati(STAT_HEALTH) <= 0);
if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped
{
float vehicle_chase = (hud != HUD_NORMAL && (autocvar_cl_eventchase_vehicle || spectatee_status > 0));
- float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && getstati(STAT_ROUNDLOST));
+ float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && STAT(ROUNDLOST));
entity gen = world;
if(ons_roundlost)
ColorTranslateMode = autocvar_cl_stripcolorcodes;
// currently switching-to weapon (for crosshair)
- switchingweapon = getstati(STAT_SWITCHINGWEAPON);
+ switchingweapon = STAT(SWITCHINGWEAPON);
// actually active weapon (for zoom)
activeweapon = getstati(STAT_ACTIVEWEAPON);
}
}
- if(autocvar_hud_damage && !getstati(STAT_FROZEN))
+ if(autocvar_hud_damage && !STAT(FROZEN))
{
splash_size.x = max(vid_conwidth, vid_conheight);
splash_size.y = max(vid_conwidth, vid_conheight);
{
// self.move_flags &= ~FL_ONGROUND;
if (self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
- Movetype_Physics_NoMatchServer();
+ Movetype_Physics_NoMatchServer(self);
// the trivial movetypes do not have to match the
// server's ticrate as they are ticrate independent
// NOTE: this assumption is only true if MOVETYPE_FLY
// projectiles detonate on impact. If they continue
// moving, we might still be ticrate dependent.
else
- Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+ Movetype_Physics_MatchServer(self, autocvar_cl_projectiles_sloppy);
if (!(self.move_flags & FL_ONGROUND))
if (self.velocity != '0 0 0')
self.move_angles = self.angles = vectoangles(self.velocity);
self.traileffect = 0;
switch (self.cnt)
{
- #define CASE(id) case PROJECTILE_##id: setmodel(self, MDL_PROJECTILE_##id);
- CASE(ELECTRO) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
- CASE(ROCKET) self.traileffect = EFFECT_TR_ROCKET.m_id; self.scale = 2; break;
- CASE(CRYLINK) self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
- CASE(CRYLINK_BOUNCING) self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
- CASE(ELECTRO_BEAM) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
- CASE(GRENADE) self.traileffect = EFFECT_TR_GRENADE.m_id; break;
- CASE(GRENADE_BOUNCING) self.traileffect = EFFECT_TR_GRENADE.m_id; break;
- CASE(MINE) self.traileffect = EFFECT_TR_GRENADE.m_id; break;
- CASE(BLASTER) self.traileffect = EFFECT_Null.m_id; break;
- CASE(HLAC) self.traileffect = EFFECT_Null.m_id; break;
- CASE(PORTO_RED) self.traileffect = EFFECT_TR_WIZSPIKE.m_id; self.scale = 4; break;
- CASE(PORTO_BLUE) self.traileffect = EFFECT_TR_WIZSPIKE.m_id; self.scale = 4; break;
- CASE(HOOKBOMB) self.traileffect = EFFECT_TR_KNIGHTSPIKE.m_id; break;
- CASE(HAGAR) self.traileffect = EFFECT_HAGAR_ROCKET.m_id; self.scale = 0.75; break;
- CASE(HAGAR_BOUNCING) self.traileffect = EFFECT_HAGAR_ROCKET.m_id; self.scale = 0.75; break;
- CASE(FIREBALL) self.modelindex = 0; self.traileffect = EFFECT_FIREBALL.m_id; break; // particle effect is good enough
- CASE(FIREMINE) self.modelindex = 0; self.traileffect = EFFECT_FIREMINE.m_id; break; // particle effect is good enough
- CASE(TAG) self.traileffect = EFFECT_TR_ROCKET.m_id; break;
- CASE(FLAC) self.scale = 0.4; self.traileffect = EFFECT_FLAC_TRAIL.m_id; break;
- CASE(SEEKER) self.traileffect = EFFECT_SEEKER_TRAIL.m_id; break;
-
- CASE(MAGE_SPIKE) self.traileffect = EFFECT_TR_VORESPIKE.m_id; break;
- CASE(SHAMBLER_LIGHTNING) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
-
- CASE(RAPTORBOMB) self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = EFFECT_Null.m_id; break;
- CASE(RAPTORBOMBLET) self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = EFFECT_Null.m_id; break;
- CASE(RAPTORCANNON) self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
-
- CASE(SPIDERROCKET) self.traileffect = EFFECT_SPIDERBOT_ROCKET_TRAIL.m_id; break;
- CASE(WAKIROCKET) self.traileffect = EFFECT_RACER_ROCKET_TRAIL.m_id; break;
- CASE(WAKICANNON) self.traileffect = EFFECT_Null.m_id; break;
-
- CASE(BUMBLE_GUN) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
- CASE(BUMBLE_BEAM) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
-
- CASE(RPC) self.traileffect = EFFECT_TR_ROCKET.m_id; break;
-
- CASE(ROCKETMINSTA_LASER) self.traileffect = EFFECT_ROCKETMINSTA_LASER(self.team).m_id; break;
-#undef CASE
+ #define HANDLE(id) case PROJECTILE_##id: setmodel(self, MDL_PROJECTILE_##id);
+ HANDLE(ELECTRO) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+ HANDLE(ROCKET) self.traileffect = EFFECT_TR_ROCKET.m_id; self.scale = 2; break;
+ HANDLE(CRYLINK) self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
+ HANDLE(CRYLINK_BOUNCING) self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
+ HANDLE(ELECTRO_BEAM) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+ HANDLE(GRENADE) self.traileffect = EFFECT_TR_GRENADE.m_id; break;
+ HANDLE(GRENADE_BOUNCING) self.traileffect = EFFECT_TR_GRENADE.m_id; break;
+ HANDLE(MINE) self.traileffect = EFFECT_TR_GRENADE.m_id; break;
+ HANDLE(BLASTER) self.traileffect = EFFECT_Null.m_id; break;
+ HANDLE(HLAC) self.traileffect = EFFECT_Null.m_id; break;
+ HANDLE(PORTO_RED) self.traileffect = EFFECT_TR_WIZSPIKE.m_id; self.scale = 4; break;
+ HANDLE(PORTO_BLUE) self.traileffect = EFFECT_TR_WIZSPIKE.m_id; self.scale = 4; break;
+ HANDLE(HOOKBOMB) self.traileffect = EFFECT_TR_KNIGHTSPIKE.m_id; break;
+ HANDLE(HAGAR) self.traileffect = EFFECT_HAGAR_ROCKET.m_id; self.scale = 0.75; break;
+ HANDLE(HAGAR_BOUNCING) self.traileffect = EFFECT_HAGAR_ROCKET.m_id; self.scale = 0.75; break;
+ HANDLE(FIREBALL) self.modelindex = 0; self.traileffect = EFFECT_FIREBALL.m_id; break; // particle effect is good enough
+ HANDLE(FIREMINE) self.modelindex = 0; self.traileffect = EFFECT_FIREMINE.m_id; break; // particle effect is good enough
+ HANDLE(TAG) self.traileffect = EFFECT_TR_ROCKET.m_id; break;
+ HANDLE(FLAC) self.scale = 0.4; self.traileffect = EFFECT_FLAC_TRAIL.m_id; break;
+ HANDLE(SEEKER) self.traileffect = EFFECT_SEEKER_TRAIL.m_id; break;
+
+ HANDLE(MAGE_SPIKE) self.traileffect = EFFECT_TR_VORESPIKE.m_id; break;
+ HANDLE(SHAMBLER_LIGHTNING) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+
+ HANDLE(RAPTORBOMB) self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = EFFECT_Null.m_id; break;
+ HANDLE(RAPTORBOMBLET) self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = EFFECT_Null.m_id; break;
+ HANDLE(RAPTORCANNON) self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
+
+ HANDLE(SPIDERROCKET) self.traileffect = EFFECT_SPIDERBOT_ROCKET_TRAIL.m_id; break;
+ HANDLE(WAKIROCKET) self.traileffect = EFFECT_RACER_ROCKET_TRAIL.m_id; break;
+ HANDLE(WAKICANNON) self.traileffect = EFFECT_Null.m_id; break;
+
+ HANDLE(BUMBLE_GUN) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+ HANDLE(BUMBLE_BEAM) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+
+ HANDLE(RPC) self.traileffect = EFFECT_TR_ROCKET.m_id; break;
+
+ HANDLE(ROCKETMINSTA_LASER) self.traileffect = EFFECT_ROCKETMINSTA_LASER(self.team).m_id; break;
+#undef HANDLE
default:
if (MUTATOR_CALLHOOK(Ent_Projectile, self))
break;
--- /dev/null
+#include "anim.qh"
+
+/**
+ * @param anim x = startframe, y = numframes, z = framerate
+ */
+void anim_set(entity e, vector anim, bool looping, bool override, bool restart)
+{
+ if (!anim) return; // no animation was given to us! We can't use this.
+
+ if (anim.x == e.animstate_startframe)
+ {
+ if (anim.y == e.animstate_numframes)
+ {
+ if (anim.z == e.animstate_framerate)
+ {
+ if (!restart) return;
+ if (anim.y == 1) // ZYM animation
+ BITXOR_ASSIGN(e.effects, EF_RESTARTANIM_BIT);
+ }
+ }
+ }
+ e.animstate_startframe = anim.x;
+ e.animstate_numframes = anim.y;
+ e.animstate_framerate = anim.z;
+ e.animstate_starttime = time - 0.1 * frametime; // shift it a little bit into the past to prevent float inaccuracy hiccups
+ e.animstate_endtime = e.animstate_starttime + e.animstate_numframes / e.animstate_framerate;
+ e.animstate_looping = looping;
+ e.animstate_override = override;
+ e.frame = e.animstate_startframe;
+ e.frame1time = time;
+}
+
+/**
+ * Update e.frame based on its animstate relative to time
+ */
+void anim_update(entity e)
+{
+ if (time >= e.animstate_endtime)
+ {
+ if (e.animstate_looping)
+ {
+ e.animstate_starttime = e.animstate_endtime;
+ e.animstate_endtime = e.animstate_starttime + e.animstate_numframes / e.animstate_framerate;
+ }
+ e.animstate_override = false;
+ }
+ float frameofs = bound(0, (time - e.animstate_starttime) * e.animstate_framerate, e.animstate_numframes - 1);
+ e.frame = e.animstate_startframe + frameofs;
+}
--- /dev/null
+#ifndef ANIM_H
+#define ANIM_H
+
+// begin engine fields
+
+/** primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4) */
+.float frame;
+/** secondary framegroup animation (strength = lerpfrac) */
+.float frame2;
+/** tertiary framegroup animation (strength = lerpfrac3) */
+.float frame3;
+/** quaternary framegroup animation (strength = lerpfrac4) */
+.float frame4;
+
+/** strength of framegroup blend */
+.float lerpfrac;
+/** strength of framegroup blend */
+.float lerpfrac3;
+/** strength of framegroup blend */
+.float lerpfrac4;
+
+/** start time of framegroup animation */
+.float frame1time;
+/** start time of framegroup animation */
+.float frame2time;
+/** start time of framegroup animation */
+.float frame3time;
+/** start time of framegroup animation */
+.float frame4time;
+
+// end engine fields
+
+// player animation state
+
+.int animstate_startframe;
+.int animstate_numframes;
+.float animstate_framerate;
+.float animstate_starttime;
+.float animstate_endtime;
+/** whether to repeat */
+.bool animstate_looping;
+/** true for one cycle, then changed to false */
+.bool animstate_override;
+
+void anim_set(entity e, vector anim, bool looping, bool override, bool restart);
+#define setanim(...) anim_set(__VA_ARGS__)
+void anim_update(entity e);
+#define updateanim(...) anim_update(__VA_ARGS__)
+
+#endif
// not so constant
-#ifdef SVQC
-#define PL_VIEW_OFS autocvar_sv_player_viewoffset
-#define PL_MIN autocvar_sv_player_mins
-#define PL_MAX autocvar_sv_player_maxs
-#define PL_CROUCH_VIEW_OFS autocvar_sv_player_crouch_viewoffset
-#define PL_CROUCH_MIN autocvar_sv_player_crouch_mins
-#define PL_CROUCH_MAX autocvar_sv_player_crouch_maxs
-#define PL_HEAD autocvar_sv_player_headsize
-#elif defined(CSQC)
-#define PL_VIEW_OFS vec3(getstatf(STAT_PL_VIEW_OFS1), getstatf(STAT_PL_VIEW_OFS2), getstatf(STAT_PL_VIEW_OFS3))
-#define PL_MIN vec3(getstatf(STAT_PL_MIN1), getstatf(STAT_PL_MIN2), getstatf(STAT_PL_MIN3))
-#define PL_MAX vec3(getstatf(STAT_PL_MAX1), getstatf(STAT_PL_MAX2), getstatf(STAT_PL_MAX3))
-#define PL_CROUCH_VIEW_OFS vec3(getstatf(STAT_PL_CROUCH_VIEW_OFS1), getstatf(STAT_PL_CROUCH_VIEW_OFS2), getstatf(STAT_PL_CROUCH_VIEW_OFS3))
-#define PL_CROUCH_MIN vec3(getstatf(STAT_PL_CROUCH_MIN1), getstatf(STAT_PL_CROUCH_MIN2), getstatf(STAT_PL_CROUCH_MIN3))
-#define PL_CROUCH_MAX vec3(getstatf(STAT_PL_CROUCH_MAX1), getstatf(STAT_PL_CROUCH_MAX2), getstatf(STAT_PL_CROUCH_MAX3))
-#endif
+#define PL_VIEW_OFS STAT(PL_VIEW_OFS, NULL)
+#define PL_CROUCH_VIEW_OFS STAT(PL_CROUCH_VIEW_OFS, NULL)
+#define PL_MIN STAT(PL_MIN, NULL)
+#define PL_CROUCH_MIN STAT(PL_CROUCH_MIN, NULL)
+#define PL_MAX STAT(PL_MAX, NULL)
+#define PL_CROUCH_MAX STAT(PL_CROUCH_MAX, NULL)
// a bit more constant
const vector PL_MAX_CONST = '16 16 45';
# define TAG_VIEWLOC_NAME tag_networkviewloc
# define TAG_VIEWLOC_TYPE int
.float tag_networkviewloc;
+
+# define MOVETYPE_NAME move_movetype
#else
# define TAG_ENTITY_NAME tag_entity
# define TAG_ENTITY_TYPE entity
# define TAG_VIEWLOC_NAME viewloc
# define TAG_VIEWLOC_TYPE entity
+
+# define MOVETYPE_NAME movetype
#endif
// new fields
CSQCMODEL_PROPERTY_SCALED(BIT(12), float, ReadByte, WriteByte, scale, 16, 0, 255) \
CSQCMODEL_PROPERTY(BIT(13), int, ReadInt24_t, WriteInt24_t, dphitcontentsmask) \
CSQCMODEL_PROPERTY(BIT(14), TAG_VIEWLOC_TYPE, ReadShort, WriteEntity, TAG_VIEWLOC_NAME) \
- CSQCMODEL_PROPERTY(BIT(15), int, ReadByte, WriteByte, multijump_count)
+ CSQCMODEL_PROPERTY(BIT(15), int, ReadByte, WriteByte, multijump_count) \
+ CSQCMODEL_PROPERTY(BIT(16), int, ReadByte, WriteByte, MOVETYPE_NAME)
// TODO get rid of colormod/glowmod here, find good solution for vortex charge glowmod hack; also get rid of some useless properties on non-players that only exist for CopyBody
// add hook function calls here
self.flags &= ~FL_ONGROUND;
}
- Movetype_Physics_MatchTicrate(autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
+ Movetype_Physics_MatchTicrate(self, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
if (wasfreed(self))
return; // deleted by touch function
vector oldorg;
oldorg = self.origin;
- Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+ Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
if(wasfreed(self))
return;
*/
void globalsound(int channel, entity from, entity gs, float r, int chan, float vol, float atten)
{
+ assert(IS_PLAYER(from), eprint(from));
if (channel == MSG_ONE && !IS_REAL_CLIENT(msg_entity)) return;
WriteHeader(channel, globalsound);
WriteByte(channel, gs.m_id);
WriteByte(channel, r * 255);
WriteByte(channel, etof(from));
- WriteByte(channel, fabs(chan));
+ WriteByte(channel, chan);
WriteByte(channel, floor(vol * 255));
WriteByte(channel, floor(atten * 64));
entcs_force_origin(from);
*/
void playersound(int channel, entity from, entity ps, float r, int chan, float vol, float atten)
{
+ assert(IS_PLAYER(from), eprint(from));
if (channel == MSG_ONE && !IS_REAL_CLIENT(msg_entity)) return;
WriteHeader(channel, playersound);
WriteByte(channel, ps.m_id);
WriteByte(channel, r * 255);
WriteByte(channel, etof(from));
- WriteByte(channel, fabs(chan));
+ WriteByte(channel, chan);
WriteByte(channel, floor(vol * 255));
WriteByte(channel, floor(atten * 64));
entcs_force_origin(from);
int who = ReadByte();
entity e = entcs_receiver(who - 1);
int chan = ReadByte();
+ chan = (chan & BIT(7) ? -1 : 1) * (chan & BITS(7));
float vol = ReadByte() / 255;
float atten = ReadByte() / 64;
vector o;
}
else
{
- entity e = new(globalsound);
- e.origin = o;
+ // Can this happen?
+ LOG_WARNINGF("Missing entcs data for player %d\n", who);
sound8(e, o, chan, sample, vol, atten, 0, 0);
- remove(e); // debug with: e.think = SUB_Remove; e.nextthink = time + 1;
}
return true;
}
string s = e.(ps.m_playersoundfld);
string sample = GlobalSound_sample(s, r);
int chan = ReadByte();
+ chan = (chan & BIT(7) ? -1 : 1) * (chan & BITS(7));
float vol = ReadByte() / 255;
float atten = ReadByte() / 64;
vector o;
}
else
{
- LOG_WARNINGF("Missing entcs data for player %d\n", who);
// Can this happen?
- entity e = new(playersound);
- e.origin = o;
+ LOG_WARNINGF("Missing entcs data for player %d\n", who);
sound8(e, o, chan, sample, vol, atten, 0, 0);
- remove(e); // debug with: e.think = SUB_Remove; e.nextthink = time + 1;
}
return true;
}
#ifdef SVQC
- void _GlobalSound(entity gs, entity ps, string sample, int chan, int voicetype, bool fake)
+ void _GlobalSound(entity this, entity gs, entity ps, string sample, int chan, int voicetype, bool fake)
{
- SELFPARAM();
if (gs == NULL && ps == NULL && sample == "") return;
float r = random();
if (sample != "") sample = GlobalSound_sample(sample, r);
#ifdef SVQC
- void _GlobalSound(entity gs, entity ps, string sample, float chan, float voicetype, bool fake);
- #define GlobalSound(def, chan, voicetype) _GlobalSound(def, NULL, string_null, chan, voicetype, false)
- #define GlobalSound_string(def, chan, voicetype) _GlobalSound(NULL, NULL, def, chan, voicetype, false)
- #define PlayerSound(def, chan, voicetype) _GlobalSound(NULL, def, string_null, chan, voicetype, false)
- #define VoiceMessage(def, msg) \
+ void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float voicetype, bool fake);
+ #define GlobalSound(this, def, chan, voicetype) _GlobalSound(this, def, NULL, string_null, chan, voicetype, false)
+ #define GlobalSound_string(this, def, chan, voicetype) _GlobalSound(this, NULL, NULL, def, chan, voicetype, false)
+ #define PlayerSound(thise, def, chan, voicetype) _GlobalSound(this, NULL, def, string_null, chan, voicetype, false)
+ #define VoiceMessage(this, def, msg) \
do \
{ \
entity VM = def; \
if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
else if (flood > 0) fake = false; \
else break; \
- _GlobalSound(NULL, VM, string_null, CH_VOICE, voicetype, fake); \
+ _GlobalSound(this, NULL, VM, string_null, CH_VOICE, voicetype, fake); \
} \
while (0)
bool entcs_send(entity this, entity to, int sf)
{
entity player = this.owner;
- sf |= 1;
+ sf |= BIT(0) | BIT(1);
if (IS_PLAYER(to) || to.caplayer) // unless spectating,
{
bool same_team = (to == player) || (teamplay && player.team == to.team);
void entcs_think()
{
SELFPARAM();
- this.nextthink = time;
- entity e = CSQCModel_server2csqc(this.sv_entnum + 1);
- bool exists = e != NULL;
- if (exists)
+ entity e = CSQCModel_server2csqc(this.sv_entnum);
+ if (e == NULL)
{
- this.has_origin = true;
- this.origin = e.origin;
- // `cl_forceplayermodels 1` sounds will be wrong until the player has been in the PVS, but so be it
- if (this.model != e.model)
- {
- if (this.model) strunzone(this.model);
- this.model = strzone(e.model);
- }
+ this.has_origin = this.has_sv_origin;
+ return;
}
- else
+ this.has_origin = true;
+ this.origin = e.origin;
+ // `cl_forceplayermodels 1` sounds will be wrong until the player has been in the PVS, but so be it
+ if (this.model != e.model)
{
- this.has_origin = this.has_sv_origin;
+ if (this.model) strunzone(this.model);
+ this.model = strzone(e.model);
}
}
this.classname = "entcs_receiver";
this.entremove = Ent_RemoveEntCS;
this.think = entcs_think;
- this.nextthink = time;
}
InterpolateOrigin_Undo(this);
int sf = ReadShort();
this.has_sv_origin = false;
- this.m_entcs_private = boolean(sf & 1);
+ this.m_entcs_private = boolean(sf & BIT(0));
int i = 1;
#define X(public, fld, sv, cl) { if (sf & BIT(i)) cl; } i += 1;
ENTCS_NETPROPS(X);
entcs_receiver(this.sv_entnum, this);
this.iflags |= IFLAG_ORIGIN;
InterpolateOrigin_Note(this);
+ this.think();
return true;
}
.bool has_sv_origin;
#ifdef SVQC
-/**
+/*
* The point of these entities is to avoid the problems
* with clientprediction.
* If you add SendEntity to players, the engine will not
* in onslaught... YAY ;)
*/
-.entity entcs;
+ .entity entcs;
-bool entcs_send(entity this, entity to, int sf);
+ bool entcs_send(entity this, entity to, int sf);
-void entcs_think();
+ void entcs_think();
-void entcs_attach(entity e);
+ void entcs_attach(entity e);
-void entcs_detach(entity e);
+ void entcs_detach(entity e);
-.int m_forceupdate;
+ .int m_forceupdate;
/** Force an origin update, for player sounds */
-#define entcs_force_origin(e) ((e).entcs.m_forceupdate = BIT(2))
+ #define entcs_force_origin(e) ((e).entcs.m_forceupdate = BIT(2))
#endif
#ifdef CSQC
-AL_declare(_entcs);
-STATIC_INIT(_entcs)
-{
- AL_init(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
-}
-SHUTDOWN(_entcs)
-{
- AL_delete(_entcs);
-}
-#define entcs_receiver(...) EVAL(OVERLOAD(entcs_receiver, __VA_ARGS__))
-#define entcs_receiver_1(i) AL_gete(_entcs, i)
-#define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
-#define entcs_is_self(e) ((e).sv_entnum + 1 == player_localentnum)
+ AL_declare(_entcs);
+ STATIC_INIT(_entcs)
+ {
+ AL_init(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
+ }
+ SHUTDOWN(_entcs)
+ {
+ AL_delete(_entcs);
+ }
+ #define entcs_receiver(...) EVAL(OVERLOAD(entcs_receiver, __VA_ARGS__))
+ #define entcs_receiver_1(i) AL_gete(_entcs, i)
+ #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
+ #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
+
+ /**
+ * @param i zero indexed player
+ */
+ bool entcs_IsSpectating(int i)
+ {
+ bool unconnected = !playerslots[i].gotscores;
+ return unconnected || stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR;
+ }
+
+ /**
+ * @param i zero indexed player
+ * @returns 0 if not teamplay
+ */
+ int entcs_GetTeamColor(int i)
+ {
+ return (!teamplay) ? 0 : stof(getplayerkeyvalue(i, "colors")) & 15;
+ }
+
+ /**
+ * @param i zero indexed player
+ * @returns 0 if not teamplay | NUM_TEAM_##N | NUM_SPECTATOR
+ */
+ int entcs_GetTeam(int i)
+ {
+ return entcs_IsSpectating(i) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
+ }
+
+ /**
+ * @param i zero indexed player
+ */
+ string entcs_GetName(int i)
+ {
+ return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
+ }
+
+ /**
+ * @param i zero indexed player
+ */
+ entity CSQCModel_server2csqc(int i);
+
+ .float alpha;
+
+ /**
+ * @param i zero indexed player
+ */
+ float entcs_GetAlpha(int i)
+ {
+ entity e = CSQCModel_server2csqc(i);
+ return e ? e.alpha : 1;
+ }
+
+ /**
+ * @param i zero indexed player
+ */
+ vector entcs_GetColor(int i)
+ {
+ entity e = CSQCModel_server2csqc(i);
+ return (!e || e.colormap <= 0)
+ ? '1 1 1'
+ : colormapPaletteColor(((e.colormap >= 1024)
+ ? e.colormap
+ : stof(getplayerkeyvalue(e.colormap - 1, "colors"))) & 15, true)
+ ;
+ }
+
+ /**
+ * @param i zero indexed player
+ */
+ bool entcs_IsDead(int i)
+ {
+ entity e = CSQCModel_server2csqc(i);
+ return e ? e.csqcmodel_isdead : false;
+ }
#endif
#ifdef IMPLEMENTATION
#ifdef SVQC
-.float metertime;
+.float metertime = _STAT(NB_METERSTART);
int autocvar_g_nexball_goalleadlimit;
#define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit")
if(g_nexball_meter_period <= 0)
g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
- addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
// General settings
/*
.float teleport_antispam;
-.bool ons_roundlost;
+.bool ons_roundlost = _STAT(ROUNDLOST);
// waypoint sprites
.entity bot_basewaypoint; // generator waypointsprite
g_onslaught = true;
ons_captureshield_force = autocvar_g_onslaught_shield_force;
- addstat(STAT_ROUNDLOST, AS_INT, ons_roundlost);
-
InitializeEntity(world, ons_DelayedInit, INITPRIO_GAMETYPE);
}
minigame_read_owner();
float ent = ReadLong();
self.minigame_playerslot = ent;
- LOG_DEBUG("Player: ",GetPlayerName(ent-1),"\n");
+ LOG_DEBUG("Player: ",entcs_GetName(ent-1),"\n");
activate = (ent == player_localnum+1 && self.owner && self.owner != active_minigame);
entity prev = self;
for(int i = 0; i < maxclients; ++i)
{
- if ( player_localnum != i && playerslots[i] && GetPlayerName(i) != "" &&
+ if ( player_localnum != i && playerslots[i] && entcs_GetName(i) != "" &&
!findfloat(world,minigame_playerslot,i+1) && playerslots[i].ping )
{
e = HUD_MinigameMenu_SpawnSubEntry(
- strzone(GetPlayerName(i)), HUD_MinigameMenu_ClickInvite_Entry,
+ strzone(entcs_GetName(i)), HUD_MinigameMenu_ClickInvite_Entry,
self );
e.flags |= 1;
e.netname = strzone(ftos(i+1));
{
mypos = pos;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
return false;
}
-#endif
\ No newline at end of file
+#endif
FOREACH_MINIGAME_ENTITY(e)
if ( e.classname == "minigame_player" &&
e.team == (active_minigame.minigame_flags & C4_TURN_TEAM) )
- playername = GetPlayerName(e.minigame_playerslot-1);
+ playername = entcs_GetName(e.minigame_playerslot-1);
vector win_pos = pos+eY*(mySize_y-winfs_y)/2;
vector win_sz;
if ( e.team == 2 )
mypos_y += player_fontsize_y + ts_y;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
FOREACH_MINIGAME_ENTITY(e)
if ( e.classname == "minigame_player" &&
e.team == (active_minigame.minigame_flags & NMM_TURN_TEAM) )
- playername = GetPlayerName(e.minigame_playerslot-1);
+ playername = entcs_GetName(e.minigame_playerslot-1);
vector win_pos = pos+eY*(mySize_y-winfs_y)/2;
vector win_sz;
if ( e.team == 2 )
mypos_y += player_fontsize_y + ts_y;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
}
else if ( e.classname == "minigame_board_piece" )
drawfill(mypos, ts, pong_team_to_color(e.team), 0.25, DRAWFLAG_ADDITIVE);
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- (e.minigame_playerslot ? GetPlayerName(e.minigame_playerslot-1) : _("AI")),
+ (e.minigame_playerslot ? entcs_GetName(e.minigame_playerslot-1) : _("AI")),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
drawstring(mypos+eY*player_fontsize_y,ftos(e.pong_score),'48 48 0',
FOREACH_MINIGAME_ENTITY(e)
if ( e.classname == "minigame_player" &&
e.team == (active_minigame.minigame_flags & PP_TURN_TEAM) )
- playername = GetPlayerName(e.minigame_playerslot-1);
+ playername = entcs_GetName(e.minigame_playerslot-1);
vector win_pos = pos+eY*(mySize_y-winfs_y)/2;
vector win_sz;
if ( e.team == 2 )
mypos_y += player_fontsize_y + ts_y;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
{
mypos = pos;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
if ( e.team > 1 )
mypos_y += player_fontsize_y + (ts_y * (e.team - 1));
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
vector tile_color = snake_teamcolor(e.team);
return false;
}
-#endif
\ No newline at end of file
+#endif
if ( e.team == 2 )
mypos_y += player_fontsize_y + ts_y;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- (e.minigame_playerslot ? GetPlayerName(e.minigame_playerslot-1) : _("AI")),
+ (e.minigame_playerslot ? entcs_GetName(e.minigame_playerslot-1) : _("AI")),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
if(delaytoo)
if(time < self.msound_delay)
return; // too early
- GlobalSound_string(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
+ GlobalSound_string(self, self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
self.msound_delay = time + sound_delay;
}
-void _Movetype_Physics_Follow() // SV_Physics_Follow
-{SELFPARAM();
- entity e = self.move_aiment; // TODO: networking?
+void _Movetype_Physics_Follow(entity this) // SV_Physics_Follow
+{
+ entity e = this.move_aiment; // TODO: networking?
// LordHavoc: implemented rotation on MOVETYPE_FOLLOW objects
- if(self.move_angles == self.move_punchangle)
+ if(this.move_angles == this.move_punchangle)
{
- self.move_origin = e.move_origin + self.view_ofs;
+ this.move_origin = e.move_origin + this.view_ofs;
}
else
{
vector ang, v;
- ang_x = -self.move_punchangle_x;
- ang_y = self.move_punchangle_y;
- ang_z = self.move_punchangle_z;
+ ang_x = -this.move_punchangle_x;
+ ang_y = this.move_punchangle_y;
+ ang_z = this.move_punchangle_z;
makevectors(ang);
- v_x = self.view_ofs_x * v_forward_x + self.view_ofs_y * v_right_x + self.view_ofs_z * v_up_x;
- v_y = self.view_ofs_x * v_forward_y + self.view_ofs_y * v_right_y + self.view_ofs_z * v_up_y;
- v_z = self.view_ofs_x * v_forward_z + self.view_ofs_y * v_right_z + self.view_ofs_z * v_up_z;
+ v_x = this.view_ofs_x * v_forward_x + this.view_ofs_y * v_right_x + this.view_ofs_z * v_up_x;
+ v_y = this.view_ofs_x * v_forward_y + this.view_ofs_y * v_right_y + this.view_ofs_z * v_up_y;
+ v_z = this.view_ofs_x * v_forward_z + this.view_ofs_y * v_right_z + this.view_ofs_z * v_up_z;
ang_x = -e.move_angles_x;
ang_y = e.move_angles_y;
ang_z = e.move_angles_z;
makevectors(ang);
- self.move_origin_x = v_x * v_forward_x + v_y * v_forward_y + v_z * v_forward_z + e.move_origin_x;
- self.move_origin_x = v_x * v_right_x + v_y * v_right_y + v_z * v_right_z + e.move_origin_y;
- self.move_origin_x = v_x * v_up_x + v_y * v_up_y + v_z * v_up_z + e.move_origin_z;
+ this.move_origin_x = v_x * v_forward_x + v_y * v_forward_y + v_z * v_forward_z + e.move_origin_x;
+ this.move_origin_x = v_x * v_right_x + v_y * v_right_y + v_z * v_right_z + e.move_origin_y;
+ this.move_origin_x = v_x * v_up_x + v_y * v_up_y + v_z * v_up_z + e.move_origin_z;
}
- self.move_angles = e.move_angles + self.v_angle;
- _Movetype_LinkEdict(false);
+ this.move_angles = e.move_angles + this.v_angle;
+ _Movetype_LinkEdict(this, false);
}
#include "../../server/autocvars.qh"
#endif
-void _Movetype_WallFriction(vector stepnormal) // SV_WallFriction
+void _Movetype_WallFriction(entity this, vector stepnormal) // SV_WallFriction
{
/*float d, i;
vector into, side;
- makevectors(self.v_angle);
+ makevectors(this.v_angle);
d = (stepnormal * v_forward) + 0.5;
if(d < 0)
{
- i = (stepnormal * self.move_velocity);
+ i = (stepnormal * this.move_velocity);
into = i * stepnormal;
- side = self.move_velocity - into;
- self.move_velocity_x = side.x * (1 * d);
- self.move_velocity_y = side.y * (1 * d);
+ side = this.move_velocity - into;
+ this.move_velocity_x = side.x * (1 * d);
+ this.move_velocity_y = side.y * (1 * d);
}*/
}
vector planes[MAX_CLIP_PLANES];
-int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float stepheight) // SV_FlyMove
-{SELFPARAM();
+int _Movetype_FlyMove(entity this, float dt, bool applygravity, vector stepnormal, float stepheight) // SV_FlyMove
+{
int blocked = 0, bumpcount;
int i, j, numplanes = 0;
float time_left = dt, grav = 0;
if(applygravity)
{
- self.move_didgravity = 1;
- grav = dt * (PHYS_ENTGRAVITY(self) ? PHYS_ENTGRAVITY(self) : 1) * PHYS_GRAVITY;
+ this.move_didgravity = 1;
+ grav = dt * (PHYS_ENTGRAVITY(this) ? PHYS_ENTGRAVITY(this) : 1) * PHYS_GRAVITY(this);
- if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(self.move_flags & FL_ONGROUND))
+ if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(this.move_flags & FL_ONGROUND))
{
- if(GRAVITY_UNAFFECTED_BY_TICRATE)
- self.move_velocity_z -= grav * 0.5;
+ if(GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
+ this.move_velocity_z -= grav * 0.5;
else
- self.move_velocity_z -= grav;
+ this.move_velocity_z -= grav;
}
}
- original_velocity = primal_velocity = restore_velocity = self.move_velocity;
+ original_velocity = primal_velocity = restore_velocity = this.move_velocity;
for(bumpcount = 0;bumpcount < MAX_CLIP_PLANES;bumpcount++)
{
- if(self.move_velocity == '0 0 0')
+ if(this.move_velocity == '0 0 0')
break;
- push = self.move_velocity * time_left;
- vector prev_origin = self.move_origin;
- _Movetype_PushEntity(push, true);
- if(trace_startsolid && self.move_origin != prev_origin)
+ push = this.move_velocity * time_left;
+ _Movetype_PushEntity(this, push, true);
+ if(trace_startsolid)
{
// we got teleported by a touch function
// let's abort the move
// abort move if we're stuck in the world (and didn't make it out)
if(trace_startsolid && trace_allsolid)
{
- self.move_velocity = restore_velocity;
+ this.move_velocity = restore_velocity;
return 3;
}
float my_trace_fraction = trace_fraction;
vector my_trace_plane_normal = trace_plane_normal;
- if(trace_plane_normal_z)
+ if(trace_plane_normal.z)
{
- if(trace_plane_normal_z > 0.7)
+ if(trace_plane_normal.z > 0.7)
{
// floor
blocked |= 1;
trace_ent = world;
}
- self.move_flags |= FL_ONGROUND;
- self.move_groundentity = trace_ent;
+ this.move_flags |= FL_ONGROUND;
+ this.move_groundentity = trace_ent;
}
}
else if(stepheight)
{
// step - handle it immediately
- vector org = self.move_origin;
+ vector org = this.move_origin;
vector steppush = '0 0 1' * stepheight;
- _Movetype_PushEntity(steppush, true);
- if(trace_startsolid && self.move_origin != org)
+ _Movetype_PushEntity(this, steppush, true);
+ if(trace_startsolid)
{
blocked |= 8;
break;
}
- _Movetype_PushEntity(push, true);
- if(trace_startsolid && self.move_origin != org)
+ _Movetype_PushEntity(this, push, true);
+ if(trace_startsolid)
{
blocked |= 8;
break;
}
float trace2_fraction = trace_fraction;
- steppush = '0 0 1' * (org_z - self.move_origin_z);
- _Movetype_PushEntity(steppush, true);
- if(trace_startsolid && self.move_origin != org)
+ steppush = '0 0 1' * (org_z - this.move_origin_z);
+ _Movetype_PushEntity(this, steppush, true);
+ if(trace_startsolid)
{
blocked |= 8;
break;
}
// accept the new position if it made some progress...
- if(fabs(self.move_origin_x - org_x) >= 0.03125 || fabs(self.move_origin_y - org_y) >= 0.03125)
+ if(fabs(this.move_origin_x - org_x) >= 0.03125 || fabs(this.move_origin_y - org_y) >= 0.03125)
{
- trace_endpos = self.move_origin;
+ trace_endpos = this.move_origin;
time_left *= 1 - trace2_fraction;
numplanes = 0;
continue;
}
else
- self.move_origin = org;
+ this.move_origin = org;
}
else
{
if(my_trace_fraction >= 0.001)
{
// actually covered some distance
- original_velocity = self.move_velocity;
+ original_velocity = this.move_velocity;
numplanes = 0;
}
if(numplanes >= MAX_CLIP_PLANES)
{
// this shouldn't really happen
- self.move_velocity = '0 0 0';
+ this.move_velocity = '0 0 0';
blocked = 3;
break;
}
if(i != numplanes)
{
// go along this plane
- self.move_velocity = new_velocity;
+ this.move_velocity = new_velocity;
}
else
{
// go along the crease
if(numplanes != 2)
{
- self.move_velocity = '0 0 0';
+ this.move_velocity = '0 0 0';
blocked = 7;
break;
}
dir.x *= ilength;
dir.y *= ilength;
dir.z *= ilength;
- float d = (dir * self.move_velocity);
- self.move_velocity = dir * d;
+ float d = (dir * this.move_velocity);
+ this.move_velocity = dir * d;
}
// if current velocity is against the original velocity,
// stop dead to avoid tiny occilations in sloping corners
- if((self.move_velocity * primal_velocity) <= 0)
+ if((this.move_velocity * primal_velocity) <= 0)
{
- self.move_velocity = '0 0 0';
+ this.move_velocity = '0 0 0';
break;
}
}
// LordHavoc: this came from QW and allows you to get out of water more easily
- if(GAMEPLAYFIX_EASIERWATERJUMP && (self.move_flags & FL_WATERJUMP) && !(blocked & 8))
- self.move_velocity = primal_velocity;
+ if(GAMEPLAYFIX_EASIERWATERJUMP && (this.move_flags & FL_WATERJUMP) && !(blocked & 8))
+ this.move_velocity = primal_velocity;
if(applygravity)
{
- if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(self.move_flags & FL_ONGROUND))
+ if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(this.move_flags & FL_ONGROUND))
{
- if(GRAVITY_UNAFFECTED_BY_TICRATE)
- self.move_velocity_z -= grav * 0.5f;
+ if(GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
+ this.move_velocity_z -= grav * 0.5f;
}
}
return blocked;
}
-void _Movetype_CheckVelocity() // SV_CheckVelocity
+void _Movetype_CheckVelocity(entity this) // SV_CheckVelocity
{
- // if(vlen(self.move_velocity) < 0.0001)
- // self.move_velocity = '0 0 0';
+ // if(vlen(this.move_velocity) < 0.0001)
+ // this.move_velocity = '0 0 0';
}
bool _Movetype_CheckWater(entity ent) // SV_CheckWater
}
}
-void _Movetype_Impact(entity oth) // SV_Impact
-{SELFPARAM();
+void _Movetype_Impact(entity this, entity oth) // SV_Impact
+{
entity oldother = other;
- if(self.move_touch)
+ if(this.move_touch)
{
other = oth;
- self.move_touch();
+ WITH(entity, self, this, this.move_touch());
other = oldother;
}
if(oth.move_touch)
{
- other = self;
+ other = this;
WITH(entity, self, oth, oth.move_touch());
}
}
-void _Movetype_LinkEdict_TouchAreaGrid() // SV_LinkEdict_TouchAreaGrid
-{SELFPARAM();
+void _Movetype_LinkEdict_TouchAreaGrid(entity this) // SV_LinkEdict_TouchAreaGrid
+{
entity oldother = other;
- for (entity e = findradius(0.5 * (self.absmin + self.absmax), 0.5 * vlen(self.absmax - self.absmin)); e; e = e.chain)
+ for (entity e = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); e; e = e.chain)
{
+ if(e.move_nomonsters != MOVE_NOMONSTERS && e.move_nomonsters != MOVE_WORLDONLY)
if(e.move_touch && boxesoverlap(e.absmin, e.absmax, this.absmin, this.absmax))
{
- setself(e);
other = this;
trace_allsolid = false;
trace_plane_dist = 0;
trace_ent = this;
- e.move_touch();
+ WITH(entity, self, e, e.move_touch());
}
}
other = oldother;
- setself(this);
}
-void _Movetype_LinkEdict(bool touch_triggers) // SV_LinkEdict
-{SELFPARAM();
+void _Movetype_LinkEdict(entity this, bool touch_triggers) // SV_LinkEdict
+{
vector mi, ma;
- if(self.solid == SOLID_BSP)
+ if(this.solid == SOLID_BSP)
{
// TODO set the absolute bbox
- mi = self.mins;
- ma = self.maxs;
+ mi = this.mins;
+ ma = this.maxs;
}
else
{
- mi = self.mins;
- ma = self.maxs;
+ mi = this.mins;
+ ma = this.maxs;
}
- mi += self.move_origin;
- ma += self.move_origin;
+ mi += this.move_origin;
+ ma += this.move_origin;
- if(self.move_flags & FL_ITEM)
+ if(this.move_flags & FL_ITEM)
{
mi.x -= 15;
mi.y -= 15;
ma.z += 1;
}
- self.absmin = mi;
- self.absmax = ma;
+ this.absmin = mi;
+ this.absmax = ma;
if(touch_triggers)
- _Movetype_LinkEdict_TouchAreaGrid();
+ _Movetype_LinkEdict_TouchAreaGrid(this);
}
-bool _Movetype_TestEntityPosition(vector ofs) // SV_TestEntityPosition
-{SELFPARAM();
-// vector org = self.move_origin + ofs;
+bool _Movetype_TestEntityPosition(entity this, vector ofs) // SV_TestEntityPosition
+{
+// vector org = this.move_origin + ofs;
- int cont = self.dphitcontentsmask;
- self.dphitcontentsmask = DPCONTENTS_SOLID;
- tracebox(self.move_origin, self.mins, self.maxs, self.move_origin, MOVE_NOMONSTERS, self);
- self.dphitcontentsmask = cont;
+ int cont = this.dphitcontentsmask;
+ this.dphitcontentsmask = DPCONTENTS_SOLID;
+ tracebox(this.move_origin, this.mins, this.maxs, this.move_origin, ((this.move_movetype == MOVETYPE_FLY_WORLDONLY) ? MOVE_WORLDONLY : MOVE_NOMONSTERS), this);
+ this.dphitcontentsmask = cont;
if(trace_startsolid)
return true;
- if(vlen(trace_endpos - self.move_origin) > 0.0001)
- self.move_origin = trace_endpos;
+ if(vlen(trace_endpos - this.move_origin) > 0.0001)
+ this.move_origin = trace_endpos;
return false;
}
-bool _Movetype_UnstickEntity() // SV_UnstickEntity
-{SELFPARAM();
- if(!_Movetype_TestEntityPosition('0 0 0')) return true;
- if(!_Movetype_TestEntityPosition('-1 0 0')) goto success;
- if(!_Movetype_TestEntityPosition('1 0 0')) goto success;
- if(!_Movetype_TestEntityPosition('0 -1 0')) goto success;
- if(!_Movetype_TestEntityPosition('0 1 0')) goto success;
- if(!_Movetype_TestEntityPosition('-1 -1 0')) goto success;
- if(!_Movetype_TestEntityPosition('1 -1 0')) goto success;
- if(!_Movetype_TestEntityPosition('-1 1 0')) goto success;
- if(!_Movetype_TestEntityPosition('1 1 0')) goto success;
+bool _Movetype_UnstickEntity(entity this) // SV_UnstickEntity
+{
+ if(!_Movetype_TestEntityPosition(this, '0 0 0')) return true;
+ if(!_Movetype_TestEntityPosition(this, '-1 0 0')) goto success;
+ if(!_Movetype_TestEntityPosition(this, '1 0 0')) goto success;
+ if(!_Movetype_TestEntityPosition(this, '0 -1 0')) goto success;
+ if(!_Movetype_TestEntityPosition(this, '0 1 0')) goto success;
+ if(!_Movetype_TestEntityPosition(this, '-1 -1 0')) goto success;
+ if(!_Movetype_TestEntityPosition(this, '1 -1 0')) goto success;
+ if(!_Movetype_TestEntityPosition(this, '-1 1 0')) goto success;
+ if(!_Movetype_TestEntityPosition(this, '1 1 0')) goto success;
for (int i = 1; i <= 17; ++i)
{
- if(!_Movetype_TestEntityPosition('0 0 -1' * i)) goto success;
- if(!_Movetype_TestEntityPosition('0 0 1' * i)) goto success;
+ if(!_Movetype_TestEntityPosition(this, '0 0 -1' * i)) goto success;
+ if(!_Movetype_TestEntityPosition(this, '0 0 1' * i)) goto success;
}
LOG_TRACEF("Can't unstick an entity (edict: %d, classname: %s, origin: %s)\n",
- num_for_edict(self), self.classname, vtos(self.move_origin));
+ num_for_edict(this), this.classname, vtos(this.move_origin));
return false;
: success;
LOG_TRACEF("Sucessfully unstuck an entity (edict: %d, classname: %s, origin: %s)\n",
- num_for_edict(self), self.classname, vtos(self.move_origin));
- _Movetype_LinkEdict(true);
+ num_for_edict(this), this.classname, vtos(this.move_origin));
+ _Movetype_LinkEdict(this, true);
return true;
}
return vel;
}
-void _Movetype_PushEntityTrace(vector push)
-{SELFPARAM();
- vector end = self.move_origin + push;
+void _Movetype_PushEntityTrace(entity this, vector push)
+{
+ vector end = this.move_origin + push;
int type;
- if(self.move_nomonsters)
- type = max(0, self.move_nomonsters);
- else if(self.move_movetype == MOVETYPE_FLYMISSILE)
+ if(this.move_nomonsters)
+ type = max(0, this.move_nomonsters);
+ else if(this.move_movetype == MOVETYPE_FLYMISSILE)
type = MOVE_MISSILE;
- else if(self.solid == SOLID_TRIGGER || self.solid == SOLID_NOT)
+ else if(this.move_movetype == MOVETYPE_FLY_WORLDONLY)
+ type = MOVE_WORLDONLY;
+ else if(this.solid == SOLID_TRIGGER || this.solid == SOLID_NOT)
type = MOVE_NOMONSTERS;
else
type = MOVE_NORMAL;
- tracebox(self.move_origin, self.mins, self.maxs, end, type, self);
+ tracebox(this.move_origin, this.mins, this.maxs, end, type, this);
}
-float _Movetype_PushEntity(vector push, bool failonstartsolid) // SV_PushEntity
-{SELFPARAM();
- _Movetype_PushEntityTrace(push);
+float _Movetype_PushEntity(entity this, vector push, bool failonstartsolid) // SV_PushEntity
+{
+ _Movetype_PushEntityTrace(this, push);
if(trace_startsolid && failonstartsolid)
return trace_fraction;
- self.move_origin = trace_endpos;
+ this.move_origin = trace_endpos;
if(trace_fraction < 1)
- if(self.solid >= SOLID_TRIGGER && (!(self.move_flags & FL_ONGROUND) || (self.move_groundentity != trace_ent)))
- _Movetype_Impact(trace_ent);
+ if(this.solid >= SOLID_TRIGGER && (!(this.move_flags & FL_ONGROUND) || (this.move_groundentity != trace_ent)))
+ _Movetype_Impact(this, trace_ent);
return trace_fraction;
}
}
}
-void _Movetype_Physics_Frame(float movedt)
-{SELFPARAM();
- self.move_didgravity = -1;
- switch (self.move_movetype)
+void _Movetype_Physics_Frame(entity this, float movedt)
+{
+ this.move_didgravity = -1;
+ switch (this.move_movetype)
{
case MOVETYPE_PUSH:
case MOVETYPE_FAKEPUSH:
- _Movetype_Physics_Pusher(movedt);
+ _Movetype_Physics_Pusher(this, movedt);
break;
case MOVETYPE_NONE:
break;
case MOVETYPE_FOLLOW:
- _Movetype_Physics_Follow();
+ _Movetype_Physics_Follow(this);
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;
- _Movetype_LinkEdict(false);
+ _Movetype_CheckWater(this);
+ this.move_origin = this.move_origin + TICRATE * this.move_velocity;
+ this.move_angles = this.move_angles + TICRATE * this.move_avelocity;
+ _Movetype_LinkEdict(this, false);
break;
case MOVETYPE_STEP:
- _Movetype_Physics_Step(movedt);
+ _Movetype_Physics_Step(this, movedt);
break;
case MOVETYPE_WALK:
- _Movetype_Physics_Walk(movedt);
+ _Movetype_Physics_Walk(this, movedt);
break;
case MOVETYPE_TOSS:
case MOVETYPE_BOUNCE:
case MOVETYPE_BOUNCEMISSILE:
case MOVETYPE_FLYMISSILE:
case MOVETYPE_FLY:
- _Movetype_Physics_Toss(movedt);
+ case MOVETYPE_FLY_WORLDONLY:
+ _Movetype_Physics_Toss(this, movedt);
+ break;
+ case MOVETYPE_PHYSICS:
break;
}
}
-void Movetype_Physics_NoMatchServer() // optimized
-{SELFPARAM();
- float movedt = time - self.move_time;
- self.move_time = time;
+void _Movetype_Physics_ClientFrame(entity this, float movedt)
+{
+ this.move_didgravity = -1;
+ switch (this.move_movetype)
+ {
+ case MOVETYPE_PUSH:
+ case MOVETYPE_FAKEPUSH:
+ _Movetype_Physics_Pusher(this, movedt);
+ break;
+ case MOVETYPE_NONE:
+ break;
+ case MOVETYPE_FOLLOW:
+ _Movetype_Physics_Follow(this);
+ break;
+ case MOVETYPE_NOCLIP:
+ _Movetype_CheckWater(this);
+ this.move_origin = this.move_origin + TICRATE * this.move_velocity;
+ this.move_angles = this.move_angles + TICRATE * this.move_avelocity;
+ _Movetype_LinkEdict(this, false);
+ break;
+ case MOVETYPE_STEP:
+ _Movetype_Physics_Step(this, movedt);
+ break;
+ case MOVETYPE_WALK:
+ case MOVETYPE_FLY:
+ case MOVETYPE_FLY_WORLDONLY:
+ _Movetype_Physics_Walk(this, movedt);
+ break;
+ case MOVETYPE_TOSS:
+ case MOVETYPE_BOUNCE:
+ case MOVETYPE_BOUNCEMISSILE:
+ case MOVETYPE_FLYMISSILE:
+ _Movetype_Physics_Toss(this, movedt);
+ break;
+ case MOVETYPE_PHYSICS:
+ break;
+ }
+}
+
+void Movetype_Physics_NoMatchServer(entity this) // optimized
+{
+ float movedt = time - this.move_time;
+ this.move_time = time;
- _Movetype_Physics_Frame(movedt);
- if(wasfreed(self))
+ _Movetype_Physics_Frame(this, movedt);
+ if(wasfreed(this))
return;
- self.avelocity = self.move_avelocity;
- self.velocity = self.move_velocity;
- self.angles = self.move_angles;
- setorigin(self, self.move_origin);
+ this.avelocity = this.move_avelocity;
+ this.velocity = this.move_velocity;
+ this.angles = this.move_angles;
+ setorigin(this, this.move_origin);
}
-void Movetype_Physics_MatchServer(bool sloppy)
+void Movetype_Physics_MatchServer(entity this, bool sloppy)
{
- Movetype_Physics_MatchTicrate(TICRATE, sloppy);
+ Movetype_Physics_MatchTicrate(this, TICRATE, sloppy);
}
-void Movetype_Physics_MatchTicrate(float tr, bool sloppy) // SV_Physics_Entity
-{SELFPARAM();
+void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy) // SV_Physics_Entity
+{
if(tr <= 0)
{
- Movetype_Physics_NoMatchServer();
+ Movetype_Physics_NoMatchServer(this);
return;
}
- float dt = time - self.move_time;
+ float dt = time - this.move_time;
int n = max(0, floor(dt / tr));
dt -= n * tr;
- self.move_time += n * tr;
+ this.move_time += n * tr;
- if(!self.move_didgravity)
- self.move_didgravity = ((self.move_movetype == MOVETYPE_BOUNCE || self.move_movetype == MOVETYPE_TOSS) && !(self.move_flags & FL_ONGROUND));
+ if(!this.move_didgravity)
+ this.move_didgravity = ((this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS) && !(this.move_flags & FL_ONGROUND));
for (int i = 0; i < n; ++i)
{
- _Movetype_Physics_Frame(tr);
- if(wasfreed(self))
+ _Movetype_Physics_Frame(this, tr);
+ if(wasfreed(this))
return;
}
- self.avelocity = self.move_avelocity;
+ this.avelocity = this.move_avelocity;
- if(dt > 0 && self.move_movetype != MOVETYPE_NONE && !(self.move_flags & FL_ONGROUND))
+ if(dt > 0 && this.move_movetype != MOVETYPE_NONE && !(this.move_flags & FL_ONGROUND))
{
// now continue the move from move_time to time
- self.velocity = self.move_velocity;
+ this.velocity = this.move_velocity;
- if(self.move_didgravity > 0)
+ if(this.move_didgravity > 0)
{
- self.velocity_z -= (GRAVITY_UNAFFECTED_BY_TICRATE ? 0.5 : 1)
+ this.velocity_z -= (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1)
* dt
- * (self.gravity ? self.gravity : 1)
- * PHYS_GRAVITY;
+ * (this.gravity ? this.gravity : 1)
+ * PHYS_GRAVITY(this);
}
- self.angles = self.move_angles + dt * self.avelocity;
+ this.angles = this.move_angles + dt * this.avelocity;
- if(sloppy || self.move_movetype == MOVETYPE_NOCLIP)
+ if(sloppy || this.move_movetype == MOVETYPE_NOCLIP)
{
- setorigin(self, self.move_origin + dt * self.velocity);
+ setorigin(this, this.move_origin + dt * this.velocity);
}
else
{
- _Movetype_PushEntityTrace(dt * self.velocity);
+ _Movetype_PushEntityTrace(this, dt * this.velocity);
if(!trace_startsolid)
- setorigin(self, trace_endpos);
+ setorigin(this, trace_endpos);
}
- if(self.move_didgravity > 0 && GRAVITY_UNAFFECTED_BY_TICRATE)
- self.velocity_z -= 0.5 * dt * (self.gravity ? self.gravity : 1) * PHYS_GRAVITY;
+ if(this.move_didgravity > 0 && GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
+ this.velocity_z -= 0.5 * dt * (this.gravity ? this.gravity : 1) * PHYS_GRAVITY(this);
}
else
{
- self.velocity = self.move_velocity;
- self.angles = self.move_angles;
- setorigin(self, self.move_origin);
+ this.velocity = this.move_velocity;
+ this.angles = this.move_angles;
+ setorigin(this, this.move_origin);
}
}
// should match sv_gameplayfix_fixedcheckwatertransition
float autocvar_cl_gameplayfix_fixedcheckwatertransition = 1;
-#ifdef SVQC
-.int stat_gameplayfix_upvelocityclearsonground;
-
-#define GRAVITY_UNAFFECTED_BY_TICRATE autocvar_sv_gameplayfix_gravityunaffectedbyticrate
-#define UPWARD_VELOCITY_CLEARS_ONGROUND autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag
-
-#define TICRATE sys_frametime
-#elif defined(CSQC)
-#define GRAVITY_UNAFFECTED_BY_TICRATE (getstati(STAT_MOVEFLAGS) & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
-#define UPWARD_VELOCITY_CLEARS_ONGROUND getstati(STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND)
-
-#define TICRATE ticrate
-#endif
-
.entity move_groundentity; // FIXME add move_groundnetworkentity?
.float move_suspendedinair;
.float move_didgravity;
-void _Movetype_WallFriction(vector stepnormal);
-int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float stepheight);
-void _Movetype_CheckVelocity();
+void _Movetype_WallFriction(entity this, vector stepnormal);
+int _Movetype_FlyMove(entity this, float dt, bool applygravity, vector stepnormal, float stepheight);
+void _Movetype_CheckVelocity(entity this);
void _Movetype_CheckWaterTransition(entity ent);
float _Movetype_CheckWater(entity ent);
-void _Movetype_LinkEdict_TouchAreaGrid();
-void _Movetype_LinkEdict(float touch_triggers);
-float _Movetype_TestEntityPosition(vector ofs);
-float _Movetype_UnstickEntity();
+void _Movetype_LinkEdict_TouchAreaGrid(entity this);
+void _Movetype_LinkEdict(entity this, float touch_triggers);
+float _Movetype_TestEntityPosition(entity this, vector ofs);
+float _Movetype_UnstickEntity(entity this);
vector _Movetype_ClipVelocity(vector vel, vector norm, float f);
-void _Movetype_PushEntityTrace(vector push);
-float _Movetype_PushEntity(vector push, float failonstartsolid);
+void _Movetype_PushEntityTrace(entity this, vector push);
+float _Movetype_PushEntity(entity this, vector push, float failonstartsolid);
void makevectors_matrix(vector myangles);
-void Movetype_Physics_MatchTicrate(float tr, bool sloppy);
-void Movetype_Physics_MatchServer(bool sloppy);
-void Movetype_Physics_NoMatchServer();
-void _Movetype_LinkEdict(float touch_triggers);
-void _Movetype_LinkEdict_TouchAreaGrid();
+void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy);
+void Movetype_Physics_MatchServer(entity this, bool sloppy);
+void Movetype_Physics_NoMatchServer(entity this);
+void _Movetype_LinkEdict(entity this, float touch_triggers);
+void _Movetype_LinkEdict_TouchAreaGrid(entity this);
-float _Movetype_UnstickEntity();
+float _Movetype_UnstickEntity(entity this);
const int MAX_CLIP_PLANES = 5;
const int MOVETYPE_BOUNCE = 10;
const int MOVETYPE_BOUNCEMISSILE = 11; // Like bounce but doesn't lose speed on bouncing
const int MOVETYPE_FOLLOW = 12;
+const int MOVETYPE_PHYSICS = 32;
const int MOVETYPE_FLY_WORLDONLY = 33;
const int FL_ITEM = 256;
const int MOVETYPE_FAKEPUSH = 13;
-const float MOVEFLAG_Q2AIRACCELERATE = 1;
-const float MOVEFLAG_NOGRAVITYONGROUND = 2;
-const float MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE = 4;
+const int MOVEFLAG_VALID = BIT(23);
+const int MOVEFLAG_Q2AIRACCELERATE = BIT(0);
+const int MOVEFLAG_NOGRAVITYONGROUND = BIT(1);
+const int MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE = BIT(2);
#ifdef CSQC
-// TODO: figure out server's version of this
-#define moveflags (getstati(STAT_MOVEFLAGS))
+#define moveflags STAT(MOVEFLAGS)
#endif
#endif
-void _Movetype_PushMove(float dt) // SV_PushMove
-{SELFPARAM();
- if (self.move_velocity == '0 0 0' && self.move_avelocity == '0 0 0')
+void _Movetype_PushMove(entity this, float dt) // SV_PushMove
+{
+ if (this.move_velocity == '0 0 0' && this.move_avelocity == '0 0 0')
{
- self.move_ltime += dt;
+ this.move_ltime += dt;
return;
}
- switch (self.solid)
+ switch (this.solid)
{
// LordHavoc: valid pusher types
case SOLID_BSP:
// LordHavoc: no collisions
case SOLID_NOT:
case SOLID_TRIGGER:
- self.move_origin = self.move_origin + dt * self.move_velocity;
- self.move_angles = self.move_angles + dt * self.move_avelocity;
- self.move_angles_x -= 360.0 * floor(self.move_angles.x * (1.0 / 360.0));
- self.move_angles_y -= 360.0 * floor(self.move_angles.y * (1.0 / 360.0));
- self.move_angles_z -= 360.0 * floor(self.move_angles.z * (1.0 / 360.0));
- self.move_ltime += dt;
- _Movetype_LinkEdict(true);
+ this.move_origin = this.move_origin + dt * this.move_velocity;
+ this.move_angles = this.move_angles + dt * this.move_avelocity;
+ this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
+ this.move_angles_y -= 360.0 * floor(this.move_angles.y * (1.0 / 360.0));
+ this.move_angles_z -= 360.0 * floor(this.move_angles.z * (1.0 / 360.0));
+ this.move_ltime += dt;
+ _Movetype_LinkEdict(this, true);
return;
default:
- LOG_TRACEF("_Movetype_PushMove: entity %e, unrecognized solid type %d\n", self, self.solid);
+ LOG_TRACEF("_Movetype_PushMove: entity %e, unrecognized solid type %d\n", this, this.solid);
return;
}
- bool rotated = (self.move_angles * self.move_angles) + (self.move_avelocity * self.move_avelocity) > 0;
+ bool rotated = (this.move_angles * this.move_angles) + (this.move_avelocity * this.move_avelocity) > 0;
- vector move1 = self.move_velocity * dt;
- vector moveangle = self.move_avelocity * dt;
+ vector move1 = this.move_velocity * dt;
+ vector moveangle = this.move_avelocity * dt;
makevectors_matrix(-moveangle);
-// vector pushorig = self.move_origin;
-// vector pushang = self.move_angles;
-// float pushltime = self.move_ltime;
+// vector pushorig = this.move_origin;
+// vector pushang = this.move_angles;
+// float pushltime = this.move_ltime;
// move the pusher to its final position
- self.move_origin = self.move_origin + dt * self.move_velocity;
- self.move_angles = self.move_angles + dt * self.move_avelocity;
+ this.move_origin = this.move_origin + dt * this.move_velocity;
+ this.move_angles = this.move_angles + dt * this.move_avelocity;
- self.move_ltime += dt;
- _Movetype_LinkEdict(true);
+ this.move_ltime += dt;
+ _Movetype_LinkEdict(this, true);
- int savesolid = self.solid;
+ int savesolid = this.solid;
- if (self.move_movetype != MOVETYPE_FAKEPUSH)
+ if (this.move_movetype != MOVETYPE_FAKEPUSH)
{
- for (entity check = findradius(0.5 * (self.absmin + self.absmax), 0.5 * vlen(self.absmax - self.absmin)); check; check = check.chain)
+ for (entity check = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); check; check = check.chain)
{
switch (check.move_movetype)
{
break;
}
- if (check.owner == self)
+ if (check.owner == this)
continue;
- if (self.owner == check)
+ if (this.owner == check)
continue;
vector pivot = check.mins + 0.5 * (check.maxs - check.mins);
vector move;
if (rotated)
{
- vector org = (check.move_origin - self.move_origin) + pivot;
+ vector org = (check.move_origin - this.move_origin) + pivot;
vector org2;
org2.x = org * v_forward;
org2.y = org * v_right;
if (check.move_movetype == 32) // MOVETYPE_PHYSICS
{
check.move_origin = check.move_origin + move;
- WITH(entity, self, check, _Movetype_LinkEdict(true));
+ WITH(entity, this, check, _Movetype_LinkEdict(this, true));
continue;
}
// try moving the contacted entity
- self.solid = SOLID_NOT;
+ this.solid = SOLID_NOT;
bool flag;
- WITH(entity, self, check, {
- flag = _Movetype_PushEntity(move, true);
+ WITH(entity, this, check, {
+ flag = _Movetype_PushEntity(this, move, true);
});
if (!flag)
{
// entity "check" got teleported
check.move_angles_y += trace_fraction * moveangle.y;
- self.solid = savesolid;
+ this.solid = savesolid;
continue; // pushed enough
}
// FIXME: turn players specially
check.move_angles_y += trace_fraction * moveangle.y;
- self.solid = savesolid;
+ this.solid = savesolid;
// this trace.fraction < 1 check causes items to fall off of pushers
// if they pass under or through a wall
// the groundentity check causes items to fall off of ledges
- if (check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.move_groundentity != self))
+ if (check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.move_groundentity != this))
check.move_flags &= ~FL_ONGROUND;
}
}
- self.move_angles_x -= 360.0 * floor(self.move_angles.x * (1.0 / 360.0));
- self.move_angles_y -= 360.0 * floor(self.move_angles.y * (1.0 / 360.0));
- self.move_angles_z -= 360.0 * floor(self.move_angles.z * (1.0 / 360.0));
+ this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
+ this.move_angles_y -= 360.0 * floor(this.move_angles.y * (1.0 / 360.0));
+ this.move_angles_z -= 360.0 * floor(this.move_angles.z * (1.0 / 360.0));
}
-void _Movetype_Physics_Pusher(float dt) // SV_Physics_Pusher
-{SELFPARAM();
- float oldltime = self.move_ltime;
- float thinktime = self.move_nextthink;
+void _Movetype_Physics_Pusher(entity this, float dt) // SV_Physics_Pusher
+{
+ float oldltime = this.move_ltime;
+ float thinktime = this.move_nextthink;
float movetime;
- if (thinktime < self.move_ltime + dt)
+ if (thinktime < this.move_ltime + dt)
{
- movetime = thinktime - self.move_ltime;
+ movetime = thinktime - this.move_ltime;
if (movetime < 0)
movetime = 0;
}
}
if (movetime)
- // advances self.move_ltime if not blocked
- _Movetype_PushMove(movetime);
+ // advances this.move_ltime if not blocked
+ _Movetype_PushMove(this, movetime);
- if (thinktime > oldltime && thinktime <= self.move_ltime)
+ if (thinktime > oldltime && thinktime <= this.move_ltime)
{
- self.move_nextthink = 0;
- self.move_time = time;
+ this.move_nextthink = 0;
+ this.move_time = time;
other = world;
- if (self.move_think)
- self.move_think();
+ WITH(entity, self, this, this.move_think());
}
}
#ifndef MOVETYPE_PUSH_H
#define MOVETYPE_PUSH_H
-void _Movetype_Physics_Pusher(float dt);
+void _Movetype_Physics_Pusher(entity this, float dt);
#endif
-void _Movetype_Physics_Step(float dt) // SV_Physics_Step
-{SELFPARAM();
- if(self.move_flags & FL_ONGROUND)
+void _Movetype_Physics_Step(entity this, float dt) // SV_Physics_Step
+{
+ if(this.move_flags & FL_ONGROUND)
{
- if(self.velocity_z >= (1.0 / 32.0) && UPWARD_VELOCITY_CLEARS_ONGROUND)
+ if(this.velocity_z >= (1.0 / 32.0) && UPWARD_VELOCITY_CLEARS_ONGROUND)
{
- self.move_flags &= ~FL_ONGROUND;
- _Movetype_CheckVelocity();
- _Movetype_FlyMove(dt, true, '0 0 0', 0);
- _Movetype_LinkEdict(true);
+ this.move_flags &= ~FL_ONGROUND;
+ _Movetype_CheckVelocity(this);
+ _Movetype_FlyMove(this, dt, true, '0 0 0', 0);
+ _Movetype_LinkEdict(this, true);
}
}
else
{
- _Movetype_CheckVelocity();
- _Movetype_FlyMove(dt, true, '0 0 0', 0);
- _Movetype_LinkEdict(true);
+ _Movetype_CheckVelocity(this);
+ _Movetype_FlyMove(this, dt, true, '0 0 0', 0);
+ _Movetype_LinkEdict(this, true);
// TODO? movetypesteplandevent
}
- _Movetype_CheckWaterTransition(self);
+ _Movetype_CheckWaterTransition(this);
}
#include "../physics.qh"
-void _Movetype_Physics_Toss(float dt) // SV_Physics_Toss
-{SELFPARAM();
- if (self.move_flags & FL_ONGROUND)
+void _Movetype_Physics_Toss(entity this, float dt) // SV_Physics_Toss
+{
+ if (this.move_flags & FL_ONGROUND)
{
- if (self.move_velocity.z >= 1 / 32)
+ if (this.move_velocity.z >= 1 / 32 && UPWARD_VELOCITY_CLEARS_ONGROUND)
{
- self.move_flags &= ~FL_ONGROUND;
+ this.move_flags &= ~FL_ONGROUND;
}
- else if (!self.move_groundentity)
+ else if (!this.move_groundentity)
{
return;
}
- else if (self.move_suspendedinair && wasfreed(self.move_groundentity))
+ else if (this.move_suspendedinair && wasfreed(this.move_groundentity))
{
- self.move_groundentity = world;
+ this.move_groundentity = world;
return;
}
}
- self.move_suspendedinair = false;
+ this.move_suspendedinair = false;
- _Movetype_CheckVelocity();
+ _Movetype_CheckVelocity(this);
- if (self.move_movetype == MOVETYPE_BOUNCE || self.move_movetype == MOVETYPE_TOSS)
+ if (this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS)
{
- self.move_didgravity = 1;
- self.move_velocity_z -= (GRAVITY_UNAFFECTED_BY_TICRATE ? 0.5 : 1)
+ this.move_didgravity = 1;
+ this.move_velocity_z -= (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1)
* dt
- * (self.gravity ? self.gravity : 1)
- * PHYS_GRAVITY;
+ * (this.gravity ? this.gravity : 1)
+ * PHYS_GRAVITY(this);
}
- self.move_angles = self.move_angles + self.move_avelocity * dt;
+ this.move_angles = this.move_angles + this.move_avelocity * dt;
float movetime = dt;
for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; ++bump)
{
- vector move = self.move_velocity * movetime;
- _Movetype_PushEntity(move, true);
- if (wasfreed(self))
+ vector move = this.move_velocity * movetime;
+ _Movetype_PushEntity(this, move, true);
+ if (wasfreed(this))
return;
if (trace_startsolid)
{
- _Movetype_UnstickEntity();
- _Movetype_PushEntity(move, false);
- if (wasfreed(self))
+ _Movetype_UnstickEntity(this);
+ _Movetype_PushEntity(this, move, false);
+ if (wasfreed(this))
return;
}
movetime *= 1 - min(1, trace_fraction);
- if (self.move_movetype == MOVETYPE_BOUNCEMISSILE)
+ if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
{
- self.move_velocity = _Movetype_ClipVelocity(self.move_velocity, trace_plane_normal, 2.0);
- self.move_flags &= ~FL_ONGROUND;
+ this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 2.0);
+ this.move_flags &= ~FL_ONGROUND;
}
- else if (self.move_movetype == MOVETYPE_BOUNCE)
+ else if (this.move_movetype == MOVETYPE_BOUNCE)
{
- float bouncefac = self.move_bounce_factor; if (!bouncefac) bouncefac = 0.5;
- float bouncestop = self.move_bounce_stopspeed; if (!bouncestop) bouncestop = 60 / 800;
- bouncestop *= (self.gravity ? self.gravity : 1) * PHYS_GRAVITY;
+ float bouncefac = this.move_bounce_factor; if (!bouncefac) bouncefac = 0.5;
+ float bouncestop = this.move_bounce_stopspeed; if (!bouncestop) bouncestop = 60 / 800;
+ bouncestop *= (this.gravity ? this.gravity : 1) * PHYS_GRAVITY(this);
- self.move_velocity = _Movetype_ClipVelocity(self.move_velocity, trace_plane_normal, 1 + bouncefac);
+ this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 1 + bouncefac);
- float d = trace_plane_normal * self.move_velocity;
+ float d = trace_plane_normal * this.move_velocity;
if (trace_plane_normal.z > 0.7 && d < bouncestop && d > -bouncestop)
{
- self.move_flags |= FL_ONGROUND;
- self.move_groundentity = trace_ent;
- self.move_velocity = '0 0 0';
- self.move_avelocity = '0 0 0';
+ this.move_flags |= FL_ONGROUND;
+ this.move_groundentity = trace_ent;
+ this.move_velocity = '0 0 0';
+ this.move_avelocity = '0 0 0';
}
else
{
- self.move_flags &= ~FL_ONGROUND;
+ this.move_flags &= ~FL_ONGROUND;
}
}
else
{
- self.move_velocity = _Movetype_ClipVelocity(self.move_velocity, trace_plane_normal, 1.0);
+ this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 1.0);
if (trace_plane_normal.z > 0.7)
{
- self.move_flags |= FL_ONGROUND;
- self.move_groundentity = trace_ent;
+ this.move_flags |= FL_ONGROUND;
+ this.move_groundentity = trace_ent;
if (trace_ent.solid == SOLID_BSP)
- self.move_suspendedinair = true;
- self.move_velocity = '0 0 0';
- self.move_avelocity = '0 0 0';
+ this.move_suspendedinair = true;
+ this.move_velocity = '0 0 0';
+ this.move_avelocity = '0 0 0';
}
else
{
- self.move_flags &= ~FL_ONGROUND;
+ this.move_flags &= ~FL_ONGROUND;
}
}
// DP revision 8905 (just, WHY...)
- if (self.move_movetype == MOVETYPE_BOUNCEMISSILE)
+ if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
break;
// DP revision 8918 (WHY...)
- if (self.move_flags & FL_ONGROUND)
+ if (this.move_flags & FL_ONGROUND)
break;
}
- if (GRAVITY_UNAFFECTED_BY_TICRATE && self.move_didgravity > 0 && !(self.move_flags & FL_ONGROUND))
- self.move_velocity_z -= 0.5 * dt * (self.gravity ? self.gravity : 1) * PHYS_GRAVITY;
+ if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE && this.move_didgravity > 0 && !(this.move_flags & FL_ONGROUND))
+ this.move_velocity_z -= 0.5 * dt * (this.gravity ? this.gravity : 1) * PHYS_GRAVITY(this);
- _Movetype_CheckWaterTransition(self);
+ _Movetype_CheckWaterTransition(this);
}
#ifndef MOVETYPE_TOSS_H
#define MOVETYPE_TOSS_H
-void _Movetype_Physics_Toss(float dt);
+void _Movetype_Physics_Toss(entity this, float dt);
#endif
-void _Movetype_Physics_Walk(float dt) // SV_WalkMove
-{SELFPARAM();
+void _Movetype_Physics_Walk(entity this, float dt) // SV_WalkMove
+{
vector stepnormal = '0 0 0';
// if frametime is 0 (due to client sending the same timestamp twice), don't move
return;
if (GAMEPLAYFIX_UNSTICKPLAYERS)
- _Movetype_UnstickEntity();
+ _Movetype_UnstickEntity(this);
- bool applygravity = (!_Movetype_CheckWater(self) && self.move_movetype == MOVETYPE_WALK && !(self.move_flags & FL_WATERJUMP));
+ bool applygravity = (!_Movetype_CheckWater(this) && this.move_movetype == MOVETYPE_WALK && !(this.move_flags & FL_WATERJUMP));
- _Movetype_CheckVelocity();
+ _Movetype_CheckVelocity(this);
// do a regular slide move unless it looks like you ran into a step
- bool oldonground = (self.move_flags & FL_ONGROUND);
+ bool oldonground = (this.move_flags & FL_ONGROUND);
- vector start_origin = self.move_origin;
- vector start_velocity = self.move_velocity;
+ vector start_origin = this.move_origin;
+ vector start_velocity = this.move_velocity;
- int clip = _Movetype_FlyMove(dt, applygravity, stepnormal, GAMEPLAYFIX_STEPMULTIPLETIMES ? PHYS_STEPHEIGHT : 0);
+ int clip = _Movetype_FlyMove(this, dt, applygravity, stepnormal, GAMEPLAYFIX_STEPMULTIPLETIMES ? PHYS_STEPHEIGHT : 0);
if (GAMEPLAYFIX_DOWNTRACEONGROUND && !(clip & 1))
{
// only try this if there was no floor in the way in the trace (no,
// this check seems to be not REALLY necessary, because if clip & 1,
// our trace will hit that thing too)
- vector upmove = self.move_origin + '0 0 1';
- vector downmove = self.move_origin - '0 0 1';
+ vector upmove = this.move_origin + '0 0 1';
+ vector downmove = this.move_origin - '0 0 1';
int type;
- if (self.move_movetype == MOVETYPE_FLYMISSILE)
+ if (this.move_movetype == MOVETYPE_FLYMISSILE)
type = MOVE_MISSILE;
- else if (self.move_movetype == MOVETYPE_FLY_WORLDONLY)
+ else if (this.move_movetype == MOVETYPE_FLY_WORLDONLY)
type = MOVE_WORLDONLY;
- else if (self.solid == SOLID_TRIGGER || self.solid == SOLID_NOT)
+ else if (this.solid == SOLID_TRIGGER || this.solid == SOLID_NOT)
type = MOVE_NOMONSTERS;
else type = MOVE_NORMAL;
- tracebox(upmove, self.mins, self.maxs, downmove, type, self);
+ tracebox(upmove, this.mins, this.maxs, downmove, type, this);
if (trace_fraction < 1 && trace_plane_normal.z > 0.7)
clip |= 1; // but we HAVE found a floor
}
// if the move did not hit the ground at any point, we're not on ground
if (!(clip & 1))
- self.move_flags &= ~FL_ONGROUND;
+ this.move_flags &= ~FL_ONGROUND;
- _Movetype_CheckVelocity();
- _Movetype_LinkEdict(true);
+ _Movetype_CheckVelocity(this);
+ _Movetype_LinkEdict(this, true);
if (clip & 8) // teleport
return;
- if (self.move_flags & FL_WATERJUMP)
+ if (this.move_flags & FL_WATERJUMP)
return;
if (PHYS_NOSTEP)
return;
- vector originalmove_origin = self.move_origin;
- vector originalmove_velocity = self.move_velocity;
+ vector originalmove_origin = this.move_origin;
+ vector originalmove_velocity = this.move_velocity;
// originalmove_clip = clip;
- int originalmove_flags = self.move_flags;
- entity originalmove_groundentity = self.move_groundentity;
+ int originalmove_flags = this.move_flags;
+ entity originalmove_groundentity = this.move_groundentity;
// if move didn't block on a step, return
if (clip & 2)
if (fabs(start_velocity.x) < 0.03125 && fabs(start_velocity.y) < 0.03125)
return;
- if (self.move_movetype != MOVETYPE_FLY)
+ if (this.move_movetype != MOVETYPE_FLY)
{
// return if gibbed by a trigger
- if (self.move_movetype != MOVETYPE_WALK)
+ if (this.move_movetype != MOVETYPE_WALK)
return;
// return if attempting to jump while airborn (unless sv_jumpstep)
if (!PHYS_JUMPSTEP)
- if (!oldonground && self.move_waterlevel == 0)
+ if (!oldonground && this.move_waterlevel == 0)
return;
}
// try moving up and forward to go up a step
// back to start pos
- self.move_origin = start_origin;
- self.move_velocity = start_velocity;
+ this.move_origin = start_origin;
+ this.move_velocity = start_velocity;
// move up
vector upmove = '0 0 1' * PHYS_STEPHEIGHT;
- vector prev_origin = self.move_origin;
- _Movetype_PushEntity(upmove, true);
- if(wasfreed(self))
+ _Movetype_PushEntity(this, upmove, true);
+ if(wasfreed(this))
return;
- if(trace_startsolid && self.move_origin != prev_origin)
+ if(trace_startsolid)
{
// we got teleported when upstepping... must abort the move
return;
}
// move forward
- self.move_velocity_z = 0;
- clip = _Movetype_FlyMove(dt, applygravity, stepnormal, 0);
- self.move_velocity_z += start_velocity.z;
+ this.move_velocity_z = 0;
+ clip = _Movetype_FlyMove(this, dt, applygravity, stepnormal, 0);
+ this.move_velocity_z += start_velocity.z;
if (clip & 8)
{
// we got teleported when upstepping... must abort the move
return;
}
- _Movetype_CheckVelocity();
- _Movetype_LinkEdict(true);
+ _Movetype_CheckVelocity(this);
+ _Movetype_LinkEdict(this, true);
// check for stuckness, possibly due to the limited precision of floats
// in the clipping hulls
if (clip
- && fabs(originalmove_origin.y - self.move_origin.y) < 0.03125
- && fabs(originalmove_origin.x - self.move_origin.x) < 0.03125)
+ && fabs(originalmove_origin.y - this.move_origin.y) < 0.03125
+ && fabs(originalmove_origin.x - this.move_origin.x) < 0.03125)
{
// Con_Printf("wall\n");
// stepping up didn't make any progress, revert to original move
- self.move_origin = originalmove_origin;
- self.move_velocity = originalmove_velocity;
+ this.move_origin = originalmove_origin;
+ this.move_velocity = originalmove_velocity;
// clip = originalmove_clip;
- self.move_flags = originalmove_flags;
- self.move_groundentity = originalmove_groundentity;
+ this.move_flags = originalmove_flags;
+ this.move_groundentity = originalmove_groundentity;
// now try to unstick if needed
// clip = SV_TryUnstick (ent, oldvel);
return;
// extra friction based on view angle
if ((clip & 2) && PHYS_WALLFRICTION)
- _Movetype_WallFriction(stepnormal);
+ _Movetype_WallFriction(this, stepnormal);
}
// don't do the down move if stepdown is disabled, moving upward, not in water, or the move started offground or ended onground
- else if (!GAMEPLAYFIX_STEPDOWN || self.move_waterlevel >= 3 || start_velocity.z >= (1.0 / 32.0) || !oldonground || (self.move_flags & FL_ONGROUND))
+ else if (!GAMEPLAYFIX_STEPDOWN || this.move_waterlevel >= 3 || start_velocity.z >= (1.0 / 32.0) || !oldonground || (this.move_flags & FL_ONGROUND))
{
return;
}
// move down
vector downmove = '0 0 1' * (-PHYS_STEPHEIGHT + start_velocity.z * dt);
- vector prev_origin = self.move_origin;
- _Movetype_PushEntity(downmove, true);
- if(wasfreed(self))
+ _Movetype_PushEntity(this, downmove, true);
+ if(wasfreed(this))
return;
- if(trace_startsolid && self.move_origin != prev_origin)
+ if(trace_startsolid)
{
// we got teleported when downstepping... must abort the move
return;
// if the push down didn't end up on good ground, use the move without
// the step up. This happens near wall / slope combinations, and can
// cause the player to hop up higher on a slope too steep to climb
- self.move_origin = originalmove_origin;
- self.move_velocity = originalmove_velocity;
- self.move_flags = originalmove_flags;
- self.move_groundentity = originalmove_groundentity;
+ this.move_origin = originalmove_origin;
+ this.move_velocity = originalmove_velocity;
+ this.move_flags = originalmove_flags;
+ this.move_groundentity = originalmove_groundentity;
}
- _Movetype_CheckVelocity();
- _Movetype_LinkEdict(true);
+ _Movetype_CheckVelocity(this);
+ _Movetype_LinkEdict(this, true);
}
#ifndef MOVETYPE_WALK_H
#define MOVETYPE_WALK_H
-void _Movetype_Physics_Walk(float dt);
+void _Movetype_Physics_Walk(entity this, float dt);
#endif
REGISTRY(Mutators, BITS(7))
#define Mutators_from(i) _Mutators_from(i, NULL)
Mutator loaded_mutators[Mutators_MAX];
+bool Mutator_Add(Mutator mut);
+void Mutator_Remove(Mutator mut);
+bool mutator_log = false;
+
+#ifndef MENUQC
+REGISTER_NET_LINKED(Mutator)
+
+#ifdef SVQC
+bool Mutator_SendEntity(entity this, entity to, int sf)
+{
+ int chan = MSG_ENTITY;
+ WriteHeader(chan, Mutator);
+ WriteString(chan, this.registered_id);
+ return true;
+}
+#endif
+
+#ifdef CSQC
+void NET_Mutator_Remove()
+{
+ SELFPARAM();
+ string s = this.netname;
+ WITH(bool, mutator_log, true, LAMBDA(
+ FOREACH(Mutators, it.registered_id == s, LAMBDA(Mutator_Remove(it)));
+ ));
+}
+NET_HANDLE(Mutator, bool isNew)
+{
+ string s = this.netname = ReadString();
+ return = true;
+ if (isNew)
+ {
+ make_pure(this);
+ this.entremove = NET_Mutator_Remove;
+ int added = 0;
+ WITH(bool, mutator_log, true, LAMBDA(
+ FOREACH(Mutators, it.registered_id == s, LAMBDA(Mutator_Add(it); ++added));
+ ));
+ if (added > 1) LOG_WARNINGF("Added more than one mutator for %s\n", s);
+ }
+}
+#endif
+
+#endif
bool Mutator_Add(Mutator mut)
{
mutatorfunc_t func = mut.mutatorfunc;
if (!func(MUTATOR_ADDING)) {
// good
+ if (mutator_log) LOG_TRACEF("Mutator: added %s\n", mut.m_name);
+#ifdef SVQC
+ Net_LinkEntity(mut, false, 0, Mutator_SendEntity);
+#endif
return true;
}
backtrace("WARNING: when adding mutator: adding failed, rolling back\n");
// baaaaad
error("Mutator_Remove: removing mutator failed");
}
+ if (mutator_log) LOG_TRACEF("Mutator: removed %s\n", mut.m_name);
+#ifdef SVQC
+ Net_UnlinkEntity(mut);
+#endif
}
#define REGISTER_MUTATOR(id, dependence) \
* called before any player physics, may adjust variables for movement,
* is run AFTER bot code and idle checking on the server
*/
-MUTATOR_HOOKABLE(PlayerPhysics, EV_NO_ARGS);
+#define EV_PlayerPhysics(i, o) \
+ /**/ i(entity, __self) \
+ /**/
+MUTATOR_HOOKABLE(PlayerPhysics, EV_PlayerPhysics);
/** called when a player presses the jump key */
#define EV_PlayerJump(i, o) \
+ /**/ i(entity, __self) \
/**/ i(float, player_multijump) \
/**/ i(float, player_jumpheight) \
/**/ o(float, player_multijump) \
/** called during player physics, allows adjusting the movement type used */
#define EV_PM_Physics(i, o) \
+ /**/ i(entity, __self) \
/**/ i(float, pm_maxspeed_mod) \
/**/
float pm_maxspeed_mod;
MUTATOR_HOOKABLE(PM_Physics, EV_PM_Physics);
+/** called when a weapon model is about to be set, allows custom paths etc. */
+#define EV_WeaponModel(i, o) \
+ /**/ i(string, weapon_model) \
+ /**/ i(string, weapon_model_output) \
+ /**/ o(string, weapon_model_output) \
+ /**/
+string weapon_model;
+string weapon_model_output;
+MUTATOR_HOOKABLE(WeaponModel, EV_WeaponModel);
+
#endif
ENDCLASS(Buff)
#ifdef SVQC
- .int buffs;
+ // .int buffs = _STAT(BUFFS);
void buff_Init(entity ent);
void buff_Init_Compat(entity ent, entity replacement);
#define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
#include "../../../triggers/target/music.qh"
#include "../../../gamemodes/all.qh"
-.float buff_time;
+.float buff_time = _STAT(BUFF_TIME);
void buffs_DelayedInit();
REGISTER_MUTATOR(buffs, cvar("g_buffs"))
{
MUTATOR_ONADD
{
- addstat(STAT_BUFFS, AS_INT, buffs);
- addstat(STAT_BUFF_TIME, AS_FLOAT, buff_time);
-
InitializeEntity(world, buffs_DelayedInit, INITPRIO_FINDTARGET);
}
}
REGISTER_MUTATOR(cl_buffs, true);
MUTATOR_HOOKFUNCTION(cl_buffs, HUD_Powerups_add)
{
- int allBuffs = getstati(STAT_BUFFS, 0, 24);
+ int allBuffs = STAT(BUFFS);
FOREACH(Buffs, it.m_itemid & allBuffs, LAMBDA(
- addPowerupItem(it.m_prettyName, strcat("buff_", it.m_name), it.m_color, bound(0, getstatf(STAT_BUFF_TIME) - time, 99), 60);
+ addPowerupItem(it.m_prettyName, strcat("buff_", it.m_name), it.m_color, bound(0, STAT(BUFF_TIME) - time, 99), 60);
));
}
MUTATOR_HOOKFUNCTION(cl_buffs, WP_Format)
#if defined(SVQC)
void bugrigs_SetVars();
-void bugrigs_AddStats();
REGISTER_MUTATOR(bugrigs, cvar("g_bugrigs"))
{
MUTATOR_ONADD
{
bugrigs_SetVars();
- bugrigs_AddStats();
}
return false;
}
#endif
-#ifdef CSQC
-
-#define PHYS_BUGRIGS getstati(STAT_BUGRIGS)
-#define PHYS_BUGRIGS_ANGLE_SMOOTHING getstati(STAT_BUGRIGS_ANGLE_SMOOTHING)
-#define PHYS_BUGRIGS_PLANAR_MOVEMENT getstati(STAT_BUGRIGS_PLANAR_MOVEMENT)
-#define PHYS_BUGRIGS_REVERSE_SPEEDING getstati(STAT_BUGRIGS_REVERSE_SPEEDING)
-#define PHYS_BUGRIGS_FRICTION_FLOOR getstatf(STAT_BUGRIGS_FRICTION_FLOOR)
-#define PHYS_BUGRIGS_AIR_STEERING getstati(STAT_BUGRIGS_AIR_STEERING)
-#define PHYS_BUGRIGS_FRICTION_BRAKE getstatf(STAT_BUGRIGS_FRICTION_BRAKE)
-#define PHYS_BUGRIGS_ACCEL getstatf(STAT_BUGRIGS_ACCEL)
-#define PHYS_BUGRIGS_SPEED_REF getstatf(STAT_BUGRIGS_SPEED_REF)
-#define PHYS_BUGRIGS_SPEED_POW getstatf(STAT_BUGRIGS_SPEED_POW)
-#define PHYS_BUGRIGS_STEER getstatf(STAT_BUGRIGS_STEER)
-#define PHYS_BUGRIGS_FRICTION_AIR getstatf(STAT_BUGRIGS_FRICTION_AIR)
-#define PHYS_BUGRIGS_CAR_JUMPING getstatf(STAT_BUGRIGS_CAR_JUMPING)
-#define PHYS_BUGRIGS_REVERSE_SPINNING getstatf(STAT_BUGRIGS_REVERSE_SPINNING)
-#define PHYS_BUGRIGS_REVERSE_STOPPING getstatf(STAT_BUGRIGS_REVERSE_STOPPING)
-
-#elif defined(SVQC)
-
-bool g_bugrigs;
-bool g_bugrigs_planar_movement;
-bool g_bugrigs_planar_movement_car_jumping;
-float g_bugrigs_reverse_spinning;
-float g_bugrigs_reverse_speeding;
-float g_bugrigs_reverse_stopping;
-float g_bugrigs_air_steering;
-float g_bugrigs_angle_smoothing;
-float g_bugrigs_friction_floor;
-float g_bugrigs_friction_brake;
-float g_bugrigs_friction_air;
-float g_bugrigs_accel;
-float g_bugrigs_speed_ref;
-float g_bugrigs_speed_pow;
-float g_bugrigs_steer;
-
-#define PHYS_BUGRIGS g_bugrigs
-#define PHYS_BUGRIGS_ANGLE_SMOOTHING g_bugrigs_angle_smoothing
-#define PHYS_BUGRIGS_PLANAR_MOVEMENT g_bugrigs_planar_movement
-#define PHYS_BUGRIGS_REVERSE_SPEEDING g_bugrigs_reverse_speeding
-#define PHYS_BUGRIGS_FRICTION_FLOOR g_bugrigs_friction_floor
-#define PHYS_BUGRIGS_AIR_STEERING g_bugrigs_air_steering
-#define PHYS_BUGRIGS_FRICTION_BRAKE g_bugrigs_friction_brake
-#define PHYS_BUGRIGS_ACCEL g_bugrigs_accel
-#define PHYS_BUGRIGS_SPEED_REF g_bugrigs_speed_ref
-#define PHYS_BUGRIGS_SPEED_POW g_bugrigs_speed_pow
-#define PHYS_BUGRIGS_STEER g_bugrigs_steer
-#define PHYS_BUGRIGS_FRICTION_AIR g_bugrigs_friction_air
-#define PHYS_BUGRIGS_CAR_JUMPING g_bugrigs_planar_movement_car_jumping
-#define PHYS_BUGRIGS_REVERSE_SPINNING g_bugrigs_reverse_spinning
-#define PHYS_BUGRIGS_REVERSE_STOPPING g_bugrigs_reverse_stopping
-
-.float stat_bugrigs;
-.float stat_bugrigs_angle_smoothing;
-.float stat_bugrigs_planar_movement;
-.float stat_bugrigs_reverse_speeding;
-.float stat_bugrigs_friction_floor;
-.float stat_bugrigs_air_steering;
-.float stat_bugrigs_friction_brake;
-.float stat_bugrigs_accel;
-.float stat_bugrigs_speed_ref;
-.float stat_bugrigs_speed_pow;
-.float stat_bugrigs_steer;
-.float stat_bugrigs_friction_air;
-.float stat_bugrigs_car_jumping;
-.float stat_bugrigs_reverse_spinning;
-.float stat_bugrigs_reverse_stopping;
+#define PHYS_BUGRIGS(s) STAT(BUGRIGS, s)
+#define PHYS_BUGRIGS_ACCEL(s) STAT(BUGRIGS_ACCEL, s)
+#define PHYS_BUGRIGS_AIR_STEERING(s) STAT(BUGRIGS_AIR_STEERING, s)
+#define PHYS_BUGRIGS_ANGLE_SMOOTHING(s) STAT(BUGRIGS_ANGLE_SMOOTHING, s)
+#define PHYS_BUGRIGS_CAR_JUMPING(s) STAT(BUGRIGS_CAR_JUMPING, s)
+#define PHYS_BUGRIGS_FRICTION_AIR(s) STAT(BUGRIGS_FRICTION_AIR, s)
+#define PHYS_BUGRIGS_FRICTION_BRAKE(s) STAT(BUGRIGS_FRICTION_BRAKE, s)
+#define PHYS_BUGRIGS_FRICTION_FLOOR(s) STAT(BUGRIGS_FRICTION_FLOOR, s)
+#define PHYS_BUGRIGS_PLANAR_MOVEMENT(s) STAT(BUGRIGS_PLANAR_MOVEMENT, s)
+#define PHYS_BUGRIGS_REVERSE_SPEEDING(s) STAT(BUGRIGS_REVERSE_SPEEDING, s)
+#define PHYS_BUGRIGS_REVERSE_SPINNING(s) STAT(BUGRIGS_REVERSE_SPINNING, s)
+#define PHYS_BUGRIGS_REVERSE_STOPPING(s) STAT(BUGRIGS_REVERSE_STOPPING, s)
+#define PHYS_BUGRIGS_SPEED_POW(s) STAT(BUGRIGS_SPEED_POW, s)
+#define PHYS_BUGRIGS_SPEED_REF(s) STAT(BUGRIGS_SPEED_REF, s)
+#define PHYS_BUGRIGS_STEER(s) STAT(BUGRIGS_STEER, s)
+
+#if defined(SVQC)
void bugrigs_SetVars()
{
g_bugrigs_steer = cvar("g_bugrigs_steer");
}
-void bugrigs_UpdateStats(entity this)
-{
- this.stat_bugrigs = PHYS_BUGRIGS;
- this.stat_bugrigs_angle_smoothing = PHYS_BUGRIGS_ANGLE_SMOOTHING;
- this.stat_bugrigs_planar_movement = PHYS_BUGRIGS_PLANAR_MOVEMENT;
- this.stat_bugrigs_reverse_speeding = PHYS_BUGRIGS_REVERSE_SPEEDING;
- this.stat_bugrigs_friction_floor = PHYS_BUGRIGS_FRICTION_FLOOR;
- this.stat_bugrigs_air_steering = PHYS_BUGRIGS_AIR_STEERING;
- this.stat_bugrigs_friction_brake = PHYS_BUGRIGS_FRICTION_BRAKE;
- this.stat_bugrigs_accel = PHYS_BUGRIGS_ACCEL;
- this.stat_bugrigs_speed_ref = PHYS_BUGRIGS_SPEED_REF;
- this.stat_bugrigs_speed_pow = PHYS_BUGRIGS_SPEED_POW;
- this.stat_bugrigs_steer = PHYS_BUGRIGS_STEER;
- this.stat_bugrigs_friction_air = PHYS_BUGRIGS_FRICTION_AIR;
- this.stat_bugrigs_car_jumping = PHYS_BUGRIGS_CAR_JUMPING;
- this.stat_bugrigs_reverse_spinning = PHYS_BUGRIGS_REVERSE_SPINNING;
- this.stat_bugrigs_reverse_stopping = PHYS_BUGRIGS_REVERSE_STOPPING;
-}
-
-void bugrigs_AddStats()
-{
- addstat(STAT_BUGRIGS, AS_INT, stat_bugrigs);
- addstat(STAT_BUGRIGS_ANGLE_SMOOTHING, AS_INT, stat_bugrigs_angle_smoothing);
- addstat(STAT_BUGRIGS_PLANAR_MOVEMENT, AS_INT, stat_bugrigs_planar_movement);
- addstat(STAT_BUGRIGS_REVERSE_SPEEDING, AS_INT, stat_bugrigs_reverse_speeding);
- addstat(STAT_BUGRIGS_FRICTION_FLOOR, AS_FLOAT, stat_bugrigs_friction_floor);
- addstat(STAT_BUGRIGS_AIR_STEERING, AS_INT, stat_bugrigs_air_steering);
- addstat(STAT_BUGRIGS_FRICTION_BRAKE, AS_FLOAT, stat_bugrigs_friction_brake);
- addstat(STAT_BUGRIGS_ACCEL, AS_FLOAT, stat_bugrigs_accel);
- addstat(STAT_BUGRIGS_SPEED_REF, AS_FLOAT, stat_bugrigs_speed_ref);
- addstat(STAT_BUGRIGS_SPEED_POW, AS_FLOAT, stat_bugrigs_speed_pow);
- addstat(STAT_BUGRIGS_STEER, AS_FLOAT, stat_bugrigs_steer);
- addstat(STAT_BUGRIGS_FRICTION_AIR, AS_FLOAT, stat_bugrigs_friction_air);
- addstat(STAT_BUGRIGS_CAR_JUMPING, AS_FLOAT, stat_bugrigs_car_jumping);
- addstat(STAT_BUGRIGS_REVERSE_SPINNING, AS_FLOAT, stat_bugrigs_reverse_spinning);
- addstat(STAT_BUGRIGS_REVERSE_STOPPING, AS_FLOAT, stat_bugrigs_reverse_stopping);
-}
-
#endif
void RaceCarPhysics(entity this)
float accel = bound(-1, this.movement.x / PHYS_MAXSPEED(this), 1);
float steer = bound(-1, this.movement.y / PHYS_MAXSPEED(this), 1);
- if (PHYS_BUGRIGS_REVERSE_SPEEDING)
+ if (PHYS_BUGRIGS_REVERSE_SPEEDING(this))
{
if (accel < 0)
{
this.angles_z = 0;
makevectors(this.angles); // new forward direction!
- if (IS_ONGROUND(this) || PHYS_BUGRIGS_AIR_STEERING)
+ if (IS_ONGROUND(this) || PHYS_BUGRIGS_AIR_STEERING(this))
{
float myspeed = this.velocity * v_forward;
float upspeed = this.velocity * v_up;
// responsiveness factor for steering and acceleration
- float f = 1 / (1 + pow(max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF, PHYS_BUGRIGS_SPEED_POW));
- //MAXIMA: f(v) := 1 / (1 + (v / PHYS_BUGRIGS_SPEED_REF) ^ PHYS_BUGRIGS_SPEED_POW);
+ float f = 1 / (1 + pow(max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF(this), PHYS_BUGRIGS_SPEED_POW(this)));
+ //MAXIMA: f(v) := 1 / (1 + (v / PHYS_BUGRIGS_SPEED_REF(this)) ^ PHYS_BUGRIGS_SPEED_POW(this));
float steerfactor;
- if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPINNING)
- steerfactor = -myspeed * PHYS_BUGRIGS_STEER;
+ if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPINNING(this))
+ steerfactor = -myspeed * PHYS_BUGRIGS_STEER(this);
else
- steerfactor = -myspeed * f * PHYS_BUGRIGS_STEER;
+ steerfactor = -myspeed * f * PHYS_BUGRIGS_STEER(this);
float accelfactor;
- if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPEEDING)
- accelfactor = PHYS_BUGRIGS_ACCEL;
+ if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPEEDING(this))
+ accelfactor = PHYS_BUGRIGS_ACCEL(this);
else
- accelfactor = f * PHYS_BUGRIGS_ACCEL;
- //MAXIMA: accel(v) := f(v) * PHYS_BUGRIGS_ACCEL;
+ accelfactor = f * PHYS_BUGRIGS_ACCEL(this);
+ //MAXIMA: accel(v) := f(v) * PHYS_BUGRIGS_ACCEL(this);
if (accel < 0)
{
if (myspeed > 0)
{
- myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * (PHYS_BUGRIGS_FRICTION_FLOOR - PHYS_BUGRIGS_FRICTION_BRAKE * accel));
+ myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * (PHYS_BUGRIGS_FRICTION_FLOOR(this) - PHYS_BUGRIGS_FRICTION_BRAKE(this) * accel));
}
else
{
- if (!PHYS_BUGRIGS_REVERSE_SPEEDING)
- myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_FRICTION_FLOOR);
+ if (!PHYS_BUGRIGS_REVERSE_SPEEDING(this))
+ myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_FRICTION_FLOOR(this));
}
}
else
{
if (myspeed >= 0)
{
- myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_FRICTION_FLOOR);
+ myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_FRICTION_FLOOR(this));
}
else
{
- if (PHYS_BUGRIGS_REVERSE_STOPPING)
+ if (PHYS_BUGRIGS_REVERSE_STOPPING(this))
myspeed = 0;
else
- myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * (PHYS_BUGRIGS_FRICTION_FLOOR + PHYS_BUGRIGS_FRICTION_BRAKE * accel));
+ myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * (PHYS_BUGRIGS_FRICTION_FLOOR(this) + PHYS_BUGRIGS_FRICTION_BRAKE(this) * accel));
}
}
// terminal velocity = velocity at which 50 == accelfactor, that is, 1549 units/sec
- //MAXIMA: friction(v) := PHYS_BUGRIGS_FRICTION_FLOOR;
+ //MAXIMA: friction(v) := PHYS_BUGRIGS_FRICTION_FLOOR(this);
this.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering
makevectors(this.angles); // new forward direction!
float myspeed = vlen(this.velocity);
// responsiveness factor for steering and acceleration
- float f = 1 / (1 + pow(max(0, myspeed / PHYS_BUGRIGS_SPEED_REF), PHYS_BUGRIGS_SPEED_POW));
+ float f = 1 / (1 + pow(max(0, myspeed / PHYS_BUGRIGS_SPEED_REF(this)), PHYS_BUGRIGS_SPEED_POW(this)));
float steerfactor = -myspeed * f;
this.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering
makevectors(this.angles); // new forward direction!
}
- rigvel *= max(0, 1 - vlen(rigvel) * PHYS_BUGRIGS_FRICTION_AIR * PHYS_INPUT_TIMELENGTH);
- //MAXIMA: airfriction(v) := v * v * PHYS_BUGRIGS_FRICTION_AIR;
+ rigvel *= max(0, 1 - vlen(rigvel) * PHYS_BUGRIGS_FRICTION_AIR(this) * PHYS_INPUT_TIMELENGTH);
+ //MAXIMA: airfriction(v) := v * v * PHYS_BUGRIGS_FRICTION_AIR(this);
//MAXIMA: total_acceleration(v) := accel(v) - friction(v) - airfriction(v);
//MAXIMA: solve(total_acceleration(v) = 0, v);
- if (PHYS_BUGRIGS_PLANAR_MOVEMENT)
+ if (PHYS_BUGRIGS_PLANAR_MOVEMENT(this))
{
vector rigvel_xy, neworigin, up;
float mt;
- rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better
+ rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY(this); // 4x gravity plays better
rigvel_xy = vec2(rigvel);
- if (PHYS_BUGRIGS_CAR_JUMPING)
+ if (PHYS_BUGRIGS_CAR_JUMPING(this))
mt = MOVE_NORMAL;
else
mt = MOVE_NOMONSTERS;
}
else
{
- rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better
+ rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY(this); // 4x gravity plays better
this.velocity = rigvel;
this.movetype = MOVETYPE_FLY;
}
// smooth the angles
vector vf1, vu1, smoothangles;
makevectors(this.angles);
- float f = bound(0, PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_ANGLE_SMOOTHING, 1);
+ float f = bound(0, PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_ANGLE_SMOOTHING(this), 1);
if (f == 0)
f = 1;
vf1 = v_forward * f;
this.angles_x = -smoothangles_x;
this.angles_z = smoothangles_z;
- PM_ClientMovement_Move();
+ PM_ClientMovement_Move(this);
}
#ifdef SVQC
#endif
MUTATOR_HOOKFUNCTION(bugrigs, PM_Physics)
{
- if(!PHYS_BUGRIGS || !IS_PLAYER(self)) { return false; }
+ if(!PHYS_BUGRIGS(self) || !IS_PLAYER(self)) { return false; }
#ifdef SVQC
self.angles = self.bugrigs_prevangles;
MUTATOR_HOOKFUNCTION(bugrigs, PlayerPhysics)
{
- if(!PHYS_BUGRIGS) { return false; }
+ if(!PHYS_BUGRIGS(self)) { return false; }
#ifdef SVQC
self.bugrigs_prevangles = self.angles;
-
- bugrigs_UpdateStats(self);
#endif
return false;
}
#ifdef IMPLEMENTATION
+#define PHYS_DODGING STAT(DODGING, this)
+#define PHYS_DODGING_DELAY STAT(DODGING_DELAY, this)
+#define PHYS_DODGING_DISTANCE_THRESHOLD STAT(DODGING_DISTANCE_THRESHOLD, this)
+#define PHYS_DODGING_FROZEN_NODOUBLETAP STAT(DODGING_FROZEN_NO_DOUBLETAP, this)
+#define PHYS_DODGING_HEIGHT_THRESHOLD STAT(DODGING_HEIGHT_THRESHOLD, this)
+#define PHYS_DODGING_HORIZ_SPEED STAT(DODGING_HORIZ_SPEED, this)
+#define PHYS_DODGING_HORIZ_SPEED_FROZEN STAT(DODGING_HORIZ_SPEED_FROZEN, this)
+#define PHYS_DODGING_RAMP_TIME STAT(DODGING_RAMP_TIME, this)
+#define PHYS_DODGING_UP_SPEED STAT(DODGING_UP_SPEED, this)
+#define PHYS_DODGING_WALL STAT(DODGING_WALL, this)
+#define PHYS_DODGING_PRESSED_KEYS(s) (s).pressedkeys
+
#ifdef CSQC
#define PHYS_DODGING_FRAMETIME (1 / (frametime <= 0 ? 60 : frametime))
- #define PHYS_DODGING getstati(STAT_DODGING)
- #define PHYS_DODGING_DELAY getstatf(STAT_DODGING_DELAY)
- #define PHYS_DODGING_TIMEOUT(s) getstatf(STAT_DODGING_TIMEOUT)
- #define PHYS_DODGING_HORIZ_SPEED_FROZEN getstatf(STAT_DODGING_HORIZ_SPEED_FROZEN)
- #define PHYS_DODGING_FROZEN_NODOUBLETAP getstati(STAT_DODGING_FROZEN_NO_DOUBLETAP)
- #define PHYS_DODGING_HORIZ_SPEED getstatf(STAT_DODGING_HORIZ_SPEED)
- #define PHYS_DODGING_PRESSED_KEYS(s) s.pressedkeys
- #define PHYS_DODGING_HEIGHT_THRESHOLD getstatf(STAT_DODGING_HEIGHT_THRESHOLD)
- #define PHYS_DODGING_DISTANCE_THRESHOLD getstatf(STAT_DODGING_DISTANCE_THRESHOLD)
- #define PHYS_DODGING_RAMP_TIME getstatf(STAT_DODGING_RAMP_TIME)
- #define PHYS_DODGING_UP_SPEED getstatf(STAT_DODGING_UP_SPEED)
- #define PHYS_DODGING_WALL getstatf(STAT_DODGING_WALL)
+ #define PHYS_DODGING_TIMEOUT(s) STAT(DODGING_TIMEOUT)
#elif defined(SVQC)
#define PHYS_DODGING_FRAMETIME sys_frametime
- #define PHYS_DODGING g_dodging
- #define PHYS_DODGING_DELAY autocvar_sv_dodging_delay
#define PHYS_DODGING_TIMEOUT(s) s.cvar_cl_dodging_timeout
- #define PHYS_DODGING_HORIZ_SPEED_FROZEN autocvar_sv_dodging_horiz_speed_frozen
- #define PHYS_DODGING_FROZEN_NODOUBLETAP autocvar_sv_dodging_frozen_doubletap
- #define PHYS_DODGING_HORIZ_SPEED autocvar_sv_dodging_horiz_speed
- #define PHYS_DODGING_PRESSED_KEYS(s) s.pressedkeys
- #define PHYS_DODGING_HEIGHT_THRESHOLD autocvar_sv_dodging_height_threshold
- #define PHYS_DODGING_DISTANCE_THRESHOLD autocvar_sv_dodging_wall_distance_threshold
- #define PHYS_DODGING_RAMP_TIME autocvar_sv_dodging_ramp_time
- #define PHYS_DODGING_UP_SPEED autocvar_sv_dodging_up_speed
- #define PHYS_DODGING_WALL autocvar_sv_dodging_wall_dodging
-
- float autocvar_sv_dodging_delay;
- float autocvar_sv_dodging_height_threshold;
- float autocvar_sv_dodging_horiz_speed;
- float autocvar_sv_dodging_horiz_speed_frozen;
- float autocvar_sv_dodging_ramp_time;
- bool autocvar_sv_dodging_sound;
- float autocvar_sv_dodging_up_speed;
- float autocvar_sv_dodging_wall_distance_threshold;
- bool autocvar_sv_dodging_wall_dodging;
- bool autocvar_sv_dodging_frozen_doubletap;
+
+
#endif
#ifdef SVQC
-float g_dodging;
+bool autocvar_sv_dodging_sound;
// set to 1 to indicate dodging has started.. reset by physics hook after dodge has been done..
.float dodging_action;
#include "../../../animdecide.qh"
#include "../../../physics.qh"
-.float cvar_cl_dodging_timeout;
-
-.float stat_dodging;
-.float stat_dodging_delay;
-.float stat_dodging_horiz_speed_frozen;
-.float stat_dodging_frozen_nodoubletap;
-.float stat_dodging_frozen;
-.float stat_dodging_horiz_speed;
-.float stat_dodging_height_threshold;
-.float stat_dodging_distance_threshold;
-.float stat_dodging_ramp_time;
-.float stat_dodging_up_speed;
-.float stat_dodging_wall;
+.float cvar_cl_dodging_timeout = _STAT(DODGING_TIMEOUT);
REGISTER_MUTATOR(dodging, cvar("g_dodging"))
{
MUTATOR_ONADD
{
g_dodging = cvar("g_dodging");
- addstat(STAT_DODGING, AS_INT, stat_dodging);
- addstat(STAT_DODGING_DELAY, AS_FLOAT, stat_dodging_delay);
- addstat(STAT_DODGING_TIMEOUT, AS_FLOAT, cvar_cl_dodging_timeout); // we stat this, so it is updated on the client when updated on server (otherwise, chaos)
- addstat(STAT_DODGING_FROZEN_NO_DOUBLETAP, AS_INT, stat_dodging_frozen_nodoubletap);
- addstat(STAT_DODGING_HORIZ_SPEED_FROZEN, AS_FLOAT, stat_dodging_horiz_speed_frozen);
- addstat(STAT_DODGING_FROZEN, AS_INT, stat_dodging_frozen);
- addstat(STAT_DODGING_HORIZ_SPEED, AS_FLOAT, stat_dodging_horiz_speed);
- addstat(STAT_DODGING_HEIGHT_THRESHOLD, AS_FLOAT, stat_dodging_height_threshold);
- addstat(STAT_DODGING_DISTANCE_THRESHOLD, AS_FLOAT, stat_dodging_distance_threshold);
- addstat(STAT_DODGING_RAMP_TIME, AS_FLOAT, stat_dodging_ramp_time);
- addstat(STAT_DODGING_UP_SPEED, AS_FLOAT, stat_dodging_up_speed);
- addstat(STAT_DODGING_WALL, AS_FLOAT, stat_dodging_wall);
}
// this just turns off the cvar.
.int pressedkeys;
#endif
-void dodging_UpdateStats(entity this)
-{
-#ifdef SVQC
- this.stat_dodging = PHYS_DODGING;
- this.stat_dodging_delay = PHYS_DODGING_DELAY;
- this.stat_dodging_horiz_speed_frozen = PHYS_DODGING_HORIZ_SPEED_FROZEN;
- this.stat_dodging_frozen = PHYS_DODGING_FROZEN;
- this.stat_dodging_frozen_nodoubletap = PHYS_DODGING_FROZEN_NODOUBLETAP;
- this.stat_dodging_height_threshold = PHYS_DODGING_HEIGHT_THRESHOLD;
- this.stat_dodging_distance_threshold = PHYS_DODGING_DISTANCE_THRESHOLD;
- this.stat_dodging_ramp_time = PHYS_DODGING_RAMP_TIME;
- this.stat_dodging_up_speed = PHYS_DODGING_UP_SPEED;
- this.stat_dodging_wall = PHYS_DODGING_WALL;
-#endif
-}
-
// returns 1 if the player is close to a wall
bool check_close_to_wall(entity this, float threshold)
{
if (!PHYS_DODGING)
return;
- dodging_UpdateStats(this);
-
if (PHYS_DEAD(this))
return;
#ifdef SVQC
if (autocvar_sv_dodging_sound)
- PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
animdecide_setaction(this, ANIMACTION_JUMP, true);
#endif
#endif
#include "../../../physics.qh"
-
-#if defined(SVQC)
-void doublejump_AddStats();
-
-REGISTER_MUTATOR(doublejump, true)
-{
- MUTATOR_ONADD
- {
- doublejump_AddStats();
- }
- return false;
-}
+#ifdef SVQC
+REGISTER_MUTATOR(doublejump, autocvar_sv_doublejump);
#elif defined(CSQC)
REGISTER_MUTATOR(doublejump, true);
#endif
-
-#ifdef CSQC
-
-#define PHYS_DOUBLEJUMP getstati(STAT_DOUBLEJUMP)
-
-#elif defined(SVQC)
-
-bool autocvar_sv_doublejump;
-
-#define PHYS_DOUBLEJUMP autocvar_sv_doublejump
-
-.int stat_doublejump;
-
-void doublejump_UpdateStats(entity this)
-{
- this.stat_doublejump = PHYS_DOUBLEJUMP;
-}
-
-void doublejump_AddStats()
-{
- addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump);
-}
-
-#endif
+#define PHYS_DOUBLEJUMP(s) STAT(DOUBLEJUMP, s)
MUTATOR_HOOKFUNCTION(doublejump, PlayerJump)
{
- if (PHYS_DOUBLEJUMP)
+ if (PHYS_DOUBLEJUMP(self))
{
tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
return false;
}
-MUTATOR_HOOKFUNCTION(doublejump, PlayerPhysics)
-{
-#ifdef SVQC
- doublejump_UpdateStats(self);
-#endif
- return false;
-}
-
-#ifdef SVQC
-
-MUTATOR_HOOKFUNCTION(doublejump, BuildMutatorsString)
-{
- ret_string = strcat(ret_string, ":doublejump");
- return false;
-}
-
-MUTATOR_HOOKFUNCTION(doublejump, BuildMutatorsPrettyString)
-{
- ret_string = strcat(ret_string, ", Double jump");
- return false;
-}
-
-#endif
#endif
#if defined(SVQC)
-void multijump_AddStats();
-
-REGISTER_MUTATOR(multijump, cvar("g_multijump"))
-{
- MUTATOR_ONADD
- {
- multijump_AddStats();
- }
- return false;
-}
+REGISTER_MUTATOR(multijump, cvar("g_multijump"));
#elif defined(CSQC)
REGISTER_MUTATOR(multijump, true);
#endif
-.int multijump_count;
+#define PHYS_MULTIJUMP STAT(MULTIJUMP, self)
+#define PHYS_MULTIJUMP_SPEED STAT(MULTIJUMP_SPEED, self)
+#define PHYS_MULTIJUMP_ADD STAT(MULTIJUMP_ADD, self)
+#define PHYS_MULTIJUMP_MAXSPEED STAT(MULTIJUMP_MAXSPEED, self)
+#define PHYS_MULTIJUMP_DODGING STAT(MULTIJUMP_DODGING, self)
+#define PHYS_MULTIJUMP_COUNT(s) STAT(MULTIJUMP_COUNT, s)
+
.bool multijump_ready;
#ifdef CSQC
+bool autocvar_cl_multijump = false;
-bool autocvar_cl_multijump = true;
-
-#define PHYS_MULTIJUMP getstati(STAT_MULTIJUMP)
-#define PHYS_MULTIJUMP_SPEED getstatf(STAT_MULTIJUMP_SPEED)
-#define PHYS_MULTIJUMP_ADD getstati(STAT_MULTIJUMP_ADD)
-#define PHYS_MULTIJUMP_MAXSPEED getstatf(STAT_MULTIJUMP_MAXSPEED)
-#define PHYS_MULTIJUMP_DODGING getstati(STAT_MULTIJUMP_DODGING)
-#define PHYS_MULTIJUMP_COUNT(s) getstati(STAT_MULTIJUMP_COUNT)
-#define PHYS_MULTIJUMP_CLIENT(s) autocvar_cl_multijump
-
+ #define PHYS_MULTIJUMP_CLIENT(s) autocvar_cl_multijump
#elif defined(SVQC)
-
.bool cvar_cl_multijump;
-int autocvar_g_multijump;
-float autocvar_g_multijump_add;
-float autocvar_g_multijump_speed;
-float autocvar_g_multijump_maxspeed;
-float autocvar_g_multijump_dodging = 1;
-
-#define PHYS_MULTIJUMP autocvar_g_multijump
-#define PHYS_MULTIJUMP_SPEED autocvar_g_multijump_speed
-#define PHYS_MULTIJUMP_ADD autocvar_g_multijump_add
-#define PHYS_MULTIJUMP_MAXSPEED autocvar_g_multijump_maxspeed
-#define PHYS_MULTIJUMP_DODGING autocvar_g_multijump_dodging
-#define PHYS_MULTIJUMP_COUNT(s) (s).multijump_count
-#define PHYS_MULTIJUMP_CLIENT(s) (s).cvar_cl_multijump
-
-.float stat_multijump;
-.float stat_multijump_speed;
-.float stat_multijump_add;
-.float stat_multijump_maxspeed;
-.float stat_multijump_dodging;
-
-void multijump_UpdateStats(entity this)
-{
- this.stat_multijump = PHYS_MULTIJUMP;
- this.stat_multijump_speed = PHYS_MULTIJUMP_SPEED;
- this.stat_multijump_add = PHYS_MULTIJUMP_ADD;
- this.stat_multijump_maxspeed = PHYS_MULTIJUMP_MAXSPEED;
- this.stat_multijump_dodging = PHYS_MULTIJUMP_DODGING;
-}
-
-void multijump_AddStats()
-{
- addstat(STAT_MULTIJUMP, AS_INT, stat_multijump);
- addstat(STAT_MULTIJUMP_SPEED, AS_FLOAT, stat_multijump_speed);
- addstat(STAT_MULTIJUMP_ADD, AS_INT, stat_multijump_add);
- addstat(STAT_MULTIJUMP_MAXSPEED, AS_FLOAT, stat_multijump_maxspeed);
- addstat(STAT_MULTIJUMP_DODGING, AS_INT, stat_multijump_dodging);
- addstat(STAT_MULTIJUMP_COUNT, AS_INT, multijump_count);
-}
-
+ #define PHYS_MULTIJUMP_CLIENT(s) (s).cvar_cl_multijump
#endif
-void PM_multijump(entity this)
-{
- if(!PHYS_MULTIJUMP) { return; }
-
- if(IS_ONGROUND(this))
- this.multijump_count = 0;
-}
-
bool PM_multijump_checkjump(entity this)
{
if(!PHYS_MULTIJUMP) { return false; }
{
if (!PHYS_MULTIJUMP_ADD) // in this case we make the z velocity == jumpvelocity
{
- if (this.velocity_z < PHYS_JUMPVELOCITY)
+ if (this.velocity_z < PHYS_JUMPVELOCITY(this))
{
player_multijump = true;
this.velocity_z = 0;
MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics)
{
-#ifdef SVQC
- multijump_UpdateStats(self);
-#elif defined(CSQC)
+#ifdef CSQC
self.multijump_count = PHYS_MULTIJUMP_COUNT(self);
#endif
- PM_multijump(self);
+ if(!PHYS_MULTIJUMP) { return; }
+
+ if(IS_ONGROUND(self))
+ self.multijump_count = 0;
return false;
}
REGISTER_MUTATOR(cl_nades, true);
MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
{
- if (getstatf(STAT_HEALING_ORB) <= time) return false;
+ if (STAT(HEALING_ORB) <= time) return false;
MUTATOR_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
- MUTATOR_ARGV(0, float) = getstatf(STAT_HEALING_ORB_ALPHA);
+ MUTATOR_ARGV(0, float) = STAT(HEALING_ORB_ALPHA);
return true;
}
MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
}
void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
{
- float bonusNades = getstatf(STAT_NADE_BONUS);
- float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
- float bonusType = getstati(STAT_NADE_BONUS_TYPE);
+ float bonusNades = STAT(NADE_BONUS);
+ float bonusProgress = STAT(NADE_BONUS_SCORE);
+ float bonusType = STAT(NADE_BONUS_TYPE);
Nade def = Nades_from(bonusType);
vector nadeColor = def.m_color;
string nadeIcon = def.m_icon;
#include "../../../monsters/sv_monsters.qh"
#include "../../../../server/g_subs.qh"
-REGISTER_MUTATOR(nades, cvar("g_nades"))
-{
- MUTATOR_ONADD
- {
- addstat(STAT_NADE_TIMER, AS_FLOAT, nade_timer);
- addstat(STAT_NADE_BONUS, AS_FLOAT, bonus_nades);
- addstat(STAT_NADE_BONUS_TYPE, AS_INT, nade_type);
- addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score);
- addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb);
- addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha);
- }
-
- return false;
-}
+REGISTER_MUTATOR(nades, cvar("g_nades"));
.float nade_time_primed;
.entity nade;
.entity fake_nade;
-.float nade_timer;
+.float nade_timer = _STAT(NADE_TIMER);
.float nade_refire;
-.float bonus_nades;
+.float bonus_nades = _STAT(NADE_BONUS);
.float nade_special_time;
-.float bonus_nade_score;
-.float nade_type;
+.float bonus_nade_score = _STAT(NADE_BONUS_SCORE);
+.int nade_type = _STAT(NADE_BONUS_TYPE);
.string pokenade_type;
.entity nade_damage_target;
.float cvar_cl_nade_type;
.string cvar_cl_pokenade_type;
.float toss_time;
-.float stat_healing_orb;
-.float stat_healing_orb_alpha;
+.float stat_healing_orb = _STAT(HEALING_ORB);
+.float stat_healing_orb_alpha = _STAT(HEALING_ORB_ALPHA);
.float nade_show_particles;
bool healer_send(entity this, entity to, int sf);
#ifdef SVQC
#include "overkill.qc"
#endif
+#ifdef CSQC
+ #ifdef IMPLEMENTATION
+ REGISTER_MUTATOR(ok, false)
+ {
+ MUTATOR_ONADD {
+ cvar_settemp("g_overkill", "1");
+ WEP_SHOTGUN.mdl = "ok_shotgun";
+ WEP_MACHINEGUN.mdl = "ok_mg";
+ WEP_VORTEX.mdl = "ok_sniper";
+ }
+ }
+ #endif
+#endif
.float ok_notice_time;
.float ammo_charge[Weapons_MAX];
-.float ok_use_ammocharge;
-.float ok_ammo_charge;
+.float ok_use_ammocharge = _STAT(OK_AMMO_CHARGE);
+.float ok_ammo_charge = _STAT(OK_AMMO_CHARGEPOOL);
.float ok_pauseregen_finished;
precache_all_playermodels("models/ok_player/*.dpm");
- addstat(STAT_OK_AMMO_CHARGE, AS_FLOAT, ok_use_ammocharge);
- addstat(STAT_OK_AMMO_CHARGEPOOL, AS_FLOAT, ok_ammo_charge);
-
WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
int autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
bool autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath;
-REGISTER_MUTATOR(spawn_near_teammate, cvar("g_spawn_near_teammate") && teamplay);
+REGISTER_MUTATOR(spawn_near_teammate, cvar("g_spawn_near_teammate"));
.entity msnt_lookat;
MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
{SELFPARAM();
+ if(!teamplay) { return false; }
// Note: when entering this, fixangle is already set.
if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && self.cvar_cl_spawn_near_teammate))
{
else
fixedmakevectors(team_mate.angles);
- for(pc = 0; pc != 5; ++pc) // test 5 diffrent spots close to mate
+ for(pc = 0; pc < 5; ++pc) // test 5 diffrent spots close to mate
{
switch(pc)
{
InterpolateOrigin_Do(self);
- float t = GetPlayerColor(player_localnum) + 1;
+ float t = entcs_GetTeam(player_localnum) + 1;
string spriteimage = "";
return autocvar_g_physics_clientselect && strhasword(autocvar_g_physics_clientselect_options, thecvar);
}
-float Physics_ClientOption(entity pl, string option)
+float Physics_ClientOption(entity this, string option)
{
- if(Physics_Valid(pl.cvar_cl_physics))
+ if(Physics_Valid(this.cvar_cl_physics))
{
- string s = sprintf("g_physics_%s_%s", pl.cvar_cl_physics, option);
+ string s = sprintf("g_physics_%s_%s", this.cvar_cl_physics, option);
if(cvar_type(s) & CVAR_TYPEFLAG_EXISTS)
return cvar(s);
}
return cvar(strcat("sv_", option));
}
-void Physics_AddStats()
+void Physics_UpdateStats(entity this, float maxspd_mod)
{
- // static view offset and hitbox vectors
- // networked for all you bandwidth pigs out there
- addstat(STAT_PL_VIEW_OFS1, AS_FLOAT, stat_pl_view_ofs_x);
- addstat(STAT_PL_VIEW_OFS2, AS_FLOAT, stat_pl_view_ofs_y);
- addstat(STAT_PL_VIEW_OFS3, AS_FLOAT, stat_pl_view_ofs_z);
- addstat(STAT_PL_CROUCH_VIEW_OFS1, AS_FLOAT, stat_pl_crouch_view_ofs_x);
- addstat(STAT_PL_CROUCH_VIEW_OFS2, AS_FLOAT, stat_pl_crouch_view_ofs_y);
- addstat(STAT_PL_CROUCH_VIEW_OFS3, AS_FLOAT, stat_pl_crouch_view_ofs_z);
-
- addstat(STAT_PL_MIN1, AS_FLOAT, stat_pl_min_x);
- addstat(STAT_PL_MIN2, AS_FLOAT, stat_pl_min_y);
- addstat(STAT_PL_MIN3, AS_FLOAT, stat_pl_min_z);
- addstat(STAT_PL_MAX1, AS_FLOAT, stat_pl_max_x);
- addstat(STAT_PL_MAX2, AS_FLOAT, stat_pl_max_y);
- addstat(STAT_PL_MAX3, AS_FLOAT, stat_pl_max_z);
- addstat(STAT_PL_CROUCH_MIN1, AS_FLOAT, stat_pl_crouch_min_x);
- addstat(STAT_PL_CROUCH_MIN2, AS_FLOAT, stat_pl_crouch_min_y);
- addstat(STAT_PL_CROUCH_MIN3, AS_FLOAT, stat_pl_crouch_min_z);
- addstat(STAT_PL_CROUCH_MAX1, AS_FLOAT, stat_pl_crouch_max_x);
- addstat(STAT_PL_CROUCH_MAX2, AS_FLOAT, stat_pl_crouch_max_y);
- addstat(STAT_PL_CROUCH_MAX3, AS_FLOAT, stat_pl_crouch_max_z);
-
- // 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);
- addstat(STAT_MOVEVARS_HIGHSPEED, AS_FLOAT, stat_movement_highspeed);
-
- // jet pack
- addstat(STAT_JETPACK_ACCEL_SIDE, AS_FLOAT, stat_jetpack_accel_side);
- addstat(STAT_JETPACK_ACCEL_UP, AS_FLOAT, stat_jetpack_accel_up);
- addstat(STAT_JETPACK_ANTIGRAVITY, AS_FLOAT, stat_jetpack_antigravity);
- addstat(STAT_JETPACK_FUEL, AS_FLOAT, stat_jetpack_fuel);
- addstat(STAT_JETPACK_MAXSPEED_UP, AS_FLOAT, stat_jetpack_maxspeed_up);
- addstat(STAT_JETPACK_MAXSPEED_SIDE, AS_FLOAT, stat_jetpack_maxspeed_side);
-
- // hack to fix track_canjump
- addstat(STAT_MOVEVARS_CL_TRACK_CANJUMP, AS_INT, cvar_cl_movement_track_canjump);
- addstat(STAT_MOVEVARS_TRACK_CANJUMP, AS_INT, stat_sv_track_canjump);
-
- // jump speed caps
- addstat(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, AS_INT, stat_jumpspeedcap_disable_onramps);
-
- // hacks
- addstat(STAT_MOVEVARS_FRICTION_ONLAND, AS_FLOAT, stat_sv_friction_on_land);
- addstat(STAT_MOVEVARS_FRICTION_SLICK, AS_FLOAT, stat_sv_friction_slick);
- addstat(STAT_GAMEPLAYFIX_EASIERWATERJUMP, AS_INT, stat_gameplayfix_easierwaterjump);
-
- // new properties
- addstat(STAT_MOVEVARS_JUMPVELOCITY, AS_FLOAT, stat_sv_jumpvelocity);
- addstat(STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, AS_FLOAT, stat_sv_airaccel_qw_stretchfactor);
- addstat(STAT_MOVEVARS_MAXAIRSTRAFESPEED, AS_FLOAT, stat_sv_maxairstrafespeed);
- addstat(STAT_MOVEVARS_MAXAIRSPEED, AS_FLOAT, stat_sv_maxairspeed);
- addstat(STAT_MOVEVARS_AIRSTRAFEACCELERATE, AS_FLOAT, stat_sv_airstrafeaccelerate);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL, AS_FLOAT, stat_sv_warsowbunny_turnaccel);
- addstat(STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, AS_FLOAT, stat_sv_airaccel_sideways_friction);
- addstat(STAT_MOVEVARS_AIRCONTROL, AS_FLOAT, stat_sv_aircontrol);
- addstat(STAT_MOVEVARS_AIRCONTROL_POWER, AS_FLOAT, stat_sv_aircontrol_power);
- addstat(STAT_MOVEVARS_AIRCONTROL_PENALTY, AS_FLOAT, stat_sv_aircontrol_penalty);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, AS_FLOAT, stat_sv_warsowbunny_airforwardaccel);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED, AS_FLOAT, stat_sv_warsowbunny_topspeed);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_ACCEL, AS_FLOAT, stat_sv_warsowbunny_accel);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, AS_FLOAT, stat_sv_warsowbunny_backtosideratio);
- addstat(STAT_MOVEVARS_FRICTION, AS_FLOAT, stat_sv_friction);
- addstat(STAT_MOVEVARS_ACCELERATE, AS_FLOAT, stat_sv_accelerate);
- addstat(STAT_MOVEVARS_STOPSPEED, AS_FLOAT, stat_sv_stopspeed);
- addstat(STAT_MOVEVARS_AIRACCELERATE, AS_FLOAT, stat_sv_airaccelerate);
- addstat(STAT_MOVEVARS_AIRSTOPACCELERATE, AS_FLOAT, stat_sv_airstopaccelerate);
-
- addstat(STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, AS_INT, stat_gameplayfix_upvelocityclearsonground);
-}
-
-void Physics_UpdateStats(float maxspd_mod)
-{SELFPARAM();
- // blah
- self.stat_pl_view_ofs = PL_VIEW_OFS;
- self.stat_pl_crouch_view_ofs = PL_CROUCH_VIEW_OFS;
-
- self.stat_pl_min = PL_MIN;
- self.stat_pl_max = PL_MAX;
- self.stat_pl_crouch_min = PL_CROUCH_MIN;
- self.stat_pl_crouch_max = PL_CROUCH_MAX;
-
-
- self.stat_sv_airaccel_qw = AdjustAirAccelQW(Physics_ClientOption(self, "airaccel_qw"), maxspd_mod);
- if(Physics_ClientOption(self, "airstrafeaccel_qw"))
- self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(Physics_ClientOption(self, "airstrafeaccel_qw"), maxspd_mod);
- else
- self.stat_sv_airstrafeaccel_qw = 0;
- self.stat_sv_airspeedlimit_nonqw = Physics_ClientOption(self, "airspeedlimit_nonqw") * maxspd_mod;
- self.stat_sv_maxspeed = Physics_ClientOption(self, "maxspeed") * maxspd_mod; // also slow walking
- self.stat_movement_highspeed = PHYS_HIGHSPEED; // TODO: remove this!
-
- self.stat_jetpack_antigravity = PHYS_JETPACK_ANTIGRAVITY;
- self.stat_jetpack_accel_up = PHYS_JETPACK_ACCEL_UP;
- self.stat_jetpack_accel_side = PHYS_JETPACK_ACCEL_SIDE;
- self.stat_jetpack_maxspeed_side = PHYS_JETPACK_MAXSPEED_SIDE;
- self.stat_jetpack_maxspeed_up = PHYS_JETPACK_MAXSPEED_UP;
- self.stat_jetpack_fuel = PHYS_JETPACK_FUEL;
-
- self.stat_jumpspeedcap_disable_onramps = PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS;
-
- self.stat_sv_friction_on_land = PHYS_FRICTION_ONLAND;
- self.stat_sv_friction_slick = PHYS_FRICTION_SLICK;
-
- self.stat_gameplayfix_easierwaterjump = GAMEPLAYFIX_EASIERWATERJUMP;
-
+ STAT(MOVEVARS_AIRACCEL_QW, this) = AdjustAirAccelQW(Physics_ClientOption(this, "airaccel_qw"), maxspd_mod);
+ STAT(MOVEVARS_AIRSTRAFEACCEL_QW, this) = (Physics_ClientOption(this, "airstrafeaccel_qw"))
+ ? AdjustAirAccelQW(Physics_ClientOption(this, "airstrafeaccel_qw"), maxspd_mod)
+ : 0;
+ STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, this) = Physics_ClientOption(this, "airspeedlimit_nonqw") * maxspd_mod;
+ STAT(MOVEVARS_MAXSPEED, this) = Physics_ClientOption(this, "maxspeed") * maxspd_mod; // also slow walking
// old stats
// fix some new settings
- self.stat_sv_airaccel_qw_stretchfactor = Physics_ClientOption(self, "airaccel_qw_stretchfactor");
- self.stat_sv_maxairstrafespeed = Physics_ClientOption(self, "maxairstrafespeed");
- self.stat_sv_maxairspeed = Physics_ClientOption(self, "maxairspeed");
- self.stat_sv_airstrafeaccelerate = Physics_ClientOption(self, "airstrafeaccelerate");
- self.stat_sv_warsowbunny_turnaccel = Physics_ClientOption(self, "warsowbunny_turnaccel");
- self.stat_sv_airaccel_sideways_friction = Physics_ClientOption(self, "airaccel_sideways_friction");
- self.stat_sv_aircontrol = Physics_ClientOption(self, "aircontrol");
- self.stat_sv_aircontrol_power = Physics_ClientOption(self, "aircontrol_power");
- self.stat_sv_aircontrol_penalty = Physics_ClientOption(self, "aircontrol_penalty");
- self.stat_sv_warsowbunny_airforwardaccel = Physics_ClientOption(self, "warsowbunny_airforwardaccel");
- self.stat_sv_warsowbunny_topspeed = Physics_ClientOption(self, "warsowbunny_topspeed");
- self.stat_sv_warsowbunny_accel = Physics_ClientOption(self, "warsowbunny_accel");
- self.stat_sv_warsowbunny_backtosideratio = Physics_ClientOption(self, "warsowbunny_backtosideratio");
- self.stat_sv_friction = Physics_ClientOption(self, "friction");
- self.stat_sv_accelerate = Physics_ClientOption(self, "accelerate");
- self.stat_sv_stopspeed = Physics_ClientOption(self, "stopspeed");
- self.stat_sv_airaccelerate = Physics_ClientOption(self, "airaccelerate");
- self.stat_sv_airstopaccelerate = Physics_ClientOption(self, "airstopaccelerate");
- self.stat_sv_jumpvelocity = Physics_ClientOption(self, "jumpvelocity");
-
- self.stat_sv_track_canjump = Physics_ClientOption(self, "track_canjump");
-
- self.stat_gameplayfix_upvelocityclearsonground = UPWARD_VELOCITY_CLEARS_ONGROUND;
+ STAT(MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, this) = Physics_ClientOption(this, "airaccel_qw_stretchfactor");
+ STAT(MOVEVARS_MAXAIRSTRAFESPEED, this) = Physics_ClientOption(this, "maxairstrafespeed");
+ STAT(MOVEVARS_MAXAIRSPEED, this) = Physics_ClientOption(this, "maxairspeed");
+ STAT(MOVEVARS_AIRSTRAFEACCELERATE, this) = Physics_ClientOption(this, "airstrafeaccelerate");
+ STAT(MOVEVARS_WARSOWBUNNY_TURNACCEL, this) = Physics_ClientOption(this, "warsowbunny_turnaccel");
+ STAT(MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, this) = Physics_ClientOption(this, "airaccel_sideways_friction");
+ STAT(MOVEVARS_AIRCONTROL, this) = Physics_ClientOption(this, "aircontrol");
+ STAT(MOVEVARS_AIRCONTROL_POWER, this) = Physics_ClientOption(this, "aircontrol_power");
+ STAT(MOVEVARS_AIRCONTROL_PENALTY, this) = Physics_ClientOption(this, "aircontrol_penalty");
+ STAT(MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, this) = Physics_ClientOption(this, "warsowbunny_airforwardaccel");
+ STAT(MOVEVARS_WARSOWBUNNY_TOPSPEED, this) = Physics_ClientOption(this, "warsowbunny_topspeed");
+ STAT(MOVEVARS_WARSOWBUNNY_ACCEL, this) = Physics_ClientOption(this, "warsowbunny_accel");
+ STAT(MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, this) = Physics_ClientOption(this, "warsowbunny_backtosideratio");
+ STAT(MOVEVARS_FRICTION, this) = Physics_ClientOption(this, "friction");
+ STAT(MOVEVARS_ACCELERATE, this) = Physics_ClientOption(this, "accelerate");
+ STAT(MOVEVARS_STOPSPEED, this) = Physics_ClientOption(this, "stopspeed");
+ STAT(MOVEVARS_AIRACCELERATE, this) = Physics_ClientOption(this, "airaccelerate");
+ STAT(MOVEVARS_AIRSTOPACCELERATE, this) = Physics_ClientOption(this, "airstopaccelerate");
+ STAT(MOVEVARS_JUMPVELOCITY, this) = Physics_ClientOption(this, "jumpvelocity");
+ STAT(MOVEVARS_TRACK_CANJUMP, this) = Physics_ClientOption(this, "track_canjump");
}
#endif
: a * pow(fabs(b / a), lerp);
}
-noref float pmove_waterjumptime;
-
#define unstick_offsets(X) \
/* 1 no nudge (just return the original if this test passes) */ \
X(' 0.000 0.000 0.000') \
void PM_ClientMovement_UpdateStatus(entity this, bool ground)
{
+#ifdef CSQC
// make sure player is not stuck
- PM_ClientMovement_Unstick(this);
+ if(autocvar_cl_movement != 3)
+ PM_ClientMovement_Unstick(this);
// set crouched
if (PHYS_INPUT_BUTTON_CROUCH(this))
vector origin1 = this.origin + '0 0 1';
vector origin2 = this.origin - '0 0 1';
- if (ground)
+ if (ground && autocvar_cl_movement != 3)
{
tracebox(origin1, this.mins, this.maxs, origin2, MOVE_NORMAL, this);
if (trace_fraction < 1.0 && trace_plane_normal.z > 0.7)
UNSET_ONGROUND(this);
}
- // set watertype/waterlevel
- origin1 = this.origin;
- origin1.z += this.mins_z + 1;
- this.waterlevel = WATERLEVEL_NONE;
+ if(autocvar_cl_movement != 3)
+ {
+ // set watertype/waterlevel
+ origin1 = this.origin;
+ origin1.z += this.mins_z + 1;
+ this.waterlevel = WATERLEVEL_NONE;
- int thepoint = pointcontents(origin1);
+ int thepoint = pointcontents(origin1);
- this.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
+ this.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
- if (this.watertype)
- {
- this.waterlevel = WATERLEVEL_WETFEET;
- origin1.z = this.origin.z + (this.mins.z + this.maxs.z) * 0.5;
- thepoint = pointcontents(origin1);
- if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
+ if (this.watertype)
{
- this.waterlevel = WATERLEVEL_SWIMMING;
- origin1.z = this.origin.z + 22;
+ this.waterlevel = WATERLEVEL_WETFEET;
+ origin1.z = this.origin.z + (this.mins.z + this.maxs.z) * 0.5;
thepoint = pointcontents(origin1);
if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
- this.waterlevel = WATERLEVEL_SUBMERGED;
+ {
+ this.waterlevel = WATERLEVEL_SWIMMING;
+ origin1.z = this.origin.z + 22;
+ thepoint = pointcontents(origin1);
+ if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
+ this.waterlevel = WATERLEVEL_SUBMERGED;
+ }
}
}
- if (IS_ONGROUND(this) || this.velocity.z <= 0 || pmove_waterjumptime <= 0)
- pmove_waterjumptime = 0;
+ if (IS_ONGROUND(this) || this.velocity.z <= 0 || PHYS_TELEPORT_TIME(this) <= 0)
+ PHYS_TELEPORT_TIME(this) = 0;
+#endif
}
-void PM_ClientMovement_Move()
-{SELFPARAM();
+void PM_ClientMovement_Move(entity this)
+{
#ifdef CSQC
+
+ PM_ClientMovement_UpdateStatus(this, false);
+ if(autocvar_cl_movement == 3)
+ return;
+
int bump;
float t;
float f;
vector trace2_plane_normal = '0 0 0';
vector trace3_plane_normal = '0 0 0';
-
- PM_ClientMovement_UpdateStatus(this, false);
- primalvelocity = self.velocity;
- for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (self.velocity * self.velocity) > 0; bump++)
+ primalvelocity = this.velocity;
+ for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (this.velocity * this.velocity) > 0; bump++)
{
- neworigin = self.origin + t * self.velocity;
- tracebox(self.origin, self.mins, self.maxs, neworigin, MOVE_NORMAL, self);
+ neworigin = this.origin + t * this.velocity;
+ tracebox(this.origin, this.mins, this.maxs, neworigin, MOVE_NORMAL, this);
trace1_endpos = trace_endpos;
trace1_fraction = trace_fraction;
trace1_plane_normal = trace_plane_normal;
{
// may be a step or wall, try stepping up
// first move forward at a higher level
- currentorigin2 = self.origin;
+ currentorigin2 = this.origin;
currentorigin2_z += PHYS_STEPHEIGHT;
neworigin2 = neworigin;
neworigin2_z += PHYS_STEPHEIGHT;
- tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
+ tracebox(currentorigin2, this.mins, this.maxs, neworigin2, MOVE_NORMAL, this);
trace2_endpos = trace_endpos;
trace2_fraction = trace_fraction;
trace2_plane_normal = trace_plane_normal;
// then move down from there
currentorigin2 = trace2_endpos;
neworigin2 = trace2_endpos;
- neworigin2_z = self.origin_z;
- tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
+ neworigin2_z = this.origin_z;
+ tracebox(currentorigin2, this.mins, this.maxs, neworigin2, MOVE_NORMAL, this);
trace3_endpos = trace_endpos;
trace3_fraction = trace_fraction;
trace3_plane_normal = trace_plane_normal;
// check if it moved at all
if(trace1_fraction >= 0.001)
- setorigin(self, trace1_endpos);
+ setorigin(this, trace1_endpos);
// check if it moved all the way
if(trace1_fraction == 1)
// this got commented out in a change that supposedly makes the code match QW better
// so if this is broken, maybe put it in an if(cls.protocol != PROTOCOL_QUAKEWORLD) block
if(trace1_plane_normal_z > 0.7)
- SET_ONGROUND(self);
+ SET_ONGROUND(this);
t -= t * trace1_fraction;
- f = (self.velocity * trace1_plane_normal);
- self.velocity = self.velocity + -f * trace1_plane_normal;
+ f = (this.velocity * trace1_plane_normal);
+ this.velocity = this.velocity + -f * trace1_plane_normal;
}
- if(pmove_waterjumptime > 0)
- self.velocity = primalvelocity;
+ if(PHYS_TELEPORT_TIME(this) > 0)
+ this.velocity = primalvelocity;
#endif
}
-void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
-{SELFPARAM();
- float k = 32 * (2 * IsMoveInDirection(self.movement, 0) - 1);
+void CPM_PM_Aircontrol(entity this, vector wishdir, float wishspeed)
+{
+ float k = 32 * (2 * IsMoveInDirection(this.movement, 0) - 1);
if (k <= 0)
return;
- k *= bound(0, wishspeed / PHYS_MAXAIRSPEED(self), 1);
+ k *= bound(0, wishspeed / PHYS_MAXAIRSPEED(this), 1);
- float zspeed = self.velocity_z;
- self.velocity_z = 0;
- float xyspeed = vlen(self.velocity);
- self.velocity = normalize(self.velocity);
+ float zspeed = this.velocity_z;
+ this.velocity_z = 0;
+ float xyspeed = vlen(this.velocity);
+ this.velocity = normalize(this.velocity);
- float dot = self.velocity * wishdir;
+ float dot = this.velocity * wishdir;
if (dot > 0) // we can't change direction while slowing down
{
- k *= pow(dot, PHYS_AIRCONTROL_POWER) * PHYS_INPUT_TIMELENGTH;
- xyspeed = max(0, xyspeed - PHYS_AIRCONTROL_PENALTY * sqrt(max(0, 1 - dot*dot)) * k/32);
- k *= PHYS_AIRCONTROL;
- self.velocity = normalize(self.velocity * xyspeed + wishdir * k);
+ k *= pow(dot, PHYS_AIRCONTROL_POWER(this)) * PHYS_INPUT_TIMELENGTH;
+ xyspeed = max(0, xyspeed - PHYS_AIRCONTROL_PENALTY(this) * sqrt(max(0, 1 - dot*dot)) * k/32);
+ k *= PHYS_AIRCONTROL(this);
+ this.velocity = normalize(this.velocity * xyspeed + wishdir * k);
}
- self.velocity = self.velocity * xyspeed;
- self.velocity_z = zspeed;
+ this.velocity = this.velocity * xyspeed;
+ this.velocity_z = zspeed;
}
float AdjustAirAccelQW(float accelqw, float factor)
// sv_airaccel_sideways_friction 0
// prvm_globalset server speedclamp_mode 1
// (or 2)
-void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float stretchfactor, float sidefric, float speedlimit)
-{SELFPARAM();
+void PM_Accelerate(entity this, vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float stretchfactor, float sidefric, float speedlimit)
+{
float speedclamp = stretchfactor > 0 ? stretchfactor
: accelqw < 0 ? 1 // full clamping, no stretch
: -1; // no clamping
if (GAMEPLAYFIX_Q2AIRACCELERATE)
wishspeed0 = wishspeed; // don't need to emulate this Q1 bug
- float vel_straight = self.velocity * wishdir;
- float vel_z = self.velocity_z;
- vector vel_xy = vec2(self.velocity);
+ float vel_straight = this.velocity * wishdir;
+ float vel_z = this.velocity_z;
+ vector vel_xy = vec2(this.velocity);
vector vel_perpend = vel_xy - vel_straight * wishdir;
float step = accel * PHYS_INPUT_TIMELENGTH * wishspeed0;
// negative: only apply so much sideways friction to stay below the speed you could get by "braking"
{
float f = max(0, 1 + PHYS_INPUT_TIMELENGTH * wishspeed * sidefric);
- float fmin = (vel_xy_backward * vel_xy_backward - vel_straight * vel_straight) / (vel_perpend * vel_perpend);
- // assume: fmin > 1
+ float themin = (vel_xy_backward * vel_xy_backward - vel_straight * vel_straight) / (vel_perpend * vel_perpend);
+ // assume: themin > 1
// vel_xy_backward*vel_xy_backward - vel_straight*vel_straight > vel_perpend*vel_perpend
// vel_xy_backward*vel_xy_backward > vel_straight*vel_straight + vel_perpend*vel_perpend
// vel_xy_backward*vel_xy_backward > vel_xy * vel_xy
// obviously, this cannot be
- if (fmin <= 0)
+ if (themin <= 0)
vel_perpend *= f;
else
{
- fmin = sqrt(fmin);
- vel_perpend *= max(fmin, f);
+ themin = sqrt(themin);
+ vel_perpend *= max(themin, f);
}
}
else
}
}
- self.velocity = vel_xy + vel_z * '0 0 1';
+ this.velocity = vel_xy + vel_z * '0 0 1';
}
-void PM_AirAccelerate(vector wishdir, float wishspeed)
-{SELFPARAM();
+void PM_AirAccelerate(entity this, vector wishdir, float wishspeed)
+{
if (wishspeed == 0)
return;
- vector curvel = self.velocity;
+ vector curvel = this.velocity;
curvel_z = 0;
float curspeed = vlen(curvel);
if (wishspeed > curspeed * 1.01)
- wishspeed = min(wishspeed, curspeed + PHYS_WARSOWBUNNY_AIRFORWARDACCEL * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH);
+ wishspeed = min(wishspeed, curspeed + PHYS_WARSOWBUNNY_AIRFORWARDACCEL(this) * PHYS_MAXSPEED(this) * PHYS_INPUT_TIMELENGTH);
else
{
- float f = max(0, (PHYS_WARSOWBUNNY_TOPSPEED - curspeed) / (PHYS_WARSOWBUNNY_TOPSPEED - PHYS_MAXSPEED(self)));
- wishspeed = max(curspeed, PHYS_MAXSPEED(self)) + PHYS_WARSOWBUNNY_ACCEL * f * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH;
+ float f = max(0, (PHYS_WARSOWBUNNY_TOPSPEED(this) - curspeed) / (PHYS_WARSOWBUNNY_TOPSPEED(this) - PHYS_MAXSPEED(this)));
+ wishspeed = max(curspeed, PHYS_MAXSPEED(this)) + PHYS_WARSOWBUNNY_ACCEL(this) * f * PHYS_MAXSPEED(this) * PHYS_INPUT_TIMELENGTH;
}
vector wishvel = wishdir * wishspeed;
vector acceldir = wishvel - curvel;
float addspeed = vlen(acceldir);
acceldir = normalize(acceldir);
- float accelspeed = min(addspeed, PHYS_WARSOWBUNNY_TURNACCEL * PHYS_MAXSPEED(self) * PHYS_INPUT_TIMELENGTH);
+ float accelspeed = min(addspeed, PHYS_WARSOWBUNNY_TURNACCEL(this) * PHYS_MAXSPEED(this) * PHYS_INPUT_TIMELENGTH);
- if (PHYS_WARSOWBUNNY_BACKTOSIDERATIO < 1)
+ if (PHYS_WARSOWBUNNY_BACKTOSIDERATIO(this) < 1)
{
vector curdir = normalize(curvel);
float dot = acceldir * curdir;
if (dot < 0)
- acceldir -= (1 - PHYS_WARSOWBUNNY_BACKTOSIDERATIO) * dot * curdir;
+ acceldir -= (1 - PHYS_WARSOWBUNNY_BACKTOSIDERATIO(this)) * dot * curdir;
}
- self.velocity += accelspeed * acceldir;
+ this.velocity += accelspeed * acceldir;
}
returns true if handled
=============
*/
-bool PlayerJump ()
-{SELFPARAM();
- if (PHYS_FROZEN(self))
+bool PlayerJump(entity this)
+{
+ if (PHYS_FROZEN(this))
return true; // no jumping in freezetag when frozen
#ifdef SVQC
- if (self.player_blocked)
+ if (this.player_blocked)
return true; // no jumping while blocked
#endif
bool doublejump = false;
- float mjumpheight = PHYS_JUMPVELOCITY;
+ float mjumpheight = PHYS_JUMPVELOCITY(this);
- if (MUTATOR_CALLHOOK(PlayerJump, doublejump, mjumpheight))
+ if (MUTATOR_CALLHOOK(PlayerJump, this, doublejump, mjumpheight))
return true;
doublejump = player_multijump;
mjumpheight = player_jumpheight;
- if (self.waterlevel >= WATERLEVEL_SWIMMING)
+ if (this.waterlevel >= WATERLEVEL_SWIMMING)
{
- self.velocity_z = PHYS_MAXSPEED(self) * 0.7;
+ this.velocity_z = PHYS_MAXSPEED(this) * 0.7;
return true;
}
if (!doublejump)
- if (!IS_ONGROUND(self))
- return IS_JUMP_HELD(self);
+ if (!IS_ONGROUND(this))
+ return IS_JUMP_HELD(this);
- bool track_jump = PHYS_CL_TRACK_CANJUMP(self);
- if(PHYS_TRACK_CANJUMP(self))
+ bool track_jump = PHYS_CL_TRACK_CANJUMP(this);
+ if(PHYS_TRACK_CANJUMP(this))
track_jump = true;
if (track_jump)
- if (IS_JUMP_HELD(self))
+ if (IS_JUMP_HELD(this))
return true;
// sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline
{
float minjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MIN);
- if (self.velocity_z < minjumpspeed)
- mjumpheight += minjumpspeed - self.velocity_z;
+ if (this.velocity_z < minjumpspeed)
+ mjumpheight += minjumpspeed - this.velocity_z;
}
if(PHYS_JUMPSPEEDCAP_MAX != "")
{
// don't do jump speedcaps on ramps to preserve old xonotic ramjump style
- tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
+ tracebox(this.origin + '0 0 0.01', this.mins, this.maxs, this.origin - '0 0 0.01', MOVE_NORMAL, this);
if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS))
{
float maxjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MAX);
- if (self.velocity_z > maxjumpspeed)
- mjumpheight -= self.velocity_z - maxjumpspeed;
+ if (this.velocity_z > maxjumpspeed)
+ mjumpheight -= this.velocity_z - maxjumpspeed;
}
}
- if (!WAS_ONGROUND(self))
+ if (!WAS_ONGROUND(this))
{
#ifdef SVQC
if(autocvar_speedmeter)
- LOG_TRACE(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
+ LOG_TRACE(strcat("landing velocity: ", vtos(this.velocity), " (abs: ", ftos(vlen(this.velocity)), ")\n"));
#endif
- if(self.lastground < time - 0.3)
+ if(this.lastground < time - 0.3)
{
- self.velocity_x *= (1 - PHYS_FRICTION_ONLAND);
- self.velocity_y *= (1 - PHYS_FRICTION_ONLAND);
+ this.velocity_x *= (1 - PHYS_FRICTION_ONLAND);
+ this.velocity_y *= (1 - PHYS_FRICTION_ONLAND);
}
#ifdef SVQC
- if(self.jumppadcount > 1)
- LOG_TRACE(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
- self.jumppadcount = 0;
+ if(this.jumppadcount > 1)
+ LOG_TRACE(strcat(ftos(this.jumppadcount), "x jumppad combo\n"));
+ this.jumppadcount = 0;
#endif
}
- self.velocity_z += mjumpheight;
+ this.velocity_z += mjumpheight;
- UNSET_ONGROUND(self);
- SET_JUMP_HELD(self);
+ UNSET_ONGROUND(this);
+ SET_JUMP_HELD(this);
#ifdef SVQC
- self.oldvelocity_z = self.velocity_z;
+ this.oldvelocity_z = this.velocity_z;
- animdecide_setaction(self, ANIMACTION_JUMP, true);
+ animdecide_setaction(this, ANIMACTION_JUMP, true);
if (autocvar_g_jump_grunt)
- PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
#endif
return true;
}
-void CheckWaterJump()
-{SELFPARAM();
+void CheckWaterJump(entity this)
+{
// check for a jump-out-of-water
- makevectors(self.v_angle);
- vector start = self.origin;
+ makevectors(this.v_angle);
+ vector start = this.origin;
start_z += 8;
v_forward_z = 0;
normalize(v_forward);
vector end = start + v_forward*24;
- traceline (start, end, true, self);
+ traceline (start, end, true, this);
if (trace_fraction < 1)
{ // solid at waist
- start_z = start_z + self.maxs_z - 8;
+ start_z = start_z + this.maxs_z - 8;
end = start + v_forward*24;
- self.movedir = trace_plane_normal * -50;
- traceline(start, end, true, self);
+ this.movedir = trace_plane_normal * -50;
+ traceline(start, end, true, this);
if (trace_fraction == 1)
{ // open at eye level
- self.velocity_z = 225;
- self.flags |= FL_WATERJUMP;
- SET_JUMP_HELD(self);
-#ifdef SVQC
- self.teleport_time = time + 2; // safety net
-#elif defined(CSQC)
- pmove_waterjumptime = time + 2;
-#endif
+ this.velocity_z = 225;
+ this.flags |= FL_WATERJUMP;
+ SET_JUMP_HELD(this);
+ PHYS_TELEPORT_TIME(this) = time + 2; // safety net
}
}
}
#define JETPACK_JUMP(s) autocvar_cl_jetpack_jump
#endif
.float jetpack_stopped;
-void CheckPlayerJump()
-{SELFPARAM();
+void CheckPlayerJump(entity this)
+{
#ifdef SVQC
- float was_flying = ITEMS_STAT(self) & IT_USING_JETPACK;
+ float was_flying = ITEMS_STAT(this) & IT_USING_JETPACK;
#endif
- if (JETPACK_JUMP(self) < 2)
- ITEMS_STAT(self) &= ~IT_USING_JETPACK;
+ if (JETPACK_JUMP(this) < 2)
+ ITEMS_STAT(this) &= ~IT_USING_JETPACK;
- if(PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self))
+ if(PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(this))
{
- float air_jump = !PlayerJump() || player_multijump; // PlayerJump() has important side effects
- float activate = JETPACK_JUMP(self) && air_jump && PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self);
- float has_fuel = !PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) || ITEMS_STAT(self) & IT_UNLIMITED_WEAPON_AMMO;
+ float air_jump = !PlayerJump(this) || player_multijump; // PlayerJump() has important side effects
+ float activate = JETPACK_JUMP(this) && air_jump && PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(this);
+ float has_fuel = !PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(this) || ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO;
- if (!(ITEMS_STAT(self) & ITEM_Jetpack.m_itemid)) { }
- else if (self.jetpack_stopped) { }
+ if (!(ITEMS_STAT(this) & ITEM_Jetpack.m_itemid)) { }
+ else if (this.jetpack_stopped) { }
else if (!has_fuel)
{
#ifdef SVQC
if (was_flying) // TODO: ran out of fuel message
- Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
+ Send_Notification(NOTIF_ONE, this, MSG_INFO, INFO_JETPACK_NOFUEL);
else if (activate)
- Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
+ Send_Notification(NOTIF_ONE, this, MSG_INFO, INFO_JETPACK_NOFUEL);
#endif
- self.jetpack_stopped = true;
- ITEMS_STAT(self) &= ~IT_USING_JETPACK;
+ this.jetpack_stopped = true;
+ ITEMS_STAT(this) &= ~IT_USING_JETPACK;
}
- else if (activate && !PHYS_FROZEN(self))
- ITEMS_STAT(self) |= IT_USING_JETPACK;
+ else if (activate && !PHYS_FROZEN(this))
+ ITEMS_STAT(this) |= IT_USING_JETPACK;
}
else
{
- self.jetpack_stopped = false;
- ITEMS_STAT(self) &= ~IT_USING_JETPACK;
+ this.jetpack_stopped = false;
+ ITEMS_STAT(this) &= ~IT_USING_JETPACK;
}
- if (!PHYS_INPUT_BUTTON_JUMP(self))
- UNSET_JUMP_HELD(self);
+ if (!PHYS_INPUT_BUTTON_JUMP(this))
+ UNSET_JUMP_HELD(this);
- if (self.waterlevel == WATERLEVEL_SWIMMING)
- CheckWaterJump();
+ if (this.waterlevel == WATERLEVEL_SWIMMING)
+ CheckWaterJump(this);
}
float racecar_angle(float forward, float down)
#endif
}
-float PM_check_specialcommand(float buttons)
-{SELFPARAM();
+float PM_check_specialcommand(entity this, float buttons)
+{
#ifdef SVQC
string c;
if (!buttons)
else
c = "?";
- if (c == substring(specialcommand, self.specialcommand_pos, 1))
+ if (c == substring(specialcommand, this.specialcommand_pos, 1))
{
- self.specialcommand_pos += 1;
- if (self.specialcommand_pos >= strlen(specialcommand))
+ this.specialcommand_pos += 1;
+ if (this.specialcommand_pos >= strlen(specialcommand))
{
- self.specialcommand_pos = 0;
+ this.specialcommand_pos = 0;
SpecialCommand();
return true;
}
}
- else if (self.specialcommand_pos && (c != substring(specialcommand, self.specialcommand_pos - 1, 1)))
- self.specialcommand_pos = 0;
+ else if (this.specialcommand_pos && (c != substring(specialcommand, this.specialcommand_pos - 1, 1)))
+ this.specialcommand_pos = 0;
#endif
return false;
}
-void PM_check_nickspam()
-{SELFPARAM();
+void PM_check_nickspam(entity this)
+{
#ifdef SVQC
- if (time >= self.nickspamtime)
+ if (time >= this.nickspamtime)
return;
- if (self.nickspamcount >= autocvar_g_nick_flood_penalty_yellow)
+ if (this.nickspamcount >= autocvar_g_nick_flood_penalty_yellow)
{
// slight annoyance for nick change scripts
- self.movement = -1 * self.movement;
- self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
+ this.movement = -1 * this.movement;
+ this.BUTTON_ATCK = this.BUTTON_JUMP = this.BUTTON_ATCK2 = this.BUTTON_ZOOM = this.BUTTON_CROUCH = this.BUTTON_HOOK = this.BUTTON_USE = 0;
- if (self.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
+ if (this.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
{
- self.v_angle_x = random() * 360;
- self.v_angle_y = random() * 360;
+ this.v_angle_x = random() * 360;
+ this.v_angle_y = random() * 360;
// at least I'm not forcing retardedview by also assigning to angles_z
- self.fixangle = true;
+ this.fixangle = true;
}
}
#endif
}
-void PM_check_punch()
-{SELFPARAM();
+void PM_check_punch(entity this)
+{
#ifdef SVQC
- if (self.punchangle != '0 0 0')
+ if (this.punchangle != '0 0 0')
{
- float f = vlen(self.punchangle) - 10 * PHYS_INPUT_TIMELENGTH;
+ float f = vlen(this.punchangle) - 10 * PHYS_INPUT_TIMELENGTH;
if (f > 0)
- self.punchangle = normalize(self.punchangle) * f;
+ this.punchangle = normalize(this.punchangle) * f;
else
- self.punchangle = '0 0 0';
+ this.punchangle = '0 0 0';
}
- if (self.punchvector != '0 0 0')
+ if (this.punchvector != '0 0 0')
{
- float f = vlen(self.punchvector) - 30 * PHYS_INPUT_TIMELENGTH;
+ float f = vlen(this.punchvector) - 30 * PHYS_INPUT_TIMELENGTH;
if (f > 0)
- self.punchvector = normalize(self.punchvector) * f;
+ this.punchvector = normalize(this.punchvector) * f;
else
- self.punchvector = '0 0 0';
+ this.punchvector = '0 0 0';
}
#endif
}
// predict frozen movement, as frozen players CAN move in some cases
-void PM_check_frozen()
-{SELFPARAM();
- if (!PHYS_FROZEN(self))
+void PM_check_frozen(entity this)
+{
+ if (!PHYS_FROZEN(this))
return;
if (PHYS_DODGING_FROZEN
#ifdef SVQC
- && IS_REAL_CLIENT(self)
+ && IS_REAL_CLIENT(this)
#endif
)
{
- self.movement_x = bound(-5, self.movement.x, 5);
- self.movement_y = bound(-5, self.movement.y, 5);
- self.movement_z = bound(-5, self.movement.z, 5);
+ this.movement_x = bound(-5, this.movement.x, 5);
+ this.movement_y = bound(-5, this.movement.y, 5);
+ this.movement_z = bound(-5, this.movement.z, 5);
}
else
- self.movement = '0 0 0';
+ this.movement = '0 0 0';
- vector midpoint = ((self.absmin + self.absmax) * 0.5);
+ vector midpoint = ((this.absmin + this.absmax) * 0.5);
if (pointcontents(midpoint) == CONTENT_WATER)
{
- self.velocity = self.velocity * 0.5;
+ this.velocity = this.velocity * 0.5;
if (pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
- self.velocity_z = 200;
+ this.velocity_z = 200;
}
}
-void PM_check_hitground()
-{SELFPARAM();
+void PM_check_hitground(entity this)
+{
#ifdef SVQC
- if (!IS_PLAYER(this)) return; // no fall sounds for observers thank you very much
- if (!IS_ONGROUND(this)) return;
if (!this.wasFlying) return;
this.wasFlying = false;
if (this.waterlevel >= WATERLEVEL_SWIMMING) return;
this.nextstep = time + 0.3 + random() * 0.1;
trace_dphitq3surfaceflags = 0;
tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
- if ((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)) return;
- entity fall = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) ? GS_FALL_METAL : GS_FALL;
- GlobalSound(fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS) return;
+ entity gs = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
+ ? GS_FALL_METAL
+ : GS_FALL;
+ GlobalSound(this, gs, CH_PLAYER, VOICETYPE_PLAYERSOUND);
#endif
}
-void PM_check_blocked()
-{SELFPARAM();
+void PM_Footsteps(entity this)
+{
#ifdef SVQC
- if (!self.player_blocked)
+ if (!g_footsteps) return;
+ if (IS_DUCKED(this)) return;
+ if (time >= this.lastground + 0.2) return;
+ if (vdist(this.velocity, <=, autocvar_sv_maxspeed * 0.6)) return;
+ if ((time > this.nextstep) || (time < (this.nextstep - 10.0)))
+ {
+ this.nextstep = time + 0.3 + random() * 0.1;
+ trace_dphitq3surfaceflags = 0;
+ tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
+ if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS) return;
+ entity gs = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
+ ? GS_STEP_METAL
+ : GS_STEP;
+ GlobalSound(this, gs, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ }
+#endif
+}
+
+void PM_check_blocked(entity this)
+{
+#ifdef SVQC
+ if (!this.player_blocked)
return;
- self.movement = '0 0 0';
- self.disableclientprediction = 1;
+ this.movement = '0 0 0';
+ this.disableclientprediction = 1;
#endif
}
-void PM_fly(float maxspd_mod)
-{SELFPARAM();
+void PM_fly(entity this, float maxspd_mod)
+{
// noclipping or flying
- UNSET_ONGROUND(self);
-
- self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
- makevectors(self.v_angle);
- //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z;
- vector wishvel = v_forward * self.movement.x
- + v_right * self.movement.y
- + '0 0 1' * self.movement.z;
+ UNSET_ONGROUND(this);
+
+ this.velocity = this.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this));
+ makevectors(this.v_angle);
+ //wishvel = v_forward * this.movement.x + v_right * this.movement.y + v_up * this.movement.z;
+ vector wishvel = v_forward * this.movement.x
+ + v_right * this.movement.y
+ + '0 0 1' * this.movement.z;
// acceleration
vector wishdir = normalize(wishvel);
- float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
-#ifdef SVQC
- if (time >= self.teleport_time)
-#endif
- PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
- PM_ClientMovement_Move();
+ float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(this) * maxspd_mod);
+ if(time >= PHYS_TELEPORT_TIME(this))
+ PM_Accelerate(this, wishdir, wishspeed, wishspeed, PHYS_ACCELERATE(this) * maxspd_mod, 1, 0, 0, 0);
+ PM_ClientMovement_Move(this);
}
-void PM_swim(float maxspd_mod)
-{SELFPARAM();
+void PM_swim(entity this, float maxspd_mod)
+{
// swimming
- UNSET_ONGROUND(self);
+ UNSET_ONGROUND(this);
- float jump = PHYS_INPUT_BUTTON_JUMP(self);
+ float jump = PHYS_INPUT_BUTTON_JUMP(this);
// water jump only in certain situations
// this mimics quakeworld code
- if (jump && self.waterlevel == WATERLEVEL_SWIMMING && self.velocity_z >= -180)
+ if (jump && this.waterlevel == WATERLEVEL_SWIMMING && this.velocity_z >= -180)
{
- vector yawangles = '0 1 0' * self.v_angle.y;
+ vector yawangles = '0 1 0' * this.v_angle.y;
makevectors(yawangles);
vector forward = v_forward;
- vector spot = self.origin + 24 * forward;
+ vector spot = this.origin + 24 * forward;
spot_z += 8;
- traceline(spot, spot, MOVE_NOMONSTERS, self);
+ traceline(spot, spot, MOVE_NOMONSTERS, this);
if (trace_startsolid)
{
spot_z += 24;
- traceline(spot, spot, MOVE_NOMONSTERS, self);
+ traceline(spot, spot, MOVE_NOMONSTERS, this);
if (!trace_startsolid)
{
- self.velocity = forward * 50;
- self.velocity_z = 310;
- pmove_waterjumptime = 2;
- UNSET_ONGROUND(self);
- SET_JUMP_HELD(self);
+ this.velocity = forward * 50;
+ this.velocity_z = 310;
+ PHYS_TELEPORT_TIME(this) = 2;
+ UNSET_ONGROUND(this);
+ SET_JUMP_HELD(this);
}
}
}
- makevectors(self.v_angle);
- //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z;
- vector wishvel = v_forward * self.movement.x
- + v_right * self.movement.y
- + '0 0 1' * self.movement.z;
+ makevectors(this.v_angle);
+ //wishvel = v_forward * this.movement.x + v_right * this.movement.y + v_up * this.movement.z;
+ vector wishvel = v_forward * this.movement.x
+ + v_right * this.movement.y
+ + '0 0 1' * this.movement.z;
if (wishvel == '0 0 0')
wishvel = '0 0 -60'; // drift towards bottom
vector wishdir = normalize(wishvel);
- float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod) * 0.7;
+ float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(this) * maxspd_mod) * 0.7;
- if (IS_DUCKED(self))
+ if (IS_DUCKED(this))
wishspeed *= 0.5;
// if (pmove_waterjumptime <= 0) // TODO: use
{
// water friction
- float f = 1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION;
+ float f = 1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this);
f = min(max(0, f), 1);
- self.velocity *= f;
+ this.velocity *= f;
- f = wishspeed - self.velocity * wishdir;
+ f = wishspeed - this.velocity * wishdir;
if (f > 0)
{
- float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, f);
- self.velocity += accelspeed * wishdir;
+ float accelspeed = min(PHYS_ACCELERATE(this) * PHYS_INPUT_TIMELENGTH * wishspeed, f);
+ this.velocity += accelspeed * wishdir;
}
// holding jump button swims upward slowly
if (jump)
{
#if 0
- if (self.watertype & CONTENT_LAVA)
- self.velocity_z = 50;
- else if (self.watertype & CONTENT_SLIME)
- self.velocity_z = 80;
+ if (this.watertype & CONTENT_LAVA)
+ this.velocity_z = 50;
+ else if (this.watertype & CONTENT_SLIME)
+ this.velocity_z = 80;
else
{
if (IS_NEXUIZ_DERIVED(gamemode))
#endif
- self.velocity_z = 200;
+ this.velocity_z = 200;
#if 0
else
- self.velocity_z = 100;
+ this.velocity_z = 100;
}
#endif
}
}
// water acceleration
- PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
- PM_ClientMovement_Move();
+ PM_Accelerate(this, wishdir, wishspeed, wishspeed, PHYS_ACCELERATE(this) * maxspd_mod, 1, 0, 0, 0);
+ PM_ClientMovement_Move(this);
}
-void PM_ladder(float maxspd_mod)
-{SELFPARAM();
+void PM_ladder(entity this, float maxspd_mod)
+{
// on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
- UNSET_ONGROUND(self);
+ UNSET_ONGROUND(this);
float g;
- g = PHYS_GRAVITY * PHYS_INPUT_TIMELENGTH;
- if (PHYS_ENTGRAVITY(self))
- g *= PHYS_ENTGRAVITY(self);
+ g = PHYS_GRAVITY(this) * PHYS_INPUT_TIMELENGTH;
+ if (PHYS_ENTGRAVITY(this))
+ g *= PHYS_ENTGRAVITY(this);
if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
{
g *= 0.5;
- self.velocity_z += g;
+ this.velocity_z += g;
}
- self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
- makevectors(self.v_angle);
- //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z;
- vector wishvel = v_forward * self.movement_x
- + v_right * self.movement_y
- + '0 0 1' * self.movement_z;
- self.velocity_z += g;
- if (self.ladder_entity.classname == "func_water")
+ this.velocity = this.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this));
+ makevectors(this.v_angle);
+ //wishvel = v_forward * this.movement.x + v_right * this.movement.y + v_up * this.movement.z;
+ vector wishvel = v_forward * this.movement_x
+ + v_right * this.movement_y
+ + '0 0 1' * this.movement_z;
+ this.velocity_z += g;
+ if (this.ladder_entity.classname == "func_water")
{
float f = vlen(wishvel);
- if (f > self.ladder_entity.speed)
- wishvel *= (self.ladder_entity.speed / f);
-
- self.watertype = self.ladder_entity.skin;
- f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
- if ((self.origin_z + self.view_ofs_z) < f)
- self.waterlevel = WATERLEVEL_SUBMERGED;
- else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
- self.waterlevel = WATERLEVEL_SWIMMING;
- else if ((self.origin_z + self.mins_z + 1) < f)
- self.waterlevel = WATERLEVEL_WETFEET;
+ if (f > this.ladder_entity.speed)
+ wishvel *= (this.ladder_entity.speed / f);
+
+ this.watertype = this.ladder_entity.skin;
+ f = this.ladder_entity.origin_z + this.ladder_entity.maxs_z;
+ if ((this.origin_z + this.view_ofs_z) < f)
+ this.waterlevel = WATERLEVEL_SUBMERGED;
+ else if ((this.origin_z + (this.mins_z + this.maxs_z) * 0.5) < f)
+ this.waterlevel = WATERLEVEL_SWIMMING;
+ else if ((this.origin_z + this.mins_z + 1) < f)
+ this.waterlevel = WATERLEVEL_WETFEET;
else
{
- self.waterlevel = WATERLEVEL_NONE;
- self.watertype = CONTENT_EMPTY;
+ this.waterlevel = WATERLEVEL_NONE;
+ this.watertype = CONTENT_EMPTY;
}
}
// acceleration
vector wishdir = normalize(wishvel);
- float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
-#ifdef SVQC
- if (time >= self.teleport_time)
-#endif
+ float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(this) * maxspd_mod);
+ if(time >= PHYS_TELEPORT_TIME(this))
// water acceleration
- PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0);
- PM_ClientMovement_Move();
+ PM_Accelerate(this, wishdir, wishspeed, wishspeed, PHYS_ACCELERATE(this)*maxspd_mod, 1, 0, 0, 0);
+ PM_ClientMovement_Move(this);
}
-void PM_jetpack(float maxspd_mod)
-{SELFPARAM();
- //makevectors(self.v_angle.y * '0 1 0');
- makevectors(self.v_angle);
- vector wishvel = v_forward * self.movement_x
- + v_right * self.movement_y;
+void PM_jetpack(entity this, float maxspd_mod)
+{
+ //makevectors(this.v_angle.y * '0 1 0');
+ makevectors(this.v_angle);
+ vector wishvel = v_forward * this.movement_x
+ + v_right * this.movement_y;
// add remaining speed as Z component
- float maxairspd = PHYS_MAXAIRSPEED(self) * max(1, maxspd_mod);
+ float maxairspd = PHYS_MAXAIRSPEED(this) * max(1, maxspd_mod);
// fix speedhacks :P
wishvel = normalize(wishvel) * min(1, vlen(wishvel) / maxairspd);
// add the unused velocity as up component
wishvel_z = 0;
- // if (self.BUTTON_JUMP)
+ // if (this.BUTTON_JUMP)
wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
// it is now normalized, so...
float a_side = PHYS_JETPACK_ACCEL_SIDE;
float a_up = PHYS_JETPACK_ACCEL_UP;
- float a_add = PHYS_JETPACK_ANTIGRAVITY * PHYS_GRAVITY;
+ float a_add = PHYS_JETPACK_ANTIGRAVITY * PHYS_GRAVITY(this);
wishvel_x *= a_side;
wishvel_y *= a_side;
//print("best possible acceleration: ", ftos(best), "\n");
float fxy, fz;
- fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / PHYS_JETPACK_MAXSPEED_SIDE, 1);
- if (wishvel_z - PHYS_GRAVITY > 0)
- fz = bound(0, 1 - self.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
+ fxy = bound(0, 1 - (this.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / PHYS_JETPACK_MAXSPEED_SIDE, 1);
+ if (wishvel_z - PHYS_GRAVITY(this) > 0)
+ fz = bound(0, 1 - this.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
else
- fz = bound(0, 1 + self.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
+ fz = bound(0, 1 + this.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
float fvel;
fvel = vlen(wishvel);
wishvel_x *= fxy;
wishvel_y *= fxy;
- wishvel_z = (wishvel_z - PHYS_GRAVITY) * fz + PHYS_GRAVITY;
+ wishvel_z = (wishvel_z - PHYS_GRAVITY(this)) * fz + PHYS_GRAVITY(this);
fvel = min(1, vlen(wishvel) / best);
- if (PHYS_JETPACK_FUEL && !(ITEMS_STAT(self) & IT_UNLIMITED_WEAPON_AMMO))
- f = min(1, PHYS_AMMO_FUEL(self) / (PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel));
+ if (PHYS_JETPACK_FUEL && !(ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO))
+ f = min(1, PHYS_AMMO_FUEL(this) / (PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel));
else
f = 1;
if (f > 0 && wishvel != '0 0 0')
{
- self.velocity = self.velocity + wishvel * f * PHYS_INPUT_TIMELENGTH;
- UNSET_ONGROUND(self);
+ this.velocity = this.velocity + wishvel * f * PHYS_INPUT_TIMELENGTH;
+ UNSET_ONGROUND(this);
#ifdef SVQC
- if (!(ITEMS_STAT(self) & IT_UNLIMITED_WEAPON_AMMO))
- self.ammo_fuel -= PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel * f;
+ if (!(ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO))
+ this.ammo_fuel -= PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel * f;
- ITEMS_STAT(self) |= IT_USING_JETPACK;
+ ITEMS_STAT(this) |= IT_USING_JETPACK;
// jetpack also inhibits health regeneration, but only for 1 second
- self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
+ this.pauseregen_finished = max(this.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
#endif
}
#ifdef CSQC
- float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
- if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
- self.velocity_z -= g * 0.5;
- else
- self.velocity_z -= g;
- PM_ClientMovement_Move();
- if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
+ float g = PHYS_GRAVITY(this) * PHYS_ENTGRAVITY(this) * PHYS_INPUT_TIMELENGTH;
+ if(autocvar_cl_movement != 3)
+ {
if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
- self.velocity_z -= g * 0.5;
+ this.velocity_z -= g * 0.5;
+ else
+ this.velocity_z -= g;
+ }
+ PM_ClientMovement_Move(this);
+ if(autocvar_cl_movement != 3)
+ {
+ if (!IS_ONGROUND(this) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
+ if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
+ this.velocity_z -= g * 0.5;
+ }
#endif
}
// apply ground friction
const int realfriction = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
? PHYS_FRICTION_SLICK
- : PHYS_FRICTION;
+ : PHYS_FRICTION(this);
float f = sqrt(f2);
- f = 1 - PHYS_INPUT_TIMELENGTH * realfriction * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
+ f = 1 - PHYS_INPUT_TIMELENGTH * realfriction * ((f < PHYS_STOPSPEED(this)) ? (PHYS_STOPSPEED(this) / f) : 1);
f = max(0, f);
this.velocity *= f;
/*
Our goal is to invert this mess.
For the two cases we get:
- v = v0 * (1 - PHYS_INPUT_TIMELENGTH * (PHYS_STOPSPEED / v0) * PHYS_FRICTION)
- = v0 - PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION
- v0 = v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION
+ v = v0 * (1 - PHYS_INPUT_TIMELENGTH * (PHYS_STOPSPEED(this) / v0) * PHYS_FRICTION(this))
+ = v0 - PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED(this) * PHYS_FRICTION(this)
+ v0 = v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED(this) * PHYS_FRICTION(this)
and
- v = v0 * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
- v0 = v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
+ v = v0 * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this))
+ v0 = v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this))
These cases would be chosen ONLY if:
- v0 < PHYS_STOPSPEED
- v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED * PHYS_FRICTION < PHYS_STOPSPEED
- v < PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
+ v0 < PHYS_STOPSPEED(this)
+ v + PHYS_INPUT_TIMELENGTH * PHYS_STOPSPEED(this) * PHYS_FRICTION(this) < PHYS_STOPSPEED(this)
+ v < PHYS_STOPSPEED(this) * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this))
and, respectively:
- v0 >= PHYS_STOPSPEED
- v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION) >= PHYS_STOPSPEED
- v >= PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
+ v0 >= PHYS_STOPSPEED(this)
+ v / (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this)) >= PHYS_STOPSPEED(this)
+ v >= PHYS_STOPSPEED(this) * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this))
*/
}
const float addspeed = wishspeed - this.velocity * wishdir;
if (addspeed > 0)
{
- const float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
+ const float accelspeed = min(PHYS_ACCELERATE(this) * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
this.velocity += accelspeed * wishdir;
}
- const float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(this) * PHYS_INPUT_TIMELENGTH;
- if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
- this.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
+#ifdef CSQC
+ float g = PHYS_GRAVITY(this) * PHYS_ENTGRAVITY(this) * PHYS_INPUT_TIMELENGTH;
+ if(autocvar_cl_movement != 3)
+ {
+ if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
+ this.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
+ }
if (vdist(this.velocity, >, 0))
- PM_ClientMovement_Move();
- if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
- if (!IS_ONGROUND(this) || !GAMEPLAYFIX_NOGRAVITYONGROUND)
- this.velocity_z -= g * 0.5;
+ PM_ClientMovement_Move(this);
+ if(autocvar_cl_movement != 3)
+ {
+ if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
+ if (!IS_ONGROUND(this) || !GAMEPLAYFIX_NOGRAVITYONGROUND)
+ this.velocity_z -= g * 0.5;
+ }
+#endif
}
-void PM_air(float buttons_prev, float maxspd_mod)
-{SELFPARAM();
- makevectors(self.v_angle.y * '0 1 0');
- vector wishvel = v_forward * self.movement.x
- + v_right * self.movement.y;
+void PM_air(entity this, float buttons_prev, float maxspd_mod)
+{
+ makevectors(this.v_angle.y * '0 1 0');
+ vector wishvel = v_forward * this.movement.x
+ + v_right * this.movement.y;
// acceleration
vector wishdir = normalize(wishvel);
float wishspeed = vlen(wishvel);
-#ifdef SVQC
- if (time >= self.teleport_time)
-#else
- if (pmove_waterjumptime <= 0)
-#endif
+ if(PHYS_TELEPORT_TIME(this) < time)
{
- float maxairspd = PHYS_MAXAIRSPEED(self) * min(maxspd_mod, 1);
+ float maxairspd = PHYS_MAXAIRSPEED(this) * min(maxspd_mod, 1);
// apply air speed limit
- float airaccelqw = PHYS_AIRACCEL_QW(self);
+ float airaccelqw = PHYS_AIRACCEL_QW(this);
float wishspeed0 = wishspeed;
wishspeed = min(wishspeed, maxairspd);
- if (IS_DUCKED(self))
+ if (IS_DUCKED(this))
wishspeed *= 0.5;
- float airaccel = PHYS_AIRACCELERATE * min(maxspd_mod, 1);
+ float airaccel = PHYS_AIRACCELERATE(this) * min(maxspd_mod, 1);
- float accelerating = (self.velocity * wishdir > 0);
+ float accelerating = (this.velocity * wishdir > 0);
float wishspeed2 = wishspeed;
// CPM: air control
- if (PHYS_AIRSTOPACCELERATE)
+ if (PHYS_AIRSTOPACCELERATE(this))
{
- vector curdir = normalize(vec2(self.velocity));
- airaccel += (PHYS_AIRSTOPACCELERATE*maxspd_mod - airaccel) * max(0, -(curdir * wishdir));
+ vector curdir = normalize(vec2(this.velocity));
+ airaccel += (PHYS_AIRSTOPACCELERATE(this)*maxspd_mod - airaccel) * max(0, -(curdir * wishdir));
}
// note that for straight forward jumping:
// step = accel * PHYS_INPUT_TIMELENGTH * wishspeed0;
// dv/dt = accel * maxspeed * (1 - accelqw) (when fast)
// log dv/dt = logaccel + logmaxspeed (when slow)
// log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast)
- float strafity = IsMoveInDirection(self.movement, -90) + IsMoveInDirection(self.movement, +90); // if one is nonzero, other is always zero
- if (PHYS_MAXAIRSTRAFESPEED)
- wishspeed = min(wishspeed, GeomLerp(PHYS_MAXAIRSPEED(self)*maxspd_mod, strafity, PHYS_MAXAIRSTRAFESPEED*maxspd_mod));
- if (PHYS_AIRSTRAFEACCELERATE(self))
- airaccel = GeomLerp(airaccel, strafity, PHYS_AIRSTRAFEACCELERATE(self)*maxspd_mod);
- if (PHYS_AIRSTRAFEACCEL_QW(self))
+ float strafity = IsMoveInDirection(this.movement, -90) + IsMoveInDirection(this.movement, +90); // if one is nonzero, other is always zero
+ if (PHYS_MAXAIRSTRAFESPEED(this))
+ wishspeed = min(wishspeed, GeomLerp(PHYS_MAXAIRSPEED(this)*maxspd_mod, strafity, PHYS_MAXAIRSTRAFESPEED(this)*maxspd_mod));
+ if (PHYS_AIRSTRAFEACCELERATE(this))
+ airaccel = GeomLerp(airaccel, strafity, PHYS_AIRSTRAFEACCELERATE(this)*maxspd_mod);
+ if (PHYS_AIRSTRAFEACCEL_QW(this))
airaccelqw =
- (((strafity > 0.5 ? PHYS_AIRSTRAFEACCEL_QW(self) : PHYS_AIRACCEL_QW(self)) >= 0) ? +1 : -1)
+ (((strafity > 0.5 ? PHYS_AIRSTRAFEACCEL_QW(this) : PHYS_AIRACCEL_QW(this)) >= 0) ? +1 : -1)
*
- (1 - GeomLerp(1 - fabs(PHYS_AIRACCEL_QW(self)), strafity, 1 - fabs(PHYS_AIRSTRAFEACCEL_QW(self))));
+ (1 - GeomLerp(1 - fabs(PHYS_AIRACCEL_QW(this)), strafity, 1 - fabs(PHYS_AIRSTRAFEACCEL_QW(this))));
// !CPM
- if (PHYS_WARSOWBUNNY_TURNACCEL && accelerating && self.movement.y == 0 && self.movement.x != 0)
- PM_AirAccelerate(wishdir, wishspeed2);
+ if (PHYS_WARSOWBUNNY_TURNACCEL(this) && accelerating && this.movement.y == 0 && this.movement.x != 0)
+ PM_AirAccelerate(this, wishdir, wishspeed2);
else
- PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(self), PHYS_AIRACCEL_SIDEWAYS_FRICTION / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(self));
+ PM_Accelerate(this, wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(this), PHYS_AIRACCEL_SIDEWAYS_FRICTION(this) / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(this));
- if (PHYS_AIRCONTROL)
- CPM_PM_Aircontrol(wishdir, wishspeed2);
+ if (PHYS_AIRCONTROL(this))
+ CPM_PM_Aircontrol(this, wishdir, wishspeed2);
}
- float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
+#ifdef CSQC
+ float g = PHYS_GRAVITY(this) * PHYS_ENTGRAVITY(this) * PHYS_INPUT_TIMELENGTH;
+ if(autocvar_cl_movement != 3)
if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
- self.velocity_z -= g * 0.5;
+ this.velocity_z -= g * 0.5;
else
- self.velocity_z -= g;
- PM_ClientMovement_Move();
- if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
+ this.velocity_z -= g;
+#endif
+ PM_ClientMovement_Move(this);
+#ifdef CSQC
+ if(autocvar_cl_movement != 3)
+ if (!IS_ONGROUND(this) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
- self.velocity_z -= g * 0.5;
+ this.velocity_z -= g * 0.5;
+#endif
}
// used for calculating airshots
-bool IsFlying(entity a)
+bool IsFlying(entity this)
{
- if(IS_ONGROUND(a))
+ if(IS_ONGROUND(this))
return false;
- if(a.waterlevel >= WATERLEVEL_SWIMMING)
+ if(this.waterlevel >= WATERLEVEL_SWIMMING)
return false;
- traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
+ traceline(this.origin, this.origin - '0 0 48', MOVE_NORMAL, this);
if(trace_fraction < 1)
return false;
return true;
this.team = myteam + 1; // is this correct?
if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump
UNSET_JUMP_HELD(this); // canjump = true
- pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
+ PHYS_TELEPORT_TIME(this) -= PHYS_INPUT_TIMELENGTH;
PM_ClientMovement_UpdateStatus(this, true);
#endif
maxspeed_mod *= PHYS_HIGHSPEED;
#ifdef SVQC
- Physics_UpdateStats(maxspeed_mod);
+ Physics_UpdateStats(this, maxspeed_mod);
if (this.PlayerPhysplug)
if (this.PlayerPhysplug())
#endif
#ifdef SVQC
- anticheat_physics();
+ anticheat_physics(this);
#endif
- if (PM_check_specialcommand(buttons))
+ if (PM_check_specialcommand(this, buttons))
return;
#ifdef SVQC
if (sv_maxidle > 0)
this.movement_old = this.movement;
this.v_angle_old = this.v_angle;
- PM_check_nickspam();
+ PM_check_nickspam(this);
- PM_check_punch();
+ PM_check_punch(this);
#ifdef SVQC
if (IS_BOT_CLIENT(this))
{
- if (playerdemo_read())
+ if (playerdemo_read(this))
return;
- bot_think();
+ WITH(entity, self, this, bot_think());
}
#endif
this.disableclientprediction = 0;
#endif
- viewloc_PlayerPhysics();
+ viewloc_PlayerPhysics(this);
- PM_check_frozen();
+ PM_check_frozen(this);
- PM_check_blocked();
+ PM_check_blocked(this);
maxspeed_mod = 1;
if (this.conveyor.state)
this.velocity -= this.conveyor.movedir;
- MUTATOR_CALLHOOK(PlayerPhysics);
+ MUTATOR_CALLHOOK(PlayerPhysics, this);
#ifdef SVQC
if (!IS_PLAYER(this))
this.angles = '0 1 0' * this.v_angle.y;
#endif
- PM_check_hitground();
+ if (IS_PLAYER(this) && IS_ONGROUND(this))
+ {
+ PM_check_hitground(this);
+ PM_Footsteps(this);
+ }
if(IsFlying(this))
this.wasFlying = 1;
if (IS_PLAYER(this))
- CheckPlayerJump();
+ CheckPlayerJump(this);
if (this.flags & FL_WATERJUMP)
{
this.velocity_x = this.movedir.x;
this.velocity_y = this.movedir.y;
- if (time > this.teleport_time || this.waterlevel == WATERLEVEL_NONE)
+ if (time > PHYS_TELEPORT_TIME(this) || this.waterlevel == WATERLEVEL_NONE)
{
this.flags &= ~FL_WATERJUMP;
- this.teleport_time = 0;
+ PHYS_TELEPORT_TIME(this) = 0;
}
}
- else if (MUTATOR_CALLHOOK(PM_Physics, maxspeed_mod))
+ else if (MUTATOR_CALLHOOK(PM_Physics, this, maxspeed_mod))
{ }
+#ifdef SVQC
else if (this.movetype == MOVETYPE_NOCLIP || this.movetype == MOVETYPE_FLY || this.movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, this))
- PM_fly(maxspeed_mod);
+#elif defined(CSQC)
+ else if (this.move_movetype == MOVETYPE_NOCLIP || this.move_movetype == MOVETYPE_FLY || this.move_movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, this))
+#endif
+ PM_fly(this, maxspeed_mod);
else if (this.waterlevel >= WATERLEVEL_SWIMMING)
- PM_swim(maxspeed_mod);
+ PM_swim(this, maxspeed_mod);
else if (time < this.ladder_time)
- PM_ladder(maxspeed_mod);
+ PM_ladder(this, maxspeed_mod);
else if (ITEMS_STAT(this) & IT_USING_JETPACK)
- PM_jetpack(maxspeed_mod);
+ PM_jetpack(this, maxspeed_mod);
else if (IS_ONGROUND(this))
PM_walk(this, maxspeed_mod);
else
- PM_air(buttons_prev, maxspeed_mod);
+ PM_air(this, buttons_prev, maxspeed_mod);
:end
if (IS_ONGROUND(this))
SELFPARAM();
#endif
PM_Main(this);
-#ifdef CSQC
- this.pmove_flags =
- ((this.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
- (!(this.flags & FL_JUMPRELEASED) ? PMF_JUMP_HELD : 0) |
- ((this.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
-#endif
}
bool IsFlying(entity a);
+#define BUFFS_STAT(s) STAT(BUFFS, s)
+
+#define GAMEPLAYFIX_DOWNTRACEONGROUND STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, this)
+#define GAMEPLAYFIX_EASIERWATERJUMP STAT(GAMEPLAYFIX_EASIERWATERJUMP, this)
+#define GAMEPLAYFIX_STEPDOWN STAT(GAMEPLAYFIX_STEPDOWN, this)
+#define GAMEPLAYFIX_STEPMULTIPLETIMES STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, this)
+#define GAMEPLAYFIX_UNSTICKPLAYERS STAT(GAMEPLAYFIX_UNSTICKPLAYERS, this)
+
+#define PHYS_ACCELERATE(s) STAT(MOVEVARS_ACCELERATE, s)
+#define PHYS_AIRACCELERATE(s) STAT(MOVEVARS_AIRACCELERATE, s)
+#define PHYS_AIRACCEL_QW(s) STAT(MOVEVARS_AIRACCEL_QW, s)
+#define PHYS_AIRACCEL_QW_STRETCHFACTOR(s) STAT(MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, s)
+#define PHYS_AIRACCEL_SIDEWAYS_FRICTION(s) STAT(MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, s)
+#define PHYS_AIRCONTROL(s) STAT(MOVEVARS_AIRCONTROL, s)
+#define PHYS_AIRCONTROL_PENALTY(s) STAT(MOVEVARS_AIRCONTROL_PENALTY, s)
+#define PHYS_AIRCONTROL_POWER(s) STAT(MOVEVARS_AIRCONTROL_POWER, s)
+#define PHYS_AIRSPEEDLIMIT_NONQW(s) STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, s)
+#define PHYS_AIRSTOPACCELERATE(s) STAT(MOVEVARS_AIRSTOPACCELERATE, s)
+#define PHYS_AIRSTRAFEACCELERATE(s) STAT(MOVEVARS_AIRSTRAFEACCELERATE, s)
+#define PHYS_AIRSTRAFEACCEL_QW(s) STAT(MOVEVARS_AIRSTRAFEACCEL_QW, s)
+
+#define PHYS_AMMO_FUEL(s) STAT(FUEL, s)
+
+#define PHYS_DODGING_FROZEN STAT(DODGING_FROZEN, this)
+
+#define PHYS_FRICTION(s) STAT(MOVEVARS_FRICTION, s)
+#define PHYS_FRICTION_ONLAND STAT(MOVEVARS_FRICTION_ONLAND, this)
+#define PHYS_FRICTION_SLICK STAT(MOVEVARS_FRICTION_SLICK, this)
+
+#define PHYS_FROZEN(s) STAT(FROZEN, s)
+
+#define PHYS_HIGHSPEED STAT(MOVEVARS_HIGHSPEED, this)
+
+#define PHYS_JETPACK_ACCEL_SIDE STAT(JETPACK_ACCEL_SIDE, this)
+#define PHYS_JETPACK_ACCEL_UP STAT(JETPACK_ACCEL_UP, this)
+#define PHYS_JETPACK_ANTIGRAVITY STAT(JETPACK_ANTIGRAVITY, this)
+#define PHYS_JETPACK_FUEL STAT(JETPACK_FUEL, this)
+#define PHYS_JETPACK_MAXSPEED_SIDE STAT(JETPACK_MAXSPEED_SIDE, this)
+#define PHYS_JETPACK_MAXSPEED_UP STAT(JETPACK_MAXSPEED_UP, this)
+
+#define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS STAT(MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, this)
+#define PHYS_JUMPSTEP STAT(MOVEVARS_JUMPSTEP, this)
+#define PHYS_JUMPVELOCITY(s) STAT(MOVEVARS_JUMPVELOCITY, s)
+
+#define PHYS_MAXAIRSPEED(s) STAT(MOVEVARS_MAXAIRSPEED, s)
+#define PHYS_MAXAIRSTRAFESPEED(s) STAT(MOVEVARS_MAXAIRSTRAFESPEED, s)
+#define PHYS_MAXSPEED(s) STAT(MOVEVARS_MAXSPEED, s)
+
+#define PHYS_NOSTEP STAT(NOSTEP, this)
+#define PHYS_STEPHEIGHT STAT(MOVEVARS_STEPHEIGHT, this)
+
+#define PHYS_STOPSPEED(s) STAT(MOVEVARS_STOPSPEED, s)
+
+#define PHYS_TRACK_CANJUMP(s) STAT(MOVEVARS_TRACK_CANJUMP, s)
+
+#define PHYS_WALLFRICTION STAT(MOVEVARS_WALLFRICTION, this)
+
+#define PHYS_WARSOWBUNNY_ACCEL(s) STAT(MOVEVARS_WARSOWBUNNY_ACCEL, s)
+#define PHYS_WARSOWBUNNY_AIRFORWARDACCEL(s) STAT(MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, s)
+#define PHYS_WARSOWBUNNY_BACKTOSIDERATIO(s) STAT(MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, s)
+#define PHYS_WARSOWBUNNY_TOPSPEED(s) STAT(MOVEVARS_WARSOWBUNNY_TOPSPEED, s)
+#define PHYS_WARSOWBUNNY_TURNACCEL(s) STAT(MOVEVARS_WARSOWBUNNY_TURNACCEL, s)
+
+#define UPWARD_VELOCITY_CLEARS_ONGROUND STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, this)
+
#ifdef CSQC
+ noref float pmove_waterjumptime;
+
const int FL_WATERJUMP = 2048; // player jumping out of water
const int FL_JUMPRELEASED = 4096; // for jump debouncing
//float player_multijump;
//float player_jumpheight;
+ #define PHYS_GRAVITY(s) STAT(MOVEVARS_GRAVITY, s)
+
+ #define PHYS_TELEPORT_TIME(s) pmove_waterjumptime
+
+ #define TICRATE ticrate
+
#define PHYS_INPUT_ANGLES(s) input_angles
// TODO
#define PHYS_WORLD_ANGLES(s) input_angles
#define PHYS_DEAD(s) s.csqcmodel_isdead
- #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
- #define GAMEPLAYFIX_NOGRAVITYONGROUND cvar("sv_gameplayfix_nogravityonground")
- #define GAMEPLAYFIX_Q2AIRACCELERATE cvar("sv_gameplayfix_q2airaccelerate")
- #define GAMEPLAYFIX_EASIERWATERJUMP getstati(STAT_GAMEPLAYFIX_EASIERWATERJUMP)
- #define GAMEPLAYFIX_DOWNTRACEONGROUND getstati(STAT_GAMEPLAYFIX_DOWNTRACEONGROUND)
- #define GAMEPLAYFIX_STEPMULTIPLETIMES getstati(STAT_GAMEPLAYFIX_STEPMULTIPLETIMES)
- #define GAMEPLAYFIX_UNSTICKPLAYERS getstati(STAT_GAMEPLAYFIX_UNSTICKPLAYERS)
- #define GAMEPLAYFIX_STEPDOWN getstati(STAT_GAMEPLAYFIX_STEPDOWN)
+ #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE (boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE))
+ #define GAMEPLAYFIX_NOGRAVITYONGROUND (boolean(moveflags & MOVEFLAG_NOGRAVITYONGROUND))
+ #define GAMEPLAYFIX_Q2AIRACCELERATE (boolean(moveflags & MOVEFLAG_Q2AIRACCELERATE))
#define IS_DUCKED(s) boolean(s.flags & FL_DUCKED)
#define SET_DUCKED(s) s.flags |= FL_DUCKED
#define WAS_ONGROUND(s) boolean(s.lastflags & FL_ONGROUND)
#define ITEMS_STAT(s) (s).items
- #define BUFFS_STAT(s) getstati(STAT_BUFFS)
-
- #define PHYS_AMMO_FUEL(s) getstati(STAT_FUEL)
-
- #define PHYS_FROZEN(s) getstati(STAT_FROZEN)
#define PHYS_JUMPSPEEDCAP_MIN cvar_string("cl_jumpspeedcap_min")
#define PHYS_JUMPSPEEDCAP_MAX cvar_string("cl_jumpspeedcap_max")
- #define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS getstati(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS)
-
- #define PHYS_CL_TRACK_CANJUMP(s) getstati(STAT_MOVEVARS_CL_TRACK_CANJUMP)
- #define PHYS_TRACK_CANJUMP(s) getstati(STAT_MOVEVARS_TRACK_CANJUMP)
- #define PHYS_ACCELERATE getstatf(STAT_MOVEVARS_ACCELERATE)
- #define PHYS_AIRACCEL_QW(s) getstatf(STAT_MOVEVARS_AIRACCEL_QW)
- #define PHYS_AIRACCEL_QW_STRETCHFACTOR(s) getstatf(STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR)
- #define PHYS_AIRACCEL_SIDEWAYS_FRICTION getstatf(STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION)
- #define PHYS_AIRACCELERATE getstatf(STAT_MOVEVARS_AIRACCELERATE)
- #define PHYS_AIRCONTROL getstatf(STAT_MOVEVARS_AIRCONTROL)
- #define PHYS_AIRCONTROL_PENALTY getstatf(STAT_MOVEVARS_AIRCONTROL_PENALTY)
- #define PHYS_AIRCONTROL_POWER getstatf(STAT_MOVEVARS_AIRCONTROL_POWER)
- #define PHYS_AIRSPEEDLIMIT_NONQW(s) getstatf(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW)
- #define PHYS_AIRSTOPACCELERATE getstatf(STAT_MOVEVARS_AIRSTOPACCELERATE)
- #define PHYS_AIRSTRAFEACCEL_QW(s) getstatf(STAT_MOVEVARS_AIRSTRAFEACCEL_QW)
- #define PHYS_AIRSTRAFEACCELERATE(s) getstatf(STAT_MOVEVARS_AIRSTRAFEACCELERATE)
- #define PHYS_ENTGRAVITY(s) getstatf(STAT_MOVEVARS_ENTGRAVITY)
- #define PHYS_FRICTION getstatf(STAT_MOVEVARS_FRICTION)
- #define PHYS_FRICTION_SLICK getstatf(STAT_MOVEVARS_FRICTION_SLICK)
- #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_MAXAIRSPEED(s) getstatf(STAT_MOVEVARS_MAXAIRSPEED)
- #define PHYS_MAXAIRSTRAFESPEED getstatf(STAT_MOVEVARS_MAXAIRSTRAFESPEED)
- #define PHYS_MAXSPEED(s) getstatf(STAT_MOVEVARS_MAXSPEED)
- #define PHYS_STEPHEIGHT getstatf(STAT_MOVEVARS_STEPHEIGHT)
- #define PHYS_STOPSPEED getstatf(STAT_MOVEVARS_STOPSPEED)
- #define PHYS_WARSOWBUNNY_ACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_ACCEL)
- #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO getstatf(STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO)
- #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL)
- #define PHYS_WARSOWBUNNY_TOPSPEED getstatf(STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED)
- #define PHYS_WARSOWBUNNY_TURNACCEL getstatf(STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL)
-
- #define PHYS_WALLFRICTION getstati(STAT_MOVEVARS_WALLFRICTION)
-
- #define PHYS_JETPACK_ACCEL_UP getstatf(STAT_JETPACK_ACCEL_UP)
- #define PHYS_JETPACK_ACCEL_SIDE getstatf(STAT_JETPACK_ACCEL_SIDE)
- #define PHYS_JETPACK_ANTIGRAVITY getstatf(STAT_JETPACK_ANTIGRAVITY)
- #define PHYS_JETPACK_FUEL getstatf(STAT_JETPACK_FUEL)
- #define PHYS_JETPACK_MAXSPEED_UP getstatf(STAT_JETPACK_MAXSPEED_UP)
- #define PHYS_JETPACK_MAXSPEED_SIDE getstatf(STAT_JETPACK_MAXSPEED_SIDE)
-
- #define PHYS_DODGING_FROZEN getstati(STAT_DODGING_FROZEN)
-
- #define PHYS_NOSTEP getstati(STAT_NOSTEP)
- #define PHYS_JUMPSTEP getstati(STAT_MOVEVARS_JUMPSTEP)
+
+ #define PHYS_CL_TRACK_CANJUMP(s) STAT(MOVEVARS_CL_TRACK_CANJUMP, s)
+ // FIXME: 0 doesn't mean zero gravity
+ #define PHYS_ENTGRAVITY(s) STAT(MOVEVARS_ENTGRAVITY, s)
#elif defined(SVQC)
bool Physics_Valid(string thecvar);
- .vector stat_pl_view_ofs;
- .vector stat_pl_crouch_view_ofs;
-
- .vector stat_pl_min;
- .vector stat_pl_max;
- .vector stat_pl_crouch_min;
- .vector stat_pl_crouch_max;
-
- .float stat_sv_airaccel_qw;
- .float stat_sv_airstrafeaccel_qw;
- .float stat_sv_airspeedlimit_nonqw;
- .float stat_sv_maxspeed;
- .float stat_movement_highspeed;
-
- .float stat_sv_friction_on_land;
- .float stat_sv_friction_slick;
-
- .string stat_jumpspeedcap_min;
- .string stat_jumpspeedcap_max;
- .float stat_jumpspeedcap_disable_onramps;
-
- .float stat_jetpack_accel_side;
- .float stat_jetpack_accel_up;
- .float stat_jetpack_antigravity;
- .float stat_jetpack_fuel;
- .float stat_jetpack_maxspeed_up;
- .float stat_jetpack_maxspeed_side;
- .float stat_gameplayfix_easierwaterjump;
- .float stat_gameplayfix_downtracesupportsongroundflag;
- .float stat_gameplayfix_stepmultipletimes;
- .float stat_gameplayfix_unstickplayers;
- .float stat_gameplayfix_stepdown;
-
- // new properties
- .float stat_sv_jumpvelocity;
- .float stat_sv_airaccel_qw_stretchfactor;
- .float stat_sv_maxairstrafespeed;
- .float stat_sv_maxairspeed;
- .float stat_sv_airstrafeaccelerate;
- .float stat_sv_warsowbunny_turnaccel;
- .float stat_sv_airaccel_sideways_friction;
- .float stat_sv_aircontrol;
- .float stat_sv_aircontrol_power;
- .float stat_sv_aircontrol_penalty;
- .float stat_sv_warsowbunny_airforwardaccel;
- .float stat_sv_warsowbunny_topspeed;
- .float stat_sv_warsowbunny_accel;
- .float stat_sv_warsowbunny_backtosideratio;
- .float stat_sv_friction;
- .float stat_sv_accelerate;
- .float stat_sv_stopspeed;
- .float stat_sv_airaccelerate;
- .float stat_sv_airstopaccelerate;
-
- .float stat_nostep;
- .float stat_jumpstep;
-
- .bool stat_sv_track_canjump;
+ .float stat_sv_airspeedlimit_nonqw = _STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW);
+ .float stat_sv_maxspeed = _STAT(MOVEVARS_MAXSPEED);
+
+ /** Not real stats */
+ .string stat_jumpspeedcap_min, stat_jumpspeedcap_max;
+
+ #define PHYS_TELEPORT_TIME(s) s.teleport_time
+
+ #define PHYS_GRAVITY(s) autocvar_sv_gravity
+
+ #define TICRATE sys_frametime
#define PHYS_INPUT_ANGLES(s) s.v_angle
#define PHYS_WORLD_ANGLES(s) s.angles
#define PHYS_DEAD(s) s.deadflag != DEAD_NO
#define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE autocvar_sv_gameplayfix_gravityunaffectedbyticrate
- #define GAMEPLAYFIX_NOGRAVITYONGROUND cvar("sv_gameplayfix_nogravityonground")
+ #define GAMEPLAYFIX_NOGRAVITYONGROUND autocvar_sv_gameplayfix_nogravityonground
#define GAMEPLAYFIX_Q2AIRACCELERATE autocvar_sv_gameplayfix_q2airaccelerate
- #define GAMEPLAYFIX_EASIERWATERJUMP cvar("sv_gameplayfix_easierwaterjump")
- #define GAMEPLAYFIX_DOWNTRACEONGROUND cvar("sv_gameplayfix_downtracesupportsongroundflag")
- #define GAMEPLAYFIX_STEPMULTIPLETIMES cvar("sv_gameplayfix_stepmultipletimes")
- #define GAMEPLAYFIX_UNSTICKPLAYERS cvar("sv_gameplayfix_unstickplayers")
- #define GAMEPLAYFIX_STEPDOWN cvar("sv_gameplayfix_stepdown")
#define IS_DUCKED(s) s.crouch
#define SET_DUCKED(s) s.crouch = true
#define WAS_ONGROUND(s) boolean((s).lastflags & FL_ONGROUND)
#define ITEMS_STAT(s) s.items
- #define BUFFS_STAT(s) (s).buffs
-
- #define PHYS_AMMO_FUEL(s) s.ammo_fuel
-
- #define PHYS_FROZEN(s) s.frozen
#define PHYS_JUMPSPEEDCAP_MIN autocvar_sv_jumpspeedcap_min
#define PHYS_JUMPSPEEDCAP_MAX autocvar_sv_jumpspeedcap_max
- #define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS autocvar_sv_jumpspeedcap_max_disable_on_ramps
#define PHYS_CL_TRACK_CANJUMP(s) s.cvar_cl_movement_track_canjump
- #define PHYS_TRACK_CANJUMP(s) s.stat_sv_track_canjump
- #define PHYS_ACCELERATE self.stat_sv_accelerate
- #define PHYS_AIRACCEL_QW(s) s.stat_sv_airaccel_qw
- #define PHYS_AIRACCEL_QW_STRETCHFACTOR(s) self.stat_sv_airaccel_qw_stretchfactor
- #define PHYS_AIRACCEL_SIDEWAYS_FRICTION self.stat_sv_airaccel_sideways_friction
- #define PHYS_AIRACCELERATE self.stat_sv_airaccelerate
- #define PHYS_AIRCONTROL self.stat_sv_aircontrol
- #define PHYS_AIRCONTROL_PENALTY self.stat_sv_aircontrol_penalty
- #define PHYS_AIRCONTROL_POWER self.stat_sv_aircontrol_power
- #define PHYS_AIRSPEEDLIMIT_NONQW(s) s.stat_sv_airspeedlimit_nonqw
- #define PHYS_AIRSTOPACCELERATE self.stat_sv_airstopaccelerate
- #define PHYS_AIRSTRAFEACCEL_QW(s) s.stat_sv_airstrafeaccel_qw
- #define PHYS_AIRSTRAFEACCELERATE(s) s.stat_sv_airstrafeaccelerate
#define PHYS_ENTGRAVITY(s) s.gravity
- #define PHYS_FRICTION self.stat_sv_friction
- #define PHYS_FRICTION_SLICK autocvar_sv_friction_slick
- #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 self.stat_sv_jumpvelocity
- #define PHYS_MAXAIRSPEED(s) self.stat_sv_maxairspeed
- #define PHYS_MAXAIRSTRAFESPEED self.stat_sv_maxairstrafespeed
- #define PHYS_MAXSPEED(s) s.stat_sv_maxspeed
- #define PHYS_STEPHEIGHT autocvar_sv_stepheight
- #define PHYS_STOPSPEED self.stat_sv_stopspeed
- #define PHYS_WARSOWBUNNY_ACCEL self.stat_sv_warsowbunny_accel
- #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO self.stat_sv_warsowbunny_backtosideratio
- #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL self.stat_sv_warsowbunny_airforwardaccel
- #define PHYS_WARSOWBUNNY_TOPSPEED self.stat_sv_warsowbunny_topspeed
- #define PHYS_WARSOWBUNNY_TURNACCEL self.stat_sv_warsowbunny_turnaccel
-
- #define PHYS_WALLFRICTION cvar("sv_wallfriction")
-
- #define PHYS_JETPACK_ACCEL_UP autocvar_g_jetpack_acceleration_up
- #define PHYS_JETPACK_ACCEL_SIDE autocvar_g_jetpack_acceleration_side
- #define PHYS_JETPACK_ANTIGRAVITY autocvar_g_jetpack_antigravity
- #define PHYS_JETPACK_FUEL autocvar_g_jetpack_fuel
- #define PHYS_JETPACK_MAXSPEED_UP autocvar_g_jetpack_maxspeed_up
- #define PHYS_JETPACK_MAXSPEED_SIDE autocvar_g_jetpack_maxspeed_side
-
- #define PHYS_DODGING_FROZEN autocvar_sv_dodging_frozen
-
- #define PHYS_NOSTEP cvar("sv_nostep")
- #define PHYS_JUMPSTEP cvar("sv_jumpstep")
#endif
#endif
#define sound8(e, o, chan, samp, vol, atten, speed, sf) \
do \
{ \
- entity __e = e; \
+ entity __e; \
+ int __chan = chan; \
+ string __samp = samp; \
+ bool auto = false; \
+ if (__chan > 0) __e = e; \
+ else \
+ { \
+ auto = true; \
+ __chan = fabs(__chan); \
+ entity tmp = __e = new(csqc_autochannel); \
+ make_pure(tmp); \
+ tmp.think = SUB_Remove_self; \
+ tmp.nextthink = time + soundlength(__samp); \
+ } \
vector old_origin = __e.origin; \
vector old_mins = __e.mins; \
vector old_maxs = __e.maxs; \
setorigin(__e, o); \
setsize(__e, '0 0 0', '0 0 0'); \
- sound7(__e, chan, samp, vol, atten, speed, sf); \
+ sound7(__e, __chan, __samp, vol, atten, speed, sf); \
+ if (auto) break; \
setorigin(__e, old_origin); \
setsize(__e, old_mins, old_maxs); \
} \
x(ogg) \
x(flac) \
/**/
- string full, relative;
- #define tryext(ext) { if (fexists(full = strcat("sound/", relative = strcat(base, "." #ext)))) break; }
+ string relative;
+ #define tryext(ext) { if (fexists(strcat("sound/", relative = strcat(base, "." #ext)))) break; }
do
{
extensions(tryext);
#undef tryext
#undef extensions
- LOG_WARNINGF("Missing sound: \"%s\"\n", full);
+ LOG_WARNINGF("Missing sound: \"%s\"\n", strcat("sound/", base));
+#ifdef CSQC
return string_null;
+#endif
}
while (0);
+#ifdef SVQC
+ return strcat(base, ".wav"); // let the client engine decide
+#else
return relative;
+#endif
}
METHOD(Sound, sound_precache, void(entity this))
{
#ifndef STATS_H
#define STATS_H
+#ifdef SVQC
+#include "../server/cl_client.qh"
+#endif
+
// Full list of all stat constants, included in a single location for easy reference
// 255 is the current limit (MAX_CL_STATS - 1), engine will need to be modified if you wish to add more stats
-const int MAX_CL_STATS = 256;
-// -Wdouble-declaration
-// const int STAT_HEALTH = 0;
-// 1 empty?
-const int STAT_WEAPON = 2;
-// -Wdouble-declaration
-// const int STAT_AMMO = 3;
-// -Wdouble-declaration
-// const int STAT_ARMOR = 4;
-// -Wdouble-declaration
-// const int STAT_WEAPONFRAME = 5;
-// -Wdouble-declaration
-// const int STAT_SHELLS = 6;
-// -Wdouble-declaration
-// const int STAT_NAILS = 7;
-// -Wdouble-declaration
-// const int STAT_ROCKETS = 8;
-// -Wdouble-declaration
-// const int STAT_CELLS = 9;
-// -Wdouble-declaration
-// const int STAT_ACTIVEWEAPON = 10;
-// -Wdouble-declaration
-// const int STAT_TOTALSECRETS = 11;
-// -Wdouble-declaration
-// const int STAT_TOTALMONSTERS = 12;
-// -Wdouble-declaration
-// const int STAT_SECRETS = 13;
-// -Wdouble-declaration
-// const int STAT_MONSTERS = 14;
-// -Wdouble-declaration
-// const int STAT_ITEMS = 15;
-// -Wdouble-declaration
-// const int STAT_VIEWHEIGHT = 16;
-// 17 empty?
-// 18 empty?
-// 19 empty?
-// 20 empty?
-const int STAT_VIEWZOOM = 21;
-// 22 empty?
-// 23 empty?
-// 24 empty?
-// 25 empty?
-// 26 empty?
-// 27 empty?
-// 28 empty?
-// 29 empty?
-// 30 empty?
-// 31 empty?
-
-enum {
- STAT_WEAPONS = 32,
- STAT_WEAPONS2,
- STAT_WEAPONS3,
-
- STAT_WEAPONSINMAP,
- STAT_WEAPONSINMAP2,
- STAT_WEAPONSINMAP3,
-
- STAT_PL_VIEW_OFS1,
- STAT_PL_VIEW_OFS2,
- STAT_PL_VIEW_OFS3,
-
- STAT_PL_CROUCH_VIEW_OFS1,
- STAT_PL_CROUCH_VIEW_OFS2,
- STAT_PL_CROUCH_VIEW_OFS3,
-
- STAT_PL_MIN1,
- STAT_PL_MIN2,
- STAT_PL_MIN3,
-
- STAT_PL_MAX1,
- STAT_PL_MAX2,
- STAT_PL_MAX3,
+const int MAX_CL_STATS = 256;
+#ifndef CSQC
+const int STAT_HEALTH = 0; // .health
+const int STAT_ARMOR = 4; // .armorvalue
+const int STAT_SHELLS = 6; // .ammo_shells
+const int STAT_NAILS = 7; // .ammo_nails
+const int STAT_ROCKETS = 8; // .ammo_rockets
+const int STAT_CELLS = 9; // .ammo_cells
+const int STAT_ACTIVEWEAPON = 10; // .weapon
+const int STAT_ITEMS = 15; // .items | .items2 << 23 | serverflags << 28
+const int STAT_VIEWHEIGHT = 16; // .view_ofs_z
+#endif
- STAT_PL_CROUCH_MIN1,
- STAT_PL_CROUCH_MIN2,
- STAT_PL_CROUCH_MIN3,
+REGISTER_STAT(WEAPONS, vectori)
+REGISTER_STAT(WEAPONSINMAP, vectori)
- STAT_PL_CROUCH_MAX1,
- STAT_PL_CROUCH_MAX2,
- STAT_PL_CROUCH_MAX3,
+REGISTER_STAT(PL_VIEW_OFS, vector, autocvar_sv_player_viewoffset)
+REGISTER_STAT(PL_CROUCH_VIEW_OFS, vector, autocvar_sv_player_crouch_viewoffset)
- STAT_LAST_VECTOR
-};
+REGISTER_STAT(PL_MIN, vector, autocvar_sv_player_mins)
+REGISTER_STAT(PL_CROUCH_MIN, vector, autocvar_sv_player_crouch_mins)
-const int REGISTERED_STATS = 6;
+REGISTER_STAT(PL_MAX, vector, autocvar_sv_player_maxs)
+REGISTER_STAT(PL_CROUCH_MAX, vector, autocvar_sv_player_crouch_maxs)
REGISTER_STAT(KH_KEYS, int)
+
/** weapon requested to switch to; next WANTED weapon (for HUD) */
REGISTER_STAT(SWITCHWEAPON, int)
+/** weapon currently being switched to (is copied from switchweapon once switch is possible) */
+REGISTER_STAT(SWITCHINGWEAPON, int)
+REGISTER_STAT(WEAPON_NEXTTHINK, float)
+#ifdef SVQC
+SPECTATE_COPY(_STAT(WEAPON_NEXTTHINK))
+float W_WeaponRateFactor();
+#endif
+REGISTER_STAT(WEAPONRATEFACTOR, float, W_WeaponRateFactor())
+
REGISTER_STAT(GAMESTARTTIME, float)
REGISTER_STAT(STRENGTH_FINISHED, float)
REGISTER_STAT(INVINCIBLE_FINISHED, float)
/** arc heat in [0,1] */
REGISTER_STAT(ARC_HEAT, float)
+REGISTER_STAT(PRESSED_KEYS, int)
+/** this stat could later contain some other bits of info, like, more server-side particle config */
+REGISTER_STAT(ALLOW_OLDVORTEXBEAM, bool)
+REGISTER_STAT(FUEL, int)
+REGISTER_STAT(NB_METERSTART, float)
+/** compressShotOrigin */
+REGISTER_STAT(SHOTORG, int)
+REGISTER_STAT(LEADLIMIT, float)
+REGISTER_STAT(WEAPON_CLIPLOAD, int)
+REGISTER_STAT(WEAPON_CLIPSIZE, int)
-enum {
- STAT_FIRST_MAIN = (STAT_LAST_VECTOR - 1) + REGISTERED_STATS,
+REGISTER_STAT(VORTEX_CHARGE, float)
+REGISTER_STAT(LAST_PICKUP, float)
+REGISTER_STAT(HUD, int)
+REGISTER_STAT(VORTEX_CHARGEPOOL, float)
+REGISTER_STAT(HIT_TIME, float)
+REGISTER_STAT(DAMAGE_DEALT_TOTAL, int)
+REGISTER_STAT(TYPEHIT_TIME, float)
+REGISTER_STAT(LAYED_MINES, int)
+REGISTER_STAT(HAGAR_LOAD, int)
+REGISTER_STAT(SUPERWEAPONS_FINISHED, float)
+REGISTER_STAT(VEHICLESTAT_HEALTH, int)
+REGISTER_STAT(VEHICLESTAT_SHIELD, int)
+REGISTER_STAT(VEHICLESTAT_ENERGY, int)
+REGISTER_STAT(VEHICLESTAT_AMMO1, int)
+REGISTER_STAT(VEHICLESTAT_RELOAD1, int)
+REGISTER_STAT(VEHICLESTAT_AMMO2, int)
+REGISTER_STAT(VEHICLESTAT_RELOAD2, int)
+REGISTER_STAT(VEHICLESTAT_W2MODE, int)
+REGISTER_STAT(NADE_TIMER, float)
+REGISTER_STAT(SECRETS_TOTAL, float)
+REGISTER_STAT(SECRETS_FOUND, float)
+REGISTER_STAT(RESPAWN_TIME, float)
+REGISTER_STAT(ROUNDSTARTTIME, float)
+REGISTER_STAT(MONSTERS_TOTAL, int)
+REGISTER_STAT(MONSTERS_KILLED, int)
+REGISTER_STAT(BUFFS, int)
+REGISTER_STAT(NADE_BONUS, float)
+REGISTER_STAT(NADE_BONUS_TYPE, int)
+REGISTER_STAT(NADE_BONUS_SCORE, float)
+REGISTER_STAT(HEALING_ORB, float)
+REGISTER_STAT(HEALING_ORB_ALPHA, float)
+REGISTER_STAT(PLASMA, int)
+REGISTER_STAT(OK_AMMO_CHARGE, float)
+REGISTER_STAT(OK_AMMO_CHARGEPOOL, float)
+REGISTER_STAT(FROZEN, int)
+REGISTER_STAT(REVIVE_PROGRESS, float)
+REGISTER_STAT(ROUNDLOST, int)
+REGISTER_STAT(BUFF_TIME, float)
+REGISTER_STAT(CTF_FLAGSTATUS, int)
- STAT_PRESSED_KEYS,
- /** this stat could later contain some other bits of info, like, more server-side particle config */ STAT_ALLOW_OLDVORTEXBEAM,
- STAT_FUEL,
- STAT_NB_METERSTART,
- /** compressShotOrigin */ STAT_SHOTORG,
- STAT_LEADLIMIT,
- STAT_WEAPON_CLIPLOAD,
- STAT_WEAPON_CLIPSIZE,
- STAT_VORTEX_CHARGE,
- STAT_LAST_PICKUP,
- STAT_HUD,
- STAT_VORTEX_CHARGEPOOL,
- STAT_HIT_TIME,
- STAT_DAMAGE_DEALT_TOTAL,
- STAT_TYPEHIT_TIME,
- STAT_LAYED_MINES,
- STAT_HAGAR_LOAD,
- STAT_SWITCHINGWEAPON,
- STAT_SUPERWEAPONS_FINISHED,
- STAT_VEHICLESTAT_HEALTH,
- STAT_VEHICLESTAT_SHIELD,
- STAT_VEHICLESTAT_ENERGY,
- STAT_VEHICLESTAT_AMMO1,
- STAT_VEHICLESTAT_RELOAD1,
- STAT_VEHICLESTAT_AMMO2,
- STAT_VEHICLESTAT_RELOAD2,
- STAT_VEHICLESTAT_W2MODE,
- STAT_NADE_TIMER,
- STAT_SECRETS_TOTAL,
- STAT_SECRETS_FOUND,
- STAT_RESPAWN_TIME,
- STAT_ROUNDSTARTTIME,
- STAT_MONSTERS_TOTAL,
- STAT_MONSTERS_KILLED,
- STAT_BUFFS,
- STAT_NADE_BONUS,
- STAT_NADE_BONUS_TYPE,
- STAT_NADE_BONUS_SCORE,
- STAT_HEALING_ORB,
- STAT_HEALING_ORB_ALPHA,
- STAT_PLASMA,
- STAT_OK_AMMO_CHARGE,
- STAT_OK_AMMO_CHARGEPOOL,
- STAT_FROZEN,
- STAT_REVIVE_PROGRESS,
- STAT_ROUNDLOST,
- STAT_BUFF_TIME,
- STAT_CTF_FLAGSTATUS,
- STAT_MULTIJUMP_DODGING,
- STAT_MULTIJUMP_MAXSPEED,
- STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND,
- STAT_BUGRIGS_REVERSE_STOPPING,
- STAT_BUGRIGS_REVERSE_SPINNING,
- STAT_BUGRIGS_CAR_JUMPING,
- STAT_BUGRIGS_FRICTION_AIR,
- STAT_BUGRIGS_STEER,
- STAT_BUGRIGS_SPEED_POW,
- STAT_BUGRIGS_SPEED_REF,
- STAT_BUGRIGS_ACCEL,
- STAT_BUGRIGS_FRICTION_BRAKE,
- STAT_BUGRIGS_AIR_STEERING,
- STAT_BUGRIGS_FRICTION_FLOOR,
- STAT_BUGRIGS_REVERSE_SPEEDING,
- STAT_BUGRIGS_PLANAR_MOVEMENT,
- STAT_BUGRIGS_ANGLE_SMOOTHING,
- STAT_BUGRIGS,
- STAT_GAMEPLAYFIX_STEPDOWN,
- STAT_MOVEVARS_JUMPSTEP,
- STAT_NOSTEP,
- STAT_GAMEPLAYFIX_UNSTICKPLAYERS,
- STAT_GAMEPLAYFIX_STEPMULTIPLETIMES,
- STAT_GAMEPLAYFIX_DOWNTRACEONGROUND,
- STAT_GAMEPLAYFIX_EASIERWATERJUMP,
- STAT_MOVEVARS_FRICTION_SLICK,
- STAT_MOVEVARS_FRICTION_ONLAND,
- STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS,
- STAT_MOVEVARS_TRACK_CANJUMP,
- STAT_DOUBLEJUMP,
- STAT_MOVEVARS_CL_TRACK_CANJUMP,
- STAT_MULTIJUMP_ADD,
- STAT_MULTIJUMP_SPEED,
- STAT_MULTIJUMP,
- STAT_DODGING_TIMEOUT,
- STAT_DODGING_WALL,
- STAT_DODGING_UP_SPEED,
- STAT_DODGING_RAMP_TIME,
- STAT_DODGING_HEIGHT_THRESHOLD,
- STAT_DODGING_DISTANCE_THRESHOLD,
- STAT_DODGING_HORIZ_SPEED,
- STAT_DODGING_DELAY,
- STAT_DODGING_FROZEN_NO_DOUBLETAP,
- STAT_DODGING_HORIZ_SPEED_FROZEN,
- STAT_DODGING,
- STAT_DODGING_FROZEN,
- STAT_JETPACK_MAXSPEED_UP,
- STAT_JETPACK_MAXSPEED_SIDE,
- STAT_JETPACK_FUEL,
- STAT_JETPACK_ANTIGRAVITY,
- STAT_JETPACK_ACCEL_SIDE,
- STAT_JETPACK_ACCEL_UP,
- STAT_MOVEVARS_HIGHSPEED,
- STAT_MULTIJUMP_COUNT,
+#ifdef SVQC
+int autocvar_g_multijump;
+float autocvar_g_multijump_add;
+float autocvar_g_multijump_speed;
+float autocvar_g_multijump_maxspeed;
+float autocvar_g_multijump_dodging = 1;
+#endif
+REGISTER_STAT(MULTIJUMP_DODGING, int, autocvar_g_multijump_dodging)
+REGISTER_STAT(MULTIJUMP_MAXSPEED, float, autocvar_g_multijump_maxspeed)
+REGISTER_STAT(MULTIJUMP_ADD, int, autocvar_g_multijump_add)
+REGISTER_STAT(MULTIJUMP_SPEED, float, autocvar_g_multijump_speed)
+.int multijump_count;
+REGISTER_STAT(MULTIJUMP_COUNT, int, this.multijump_count)
+REGISTER_STAT(MULTIJUMP, int, autocvar_g_multijump)
+REGISTER_STAT(DOUBLEJUMP, int, autocvar_sv_doublejump)
+
+#ifdef SVQC
+bool g_bugrigs;
+bool g_bugrigs_planar_movement;
+bool g_bugrigs_planar_movement_car_jumping;
+float g_bugrigs_reverse_spinning;
+float g_bugrigs_reverse_speeding;
+float g_bugrigs_reverse_stopping;
+float g_bugrigs_air_steering;
+float g_bugrigs_angle_smoothing;
+float g_bugrigs_friction_floor;
+float g_bugrigs_friction_brake;
+float g_bugrigs_friction_air;
+float g_bugrigs_accel;
+float g_bugrigs_speed_ref;
+float g_bugrigs_speed_pow;
+float g_bugrigs_steer;
+#endif
+REGISTER_STAT(BUGRIGS, int, g_bugrigs)
+REGISTER_STAT(BUGRIGS_ACCEL, float, g_bugrigs_accel)
+REGISTER_STAT(BUGRIGS_AIR_STEERING, int, g_bugrigs_air_steering)
+REGISTER_STAT(BUGRIGS_ANGLE_SMOOTHING, int, g_bugrigs_angle_smoothing)
+REGISTER_STAT(BUGRIGS_CAR_JUMPING, int, g_bugrigs_planar_movement_car_jumping)
+REGISTER_STAT(BUGRIGS_FRICTION_AIR, float, g_bugrigs_friction_air)
+REGISTER_STAT(BUGRIGS_FRICTION_BRAKE, float, g_bugrigs_friction_brake)
+REGISTER_STAT(BUGRIGS_FRICTION_FLOOR, float, g_bugrigs_friction_floor)
+REGISTER_STAT(BUGRIGS_PLANAR_MOVEMENT, int, g_bugrigs_planar_movement)
+REGISTER_STAT(BUGRIGS_REVERSE_SPEEDING, int, g_bugrigs_reverse_speeding)
+REGISTER_STAT(BUGRIGS_REVERSE_SPINNING, int, g_bugrigs_reverse_spinning)
+REGISTER_STAT(BUGRIGS_REVERSE_STOPPING, int, g_bugrigs_reverse_stopping)
+REGISTER_STAT(BUGRIGS_SPEED_POW, float, g_bugrigs_speed_pow)
+REGISTER_STAT(BUGRIGS_SPEED_REF, float, g_bugrigs_speed_ref)
+REGISTER_STAT(BUGRIGS_STEER, float, g_bugrigs_steer)
+
+REGISTER_STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, int, cvar("sv_gameplayfix_downtracesupportsongroundflag"))
+REGISTER_STAT(GAMEPLAYFIX_EASIERWATERJUMP, int, cvar("sv_gameplayfix_easierwaterjump"))
+REGISTER_STAT(GAMEPLAYFIX_STEPDOWN, int, cvar("sv_gameplayfix_stepdown"))
+REGISTER_STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, int, cvar("sv_gameplayfix_stepmultipletimes"))
+REGISTER_STAT(GAMEPLAYFIX_UNSTICKPLAYERS, int, cvar("sv_gameplayfix_unstickplayers"))
+REGISTER_STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, int, autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag)
+
+REGISTER_STAT(MOVEVARS_JUMPSTEP, int, cvar("sv_jumpstep"))
+REGISTER_STAT(NOSTEP, int, cvar("sv_nostep"))
+
+REGISTER_STAT(MOVEVARS_FRICTION, float)
+REGISTER_STAT(MOVEVARS_FRICTION_SLICK, float, autocvar_sv_friction_slick)
+REGISTER_STAT(MOVEVARS_FRICTION_ONLAND, float, autocvar_sv_friction_on_land)
- STAT_LAST_MAIN
-};
+REGISTER_STAT(MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, int, autocvar_sv_jumpspeedcap_max_disable_on_ramps)
+REGISTER_STAT(MOVEVARS_TRACK_CANJUMP, int)
+/** cvar loopback */
+REGISTER_STAT(MOVEVARS_CL_TRACK_CANJUMP, int)
-const int STAT_LAST = STAT_LAST_MAIN + 5;
+#ifdef SVQC
+int g_dodging;
+float autocvar_sv_dodging_delay;
+float autocvar_sv_dodging_wall_distance_threshold;
+bool autocvar_sv_dodging_frozen;
+bool autocvar_sv_dodging_frozen_doubletap;
+float autocvar_sv_dodging_height_threshold;
+float autocvar_sv_dodging_horiz_speed;
+float autocvar_sv_dodging_horiz_speed_frozen;
+float autocvar_sv_dodging_ramp_time;
+float autocvar_sv_dodging_up_speed;
+bool autocvar_sv_dodging_wall_dodging;
+#endif
+
+REGISTER_STAT(DODGING, int, g_dodging)
+REGISTER_STAT(DODGING_DELAY, float, autocvar_sv_dodging_delay)
+REGISTER_STAT(DODGING_DISTANCE_THRESHOLD, float, autocvar_sv_dodging_wall_distance_threshold)
+REGISTER_STAT(DODGING_FROZEN, int, autocvar_sv_dodging_frozen)
+REGISTER_STAT(DODGING_FROZEN_NO_DOUBLETAP, int, autocvar_sv_dodging_frozen_doubletap)
+REGISTER_STAT(DODGING_HEIGHT_THRESHOLD, float, autocvar_sv_dodging_height_threshold)
+REGISTER_STAT(DODGING_HORIZ_SPEED, float, autocvar_sv_dodging_horiz_speed)
+REGISTER_STAT(DODGING_HORIZ_SPEED_FROZEN, float, autocvar_sv_dodging_horiz_speed_frozen)
+REGISTER_STAT(DODGING_RAMP_TIME, float, autocvar_sv_dodging_ramp_time)
+/** cvar loopback */
+REGISTER_STAT(DODGING_TIMEOUT, float)
+REGISTER_STAT(DODGING_UP_SPEED, float, autocvar_sv_dodging_up_speed)
+REGISTER_STAT(DODGING_WALL, int, autocvar_sv_dodging_wall_dodging)
+
+REGISTER_STAT(JETPACK_ACCEL_SIDE, float, autocvar_g_jetpack_acceleration_side)
+REGISTER_STAT(JETPACK_ACCEL_UP, float, autocvar_g_jetpack_acceleration_up)
+REGISTER_STAT(JETPACK_ANTIGRAVITY, float, autocvar_g_jetpack_antigravity)
+REGISTER_STAT(JETPACK_FUEL, float, autocvar_g_jetpack_fuel)
+REGISTER_STAT(JETPACK_MAXSPEED_SIDE, float, autocvar_g_jetpack_maxspeed_side)
+REGISTER_STAT(JETPACK_MAXSPEED_UP, float, autocvar_g_jetpack_maxspeed_up)
-/* The following stats change depending on the gamemode, so can share the same ID */
+REGISTER_STAT(MOVEVARS_HIGHSPEED, float, autocvar_g_movement_highspeed)
-// freeze tag, clan arena, jailbreak
-enum {
- STAT_REDALIVE = STAT_LAST_MAIN,
- STAT_BLUEALIVE,
- STAT_YELLOWALIVE,
- STAT_PINKALIVE,
-};
+// freeze tag, clan arena
+REGISTER_STAT(REDALIVE, int)
+REGISTER_STAT(BLUEALIVE, int)
+REGISTER_STAT(YELLOWALIVE, int)
+REGISTER_STAT(PINKALIVE, int)
// domination
-enum {
- STAT_DOM_TOTAL_PPS = STAT_LAST_MAIN,
- STAT_DOM_PPS_RED,
- STAT_DOM_PPS_BLUE,
- STAT_DOM_PPS_YELLOW,
- STAT_DOM_PPS_PINK,
-};
+REGISTER_STAT(DOM_TOTAL_PPS, float)
+REGISTER_STAT(DOM_PPS_RED, float)
+REGISTER_STAT(DOM_PPS_BLUE, float)
+REGISTER_STAT(DOM_PPS_YELLOW, float)
+REGISTER_STAT(DOM_PPS_PINK, float)
-// vip
-enum {
- STAT_VIP = STAT_LAST_MAIN,
- STAT_VIP_RED,
- STAT_VIP_BLUE,
- STAT_VIP_YELLOW,
- STAT_VIP_PINK,
-};
+REGISTER_STAT(TELEPORT_MAXSPEED, float, autocvar_g_teleport_maxspeed)
+REGISTER_STAT(TELEPORT_TELEFRAG_AVOID, int, autocvar_g_telefrags_avoid)
-// key hunt
-enum {
- STAT_KH_REDKEY_TEAM = STAT_LAST_MAIN,
- STAT_KH_BLUEKEY_TEAM,
- STAT_KH_YELLOWKEY_TEAM,
- STAT_KH_PINKKEY_TEAM,
-};
+#ifdef SVQC
+#include "movetypes/movetypes.qh"
+#endif
+
+REGISTER_STAT(MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, float)
+REGISTER_STAT(MOVEVARS_AIRCONTROL_PENALTY, float)
+REGISTER_STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, float)
+REGISTER_STAT(MOVEVARS_AIRSTRAFEACCEL_QW, float)
+REGISTER_STAT(MOVEVARS_AIRCONTROL_POWER, float)
+noref bool autocvar_sv_gameplayfix_nogravityonground;
+REGISTER_STAT(MOVEFLAGS, int, MOVEFLAG_VALID
+ | (autocvar_sv_gameplayfix_q2airaccelerate ? MOVEFLAG_Q2AIRACCELERATE : 0)
+ | (autocvar_sv_gameplayfix_nogravityonground ? MOVEFLAG_NOGRAVITYONGROUND : 0)
+ | (autocvar_sv_gameplayfix_gravityunaffectedbyticrate ? MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE : 0))
-#define ASSERT_LESS(name, var, const) noref int name[(const - var + 1)];
-ASSERT_LESS(stat_limit, STAT_LAST, 220)
+REGISTER_STAT(MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, float)
+REGISTER_STAT(MOVEVARS_WARSOWBUNNY_ACCEL, float)
+REGISTER_STAT(MOVEVARS_WARSOWBUNNY_TOPSPEED, float)
+REGISTER_STAT(MOVEVARS_WARSOWBUNNY_TURNACCEL, float)
+REGISTER_STAT(MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, float)
-const int STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR = 220;
-const int STAT_MOVEVARS_AIRCONTROL_PENALTY = 221;
-const int STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW = 222;
-const int STAT_MOVEVARS_AIRSTRAFEACCEL_QW = 223;
-const int STAT_MOVEVARS_AIRCONTROL_POWER = 224;
-const int STAT_MOVEFLAGS = 225;
-const int STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL = 226;
-const int STAT_MOVEVARS_WARSOWBUNNY_ACCEL = 227;
-const int STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED = 228;
-const int STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL = 229;
-const int STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO = 230;
-const int STAT_MOVEVARS_AIRSTOPACCELERATE = 231;
-const int STAT_MOVEVARS_AIRSTRAFEACCELERATE = 232;
-const int STAT_MOVEVARS_MAXAIRSTRAFESPEED = 233;
-const int STAT_MOVEVARS_AIRCONTROL = 234;
-// -Wdouble-declaration
-// const int STAT_FRAGLIMIT = 235;
-// -Wdouble-declaration
-// const int STAT_TIMELIMIT = 236;
-const int STAT_MOVEVARS_WALLFRICTION = 237;
-const int STAT_MOVEVARS_FRICTION = 238;
-const int STAT_MOVEVARS_WATERFRICTION = 239;
-// -Wdouble-declaration
-// const int STAT_MOVEVARS_TICRATE = 240;
-// -Wdouble-declaration
-// const int STAT_MOVEVARS_TIMESCALE = 241;
-// -Wdouble-declaration
-// const int STAT_MOVEVARS_GRAVITY = 242;
-const int STAT_MOVEVARS_STOPSPEED = 243;
-const int STAT_MOVEVARS_MAXSPEED = 244;
-const int STAT_MOVEVARS_SPECTATORMAXSPEED = 245;
-const int STAT_MOVEVARS_ACCELERATE = 246;
-const int STAT_MOVEVARS_AIRACCELERATE = 247;
-const int STAT_MOVEVARS_WATERACCELERATE = 248;
-const int STAT_MOVEVARS_ENTGRAVITY = 249;
-const int STAT_MOVEVARS_JUMPVELOCITY = 250;
-const int STAT_MOVEVARS_EDGEFRICTION = 251;
-const int STAT_MOVEVARS_MAXAIRSPEED = 252;
-const int STAT_MOVEVARS_STEPHEIGHT = 253;
-const int STAT_MOVEVARS_AIRACCEL_QW = 254;
-const int STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION = 255;
+REGISTER_STAT(MOVEVARS_AIRSTOPACCELERATE, float)
+REGISTER_STAT(MOVEVARS_AIRSTRAFEACCELERATE, float)
+REGISTER_STAT(MOVEVARS_MAXAIRSTRAFESPEED, float)
+REGISTER_STAT(MOVEVARS_AIRCONTROL, float)
+REGISTER_STAT(FRAGLIMIT, float, autocvar_fraglimit)
+REGISTER_STAT(TIMELIMIT, float, autocvar_timelimit)
+#ifdef SVQC
+float autocvar_sv_wallfriction;
+#endif
+REGISTER_STAT(MOVEVARS_WALLFRICTION, int, autocvar_sv_wallfriction)
+REGISTER_STAT(MOVEVARS_TICRATE, float, autocvar_sys_ticrate)
+REGISTER_STAT(MOVEVARS_TIMESCALE, float, autocvar_slowmo)
+REGISTER_STAT(MOVEVARS_GRAVITY, float, autocvar_sv_gravity)
+REGISTER_STAT(MOVEVARS_STOPSPEED, float)
+REGISTER_STAT(MOVEVARS_MAXSPEED, float)
+REGISTER_STAT(MOVEVARS_ACCELERATE, float)
+REGISTER_STAT(MOVEVARS_AIRACCELERATE, float)
+.float gravity;
+// FIXME: Was 0 on server, 1 on client. Still want that?
+REGISTER_STAT(MOVEVARS_ENTGRAVITY, float, (this.gravity) ? this.gravity : 1)
+REGISTER_STAT(MOVEVARS_JUMPVELOCITY, float)
+REGISTER_STAT(MOVEVARS_MAXAIRSPEED, float)
+REGISTER_STAT(MOVEVARS_STEPHEIGHT, float, autocvar_sv_stepheight)
+REGISTER_STAT(MOVEVARS_AIRACCEL_QW, float)
+REGISTER_STAT(MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, float)
#endif
void door_draw(entity this)
{
- Movetype_Physics_NoMatchServer();
+ Movetype_Physics_NoMatchServer(this);
trigger_draw_generic(this);
}
if(IS_VEHICLE(other))
return;
#endif
-#ifdef CSQC
- if(other.classname != "csqcmodel")
- return;
-#endif
EXACTTRIGGER_TOUCH;
}
#ifdef SVQC
-bool func_ladder_send(entity this, entity to, float sf)
-{
+bool func_ladder_send(entity to, int sf)
+{SELFPARAM();
WriteHeader(MSG_ENTITY, ENT_CLIENT_LADDER);
+ int f = 0;
+ if(self.warpzone_isboxy)
+ BITSET_ASSIGN(f, 1);
+ if(self.origin != '0 0 0')
+ BITSET_ASSIGN(f, 4);
+ WriteByte(MSG_ENTITY, f);
+
+ // we need THESE to render the warpzone (and cull properly)...
+ if(f & 4)
+ {
+ WriteCoord(MSG_ENTITY, self.origin.x);
+ WriteCoord(MSG_ENTITY, self.origin.y);
+ WriteCoord(MSG_ENTITY, self.origin.z);
+ }
+
+ WriteShort(MSG_ENTITY, self.modelindex);
+ 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);
+ WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
+
WriteString(MSG_ENTITY, self.classname);
WriteByte(MSG_ENTITY, self.skin);
- WriteByte(MSG_ENTITY, self.speed);
- WriteString(MSG_ENTITY, self.mdl);
+ WriteCoord(MSG_ENTITY, self.speed);
trigger_common_write(false);
void func_ladder_link()
{
- //self.SendEntity = func_ladder_send;
- //self.SendFlags = 0xFFFFFF;
+ self.SendEntity = func_ladder_send;
+ self.SendFlags = 0xFFFFFF;
//self.model = "null";
}
-spawnfunc(func_ladder)
+void func_ladder_init()
{
- self.mdl = self.model;
- EXACTTRIGGER_INIT;
+ //self.mdl = self.model;
+ string m = self.model;
+ WarpZoneLib_ExactTrigger_Init();
+ if(m != "")
+ {
+ precache_model(m);
+ _setmodel(self, m); // no precision needed
+ }
+ setorigin(self, self.origin);
+ if(self.scale)
+ setsize(self, self.mins * self.scale, self.maxs * self.scale);
+ else
+ setsize(self, self.mins, self.maxs);
self.touch = func_ladder_touch;
+ BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
func_ladder_link();
}
-spawnfunc(func_water)
+spawnfunc(func_ladder)
{
- self.mdl = self.model;
- EXACTTRIGGER_INIT;
- self.touch = func_ladder_touch;
+ func_ladder_init();
+}
- func_ladder_link();
+spawnfunc(func_water)
+{
+ func_ladder_init();
}
#elif defined(CSQC)
.float speed;
+void func_ladder_remove()
+{
+ if(self.classname) { strunzone(self.classname); }
+ self.classname = string_null;
+}
+
NET_HANDLE(ENT_CLIENT_LADDER, bool isnew)
{
+ int f = ReadByte();
+ self.warpzone_isboxy = (f & 1);
+ if(f & 4)
+ {
+ self.origin_x = ReadCoord();
+ self.origin_y = ReadCoord();
+ self.origin_z = ReadCoord();
+ }
+ else
+ self.origin = '0 0 0';
+
+ self.modelindex = ReadShort();
+ self.mins_x = ReadCoord();
+ self.mins_y = ReadCoord();
+ self.mins_z = ReadCoord();
+ self.maxs_x = ReadCoord();
+ self.maxs_y = ReadCoord();
+ self.maxs_z = ReadCoord();
+ self.scale = ReadByte() / 16;
self.classname = strzone(ReadString());
self.skin = ReadByte();
- self.speed = ReadByte();
- self.model = strzone(ReadString());
+ self.speed = ReadCoord();
trigger_common_read(false);
- return = true;
-
- self.mins = self.maxs = '0 0 0';
-
self.solid = SOLID_TRIGGER;
- self.draw = trigger_draw_generic;
- self.trigger_touch = func_ladder_touch;
+ self.move_touch = func_ladder_touch;
self.drawmask = MASK_NORMAL;
self.move_time = time;
- self.entremove = trigger_remove_generic;
+ self.entremove = func_ladder_remove;
- //precache_model(self.mdl);
- EXACTTRIGGER_INIT;
+ return true;
}
#endif
#elif defined(CSQC)
void plat_draw(entity this)
{
- Movetype_Physics_NoMatchServer();
+ Movetype_Physics_NoMatchServer(this);
//Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
}
void train_draw(entity this)
{
//Movetype_Physics_NoMatchServer();
- Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+ Movetype_Physics_MatchServer(this, autocvar_cl_projectiles_sloppy);
}
NET_HANDLE(ENT_CLIENT_TRAIN, bool isnew)
+REGISTER_NET_LINKED(ENT_CLIENT_TELEPORT_DEST)
+
#ifdef SVQC
+bool teleport_dest_send(entity this, entity to, int sf)
+{
+ WriteHeader(MSG_ENTITY, ENT_CLIENT_TELEPORT_DEST);
+ WriteByte(MSG_ENTITY, sf);
+
+ if(sf & 1)
+ {
+ WriteByte(MSG_ENTITY, this.cnt);
+ WriteCoord(MSG_ENTITY, this.speed);
+ WriteString(MSG_ENTITY, this.targetname);
+ WriteCoord(MSG_ENTITY, this.origin_x);
+ WriteCoord(MSG_ENTITY, this.origin_y);
+ WriteCoord(MSG_ENTITY, this.origin_z);
+
+ WriteAngle(MSG_ENTITY, this.mangle_x);
+ WriteAngle(MSG_ENTITY, this.mangle_y);
+ WriteAngle(MSG_ENTITY, this.mangle_z);
+ }
+
+ return true;
+}
+
+void teleport_dest_link()
+{SELFPARAM();
+ Net_LinkEntity(self, false, 0, teleport_dest_send);
+ //self.SendFlags |= 1; // update
+}
+
spawnfunc(info_teleport_destination)
{
self.classname = "info_teleport_destination";
}
else
objerror ("^3Teleport destination without a targetname");
+
+ teleport_dest_link();
}
spawnfunc(misc_teleporter_dest)
spawnfunc_info_teleport_destination(this);
}
+#elif defined(CSQC)
+
+void teleport_dest_remove()
+{SELFPARAM();
+ //if(self.classname)
+ //strunzone(self.classname);
+ //self.classname = string_null;
+
+ if(self.targetname)
+ strunzone(self.targetname);
+ self.targetname = string_null;
+}
+
+NET_HANDLE(ENT_CLIENT_TELEPORT_DEST, bool isnew)
+{
+ int sf = ReadByte();
+
+ if(sf & 1)
+ {
+ self.classname = "info_teleport_destination";
+ self.cnt = ReadByte();
+ self.speed = ReadCoord();
+ self.targetname = strzone(ReadString());
+ self.origin_x = ReadCoord();
+ self.origin_y = ReadCoord();
+ self.origin_z = ReadCoord();
+
+ self.mangle_x = ReadAngle();
+ self.mangle_y = ReadAngle();
+ self.mangle_z = ReadAngle();
+
+ setorigin(self, self.origin);
+
+ self.drawmask = MASK_NORMAL;
+ self.entremove = teleport_dest_remove;
+ }
+
+ return = true;
+}
+
#endif
#elif defined(CSQC)
- void _Movetype_LinkEdict(float touch_triggers);
+ void _Movetype_LinkEdict(entity this, float touch_triggers);
#define SUB_ANGLES(s) (s).move_angles
#define SUB_VELOCITY move_velocity
void SUB_SETORIGIN(entity s, vector v)
{SELFPARAM();
s.move_origin = v;
- WITH(entity, self, s, _Movetype_LinkEdict(true));
+ _Movetype_LinkEdict(s, true);
}
#endif
.vector destvec;
.vector destvec2;
-// player animation state
-.float animstate_startframe;
-.float animstate_numframes;
-.float animstate_framerate;
-.float animstate_starttime;
-.float animstate_endtime;
-.float animstate_override;
-.float animstate_looping;
-
.float delay;
.float wait;
.float lip;
#include "../../server/anticheat.qh"
#endif
-#ifdef SVQC
-
float check_tdeath(entity player, vector org, vector telefragmin, vector telefragmax)
{
- if (IS_PLAYER(player) && player.health >= 1)
+ if (IS_PLAYER(player) && !PHYS_DEAD(player))
{
TDEATHLOOP(org)
{
+ #ifdef SVQC
if (!(teamplay && autocvar_g_telefrags_teamplay && head.team == player.team))
+ #endif
if(IS_PLAYER(head))
- if(head.health >= 1)
+ if(!PHYS_DEAD(head))
return 1;
}
}
return 0;
}
+#ifdef SVQC
+
+void trigger_teleport_link(entity this);
+
void tdeath(entity player, entity teleporter, entity telefragger, vector telefragmin, vector telefragmax)
{
TDEATHLOOP(player.origin)
tdeath(e, e, e, '0 0 0', '0 0 0');
}
+#endif
+
void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
{SELFPARAM();
entity telefragger;
makevectors (to_angles);
+#ifdef SVQC
if(player.teleportable == TELEPORT_NORMAL) // don't play sounds or show particles for anything that isn't a player, maybe change later to block only observers
{
if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
self.pushltime = time + 0.2;
}
}
+#endif
// Relocate the player
// assuming to allows PL_MIN to PL_MAX box and some more
+#ifdef SVQC
from = player.origin;
setorigin (player, to);
player.oldorigin = to; // don't undo the teleport by unsticking
makevectors(player.angles);
Reset_ArcBeam(player, v_forward);
UpdateCSQCProjectileAfterTeleport(player);
+#elif defined(CSQC)
+ from = player.move_origin;
+ player.move_origin = to;
+ player.move_angles = to_angles;
+ player.move_velocity = to_velocity;
+ player.move_flags &= ~FL_ONGROUND;
+ player.iflags |= IFLAG_TELEPORTED | IFLAG_V_ANGLE | IFLAG_ANGLES;
+ player.csqcmodel_teleported = 1;
+ player.v_angle = to_angles;
+ setproperty(VF_ANGLES, player.move_angles);
+ setproperty(VF_CL_VIEWANGLES, player.move_angles);
+
+ makevectors(player.move_angles);
+#endif
+#ifdef SVQC
if(IS_PLAYER(player))
{
if(tflags & TELEPORT_FLAG_TDEATH)
player.lastteleporttime = time;
}
+#endif
}
entity Simple_TeleportPlayer(entity teleporter, entity player)
for(e = world; (e = find(e, targetname, teleporter.target)); )
{
p = 1;
- if(autocvar_g_telefrags_avoid)
+ if(STAT(TELEPORT_TELEFRAG_AVOID, player))
{
+ #ifdef SVQC
locout = e.origin + '0 0 1' * (1 - player.mins.z - 24);
+ #elif defined(CSQC)
+ locout = e.origin + '0 0 1' * (1 - player.mins.z - 24);
+ #endif
if(check_tdeath(player, locout, '0 0 0', '0 0 0'))
p = 0;
}
e = RandomSelection_chosen_ent;
}
+#ifdef SVQC
if(!e) { sprint(player, "Teleport destination vanished. Sorry... please complain to the mapper.\n"); }
+#elif defined(CSQC)
+ if(!e) { LOG_INFO("Teleport destination could not be found from CSQC.\n"); }
+#endif
makevectors(e.mangle);
+#ifdef SVQC
if(e.speed)
if(vlen(player.velocity) > e.speed)
player.velocity = normalize(player.velocity) * max(0, e.speed);
+#elif defined(CSQC)
+ if(e.speed)
+ if(vlen(player.move_velocity) > e.speed)
+ player.move_velocity = normalize(player.move_velocity) * max(0, e.speed);
+#endif
- if(autocvar_g_teleport_maxspeed)
- if(vlen(player.velocity) > autocvar_g_teleport_maxspeed)
- player.velocity = normalize(player.velocity) * max(0, autocvar_g_teleport_maxspeed);
+#ifdef SVQC
+ if(STAT(TELEPORT_MAXSPEED, player))
+ if(vlen(player.velocity) > STAT(TELEPORT_MAXSPEED, player))
+ player.velocity = normalize(player.velocity) * max(0, STAT(TELEPORT_MAXSPEED, player));
+#elif defined(CSQC)
+ if(STAT(TELEPORT_MAXSPEED, player))
+ if(vlen(player.move_velocity) > STAT(TELEPORT_MAXSPEED, player))
+ player.move_velocity = normalize(player.move_velocity) * max(0, STAT(TELEPORT_MAXSPEED, player));
+#endif
+#ifdef SVQC
locout = e.origin + '0 0 1' * (1 - player.mins.z - 24);
+
TeleportPlayer(teleporter, player, locout, e.mangle, v_forward * vlen(player.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+#elif defined(CSQC)
+ locout = e.origin + '0 0 1' * (1 - player.mins.z - 24);
+
+ TeleportPlayer(teleporter, player, locout, e.mangle, v_forward * vlen(player.move_velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+#endif
return e;
}
-void teleport_findtarget ()
-{SELFPARAM();
+void teleport_findtarget()
+{
+ int n = 0;
entity e;
- float n;
-
- n = 0;
for(e = world; (e = find(e, targetname, self.target)); )
{
++n;
+#ifdef SVQC
if(e.movetype == MOVETYPE_NONE)
waypoint_spawnforteleporter(self, e.origin, 0);
if(e.classname != "info_teleport_destination")
LOG_INFO("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.\n");
+#endif
}
if(n == 0)
}
// now enable touch
+#ifdef SVQC
self.touch = Teleport_Touch;
+
+ trigger_teleport_link(self);
+#elif defined(CSQC)
+ self.move_touch = Teleport_Touch;
+#endif
}
entity Teleport_Find(vector mi, vector ma)
return world;
}
+#ifdef SVQC
void WarpZone_PostTeleportPlayer_Callback(entity pl)
{SELFPARAM();
makevectors(pl.angles);
#ifndef T_TELEPORTERS_H
#define T_TELEPORTERS_H
+.entity pusher;
+const float TELEPORT_FLAG_SOUND = 1;
+const float TELEPORT_FLAG_PARTICLES = 2;
+const float TELEPORT_FLAG_TDEATH = 4;
+const float TELEPORT_FLAG_FORCE_TDEATH = 8;
+
+#define TELEPORT_FLAGS_WARPZONE 0
+#define TELEPORT_FLAGS_PORTAL (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH | TELEPORT_FLAG_FORCE_TDEATH)
+#define TELEPORT_FLAGS_TELEPORTER (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH)
+
+// types for .teleportable entity setting
+const float TELEPORT_NORMAL = 1; // play sounds/effects etc
+const float TELEPORT_SIMPLE = 2; // only do teleport, nothing special
+
+entity Simple_TeleportPlayer(entity teleporter, entity player);
+
+void Teleport_Touch ();
+
+void teleport_findtarget();
+
+entity Teleport_Find(vector mi, vector ma);
+
+void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags);
+
+entity teleport_first;
+.entity teleport_next;
+
#ifdef SVQC
void trigger_teleport_use();
if(head.takedamage) \
if(boxesoverlap(deathmin, deathmax, head.absmin, head.absmax))
-
float check_tdeath(entity player, vector org, vector telefragmin, vector telefragmax);
float tdeath_hit;
void tdeath(entity player, entity teleporter, entity telefragger, vector telefragmin, vector telefragmax);
void spawn_tdeath(vector v0, entity e, vector v);
-.entity pusher;
-const float TELEPORT_FLAG_SOUND = 1;
-const float TELEPORT_FLAG_PARTICLES = 2;
-const float TELEPORT_FLAG_TDEATH = 4;
-const float TELEPORT_FLAG_FORCE_TDEATH = 8;
-
-#define TELEPORT_FLAGS_WARPZONE 0
-#define TELEPORT_FLAGS_PORTAL (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH | TELEPORT_FLAG_FORCE_TDEATH)
-#define TELEPORT_FLAGS_TELEPORTER (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH)
-
-// types for .teleportable entity setting
-const float TELEPORT_NORMAL = 1; // play sounds/effects etc
-const float TELEPORT_SIMPLE = 2; // only do teleport, nothing special
-
void Reset_ArcBeam(entity player, vector forward);
-void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags);
-
-entity Simple_TeleportPlayer(entity teleporter, entity player);
-
-void Teleport_Touch ();
-
-void teleport_findtarget ();
-
-entity Teleport_Find(vector mi, vector ma);
-
-entity teleport_first;
-.entity teleport_next;
void WarpZone_PostTeleportPlayer_Callback(entity pl);
#endif
+#ifdef CSQC
+#define TDEATHLOOP(o) \
+ entity head; \
+ vector deathmin; \
+ vector deathmax; \
+ float deathradius; \
+ deathmin = (o) + player.mins; \
+ deathmax = (o) + player.maxs; \
+ if(telefragmin != telefragmax) \
+ { \
+ if(deathmin.x > telefragmin.x) deathmin.x = telefragmin.x; \
+ if(deathmin.y > telefragmin.y) deathmin.y = telefragmin.y; \
+ if(deathmin.z > telefragmin.z) deathmin.z = telefragmin.z; \
+ if(deathmax.x < telefragmax.x) deathmax.x = telefragmax.x; \
+ if(deathmax.y < telefragmax.y) deathmax.y = telefragmax.y; \
+ if(deathmax.z < telefragmax.z) deathmax.z = telefragmax.z; \
+ } \
+ deathradius = max(vlen(deathmin), vlen(deathmax)); \
+ for(head = findradius(o, deathradius); head; head = head.chain) \
+ if(head != player) \
+ if(head.isplayermodel) \
+ if(boxesoverlap(deathmin, deathmax, head.absmin, head.absmax))
+#endif
+
#endif
return;
}
+#ifdef SVQC
str = min(self.radius, vlen(self.origin - other.origin));
+#elif defined(CSQC)
+ str = min(self.radius, vlen(self.origin - other.move_origin));
+#endif
if(self.falloff == 1)
str = (str / self.radius) * self.strength;
if(self.spawnflags & 64)
{
+#ifdef SVQC
float addspeed = str - other.velocity * normalize(targ.origin - self.origin);
if (addspeed > 0)
{
float accelspeed = min(8 * pushdeltatime * str, addspeed);
other.velocity += accelspeed * normalize(targ.origin - self.origin);
}
+#elif defined(CSQC)
+ float addspeed = str - other.move_velocity * normalize(targ.origin - self.origin);
+ if (addspeed > 0)
+ {
+ float accelspeed = min(8 * pushdeltatime * str, addspeed);
+ other.move_velocity += accelspeed * normalize(targ.origin - self.origin);
+ }
+#endif
}
else
+#ifdef SVQC
other.velocity = other.velocity + normalize(targ.origin - self.origin) * str * pushdeltatime;
- other.flags &= ~FL_ONGROUND;
+#elif defined(CSQC)
+ other.move_velocity = other.move_velocity + normalize(targ.origin - self.origin) * str * pushdeltatime;
+#endif
+
#ifdef SVQC
+ UNSET_ONGROUND(other);
+
UpdateCSQCProjectile(other);
+#elif defined(CSQC)
+ other.move_flags &= ~FL_ONGROUND;
#endif
}
if(!pushdeltatime) return;
// div0: ticrate independent, 1 = identity (not 20)
- other.velocity = other.velocity * pow(self.strength, pushdeltatime);
#ifdef SVQC
+ other.velocity = other.velocity * pow(self.strength, pushdeltatime);
+
UpdateCSQCProjectile(other);
+#elif defined(CSQC)
+ other.move_velocity = other.move_velocity * pow(self.strength, pushdeltatime);
#endif
}
setsize(self, '-1 -1 -1' * self.radius,'1 1 1' * self.radius);
+#ifdef SVQC
str = min(self.radius, vlen(self.origin - other.origin));
+#elif defined(CSQC)
+ str = min(self.radius, vlen(self.origin - other.move_origin));
+#endif
if(self.falloff == 1)
str = (1 - str / self.radius) * self.strength; // 1 in the inside
else
str = self.strength;
- other.velocity = other.velocity + normalize(other.origin - self.origin) * str * pushdeltatime;
#ifdef SVQC
+ other.velocity = other.velocity + normalize(other.origin - self.origin) * str * pushdeltatime;
+
UpdateCSQCProjectile(other);
+#elif defined(CSQC)
+ other.move_velocity = other.move_velocity + normalize(other.move_origin - self.origin) * str * pushdeltatime;
#endif
}
in directional and sperical mode. For damper/accelerator mode this is not nessesary (and has no effect).
*/
#ifdef SVQC
-bool trigger_impulse_send(entity to, int sf)
-{SELFPARAM();
+bool trigger_impulse_send(entity this, entity to, int sf)
+{
WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_IMPULSE);
+ WriteInt24_t(MSG_ENTITY, self.spawnflags);
WriteCoord(MSG_ENTITY, self.radius);
WriteCoord(MSG_ENTITY, self.strength);
WriteByte(MSG_ENTITY, self.falloff);
void trigger_impulse_link()
{
- //Net_LinkEntity(self, 0, false, trigger_impulse_send);
+ Net_LinkEntity(self, 0, false, trigger_impulse_send);
}
spawnfunc(trigger_impulse)
#elif defined(CSQC)
NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew)
{
+ self.spawnflags = ReadInt24_t();
self.radius = ReadCoord();
self.strength = ReadCoord();
self.falloff = ReadByte();
self.classname = "trigger_impulse";
self.solid = SOLID_TRIGGER;
self.entremove = trigger_remove_generic;
- self.draw = trigger_draw_generic;
+ //self.draw = trigger_draw_generic;
self.drawmask = MASK_NORMAL;
self.move_time = time;
- if(self.radius) { self.trigger_touch = trigger_impulse_touch3; }
- else if(self.target) { self.trigger_touch = trigger_impulse_touch1; }
- else { self.trigger_touch = trigger_impulse_touch2; }
+ if(self.radius) { self.move_touch = trigger_impulse_touch3; }
+ else if(self.target) { self.move_touch = trigger_impulse_touch1; }
+ else { self.move_touch = trigger_impulse_touch2; }
}
#endif
torg = tgt.origin + (tgt.mins + tgt.maxs) * 0.5;
- grav = PHYS_GRAVITY;
+ grav = PHYS_GRAVITY(other);
if(PHYS_ENTGRAVITY(other))
grav *= PHYS_ENTGRAVITY(other);
other.move_velocity = other.velocity;
}
+#ifdef SVQC
UNSET_ONGROUND(other);
-
+#elif defined(CSQC)
other.move_flags &= ~FL_ONGROUND;
+#endif
#ifdef SVQC
if (IS_PLAYER(other))
}
#ifdef SVQC
-float trigger_push_send(entity to, float sf)
-{SELFPARAM();
+float trigger_push_send(entity this, entity to, float sf)
+{
WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_PUSH);
WriteByte(MSG_ENTITY, sf);
WriteByte(MSG_ENTITY, self.team);
WriteInt24_t(MSG_ENTITY, self.spawnflags);
WriteByte(MSG_ENTITY, self.active);
- WriteByte(MSG_ENTITY, self.height);
+ WriteCoord(MSG_ENTITY, self.height);
trigger_common_write(true);
}
void trigger_push_link()
{
- //Net_LinkEntity(self, false, 0, trigger_push_send);
+ BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
+ Net_LinkEntity(self, false, 0, trigger_push_send);
}
-#endif
-#ifdef SVQC
+
/*
* ENTITY PARAMETERS:
*
WriteCoord(MSG_ENTITY, self.origin_y);
WriteCoord(MSG_ENTITY, self.origin_z);
+ WriteAngle(MSG_ENTITY, self.angles_x);
+ WriteAngle(MSG_ENTITY, self.angles_y);
+ WriteAngle(MSG_ENTITY, self.angles_z);
+
return true;
}
void target_push_link()
{SELFPARAM();
- //Net_LinkEntity(self, false, 0, target_push_send);
+ BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
+ Net_LinkEntity(self, false, 0, target_push_send);
//self.SendFlags |= 1; // update
}
spawnfunc(info_notnull) { target_push_link(); }
spawnfunc(target_position) { make_pure(this); target_push_link(); }
-#endif
-
-#ifdef CSQC
+#elif defined(CSQC)
NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew)
{
+ make_pure(this);
float sf = ReadByte();
if(sf & 1)
int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
self.spawnflags = ReadInt24_t();
self.active = ReadByte();
- self.height = ReadByte();
+ self.height = ReadCoord();
trigger_common_read(true);
self.entremove = trigger_remove_generic;
self.solid = SOLID_TRIGGER;
- self.draw = trigger_draw_generic;
- self.trigger_touch = trigger_push_touch;
+ //self.draw = trigger_draw_generic;
+ self.move_touch = trigger_push_touch;
self.drawmask = MASK_NORMAL;
self.move_time = time;
- trigger_push_findtarget();
+ defer(self, 0.25, trigger_push_findtarget);
}
if(sf & 2)
NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew)
{
+ make_pure(this);
self.classname = "push_target";
self.cnt = ReadByte();
self.targetname = strzone(ReadString());
self.origin_y = ReadCoord();
self.origin_z = ReadCoord();
+ self.angles_x = ReadAngle();
+ self.angles_y = ReadAngle();
+ self.angles_z = ReadAngle();
+
return = true;
setorigin(self, self.origin);
float secrets_found;
-.float stat_secrets_total;
-.float stat_secrets_found;
+.float stat_secrets_total = _STAT(SECRETS_TOTAL);
+.float stat_secrets_found = _STAT(SECRETS_FOUND);
/**
* update secrets status.
REGISTER_NET_LINKED(ENT_CLIENT_SWAMP)
#ifdef SVQC
-float swamp_send(entity to, float sf)
-{SELFPARAM();
+float swamp_send(entity this, entity to, float sf)
+{
WriteHeader(MSG_ENTITY, ENT_CLIENT_SWAMP);
WriteByte(MSG_ENTITY, self.dmg); // can probably get away with using a single byte here
void swamp_link()
{SELFPARAM();
- Net_LinkEntity(self, false, 0, func_ladder_send);
+ Net_LinkEntity(self, false, 0, swamp_send);
}
/*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
self.classname = "trigger_swamp";
self.solid = SOLID_TRIGGER;
- self.draw = trigger_draw_generic;
- self.trigger_touch = swamp_touch;
+ self.move_touch = swamp_touch;
self.drawmask = MASK_NORMAL;
self.move_time = time;
self.entremove = trigger_remove_generic;
+REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT)
+
#ifdef SVQC
void trigger_teleport_use()
{SELFPARAM();
self.SendFlags |= SF_TRIGGER_UPDATE;
#endif
}
+#endif
void Teleport_Touch ()
{SELFPARAM();
- string s;
-
if (self.active != ACTIVE_ACTIVE)
return;
+#ifdef SVQC
if (!other.teleportable)
return;
if(IS_TURRET(other))
return;
+#endif
- if(other.deadflag != DEAD_NO)
+ if(PHYS_DEAD(other))
return;
if(self.team)
- if(((self.spawnflags & 4) == 0) == (self.team != other.team))
+ if(((self.spawnflags & 4) == 0) == (DIFF_TEAM(this, other)))
return;
EXACTTRIGGER_TOUCH;
+#ifdef SVQC
if(IS_PLAYER(other))
RemoveGrapplingHook(other);
+#endif
- entity e = Simple_TeleportPlayer(self, other);
+ entity e;
+ e = Simple_TeleportPlayer(self, other);
+#ifdef SVQC
activator = other;
- s = self.target; self.target = string_null;
+ string s = self.target; self.target = string_null;
SUB_UseTargets();
if (!self.target) self.target = s;
WITH(entity, self, e, SUB_UseTargets());
+#endif
+}
+
+#ifdef SVQC
+float trigger_teleport_send(entity this, entity to, float sf)
+{
+ WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
+ WriteByte(MSG_ENTITY, sf);
+
+ if(sf & 1)
+ {
+ WriteByte(MSG_ENTITY, this.team);
+ WriteInt24_t(MSG_ENTITY, this.spawnflags);
+ WriteByte(MSG_ENTITY, this.active);
+ WriteCoord(MSG_ENTITY, this.speed);
+
+ trigger_common_write(true);
+ }
+
+ if(sf & 2)
+ {
+ WriteByte(MSG_ENTITY, this.team);
+ WriteByte(MSG_ENTITY, this.active);
+ }
+
+ return true;
+}
+
+void trigger_teleport_link(entity this)
+{
+ Net_LinkEntity(this, false, 0, trigger_teleport_send);
}
spawnfunc(trigger_teleport)
self.teleport_next = teleport_first;
teleport_first = self;
}
+#elif defined(CSQC)
+NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
+{
+ int sf = ReadByte();
+
+ if(sf & 1)
+ {
+ self.classname = "trigger_teleport";
+ int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
+ self.spawnflags = ReadInt24_t();
+ self.active = ReadByte();
+ self.speed = ReadCoord();
+
+ trigger_common_read(true);
+
+ self.entremove = trigger_remove_generic;
+ self.solid = SOLID_TRIGGER;
+ //self.draw = trigger_draw_generic;
+ //self.move_touch = trigger_push_touch;
+ self.drawmask = MASK_NORMAL;
+ self.move_time = time;
+ defer(self, 0.25, teleport_findtarget);
+
+ self.teleport_next = teleport_first;
+ teleport_first = self;
+ }
+
+ if(sf & 2)
+ {
+ self.team = ReadByte();
+ self.active = ReadByte();
+ }
+ return true;
+}
+
#endif
if(withtarget)
{
+ if(self.target) { strunzone(self.target); }
self.target = strzone(ReadString());
+ if(self.target2) { strunzone(self.target2); }
self.target2 = strzone(ReadString());
+ if(self.target3) { strunzone(self.target3); }
self.target3 = strzone(ReadString());
+ if(self.target4) { strunzone(self.target4); }
self.target4 = strzone(ReadString());
+ if(self.targetname) { strunzone(self.targetname); }
self.targetname = strzone(ReadString());
+ if(self.killtarget) { strunzone(self.killtarget); }
self.killtarget = strzone(ReadString());
}
return;
float dist = vlen(self.origin - view_origin);
- float t = (GetPlayerColor(player_localnum) + 1);
+ float t = (entcs_GetTeam(player_localnum) + 1);
vector o;
string txt;
void turret_gibboom();
void turret_gib_draw(entity this)
{
- Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+ Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
self.drawmask = MASK_NORMAL;
/* mins */ ATTRIB(EWheel, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(EWheel, maxs, vector, '32 32 48');
/* modelname */ ATTRIB(EWheel, mdl, string, "ewheel-base2.md3");
-/* model */ ATTRIB(EWheel, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(EWheel, head_model, string, strzone(strcat("models/turrets/", "ewheel-gun1.md3")));
+/* model */ ATTRIB_STRZONE(EWheel, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(EWheel, head_model, string, strcat("models/turrets/", "ewheel-gun1.md3"));
/* netname */ ATTRIB(EWheel, netname, string, "ewheel");
/* fullname */ ATTRIB(EWheel, turret_name, string, _("eWheel Turret"));
ATTRIB(EWheel, m_weapon, Weapon, WEP_EWHEEL);
/* mins */ ATTRIB(Flac, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(Flac, maxs, vector, '32 32 64');
/* modelname */ ATTRIB(Flac, mdl, string, "base.md3");
-/* model */ ATTRIB(Flac, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(Flac, head_model, string, strzone(strcat("models/turrets/", "flac.md3")));
+/* model */ ATTRIB_STRZONE(Flac, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(Flac, head_model, string, strcat("models/turrets/", "flac.md3"));
/* netname */ ATTRIB(Flac, netname, string, "flac");
/* fullname */ ATTRIB(Flac, turret_name, string, _("FLAC Cannon"));
ATTRIB(Flac, m_weapon, Weapon, WEP_FLAC);
/* mins */ ATTRIB(FusionReactor, mins, vector, '-34 -34 0');
/* maxs */ ATTRIB(FusionReactor, maxs, vector, '34 34 90');
/* modelname */ ATTRIB(FusionReactor, mdl, string, "base.md3");
-/* model */ ATTRIB(FusionReactor, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(FusionReactor, head_model, string, strzone(strcat("models/turrets/", "reactor.md3")));
+/* model */ ATTRIB_STRZONE(FusionReactor, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(FusionReactor, head_model, string, strcat("models/turrets/", "reactor.md3"));
/* netname */ ATTRIB(FusionReactor, netname, string, "fusionreactor");
/* fullname */ ATTRIB(FusionReactor, turret_name, string, _("Fusion Reactor"));
ENDCLASS(FusionReactor)
/* mins */ ATTRIB(Hellion, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(Hellion, maxs, vector, '32 32 64');
/* modelname */ ATTRIB(Hellion, mdl, string, "base.md3");
-/* model */ ATTRIB(Hellion, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(Hellion, head_model, string, strzone(strcat("models/turrets/", "hellion.md3")));
+/* model */ ATTRIB_STRZONE(Hellion, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(Hellion, head_model, string, strcat("models/turrets/", "hellion.md3"));
/* netname */ ATTRIB(Hellion, netname, string, "hellion");
/* fullname */ ATTRIB(Hellion, turret_name, string, _("Hellion Missile Turret"));
ATTRIB(Hellion, m_weapon, Weapon, WEP_HELLION);
/* mins */ ATTRIB(HunterKiller, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(HunterKiller, maxs, vector, '32 32 64');
/* modelname */ ATTRIB(HunterKiller, mdl, string, "base.md3");
-/* model */ ATTRIB(HunterKiller, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(HunterKiller, head_model, string, strzone(strcat("models/turrets/", "hk.md3")));
+/* model */ ATTRIB_STRZONE(HunterKiller, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(HunterKiller, head_model, string, strcat("models/turrets/", "hk.md3"));
/* netname */ ATTRIB(HunterKiller, netname, string, "hk");
/* fullname */ ATTRIB(HunterKiller, turret_name, string, _("Hunter-Killer Turret"));
ATTRIB(HunterKiller, m_weapon, Weapon, WEP_HK);
/* mins */ ATTRIB(MachineGunTurret, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(MachineGunTurret, maxs, vector, '32 32 64');
/* modelname */ ATTRIB(MachineGunTurret, mdl, string, "base.md3");
-/* model */ ATTRIB(MachineGunTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(MachineGunTurret, head_model, string, strzone(strcat("models/turrets/", "machinegun.md3")));
+/* model */ ATTRIB_STRZONE(MachineGunTurret, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(MachineGunTurret, head_model, string, strcat("models/turrets/", "machinegun.md3"));
/* netname */ ATTRIB(MachineGunTurret, netname, string, "machinegun");
/* fullname */ ATTRIB(MachineGunTurret, turret_name, string, _("Machinegun Turret"));
ATTRIB(MachineGunTurret, m_weapon, Weapon, WEP_TUR_MACHINEGUN);
/* mins */ ATTRIB(MLRSTurret, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(MLRSTurret, maxs, vector, '32 32 64');
/* modelname */ ATTRIB(MLRSTurret, mdl, string, "base.md3");
-/* model */ ATTRIB(MLRSTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(MLRSTurret, head_model, string, strzone(strcat("models/turrets/", "mlrs.md3")));
+/* model */ ATTRIB_STRZONE(MLRSTurret, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(MLRSTurret, head_model, string, strcat("models/turrets/", "mlrs.md3"));
/* netname */ ATTRIB(MLRSTurret, netname, string, "mlrs");
/* fullname */ ATTRIB(MLRSTurret, turret_name, string, _("MLRS Turret"));
ATTRIB(MLRSTurret, m_weapon, Weapon, WEP_TUR_MLRS);
/* mins */ ATTRIB(PhaserTurret, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(PhaserTurret, maxs, vector, '32 32 64');
/* modelname */ ATTRIB(PhaserTurret, mdl, string, "base.md3");
-/* model */ ATTRIB(PhaserTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(PhaserTurret, head_model, string, strzone(strcat("models/turrets/", "phaser.md3")));
+/* model */ ATTRIB_STRZONE(PhaserTurret, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(PhaserTurret, head_model, string, strcat("models/turrets/", "phaser.md3"));
/* netname */ ATTRIB(PhaserTurret, netname, string, "phaser");
/* fullname */ ATTRIB(PhaserTurret, turret_name, string, _("Phaser Cannon"));
ATTRIB(PhaserTurret, m_weapon, Weapon, WEP_PHASER);
/* mins */ ATTRIB(PlasmaTurret, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(PlasmaTurret, maxs, vector, '32 32 64');
/* modelname */ ATTRIB(PlasmaTurret, mdl, string, "base.md3");
-/* model */ ATTRIB(PlasmaTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(PlasmaTurret, head_model, string, strzone(strcat("models/turrets/", "plasma.md3")));
+/* model */ ATTRIB_STRZONE(PlasmaTurret, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(PlasmaTurret, head_model, string, strcat("models/turrets/", "plasma.md3"));
/* netname */ ATTRIB(PlasmaTurret, netname, string, "plasma");
/* fullname */ ATTRIB(PlasmaTurret, turret_name, string, _("Plasma Cannon"));
ATTRIB(PlasmaTurret, m_weapon, Weapon, WEP_PLASMA);
/* mins */ ATTRIB(DualPlasmaTurret, mins, vector, '-32 -32 0');
/* maxs */ ATTRIB(DualPlasmaTurret, maxs, vector, '32 32 64');
/* modelname */ ATTRIB(DualPlasmaTurret, mdl, string, "base.md3");
-/* model */ ATTRIB(DualPlasmaTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(DualPlasmaTurret, head_model, string, strzone(strcat("models/turrets/", "plasmad.md3")));
+/* model */ ATTRIB_STRZONE(DualPlasmaTurret, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(DualPlasmaTurret, head_model, string, strcat("models/turrets/", "plasmad.md3"));
/* netname */ ATTRIB(DualPlasmaTurret, netname, string, "plasma_dual");
/* fullname */ ATTRIB(DualPlasmaTurret, turret_name, string, _("Dual Plasma Cannon"));
ATTRIB(DualPlasmaTurret, m_weapon, Weapon, WEP_PLASMA_DUAL);
/* mins */ ATTRIB(TeslaCoil, mins, vector, '-60 -60 0');
/* maxs */ ATTRIB(TeslaCoil, maxs, vector, '60 60 128');
/* modelname */ ATTRIB(TeslaCoil, mdl, string, "tesla_base.md3");
-/* model */ ATTRIB(TeslaCoil, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(TeslaCoil, head_model, string, strzone(strcat("models/turrets/", "tesla_head.md3")));
+/* model */ ATTRIB_STRZONE(TeslaCoil, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(TeslaCoil, head_model, string, strcat("models/turrets/", "tesla_head.md3"));
/* netname */ ATTRIB(TeslaCoil, netname, string, "tesla");
/* fullname */ ATTRIB(TeslaCoil, turret_name, string, _("Tesla Coil"));
ATTRIB(TeslaCoil, m_weapon, Weapon, WEP_TESLA);
/* mins */ ATTRIB(WalkerTurret, mins, vector, '-70 -70 0');
/* maxs */ ATTRIB(WalkerTurret, maxs, vector, '70 70 95');
/* modelname */ ATTRIB(WalkerTurret, mdl, string, "walker_body.md3");
-/* model */ ATTRIB(WalkerTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
-/* head_model */ ATTRIB(WalkerTurret, head_model, string, strzone(strcat("models/turrets/", "walker_head_minigun.md3")));
+/* model */ ATTRIB_STRZONE(WalkerTurret, model, string, strcat("models/turrets/", this.mdl));
+/* head_model */ ATTRIB_STRZONE(WalkerTurret, head_model, string, strcat("models/turrets/", "walker_head_minigun.md3"));
/* netname */ ATTRIB(WalkerTurret, netname, string, "walker");
/* fullname */ ATTRIB(WalkerTurret, turret_name, string, _("Walker Turret"));
ATTRIB(WalkerTurret, m_weapon, Weapon, WEP_WALKER);
if(cvar_type(e.netname))
{
cvar_set(e.netname, e.message);
+ strunzone(e.netname);
+ strunzone(e.message);
remove(e);
++i;
}
#include "all.qh"
-#ifndef MENUQC
-STATIC_INIT(vehicles_common_initialize)
-{
-#ifdef SVQC
- addstat(STAT_HUD, AS_INT, hud);
- addstat(STAT_VEHICLESTAT_HEALTH, AS_INT, vehicle_health);
- addstat(STAT_VEHICLESTAT_SHIELD, AS_INT, vehicle_shield);
- addstat(STAT_VEHICLESTAT_ENERGY, AS_INT, vehicle_energy);
-
- addstat(STAT_VEHICLESTAT_W2MODE, AS_INT, vehicle_weapon2mode);
-
- addstat(STAT_VEHICLESTAT_AMMO1, AS_INT, vehicle_ammo1);
- addstat(STAT_VEHICLESTAT_RELOAD1, AS_INT, vehicle_reload1);
-
- addstat(STAT_VEHICLESTAT_AMMO2, AS_INT, vehicle_ammo2);
- addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
-#endif // SVQC
-}
-#endif
-
REGISTER_NET_LINKED(ENT_CLIENT_AUXILIARYXHAIR)
#if defined(SVQC)
float barAlpha = autocvar_hud_progressbar_alpha * hudAlpha;
float blinkValue = 0.55 + sin(time * 7) * 0.45;
- float health = getstati(STAT_VEHICLESTAT_HEALTH) * 0.01;
- float shield = getstati(STAT_VEHICLESTAT_SHIELD) * 0.01;
- float energy = getstati(STAT_VEHICLESTAT_ENERGY) * 0.01;
- float ammo1 = getstati(STAT_VEHICLESTAT_AMMO1) * 0.01;
- float reload1 = getstati(STAT_VEHICLESTAT_RELOAD1) * 0.01;
- float ammo2 = getstati(STAT_VEHICLESTAT_AMMO2) * 0.01;
- float reload2 = getstati(STAT_VEHICLESTAT_RELOAD2) * 0.01;
+ float health = STAT(VEHICLESTAT_HEALTH) * 0.01;
+ float shield = STAT(VEHICLESTAT_SHIELD) * 0.01;
+ float energy = STAT(VEHICLESTAT_ENERGY) * 0.01;
+ float ammo1 = STAT(VEHICLESTAT_AMMO1) * 0.01;
+ float reload1 = STAT(VEHICLESTAT_RELOAD1) * 0.01;
+ float ammo2 = STAT(VEHICLESTAT_AMMO2) * 0.01;
+ float reload2 = STAT(VEHICLESTAT_RELOAD2) * 0.01;
// HACK to deal with the inconsistent use of the vehicle stats
ammo1 = (ammo1) ? ammo1 : energy;
void RaptorCBShellfragDraw(entity this);
void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang);
-#define weapon2mode getstati(STAT_VEHICLESTAT_W2MODE)
+#define weapon2mode STAT(VEHICLESTAT_W2MODE)
#endif
.entity gunner1;
.entity gunner2;
-.float vehicle_health; /// If self is player this is 0..100 indicating precentage of health left on vehicle. If self is vehile, this is the real health value.
-.float vehicle_energy; /// If self is player this is 0..100 indicating precentage of energy left on vehicle. If self is vehile, this is the real energy value.
-.float vehicle_shield; /// If self is player this is 0..100 indicating precentage of shield left on vehicle. If self is vehile, this is the real shield value.
+.float vehicle_health = _STAT(VEHICLESTAT_HEALTH); /// If self is player this is 0..100 indicating precentage of health left on vehicle. If self is vehile, this is the real health value.
+.float vehicle_energy = _STAT(VEHICLESTAT_ENERGY); /// If self is player this is 0..100 indicating precentage of energy left on vehicle. If self is vehile, this is the real energy value.
+.float vehicle_shield = _STAT(VEHICLESTAT_SHIELD); /// If self is player this is 0..100 indicating precentage of shield left on vehicle. If self is vehile, this is the real shield value.
-.float vehicle_ammo1; /// If self is player this is 0..100 indicating percentage of primary ammo left UNLESS value is already stored in vehicle_energy. If self is vehile, this is the real ammo1 value.
-.float vehicle_reload1; /// If self is player this is 0..100 indicating percentage of primary reload status. If self is vehile, this is the real reload1 value.
-.float vehicle_ammo2; /// If self is player this is 0..100 indicating percentage of secondary ammo left. If self is vehile, this is the real ammo2 value.
-.float vehicle_reload2; /// If self is player this is 0..100 indicating percentage of secondary reload status. If self is vehile, this is the real reload2 value.
+.float vehicle_ammo1 = _STAT(VEHICLESTAT_AMMO1); /// If self is player this is 0..100 indicating percentage of primary ammo left UNLESS value is already stored in vehicle_energy. If self is vehile, this is the real ammo1 value.
+.float vehicle_reload1 = _STAT(VEHICLESTAT_RELOAD1); /// If self is player this is 0..100 indicating percentage of primary reload status. If self is vehile, this is the real reload1 value.
+.float vehicle_ammo2 = _STAT(VEHICLESTAT_AMMO2); /// If self is player this is 0..100 indicating percentage of secondary ammo left. If self is vehile, this is the real ammo2 value.
+.float vehicle_reload2 = _STAT(VEHICLESTAT_RELOAD2); /// If self is player this is 0..100 indicating percentage of secondary reload status. If self is vehile, this is the real reload2 value.
.float sound_nexttime;
const float VOL_VEHICLEENGINE = 1;
const float VHSF_NORMAL = 0;
const float VHSF_FACTORY = 2;
-.int hud;
+.int hud = _STAT(HUD);
.float dmg_time;
.int volly_counter;
// vehicle functions
.void(int _spawnflag) vehicle_spawn; /// Vehicles custom fucntion to be efecuted when vehicle (re)spawns
.bool(int _imp) vehicles_impulse;
-.int vehicle_weapon2mode;
+.int vehicle_weapon2mode = _STAT(VEHICLESTAT_W2MODE);
.void(int exit_flags) vehicle_exit;
.bool() vehicle_enter;
const int VHEF_NORMAL = 0; /// User pressed exit key
dropmark.gravity = 1;
}
- float reload2 = getstati(STAT_VEHICLESTAT_RELOAD2) * 0.01;
+ float reload2 = STAT(VEHICLESTAT_RELOAD2) * 0.01;
if(reload2 == 1)
{
setorigin(dropmark, pmove_org);
if(wasfreed(self))
return;
- Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+ Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
self.move_avelocity += randomvec() * 15;
self.renderflags = 0;
#endif
// client movement
-void viewloc_PlayerPhysics()
-{SELFPARAM();
- if(self.viewloc)
+void viewloc_PlayerPhysics(entity this)
+{
+ if(this.viewloc)
{
- vector oldmovement = self.movement;
- self.movement_x = oldmovement_y;
- self.movement_y = 0;
+ vector oldmovement = this.movement;
+ this.movement_x = oldmovement_y;
+ this.movement_y = 0;
- if(self.movement_x < 0)
- self.movement_x = -self.movement_x;
+ if(this.movement_x < 0)
+ this.movement_x = -this.movement_x;
vector level_start, level_end;
- level_start = self.viewloc.enemy.origin;
- level_end = self.viewloc.goalentity.origin;
+ level_start = this.viewloc.enemy.origin;
+ level_end = this.viewloc.goalentity.origin;
vector forward, backward;
forward = vectoangles(normalize(level_end - level_start));
backward = vectoangles(normalize(level_start - level_end));
- if(self.movement_x < 0) // left
- self.angles_y = backward_y;
- if(self.movement_x > 0) // right
- self.angles_y = forward_y;
+ if(this.movement_x < 0) // left
+ this.angles_y = backward_y;
+ if(this.movement_x > 0) // right
+ this.angles_y = forward_y;
if(oldmovement_x > 0)
#ifdef CSQC
input_angles_x =
#endif
- self.v_angle_x = self.angles_x = -50;
+ this.v_angle_x = this.angles_x = -50;
else if(oldmovement_x < 0)
#ifdef CSQC
input_angles_x =
#endif
- self.v_angle_x = self.angles_x = 50;
+ this.v_angle_x = this.angles_x = 50;
- //if(!PHYS_INPUT_BUTTON_CROUCH(self) && !IS_DUCKED(self))
+ //if(!PHYS_INPUT_BUTTON_CROUCH(this) && !IS_DUCKED(this))
#ifdef SVQC
- //self.BUTTON_CROUCH = (oldmovement_x < 0);
+ //this.BUTTON_CROUCH = (oldmovement_x < 0);
if (oldmovement.x < 0)
- self.BUTTON_CROUCH = true;
+ this.BUTTON_CROUCH = true;
#elif defined(CSQC)
if (oldmovement.x < 0)
{
input_buttons |= BIT(4);
- self.flags |= FL_DUCKED;
+ this.flags |= FL_DUCKED;
}
- //else { input_buttons &= ~16; self.flags &= ~FL_DUCKED; }
+ //else { input_buttons &= ~16; this.flags &= ~FL_DUCKED; }
#endif
}
}
vector old_camera_angle = '0 0 0';
void viewloc_SetViewLocation()
{
- entity view = CSQCModel_server2csqc(player_localentnum);
+ entity view = CSQCModel_server2csqc(player_localentnum - 1);
if (!view) return;
//NOTE: the "cam_" cvars sould probably be changed out with a spawnflag or an entity key. I have it like this for my testing -- Player_2
if(view.viewloc && !wasfreed(view.viewloc) && view.viewloc.enemy && view.viewloc.goalentity)
.entity viewloc;
-void viewloc_PlayerPhysics();
+void viewloc_PlayerPhysics(entity this);
#ifdef CSQC
#include "../../server/g_hook.qh"
#endif
#ifndef MENUQC
-#include "calculations.qc"
+ #include "calculations.qc"
#endif
#define IMPLEMENTATION
#include "all.inc"
// WEAPON PLUGIN SYSTEM
-WepSet _WepSet_FromWeapon(int a) {
+WepSet _WepSet_FromWeapon(int a)
+{
a -= WEP_FIRST;
if (Weapons_MAX > 24)
- if (a >= 24) {
- a -= 24;
- if (Weapons_MAX > 48)
- if (a >= 24) {
+ if (a >= 24)
+ {
a -= 24;
- return '0 0 1' * power2of(a);
+ if (Weapons_MAX > 48)
+ if (a >= 24)
+ {
+ a -= 24;
+ return '0 0 1' * power2of(a);
+ }
+ return '0 1 0' * power2of(a);
}
- return '0 1 0' * power2of(a);
- }
return '1 0 0' * power2of(a);
}
#ifdef SVQC
-void WepSet_AddStat()
-{
- addstat(STAT_WEAPONS, AS_INT, weapons_x);
- if (Weapons_MAX > 24)
- addstat(STAT_WEAPONS2, AS_INT, weapons_y);
- if (Weapons_MAX > 48)
- addstat(STAT_WEAPONS3, AS_INT, weapons_z);
-}
-void WepSet_AddStat_InMap()
-{
- addstat(STAT_WEAPONSINMAP, AS_INT, weaponsinmap_x);
- if (Weapons_MAX > 24)
- addstat(STAT_WEAPONSINMAP2, AS_INT, weaponsinmap_y);
- if (Weapons_MAX > 48)
- addstat(STAT_WEAPONSINMAP3, AS_INT, weaponsinmap_z);
-}
-void WriteWepSet(float dst, WepSet w)
-{
- if (Weapons_MAX > 48)
- WriteInt72_t(dst, w);
- else if (Weapons_MAX > 24)
- WriteInt48_t(dst, w);
- else
- WriteInt24_t(dst, w.x);
-}
+ void WriteWepSet(float dst, WepSet w)
+ {
+ if (Weapons_MAX > 48) WriteInt72_t(dst, w);
+ else if (Weapons_MAX > 24) WriteInt48_t(dst, w);
+ else WriteInt24_t(dst, w.x);
+ }
#endif
#ifdef CSQC
-WepSet WepSet_GetFromStat()
-{
- WepSet w = '0 0 0';
- w.x = getstati(STAT_WEAPONS);
- if (Weapons_MAX > 24)
- w.y = getstati(STAT_WEAPONS2);
- if (Weapons_MAX > 48)
- w.z = getstati(STAT_WEAPONS3);
- return w;
-}
-WepSet WepSet_GetFromStat_InMap()
-{
- WepSet w = '0 0 0';
- w_x = getstati(STAT_WEAPONSINMAP);
- if (Weapons_MAX > 24)
- w_y = getstati(STAT_WEAPONSINMAP2);
- if (Weapons_MAX > 48)
- w_z = getstati(STAT_WEAPONSINMAP3);
- return w;
-}
-WepSet ReadWepSet()
-{
- if (Weapons_MAX > 48)
- return ReadInt72_t();
- if (Weapons_MAX > 24)
- return ReadInt48_t();
- return ReadInt24_t() * '1 0 0';
-}
+ WepSet WepSet_GetFromStat()
+ {
+ return STAT(WEAPONS);
+ }
+ WepSet WepSet_GetFromStat_InMap()
+ {
+ return STAT(WEAPONSINMAP);
+ }
+ WepSet ReadWepSet()
+ {
+ if (Weapons_MAX > 48) return ReadInt72_t();
+ if (Weapons_MAX > 24) return ReadInt48_t();
+ return ReadInt24_t() * '1 0 0';
+ }
#endif
string W_FixWeaponOrder(string order, float complete)
string W_NameWeaponOrder_MapFunc(string s)
{
entity wi;
- if(s == "0" || stof(s))
+ if (s == "0" || stof(s))
{
wi = get_weaponinfo(stof(s));
- if(wi != WEP_Null)
- return wi.netname;
+ if (wi != WEP_Null) return wi.netname;
}
return s;
}
string W_UndeprecateName(string s)
{
- switch ( s )
+ switch (s)
{
- case "nex" : return "vortex";
- case "rocketlauncher" : return "devastator";
- case "laser" : return "blaster";
- case "minstanex" : return "vaporizer";
+ case "nex": return "vortex";
+ case "rocketlauncher": return "devastator";
+ case "laser": return "blaster";
+ case "minstanex": return "vaporizer";
case "grenadelauncher": return "mortar";
- case "uzi" : return "machinegun";
- default : return s;
+ case "uzi": return "machinegun";
+ default: return s;
}
}
string W_NameWeaponOrder(string order)
string W_NumberWeaponOrder_MapFunc(string s)
{
int i;
- if(s == "0" || stof(s))
- return s;
+ if (s == "0" || stof(s)) return s;
s = W_UndeprecateName(s);
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)
- if(s == get_weaponinfo(i).netname)
- return ftos(i);
+ for (i = WEP_FIRST; i <= WEP_LAST; ++i)
+ if (s == get_weaponinfo(i).netname) return ftos(i);
return s;
}
string W_NumberWeaponOrder(string order)
e1 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[i]);
e2 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[j]);
d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
- if(d != 0)
- return -d; // high impulse first!
- return
- strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
- -
- strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
- ; // low char index first!
+ if (d != 0) return -d; // high impulse first!
+ return strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "),
+ sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
+ -
+ strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "),
+ sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
+ ; // low char index first!
}
string W_FixWeaponOrder_BuildImpulseList(string o)
{
int i;
W_FixWeaponOrder_BuildImpulseList_order = o;
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+ for (i = WEP_FIRST; i <= WEP_LAST; ++i)
W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST] = i;
- heapsort(WEP_LAST - WEP_FIRST + 1, W_FixWeaponOrder_BuildImpulseList_swap, W_FixWeaponOrder_BuildImpulseList_cmp, world);
+ heapsort(WEP_LAST - WEP_FIRST + 1, W_FixWeaponOrder_BuildImpulseList_swap, W_FixWeaponOrder_BuildImpulseList_cmp,
+ world);
o = "";
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+ for (i = WEP_FIRST; i <= WEP_LAST; ++i)
o = strcat(o, " ", ftos(W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST]));
W_FixWeaponOrder_BuildImpulseList_order = string_null;
return substring(o, 1, -1);
string W_FixWeaponOrder_ForceComplete(string order)
{
- if(order == "")
- order = W_NumberWeaponOrder(cvar_defstring("cl_weaponpriority"));
+ if (order == "") order = W_NumberWeaponOrder(cvar_defstring("cl_weaponpriority"));
return W_FixWeaponOrder(order, 1);
}
WepSet result;
remaining = e.weapons;
result = '0 0 0';
- for(i = 0; i < n; ++i)
+ for (i = 0; i < n; ++i)
{
RandomSelection_Init();
- for(j = WEP_FIRST; j <= WEP_LAST; ++j)
- if(remaining & WepSet_FromWeapon(j))
- RandomSelection_Add(world, j, string_null, 1, 1);
+ for (j = WEP_FIRST; j <= WEP_LAST; ++j)
+ if (remaining & WepSet_FromWeapon(j)) RandomSelection_Add(world, j, string_null, 1, 1);
result |= WepSet_FromWeapon(RandomSelection_chosen_float);
remaining &= ~WepSet_FromWeapon(RandomSelection_chosen_float);
}
case ammo_cells: return ITEM_Cells.m_icon;
case ammo_plasma: return ITEM_Plasma.m_icon;
case ammo_fuel: return ITEM_JetpackFuel.m_icon;
- default: return ""; // wtf, no ammo type?
+ default: return ""; // wtf, no ammo type?
}
}
#ifdef CSQC
-.int GetAmmoFieldFromNum(int i)
-{
- switch(i)
+ .int GetAmmoFieldFromNum(int i)
{
- case 0: return ammo_shells;
- case 1: return ammo_nails;
- case 2: return ammo_rockets;
- case 3: return ammo_cells;
- case 4: return ammo_plasma;
- case 5: return ammo_fuel;
- default: return ammo_none;
+ switch (i)
+ {
+ case 0: return ammo_shells;
+ case 1: return ammo_nails;
+ case 2: return ammo_rockets;
+ case 3: return ammo_cells;
+ case 4: return ammo_plasma;
+ case 5: return ammo_fuel;
+ default: return ammo_none;
+ }
}
-}
-int GetAmmoStat(.int ammotype)
-{
- switch(ammotype)
+ int GetAmmoStat(.int ammotype)
{
- case ammo_shells: return STAT_SHELLS;
- case ammo_nails: return STAT_NAILS;
- case ammo_rockets: return STAT_ROCKETS;
- case ammo_cells: return STAT_CELLS;
- case ammo_plasma: return STAT_PLASMA;
- case ammo_fuel: return STAT_FUEL;
- default: return -1;
+ switch (ammotype)
+ {
+ case ammo_shells: return STAT_SHELLS;
+ case ammo_nails: return STAT_NAILS;
+ case ammo_rockets: return STAT_ROCKETS;
+ case ammo_cells: return STAT_CELLS;
+ case ammo_plasma: return STAT_PLASMA.m_id;
+ case ammo_fuel: return STAT_FUEL.m_id;
+ default: return -1;
+ }
}
-}
#endif
string W_Sound(string w_snd)
{
string output = strcat("weapons/", w_snd);
#ifdef SVQC
- MUTATOR_CALLHOOK(WeaponSound, w_snd, output);
- return weapon_sound_output;
+ MUTATOR_CALLHOOK(WeaponSound, w_snd, output);
+ return weapon_sound_output;
#else
- return output;
+ return output;
#endif
}
string W_Model(string w_mdl)
{
string output = strcat("models/weapons/", w_mdl);
-#ifdef SVQC
MUTATOR_CALLHOOK(WeaponModel, w_mdl, output);
return weapon_model_output;
+}
+
+#ifndef MENUQC
+vector shotorg_adjustfromclient(vector vecs, float y_is_right, float algn)
+{
+ switch (algn)
+ {
+ default:
+ case 3:
+ // right alignment
+ break;
+ case 4:
+ // left
+ vecs.y = -vecs.y;
+ break;
+ case 1:
+ case 2:
+ // center
+ vecs.y = 0;
+ vecs.z -= 2;
+ break;
+ }
+ return vecs;
+}
+
+vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn)
+{
+#ifdef SVQC
+ string s;
+#endif
+ if (visual)
+ {
+ vecs = shotorg_adjustfromclient(vecs, y_is_right, algn);
+ }
+#ifdef SVQC
+ else if (autocvar_g_shootfromeye)
+ {
+ vecs.y = vecs.z = 0;
+ }
+ else if (autocvar_g_shootfromcenter)
+ {
+ vecs.y = 0;
+ vecs.z -= 2;
+ }
+ else if ((s = autocvar_g_shootfromfixedorigin) != "")
+ {
+ vector v = stov(s);
+ if (y_is_right) v.y = -v.y;
+ if (v.x != 0) vecs.x = v.x;
+ vecs.y = v.y;
+ vecs.z = v.z;
+ }
+#endif
+ else // just do the same as top
+ {
+ vecs = shotorg_adjustfromclient(vecs, y_is_right, algn);
+ }
+
+ return vecs;
+}
+
+#define shotorg_adjust shotorg_adjust_values
+
+/**
+ * supported formats:
+ *
+ * 1. simple animated model, muzzle flash handling on h_ model:
+ * h_tuba.dpm, h_tuba.dpm.framegroups - invisible model controlling the animation
+ * tags:
+ * shot = muzzle end (shot origin, also used for muzzle flashes)
+ * shell = casings ejection point (must be on the right hand side of the gun)
+ * weapon = attachment for v_tuba.md3
+ * v_tuba.md3 - first and third person model
+ * g_tuba.md3 - pickup model
+ *
+ * 2. simple animated model, muzzle flash handling on v_ model:
+ * h_tuba.dpm, h_tuba.dpm.framegroups - invisible model controlling the animation
+ * tags:
+ * weapon = attachment for v_tuba.md3
+ * v_tuba.md3 - first and third person model
+ * tags:
+ * shot = muzzle end (shot origin, also used for muzzle flashes)
+ * shell = casings ejection point (must be on the right hand side of the gun)
+ * g_tuba.md3 - pickup model
+ *
+ * 3. fully animated model, muzzle flash handling on h_ model:
+ * h_tuba.dpm, h_tuba.dpm.framegroups - animated first person model
+ * tags:
+ * shot = muzzle end (shot origin, also used for muzzle flashes)
+ * shell = casings ejection point (must be on the right hand side of the gun)
+ * handle = corresponding to the origin of v_tuba.md3 (used for muzzle flashes)
+ * v_tuba.md3 - third person model
+ * g_tuba.md3 - pickup model
+ *
+ * 4. fully animated model, muzzle flash handling on v_ model:
+ * h_tuba.dpm, h_tuba.dpm.framegroups - animated first person model
+ * tags:
+ * shot = muzzle end (shot origin)
+ * shell = casings ejection point (must be on the right hand side of the gun)
+ * v_tuba.md3 - third person model
+ * tags:
+ * shot = muzzle end (for muzzle flashes)
+ * g_tuba.md3 - pickup model
+ *
+ * writes:
+ * this.origin, this.angles
+ * this.weaponchild
+ * this.movedir, this.view_ofs
+ * attachment stuff
+ * anim stuff
+ * to free:
+ * call again with ""
+ * remove the ent
+ */
+void CL_WeaponEntity_SetModel(entity this, string name)
+{
+ if (name == "")
+ {
+ this.model = "";
+ if (this.weaponchild) remove(this.weaponchild);
+ this.weaponchild = NULL;
+ this.movedir = '0 0 0';
+ this.spawnorigin = '0 0 0';
+ this.oldorigin = '0 0 0';
+ this.anim_fire1 = '0 1 0.01';
+ this.anim_fire2 = '0 1 0.01';
+ this.anim_idle = '0 1 0.01';
+ this.anim_reload = '0 1 0.01';
+ }
+ else
+ {
+ // if there is a child entity, hide it until we're sure we use it
+ if (this.weaponchild) this.weaponchild.model = "";
+ _setmodel(this, W_Model(strcat("v_", name, ".md3")));
+ int v_shot_idx; // used later
+ (v_shot_idx = gettagindex(this, "shot")) || (v_shot_idx = gettagindex(this, "tag_shot"));
+
+ _setmodel(this, W_Model(strcat("h_", name, ".iqm")));
+ // preset some defaults that work great for renamed zym files (which don't need an animinfo)
+ this.anim_fire1 = animfixfps(this, '0 1 0.01', '0 0 0');
+ this.anim_fire2 = animfixfps(this, '1 1 0.01', '0 0 0');
+ this.anim_idle = animfixfps(this, '2 1 0.01', '0 0 0');
+ this.anim_reload = animfixfps(this, '3 1 0.01', '0 0 0');
+
+ // if we have a "weapon" tag, let's attach the v_ model to it ("invisible hand" style model)
+ // if we don't, this is a "real" animated model
+ string t;
+ if ((t = "weapon", gettagindex(this, t)) || (t = "tag_weapon", gettagindex(this, t)))
+ {
+ if (!this.weaponchild)
+ {
+ this.weaponchild = new(weaponchild);
+ make_pure(this.weaponchild);
+#ifdef CSQC
+ this.weaponchild.drawmask = MASK_NORMAL;
+ this.weaponchild.renderflags |= RF_VIEWMODEL;
+#endif
+ }
+ _setmodel(this.weaponchild, W_Model(strcat("v_", name, ".md3")));
+ setattachment(this.weaponchild, this, t);
+ }
+ else
+ {
+ if (this.weaponchild) remove(this.weaponchild);
+ this.weaponchild = NULL;
+ }
+
+ setorigin(this, '0 0 0');
+ this.angles = '0 0 0';
+ this.frame = 0;
+#ifdef SVQC
+ this.viewmodelforclient = NULL;
+#else
+ this.renderflags &= ~RF_VIEWMODEL;
+#endif
+ if (v_shot_idx) // v_ model attached to invisible h_ model
+ {
+ this.movedir = gettaginfo(this.weaponchild, v_shot_idx);
+ }
+ else
+ {
+ int idx;
+ if ((idx = gettagindex(this, "shot")) || (idx = gettagindex(this, "tag_shot")))
+ {
+ this.movedir = gettaginfo(this, idx);
+ }
+ else
+ {
+ LOG_WARNINGF("weapon model %s does not support the 'shot' tag, will display shots TOTALLY wrong\n",
+ this.model);
+ this.movedir = '0 0 0';
+ }
+ }
+ {
+ int idx = 0;
+ // v_ model attached to invisible h_ model
+ if (this.weaponchild
+ && ((idx = gettagindex(this.weaponchild, "shell")) || (idx = gettagindex(this.weaponchild, "tag_shell"))))
+ {
+ this.spawnorigin = gettaginfo(this.weaponchild, idx);
+ }
+ else if ((idx = gettagindex(this, "shell")) || (idx = gettagindex(this, "tag_shell")))
+ {
+ this.spawnorigin = gettaginfo(this, idx);
+ }
+ else
+ {
+ LOG_WARNINGF("weapon model %s does not support the 'shell' tag, will display casings wrong\n",
+ this.model);
+ this.spawnorigin = this.movedir;
+ }
+ }
+ if (v_shot_idx)
+ {
+ this.oldorigin = '0 0 0'; // use regular attachment
+ }
+ else
+ {
+ int idx;
+ if (this.weaponchild)
+ (idx = gettagindex(this, "weapon")) || (idx = gettagindex(this, "tag_weapon"));
+ else
+ (idx = gettagindex(this, "handle")) || (idx = gettagindex(this, "tag_handle"));
+ if (idx)
+ {
+ this.oldorigin = this.movedir - gettaginfo(this, idx);
+ }
+ else
+ {
+ LOG_WARNINGF(
+ "weapon model %s does not support the 'handle' tag "
+ "and neither does the v_ model support the 'shot' tag, "
+ "will display muzzle flashes TOTALLY wrong\n",
+ this.model);
+ this.oldorigin = '0 0 0'; // there is no way to recover from this
+ }
+ }
+
+#ifdef SVQC
+ this.viewmodelforclient = this.owner;
+#else
+ this.renderflags |= RF_VIEWMODEL;
+#endif
+ }
+
+ this.view_ofs = '0 0 0';
+
+ if (this.movedir.x >= 0)
+ {
+#ifdef SVQC
+ int algn = this.owner.cvar_cl_gunalign;
+#else
+ int algn = autocvar_cl_gunalign;
+#endif
+ vector v = this.movedir;
+ this.movedir = shotorg_adjust(v, false, false, algn);
+ this.view_ofs = shotorg_adjust(v, false, true, algn) - v;
+ }
+ int compressed_shotorg = compressShotOrigin(this.movedir);
+ // make them match perfectly
+#ifdef SVQC
+ this.movedir = decompressShotOrigin(this.owner.stat_shotorg = compressed_shotorg);
#else
- return output;
+ this.movedir = decompressShotOrigin(compressed_shotorg);
#endif
+
+ this.spawnorigin += this.view_ofs; // offset the casings origin by the same amount
+
+ // check if an instant weapon switch occurred
+ setorigin(this, this.view_ofs);
+ // reset animstate now
+ this.wframe = WFRAME_IDLE;
+ setanim(this, this.anim_idle, true, false, true);
}
+#endif
+
+#ifndef MENUQC
+
+REGISTER_NET_TEMP(wframe)
+#ifdef CSQC
+NET_HANDLE(wframe, bool isNew)
+{
+ vector a;
+ a.x = ReadCoord();
+ a.y = ReadCoord();
+ a.z = ReadCoord();
+ bool restartanim = ReadByte();
+ anim_set(viewmodel, a, !restartanim, restartanim, restartanim);
+ viewmodel.state = ReadByte();
+ viewmodel.weapon_nextthink = ReadFloat();
+ viewmodel.alpha = ReadByte() / 255;
+ switch (viewmodel.state)
+ {
+ case WS_RAISE:
+ case WS_DROP:
+ viewmodel.weapon_switchdelay = ReadFloat();
+ break;
+ default:
+ viewmodel.weapon_switchdelay = 0;
+ break;
+ }
+ return true;
+}
+#endif
+
+#ifdef SVQC
+void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim)
+{
+ if (!IS_REAL_CLIENT(actor)) return;
+ int channel = MSG_ONE;
+ msg_entity = actor;
+ WriteHeader(channel, wframe);
+ WriteCoord(channel, a.x);
+ WriteCoord(channel, a.y);
+ WriteCoord(channel, a.z);
+ WriteByte(channel, restartanim);
+ WriteByte(channel, weaponentity.state);
+ WriteFloat(channel, weaponentity.weapon_nextthink);
+ WriteByte(channel, weaponentity.m_alpha * 255);
+ Weapon w = Weapons_from(actor.weapon);
+ switch (weaponentity.state)
+ {
+ case WS_RAISE:
+ WriteFloat(channel, w.switchdelay_raise);
+ break;
+ case WS_DROP:
+ WriteFloat(channel, w.switchdelay_drop);
+ break;
+ }
+}
+#endif
+
+#endif
#endif
// weapon sets
typedef vector WepSet;
#ifdef SVQC
-void WepSet_AddStat();
-void WepSet_AddStat_InMap();
void WriteWepSet(float dest, WepSet w);
#endif
weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
}
+#ifndef MENUQC
+
+.entity weaponchild;
+.entity exteriorweaponentity;
+.vector weaponentity_glowmod;
+
+//.int weapon; // current weapon
+#ifdef SVQC
+.int switchweapon = _STAT(SWITCHWEAPON);
+.int switchingweapon = _STAT(SWITCHINGWEAPON);
+#endif
+.string weaponname; // name of .weapon
+
+.vector spawnorigin; // for casings
+
+// weapon animation vectors:
+.vector anim_fire1;
+.vector anim_fire2;
+.vector anim_idle;
+.vector anim_reload;
+
+// static frame globals
+
+ENUMCLASS(WFRAME)
+CASE(WFRAME, DONTCHANGE)
+CASE(WFRAME, FIRE1)
+CASE(WFRAME, FIRE2)
+CASE(WFRAME, IDLE)
+CASE(WFRAME, RELOAD)
+ENUMCLASS_END(WFRAME)
+
+.WFRAME wframe;
+
+vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn);
+void CL_WeaponEntity_SetModel(entity this, string name);
+#endif
+
#endif
#ifndef WEAPON_H
#define WEAPON_H
#include "../items/item/pickup.qh"
+#include "../stats.qh"
const int MAX_WEAPONSLOTS = 2;
.entity weaponentities[MAX_WEAPONSLOTS];
return 0;
}
+// weapon states (actor.(weaponentity).state)
+/** no weapon selected */
+const int WS_CLEAR = 0;
+/** raise frame */
+const int WS_RAISE = 1;
+/** deselecting frame */
+const int WS_DROP = 2;
+/** fire state */
+const int WS_INUSE = 3;
+/** idle frame */
+const int WS_READY = 4;
+
+#ifdef SVQC
+.int ammo_shells;
+.int ammo_nails;
+.int ammo_rockets;
+.int ammo_cells;
+.int ammo_plasma = _STAT(PLASMA);
+.int ammo_fuel = _STAT(FUEL);
+.int ammo_none;
+#else
.int ammo_shells;
.int ammo_nails;
.int ammo_rockets;
.int ammo_plasma;
.int ammo_fuel;
.int ammo_none;
+#endif
/** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
CLASS(Weapon, Object)
// no weapon specific image for this weapon
return false;
}
+ /** (CLIENT) weapon specific glow */
+ METHOD(Weapon, wr_glow, vector(Weapon this)) { return '0 0 0'; }
/** (SERVER) the weapon is dropped */
METHOD(Weapon, wr_drop, void(Weapon this)) {}
/** (SERVER) a weapon is picked up */
weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
else
#endif
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
+ weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(arc, beam_animtime), w_ready);
}
if((!actor.arc_beam) || wasfreed(actor.arc_beam))
}
.void() rifle_bullethail_attackfunc;
-.float rifle_bullethail_frame;
+.WFRAME rifle_bullethail_frame;
.float rifle_bullethail_animtime;
.float rifle_bullethail_refire;
void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, .entity weaponentity, int fire)
}
}
-void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, float fr, float animtime, float refire)
+void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, WFRAME fr, float animtime, float refire)
{SELFPARAM();
// if we get here, we have at least one bullet to fire
AttackFunc();
if(a < ALPHA_MIN_VISIBLE) { remove(self); }
// WEAPONTODO: save this only once when creating the entity
- vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
+ vector sw_color = entcs_GetColor(self.sv_entnum - 1); // GetTeamRGB(entcs_GetTeam(self.sv_entnum));
// WEAPONTODO: trace to find what we actually hit
vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
WriteCoord(MSG_BROADCAST, v.y);
WriteCoord(MSG_BROADCAST, v.z);
WriteByte(MSG_BROADCAST, hit);
- WriteShort(MSG_BROADCAST, num_for_edict(player));
+ WriteByte(MSG_BROADCAST, num_for_edict(player));
WriteByte(MSG_BROADCAST, player.team);
}
#elif defined(CSQC)
string tex = "particles/lgbeam";
if(this.cnt)
tex = "particles/gauntletbeam";
- vector rgb = getcsqcplayercolor(this.sv_entnum);
+ vector rgb;
+ //entity e = CSQCModel_server2csqc(this.sv_entnum - 1);
+ //if (e == NULL)
+ //{
+ rgb = colormapPaletteColor(stof(getplayerkeyvalue(this.sv_entnum - 1, "colors")) & 0x0F, true);
+ //rgb = '1 1 1';
+ //}
+ //else
+ // rgb = e.glowmod;
rgb *= (1 + autocvar_cl_vaporizerbeam_colorboost);
float fail = (self.nextthink - time);
this.vorg1_x = ReadCoord(); this.vorg1_y = ReadCoord(); this.vorg1_z = ReadCoord();
this.vorg2_x = ReadCoord(); this.vorg2_y = ReadCoord(); this.vorg2_z = ReadCoord();
this.cnt = ReadByte();
- this.sv_entnum = ReadShort();
+ int myowner = ReadByte();
+ this.owner = playerslots[myowner - 1];
+ this.sv_entnum = myowner;
this.team = ReadByte() - 1;
if(autocvar_cl_vaporizerbeam_particle)
#endif
#ifdef IMPLEMENTATION
+REGISTER_STAT(WEP_CVAR_vortex_charge, bool, WEP_CVAR(vortex, charge))
+REGISTER_STAT(WEP_CVAR_vortex_charge_animlimit, float, WEP_CVAR(vortex, charge_animlimit))
+
+#if defined(CSQC)
+float autocvar_g_weapon_charge_colormod_red_full;
+float autocvar_g_weapon_charge_colormod_red_half;
+float autocvar_g_weapon_charge_colormod_green_full;
+float autocvar_g_weapon_charge_colormod_blue_full;
+float autocvar_g_weapon_charge_colormod_blue_half;
+float autocvar_g_weapon_charge_colormod_green_half;
+float autocvar_g_weapon_charge_colormod_hdrmultiplier;
+
+METHOD(Vortex, wr_glow, vector(Vortex this))
+{
+ if (!STAT(WEP_CVAR_vortex_charge)) return '0 0 0';
+ float charge = STAT(VORTEX_CHARGE);
+ float animlimit = STAT(WEP_CVAR_vortex_charge_animlimit);
+ vector g;
+ g.x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, charge / animlimit);
+ g.y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, charge / animlimit);
+ g.z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, charge / animlimit);
+ if (charge > animlimit)
+ {
+ g.x += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (charge - animlimit) / (1 - animlimit);
+ g.y += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (charge - animlimit) / (1 - animlimit);
+ g.z += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (charge - animlimit) / (1 - animlimit);
+ }
+ return g;
+}
+#endif
+
REGISTER_NET_TEMP(TE_CSQC_VORTEXBEAMPARTICLE)
#if defined(SVQC)
particles_alphamin = particles_alphamax = particles_fade = charge;
if(!MUTATOR_CALLHOOK(Particles_VortexBeam, shotorg, endpos))
- if(autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
+ if(autocvar_cl_particles_oldvortexbeam && (STAT(ALLOW_OLDVORTEXBEAM) || isdemo()))
WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
else
WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
#define pointparticles __pointparticles
#define setmodel _setmodel
+#define STAT_FRAGLIMIT _STAT_FRAGLIMIT
+#define STAT_TIMELIMIT _STAT_TIMELIMIT
+#define STAT_MOVEVARS_TICRATE _STAT_MOVEVARS_TICRATE
+#define STAT_MOVEVARS_TIMESCALE _STAT_MOVEVARS_TIMESCALE
+#define STAT_MOVEVARS_GRAVITY _STAT_MOVEVARS_GRAVITY
+
#include "upstream/csprogsdefs.qc"
#undef true
#undef pointparticles
#undef setmodel
+#undef STAT_FRAGLIMIT
+#undef STAT_TIMELIMIT
+#undef STAT_MOVEVARS_TICRATE
+#undef STAT_MOVEVARS_TIMESCALE
+#undef STAT_MOVEVARS_GRAVITY
+
#pragma noref 0
#endif
#include "cvar.qh"
#include "defer.qh"
#include "draw.qh"
+#include "enumclass.qh"
#include "file.qh"
#include "functional.qh"
#include "i18n.qh"
#include "noise.qc"
#include "oo.qh"
#include "p2mathlib.qc"
-#include "player.qh"
#include "progname.qh"
#include "random.qc"
#include "registry.qh"
return true;
}
-entity CSQCModel_server2csqc(int pl)
+/**
+ * @param i zero indexed player
+ */
+entity CSQCModel_server2csqc(int i)
{
- if (pl <= maxclients) return CSQCModel_players[pl - 1];
- LOG_WARNINGF("player out of bounds: %d\n", pl);
- return findfloat(NULL, entnum, pl);
+ if (i < maxclients) return CSQCModel_players[i];
+ ++i;
+ LOG_WARNINGF("player out of bounds: %d\n", i);
+ return findfloat(NULL, entnum, i);
}
#undef CSQCMODEL_ENDIF
#undef CSQCMODEL_IF
-entity CSQCModel_server2csqc(float pl);
+entity CSQCModel_server2csqc(int i);
.float csqcmodel_teleported;
// this is exported for custom frame animation code. Use with care.
#include "../../common/viewloc.qh"
float autocvar_cl_movement_errorcompensation = 0;
-bool autocvar_cl_movement = true;
// engine stuff
float pmove_onground; // weird engine flag we shouldn't really use but have to for now
}
void CSQC_ClientMovement_PlayerMove_Frame(entity this);
+void _Movetype_Physics_ClientFrame(entity this, float movedt);
-void PM_Movement_Move(entity this)
+void Movetype_Physics_Spam(entity this) // optimized
{
- runstandardplayerphysics(this);
-#ifdef CSQC
- this.flags =
- ((this.pmove_flags & PMF_DUCKED) ? FL_DUCKED : 0) |
- (!(this.pmove_flags & PMF_JUMP_HELD) ? FL_JUMPRELEASED : 0) |
- ((this.pmove_flags & PMF_ONGROUND) ? FL_ONGROUND : 0);
-#endif
+ _Movetype_Physics_ClientFrame(this, PHYS_INPUT_TIMELENGTH);
+ if(wasfreed(this))
+ return;
+
+ this.avelocity = this.move_avelocity;
+ this.velocity = this.move_velocity;
+ this.angles = this.move_angles;
+ this.flags = BITSET(this.flags, FL_ONGROUND, boolean(this.move_flags & FL_ONGROUND));
+ this.flags = BITSET(this.flags, FL_WATERJUMP, boolean(this.move_flags & FL_WATERJUMP));
+ this.waterlevel = this.move_waterlevel;
+ this.watertype = this.move_watertype;
+ setorigin(this, this.move_origin);
}
void CSQCPlayer_Physics(entity this)
{
if(autocvar_cl_movement)
+ {
CSQC_ClientMovement_PlayerMove_Frame(this);
+
+ if(autocvar_cl_movement == 3)
+ {
+ this.move_origin = this.origin;
+ this.move_angles = this.angles;
+ //this.move_movetype = MOVETYPE_WALK; // temp
+ this.move_velocity = this.velocity;
+ this.move_avelocity = this.avelocity;
+ this.move_flags = BITSET(this.move_flags, FL_ONGROUND, boolean(this.flags & FL_ONGROUND));
+ this.move_flags = BITSET(this.move_flags, FL_WATERJUMP, boolean(this.flags & FL_WATERJUMP));
+ this.move_waterlevel = this.waterlevel;
+ this.move_watertype = this.watertype;
+ Movetype_Physics_Spam(this);
+ }
+
+ this.pmove_flags =
+ ((this.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
+ (!(this.flags & FL_JUMPRELEASED) ? PMF_JUMP_HELD : 0) |
+ ((this.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
+ }
}
void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error)
setorigin(e, e.origin);
}
- const entity view = CSQCModel_server2csqc(player_localentnum);
+ const entity view = CSQCModel_server2csqc(player_localentnum - 1);
if (view)
{
if (view != csqcplayer)
#ifndef LIB_CSQCMODEL_CL_PLAYER_H
#define LIB_CSQCMODEL_CL_PLAYER_H
+int autocvar_cl_movement = 1;
+
entity csqcplayer;
float csqcplayer_status;
const int CSQCPLAYERSTATUS_UNPREDICTED = 0;
--- /dev/null
+#ifndef ENUMCLASS_H
+#define ENUMCLASS_H
+
+#include "oo.qh"
+
+// purpose: prevent transposed parameter passing
+
+#if NDEBUG
+
+// zero overhead mode, use this for releases
+
+#define ENUMCLASS(id) typedef int id; enum {
+#define CASE(class, id) class##_##id,
+#define ENUMCLASS_END(id) };
+
+#else
+
+// edict overhead mode, use this for type checking
+
+#define ENUMCLASS(id) CLASS(id, Object)
+#define CASE(class, id) class class##_##id; STATIC_INIT(class##_##id) { class##_##id = NEW(class); }
+#define ENUMCLASS_END(id) ENDCLASS(id)
+
+#endif
+
+#endif
} \
while (0)
-#define assert(expr, ...) \
+#define assert(expr, ...) _assert(LOG_SEVERE, expr, __VA_ARGS__)
+#define ASSERT(expr, ...) _assert(LOG_FATAL, expr, __VA_ARGS__)
+#define _assert(f, expr, then) \
do \
{ \
- if (!(expr)) LOG_WARNINGF(__VA_ARGS__); \
+ if (!(expr)) \
+ { \
+ f("assertion failed: `" #expr "`\n"); \
+ then; \
+ } \
} \
while (0)
+#define ASSERT_LESS(name, var, const) noref int name[(const - var + 1)];
+
#define _LOG(f, level, s) f("[::"level "] ["__FILE__ ":%s:%.0f] %s", __FUNC__, __LINE__, s)
#define LOG_FATAL(...) _LOG_FATAL(strcat("", __VA_ARGS__))
} \
while (0)
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) LOG_FATAL("assertion failed: " #expr "\n"); \
- } \
- while (0)
-
#endif
else return pow(e.(a) / e.(c), 1.0 / mean);
}
-#define MEAN_ACCUMULATE(prefix, v, w) mean_accumulate(self, prefix##_accumulator, prefix##_count, prefix##_mean, v, w)
-#define MEAN_EVALUATE(prefix) mean_evaluate(self, prefix##_accumulator, prefix##_count, prefix##_mean)
+#define MEAN_ACCUMULATE(s, prefix, v, w) mean_accumulate(s, prefix##_accumulator, prefix##_count, prefix##_mean, v, w)
+#define MEAN_EVALUATE(s, prefix) mean_evaluate(s, prefix##_accumulator, prefix##_count, prefix##_mean)
#define MEAN_DECLARE(prefix, m) float prefix##_mean = m; .float prefix##_count, prefix##_accumulator
/** Returns a random number between -1.0 and 1.0 */
}
}
+ void Net_UnlinkEntity(entity e)
+ {
+ e.SendEntity = func_null;
+ }
+
.void() uncustomizeentityforclient;
.float uncustomizeentityforclient_set;
}
#define ReadFloat() ReadCoord()
- vector ReadVector() { vector v; v.x = ReadFloat(); v_y = ReadFloat(); v.z = ReadFloat(); return v; }
+ vector ReadVector() { vector v; v.x = ReadFloat(); v.y = ReadFloat(); v.z = ReadFloat(); return v; }
vector ReadVector2D() { vector v; v.x = ReadFloat(); v.y = ReadFloat(); v.z = 0; return v; }
float ReadApproxPastTime()
(e).pure_data = true; \
} \
while (0)
+#define make_impure(e) \
+ do \
+ { \
+ (e).pure_data = false; \
+ } \
+ while (0)
#define is_pure(e) ((e).pure_data)
.string classname;
STATIC_INIT(clearentity)
{
_clearentity_ent = new(clearentity);
+ make_pure(_clearentity_ent);
}
void clearentity(entity e)
{
#ifdef CSQC
int n = e.entnum;
#endif
+ bool was_pure = is_pure(e);
copyentity(_clearentity_ent, e);
+ if (!was_pure) make_impure(e);
#ifdef CSQC
e.entnum = n;
#endif
class(cname).type name; \
INIT(cname) \
{ \
+ noref bool strzone; /* Error on strzone() calls. */ \
this.name = val; \
}
+#define ATTRIB_STRZONE(cname, name, type, val) \
+ class(cname).type name; \
+ INIT(cname) \
+ { \
+ if (this.name) \
+ strunzone(this.name); \
+ this.name = strzone(val); \
+ }
+
#define ATTRIBARRAY(cname, name, type, cnt) \
class(cname).type name[cnt];
+++ /dev/null
-#ifdef CSQC
-#ifndef PLAYER_H
- #define PLAYER_H
-
- #include "string.qh"
-
- #include "../client/main.qh"
- #include "../common/teams.qh"
-
- int GetPlayerColorForce(int i)
- {
- if (!teamplay) return 0;
- else return stof(getplayerkeyvalue(i, "colors")) & 15;
- }
-
- int GetPlayerColor(int i)
- {
- if (!playerslots[i].gotscores) // unconnected
- return NUM_SPECTATOR;
- else if (stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR) return NUM_SPECTATOR;
- else return GetPlayerColorForce(i);
- }
-
- string GetPlayerName(int i)
- {
- return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
- }
-
-#endif
-#endif
if (registry##_COUNT >= registry##_MAX) LOG_FATALF("Registry capacity exceeded (%s)", ftos(registry##_MAX)); \
entity this = id = inst; \
this.registered_id = #id; \
- this.fld = registry##_COUNT; \
- _R_SET(_##registry, registry##_COUNT, this); \
- ++registry##_COUNT; \
- if (!registry##_first) registry##_first = this; \
- if (registry##_last) registry##_last.REGISTRY_NEXT = this; \
- registry##_last = this; \
+ REGISTRY_PUSH(registry, fld, this); \
Register_##id##_init(this); \
Register_##id##_init_post(this); \
} \
ACCUMULATE_FUNCTION(Register##registry, Register_##id) \
REGISTER_INIT(id)
+#define REGISTRY_PUSH(registry, fld, it) do { \
+ it.fld = registry##_COUNT; \
+ _R_SET(_##registry, registry##_COUNT, it); \
+ ++registry##_COUNT; \
+ if (!registry##_first) registry##_first = it; \
+ if (registry##_last) registry##_last.REGISTRY_NEXT = it; \
+ registry##_last = it; \
+} while (0)
+
+#define REGISTRY_RESERVE(registry, fld, id, suffix) do { \
+ entity e = new(registry_reserved); \
+ make_pure(e); \
+ e.registered_id = #id "/" #suffix; \
+ REGISTRY_PUSH(registry, fld, e); \
+} while (0)
+
#define REGISTER_INIT(id) [[accumulate]] void Register_##id##_init(entity this)
#define REGISTER_INIT_POST(id) [[accumulate]] void Register_##id##_init_post(entity this)
#ifndef LIB_STATS_H
#define LIB_STATS_H
+// TODO: rename to 'netvars'
+
#include "registry.qh"
#include "sort.qh"
.int m_id;
+typedef vector vectori;
+#define REGISTER_STAT(...) EVAL(OVERLOAD(REGISTER_STAT, __VA_ARGS__))
#if defined(CSQC)
/** Get all stats and store them as globals, access with `STAT(ID)` */
void stats_get() {}
#define getstat_int(id) getstati(id, 0, 24)
#define getstat_bool(id) boolean(getstati(id))
#define getstat_float(id) getstatf(id)
+ #define getstat_vector(id) vec3(getstat_float(id + 0), getstat_float(id + 1), getstat_float(id + 2))
+ #define getstat_vectori(id) vec3(getstat_int(id + 0), getstat_int(id + 1), getstat_int(id + 2))
#define _STAT(id) g_stat_##id
- #define REGISTER_STAT(id, type) \
- type _STAT(id); \
- REGISTER(Stats, STAT, id, m_id, new(stat)) \
+ #define REGISTER_STAT_2(id, T) \
+ T _STAT(id); \
+ REGISTER(Stats, STAT_##id, m_id, new(stat)) \
{ \
make_pure(this); \
+ if (#T == "vector" || #T == "vectori") { \
+ REGISTRY_RESERVE(Stats, m_id, STAT_##id, y); \
+ REGISTRY_RESERVE(Stats, m_id, STAT_##id, z); \
+ } \
} \
[[accumulate]] void stats_get() \
{ \
- _STAT(id) = getstat_##type(STAT_##id.m_id); \
+ _STAT(id) = getstat_##T(STAT_##id.m_id); \
}
+ #define REGISTER_STAT_3(x, T, expr) REGISTER_STAT(x, T)
#elif defined(SVQC)
/** Add all registered stats, access with `STAT(ID, player)` or `.type stat = _STAT(ID); player.stat` */
void stats_add() {}
#define addstat_int(id, fld) addstat(id, AS_INT, fld)
#define addstat_bool(id, fld) addstat(id, AS_INT, fld)
#define addstat_float(id, fld) addstat(id, AS_FLOAT, fld)
+ #define addstat_vector(id, fld) do { \
+ addstat_float(id + 0, fld##_x); \
+ addstat_float(id + 1, fld##_y); \
+ addstat_float(id + 2, fld##_z); \
+ } while (0)
+ #define addstat_vectori(id, fld) do { \
+ addstat_int(id + 0, fld##_x); \
+ addstat_int(id + 1, fld##_y); \
+ addstat_int(id + 2, fld##_z); \
+ } while (0)
const int AS_STRING = 1;
const int AS_INT = 2;
const int AS_FLOAT = 8;
+ .int __stat_null;
+ /** Prevent engine stats being sent */
+ STATIC_INIT(stats_clear)
+ {
+ int r = 32;
+ for (int i = 0, n = 256 - r; i < n; ++i) {
+ addstat(r + i, AS_INT, __stat_null);
+ }
+ }
+
#define _STAT(id) stat_##id
- #define REGISTER_STAT(id, type) \
- .type _STAT(id); \
- REGISTER(Stats, STAT, id, m_id, new(stat)) \
+ #define REGISTER_STAT_2(id, T) \
+ .T _STAT(id); \
+ REGISTER(Stats, STAT_##id, m_id, new(stat)) \
{ \
make_pure(this); \
+ if (#T == "vector" || #T == "vectori") { \
+ REGISTRY_RESERVE(Stats, m_id, STAT_##id, y); \
+ REGISTRY_RESERVE(Stats, m_id, STAT_##id, z); \
+ } \
} \
[[accumulate]] void stats_add() \
{ \
- addstat_##type(STAT_##id.m_id, _STAT(id)); \
+ addstat_##T(STAT_##id.m_id, _STAT(id)); \
}
+ void GlobalStats_update(entity this) {}
+ #define REGISTER_STAT_3(x, T, expr) \
+ REGISTER_STAT(x, T); \
+ [[accumulate]] void GlobalStats_update(entity this) { STAT(x, this) = (expr); } \
+ STATIC_INIT(worldstat_##x) { entity this = world; STAT(x, this) = (expr); }
#else
- #define REGISTER_STAT(id, type)
+ #define REGISTER_STAT_2(id, type)
+ #define REGISTER_STAT_3(x, T, expr)
#endif
-const int STATS_ENGINE_RESERVE = 32 + (8 * 3); // Not sure how to handle vector stats yet, reserve them too
+const int STATS_ENGINE_RESERVE = 32;
-REGISTRY(Stats, 220 - STATS_ENGINE_RESERVE)
+REGISTRY(Stats, 256 - STATS_ENGINE_RESERVE)
REGISTER_REGISTRY(Stats)
REGISTRY_SORT(Stats)
REGISTRY_CHECK(Stats)
/** requires the same as boxesoverlap, but is a stronger condition */
float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { return smins.x >= bmins.x && smaxs.x <= bmaxs.x && smins.y >= bmins.y && smaxs.y <= bmaxs.y && smins.z >= bmins.z && smaxs.z <= bmaxs.z; }
+#define PITCH(v) ((v).x)
+#define YAW(v) ((v).y)
+#define ROLL(v) ((v).z)
+
+#define MAKEVECTORS(f, angles, forward, right, up) do { \
+ f(angles); \
+ forward = v_forward; \
+ right = v_right; \
+ up = v_up; \
+} while (0)
noref vector _vec2;
#define vec2(v) (_vec2 = (v), _vec2.z = 0, _vec2)
void XonoticPlayerModelSelector_showNotify(entity me)
{
+ // Reinitialize self.
+ me.destroy(me);
me.configureXonoticPlayerModelSelector(me);
}
#endif
// returns 0 for: -1, -sqrt(0.5), 0 (angles that commonly happen with kbd)
}
-void anticheat_physics()
-{SELFPARAM();
+void anticheat_physics(entity this)
+{
float f;
// div0_evade -> SPECTATORS
- makevectors(self.v_angle);
- if(self.anticheat_div0_evade_offset == 0)
+ makevectors(this.v_angle);
+ if(this.anticheat_div0_evade_offset == 0)
{
f = fabs(anticheat_div0_evade_evasion_delta - floor(anticheat_div0_evade_evasion_delta) - 0.5) * 2; // triangle function
- self.anticheat_div0_evade_offset = servertime + sys_frametime * (3 * f - 1);
- self.anticheat_div0_evade_v_angle = self.v_angle;
- self.anticheat_div0_evade_forward_initial = v_forward;
- MEAN_ACCUMULATE(anticheat_div0_evade, 0, 1);
+ this.anticheat_div0_evade_offset = servertime + sys_frametime * (3 * f - 1);
+ this.anticheat_div0_evade_v_angle = this.v_angle;
+ this.anticheat_div0_evade_forward_initial = v_forward;
+ MEAN_ACCUMULATE(this, anticheat_div0_evade, 0, 1);
}
else
{
- if(time < self.anticheat_div0_evade_offset)
- self.anticheat_div0_evade_v_angle = self.v_angle;
- MEAN_ACCUMULATE(anticheat_div0_evade, 0.5 - 0.5 * (self.anticheat_div0_evade_forward_initial * v_forward), 1);
+ if(time < this.anticheat_div0_evade_offset)
+ this.anticheat_div0_evade_v_angle = this.v_angle;
+ MEAN_ACCUMULATE(this, anticheat_div0_evade, 0.5 - 0.5 * (this.anticheat_div0_evade_forward_initial * v_forward), 1);
}
- MEAN_ACCUMULATE(anticheat_div0_strafebot_old, movement_oddity(self.movement, self.anticheat_div0_strafebot_movement_prev), 1);
- self.anticheat_div0_strafebot_movement_prev = self.movement;
+ MEAN_ACCUMULATE(this, anticheat_div0_strafebot_old, movement_oddity(this.movement, this.anticheat_div0_strafebot_movement_prev), 1);
+ this.anticheat_div0_strafebot_movement_prev = this.movement;
// Note: this actually tries to detect snap-aim.
- if(vlen(self.anticheat_div0_strafebot_forward_prev) && time > self.anticheat_fixangle_endtime) {
- float cosangle = self.anticheat_div0_strafebot_forward_prev * v_forward;
+ if(vlen(this.anticheat_div0_strafebot_forward_prev) && time > this.anticheat_fixangle_endtime) {
+ float cosangle = this.anticheat_div0_strafebot_forward_prev * v_forward;
float angle = cosangle < -1 ? M_PI : cosangle > 1 ? 0 : acos(cosangle);
/*
if (angle >= 10 * M_PI / 180)
- printf("SNAP %s: %f for %f, %f since fixangle\n", self.netname, angle * 180 / M_PI, cosangle, time - self.anticheat_fixangle_endtime);
+ printf("SNAP %s: %f for %f, %f since fixangle\n", this.netname, angle * 180 / M_PI, cosangle, time - this.anticheat_fixangle_endtime);
*/
- MEAN_ACCUMULATE(anticheat_div0_strafebot_new, angle / M_PI, 1);
+ MEAN_ACCUMULATE(this, anticheat_div0_strafebot_new, angle / M_PI, 1);
if (autocvar_slowmo > 0) {
// Technically this is a NOP, as the engine should be ensuring
float dt = max(0.001, frametime) / autocvar_slowmo;
float anglespeed = angle / dt;
- MEAN_ACCUMULATE(anticheat_idle_snapaim_signal, anglespeed, dt);
- MEAN_ACCUMULATE(anticheat_idle_snapaim_noise, anglespeed, dt);
- MEAN_ACCUMULATE(anticheat_idle_snapaim_m2, anglespeed, dt);
- MEAN_ACCUMULATE(anticheat_idle_snapaim_m3, anglespeed, dt);
- MEAN_ACCUMULATE(anticheat_idle_snapaim_m4, anglespeed, dt);
- MEAN_ACCUMULATE(anticheat_idle_snapaim_m7, anglespeed, dt);
- MEAN_ACCUMULATE(anticheat_idle_snapaim_m10, anglespeed, dt);
+ MEAN_ACCUMULATE(this, anticheat_idle_snapaim_signal, anglespeed, dt);
+ MEAN_ACCUMULATE(this, anticheat_idle_snapaim_noise, anglespeed, dt);
+ MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m2, anglespeed, dt);
+ MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m3, anglespeed, dt);
+ MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m4, anglespeed, dt);
+ MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m7, anglespeed, dt);
+ MEAN_ACCUMULATE(this, anticheat_idle_snapaim_m10, anglespeed, dt);
}
}
- self.anticheat_div0_strafebot_forward_prev = v_forward;
+ this.anticheat_div0_strafebot_forward_prev = v_forward;
// generic speedhack detection: correlate anticheat_speedhack_movetime (UPDATED BEFORE THIS) and server time
- self.anticheat_speedhack_movetime_frac += frametime;
- f = floor(self.anticheat_speedhack_movetime_frac);
- self.anticheat_speedhack_movetime_frac -= f;
- self.anticheat_speedhack_movetime_count += f;
- self.anticheat_speedhack_movetime = self.anticheat_speedhack_movetime_frac + self.anticheat_speedhack_movetime_count;
- f = self.anticheat_speedhack_movetime - servertime;
- if(self.anticheat_speedhack_offset == 0)
- self.anticheat_speedhack_offset = f;
+ this.anticheat_speedhack_movetime_frac += frametime;
+ f = floor(this.anticheat_speedhack_movetime_frac);
+ this.anticheat_speedhack_movetime_frac -= f;
+ this.anticheat_speedhack_movetime_count += f;
+ this.anticheat_speedhack_movetime = this.anticheat_speedhack_movetime_frac + this.anticheat_speedhack_movetime_count;
+ f = this.anticheat_speedhack_movetime - servertime;
+ if(this.anticheat_speedhack_offset == 0)
+ this.anticheat_speedhack_offset = f;
else
{
- MEAN_ACCUMULATE(anticheat_speedhack, max(0, f - self.anticheat_speedhack_offset), 1);
- self.anticheat_speedhack_offset += (f - self.anticheat_speedhack_offset) * frametime * 0.1;
+ MEAN_ACCUMULATE(this, anticheat_speedhack, max(0, f - this.anticheat_speedhack_offset), 1);
+ this.anticheat_speedhack_offset += (f - this.anticheat_speedhack_offset) * frametime * 0.1;
}
// new generic speedhack detection
- if (self.anticheat_speedhack_lasttime > 0) {
- float dt = servertime - self.anticheat_speedhack_lasttime;
+ if (this.anticheat_speedhack_lasttime > 0) {
+ float dt = servertime - this.anticheat_speedhack_lasttime;
const float falloff = 0.2;
- self.anticheat_speedhack_accu *= exp(-dt * falloff);
- self.anticheat_speedhack_accu += frametime * falloff;
+ this.anticheat_speedhack_accu *= exp(-dt * falloff);
+ this.anticheat_speedhack_accu += frametime * falloff;
// NOTE: at cl_netfps x, this actually averages not to 1, but to 1/x * falloff / (1 - exp(-1/x * falloff))
// For 15 netfps (absolute minimum bearable), and 0.2 falloff, this is: 1.0067
- self.anticheat_speedhack_lasttime = servertime;
- MEAN_ACCUMULATE(anticheat_speedhack_m1, self.anticheat_speedhack_accu, frametime);
- MEAN_ACCUMULATE(anticheat_speedhack_m2, self.anticheat_speedhack_accu, frametime);
- MEAN_ACCUMULATE(anticheat_speedhack_m3, self.anticheat_speedhack_accu, frametime);
- MEAN_ACCUMULATE(anticheat_speedhack_m4, self.anticheat_speedhack_accu, frametime);
- MEAN_ACCUMULATE(anticheat_speedhack_m5, self.anticheat_speedhack_accu, frametime);
+ this.anticheat_speedhack_lasttime = servertime;
+ MEAN_ACCUMULATE(this, anticheat_speedhack_m1, this.anticheat_speedhack_accu, frametime);
+ MEAN_ACCUMULATE(this, anticheat_speedhack_m2, this.anticheat_speedhack_accu, frametime);
+ MEAN_ACCUMULATE(this, anticheat_speedhack_m3, this.anticheat_speedhack_accu, frametime);
+ MEAN_ACCUMULATE(this, anticheat_speedhack_m4, this.anticheat_speedhack_accu, frametime);
+ MEAN_ACCUMULATE(this, anticheat_speedhack_m5, this.anticheat_speedhack_accu, frametime);
} else {
- self.anticheat_speedhack_accu = 1;
- self.anticheat_speedhack_lasttime = servertime;
+ this.anticheat_speedhack_accu = 1;
+ this.anticheat_speedhack_lasttime = servertime;
}
}
return;
// TODO(divVerent): Use xonstat to acquire good thresholds.
GameLogEcho(strcat(":anticheat:_time:", ftos(self.playerid), ":", ftos(servertime - self.anticheat_jointime)));
- GameLogEcho(strcat(":anticheat:speedhack:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack), 240, 0, 9999))); // Actually this one seems broken.
- GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m1), 240, 1.01, 1.25)));
- GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m2), 240, 1.01, 1.25)));
- GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m3), 240, 1.01, 1.25)));
- GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m4), 240, 1.01, 1.25)));
- GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m5), 240, 1.01, 1.25)));
- GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_strafebot_old), 120, 0.15, 0.4)));
- GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_strafebot_new), 120, 0.25, 0.8)));
- GameLogEcho(strcat(":anticheat:div0_evade:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_evade), 120, 0.2, 0.5)));
- GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_signal) - MEAN_EVALUATE(anticheat_idle_snapaim_noise), 120, 0, 9999)));
- GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_signal), 120, 0, 9999)));
- GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_noise), 120, 0, 9999)));
- GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m2), 120, 0, 9999)));
- GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m3), 120, 0, 9999)));
- GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m4), 120, 0, 9999)));
- GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m7), 120, 0, 9999)));
- GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m10), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:speedhack:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack), 240, 0, 9999))); // Actually this one seems broken.
+ GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m1), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m2), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m3), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m4), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_speedhack_m5), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_div0_strafebot_old), 120, 0.15, 0.4)));
+ GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_div0_strafebot_new), 120, 0.25, 0.8)));
+ GameLogEcho(strcat(":anticheat:div0_evade:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_div0_evade), 120, 0.2, 0.5)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_signal) - MEAN_EVALUATE(self, anticheat_idle_snapaim_noise), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_signal), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_noise), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m2), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m3), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m4), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m7), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(self, anticheat_idle_snapaim_m10), 120, 0, 9999)));
}
float anticheat_getvalue(string id)
{SELFPARAM();
switch(id) {
case "_time": return servertime - self.anticheat_jointime;
- case "speedhack": return MEAN_EVALUATE(anticheat_speedhack);
- case "speedhack_m1": return MEAN_EVALUATE(anticheat_speedhack_m1);
- case "speedhack_m2": return MEAN_EVALUATE(anticheat_speedhack_m2);
- case "speedhack_m3": return MEAN_EVALUATE(anticheat_speedhack_m3);
- case "speedhack_m4": return MEAN_EVALUATE(anticheat_speedhack_m4);
- case "speedhack_m5": return MEAN_EVALUATE(anticheat_speedhack_m5);
- case "div0_strafebot_old": return MEAN_EVALUATE(anticheat_div0_strafebot_old);
- case "div0_strafebot_new": return MEAN_EVALUATE(anticheat_div0_strafebot_new);
- case "div0_evade": return MEAN_EVALUATE(anticheat_div0_evade);
- case "idle_snapaim": return MEAN_EVALUATE(anticheat_idle_snapaim_signal) - MEAN_EVALUATE(anticheat_idle_snapaim_noise);
- case "idle_snapaim_signal": return MEAN_EVALUATE(anticheat_idle_snapaim_signal);
- case "idle_snapaim_noise": return MEAN_EVALUATE(anticheat_idle_snapaim_noise);
- case "idle_snapaim_m2": return MEAN_EVALUATE(anticheat_idle_snapaim_m2);
- case "idle_snapaim_m3": return MEAN_EVALUATE(anticheat_idle_snapaim_m3);
- case "idle_snapaim_m4": return MEAN_EVALUATE(anticheat_idle_snapaim_m4);
- case "idle_snapaim_m7": return MEAN_EVALUATE(anticheat_idle_snapaim_m7);
- case "idle_snapaim_m10": return MEAN_EVALUATE(anticheat_idle_snapaim_m10);
+ case "speedhack": return MEAN_EVALUATE(self, anticheat_speedhack);
+ case "speedhack_m1": return MEAN_EVALUATE(self, anticheat_speedhack_m1);
+ case "speedhack_m2": return MEAN_EVALUATE(self, anticheat_speedhack_m2);
+ case "speedhack_m3": return MEAN_EVALUATE(self, anticheat_speedhack_m3);
+ case "speedhack_m4": return MEAN_EVALUATE(self, anticheat_speedhack_m4);
+ case "speedhack_m5": return MEAN_EVALUATE(self, anticheat_speedhack_m5);
+ case "div0_strafebot_old": return MEAN_EVALUATE(self, anticheat_div0_strafebot_old);
+ case "div0_strafebot_new": return MEAN_EVALUATE(self, anticheat_div0_strafebot_new);
+ case "div0_evade": return MEAN_EVALUATE(self, anticheat_div0_evade);
+ case "idle_snapaim": return MEAN_EVALUATE(self, anticheat_idle_snapaim_signal) - MEAN_EVALUATE(self, anticheat_idle_snapaim_noise);
+ case "idle_snapaim_signal": return MEAN_EVALUATE(self, anticheat_idle_snapaim_signal);
+ case "idle_snapaim_noise": return MEAN_EVALUATE(self, anticheat_idle_snapaim_noise);
+ case "idle_snapaim_m2": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m2);
+ case "idle_snapaim_m3": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m3);
+ case "idle_snapaim_m4": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m4);
+ case "idle_snapaim_m7": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m7);
+ case "idle_snapaim_m10": return MEAN_EVALUATE(self, anticheat_idle_snapaim_m10);
}
return -1;
}
void anticheat_report();
void anticheat_shutdown();
-void anticheat_physics();
+void anticheat_physics(entity this);
void anticheat_spectatecopy(entity spectatee);
void anticheat_prethink();
float autocvar_g_balance_contents_drowndelay;
int autocvar_g_balance_contents_playerdamage_drowning;
int autocvar_g_balance_contents_playerdamage_lava;
+int autocvar_g_balance_contents_playerdamage_lava_burn; // 10 is a nice value
+float autocvar_g_balance_contents_playerdamage_lava_burn_time = 2.5; // note: damage is total across this time (not by dps)
int autocvar_g_balance_contents_playerdamage_slime;
int autocvar_g_balance_contents_projectiledamage;
float autocvar_g_balance_damagepush_speedfactor;
bool autocvar_g_waypointeditor;
int autocvar_g_waypointeditor_auto;
bool autocvar_g_waypoints_for_items;
-float autocvar_g_weapon_charge_colormod_blue_full;
-float autocvar_g_weapon_charge_colormod_blue_half;
-float autocvar_g_weapon_charge_colormod_green_full;
-float autocvar_g_weapon_charge_colormod_green_half;
-float autocvar_g_weapon_charge_colormod_hdrmultiplier;
-float autocvar_g_weapon_charge_colormod_red_full;
-float autocvar_g_weapon_charge_colormod_red_half;
#define autocvar_g_weapon_stay cvar("g_weapon_stay")
bool autocvar_g_weapon_throwable;
#define autocvar_g_weaponarena cvar_string("g_weaponarena")
string autocvar_sv_defaultplayermodel_red;
string autocvar_sv_defaultplayermodel_yellow;
int autocvar_sv_defaultplayerskin;
-bool autocvar_sv_dodging_frozen;
+bool autocvar_sv_doublejump;
bool autocvar_sv_eventlog;
bool autocvar_sv_eventlog_console;
bool autocvar_sv_eventlog_files;
======================
*/
-void SpectateCopy(entity spectatee)
-{SELFPARAM();
+void SpectateCopy(entity this, entity spectatee)
+{
MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
self.armortype = spectatee.armortype;
self.armorvalue = spectatee.armorvalue;
return false;
}
- SpectateCopy(self.enemy);
+ SpectateCopy(this, this.enemy);
return true;
}
if(frametime)
{
- if(self.weapon == WEP_VORTEX.m_id && WEP_CVAR(vortex, charge))
- {
- self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
- self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
- self.weaponentity_glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
-
- if(self.vortex_charge > WEP_CVAR(vortex, charge_animlimit))
- {
- self.weaponentity_glowmod_x = self.weaponentity_glowmod.x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
- self.weaponentity_glowmod_y = self.weaponentity_glowmod.y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
- self.weaponentity_glowmod_z = self.weaponentity_glowmod.z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
- }
- }
- else
- self.weaponentity_glowmod = colormapPaletteColor(self.clientcolors & 0x0F, true) * 2;
-
player_powerups();
}
if (!self.crouch)
{
self.crouch = true;
- self.view_ofs = self.stat_pl_crouch_view_ofs;
- setsize (self, self.stat_pl_crouch_min, self.stat_pl_crouch_max);
+ self.view_ofs = STAT(PL_CROUCH_VIEW_OFS, self);
+ setsize (self, STAT(PL_CROUCH_MIN, self), STAT(PL_CROUCH_MAX, self));
// setanim(self, self.anim_duck, false, true, true); // this anim is BROKEN anyway
}
}
{
if (self.crouch)
{
- tracebox(self.origin, self.stat_pl_min, self.stat_pl_max, self.origin, false, self);
+ tracebox(self.origin, STAT(PL_MIN, self), STAT(PL_MAX, self), self.origin, false, self);
if (!trace_startsolid)
{
self.crouch = false;
- self.view_ofs = self.stat_pl_view_ofs;
- setsize (self, self.stat_pl_min, self.stat_pl_max);
+ self.view_ofs = STAT(PL_VIEW_OFS, self);
+ setsize (self, STAT(PL_MIN, self), STAT(PL_MAX, self));
}
}
}
{
self.teamkill_soundtime = 0;
- setself(self.teamkill_soundsource);
- entity oldpusher = self.pusher;
- self.pusher = this;
-
- PlayerSound(playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY);
-
- self.pusher = oldpusher;
- setself(this);
+ entity e = self.teamkill_soundsource;
+ entity oldpusher = e.pusher;
+ e.pusher = this;
+ PlayerSound(e, playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY);
+ e.pusher = oldpusher;
}
if(self.taunt_soundtime)
if(time > self.taunt_soundtime)
{
self.taunt_soundtime = 0;
- PlayerSound(playersound_taunt, CH_VOICE, VOICETYPE_AUTOTAUNT);
+ PlayerSound(self, playersound_taunt, CH_VOICE, VOICETYPE_AUTOTAUNT);
}
target_voicescript_next(self);
self.clip_load = self.clip_size = 0;
}
+void DrownPlayer(entity this)
+{
+ if(this.deadflag != DEAD_NO)
+ return;
+
+ if (this.waterlevel != WATERLEVEL_SUBMERGED)
+ {
+ if(this.air_finished < time)
+ PlayerSound(this, playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ this.air_finished = time + autocvar_g_balance_contents_drowndelay;
+ this.dmg = 2;
+ }
+ else if (this.air_finished < time)
+ { // drown!
+ if (this.pain_finished < time)
+ {
+ Damage (this, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, this.origin, '0 0 0');
+ this.pain_finished = time + 0.5;
+ }
+ }
+}
+
/*
=============
PlayerPostThink
//CheckPlayerJump();
if(IS_PLAYER(self)) {
+ DrownPlayer(self);
CheckRules_Player();
UpdateChatBubble();
if (self.impulse)
float Spectate(entity pl);
+#define SPECTATE_COPY(fld) [[accumulate]] void SpectateCopy(entity this, entity spectatee) { this.(fld) = spectatee.(fld); }
+
#endif
#include "teamplay.qh"
#include "weapons/throwing.qh"
#include "command/common.qh"
+#include "../common/anim.qh"
#include "../common/animdecide.qh"
#include "../common/csqcmodel_settings.qh"
#include "../common/deathtypes/all.qh"
animbits |= ANIMSTATE_DUCK;
animdecide_setstate(self, animbits, false);
animdecide_setimplicitstate(self, (self.flags & FL_ONGROUND));
-
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
- {
- if (self.(weaponentity))
- {
- updateanim(self.(weaponentity));
- if (!self.(weaponentity).animstate_override)
- setanim(self.(weaponentity), self.(weaponentity).anim_idle, true, false, false);
- }
- }
}
void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
// exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two
{
if(deathtype == DEATH_FALL.m_id)
- PlayerSound(playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 75) // TODO make a "gentle" version?
- PlayerSound(playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 50)
- PlayerSound(playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 25)
- PlayerSound(playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
else
- PlayerSound(playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
}
}
}
if(sound_allowed(MSG_BROADCAST, attacker))
{
if(deathtype == DEATH_DROWN.m_id)
- PlayerSound(playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
else
- PlayerSound(playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
}
// get rid of kill indicator
sprint(this, sprintf("Invalid voice. Use one of: %s\n", allvoicesamples));
return;
}
- if (argc >= 3) VoiceMessage(e, substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
- else VoiceMessage(e, "");
+ if (argc >= 3) VoiceMessage(this, e, substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
+ else VoiceMessage(this, e, "");
return;
}
.float strength_finished = _STAT(STRENGTH_FINISHED);
.float invincible_finished = _STAT(INVINCIBLE_FINISHED);
-.float superweapons_finished;
+.float superweapons_finished = _STAT(SUPERWEAPONS_FINISHED);
.float cnt; // used in too many places
.float count;
.float fade_time;
.float fade_rate;
-// weapon animation vectors:
-.vector anim_fire1;
-.vector anim_fire2;
-.vector anim_idle;
-.vector anim_reload;
-
void() player_setupanimsformodel;
-void setanim(entity e, vector anim, float looping, float override, float restart);
.string mdl;
.entity item_pickupsound_ent;
.entity item_model_ent;
-// definitions for weaponsystem
-// more WEAPONTODO: move these to their proper files
-.entity exteriorweaponentity;
-.vector weaponentity_glowmod;
-
-//.int weapon; // current weapon
-.int switchweapon = _STAT(SWITCHWEAPON);
-.int switchingweapon; // weapon currently being switched to (is copied from switchweapon once switch is possible)
-.string weaponname; // name of .weapon
-
// WEAPONTODO
.float autoswitch;
float client_hasweapon(entity cl, float wpn, float andammo, float complain);
.void(Weapon thiswep, entity actor, .entity weaponentity, int fire) weapon_think;
-// weapon states (self.weaponentity.state)
-const int WS_CLEAR = 0; // no weapon selected
-const int WS_RAISE = 1; // raise frame
-const int WS_DROP = 2; // deselecting frame
-const int WS_INUSE = 3; // fire state
-const int WS_READY = 4; // idle frame
-
// there is 2 weapon tics that can run in one server frame
const int W_TICSPERFRAME = 2;
float playerid_last;
.float noalign; // if set to 1, the item or spawnpoint won't be dropped to the floor
-.vector spawnorigin;
-
.vector death_origin;
.vector killer_origin;
.float cvar_cl_clippedspectating;
.float cvar_cl_autoscreenshot;
.float cvar_cl_jetpack_jump;
-.float cvar_cl_movement_track_canjump;
+.float cvar_cl_movement_track_canjump = _STAT(MOVEVARS_CL_TRACK_CANJUMP);
.float cvar_cl_newusekeysupported;
.string cvar_g_xonoticversion;
// WEAPONTODO: remove this
WepSet weaponsInMap;
-.WepSet weaponsinmap;
+#define weapons _STAT(WEAPONS)
+#define weaponsinmap _STAT(WEAPONSINMAP)
.float respawn_countdown; // next number to count
string clientstuff;
.float phase;
-.int pressedkeys;
+.int pressedkeys = _STAT(PRESSED_KEYS);
.string fog;
float game_starttime; //point in time when the countdown to game start is over
float round_starttime; //point in time when the countdown to round start is over
.float stat_game_starttime = _STAT(GAMESTARTTIME);
-.float stat_round_starttime;
+.float stat_round_starttime = _STAT(ROUNDSTARTTIME);
void W_Porto_Remove (entity p);
.string message2;
-.float stat_allow_oldvortexbeam;
+.bool stat_allow_oldvortexbeam = _STAT(ALLOW_OLDVORTEXBEAM);
// reset to 0 on weapon switch
// may be useful to all weapons
.float floodcontrol_voice;
.float floodcontrol_voiceteam;
-.float stat_shotorg; // networked stat for trueaim HUD
+.float stat_shotorg = _STAT(SHOTORG); // networked stat for trueaim HUD
string matchid;
-.float last_pickup;
+.float last_pickup = _STAT(LAST_PICKUP);
-.float hit_time;
-.float typehit_time;
+.float hit_time = _STAT(HIT_TIME);
+.float typehit_time = _STAT(TYPEHIT_TIME);
-.float damage_dealt_total;
+.float damage_dealt_total = _STAT(DAMAGE_DEALT_TOTAL);
-.float stat_leadlimit;
+.float stat_leadlimit = _STAT(LEADLIMIT);
bool radar_showennemies;
.float weapon_load[Weapons_MAX];
.int ammo_none; // used by the reloading system, must always be 0
-.float clip_load;
+.float clip_load = _STAT(WEAPON_CLIPLOAD);
.float old_clip_load;
-.float clip_size;
+.float clip_size = _STAT(WEAPON_CLIPSIZE);
-.float minelayer_mines;
-.float vortex_charge;
+.float minelayer_mines = _STAT(LAYED_MINES);
+.float vortex_charge = _STAT(VORTEX_CHARGE);
.float vortex_charge_rottime;
-.float vortex_chargepool_ammo;
-.float hagar_load;
+.float vortex_chargepool_ammo = _STAT(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
.float player_blocked;
.float weapon_blocked; // weapon use disabled
-.float frozen; // for freeze attacks
-.float revive_progress;
+.float frozen = _STAT(FROZEN); // for freeze attacks
+.float revive_progress = _STAT(REVIVE_PROGRESS);
.float revival_time; // time at which player was last revived
.float revive_speed; // NOTE: multiplier (anything above 1 is instaheal)
.entity iceblock;
.entity muzzle_flash;
.float misc_bulletcounter; // replaces uzi & hlac bullet counter.
-.float stat_respawn_time; // shows respawn time, and is negative when awaiting respawn
+.float stat_respawn_time = _STAT(RESPAWN_TIME); // shows respawn time, and is negative when awaiting respawn
void PlayerUseKey();
return false;
}
-.int buffs; // TODO: remove
+.int buffs = _STAT(BUFFS); // TODO: remove
void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
{
// if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately.
}
-void setanim(entity e, vector anim, float looping, float override, float restart)
-{
- if (!anim)
- return; // no animation was given to us! We can't use this.
-
- if (anim.x == e.animstate_startframe)
- if (anim.y == e.animstate_numframes)
- if (anim.z == e.animstate_framerate)
- {
- if(restart)
- {
- if(restart > 0)
- if(anim.y == 1) // ZYM animation
- BITXOR_ASSIGN(e.effects, EF_RESTARTANIM_BIT);
- }
- else
- return;
- }
- e.animstate_startframe = anim.x;
- e.animstate_numframes = anim.y;
- e.animstate_framerate = anim.z;
- e.animstate_starttime = servertime - 0.1 * serverframetime; // shift it a little bit into the past to prevent float inaccuracy hiccups
- e.animstate_endtime = e.animstate_starttime + e.animstate_numframes / e.animstate_framerate;
- e.animstate_looping = looping;
- e.animstate_override = override;
- e.frame = e.animstate_startframe;
- e.frame1time = servertime;
-}
-
-void updateanim(entity e)
-{
- if (time >= e.animstate_endtime)
- {
- if (e.animstate_looping)
- {
- e.animstate_starttime = e.animstate_endtime;
- e.animstate_endtime = e.animstate_starttime + e.animstate_numframes / e.animstate_framerate;
- }
- e.animstate_override = false;
- }
- e.frame = e.animstate_startframe + bound(0, (time - e.animstate_starttime) * e.animstate_framerate, e.animstate_numframes - 1);
- //print(ftos(time), " -> ", ftos(e.frame), "\n");
-}
-
/*
==================
main
spawnfunc(info_null);
-void setanim(entity e, vector anim, float looping, float override, float restart);
-
-void updateanim(entity e);
-
-
-
/*
==================
SUB_Friction
MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
}
+void __init_dedicated_server_shutdown() {
+ MapInfo_Shutdown();
+}
+
void Map_MarkAsRecent(string m);
float world_already_spawned;
void Nagger_Init();
void ClientInit_Spawn();
void WeaponStats_Init();
void WeaponStats_Shutdown();
-void Physics_AddStats();
spawnfunc(worldspawn)
{
float fd, l, j, n;
WeaponStats_Init();
- WepSet_AddStat();
- WepSet_AddStat_InMap();
- addstat(STAT_SWITCHINGWEAPON, AS_INT, switchingweapon);
- addstat(STAT_ROUNDSTARTTIME, AS_FLOAT, stat_round_starttime);
- addstat(STAT_ALLOW_OLDVORTEXBEAM, AS_INT, stat_allow_oldvortexbeam);
Nagger_Init();
- addstat(STAT_SUPERWEAPONS_FINISHED, AS_FLOAT, superweapons_finished);
- addstat(STAT_PRESSED_KEYS, AS_FLOAT, pressedkeys);
- addstat(STAT_FUEL, AS_INT, ammo_fuel);
- addstat(STAT_PLASMA, AS_INT, ammo_plasma);
- addstat(STAT_SHOTORG, AS_INT, stat_shotorg);
- addstat(STAT_LEADLIMIT, AS_FLOAT, stat_leadlimit);
- addstat(STAT_WEAPON_CLIPLOAD, AS_INT, clip_load);
- addstat(STAT_WEAPON_CLIPSIZE, AS_INT, clip_size);
- addstat(STAT_LAST_PICKUP, AS_FLOAT, last_pickup);
- addstat(STAT_HIT_TIME, AS_FLOAT, hit_time);
- addstat(STAT_DAMAGE_DEALT_TOTAL, AS_INT, damage_dealt_total);
- addstat(STAT_TYPEHIT_TIME, AS_FLOAT, typehit_time);
- addstat(STAT_LAYED_MINES, AS_INT, minelayer_mines);
-
- addstat(STAT_VORTEX_CHARGE, AS_FLOAT, vortex_charge);
- addstat(STAT_VORTEX_CHARGEPOOL, AS_FLOAT, vortex_chargepool_ammo);
-
- addstat(STAT_HAGAR_LOAD, AS_INT, hagar_load);
-
- // freeze attacks
- addstat(STAT_FROZEN, AS_INT, frozen);
- addstat(STAT_REVIVE_PROGRESS, AS_FLOAT, revive_progress);
-
- // physics
- Physics_AddStats();
-
- // new properties
- addstat(STAT_MOVEVARS_JUMPVELOCITY, AS_FLOAT, stat_sv_jumpvelocity);
- addstat(STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, AS_FLOAT, stat_sv_airaccel_qw_stretchfactor);
- addstat(STAT_MOVEVARS_MAXAIRSTRAFESPEED, AS_FLOAT, stat_sv_maxairstrafespeed);
- addstat(STAT_MOVEVARS_MAXAIRSPEED, AS_FLOAT, stat_sv_maxairspeed);
- addstat(STAT_MOVEVARS_AIRSTRAFEACCELERATE, AS_FLOAT, stat_sv_airstrafeaccelerate);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL, AS_FLOAT, stat_sv_warsowbunny_turnaccel);
- addstat(STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, AS_FLOAT, stat_sv_airaccel_sideways_friction);
- addstat(STAT_MOVEVARS_AIRCONTROL, AS_FLOAT, stat_sv_aircontrol);
- addstat(STAT_MOVEVARS_AIRCONTROL_POWER, AS_FLOAT, stat_sv_aircontrol_power);
- addstat(STAT_MOVEVARS_AIRCONTROL_PENALTY, AS_FLOAT, stat_sv_aircontrol_penalty);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, AS_FLOAT, stat_sv_warsowbunny_airforwardaccel);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED, AS_FLOAT, stat_sv_warsowbunny_topspeed);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_ACCEL, AS_FLOAT, stat_sv_warsowbunny_accel);
- addstat(STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, AS_FLOAT, stat_sv_warsowbunny_backtosideratio);
- addstat(STAT_MOVEVARS_FRICTION, AS_FLOAT, stat_sv_friction);
- addstat(STAT_MOVEVARS_ACCELERATE, AS_FLOAT, stat_sv_accelerate);
- addstat(STAT_MOVEVARS_STOPSPEED, AS_FLOAT, stat_sv_stopspeed);
- addstat(STAT_MOVEVARS_AIRACCELERATE, AS_FLOAT, stat_sv_airaccelerate);
- addstat(STAT_MOVEVARS_AIRSTOPACCELERATE, AS_FLOAT, stat_sv_airstopaccelerate);
-
- // secrets
- addstat(STAT_SECRETS_TOTAL, AS_FLOAT, stat_secrets_total);
- addstat(STAT_SECRETS_FOUND, AS_FLOAT, stat_secrets_found);
-
- // monsters
- addstat(STAT_MONSTERS_TOTAL, AS_FLOAT, stat_monsters_total);
- addstat(STAT_MONSTERS_KILLED, AS_FLOAT, stat_monsters_killed);
-
- // misc
- addstat(STAT_RESPAWN_TIME, AS_FLOAT, stat_respawn_time);
-
next_pingtime = time + 5;
detect_maptype();
if(e.(weaponentity))
{
e.(weaponentity).effects = EF_NODRAW;
- if (e.(weaponentity).(weaponentity))
- e.(weaponentity).(weaponentity).effects = EF_NODRAW;
+ if (e.(weaponentity).weaponchild)
+ e.(weaponentity).weaponchild.effects = EF_NODRAW;
}
}
if(IS_REAL_CLIENT(e))
{
stuffcmd(e, "\nscr_printspeed 1000000\n");
- string list = autocvar_sv_intermission_cdtrack;
- for(string it; (it = car(list)); list = cdr(list))
- RandomSelection_Add(world, 0, it, 1, 1);
- if(RandomSelection_chosen_string && RandomSelection_chosen_string != "")
- stuffcmd(e, strcat("\ncd loop ", RandomSelection_chosen_string, "\n"));
+ RandomSelection_Init();
+ FOREACH_WORD(autocvar_sv_intermission_cdtrack, true, LAMBDA(
+ RandomSelection_Add(NULL, 0, it, 1, 1);
+ ));
+ if (RandomSelection_chosen_string != "")
+ {
+ stuffcmd(e, sprintf("\ncd loop %s\n", RandomSelection_chosen_string));
+ }
msg_entity = e;
WriteByte(MSG_ONE, SVC_INTERMISSION);
}
{
LOG_INFO("NOTE: crashed before even initializing the world, not saving persistent data\n");
}
+ else
+ {
+ __init_dedicated_server_shutdown();
+ }
}
string weapon_sound_output;
MUTATOR_HOOKABLE(WeaponSound, EV_WeaponSound);
-/** called when a weapon model is about to be set, allows custom paths etc. */
-#define EV_WeaponModel(i, o) \
- /**/ i(string, weapon_model) \
- /**/ i(string, weapon_model_output) \
- /**/ o(string, weapon_model_output) \
- /**/
-string weapon_model;
-string weapon_model_output;
-MUTATOR_HOOKABLE(WeaponModel, EV_WeaponModel);
-
/** called when an item model is about to be set, allows custom paths etc. */
#define EV_ItemModel(i, o) \
/**/ i(string, item_model) \
string monster_model;
string monster_model_output;
MUTATOR_HOOKABLE(MonsterModel, EV_MonsterModel);
+
+/**/
+#define EV_Player_ChangeTeam(i, o) \
+ /**/ i(entity, __self) \
+ /**/ i(float, pct_curteam) \
+ /**/ i(float, pct_newteam) \
+ /**/
+float pct_curteam;
+float pct_newteam;
+MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam);
#endif
.float lastground;
float total_players;
float redalive, bluealive, yellowalive, pinkalive;
-.float redalive_stat, bluealive_stat, yellowalive_stat, pinkalive_stat;
+.float redalive_stat = _STAT(REDALIVE);
+.float bluealive_stat = _STAT(BLUEALIVE);
+.float yellowalive_stat = _STAT(YELLOWALIVE);
+.float pinkalive_stat = _STAT(PINKALIVE);
#endif
round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart);
round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
- addstat(STAT_REDALIVE, AS_INT, redalive_stat);
- addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
- addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
- addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
-
EliminatedPlayers_Init(ca_isEliminated);
}
#define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))
// networked flag statuses
-.int ctf_flagstatus;
+.int ctf_flagstatus = _STAT(CTF_FLAGSTATUS);
#endif
const int CTF_RED_FLAG_TAKEN = 1;
}
else if(CTF_SAMETEAM(toucher, flag) && (toucher.flagcarried) && DIFF_TEAM(toucher.flagcarried, flag) && is_not_monster)
ctf_Handle_Capture(flag, toucher, CAPTURE_NORMAL); // toucher just captured the enemies flag to his base
+ else if(CTF_DIFFTEAM(toucher, flag) && (toucher.flagcarried) && CTF_SAMETEAM(toucher.flagcarried, toucher) && (!toucher.ctf_captureshielded) && autocvar_g_ctf_flag_return_carrying && (time > toucher.next_take_time) && is_not_monster)
+ {
+ ctf_Handle_Return(toucher.flagcarried, toucher); // return their current flag
+ ctf_Handle_Pickup(flag, toucher, PICKUP_BASE); // now pickup the flag
+ }
else if(CTF_DIFFTEAM(toucher, flag) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time) && is_not_monster)
ctf_Handle_Pickup(flag, toucher, PICKUP_BASE); // toucher just stole the enemies flag
break;
// if no teams are found, spawn defaults
if(find(world, classname, "ctf_team") == world)
{
- LOG_INFO("No ""ctf_team"" entities found on this map, creating them anyway.\n");
+ LOG_INFO("No \"ctf_team\" entities found on this map, creating them anyway.\n");
ctf_SpawnTeam("Red", NUM_TEAM_1 - 1);
ctf_SpawnTeam("Blue", NUM_TEAM_2 - 1);
if(ctf_teams >= 3)
ctf_captureshield_max_ratio = autocvar_g_ctf_shield_max_ratio;
ctf_captureshield_force = autocvar_g_ctf_shield_force;
- addstat(STAT_CTF_FLAGSTATUS, AS_INT, ctf_flagstatus);
-
InitializeEntity(world, ctf_DelayedInit, INITPRIO_GAMETYPE);
}
const float SP_DOM_CAPS = 4;
// pps: points per second
-.float dom_total_pps;
-.float dom_pps_red;
-.float dom_pps_blue;
-.float dom_pps_yellow;
-.float dom_pps_pink;
+.float dom_total_pps = _STAT(DOM_TOTAL_PPS);
+.float dom_pps_red = _STAT(DOM_PPS_RED);
+.float dom_pps_blue = _STAT(DOM_PPS_BLUE);
+.float dom_pps_yellow = _STAT(DOM_PPS_YELLOW);
+.float dom_pps_pink = _STAT(DOM_PPS_PINK);
float total_pps;
float pps_red;
float pps_blue;
// if no teams are found, spawn defaults
if(find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2)
{
- LOG_INFO("No ""dom_team"" entities found on this map, creating them anyway.\n");
+ LOG_INFO("No \"dom_team\" entities found on this map, creating them anyway.\n");
domination_teams = bound(2, ((autocvar_g_domination_teams_override < 2) ? autocvar_g_domination_default_teams : autocvar_g_domination_teams_override), 4);
dom_spawnteams(domination_teams);
}
CheckAllowedTeams(world);
domination_teams = ((c4>=0) ? 4 : (c3>=0) ? 3 : 2);
- addstat(STAT_DOM_TOTAL_PPS, AS_FLOAT, dom_total_pps);
- addstat(STAT_DOM_PPS_RED, AS_FLOAT, dom_pps_red);
- addstat(STAT_DOM_PPS_BLUE, AS_FLOAT, dom_pps_blue);
- if(domination_teams >= 3) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow);
- if(domination_teams >= 4) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink);
-
domination_roundbased = autocvar_g_domination_roundbased;
ScoreRules_dom(domination_teams);
round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null);
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
- addstat(STAT_REDALIVE, AS_INT, redalive_stat);
- addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
- addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
- addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
-
EliminatedPlayers_Init(freezetag_isEliminated);
}
// if no teams are found, spawn defaults
if(find(world, classname, "tdm_team") == world)
{
- LOG_INFO("No ""tdm_team"" entities found on this map, creating them anyway.\n");
+ LOG_INFO("No \"tdm_team\" entities found on this map, creating them anyway.\n");
int numteams = min(4, autocvar_g_tdm_teams_override);
{SELFPARAM();
self.(f) = stof(fgets(self.playerdemo_fh));
}
-float playerdemo_read()
-{SELFPARAM();
- if(self.playerdemo_mode != PLAYERDEMO_MODE_READING)
+float playerdemo_read(entity this)
+{
+ if(this.playerdemo_mode != PLAYERDEMO_MODE_READING)
return 0;
- if(self.playerdemo_time < 0)
+ if(this.playerdemo_time < 0)
return 1;
float t;
t = time;
- while(time >= self.playerdemo_time)
+ while(time >= this.playerdemo_time)
{
PLAYERDEMO_FIELDS(playerdemo_read_)
{
- time = self.playerdemo_time;
- PlayerPreThink();
+ time = this.playerdemo_time;
+ WITH(entity, self, this, PlayerPreThink());
// not running physics though... this is just so we can run weapon stuff
- PlayerPostThink();
+ WITH(entity, self, this, PlayerPostThink());
}
- self.playerdemo_time = stof(fgets(self.playerdemo_fh));
- if(self.playerdemo_time == 0)
+ this.playerdemo_time = stof(fgets(this.playerdemo_fh));
+ if(this.playerdemo_time == 0)
{
- self.playerdemo_time = -1;
+ this.playerdemo_time = -1;
return 1;
}
- self.playerdemo_time += self.playerdemo_starttime;
+ this.playerdemo_time += this.playerdemo_starttime;
}
- self.velocity = '0 0 0';
+ this.velocity = '0 0 0';
time = t;
return 1;
}
void playerdemo_init();
void playerdemo_shutdown();
void playerdemo_write();
-float playerdemo_read();
+float playerdemo_read(entity this);
void playerdemo_open_read(string f);
void playerdemo_open_write(string f);
#include "weapons/weaponstats.qc"
#include "weapons/weaponsystem.qc"
+#include "../common/anim.qc"
#include "../common/animdecide.qc"
#include "../common/campaign_file.qc"
#include "../common/campaign_setup.qc"
if(fullstatus)
{
s = GetPlayerScoreString(p, 1);
- if(IS_REAL_CLIENT(p))
- s = strcat(s, ":human");
- else
- s = strcat(s, ":bot");
+ s = strcat(s, IS_REAL_CLIENT(p) ? ":human" : ":bot");
+ ret_string = string_null;
if(!IS_PLAYER(p) && !MUTATOR_CALLHOOK(GetPlayerStatus, p, s))
s = strcat(s, ":spectator");
- s = strcat(s, ret_string);
+ if (ret_string) s = strcat(s, ret_string);
}
else
{
- if(IS_PLAYER(p) || MUTATOR_CALLHOOK(GetPlayerStatus, p, s))
+ ret_string = string_null;
+ if (IS_PLAYER(p) || MUTATOR_CALLHOOK(GetPlayerStatus, p, s))
s = GetPlayerScoreString(p, 2);
else
s = "-666";
- s = strcat(s, ret_string);
+ if (ret_string) s = strcat(s, ret_string);
}
if(p.clientstatus)
.float lastground;
.int state;
-void CreatureFrame ()
-{SELFPARAM();
- float dm;
-
- for(entity e = world; (e = findfloat(e, damagedbycontents, true)); )
+void CreatureFrame_hotliquids(entity this)
+{
+ if (this.dmgtime < time)
{
- setself(e);
- if (self.movetype == MOVETYPE_NOCLIP) { continue; }
-
- float vehic = IS_VEHICLE(self);
- float projectile = (self.flags & FL_PROJECTILE);
- float monster = IS_MONSTER(self);
+ this.dmgtime = time + autocvar_g_balance_contents_damagerate;
- if (self.watertype <= CONTENT_WATER && self.waterlevel > 0) // workaround a retarded bug made by id software :P (yes, it's that old of a bug)
+ if (this.flags & FL_PROJECTILE)
{
- if (!(self.flags & FL_INWATER))
- {
- self.flags |= FL_INWATER;
- self.dmgtime = 0;
- }
-
- if(!vehic && !projectile && !monster) // vehicles, monsters and projectiles don't drown
+ if (this.watertype == CONTENT_LAVA)
+ Damage (this, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * this.waterlevel, DEATH_LAVA.m_id, this.origin, '0 0 0');
+ else if (this.watertype == CONTENT_SLIME)
+ Damage (this, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * this.waterlevel, DEATH_SLIME.m_id, this.origin, '0 0 0');
+ }
+ else
+ {
+ if (this.watertype == CONTENT_LAVA)
{
- if (self.waterlevel != WATERLEVEL_SUBMERGED)
+ if (this.watersound_finished < time)
{
- if(self.air_finished < time)
- PlayerSound(playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
- self.air_finished = time + autocvar_g_balance_contents_drowndelay;
- self.dmg = 2;
- }
- else if (self.air_finished < time)
- { // drown!
- if (!self.deadflag)
- if (self.pain_finished < time)
- {
- Damage (self, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, self.origin, '0 0 0');
- self.pain_finished = time + 0.5;
- }
+ this.watersound_finished = time + 0.5;
+ sound (this, CH_PLAYER_SINGLE, SND_LAVA, VOL_BASE, ATTEN_NORM);
}
+ Damage (this, world, world, autocvar_g_balance_contents_playerdamage_lava * autocvar_g_balance_contents_damagerate * this.waterlevel, DEATH_LAVA.m_id, this.origin, '0 0 0');
+ if(autocvar_g_balance_contents_playerdamage_lava_burn)
+ Fire_AddDamage(this, world, autocvar_g_balance_contents_playerdamage_lava_burn * this.waterlevel, autocvar_g_balance_contents_playerdamage_lava_burn_time * this.waterlevel, DEATH_LAVA.m_id);
}
-
- if (self.dmgtime < time)
+ else if (this.watertype == CONTENT_SLIME)
{
- self.dmgtime = time + autocvar_g_balance_contents_damagerate;
-
- if (projectile)
- {
- if (self.watertype == CONTENT_LAVA)
- {
- Damage (self, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_LAVA.m_id, self.origin, '0 0 0');
- }
- else if (self.watertype == CONTENT_SLIME)
- {
- Damage (self, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME.m_id, self.origin, '0 0 0');
- }
- }
- else
+ if (this.watersound_finished < time)
{
- if (self.watertype == CONTENT_LAVA)
- {
- if (self.watersound_finished < time)
- {
- self.watersound_finished = time + 0.5;
- sound (self, CH_PLAYER_SINGLE, SND_LAVA, VOL_BASE, ATTEN_NORM);
- }
- Damage (self, world, world, autocvar_g_balance_contents_playerdamage_lava * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_LAVA.m_id, self.origin, '0 0 0');
- }
- else if (self.watertype == CONTENT_SLIME)
- {
- if (self.watersound_finished < time)
- {
- self.watersound_finished = time + 0.5;
- sound (self, CH_PLAYER_SINGLE, SND_SLIME, VOL_BASE, ATTEN_NORM);
- }
- Damage (self, world, world, autocvar_g_balance_contents_playerdamage_slime * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME.m_id, self.origin, '0 0 0');
- }
+ this.watersound_finished = time + 0.5;
+ sound (this, CH_PLAYER_SINGLE, SND_SLIME, VOL_BASE, ATTEN_NORM);
}
+ Damage (this, world, world, autocvar_g_balance_contents_playerdamage_slime * autocvar_g_balance_contents_damagerate * this.waterlevel, DEATH_SLIME.m_id, this.origin, '0 0 0');
}
}
- else
+ }
+}
+
+void CreatureFrame_Liquids(entity this)
+{
+ if (this.watertype <= CONTENT_WATER && this.waterlevel > 0) // workaround a retarded bug made by id software :P (yes, it's that old of a bug)
+ {
+ if (!(this.flags & FL_INWATER))
{
- if (self.flags & FL_INWATER)
- {
- // play leave water sound
- self.flags &= ~FL_INWATER;
- self.dmgtime = 0;
- }
- self.air_finished = time + 12;
- self.dmg = 2;
+ this.flags |= FL_INWATER;
+ this.dmgtime = 0;
}
- if(!vehic && !projectile) // vehicles don't get falling damage
+ CreatureFrame_hotliquids(this);
+ }
+ else
+ {
+ if (this.flags & FL_INWATER)
{
- // check for falling damage
- float velocity_len = vlen(self.velocity);
- if(!self.hook.state)
- {
- dm = vlen(self.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
- if (self.deadflag)
- dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor;
- else
- dm = min((dm - autocvar_g_balance_falldamage_minspeed) * autocvar_g_balance_falldamage_factor, autocvar_g_balance_falldamage_maxdamage);
- if (dm > 0)
- Damage (self, world, world, dm, DEATH_FALL.m_id, self.origin, '0 0 0');
- }
+ // play leave water sound
+ this.flags &= ~FL_INWATER;
+ this.dmgtime = 0;
+ }
+ this.air_finished = time + 12;
+ this.dmg = 2;
+ }
+}
- if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
- Damage (self, world, world, 100000, DEATH_SHOOTING_STAR.m_id, self.origin, '0 0 0');
- // play stupid sounds
- if (g_footsteps)
- if (!gameover)
- if (self.flags & FL_ONGROUND)
- if (!self.crouch)
- if (velocity_len > autocvar_sv_maxspeed * 0.6)
- if (!self.deadflag)
- if (time < self.lastground + 0.2)
- {
- if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
- {
- self.nextstep = time + 0.3 + random() * 0.1;
- trace_dphitq3surfaceflags = 0;
- tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
- /*
- if(trace_fraction == 1)
- dprint("nohit\n");
- else
- dprint(ftos(trace_dphitq3surfaceflags), "\n");
- */
- if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
- {
- if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
- GlobalSound(GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
- else
- GlobalSound(GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND);
- }
- }
- }
+void CreatureFrame_FallDamage(entity this)
+{
+ if(!IS_VEHICLE(this) && !(this.flags & FL_PROJECTILE)) // vehicles don't get falling damage
+ {
+ // check for falling damage
+ float velocity_len = vlen(this.velocity);
+ if(!this.hook.state)
+ {
+ float dm = vlen(this.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
+ if (this.deadflag)
+ dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor;
+ else
+ dm = min((dm - autocvar_g_balance_falldamage_minspeed) * autocvar_g_balance_falldamage_factor, autocvar_g_balance_falldamage_maxdamage);
+ if (dm > 0)
+ Damage (this, world, world, dm, DEATH_FALL.m_id, this.origin, '0 0 0');
}
- self.oldvelocity = self.velocity;
+ if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
+ Damage (this, world, world, 100000, DEATH_SHOOTING_STAR.m_id, this.origin, '0 0 0');
+ }
+}
+
+void CreatureFrame_All()
+{
+ for(entity e = world; (e = findfloat(e, damagedbycontents, true)); )
+ {
+ if (e.movetype == MOVETYPE_NOCLIP) { continue; }
+
+ CreatureFrame_Liquids(e);
+ CreatureFrame_FallDamage(e);
+
+ e.oldvelocity = e.velocity;
}
- setself(this);
}
game_delay_last = game_delay;
- CreatureFrame();
+ CreatureFrame_All();
CheckRules_World();
// if in warmup stage and limit for warmup is hit start match
bot_serverframe();
anticheat_startframe();
MUTATOR_CALLHOOK(SV_StartFrame);
+ {
+ entity e;
+ FOR_EACH_CLIENT(e)
+ {
+ GlobalStats_update(e);
+ }
+ }
}
.vector originjitter;
{
if(self.gravity)
{
- Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+ Movetype_Physics_MatchServer(self, autocvar_cl_projectiles_sloppy);
if(self.move_flags & FL_ONGROUND)
{ // For some reason move_avelocity gets set to '0 0 0' here ...
self.oldorigin = self.origin;
{
if(self.gravity)
{
- Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+ Movetype_Physics_MatchServer(self, autocvar_cl_projectiles_sloppy);
if(self.move_flags & FL_ONGROUND)
self.gravity = 0;
self.drawmask = MASK_NORMAL;
}
+void ItemRemove()
+{SELFPARAM();
+ if (self.mdl)
+ strunzone(self.mdl);
+}
+
NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
{
int sf = ReadByte();
if(self.ItemStatus & ITS_ANIMATE2)
self.move_avelocity = '0 -90 0';
}
+
+ self.entremove = ItemRemove;
+
return true;
}
if(!IS_CLIENT(self))
Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_CONNECTING, self.netname);
+ MUTATOR_CALLHOOK(Player_ChangeTeam, self, steam, dteam);
+
SetPlayerTeam(self, dteam, steam, !IS_CLIENT(self));
if(IS_PLAYER(self) && steam != dteam)
}
// update accuracy stats
-.float hit_time;
+//.float hit_time;
.float fired_time;
void accuracy_add(entity this, int w, int fired, int hit)
if (!this.respawntime)
{
- if (e.weapons & WEPSET_SUPERWEAPONS)
+ if (e.spawnflags & WEP_FLAG_SUPERWEAPON)
{
this.respawntime = g_pickup_respawntime_superweapon;
this.respawntimejitter = g_pickup_respawntimejitter_superweapon;
}
}
- if (e.weapons & WEPSET_SUPERWEAPONS)
+ if (e.spawnflags & WEP_FLAG_SUPERWEAPON)
if (!this.superweapons_finished)
+ {
this.superweapons_finished = autocvar_g_balance_superweapons_time;
+ LOG_INFO("Setting it to ", ftos(this.superweapons_finished), " on ", e.mdl, "\n");
+ }
// if we don't already have ammo, give us some ammo
if (!this.(e.ammo_field))
#include "../../common/weapons/all.qh"
#include "../../lib/csqcmodel/sv_model.qh"
-vector shotorg_adjustfromclient(vector vecs, float y_is_right, float algn)
-{
- switch (algn)
- {
- default: case 3: break; // right alignment
- case 4: vecs.y = -vecs.y;
- break; // left
- case 1: case 2: vecs.y = 0;
- vecs.z -= 2;
- break; // center
- }
-
- return vecs;
-}
-
-vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn)
-{
- string s;
-
- if (visual)
- {
- vecs = shotorg_adjustfromclient(vecs, y_is_right, algn);
- }
- else if (autocvar_g_shootfromeye)
- {
- vecs.y = vecs.z = 0;
- }
- else if (autocvar_g_shootfromcenter)
- {
- vecs.y = 0;
- vecs.z -= 2;
- }
- else if ((s = autocvar_g_shootfromfixedorigin) != "")
- {
- vector v = stov(s);
- if (y_is_right) v.y = -v.y;
- if (v.x != 0) vecs.x = v.x;
- vecs.y = v.y;
- vecs.z = v.z;
- }
- else // just do the same as top
- {
- vecs = shotorg_adjustfromclient(vecs, y_is_right, algn);
- }
-
- return vecs;
-}
-
-vector shotorg_adjust(vector vecs, bool y_is_right, bool visual, int algn)
-{
- return shotorg_adjust_values(vecs, y_is_right, visual, algn);
-}
-
.int state;
.float weapon_frametime;
}
-void weapon_thinkf(entity actor, .entity weaponentity, float fr, float t, void(Weapon thiswep, entity actor,
- .entity weaponentity, int fire) func);
-
bool CL_Weaponentity_CustomizeEntityForClient()
{
SELFPARAM();
return true;
}
-/*
- * supported formats:
- *
- * 1. simple animated model, muzzle flash handling on h_ model:
- * h_tuba.dpm, h_tuba.dpm.framegroups - invisible model controlling the animation
- * tags:
- * shot = muzzle end (shot origin, also used for muzzle flashes)
- * shell = casings ejection point (must be on the right hand side of the gun)
- * weapon = attachment for v_tuba.md3
- * v_tuba.md3 - first and third person model
- * g_tuba.md3 - pickup model
- *
- * 2. simple animated model, muzzle flash handling on v_ model:
- * h_tuba.dpm, h_tuba.dpm.framegroups - invisible model controlling the animation
- * tags:
- * weapon = attachment for v_tuba.md3
- * v_tuba.md3 - first and third person model
- * tags:
- * shot = muzzle end (shot origin, also used for muzzle flashes)
- * shell = casings ejection point (must be on the right hand side of the gun)
- * g_tuba.md3 - pickup model
- *
- * 3. fully animated model, muzzle flash handling on h_ model:
- * h_tuba.dpm, h_tuba.dpm.framegroups - animated first person model
- * tags:
- * shot = muzzle end (shot origin, also used for muzzle flashes)
- * shell = casings ejection point (must be on the right hand side of the gun)
- * handle = corresponding to the origin of v_tuba.md3 (used for muzzle flashes)
- * v_tuba.md3 - third person model
- * g_tuba.md3 - pickup model
- *
- * 4. fully animated model, muzzle flash handling on v_ model:
- * h_tuba.dpm, h_tuba.dpm.framegroups - animated first person model
- * tags:
- * shot = muzzle end (shot origin)
- * shell = casings ejection point (must be on the right hand side of the gun)
- * v_tuba.md3 - third person model
- * tags:
- * shot = muzzle end (for muzzle flashes)
- * g_tuba.md3 - pickup model
- */
-
-// writes:
-// this.origin, this.angles
-// this.weaponentity
-// this.movedir, this.view_ofs
-// attachment stuff
-// anim stuff
-// to free:
-// call again with ""
-// remove the ent
-void CL_WeaponEntity_SetModel(entity this, .entity weaponentity, string name)
-{
- if (name != "")
- {
- // if there is a child entity, hide it until we're sure we use it
- if (this.(weaponentity)) this.(weaponentity).model = "";
- _setmodel(this, W_Model(strcat("v_", name, ".md3")));
- int v_shot_idx = gettagindex(this, "shot"); // used later
- if (!v_shot_idx) v_shot_idx = gettagindex(this, "tag_shot");
-
- _setmodel(this, W_Model(strcat("h_", name, ".iqm")));
- // preset some defaults that work great for renamed zym files (which don't need an animinfo)
- this.anim_fire1 = animfixfps(this, '0 1 0.01', '0 0 0');
- this.anim_fire2 = animfixfps(this, '1 1 0.01', '0 0 0');
- this.anim_idle = animfixfps(this, '2 1 0.01', '0 0 0');
- this.anim_reload = animfixfps(this, '3 1 0.01', '0 0 0');
-
- // if we have a "weapon" tag, let's attach the v_ model to it ("invisible hand" style model)
- // if we don't, this is a "real" animated model
- if (gettagindex(this, "weapon"))
- {
- if (!this.(weaponentity)) this.(weaponentity) = new(weaponentity);
- _setmodel(this.(weaponentity), W_Model(strcat("v_", name, ".md3")));
- setattachment(this.(weaponentity), this, "weapon");
- }
- else if (gettagindex(this, "tag_weapon"))
- {
- if (!this.(weaponentity)) this.(weaponentity) = new(weaponentity);
- _setmodel(this.(weaponentity), W_Model(strcat("v_", name, ".md3")));
- setattachment(this.(weaponentity), this, "tag_weapon");
- }
- else
- {
- if (this.(weaponentity)) remove(this.(weaponentity));
- this.(weaponentity) = NULL;
- }
-
- setorigin(this, '0 0 0');
- this.angles = '0 0 0';
- this.frame = 0;
- this.viewmodelforclient = NULL;
-
- float idx;
-
- if (v_shot_idx) // v_ model attached to invisible h_ model
- {
- this.movedir = gettaginfo(this.(weaponentity), v_shot_idx);
- }
- else
- {
- idx = gettagindex(this, "shot");
- if (!idx) idx = gettagindex(this, "tag_shot");
- if (idx)
- {
- this.movedir = gettaginfo(this, idx);
- }
- else
- {
- LOG_INFO("WARNING: weapon model ", this.model,
- " does not support the 'shot' tag, will display shots TOTALLY wrong\n");
- this.movedir = '0 0 0';
- }
- }
-
- if (this.(weaponentity)) // v_ model attached to invisible h_ model
- {
- idx = gettagindex(this.(weaponentity), "shell");
- if (!idx) idx = gettagindex(this.(weaponentity), "tag_shell");
- if (idx) this.spawnorigin = gettaginfo(this.(weaponentity), idx);
- }
- else
- {
- idx = 0;
- }
- if (!idx)
- {
- idx = gettagindex(this, "shell");
- if (!idx) idx = gettagindex(this, "tag_shell");
- if (idx)
- {
- this.spawnorigin = gettaginfo(this, idx);
- }
- else
- {
- LOG_INFO("WARNING: weapon model ", this.model,
- " does not support the 'shell' tag, will display casings wrong\n");
- this.spawnorigin = this.movedir;
- }
- }
-
- if (v_shot_idx)
- {
- this.oldorigin = '0 0 0'; // use regular attachment
- }
- else
- {
- if (this.(weaponentity))
- {
- idx = gettagindex(this, "weapon");
- if (!idx) idx = gettagindex(this, "tag_weapon");
- }
- else
- {
- idx = gettagindex(this, "handle");
- if (!idx) idx = gettagindex(this, "tag_handle");
- }
- if (idx)
- {
- this.oldorigin = this.movedir - gettaginfo(this, idx);
- }
- else
- {
- LOG_INFO("WARNING: weapon model ", this.model,
- " does not support the 'handle' tag and neither does the v_ model support the 'shot' tag, will display muzzle flashes TOTALLY wrong\n");
- this.oldorigin = '0 0 0'; // there is no way to recover from this
- }
- }
-
- this.viewmodelforclient = this.owner;
- }
- else
- {
- this.model = "";
- if (this.(weaponentity)) remove(this.(weaponentity));
- this.(weaponentity) = NULL;
- this.movedir = '0 0 0';
- this.spawnorigin = '0 0 0';
- this.oldorigin = '0 0 0';
- this.anim_fire1 = '0 1 0.01';
- this.anim_fire2 = '0 1 0.01';
- this.anim_idle = '0 1 0.01';
- this.anim_reload = '0 1 0.01';
- }
-
- this.view_ofs = '0 0 0';
-
- if (this.movedir.x >= 0)
- {
- vector v0 = this.movedir;
- this.movedir = shotorg_adjust(v0, false, false, this.owner.cvar_cl_gunalign);
- this.view_ofs = shotorg_adjust(v0, false, true, this.owner.cvar_cl_gunalign) - v0;
- }
- this.owner.stat_shotorg = compressShotOrigin(this.movedir);
- this.movedir = decompressShotOrigin(this.owner.stat_shotorg); // make them match perfectly
-
- this.spawnorigin += this.view_ofs; // offset the casings origin by the same amount
-
- // check if an instant weapon switch occurred
- setorigin(this, this.view_ofs);
- // reset animstate now
- this.wframe = WFRAME_IDLE;
- setanim(this, this.anim_idle, true, false, true);
-}
-
-vector CL_Weapon_GetShotOrg(float wpn)
+vector CL_Weapon_GetShotOrg(int wpn)
{
entity wi = Weapons_from(wpn);
entity e = spawn();
- .entity weaponentity = weaponentities[0];
- CL_WeaponEntity_SetModel(e, weaponentity, wi.mdl);
+ CL_WeaponEntity_SetModel(e, wi.mdl);
vector ret = e.movedir;
- CL_WeaponEntity_SetModel(e, weaponentity, "");
+ CL_WeaponEntity_SetModel(e, "");
remove(e);
return ret;
}
..entity weaponentity_fld;
+.float m_alpha;
void CL_Weaponentity_Think()
{
.entity weaponentity = this.weaponentity_fld;
if (this.owner.(weaponentity) != this)
{
- if (this.(weaponentity)) remove(this.(weaponentity));
+ // owner has new gun; remove self
+ if (this.weaponchild) remove(this.weaponchild);
remove(this);
return;
}
if (this.owner.deadflag != DEAD_NO)
{
+ // owner died; disappear
this.model = "";
- if (this.(weaponentity)) this.(weaponentity).model = "";
+ if (this.weaponchild) this.weaponchild.model = "";
return;
}
- if (this.weaponname != this.owner.weaponname || this.dmg != this.owner.modelindex
+ if (this.weaponname != this.owner.weaponname
+ || this.dmg != this.owner.modelindex
|| this.deadflag != this.owner.deadflag)
{
+ // owner changed weapons; update appearance
this.weaponname = this.owner.weaponname;
this.dmg = this.owner.modelindex;
this.deadflag = this.owner.deadflag;
- CL_WeaponEntity_SetModel(this, weaponentity, this.owner.weaponname);
+ CL_WeaponEntity_SetModel(this, this.owner.weaponname);
}
- int tb = (this.effects & (EF_TELEPORT_BIT | EF_RESTARTANIM_BIT));
- this.effects = this.owner.effects & EFMASK_CHEAP;
- this.effects &= ~EF_LOWPRECISION;
- this.effects &= ~EF_FULLBRIGHT; // can mask team color, so get rid of it
- this.effects &= ~EF_TELEPORT_BIT;
- this.effects &= ~EF_RESTARTANIM_BIT;
- this.effects |= tb;
- if (weaponentity != weaponentities[0]) this.effects |= EF_NODRAW;
+ this.alpha = -1; // TODO: don't render this entity at all
- if (this.owner.alpha == default_player_alpha) this.alpha = default_weapon_alpha;
- else if (this.owner.alpha != 0) this.alpha = this.owner.alpha;
- else this.alpha = 1;
+ if (this.owner.alpha == default_player_alpha) this.m_alpha = default_weapon_alpha;
+ else if (this.owner.alpha != 0) this.m_alpha = this.owner.alpha;
+ else this.m_alpha = 1;
- this.glowmod = this.owner.weaponentity_glowmod;
- this.colormap = this.owner.colormap;
- if (this.(weaponentity))
- {
- this.(weaponentity).effects = this.effects;
- this.(weaponentity).alpha = this.alpha;
- this.(weaponentity).colormap = this.colormap;
- this.(weaponentity).glowmod = this.glowmod;
- }
-
- this.angles = '0 0 0';
-
- float f = this.weapon_nextthink - time;
- if (this.state == WS_RAISE && !intermission_running)
- {
- entity newwep = Weapons_from(this.owner.switchweapon);
- f = f * g_weaponratefactor / max(f, newwep.switchdelay_raise);
- this.angles_x = -90 * f * f;
- }
- else if (this.state == WS_DROP && !intermission_running)
- {
- entity oldwep = Weapons_from(this.owner.weapon);
- f = 1 - f * g_weaponratefactor / max(f, oldwep.switchdelay_drop);
- this.angles_x = -90 * f * f;
- }
- else if (this.state == WS_CLEAR)
+ if (this.weaponchild)
{
- f = 1;
- this.angles_x = -90 * f * f;
+ this.weaponchild.alpha = this.alpha;
+ this.weaponchild.effects = this.effects;
}
}
}
// spawning weaponentity for client
-void CL_SpawnWeaponentity(entity e, .entity weaponentity)
+void CL_SpawnWeaponentity(entity actor, .entity weaponentity)
{
- entity view = e.(weaponentity) = new(weaponentity);
+ entity view = actor.(weaponentity) = new(weaponentity);
make_pure(view);
view.solid = SOLID_NOT;
- view.owner = e;
+ view.owner = actor;
setmodel(view, MDL_Null); // precision set when changed
setorigin(view, '0 0 0');
- view.angles = '0 0 0';
- view.viewmodelforclient = e;
- view.flags = 0;
view.weaponentity_fld = weaponentity;
view.think = CL_Weaponentity_Think;
- view.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
view.nextthink = time;
+ view.viewmodelforclient = actor;
+ view.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
if (weaponentity == weaponentities[0])
{
- entity exterior = e.exteriorweaponentity = new(exteriorweaponentity);
+ entity exterior = actor.exteriorweaponentity = new(exteriorweaponentity);
make_pure(exterior);
exterior.solid = SOLID_NOT;
- exterior.exteriorweaponentity = exterior;
- exterior.owner = e;
+ exterior.owner = actor;
setorigin(exterior, '0 0 0');
- exterior.angles = '0 0 0';
exterior.think = CL_ExteriorWeaponentity_Think;
exterior.nextthink = time;
if (mine.owner == actor) return false;
if (thiswep == WEP_SHOTGUN)
- if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow
+ if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow
if (thiswep == Weapons_from(actor.switchweapon) && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
{
return false;
}
-void weapon_thinkf(entity actor, .entity weaponentity, float fr, float t, void(Weapon thiswep, entity actor,
+void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim);
+
+/**
+ * @param t defer thinking until time + t
+ * @param func next think function
+ */
+void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,
.entity weaponentity, int fire) func)
{
entity this = actor.(weaponentity);
fr = this.wframe;
restartanim = false;
}
- else if (fr == WFRAME_IDLE)
- {
- restartanim = false;
- }
else
{
- restartanim = true;
+ restartanim = fr != WFRAME_IDLE;
}
vector of = v_forward;
vector or = v_right;
vector ou = v_up;
+ vector a = '0 0 0';
if (this)
{
this.wframe = fr;
- vector a = '0 0 0';
if (fr == WFRAME_IDLE) a = this.anim_idle;
else if (fr == WFRAME_FIRE1) a = this.anim_fire1;
else if (fr == WFRAME_FIRE2) a = this.anim_fire2;
else // if (fr == WFRAME_RELOAD)
a = this.anim_reload;
a.z *= g_weaponratefactor;
- setanim(this, a, restartanim == false, restartanim, restartanim);
}
v_forward = of;
this.weapon_nextthink = time;
// dprint("reset weapon animation timer at ", ftos(time), "\n");
}
- this.weapon_nextthink = this.weapon_nextthink + t;
+ this.weapon_nextthink += t;
+ if (weaponentity == weaponentities[0]) STAT(WEAPON_NEXTTHINK, actor) = this.weapon_nextthink;
this.weapon_think = func;
// dprint("next ", ftos(this.weapon_nextthink), "\n");
+ if (this)
+ {
+ entity e;
+ FOR_EACH_CLIENT(e) if (e == actor || (IS_SPEC(e) && e.enemy == actor)) wframe_send(e, this, a, restartanim);
+ }
+
if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
{
- if ((actor.weapon == WEP_SHOCKWAVE.m_id || actor.weapon == WEP_SHOTGUN.m_id)
- && fr == WFRAME_FIRE2) animdecide_setaction(actor, ANIMACTION_MELEE, restartanim);
- else animdecide_setaction(actor, ANIMACTION_SHOOT, restartanim);
+ int act = (fr == WFRAME_FIRE2 && (actor.weapon == WEP_SHOCKWAVE.m_id || actor.weapon == WEP_SHOTGUN.m_id))
+ ? ANIMACTION_MELEE
+ : ANIMACTION_SHOOT
+ ;
+ animdecide_setaction(actor, act, restartanim);
}
- else
+ else if (actor.anim_upper_action == ANIMACTION_SHOOT || actor.anim_upper_action == ANIMACTION_MELEE)
{
- if (actor.anim_upper_action == ANIMACTION_SHOOT
- || actor.anim_upper_action == ANIMACTION_MELEE) actor.anim_upper_action = 0;
+ actor.anim_upper_action = 0;
}
}
void W_WeaponFrame(entity actor)
{
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+ .entity weaponentity = weaponentities[0]; // TODO: unhardcode
entity this = actor.(weaponentity);
if (frametime) actor.weapon_frametime = frametime;
- if (!this || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands
+ if (!this || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands
if (forbidWeaponUse(actor))
entity oldwep = Weapons_from(actor.weapon);
// set up weapon switch think in the future, and start drop anim
- if (
-#if INDEPENDENT_ATTACK_FINISHED
- true
-#else
- ATTACK_FINISHED(actor, slot) <= time + actor.weapon_frametime * 0.5
-#endif
- )
+ if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + actor.weapon_frametime * 0.5)
{
sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
this.state = WS_DROP;
flash.owner = actor;
flash.angles_z = random() * 360;
- entity this = actor.(weaponentity);
- if (gettagindex(this, "shot")) setattachment(flash, this, "shot");
- else setattachment(flash, this, "tag_shot");
+ entity view = actor.(weaponentity);
+ entity exterior = actor.exteriorweaponentity;
+
+ if (gettagindex(view, "shot")) setattachment(flash, view, "shot");
+ else setattachment(flash, view, "tag_shot");
setorigin(flash, offset);
entity xflash = spawn();
flash.viewmodelforclient = actor;
- if (this.oldorigin.x > 0)
+ if (view.oldorigin.x > 0)
{
- setattachment(xflash, actor.exteriorweaponentity, "");
- setorigin(xflash, this.oldorigin + offset);
+ setattachment(xflash, exterior, "");
+ setorigin(xflash, view.oldorigin + offset);
}
else
{
- if (gettagindex(actor.exteriorweaponentity, "shot")) setattachment(xflash, actor.exteriorweaponentity, "shot");
- else setattachment(xflash, actor.exteriorweaponentity, "tag_shot");
+ if (gettagindex(exterior, "shot")) setattachment(xflash, exterior, "shot");
+ else setattachment(xflash, exterior, "tag_shot");
setorigin(xflash, offset);
}
}
#ifndef WEAPONSYSTEM_H
#define WEAPONSYSTEM_H
-.float wframe;
float internalteam;
float weaponswapping;
entity weapon_dropevent_item;
-// VorteX: static frame globals
-const float WFRAME_DONTCHANGE = -1;
-const float WFRAME_FIRE1 = 0;
-const float WFRAME_FIRE2 = 1;
-const float WFRAME_IDLE = 2;
-const float WFRAME_RELOAD = 3;
-
-vector shotorg_adjust(vector vecs, bool y_is_right, bool visual, int algn);
-
-vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn);
-
void CL_SpawnWeaponentity(entity e, .entity weaponentity);
vector CL_Weapon_GetShotOrg(float wpn);
void weapon_prepareattack_do(entity actor, .entity weaponentity, float secondary, float attacktime);
-void weapon_thinkf(entity actor, .entity weaponentity, float fr, float t, void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func);
+void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func);
#endif