script:
- wget -O data/g-23.pk3 http://beta.xonotic.org/autobuild-bsp/latest/g-23.pk3
- make
- - EXPECT=e53fb00597ea9a38aa31230e4edfbd54
+ - EXPECT=44a15d27dcfb0bccddc73284e6d968e7
- HASH=$(${ENGINE} -noconfig -nohome +exec serverbench.cfg
| tee /dev/stderr
| grep '^:'
// ===========
// multijump
// ===========
-seta cl_multijump 0 "allow multijump mutator"
+seta cl_multijump 1 "allow multijump mutator"
set g_multijump 0 "Number of multiple jumps to allow (jumping again in the air), -1 allows for infinite jumps"
set g_multijump_add 0 "0 = make the current z velocity equal to jumpvelocity, 1 = add jumpvelocity to the current z velocity"
set g_multijump_speed -999999 "Minimum vertical speed a player must have in order to jump again"
}
}
-void LocalCommand_find(int request, int argc)
-{
- switch (request)
- {
- case CMD_REQUEST_COMMAND:
- {
- FOREACH_ENTITY_CLASS(argv(1), true, LAMBDA(LOG_INFO(etos(it), "\n")));
- return;
- }
-
- default:
- {
- LOG_INFO("Incorrect parameters for ^2find^7\n");
- }
- case CMD_REQUEST_USAGE:
- {
- LOG_INFO("\nUsage:^3 cl_cmd find classname\n");
- LOG_INFO(" Where 'classname' is the classname to search for.\n");
- return;
- }
- }
-}
-
void LocalCommand_sendcvar(int request, int argc)
{
switch (request)
CLIENT_COMMAND(handlevote, "System to handle selecting a vote or option") { LocalCommand_handlevote(request, arguments); }
CLIENT_COMMAND(hud, "Commands regarding/controlling the HUD system") { LocalCommand_hud(request, arguments); }
CLIENT_COMMAND(localprint, "Create your own centerprint sent to yourself") { LocalCommand_localprint(request, arguments); }
-CLIENT_COMMAND(find, "Search through entities for matching classname") { LocalCommand_find(request, arguments); }
CLIENT_COMMAND(mv_download, "Retrieve mapshot picture from the server") { LocalCommand_mv_download(request, arguments); }
CLIENT_COMMAND(sendcvar, "Send a cvar to the server (like weaponpriority)") { LocalCommand_sendcvar(request, arguments); }
void LocalCommand_macro_help()
{
- FOREACH(CLIENT_COMMANDS, true, LAMBDA(LOG_INFOF(" ^2%s^7: %s\n", it.m_name, it.m_description)));
+ FOREACH(CLIENT_COMMANDS, true, LOG_INFOF(" ^2%s^7: %s\n", it.m_name, it.m_description));
}
bool LocalCommand_macro_command(int argc, string command)
{
string c = strtolower(argv(0));
- FOREACH(CLIENT_COMMANDS, it.m_name == c, LAMBDA(
+ FOREACH(CLIENT_COMMANDS, it.m_name == c, {
it.m_invokecmd(CMD_REQUEST_COMMAND, NULL, argc, command);
return true;
- ));
+ });
return false;
}
bool LocalCommand_macro_usage(int argc)
{
string c = strtolower(argv(1));
- FOREACH(CLIENT_COMMANDS, it.m_name == c, LAMBDA(
+ FOREACH(CLIENT_COMMANDS, it.m_name == c, {
it.m_invokecmd(CMD_REQUEST_USAGE, NULL, argc, "");
return true;
- ));
+ });
return false;
}
void LocalCommand_macro_write_aliases(int fh)
{
- FOREACH(CLIENT_COMMANDS, true, LAMBDA(CMD_Write_Alias("qc_cmd_cl", it.m_name, it.m_description)));
+ FOREACH(CLIENT_COMMANDS, true, CMD_Write_Alias("qc_cmd_cl", it.m_name, it.m_description));
}
METHOD(clientcommand_##id, m_invokecmd, void(int request, entity caller, int arguments, string command))
STATIC_INIT(CLIENT_COMMANDS_aliases) {
- FOREACH(CLIENT_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_cl"))));
+ FOREACH(CLIENT_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_cl")));
}
#endif
draw_teamradar_background(hud_panel_radar_foreground_alpha);
- FOREACH_ENTITY_CLASS("radarlink", true, LAMBDA(
- draw_teamradar_link(it.origin, it.velocity, it.team);
- ));
+ FOREACH_ENTITY_CLASS("radarlink", true, draw_teamradar_link(it.origin, it.velocity, it.team));
- FOREACH_ENTITY_FLAGS(teamradar_icon, 0xFFFFFF, LAMBDA(
+ FOREACH_ENTITY_FLAGS(teamradar_icon, 0xFFFFFF, {
if ( hud_panel_radar_mouse )
if ( it.health > 0 )
if ( it.team == myteam+1 || gametype == MAPINFO_TYPE_RACE )
}
entity icon = RadarIcons_from(it.teamradar_icon);
draw_teamradar_icon(it.origin, icon, it, spritelookupcolor(it, icon.netname, it.teamradar_color), panel_fg_alpha);
- ));
- AL_EACH(_entcs, e, it != NULL, LAMBDA(
+ });
+ AL_EACH(_entcs, e, it != NULL, {
if (!it.m_entcs_private) continue;
if (entcs_is_self(it)) continue;
color2 = entcs_GetTeam(it.sv_entnum);
draw_teamradar_player(it.origin, it.angles, Team_ColorRGB(color2));
- ));
+ });
draw_teamradar_player(view_origin, view_angles, '1 1 1');
drawresetcliparea();
weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
weapon_cnt = 0;
- FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, LAMBDA(weaponorder[weapon_cnt++] = it));
+ FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, weaponorder[weapon_cnt++] = it);
for(i = weapon_cnt; i < Weapons_MAX; ++i)
weaponorder[i] = NULL;
heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, NULL);
// get the all-weapons layout
int nHidden = 0;
WepSet weapons_stat = WepSet_GetFromStat();
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if (weapons_stat & it.m_wepset) continue;
if (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
- ));
+ });
vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, padded_panel_size, aspect);
columns = table_size.x;
rows = table_size.y;
registercvar("cl_jumpspeedcap_min", "");
registercvar("cl_jumpspeedcap_max", "");
- registercvar("cl_multijump", "0");
+ registercvar("cl_multijump", "1");
registercvar("cl_spawn_near_teammate", "1");
this.nextthink = time + 0.2;
}
-void Porto_Init();
void TrueAim_Init();
void PostInit()
{
playerchecker.think = Playerchecker_Think;
playerchecker.nextthink = time + 0.2;
- Porto_Init();
TrueAim_Init();
postinit = true;
#endif
this.enttype = t;
bool done = false;
- FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
+ FOREACH(LinkedEntities, it.m_id == t, {
if (isnew) this.classname = it.netname;
if (autocvar_developer_csqcentities)
LOG_INFOF("CSQC_Ent_Update(%d) at %f with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", isnew, savetime, this, this.entnum, this.enttype, this.classname, t);
done = it.m_read(this, NULL, isnew);
break;
- ));
+ });
time = savetime;
if (!done)
{
// Acquire TE ID
int nTEID = ReadByte();
- FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
+ FOREACH(TempEntities, it.m_id == nTEID, {
if (autocvar_developer_csqcentities)
LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
return it.m_read(NULL, NULL, true);
- ));
+ });
if (autocvar_developer_csqcentities)
LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
WepSet weapons_inmap = WepSet_GetFromStat_InMap();
float initial_posx = pos.x;
int disownedcnt = 0;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
int weapon_stats = weapon_accuracy[i - WEP_FIRST];
WepSet set = it.m_wepset;
if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
++disownedcnt;
- ));
+ });
int weapon_cnt = (Weapons_COUNT - 1) - disownedcnt;
if (weapon_cnt <= 0) return pos;
vector tmpos = pos;
int column = 0;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
int weapon_stats = weapon_accuracy[i - WEP_FIRST];
WepSet set = it.m_wepset;
pos.y += height;
}
++column;
- ));
+ });
if (weapons_with_stats)
average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
if (autocvar_hud_shownames_antioverlap)
{
// fade tag out if another tag that is closer to you overlaps
- LL_EACH(shownames_ent, it != this && entcs_receiver(i), LAMBDA(
+ LL_EACH(shownames_ent, it != this && entcs_receiver(i), {
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;
overlap = true;
break;
}
- ));
+ });
}
bool onscreen = (o.z >= 0 && o.x >= 0 && o.y >= 0 && o.x <= vid_conwidth && o.y <= vid_conheight);
if (autocvar_hud_shownames_crosshairdistance)
void Draw_ShowNames_All()
{
if (!autocvar_hud_shownames) return;
- LL_EACH(shownames_ent, true, LAMBDA(
+ LL_EACH(shownames_ent, true, {
entity entcs = entcs_receiver(i);
if (!entcs)
{
if (!it.csqcmodel_isdead) setorigin(it, entcs.origin);
it.csqcmodel_isdead = dead;
Draw_ShowNames(it);
- ));
+ });
}
viewmodel = new(viewmodel);
}
-entity porto;
-vector polyline[16];
-void Porto_Draw(entity this)
+void Porto_Draw(entity this);
+STATIC_INIT(Porto)
{
- vector p, dir, ang, q, nextdir;
- float portal_number, portal1_idx;
-
- if(activeweapon != WEP_PORTO || spectatee_status || gametype == MAPINFO_TYPE_NEXBALL)
- return;
- if(WEP_CVAR(porto, secondary))
- return;
- if(intermission == 1)
- return;
- if(intermission == 2)
- return;
- if (STAT(HEALTH) <= 0)
- return;
+ entity e = new_pure(porto);
+ e.draw = Porto_Draw;
+ e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
+}
- dir = view_forward;
+const int polyline_length = 16;
+vector polyline[polyline_length];
+void Porto_Draw(entity this)
+{
+ if (activeweapon != WEP_PORTO) return;
+ if (spectatee_status) return;
+ if (WEP_CVAR(porto, secondary)) return;
+ if (intermission == 1) return;
+ if (intermission == 2) return;
+ if (STAT(HEALTH) <= 0) return;
- if(angles_held_status)
+ vector pos = view_origin;
+ vector dir = view_forward;
+ if (angles_held_status)
{
makevectors(angles_held);
dir = v_forward;
}
- p = view_origin;
-
- polyline[0] = p;
- int idx = 1;
- portal_number = 0;
- nextdir = dir;
+ polyline[0] = pos;
- for (;;)
+ int portal_number = 0, portal1_idx = 1, portal_max = 2;
+ int n = 1 + 2; // 2 lines == 3 points
+ for (int idx = 0; idx < n && idx < polyline_length - 1; )
{
- dir = nextdir;
- traceline(p, p + 65536 * dir, true, porto);
- if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
- return;
- nextdir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
- p = trace_endpos;
- polyline[idx] = p;
- ++idx;
- if(idx >= 16)
- return;
- if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
- continue;
- ++portal_number;
- ang = vectoangles2(trace_plane_normal, dir);
- ang.x = -ang.x;
- makevectors(ang);
- if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
- return;
- if(portal_number == 1)
+ traceline(pos, pos + 65536 * dir, true, this);
+ dir = reflect(dir, trace_plane_normal);
+ pos = trace_endpos;
+ polyline[++idx] = pos;
+ if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
{
- portal1_idx = idx;
- if(portal_number >= 2)
- break;
+ n += 1;
+ continue;
}
- }
-
- while(idx >= 2)
- {
- p = polyline[idx-2];
- q = polyline[idx-1];
- if(idx == 2)
- p = p - view_up * 16;
- if(idx-1 >= portal1_idx)
+ if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
{
- Draw_CylindricLine(p, q, 4, "", 1, 0, '0 0 1', 0.5, DRAWFLAG_NORMAL, view_origin);
+ n = max(2, idx);
+ break;
}
- else
+ // check size
{
- Draw_CylindricLine(p, q, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL, view_origin);
+ vector ang = vectoangles2(trace_plane_normal, dir);
+ ang.x = -ang.x;
+ makevectors(ang);
+ if (!CheckWireframeBox(this, pos - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
+ {
+ n = max(2, idx);
+ break;
+ }
}
- --idx;
+ portal_number += 1;
+ if (portal_number >= portal_max) break;
+ if (portal_number == 1) portal1_idx = idx;
+ }
+ for (int idx = 0; idx < n - 1; ++idx)
+ {
+ vector p = polyline[idx], q = polyline[idx + 1];
+ if (idx == 0) p -= view_up * 16; // line from player
+ vector rgb = (idx < portal1_idx) ? '1 0 0' : '0 0 1';
+ Draw_CylindricLine(p, q, 4, "", 1, 0, rgb, 0.5, DRAWFLAG_NORMAL, view_origin);
}
-}
-
-void Porto_Init()
-{
- porto = new_pure(porto);
- porto.draw = Porto_Draw;
- porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
}
float drawtime;
if(myteam != prev_myteam)
{
myteamcolors = colormapPaletteColor(myteam, 1);
- FOREACH(hud_panels, true, LAMBDA(it.update_time = time));
+ FOREACH(hud_panels, true, it.update_time = time);
prev_myteam = myteam;
}
if(ons_roundlost)
{
- FOREACH_ENTITY_CLASS("onslaught_generator", it.health <= 0, LAMBDA(
+ FOREACH_ENTITY_CLASS("onslaught_generator", it.health <= 0, {
gen = it;
break;
- ));
+ });
if(!gen)
ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
}
mousepos = mousepos*0.5 + getmousepos();
*/
- FOREACH_ENTITY(it.draw, LAMBDA(it.draw(it)));
+ FOREACH_ENTITY(it.draw, it.draw(it));
addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
renderscene();
} else */
// draw 2D entities
- FOREACH_ENTITY(it.draw2d, LAMBDA(it.draw2d(it)));
+ FOREACH_ENTITY(it.draw2d, it.draw2d(it));
Draw_ShowNames_All();
Debug_Draw();
#include "mapinfo.qc"
#include "playerstats.qc"
+#ifdef SVQC
+ #include "state.qc"
+#endif
#include "util.qc"
#ifndef CSQC
bool monsters_animoverride(entity this)
{
Monster monster_id = NULL;
- FOREACH(Monsters, it != MON_Null, LAMBDA(
- if(it.model == this.model)
- {
- monster_id = it;
- break;
- }
- ));
+ FOREACH(Monsters, it != MON_Null && it.model == this.model, {
+ monster_id = it;
+ break;
+ });
if(!monster_id) { return false; }
METHOD(genericcommand_##id, m_invokecmd, void(int request, entity caller, int arguments, string command))
STATIC_INIT(GENERIC_COMMANDS_aliases) {
- FOREACH(GENERIC_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svmenu"))));
+ FOREACH(GENERIC_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svmenu")));
}
#include "generic.qh"
// Last updated: February 19th, 2012
// =========================================================
-// used by generic commands for better help/usage information
-string GetProgramCommandPrefix()
-{
- #ifdef SVQC
- return "sv_cmd";
- #endif
- #ifdef CSQC
- return "cl_cmd";
- #endif
- #ifdef MENUQC
- return "menu_cmd";
- #endif
-}
// used by curl command
void Curl_URI_Get_Callback(int id, float status, string data)
void GenericCommand_macro_help()
{
- FOREACH(GENERIC_COMMANDS, true, LAMBDA(LOG_INFOF(" ^2%s^7: %s\n", it.m_name, it.m_description)));
+ FOREACH(GENERIC_COMMANDS, true, LOG_INFOF(" ^2%s^7: %s\n", it.m_name, it.m_description));
}
float GenericCommand_macro_command(float argc, string command)
{
string c = strtolower(argv(0));
- FOREACH(GENERIC_COMMANDS, it.m_name == c, LAMBDA(
+ FOREACH(GENERIC_COMMANDS, it.m_name == c, {
it.m_invokecmd(CMD_REQUEST_COMMAND, NULL, argc, command);
return true;
- ));
+ });
return false;
}
float GenericCommand_macro_usage(float argc)
{
string c = strtolower(argv(1));
- FOREACH(GENERIC_COMMANDS, it.m_name == c, LAMBDA(
+ FOREACH(GENERIC_COMMANDS, it.m_name == c, {
it.m_invokecmd(CMD_REQUEST_USAGE, NULL, argc, "");
return true;
- ));
+ });
return false;
}
void GenericCommand_macro_write_aliases(float fh)
{
- FOREACH(GENERIC_COMMANDS, true, LAMBDA(CMD_Write_Alias("qc_cmd_svmenu", it.m_name, it.m_description)));
+ FOREACH(GENERIC_COMMANDS, true, CMD_Write_Alias("qc_cmd_svmenu", it.m_name, it.m_description));
}
float GenericCommand(string command);
// Returns command prefix specific for whatever program it is compiled in
-string GetProgramCommandPrefix();
+#ifdef SVQC
+ #define GetProgramCommandPrefix() "sv_cmd"
+#elif defined(CSQC)
+ #define GetProgramCommandPrefix() "cl_cmd"
+#elif defined(MENUQC)
+ #define GetProgramCommandPrefix() "menu_cmd"
+#endif
// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
#define CMD_Write(s) fputs(fh, s)
REGISTER_NET_TEMP(net_debug)
#endif
-#ifdef SVQC
-
-#include <server/command/all.qh>
-
-#endif
-
#ifdef CSQC
NET_HANDLE(net_debug, bool isNew)
{
static int debugdraw_frame;
++debugdraw_frame;
const int sz = 8;
- FOREACH_ENTITY(true, LAMBDA(
+ FOREACH_ENTITY(true, {
if (it.debugdraw_last == debugdraw_frame) continue;
int ofs = 0;
- for (entity e = findradius(it.origin, 100); e; e = e.chain)
- {
- if (e.debugdraw_last == debugdraw_frame) continue;
- e.debugdraw_last = debugdraw_frame;
- vector rgb = (e.debug) ? '0 0 1' : '1 0 0';
- if (autocvar_debugdraw_filterout != "" && strhasword(autocvar_debugdraw_filterout, e.classname)) continue;
- if (autocvar_debugdraw_filter != "" && !strhasword(autocvar_debugdraw_filter, e.classname)) continue;
+ FOREACH_ENTITY_RADIUS(it.origin, 100, it.debugdraw_last != debugdraw_frame, {
+ it.debugdraw_last = debugdraw_frame;
+ vector rgb = (it.debug) ? '0 0 1' : '1 0 0';
+ if (autocvar_debugdraw_filterout != "" && strhasword(autocvar_debugdraw_filterout, it.classname)) continue;
+ if (autocvar_debugdraw_filter != "" && !strhasword(autocvar_debugdraw_filter, it.classname)) continue;
if (autocvar_debugdraw == 3)
{
- if (!e.entnum) continue;
+ if (!it.entnum) continue;
}
if (autocvar_debugdraw == 4)
{
- if (e.origin) continue;
+ if (it.origin) continue;
}
if (autocvar_debugdraw == 5)
{
- if (!e.debug) continue;
+ if (!it.debug) continue;
}
else if (autocvar_debugdraw > 5)
{
bool flag = true;
do {
-// if (e.modelindex) break;
-// if (e.absmin) break;
-// if (e.absmax) break;
-// if (e.entnum) break;
-// if (e.drawmask) break;
-// if (e.predraw) break;
-// if (e.movetype) break;
- if (e.solid) break;
-// if (e.origin) break;
-// if (e.oldorigin) break;
-// if (e.velocity) break;
-// if (e.angles) break;
-// if (e.avelocity) break;
-// if (e.classname) break;
-// if (e.model) break;
-// if (e.frame) break;
-// if (e.skin) break;
-// if (e.effects) break;
-// if (e.mins) break;
-// if (e.maxs) break;
-// if (e.size) break;
-// if (e.touch) break;
-// if (e.use) break;
-// if (e.think) break;
-// if (e.blocked) break;
-// if (e.nextthink) break;
-// if (e.chain) break;
-// if (e.netname) break;
-// if (e.enemy) break;
-// if (e.flags) break;
-// if (e.colormap) break;
-// if (e.owner) break;
+// if (it.modelindex) break;
+// if (it.absmin) break;
+// if (it.absmax) break;
+// if (it.entnum) break;
+// if (it.drawmask) break;
+// if (it.predraw) break;
+// if (it.movetype) break;
+ if (it.solid) break;
+// if (it.origin) break;
+// if (it.oldorigin) break;
+// if (it.velocity) break;
+// if (it.angles) break;
+// if (it.avelocity) break;
+// if (it.classname) break;
+// if (it.model) break;
+// if (it.frame) break;
+// if (it.skin) break;
+// if (it.effects) break;
+// if (it.mins) break;
+// if (it.maxs) break;
+// if (it.size) break;
+// if (it.touch) break;
+// if (it.use) break;
+// if (it.think) break;
+// if (it.blocked) break;
+// if (it.nextthink) break;
+// if (it.chain) break;
+// if (it.netname) break;
+// if (it.enemy) break;
+// if (it.flags) break;
+// if (it.colormap) break;
+// if (it.owner) break;
flag = false;
} while (0);
if (!flag) continue;
}
- else if (is_pure(e))
+ else if (is_pure(it))
{
if (autocvar_debugdraw < 2) continue;
rgb.y = 1;
}
- vector o = e.origin;
- if (e.tag_entity)
- o += e.tag_entity.origin;
+ vector o = it.origin;
+ if (it.tag_entity)
+ o += it.tag_entity.origin;
vector pos = project_3d_to_2d(o);
if (pos.z < 0) continue;
pos.z = 0;
pos.y += ofs * sz;
drawcolorcodedstring2(pos,
- sprintf("%d: '%s'@%s", (e.debug ? e.sv_entnum : etof(e)),
- e.classname, e.sourceLoc),
+ sprintf("%d: '%s'@%s", (it.debug ? it.sv_entnum : etof(it)),
+ it.classname, it.sourceLoc),
sz * '1 1 0', rgb, 0.5, DRAWFLAG_NORMAL);
++ofs;
- }
- ));
+ });
+ });
}
#endif
}
#endif
-#ifdef SVQC
-SERVER_COMMAND(find, "Search through entities for matching classname")
+GENERIC_COMMAND(find, "Search through entities for matching classname")
{
switch (request)
{
case CMD_REQUEST_COMMAND:
{
- for (entity client = NULL; (client = find(client, classname, argv(1))); )
- LOG_INFO(etos(client), "\n");
+ FOREACH_ENTITY_CLASS_ORDERED(argv(1), true, LOG_INFOF("%i (%s)\n", it, it.classname));
return;
}
default:
+ {
LOG_INFO("Incorrect parameters for ^2find^7\n");
+ }
case CMD_REQUEST_USAGE:
{
- LOG_INFO("\nUsage:^3 sv_cmd find classname\n");
+ LOG_INFO("\nUsage:^3 " GetProgramCommandPrefix() " find classname\n");
LOG_INFO(" Where 'classname' is the classname to search for.\n");
return;
}
}
}
-SERVER_COMMAND(findat, "Search through entities for matching origin")
+GENERIC_COMMAND(findat, "Search through entities for matching origin")
{
switch (request)
{
case CMD_REQUEST_COMMAND:
{
vector match = stov(argv(1));
- FOREACH_ENTITY_ORDERED(it.origin == match, LAMBDA(LOG_INFOF("%i\n", it)));
+ FOREACH_ENTITY_ORDERED(it.origin == match, LOG_INFOF("%i (%s)\n", it, it.classname));
return;
}
LOG_INFO("Incorrect parameters for ^2findat^7\n");
case CMD_REQUEST_USAGE:
{
- LOG_INFO("\nUsage:^3 sv_cmd findat \"0 0 0\"\n");
+ LOG_INFO("\nUsage:^3 " GetProgramCommandPrefix() " findat \"0 0 0\"\n");
return;
}
}
}
-#endif
net_eff.eent_net_count = eff_cnt;
net_eff.eent_eff_trail = eff.eent_eff_trail;
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(Net_Write_Effect(net_eff, it, 0)));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), Net_Write_Effect(net_eff, it, 0));
remove(net_eff);
}
void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)
{
// problem with this is, we might not have all the available effects for it
- FOREACH(Effects, it.eent_eff_name == eff_name, LAMBDA(
+ FOREACH(Effects, it.eent_eff_name == eff_name, {
Send_Effect(it, eff_loc, eff_vel, eff_cnt);
return;
- ));
+ });
// revert to engine handling
__pointparticles(_particleeffectnum(eff_name), eff_loc, eff_vel, eff_cnt);
}
else
forcemul = 1;
- for(entity e = findradius(w_org, rad + MAX_DAMAGEEXTRARADIUS); e; e = e.chain)
- {
- setself(e);
- // attached ents suck
- if(self.tag_entity)
- continue;
-
+ FOREACH_ENTITY_RADIUS(w_org, rad + MAX_DAMAGEEXTRARADIUS, !it.tag_entity, {
+ setself(it);
vector nearest = NearestPointOnBox(self, w_org);
- if(rad)
+ if (rad)
{
thisdmg = ((vlen (nearest - w_org) - bound(MIN_DAMAGEEXTRARADIUS, self.damageextraradius, MAX_DAMAGEEXTRARADIUS)) / rad);
if(thisdmg >= 1)
if(self.isplayermodel)
hitplayer = true; // this impact damaged a player
- }
+ });
setself(this);
if(DEATH_ISVEHICLE(w_deathtype))
e.oldorigin_x = compressShortVector(e.velocity);
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(Violence_GibSplash_SendEntity(e, it, 0)));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), Violence_GibSplash_SendEntity(e, it, 0));
remove(e);
}
entity GetVoiceMessage(string type)
{
- FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == true, LAMBDA(return it));
+ FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == true, return it);
return NULL;
}
entity GetPlayerSound(string type)
{
- FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == false, LAMBDA(return it));
+ FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == false, return it);
return NULL;
}
string allvoicesamples;
STATIC_INIT(allvoicesamples)
{
- FOREACH(PlayerSounds, it.instanceOfVoiceMessage, LAMBDA(
- allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr)
- ));
+ FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
allvoicesamples = strzone(substring(allvoicesamples, 1, -1));
}
if (fake) { msg_entity = this; X(); }
else
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && (!teamplay || msg_entity.team == this.team), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && (!teamplay || msg_entity.team == this.team), {
msg_entity = it;
X();
- ));
+ });
}
#undef X
break;
}
else
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
msg_entity = it;
X();
- ));
+ });
}
#undef X
break;
REGISTRY_SORT(PlayerSounds)
STATIC_INIT(PlayerSounds_renumber)
{
- FOREACH(PlayerSounds, true, LAMBDA(it.m_id = i));
+ FOREACH(PlayerSounds, true, it.m_id = i);
}
REGISTRY_CHECK(PlayerSounds)
REGISTRY_SORT(GlobalSounds)
STATIC_INIT(GlobalSounds_renumber)
{
- FOREACH(GlobalSounds, true, LAMBDA(it.m_id = i));
+ FOREACH(GlobalSounds, true, it.m_id = i);
}
REGISTRY_CHECK(GlobalSounds)
void PrecacheGlobalSound(string samplestring);
PRECACHE(GlobalSounds)
{
- FOREACH(GlobalSounds, true, LAMBDA(PrecacheGlobalSound(it.m_globalsoundstr)));
+ FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
}
REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
e.nextthink = time;
Net_LinkEntity(e, false, 0, entcs_send);
if (!IS_REAL_CLIENT(player)) return;
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
assert(it.entcs);
_entcs_send(it.entcs, msg_entity = player, BITS(23), MSG_ONE);
- ));
+ });
}
void entcs_detach(entity player)
int _enemy_count = 0;
int _friendly_count = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
if(vdist(it.origin - self.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
{
if(SAME_TEAM(it, self))
else
++_enemy_count;
}
- ));
+ });
_friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
_enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
if (time > this.pain_finished)
{
this.pain_finished = time + 10;
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && SAME_TEAM(it, this), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK)));
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && SAME_TEAM(it, this), Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK));
play2team(this.team, SND(ONS_GENERATOR_UNDERATTACK));
}
}
if(!self.isshielded && self.wait < time)
{
self.wait = time + 5;
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
if(SAME_TEAM(it, self))
{
Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
}
else
Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(self.team, CENTER_ONS_NOTSHIELDED));
- ));
+ });
}
}
}
round_handler_Init(7, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
it.ons_roundlost = true;
it.player_blocked = true;
nades_Clear(it);
- ));
+ });
return 1;
}
void Onslaught_RoundStart()
{
entity tmp_entity;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.player_blocked = false));
+ FOREACH_CLIENT(IS_PLAYER(it), it.player_blocked = false);
for(tmp_entity = ons_worldcplist; tmp_entity; tmp_entity = tmp_entity.ons_worldcpnext)
tmp_entity.sprite.SendFlags |= 16;
// Needs weapons?
c = 0;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(self.weapons & (it.m_wepset))
if(++c >= 4)
break;
- ));
+ });
if(c<4)
needweapons = true;
// Count team mates interested in this control point
// (easier and cleaner than keeping counters per cp and teams)
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(SAME_TEAM(it, self))
if(it.havocbot_role_flags & HAVOCBOT_ONS_ROLE_OFFENSE)
if(it.havocbot_ons_target == cp2)
++c;
- ));
+ });
// NOTE: probably decrease the cost of attackable control points
cp2.wpcost = c;
MUTATOR_HOOKFUNCTION(ons, reset_map_global)
{SELFPARAM();
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
it.ons_roundlost = false;
it.ons_deathloc = '0 0 0';
WITH(entity, self, it, PutClientInServer());
- ));
+ });
return false;
}
REGISTRY_SORT(IMPULSES)
STATIC_INIT(IMPULSES_renumber)
{
- FOREACH(IMPULSES, true, LAMBDA(it.m_id = i));
+ FOREACH(IMPULSES, true, it.m_id = i);
}
REGISTRY_CHECK(IMPULSES)
void Dump_Items()
{
- FOREACH(Items, true, LAMBDA(
- ITEM_HANDLE(Show, it);
- ));
+ FOREACH(Items, true, ITEM_HANDLE(Show, it));
}
string Item_Model(string item_mdl)
REGISTRY_SORT(Items)
REGISTRY_CHECK(Items)
-STATIC_INIT(Items) { FOREACH(Items, true, LAMBDA(it.m_id = i)); }
+STATIC_INIT(Items) { FOREACH(Items, true, it.m_id = i); }
void Dump_Items();
{
make_pure(this);
const int bits = ReadInt24_t();
- FOREACH(Items, bits & BIT(it.m_id), LAMBDA(
+ FOREACH(Items, bits & BIT(it.m_id), {
.int fld = inv_items[it.m_id];
int prev = this.(fld);
int next = this.(fld) = ReadByte();
LOG_TRACEF("%s: %.0f -> %.0f\n", it.m_name, prev, next);
- ));
+ });
return true;
}
#endif
void Inventory_Write(Inventory data)
{
int bits = 0;
- FOREACH(Items, true, LAMBDA(
+ FOREACH(Items, true, {
.int fld = inv_items[it.m_id];
bits = BITSET(bits, BIT(it.m_id), data.inventory.(fld) != (data.inventory.(fld) = data.(fld)));
- ));
+ });
WriteInt24_t(MSG_ENTITY, bits);
- FOREACH(Items, bits & BIT(it.m_id), LAMBDA(
+ FOREACH(Items, bits & BIT(it.m_id), {
WriteByte(MSG_ENTITY, data.inv_items[it.m_id]);
- ));
+ });
}
#endif
string _MapInfo_GetDefaultEx(float t)
{
- FOREACH(Gametypes, it.items == t, LAMBDA(return it.model2));
+ FOREACH(Gametypes, it.items == t, return it.model2);
return "";
}
float _MapInfo_GetTeamPlayBool(float t)
{
- FOREACH(Gametypes, it.items == t, LAMBDA(return it.team));
+ FOREACH(Gametypes, it.items == t, return it.team);
return false;
}
cvar_set("timelimit", cvar_defstring("timelimit"));
cvar_set("leadlimit", cvar_defstring("leadlimit"));
cvar_set("fraglimit", cvar_defstring("fraglimit"));
- FOREACH(Gametypes, true, LAMBDA(it.m_parse_mapinfo(string_null, string_null)));
+ FOREACH(Gametypes, true, it.m_parse_mapinfo(string_null, string_null));
string fraglimit_normal = string_null;
string fraglimit_teams = string_null;
break;
}
}
- FOREACH(Gametypes, true, LAMBDA(handled |= it.m_parse_mapinfo(k, v)));
+ FOREACH(Gametypes, true, handled |= it.m_parse_mapinfo(k, v));
if (!handled)
LOG_MAPWARNF("Invalid gametype setting in mapinfo for gametype %s: %s\n", MapInfo_Type_ToString(pWantedType), sa);
}
Gametype MapInfo_Type(int t)
{
- FOREACH(Gametypes, it.items == t, LAMBDA(return it));
+ FOREACH(Gametypes, it.items == t, return it);
return NULL;
}
deprecate(assault, as);
deprecate(race, rc);
if (t == "all") return MAPINFO_TYPE_ALL;
- FOREACH(Gametypes, it.mdl == t, LAMBDA(return it.items));
+ FOREACH(Gametypes, it.mdl == t, return it.items);
return 0;
#undef deprecate
}
string MapInfo_Type_Description(float t)
{
- FOREACH(Gametypes, it.items == t, LAMBDA(return it.gametype_description));
+ FOREACH(Gametypes, it.items == t, return it.gametype_description);
return "";
}
{
if(t == MAPINFO_TYPE_ALL)
return "all";
- FOREACH(Gametypes, it.items == t, LAMBDA(return it.mdl));
+ FOREACH(Gametypes, it.items == t, return it.mdl);
return "";
}
string MapInfo_Type_ToText(float t)
{
- FOREACH(Gametypes, it.items == t, LAMBDA(return it.message));
+ FOREACH(Gametypes, it.items == t, return it.message);
/* xgettext:no-c-format */
return _("@!#%'n Tuba Throwing");
}
int MapInfo_CurrentGametype()
{
int prev = cvar("gamecfg");
- FOREACH(Gametypes, cvar(it.netname) && it.items != prev, LAMBDA(return it.items));
+ FOREACH(Gametypes, cvar(it.netname) && it.items != prev, return it.items);
if (prev) return prev;
return MAPINFO_TYPE_DEATHMATCH;
}
void MapInfo_SwitchGameType(int t)
{
- FOREACH(Gametypes, true, LAMBDA(
- cvar_set(it.netname, (it.items == t) ? "1" : "0")
- ));
+ FOREACH(Gametypes, true, cvar_set(it.netname, (it.items == t) ? "1" : "0"));
}
void MapInfo_LoadMap(string s, float reinit)
{
entity curr;
entity prev = self;
- FOREACH(Minigames, true, LAMBDA(
- {
- curr = HUD_MinigameMenu_SpawnSubEntry(
- it.message, HUD_MinigameMenu_ClickCreate_Entry, self );
+ FOREACH(Minigames, true, {
+ curr = HUD_MinigameMenu_SpawnSubEntry(it.message, HUD_MinigameMenu_ClickCreate_Entry, self);
curr.netname = it.netname;
curr.model = strzone(minigame_texture(strcat(it.netname,"/icon")));
HUD_MinigameMenu_InsertEntry( curr, prev );
prev = curr;
- }));
+ });
}
}
entity minigame_get_descriptor(string id)
{
- FOREACH(Minigames, true, LAMBDA(
- {
- if(it.netname == id)
- return it;
- }));
- return world;
+ FOREACH(Minigames, it.netname == id, return it);
+ return NULL;
}
// Get letter index of a tile name
}
else if ( minig_cmd == "list" )
{
- FOREACH(Minigames, true, LAMBDA(
- {
- sprint(self,it.netname," (",it.message,") ","\n");
- }));
+ FOREACH(Minigames, true, sprint(self, it.netname, " (", it.message, ") ", "\n"));
return;
}
else if ( minig_cmd == "list-sessions" )
string MDL_##name##_get() { return path; } \
REGISTER(Models, MDL, name, m_id, NEW(Model, MDL_##name##_get))
+STATIC_INIT(NULLMDL)
+{
+ precache_model("null");
+}
+
PRECACHE(Models) {
- FOREACH(Models, true, LAMBDA({
- it.model_precache(it);
- }));
+ FOREACH(Models, true, it.model_precache(it));
}
MODEL(Null, "null");
{
string s = this.netname;
WITH(bool, mutator_log, true, LAMBDA(
- FOREACH(Mutators, it.registered_id == s, LAMBDA(Mutator_Remove(it)));
+ FOREACH(Mutators, it.registered_id == s, Mutator_Remove(it));
));
}
NET_HANDLE(Mutator, bool isNew)
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));
+ FOREACH(Mutators, it.registered_id == s, { Mutator_Add(it); ++added; });
));
if (added > 1) LOG_WARNINGF("Added more than one mutator for %s\n", s);
}
}
STATIC_INIT_LATE(Mutators) {
- FOREACH(Mutators, it.mutatorcheck(), LAMBDA(Mutator_Add(it)));
+ FOREACH(Mutators, it.mutatorcheck(), Mutator_Add(it));
}
#define MUTATOR_ONADD if (mode == MUTATOR_ADDING)
#if defined(CSQC) || defined(MENUQC)
// no translatable cvar description please
AUTOCVAR_SAVE(cl_damagetext, bool, false, "Draw damage dealt where you hit the enemy");
-AUTOCVAR_SAVE(cl_damagetext_format, string, "-%3$d", "How to format the damage text. 1$ is health, 2$ is armor, 3$ is both");
+AUTOCVAR_SAVE(cl_damagetext_format, string, "-{total}", "How to format the damage text. {health}, {armor}, {total}");
AUTOCVAR_SAVE(cl_damagetext_color, vector, '1 1 0', "Damage text color");
AUTOCVAR_SAVE(cl_damagetext_color_per_weapon, bool, false, "Damage text uses weapon color");
AUTOCVAR_SAVE(cl_damagetext_size, float, 8, "Damage text font size");
Weapon w = DEATH_WEAPONOF(this.m_deathtype);
if (w != WEP_Null) rgb = w.wpcolor;
}
- string s = sprintf(autocvar_cl_damagetext_format, this.m_damage, this.m_armordamage, this.m_damage + this.m_armordamage);
+ string s = autocvar_cl_damagetext_format;
+ s = strreplace("{health}", sprintf("%d", this.m_damage), s);
+ s = strreplace("{armor}", sprintf("%d", this.m_armordamage), s);
+ s = strreplace("{total}", sprintf("%d", this.m_damage + this.m_armordamage), s);
drawcolorcodedstring2(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL);
}
}
.bool multijump_ready;
#ifdef CSQC
-bool autocvar_cl_multijump = false;
+bool autocvar_cl_multijump = true;
#define PHYS_MULTIJUMP_CLIENT(s) autocvar_cl_multijump
#elif defined(SVQC)
void sv_notice_toall(string _notice, float _howlong, float _modal)
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(sv_notice_to(it, _notice, _howlong, _modal)));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), sv_notice_to(it, _notice, _howlong, _modal));
}
#endif // SVQC
void cl_notice_run()
{
bool flag = false;
- LL_EACH(cl_notices, it.alpha > time, LAMBDA(flag = true; break));
+ LL_EACH(cl_notices, it.alpha > time, { flag = true; break; });
if (!flag) return;
const int M1 = 30;
const int M2 = 10;
#define OUT(s, z) MACRO_BEGIN { drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3.y += z + 4; } MACRO_END
OUT(_("^1Server notices:"), 32);
- LL_EACH(cl_notices, it.alpha > time, LAMBDA(
+ LL_EACH(cl_notices, it.alpha > time, {
string s = sprintf(_("^7%s (^3%d sec left)"), it.netname , rint(it.alpha - time));
OUT(s, 16);
- ));
+ });
#undef OUT
}
MSG net_type, Notification net_name,
...count)
{
+ if (!IS_REAL_CLIENT(client)) return;
entity notif = net_name;
string parms = sprintf("%s, '%s', %s, %s",
Get_Notif_BroadcastName(broadcast),
REGISTRY(Notifications, BITS(11))
REGISTER_REGISTRY(Notifications)
-REGISTRY_SORT(Notifications); STATIC_INIT(Notifications) { FOREACH(Notifications, true, LAMBDA(it.m_id = i)); }
+REGISTRY_SORT(Notifications); STATIC_INIT(Notifications) { FOREACH(Notifications, true, it.m_id = i); }
REGISTRY_CHECK(Notifications)
const int NOTIF_CHOICE_MAX = 50;
entity oldother = other;
- for (entity e = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); e; e = e.chain)
- {
- if(e.solid == SOLID_TRIGGER && e != this)
- if(e.move_nomonsters != MOVE_NOMONSTERS && e.move_nomonsters != MOVE_WORLDONLY)
- if(e.move_touch && boxesoverlap(e.absmin, e.absmax, this.absmin, this.absmax))
+ FOREACH_ENTITY_RADIUS(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true, {
+ if (it.solid == SOLID_TRIGGER && it != this)
+ if (it.move_nomonsters != MOVE_NOMONSTERS && it.move_nomonsters != MOVE_WORLDONLY)
+ if (it.move_touch && boxesoverlap(it.absmin, it.absmax, this.absmin, this.absmax))
{
other = this;
trace_fraction = 1;
trace_inwater = false;
trace_inopen = true;
- trace_endpos = e.move_origin;
+ trace_endpos = it.move_origin;
trace_plane_normal = '0 0 1';
trace_plane_dist = 0;
trace_ent = this;
- WITH(entity, self, e, e.move_touch());
+ WITH(entity, self, it, it.move_touch());
}
- }
+ });
other = oldother;
}
if (this.move_movetype != MOVETYPE_FAKEPUSH)
{
- 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)
+ FOREACH_ENTITY_RADIUS(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true, {
+ switch (it.move_movetype)
{
case MOVETYPE_NONE:
case MOVETYPE_PUSH:
break;
}
- if (check.owner == this)
+ if (it.owner == this)
continue;
- if (this.owner == check)
+ if (this.owner == it)
continue;
- vector pivot = check.mins + 0.5 * (check.maxs - check.mins);
+ vector pivot = it.mins + 0.5 * (it.maxs - it.mins);
vector move;
if (rotated)
{
- vector org = (check.move_origin - this.move_origin) + pivot;
+ vector org = (it.move_origin - this.move_origin) + pivot;
vector org2;
org2.x = org * v_forward;
org2.y = org * v_right;
}
// physics objects need better collisions than this code can do
- if (check.move_movetype == 32) // MOVETYPE_PHYSICS
+ if (it.move_movetype == 32) // MOVETYPE_PHYSICS
{
- check.move_origin = check.move_origin + move;
- _Movetype_LinkEdict(check, true);
+ it.move_origin = it.move_origin + move;
+ _Movetype_LinkEdict(it, true);
continue;
}
// try moving the contacted entity
this.solid = SOLID_NOT;
bool flag = false;
- flag = _Movetype_PushEntity(check, move, true);
+ flag = _Movetype_PushEntity(it, move, true);
if (!flag)
{
- // entity "check" got teleported
- check.move_angles_y += trace_fraction * moveangle.y;
+ // entity "it" got teleported
+ it.move_angles_y += trace_fraction * moveangle.y;
this.solid = savesolid;
continue; // pushed enough
}
// FIXME: turn players specially
- check.move_angles_y += trace_fraction * moveangle.y;
+ it.move_angles_y += trace_fraction * moveangle.y;
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 != this))
- check.move_flags &= ~FL_ONGROUND;
- }
+ if (it.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || it.move_groundentity != this))
+ it.move_flags &= ~FL_ONGROUND;
+ });
}
this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
{
#define ACCMAC(suffix, field) \
PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", it.netname, suffix), p.accuracy.(field[i-1]));
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
ACCMAC("hit", accuracy_hit)
ACCMAC("fired", accuracy_fired)
ACCMAC("cnt-hit", accuracy_cnt_hit)
ACCMAC("cnt-fired", accuracy_cnt_fired)
ACCMAC("frags", accuracy_frags)
- ));
+ });
#undef ACCMAC
}
PlayerScore_Sort(scoreboard_pos, 1, 1, 1);
if(teamplay) { PlayerScore_TeamStats(); }
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
// add personal score rank
PS_GR_P_ADDVAL(it, PLAYERSTATS_RANK, it.score_dummyfield);
// collect final player information
PlayerStats_GameReport_FinalizePlayer(it);
- ));
+ });
if(autocvar_g_playerstats_gamereport_uri != "")
{
PlayerStats_GameReport_AddEvent(PLAYERSTATS_RANK);
// accuracy stats
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-hit"));
PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-fired"));
PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-cnt-hit"));
PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-cnt-fired"));
PlayerStats_GameReport_AddEvent(strcat("acc-", it.netname, "-frags"));
- ));
+ });
PlayerStats_GameReport_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_3);
PlayerStats_GameReport_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_5);
db_close(PS_B_IN_DB);
PS_B_IN_DB = -1;
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(it.playerstats_basicstatus = PS_B_STATUS_IDLE));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), it.playerstats_basicstatus = PS_B_STATUS_IDLE);
}
}
}
void play2team(float t, string filename)
{
if (autocvar_bot_sound_monopoly) return;
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.team == t, LAMBDA(play2(it, filename)));
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.team == t, play2(it, filename));
}
void play2all(string samp)
#define SND(id) Sound_fixpath(SND_##id)
PRECACHE(Sounds) {
- FOREACH(Sounds, true, LAMBDA({
- it.sound_precache(it);
- }));
+ FOREACH(Sounds, true, it.sound_precache(it));
}
SOUND(Null, "misc/null");
--- /dev/null
+#include "state.qh"
+
+void Inventory_new(entity this);
+void Inventory_delete(entity this);
+
+void PlayerState_attach(entity this)
+{
+ this._ps = NEW(PlayerState, this);
+
+ Inventory_new(this);
+}
+
+void PlayerState_detach(entity this)
+{
+ if (!PS(this)) return; // initial connect
+ FOREACH_CLIENT(PS(it) == PS(this), { PS(it) = NULL; });
+ remove(PS(this));
+ this._ps = NULL;
+
+ Inventory_delete(self);
+}
+
+void GetCvars(int);
+void DecodeLevelParms(entity this);
+void PlayerScore_Attach(entity this);
+void ClientData_Attach(entity this);
+void accuracy_init(entity this);
+void entcs_attach(entity this);
+void playerdemo_init(entity this);
+void anticheat_init(entity this);
+void W_HitPlotOpen(entity this);
+void bot_clientconnect(entity this);
+
+void ClientState_attach(entity this)
+{
+ this._cs = NEW(ClientState, this);
+
+ GetCvars(0); // get other cvars from player
+
+ // TODO: xonstat elo.txt support, until then just 404s
+ if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
+
+ // TODO: fold all of these into ClientState
+
+ DecodeLevelParms(this);
+
+ PlayerScore_Attach(this);
+ ClientData_Attach(this);
+ accuracy_init(this);
+ entcs_attach(this);
+ playerdemo_init(this);
+ anticheat_init(this);
+ W_HitPlotOpen(this);
+
+ bot_clientconnect(this);
+}
+
+void bot_clientdisconnect();
+void W_HitPlotClose(entity this);
+void anticheat_report();
+void playerdemo_shutdown();
+void entcs_detach(entity this);
+void accuracy_free(entity this);
+void ClientData_Detach(entity this);
+void PlayerScore_Detach(entity this);
+
+void ClientState_detach(entity this)
+{
+ remove(CS(this));
+ this._cs = NULL;
+
+ GetCvars(-1); // free cvars
+
+ bot_clientdisconnect();
+
+ W_HitPlotClose(this);
+ anticheat_report();
+ playerdemo_shutdown();
+ entcs_detach(this);
+ accuracy_free(self);
+ ClientData_Detach(this);
+ PlayerScore_Detach(self);
+}
PlayerState PS(entity this) { assert(IS_CLIENT(this)); return this._ps; }
#endif
-void Inventory_new(entity this);
-void Inventory_delete(entity this);
-
// TODO: renew on death
-
-void PlayerState_attach(entity this)
-{
- this._ps = NEW(PlayerState, this);
-
- Inventory_new(this);
-}
-
-void PlayerState_detach(entity this)
-{
- if (!PS(this)) return; // initial connect
- remove(PS(this));
- this._ps = NULL;
-
- Inventory_delete(self);
-}
+void PlayerState_attach(entity this);
+void PlayerState_detach(entity this);
/**
* Purpose: common client state, usable on client and server
ClientState CS(entity this) { assert(IS_CLIENT(this)); assert(this._cs); return this._cs; }
#endif
-void GetCvars(int);
-void DecodeLevelParms(entity this);
-void PlayerScore_Attach(entity this);
-void ClientData_Attach(entity this);
-void accuracy_init(entity this);
-void entcs_attach(entity this);
-void playerdemo_init(entity this);
-void anticheat_init(entity this);
-void W_HitPlotOpen(entity this);
-void bot_clientconnect(entity this);
-
-void ClientState_attach(entity this)
-{
- this._cs = NEW(ClientState, this);
-
- GetCvars(0); // get other cvars from player
-
- // TODO: xonstat elo.txt support, until then just 404s
- if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
-
- // TODO: fold all of these into ClientState
-
- DecodeLevelParms(this);
-
- PlayerScore_Attach(this);
- ClientData_Attach(this);
- accuracy_init(this);
- entcs_attach(this);
- playerdemo_init(this);
- anticheat_init(this);
- W_HitPlotOpen(this);
-
- bot_clientconnect(this);
-}
-
-void bot_clientdisconnect();
-void W_HitPlotClose(entity this);
-void anticheat_report();
-void playerdemo_shutdown();
-void entcs_detach(entity this);
-void accuracy_free(entity this);
-void ClientData_Detach(entity this);
-void PlayerScore_Detach(entity this);
-
-void ClientState_detach(entity this)
-{
- remove(CS(this));
- this._cs = NULL;
-
- GetCvars(-1); // free cvars
-
- bot_clientdisconnect();
-
- W_HitPlotClose(this);
- anticheat_report();
- playerdemo_shutdown();
- entcs_detach(this);
- accuracy_free(self);
- ClientData_Detach(this);
- PlayerScore_Detach(self);
-}
+void ClientState_attach(entity this);
+void ClientState_detach(entity this);
if(self.waypointsprite_attached)
{
setself(self.waypointsprite_attached);
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
if(self.waypointsprite_visible_for_player(it))
{
msg_entity = it;
soundto(MSG_ONE, this, CH_TRIGGER, SND(ITEMRESPAWNCOUNTDOWN), VOL_BASE, ATTEN_NORM); // play respawn sound
}
- ));
+ });
setself(this);
WaypointSprite_Ping(self.waypointsprite_attached);
if (w || (item.spawnshieldtime && item.pickup_anyway > 0))
{
pickedup = true;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(w & (it.m_wepset))
{
W_DropEvent(wr_pickup, player, it.m_id, item);
W_GiveWeapon(player, it.m_id);
}
- ));
+ });
}
}
c = 0;
// Detect needed ammo
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(!(player.weapons & (it.m_wepset)))
continue;
need_plasma = true;
else if(it.items & ITEM_JetpackFuel.m_itemid)
need_fuel = true;
- ));
+ });
// TODO: figure out if the player even has the weapon this ammo is for?
// may not affect strategy much though...
if(autocvar_spawn_debug >= 2)
{
- for(entity otheritem = findradius(this.origin, 3); otheritem; otheritem = otheritem.chain)
- {
- // why not flags & fl_item?
- if(otheritem.is_item)
- {
- LOG_TRACE("XXX Found duplicated item: ", itemname, vtos(this.origin));
- LOG_TRACE(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
- error("Mapper sucks.");
- }
- }
+ // why not flags & fl_item?
+ FOREACH_ENTITY_RADIUS(this.origin, 3, it.is_item, {
+ LOG_TRACE("XXX Found duplicated item: ", itemname, vtos(this.origin));
+ LOG_TRACE(" vs ", it.netname, vtos(it.origin), "\n");
+ error("Mapper sucks.");
+ });
this.is_item = true;
}
else if(argv(i) == "fuel_regen") self.items |= ITEM_JetpackRegen.m_itemid;
else
{
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
s = W_UndeprecateName(argv(i));
if(s == it.netname)
{
it.wr_init(it);
break;
}
- ));
+ });
}
}
if(self.ammo_fuel != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_fuel), "fuel");
if(self.health != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "health");
if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.armorvalue), "armor");
- FOREACH(Weapons, it != WEP_Null, LAMBDA(self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (it.m_wepset)), it.netname)));
+ FOREACH(Weapons, it != WEP_Null, self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (it.m_wepset)), it.netname));
}
self.netname = strzone(self.netname);
//print(self.netname, "\n");
n = tokenize_console(self.netname);
for(i = 0; i < n; ++i)
{
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
- if(argv(i) == it.netname)
- {
- it.wr_init(it);
- break;
- }
- ));
+ FOREACH(Weapons, it != WEP_Null && argv(i) == it.netname, {
+ it.wr_init(it);
+ break;
+ });
}
}
got += GiveValue(e, health, op, val);
got += GiveValue(e, armorvalue, op, val);
case "allweapons":
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
- if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
- got += GiveWeapon(e, it.m_id, op, val);
- ));
+ FOREACH(Weapons, it != WEP_Null && !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), got += GiveWeapon(e, it.m_id, op, val));
case "allammo":
got += GiveValue(e, ammo_cells, op, val);
got += GiveValue(e, ammo_plasma, op, val);
got += GiveValue(e, ammo_fuel, op, val);
break;
default:
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
- if(cmd == it.netname)
- {
- got += GiveWeapon(e, it.m_id, op, val);
- break;
- }
- ));
+ FOREACH(Weapons, it != WEP_Null && cmd == it.netname, {
+ got += GiveWeapon(e, it.m_id, op, val);
+ break;
+ });
break;
}
val = 999;
POSTGIVE_BIT(e, items, IT_UNLIMITED_SUPERWEAPONS, SND_POWERUP, SND_POWEROFF);
POSTGIVE_BIT(e, items, IT_UNLIMITED_WEAPON_AMMO, SND_POWERUP, SND_POWEROFF);
POSTGIVE_BIT(e, items, ITEM_Jetpack.m_itemid, SND_ITEMPICKUP, SND_Null);
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
POSTGIVE_WEAPON(e, it, SND_WEAPONPICKUP, SND_Null);
if(!(save_weapons & (it.m_wepset)))
if(e.weapons & (it.m_wepset))
it.wr_init(it);
- ));
+ });
POSTGIVE_VALUE(e, strength_finished, 1, SND_POWERUP, SND_POWEROFF);
POSTGIVE_VALUE(e, invincible_finished, 1, SND_Shield, SND_POWEROFF);
POSTGIVE_VALUE(e, ammo_nails, 0, SND_ITEMPICKUP, SND_Null);
int plnum = 0;
int realplnum = 0;
// let's not count bots
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
++realplnum;
if(it.chlevel_targ == self)
++plnum;
- ));
+ });
if(plnum < ceil(realplnum * min(1, self.count))) // 70% of players
return;
}
msg_entity = activator;
target_music_sendto(MSG_ONE, 1);
}
- FOREACH_CLIENT(IS_SPEC(it) && it.enemy == activator, LAMBDA(
+ FOREACH_CLIENT(IS_SPEC(it) && it.enemy == activator, {
msg_entity = it;
target_music_sendto(MSG_ONE, 1);
- ));
+ });
}
spawnfunc(target_music)
{
entity best = music_default;
if (music_target && time < music_target.lifetime) best = music_target;
if (music_trigger) best = music_trigger;
- LL_EACH(TargetMusic_list, it.noise, LAMBDA(
+ LL_EACH(TargetMusic_list, it.noise, {
const float vol0 = (getsoundtime(it, CH_BGM_SINGLE) >= 0) ? it.lastvol : -1;
if (it == best)
{
_sound(it, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
it.lastvol = vol;
}
- ));
+ });
music_trigger = world;
bgmtime = (best) ? getsoundtime(best, CH_BGM_SINGLE) : gettime(GETTIME_CDTRACK);
}
const string noi = ReadString();
entity e = NULL;
- LL_EACH(TargetMusic_list, it.count == id, LAMBDA(e = it; break));
+ LL_EACH(TargetMusic_list, it.count == id, { e = it; break; });
if (!e)
{
LL_PUSH(TargetMusic_list, e = new_pure(TargetMusic));
Reset_ArcBeam(pl, v_forward);
UpdateCSQCProjectileAfterTeleport(pl);
UpdateItemAfterTeleport(pl);
- {
- WITH(entity, self, pl, anticheat_fixangle());
- }
+ if (IS_PLAYER(pl)) anticheat_fixangle(pl);
#endif
// "disown" projectiles after teleport
if(pl.owner)
self.use = trigger_teleport_use;
if(self.noise != "")
- FOREACH_WORD(self.noise, true, LAMBDA(precache_sound(it)));
+ FOREACH_WORD(self.noise, true, precache_sound(it));
// this must be called to spawn the teleport waypoints for bots
InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
void Dump_Turret_Settings()
{
float x, totalsettings = 0;
- FOREACH(Turrets, it != TUR_Null, LAMBDA({
+ FOREACH(Turrets, it != TUR_Null, {
// step 1: clear the queue
TUR_CONFIG_COUNT = 0;
for(x = 0; x <= MAX_TUR_CONFIG; ++x)
// step 5: debug info
LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.turret_name, TUR_CONFIG_COUNT));
totalsettings += TUR_CONFIG_COUNT;
- }));
+ });
// clear queue now that we're finished
TUR_CONFIG_COUNT = 0;
if (autocvar_g_turrets_reloadcvars == 1)
{
- FOREACH_ENTITY(IS_TURRET(it), LAMBDA(
+ FOREACH_ENTITY(IS_TURRET(it), {
load_unit_settings(it, true);
Turret tur = get_turretinfo(it.m_id);
tur.tr_think(tur, it);
- ));
+ });
cvar_set("g_turrets_reloadcvars", "0");
}
}
if(DIFF_TEAM(pl, veh))
if(autocvar_g_vehicles_steal)
{
- FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL)));
+ FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL));
Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
if(self.vehicle_controller)
self.team = self.vehicle_controller.team;
- FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, LAMBDA(RemoveGrapplingHook(it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, RemoveGrapplingHook(it));
vehicles_reset_colors();
{
if (s == "0" || stof(s)) return s;
s = W_UndeprecateName(s);
- FOREACH(Weapons, it != WEP_Null && it.netname == s, LAMBDA(return ftos(i)));
+ FOREACH(Weapons, it != WEP_Null && it.netname == s, return ftos(i));
return s;
}
string W_NumberWeaponOrder(string order)
for (i = 0; i < n; ++i)
{
RandomSelection_Init();
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if (remaining & (it.m_wepset))
RandomSelection_Add(it, 0, string_null, 1, 1);
- ));
+ });
Weapon w = RandomSelection_chosen_ent;
result |= WepSet_FromWeapon(w);
remaining &= ~WepSet_FromWeapon(w);
REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
#define Weapons_from(i) _Weapons_from(i, WEP_Null)
REGISTER_REGISTRY(Weapons)
-STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); }
+STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPickup, it)); }
.WepSet m_wepset;
#define WEPSET(id) (WEP_##id.m_wepset)
STATIC_INIT(register_weapons_done)
{
- FOREACH(Weapons, true, LAMBDA(
+ FOREACH(Weapons, true, {
WepSet set = it.m_wepset = _WepSet_FromWeapon(it.m_id = i);
WEPSET_ALL |= set;
if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", it.netname, imp));
else
LOG_TRACEF("Impulse limit exceeded, weapon will not be directly accessible: %s\n", it.netname);
- ));
+ });
#ifdef CSQC
- FOREACH(Weapons, true, LAMBDA(it.wr_init(it)));
+ FOREACH(Weapons, true, it.wr_init(it));
#endif
weaponorder_byid = "";
for (int i = Weapons_MAX - 1; i >= 1; --i)
void Dump_Weapon_Settings()
{
int totalweapons = 0, totalsettings = 0;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
// step 1: clear the queue
WEP_CONFIG_COUNT = 0;
for (int x = 0; x <= MAX_WEP_CONFIG; ++x)
LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.m_name, WEP_CONFIG_COUNT));
totalweapons += 1;
totalsettings += WEP_CONFIG_COUNT;
- ));
+ });
// clear queue now that we're finished
WEP_CONFIG_COUNT = 0;
REGISTER_MUTATOR(porto_ticker, true);
MUTATOR_HOOKFUNCTION(porto_ticker, SV_StartFrame) {
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.porto_forbidden = max(0, it.porto_forbidden - 1)));
+ FOREACH_CLIENT(IS_PLAYER(it), it.porto_forbidden = max(0, it.porto_forbidden - 1));
}
void W_Porto_Success()
}
self.nextthink = time;
dist_mult = WEP_CVAR(tuba, attenuation) / autocvar_snd_soundradius;
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != self.realowner, LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != self.realowner, {
v = self.origin - (it.origin + it.view_ofs);
vol0 = max(0, 1 - vlen(v) * dist_mult);
dir0 = normalize(v);
self.SendFlags |= 2;
break;
}
- ));
+ });
}
void W_Tuba_NoteOn(float hittype)
} MACRO_END
+#ifndef MENUQC
+entity(vector org, float rad, .entity tofield) _findradius_tofield = #22;
+#define FOREACH_ENTITY_RADIUS(org, dist, cond, body) FOREACH_ENTITY_RADIUS_UNORDERED(org, dist, cond, body)
+.entity _FOREACH_ENTITY_RADIUS_next;
+noref string _FOREACH_ENTITY_RADIUS_mutex;
+#define FOREACH_ENTITY_RADIUS_UNORDERED(org, dist, cond, body) \
+ MACRO_BEGIN { \
+ if (_FOREACH_ENTITY_RADIUS_mutex) LOG_SEVEREF("Loop mutex held by %s", _FOREACH_ENTITY_RADIUS_mutex); \
+ _FOREACH_ENTITY_RADIUS_mutex = __FUNC__; \
+ entity _foundchain_first = _findradius_tofield(org, dist, _FOREACH_ENTITY_RADIUS_next); \
+ FOREACH_LIST(_foundchain, _FOREACH_ENTITY_RADIUS_next, cond, body); \
+ _FOREACH_ENTITY_RADIUS_mutex = string_null; \
+ } MACRO_END
+#endif
+
#define FOREACH_ENTITY_CLASS(class, cond, body) ORDERED(FOREACH_ENTITY_CLASS)(class, cond, body)
#define FOREACH_ENTITY_CLASS_ORDERED(class, cond, body) FOREACH_ENTITY_ORDERED(it.classname == class && (cond), body)
#pragma once
+#include "progname.qh"
+
#define assert(expr, ...) _assert(LOG_SEVERE, expr, __VA_ARGS__)
#define devassert(...) MACRO_BEGIN if (autocvar_developer) assert(__VA_ARGS__); MACRO_END
#define _LOG(f, level, s) \
MACRO_BEGIN { \
- f(sprintf("^9[::" level "^9] [" __FILE__ "^7:^9%s^7:^9" STR(__LINE__) "] \n^7%s\n", __FUNC__, s)); \
+ f(sprintf("^9[::^7" PROGNAME "^9::" level "^9] [" __FILE__ "^7:^9%s^7:^9" STR(__LINE__) "] \n^7%s\n", __FUNC__, s)); \
} MACRO_END
#define LOG_FATAL(...) _LOG_FATAL(strcat0n(__VA_ARGS__))
void UncustomizeEntitiesRun()
{
- FOREACH_ENTITY_FLOAT(uncustomizeentityforclient_set, true, LAMBDA(
- WITH(entity, self, it, it.uncustomizeentityforclient());
- ));
+ FOREACH_ENTITY_FLOAT(uncustomizeentityforclient_set, true, WITH(entity, self, it, it.uncustomizeentityforclient()));
}
STRING_ITERATOR(g_buf, string_null, 0);
string algo = "MD4"; \
string join = ":"; \
string s = ""; \
- FOREACH(id, true, LAMBDA(s = strcat(s, join, it.registered_id))); \
+ FOREACH(id, true, s = strcat(s, join, it.registered_id)); \
s = substring(s, strlen(join), -1); \
string h = REGISTRY_HASH(id) = strzone(digest_hex(algo, s)); \
LOG_TRACEF(#id ": %s\n[%s]\n", h, s); \
REGISTRY_CHECK(Stats)
STATIC_INIT(RegisterStats_renumber)
{
- FOREACH(Stats, true, LAMBDA(it.m_id = STATS_ENGINE_RESERVE + i));
+ FOREACH(Stats, true, it.m_id = STATS_ENGINE_RESERVE + i);
}
#ifdef SVQC
STATIC_INIT(stats_add) { stats_add(); }
} MACRO_END
noref vector _vec2;
-#define vec2(v) (_vec2 = (v), _vec2.z = 0, _vec2)
+#define vec2(...) EVAL(OVERLOAD(vec2, __VA_ARGS__))
+#define vec2_1(v) (_vec2 = (v), _vec2.z = 0, _vec2)
+#define vec2_2(x, y) (_vec2_x = (x), _vec2_y = (y), _vec2)
noref vector _vec3;
#define vec3(_x, _y, _z) (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3)
noref vector _yinvert;
#define yinvert(v) (_yinvert = (v), _yinvert.y = 1 - _yinvert.y, _yinvert)
+/**
+ * @param dir the directional vector
+ * @param norm the normalized normal
+ * @returns dir reflected by norm
+ */
+vector reflect(vector dir, vector norm)
+{
+ return dir - 2 * (dir * norm) * norm;
+}
+
#ifndef MENUQC
vector get_corner_position(entity box, int corner)
{
bool WarpZoneLib_BadEntity(entity e)
{
- string s = e.classname;
if (is_pure(e)) return true;
+ string s = e.classname;
switch (s)
{
// case "net_linked": // actually some real entities are linked without classname, fail
.float WarpZone_findradius_hit;
.entity WarpZone_findradius_next;
-void WarpZone_FindRadius_Recurse(vector org, float rad, vector org0, vector transform, vector shift, float needlineofsight)
-// blast origin of current search original blast origin how to untransform (victim to blast system)
-{
- vector org_new;
- vector org0_new;
- vector shift_new, transform_new;
- vector p;
- entity e, e0;
- entity wz;
- if(rad <= 0)
- return;
- e0 = findradius(org, rad);
- wz = world;
-
- for(e = e0; e; e = e.chain)
- {
- if(WarpZoneLib_BadEntity(e))
- continue;
- p = WarpZoneLib_NearestPointOnBox(e.origin + e.mins, e.origin + e.maxs, org0);
- if(needlineofsight)
+void WarpZone_FindRadius_Recurse(
+ /** blast origin of current search */
+ vector org,
+ float rad,
+ /** original blast origin */
+ vector org0,
+ /** how to untransform (victim to blast system) */
+ vector transform,
+ vector shift,
+ bool needlineofsight)
+{
+ if (rad <= 0) return;
+ entity wz = NULL;
+ FOREACH_ENTITY_RADIUS(org, rad, !WarpZoneLib_BadEntity(it), {
+ vector p = WarpZoneLib_NearestPointOnBox(it.origin + it.mins, it.origin + it.maxs, org0);
+ if (needlineofsight)
{
- traceline(org, p, MOVE_NOMONSTERS, e);
- if(trace_fraction < 1)
- continue;
+ traceline(org, p, MOVE_NOMONSTERS, it);
+ if (trace_fraction < 1) continue;
}
- if(!e.WarpZone_findradius_hit || vlen2(e.WarpZone_findradius_dist) > vlen2(org0 - p))
+ if (!it.WarpZone_findradius_hit || vlen2(it.WarpZone_findradius_dist) > vlen2(org0 - p))
{
- e.WarpZone_findradius_nearest = p;
- e.WarpZone_findradius_dist = org0 - p;
- e.WarpZone_findradius_findorigin = org;
- e.WarpZone_findradius_findradius = rad;
- if(e.classname == "warpzone_refsys")
+ it.WarpZone_findradius_nearest = p;
+ it.WarpZone_findradius_dist = org0 - p;
+ it.WarpZone_findradius_findorigin = org;
+ it.WarpZone_findradius_findradius = rad;
+ if (it.classname == "warpzone_refsys")
{
// ignore, especially: do not overwrite the refsys parameters
}
- else if(e.classname == "trigger_warpzone")
+ else if (it.classname == "trigger_warpzone")
{
- e.WarpZone_findradius_next = wz;
- wz = e;
- e.WarpZone_findradius_hit = 1;
- e.enemy.WarpZone_findradius_dist = '0 0 0'; // we don't want to go through this zone ever again
- e.enemy.WarpZone_findradius_hit = 1;
+ it.WarpZone_findradius_next = wz;
+ wz = it;
+ it.WarpZone_findradius_hit = 1;
+ it.enemy.WarpZone_findradius_dist = '0 0 0'; // we don't want to go through this zone ever again
+ it.enemy.WarpZone_findradius_hit = 1;
}
else
{
- e.warpzone_transform = transform;
- e.warpzone_shift = shift;
- e.WarpZone_findradius_hit = 1;
+ it.warpzone_transform = transform;
+ it.warpzone_shift = shift;
+ it.WarpZone_findradius_hit = 1;
}
}
- }
- for(e = wz; e; e = e.WarpZone_findradius_next)
+ });
+ for(entity e = wz; e; e = e.WarpZone_findradius_next)
{
- if(WarpZoneLib_BadEntity(e))
- continue;
+ if (WarpZoneLib_BadEntity(e)) continue;
- org0_new = WarpZone_TransformOrigin(e, org);
+ vector org0_new = WarpZone_TransformOrigin(e, org);
traceline(e.warpzone_targetorigin, org0_new, MOVE_NOMONSTERS, e);
- org_new = trace_endpos;
+ vector org_new = trace_endpos;
- transform_new = AnglesTransform_Multiply(e.warpzone_transform, transform);
- shift_new = AnglesTransform_Multiply_GetPostShift(e.warpzone_transform, e.warpzone_shift, transform, shift);
+ vector transform_new = AnglesTransform_Multiply(e.warpzone_transform, transform);
+ vector shift_new = AnglesTransform_Multiply_GetPostShift(e.warpzone_transform, e.warpzone_shift, transform, shift);
WarpZone_FindRadius_Recurse(
org_new,
bound(0, rad - vlen(org_new - org0_new), rad - 8),
e.enemy.WarpZone_findradius_hit = 0;
}
}
-entity WarpZone_FindRadius(vector org, float rad, float needlineofsight)
+entity WarpZone_FindRadius(vector org, float rad, bool needlineofsight)
{
- entity e0, e;
+ if (!warpzone_warpzones_exist && !needlineofsight) return findradius(org, rad);
WarpZone_FindRadius_Recurse(org, rad, org, '0 0 0', '0 0 0', needlineofsight);
- e0 = findchainfloat(WarpZone_findradius_hit, 1);
- for(e = e0; e; e = e.chain)
- e.WarpZone_findradius_hit = 0;
- return e0;
+ entity list_first = findchainfloat(WarpZone_findradius_hit, 1);
+ FOREACH_LIST(list, chain, true, it.WarpZone_findradius_hit = 0);
+ return list_first;
}
.entity WarpZone_refsys;
#define IS_VEHICLE(v) (v.vehicle_flags & VHF_ISVEHICLE)
#define IS_TURRET(v) (v.turret_flags & TUR_FLAG_ISTURRET)
-// NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, LAMBDA(yourcode));
-// NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, LAMBDA(yourcode));
-// NOTE: FOR_EACH_REALCLIENT deprecated! Use the following instead: FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(yourcode));
+// NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, { code; });
+// NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, { code; });
+// NOTE: FOR_EACH_REALCLIENT deprecated! Use the following instead: FOREACH_CLIENT(IS_REAL_CLIENT(it), { code; });
-// NOTE: FOR_EACH_PLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(yourcode));
-// NOTE: FOR_EACH_SPEC deprecated! Use the following instead: FOREACH_CLIENT(IS_SPEC(it), LAMBDA(yourcode));
-// NOTE: FOR_EACH_OBSERVER deprecated! Use the following instead: FOREACH_CLIENT(IS_OBSERVER(it), LAMBDA(yourcode));
-// NOTE: FOR_EACH_REALPLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(yourcode));
+// NOTE: FOR_EACH_PLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it), { code; });
+// NOTE: FOR_EACH_SPEC deprecated! Use the following instead: FOREACH_CLIENT(IS_SPEC(it), { code; });
+// NOTE: FOR_EACH_OBSERVER deprecated! Use the following instead: FOREACH_CLIENT(IS_OBSERVER(it), { code; });
+// NOTE: FOR_EACH_REALPLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { code; });
#define FOREACH_CLIENTSLOT(cond, body) \
MACRO_BEGIN { \
#define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
-// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(yourcode));
+// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, { code; });
#include <common/effects/all.qh>
#include <common/models/all.qh>
#include "defs.qh"
#include "miscfunctions.qh"
-
-
#include "command/common.qh"
+#include <common/state.qh>
.float anticheat_jointime;
// div0_evade -> SPECTATORS
makevectors(this.v_angle);
- if(this.anticheat_div0_evade_offset == 0)
+ if(CS(this).anticheat_div0_evade_offset == 0)
{
f = fabs(anticheat_div0_evade_evasion_delta - floor(anticheat_div0_evade_evasion_delta) - 0.5) * 2; // triangle function
- 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);
+ CS(this).anticheat_div0_evade_offset = servertime + sys_frametime * (3 * f - 1);
+ CS(this).anticheat_div0_evade_v_angle = this.v_angle;
+ CS(this).anticheat_div0_evade_forward_initial = v_forward;
+ MEAN_ACCUMULATE(CS(this), anticheat_div0_evade, 0, 1);
}
else
{
- 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);
+ if(time < CS(this).anticheat_div0_evade_offset)
+ CS(this).anticheat_div0_evade_v_angle = this.v_angle;
+ MEAN_ACCUMULATE(CS(this), anticheat_div0_evade, 0.5 - 0.5 * (CS(this).anticheat_div0_evade_forward_initial * v_forward), 1);
}
- 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;
+ MEAN_ACCUMULATE(CS(this), anticheat_div0_strafebot_old, movement_oddity(this.movement, CS(this).anticheat_div0_strafebot_movement_prev), 1);
+ CS(this).anticheat_div0_strafebot_movement_prev = this.movement;
// Note: this actually tries to detect snap-aim.
- if(this.anticheat_div0_strafebot_forward_prev && time > this.anticheat_fixangle_endtime) {
- float cosangle = this.anticheat_div0_strafebot_forward_prev * v_forward;
+ if(CS(this).anticheat_div0_strafebot_forward_prev && time > CS(this).anticheat_fixangle_endtime) {
+ float cosangle = CS(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", this.netname, angle * 180 / M_PI, cosangle, time - this.anticheat_fixangle_endtime);
+ printf("SNAP %s: %f for %f, %f since fixangle\n", this.netname, angle * 180 / M_PI, cosangle, time - CS(this).anticheat_fixangle_endtime);
*/
- MEAN_ACCUMULATE(this, anticheat_div0_strafebot_new, angle / M_PI, 1);
+ MEAN_ACCUMULATE(CS(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(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);
+ MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_signal, anglespeed, dt);
+ MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_noise, anglespeed, dt);
+ MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m2, anglespeed, dt);
+ MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m3, anglespeed, dt);
+ MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m4, anglespeed, dt);
+ MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m7, anglespeed, dt);
+ MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m10, anglespeed, dt);
}
}
- this.anticheat_div0_strafebot_forward_prev = v_forward;
+ CS(this).anticheat_div0_strafebot_forward_prev = v_forward;
// generic speedhack detection: correlate anticheat_speedhack_movetime (UPDATED BEFORE THIS) and server time
- 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;
+ CS(this).anticheat_speedhack_movetime_frac += frametime;
+ f = floor(CS(this).anticheat_speedhack_movetime_frac);
+ CS(this).anticheat_speedhack_movetime_frac -= f;
+ CS(this).anticheat_speedhack_movetime_count += f;
+ CS(this).anticheat_speedhack_movetime = CS(this).anticheat_speedhack_movetime_frac + CS(this).anticheat_speedhack_movetime_count;
+ f = CS(this).anticheat_speedhack_movetime - servertime;
+ if(CS(this).anticheat_speedhack_offset == 0)
+ CS(this).anticheat_speedhack_offset = f;
else
{
- 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;
+ MEAN_ACCUMULATE(CS(this), anticheat_speedhack, max(0, f - CS(this).anticheat_speedhack_offset), 1);
+ CS(this).anticheat_speedhack_offset += (f - CS(this).anticheat_speedhack_offset) * frametime * 0.1;
}
// new generic speedhack detection
- if (this.anticheat_speedhack_lasttime > 0) {
- float dt = servertime - this.anticheat_speedhack_lasttime;
+ if (CS(this).anticheat_speedhack_lasttime > 0) {
+ float dt = servertime - CS(this).anticheat_speedhack_lasttime;
const float falloff = 0.2;
- this.anticheat_speedhack_accu *= exp(-dt * falloff);
- this.anticheat_speedhack_accu += frametime * falloff;
+ CS(this).anticheat_speedhack_accu *= exp(-dt * falloff);
+ CS(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
- 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);
+ CS(this).anticheat_speedhack_lasttime = servertime;
+ MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m1, CS(this).anticheat_speedhack_accu, frametime);
+ MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m2, CS(this).anticheat_speedhack_accu, frametime);
+ MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m3, CS(this).anticheat_speedhack_accu, frametime);
+ MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m4, CS(this).anticheat_speedhack_accu, frametime);
+ MEAN_ACCUMULATE(CS(this), anticheat_speedhack_m5, CS(this).anticheat_speedhack_accu, frametime);
} else {
- this.anticheat_speedhack_accu = 1;
- this.anticheat_speedhack_lasttime = servertime;
+ CS(this).anticheat_speedhack_accu = 1;
+ CS(this).anticheat_speedhack_lasttime = servertime;
}
}
void anticheat_spectatecopy(entity spectatee)
{SELFPARAM();
// div0_evade -> SPECTATORS
- self.angles = spectatee.anticheat_div0_evade_v_angle;
+ self.angles = CS(spectatee).anticheat_div0_evade_v_angle;
}
void anticheat_prethink()
-{SELFPARAM();
+{
+ SELFPARAM();
// div0_evade -> SPECTATORS
- self.anticheat_div0_evade_offset = 0;
+ CS(this).anticheat_div0_evade_offset = 0;
}
string anticheat_display(float f, float tmin, float mi, float ma)
if(!autocvar_sv_eventlog)
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(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)));
+ GameLogEcho(strcat(":anticheat:_time:", ftos(self.playerid), ":", ftos(servertime - CS(self).anticheat_jointime)));
+ GameLogEcho(strcat(":anticheat:speedhack:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack), 240, 0, 9999))); // Actually this one seems broken.
+ GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m1), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m2), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m3), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m4), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m5), 240, 1.01, 1.25)));
+ GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_old), 120, 0.15, 0.4)));
+ GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_new), 120, 0.25, 0.8)));
+ GameLogEcho(strcat(":anticheat:div0_evade:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_evade), 120, 0.2, 0.5)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m2), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m3), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m4), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m7), 120, 0, 9999)));
+ GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(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(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);
+ case "_time": return servertime - CS(self).anticheat_jointime;
+ case "speedhack": return MEAN_EVALUATE(CS(self), anticheat_speedhack);
+ case "speedhack_m1": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m1);
+ case "speedhack_m2": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m2);
+ case "speedhack_m3": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m3);
+ case "speedhack_m4": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m4);
+ case "speedhack_m5": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m5);
+ case "div0_strafebot_old": return MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_old);
+ case "div0_strafebot_new": return MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_new);
+ case "div0_evade": return MEAN_EVALUATE(CS(self), anticheat_div0_evade);
+ case "idle_snapaim": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise);
+ case "idle_snapaim_signal": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal);
+ case "idle_snapaim_noise": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise);
+ case "idle_snapaim_m2": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m2);
+ case "idle_snapaim_m3": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m3);
+ case "idle_snapaim_m4": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m4);
+ case "idle_snapaim_m7": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m7);
+ case "idle_snapaim_m10": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m10);
}
return -1;
}
anticheat_div0_evade_evasion_delta += frametime * (0.5 + random());
}
-void anticheat_fixangle()
-{SELFPARAM();
- self.anticheat_fixangle_endtime = servertime + ANTILAG_LATENCY(self) + 0.2;
+void anticheat_fixangle(entity this)
+{
+ CS(this).anticheat_fixangle_endtime = servertime + ANTILAG_LATENCY(this) + 0.2;
}
void anticheat_endframe()
{SELFPARAM();
- FOREACH_CLIENT(true, LAMBDA(
- if(it.fixangle)
- WITH(entity, self, it, anticheat_fixangle());
- ));
+ FOREACH_CLIENT(it.fixangle, anticheat_fixangle(it));
anticheat_div0_evade_evasion_delta += frametime * (0.5 + random());
}
void anticheat_init(entity this)
{
- this.anticheat_speedhack_offset = 0;
- this.anticheat_jointime = servertime;
+ CS(this).anticheat_speedhack_offset = 0;
+ CS(this).anticheat_jointime = servertime;
}
void anticheat_startframe();
void anticheat_endframe();
-void anticheat_fixangle();
+void anticheat_fixangle(entity this);
#endif
#if defined(CSQC)
#elif defined(MENUQC)
#elif defined(SVQC)
- #include "../common/vehicles/all.qh"
+ #include <common/state.qh>
+ #include <common/vehicles/all.qh>
#include "antilag.qh"
#endif
if(e.vehicle)
antilag_record(e.vehicle, t);
- if(time < e.(antilag_times[e.antilag_index]))
+ if(time < CS(e).antilag_times[CS(e).antilag_index])
return;
- e.antilag_index = e.antilag_index + 1;
- if(e.antilag_index >= ANTILAG_MAX_ORIGINS)
- e.antilag_index = 0;
- e.(antilag_times[e.antilag_index]) = t;
- e.(antilag_origins[e.antilag_index]) = e.origin;
+ CS(e).antilag_index += 1;
+ if(CS(e).antilag_index >= ANTILAG_MAX_ORIGINS)
+ CS(e).antilag_index = 0;
+ CS(e).antilag_times[CS(e).antilag_index] = t;
+ CS(e).antilag_origins[CS(e).antilag_index] = e.origin;
- if(e.antilag_debug)
- te_spark(antilag_takebackorigin(e, t - e.antilag_debug), '0 0 0', 32);
+ if(CS(e).antilag_debug)
+ te_spark(antilag_takebackorigin(e, t - CS(e).antilag_debug), '0 0 0', 32);
}
// finds the index BEFORE t
float antilag_find(entity e, float t)
{
- for(int i = e.antilag_index; i > 0; --i)
- if(e.(antilag_times[i]) >= t)
- if(e.(antilag_times[i - 1]) < t)
+ for(int i = CS(e).antilag_index; i > 0; --i)
+ if(CS(e).antilag_times[i] >= t)
+ if(CS(e).antilag_times[i - 1] < t)
return i - 1;
- if(e.(antilag_times[0]) >= t)
- if(e.(antilag_times[ANTILAG_MAX_ORIGINS - 1]) < t)
+ if(CS(e).antilag_times[0] >= t)
+ if(CS(e).antilag_times[ANTILAG_MAX_ORIGINS - 1] < t)
return ANTILAG_MAX_ORIGINS - 1;
- for(int i = ANTILAG_MAX_ORIGINS - 1; i > e.antilag_index + 1; --i)
- if(e.(antilag_times[i]) >= t)
- if(e.(antilag_times[i - 1]) < t)
+ for(int i = ANTILAG_MAX_ORIGINS - 1; i > CS(e).antilag_index + 1; --i)
+ if(CS(e).antilag_times[i] >= t)
+ if(CS(e).antilag_times[i - 1] < t)
return i - 1;
// if we get here, t is sandwiched nowhere, so let's assume it's in the present
if (i0 < 0)
{
// IN THE PRESENT
- if(e.antilag_takenback)
- return e.antilag_saved_origin;
+ if(CS(e).antilag_takenback)
+ return CS(e).antilag_saved_origin;
else
return e.origin;
}
if (i1 >= ANTILAG_MAX_ORIGINS)
i1 = 0;
- return lerpv(e.(antilag_times[i0]), e.(antilag_origins[i0]), e.(antilag_times[i1]), e.(antilag_origins[i1]), t);
+ return lerpv(CS(e).antilag_times[i0], CS(e).antilag_origins[i0], CS(e).antilag_times[i1], CS(e).antilag_origins[i1], t);
}
vector antilag_takebackavgvelocity(entity e, float t0, float t1)
if(e.vehicle)
antilag_takeback(e.vehicle, t);
- if(!e.antilag_takenback)
- e.antilag_saved_origin = e.origin;
+ if(!CS(e).antilag_takenback)
+ CS(e).antilag_saved_origin = e.origin;
vector org = antilag_takebackorigin(e, t);
setorigin(e, org);
- e.antilag_takenback = true;
+ CS(e).antilag_takenback = true;
}
void antilag_restore(entity e)
if(e.vehicle)
antilag_restore(e.vehicle);
- if(!e.antilag_takenback)
+ if(!CS(e).antilag_takenback)
return;
- setorigin(e, e.antilag_saved_origin);
- e.antilag_takenback = false;
+ setorigin(e, CS(e).antilag_saved_origin);
+ CS(e).antilag_takenback = false;
}
void antilag_clear(entity e)
antilag_restore(e);
for (int i = 0; i < ANTILAG_MAX_ORIGINS; ++i)
{
- e.(antilag_times[i]) = -2342;
- e.(antilag_origins[i]) = e.origin;
+ CS(e).antilag_times[i] = -2342;
+ CS(e).antilag_origins[i] = e.origin;
}
- e.antilag_index = ANTILAG_MAX_ORIGINS - 1; // next one is 0
+ CS(e).antilag_index = ANTILAG_MAX_ORIGINS - 1; // next one is 0
}
#include "bot/navigation.qh"
#include "../common/ent_cs.qh"
-#include "../common/state.qh"
+#include <common/state.qh>
#include "../common/triggers/teleporters.qh"
bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver);
PlayerState_detach(this);
- if (IS_PLAYER(this)) Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
+ if (IS_PLAYER(this) && this.health >= 1) {
+ // despawn effect
+ Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
+ }
{
entity spot = SelectSpawnPoint(true);
}
// give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
// so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
+ setmodel(this, MDL_Null);
setsize(this, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL));
this.view_ofs = '0 0 0';
}
WaypointSprite_PlayerDead(this);
- if (!mutator_returnvalue) // mutator prevents resetting teams
+ if (mutator_returnvalue) {
+ // mutator prevents resetting teams+score
+ } else {
this.team = -1; // move this as it is needed to log the player spectating in eventlog
+ this.frags = FRAGS_SPECTATOR;
+ PlayerScore_Clear(this); // clear scores when needed
+ }
if (this.killcount != FRAGS_SPECTATOR)
{
this.just_joined = false;
}
- PlayerScore_Clear(this); // clear scores when needed
-
accuracy_resend(this);
this.spectatortime = time;
- this.frags = FRAGS_SPECTATOR;
this.bot_attack = false;
this.hud = HUD_NORMAL;
this.classname = STR_OBSERVER;
this.items = 0;
this.weapons = '0 0 0';
- this.model = "";
- FixPlayermodel(this);
- setmodel(this, MDL_Null);
this.drawonlytoclient = this;
this.weaponname = "";
void SpectateCopy(entity this, entity spectatee)
{
- MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
- self.armortype = spectatee.armortype;
- self.armorvalue = spectatee.armorvalue;
- self.ammo_cells = spectatee.ammo_cells;
- self.ammo_plasma = spectatee.ammo_plasma;
- self.ammo_shells = spectatee.ammo_shells;
- self.ammo_nails = spectatee.ammo_nails;
- self.ammo_rockets = spectatee.ammo_rockets;
- self.ammo_fuel = spectatee.ammo_fuel;
- self.clip_load = spectatee.clip_load;
- self.clip_size = spectatee.clip_size;
- self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
- self.health = spectatee.health;
- self.impulse = 0;
- self.items = spectatee.items;
- self.last_pickup = spectatee.last_pickup;
- self.hit_time = spectatee.hit_time;
- self.strength_finished = spectatee.strength_finished;
- self.invincible_finished = spectatee.invincible_finished;
- self.pressedkeys = spectatee.pressedkeys;
- self.weapons = spectatee.weapons;
- PS(self).m_switchweapon = PS(spectatee).m_switchweapon;
- PS(self).m_switchingweapon = PS(spectatee).m_switchingweapon;
- PS(self).m_weapon = PS(spectatee).m_weapon;
- self.vortex_charge = spectatee.vortex_charge;
- self.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
- self.hagar_load = spectatee.hagar_load;
- self.arc_heat_percent = spectatee.arc_heat_percent;
- self.minelayer_mines = spectatee.minelayer_mines;
- self.punchangle = spectatee.punchangle;
- self.view_ofs = spectatee.view_ofs;
- self.velocity = spectatee.velocity;
- self.dmg_take = spectatee.dmg_take;
- self.dmg_save = spectatee.dmg_save;
- self.dmg_inflictor = spectatee.dmg_inflictor;
- self.v_angle = spectatee.v_angle;
- self.angles = spectatee.v_angle;
- STAT(FROZEN, self) = STAT(FROZEN, spectatee);
- self.revive_progress = spectatee.revive_progress;
- if(!PHYS_INPUT_BUTTON_USE(self))
- self.fixangle = true;
- setorigin(self, spectatee.origin);
- setsize(self, spectatee.mins, spectatee.maxs);
+ MUTATOR_CALLHOOK(SpectateCopy, spectatee, this);
+ PS(this) = PS(spectatee);
+ this.armortype = spectatee.armortype;
+ this.armorvalue = spectatee.armorvalue;
+ this.ammo_cells = spectatee.ammo_cells;
+ this.ammo_plasma = spectatee.ammo_plasma;
+ this.ammo_shells = spectatee.ammo_shells;
+ this.ammo_nails = spectatee.ammo_nails;
+ this.ammo_rockets = spectatee.ammo_rockets;
+ this.ammo_fuel = spectatee.ammo_fuel;
+ this.clip_load = spectatee.clip_load;
+ this.clip_size = spectatee.clip_size;
+ this.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
+ this.health = spectatee.health;
+ this.impulse = 0;
+ this.items = spectatee.items;
+ this.last_pickup = spectatee.last_pickup;
+ this.hit_time = spectatee.hit_time;
+ this.strength_finished = spectatee.strength_finished;
+ this.invincible_finished = spectatee.invincible_finished;
+ this.pressedkeys = spectatee.pressedkeys;
+ this.weapons = spectatee.weapons;
+ this.vortex_charge = spectatee.vortex_charge;
+ this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
+ this.hagar_load = spectatee.hagar_load;
+ this.arc_heat_percent = spectatee.arc_heat_percent;
+ this.minelayer_mines = spectatee.minelayer_mines;
+ this.punchangle = spectatee.punchangle;
+ this.view_ofs = spectatee.view_ofs;
+ this.velocity = spectatee.velocity;
+ this.dmg_take = spectatee.dmg_take;
+ this.dmg_save = spectatee.dmg_save;
+ this.dmg_inflictor = spectatee.dmg_inflictor;
+ this.v_angle = spectatee.v_angle;
+ this.angles = spectatee.v_angle;
+ STAT(FROZEN, this) = STAT(FROZEN, spectatee);
+ this.revive_progress = spectatee.revive_progress;
+ if(!PHYS_INPUT_BUTTON_USE(this))
+ this.fixangle = true;
+ setorigin(this, spectatee.origin);
+ setsize(this, spectatee.mins, spectatee.maxs);
SetZoomState(spectatee.zoomstate);
anticheat_spectatecopy(spectatee);
- self.hud = spectatee.hud;
+ this.hud = spectatee.hud;
if(spectatee.vehicle)
{
- self.fixangle = false;
- //self.velocity = spectatee.vehicle.velocity;
- self.vehicle_health = spectatee.vehicle_health;
- self.vehicle_shield = spectatee.vehicle_shield;
- self.vehicle_energy = spectatee.vehicle_energy;
- self.vehicle_ammo1 = spectatee.vehicle_ammo1;
- self.vehicle_ammo2 = spectatee.vehicle_ammo2;
- self.vehicle_reload1 = spectatee.vehicle_reload1;
- self.vehicle_reload2 = spectatee.vehicle_reload2;
-
- msg_entity = self;
+ this.fixangle = false;
+ //this.velocity = spectatee.vehicle.velocity;
+ this.vehicle_health = spectatee.vehicle_health;
+ this.vehicle_shield = spectatee.vehicle_shield;
+ this.vehicle_energy = spectatee.vehicle_energy;
+ this.vehicle_ammo1 = spectatee.vehicle_ammo1;
+ this.vehicle_ammo2 = spectatee.vehicle_ammo2;
+ this.vehicle_reload1 = spectatee.vehicle_reload1;
+ this.vehicle_reload2 = spectatee.vehicle_reload2;
+
+ msg_entity = this;
WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
WriteAngle(MSG_ONE, spectatee.v_angle.x);
WriteAngle(MSG_ONE, spectatee.v_angle.z);
//WriteByte (MSG_ONE, SVC_SETVIEW);
- // WriteEntity(MSG_ONE, self);
+ // WriteEntity(MSG_ONE, this);
//makevectors(spectatee.v_angle);
- //setorigin(self, spectatee.origin - v_forward * 400 + v_up * 300);*/
+ //setorigin(this, spectatee.origin - v_forward * 400 + v_up * 300);*/
}
}
int autocvar_g_ca_point_limit;
int autocvar_g_ca_point_leadlimit;
+float autocvar_g_ca_round_timelimit;
bool autocvar_g_ca_team_spawns;
+int autocvar_g_ca_teams;
+int autocvar_g_ca_teams_override;
+float autocvar_g_ca_warmup;
-void ca_Initialize();
+
+int ca_teams;
+bool allowed_to_spawn;
+
+const int ST_CA_ROUNDS = 1;
+
+bool CA_CheckTeams();
+bool CA_CheckWinner();
+void CA_RoundStart();
+bool ca_isEliminated(entity e);
REGISTER_MUTATOR(ca, false)
{
MUTATOR_ONADD
{
- if (time > 1) // game loads at time 1
- error("This is a game type and it cannot be added at runtime.");
- ca_Initialize();
+ // game loads at time 1
+ if (time > 1) error("This is a game type and it cannot be added at runtime.");
+
+ allowed_to_spawn = true;
+
+ ca_teams = autocvar_g_ca_teams_override;
+ if (ca_teams < 2) ca_teams = autocvar_g_ca_teams;
+ ca_teams = bound(2, ca_teams, 4);
+ ret_float = ca_teams;
+
+ ScoreRules_basics(ca_teams, SFL_SORT_PRIO_PRIMARY, 0, true);
+ ScoreInfo_SetLabel_TeamScore(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
+ ScoreRules_basics_end();
+
+ round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart);
+ round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
+
+ EliminatedPlayers_Init(ca_isEliminated);
ActivateTeamplay();
SetLimits(autocvar_g_ca_point_limit, autocvar_g_ca_point_leadlimit, -1, -1);
#ifdef IMPLEMENTATION
float autocvar_g_ca_damage2score_multiplier;
-float autocvar_g_ca_round_timelimit;
bool autocvar_g_ca_spectate_enemies;
-int autocvar_g_ca_teams;
-int autocvar_g_ca_teams_override;
-float autocvar_g_ca_warmup;
-
-float ca_teams;
-float allowed_to_spawn;
-
-const float ST_CA_ROUNDS = 1;
-void ca_ScoreRules(float teams)
-{
- ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true);
- ScoreInfo_SetLabel_TeamScore(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
- ScoreRules_basics_end();
-}
void CA_count_alive_players()
{
void CA_RoundStart()
{
- if(warmup_stage)
- allowed_to_spawn = true;
- else
- allowed_to_spawn = false;
+ allowed_to_spawn = boolean(warmup_stage);
}
bool CA_CheckTeams()
/** Returns next available player to spectate if g_ca_spectate_enemies == 0 */
entity CA_SpectateNext(entity player, entity start)
{
- if (SAME_TEAM(start, player)) return start;
+ if (SAME_TEAM(start, player)) return start;
// continue from current player
for (entity e = start; (e = find(e, classname, STR_PLAYER)); )
{
MUTATOR_HOOKFUNCTION(ca, PlayerSpawn)
-{SELFPARAM();
- self.caplayer = 1;
- if(!warmup_stage)
+{
+ SELFPARAM();
+ this.caplayer = 1;
+ if (!warmup_stage)
eliminatedPlayers.SendFlags |= 1;
- return 1;
}
MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
-{SELFPARAM();
- if(!allowed_to_spawn)
- if(IS_PLAYER(self)) // this is true even when player is trying to join
+{
+ SELFPARAM();
+ if (!allowed_to_spawn && IS_PLAYER(this)) // this is true even when player is trying to join
{
- self.classname = STR_OBSERVER;
- if(self.jointime != time) //not when connecting
- if(!self.caplayer)
+ this.classname = STR_OBSERVER;
+ if (this.jointime != time && !this.caplayer) // not when connecting
{
- self.caplayer = 0.5;
- if(IS_REAL_CLIENT(self))
- Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_JOIN_LATE);
+ this.caplayer = 0.5;
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CA_JOIN_LATE);
}
}
- return 1;
}
MUTATOR_HOOKFUNCTION(ca, reset_map_players)
-{SELFPARAM();
- FOREACH_CLIENT(true, LAMBDA(
- setself(it);
- self.killcount = 0;
- if(!self.caplayer && IS_BOT_CLIENT(self))
+{
+ FOREACH_CLIENT(true, {
+ it.killcount = 0;
+ if (!it.caplayer && IS_BOT_CLIENT(it))
{
- self.team = -1;
- self.caplayer = 1;
+ it.team = -1;
+ it.caplayer = 1;
}
- if(self.caplayer)
+ if (it.caplayer)
{
- self.classname = STR_PLAYER;
- self.caplayer = 1;
- PutClientInServer();
+ it.classname = STR_PLAYER;
+ it.caplayer = 1;
+ WITH(entity, self, it, PutClientInServer());
}
- ));
- return 1;
+ });
+ return true;
}
MUTATOR_HOOKFUNCTION(ca, ClientConnect)
-{SELFPARAM();
- self.classname = STR_OBSERVER;
- return 1;
+{
+ SELFPARAM();
+ this.classname = STR_OBSERVER;
+ return true;
}
MUTATOR_HOOKFUNCTION(ca, reset_map_global)
{
allowed_to_spawn = true;
- return 1;
+ return true;
}
MUTATOR_HOOKFUNCTION(ca, GetTeamCount, CBC_ORDER_EXCLUSIVE)
}
entity ca_LastPlayerForTeam()
-{SELFPARAM();
- entity last_pl = world;
- FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
- if(!IS_DEAD(it))
- if(SAME_TEAM(self, it))
- if(!last_pl)
+{
+ SELFPARAM();
+ entity last_pl = NULL;
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
+ if (!IS_DEAD(it))
+ if (SAME_TEAM(this, it))
+ if (!last_pl)
last_pl = it;
else
- return world;
- ));
+ return NULL;
+ });
return last_pl;
}
void ca_LastPlayerForTeam_Notify()
{
- if(round_handler_IsActive())
- if(round_handler_IsRoundStarted())
+ if (round_handler_IsActive())
+ if (round_handler_IsRoundStarted())
{
entity pl = ca_LastPlayerForTeam();
- if(pl)
+ if (pl)
Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
}
}
MUTATOR_HOOKFUNCTION(ca, PlayerDies)
{
ca_LastPlayerForTeam_Notify();
- if(!allowed_to_spawn)
+ if (!allowed_to_spawn)
frag_target.respawn_flags = RESPAWN_SILENT;
- if(!warmup_stage)
+ if (!warmup_stage)
eliminatedPlayers.SendFlags |= 1;
return 1;
}
MUTATOR_HOOKFUNCTION(ca, ClientDisconnect)
-{SELFPARAM();
- if(self.caplayer == 1)
+{
+ SELFPARAM();
+ if (this.caplayer == 1)
ca_LastPlayerForTeam_Notify();
return 1;
}
}
MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver)
-{SELFPARAM();
- if(self.caplayer == 1)
+{
+ SELFPARAM();
+ if (this.caplayer == 1)
ca_LastPlayerForTeam_Notify();
- if(self.killindicator_teamchange == -2)
- self.caplayer = 0;
- if(self.caplayer)
- self.frags = FRAGS_LMS_LOSER;
- if(!warmup_stage)
+ if (this.killindicator_teamchange == -2)
+ this.caplayer = 0;
+ if (this.caplayer)
+ this.frags = FRAGS_LMS_LOSER;
+ if (!warmup_stage)
eliminatedPlayers.SendFlags |= 1;
- return true;
+ return true; // prevent team reset
}
MUTATOR_HOOKFUNCTION(ca, ForbidThrowCurrentWeapon)
MUTATOR_HOOKFUNCTION(ca, SetStartItems)
{
- start_items &= ~IT_UNLIMITED_AMMO;
+ start_items &= ~IT_UNLIMITED_AMMO;
start_health = warmup_start_health = cvar("g_lms_start_health");
start_armorvalue = warmup_start_armorvalue = cvar("g_lms_start_armor");
start_ammo_shells = warmup_start_ammo_shells = cvar("g_lms_start_ammo_shells");
MUTATOR_HOOKFUNCTION(ca, PlayerDamage_Calculate)
{
- if(IS_PLAYER(frag_target))
- if(!IS_DEAD(frag_target))
- if(frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
+ if (IS_PLAYER(frag_target))
+ if (!IS_DEAD(frag_target))
+ if (frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
frag_damage = 0;
frag_mirrordamage = 0;
}
MUTATOR_HOOKFUNCTION(ca, FilterItem)
-{SELFPARAM();
- if(autocvar_g_powerups <= 0)
- if(self.flags & FL_POWERUP)
+{
+ SELFPARAM();
+ if (autocvar_g_powerups <= 0)
+ if (this.flags & FL_POWERUP)
return true;
- if(autocvar_g_pickup_items <= 0)
+ if (autocvar_g_pickup_items <= 0)
return true;
return false;
{
float excess = max(0, frag_damage - damage_take - damage_save);
- if(frag_target != frag_attacker && IS_PLAYER(frag_attacker))
+ if (frag_target != frag_attacker && IS_PLAYER(frag_attacker))
PlayerTeamScore_Add(frag_attacker, SP_SCORE, ST_SCORE, (frag_damage - excess) * autocvar_g_ca_damage2score_multiplier);
return false;
MUTATOR_HOOKFUNCTION(ca, SpectateSet)
{
- if(!autocvar_g_ca_spectate_enemies && self.caplayer)
- if(DIFF_TEAM(spec_player, self))
+ SELFPARAM();
+ if (!autocvar_g_ca_spectate_enemies && this.caplayer)
+ if (DIFF_TEAM(spec_player, this))
return true;
return false;
}
MUTATOR_HOOKFUNCTION(ca, SpectateNext)
-{SELFPARAM();
- if(!autocvar_g_ca_spectate_enemies && self.caplayer)
+{
+ SELFPARAM();
+ if (!autocvar_g_ca_spectate_enemies && this.caplayer)
{
- spec_player = CA_SpectateNext(self, spec_player);
+ spec_player = CA_SpectateNext(this, spec_player);
return true;
}
return false;
}
MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
-{SELFPARAM();
- if(!autocvar_g_ca_spectate_enemies && self.caplayer)
+{
+ SELFPARAM();
+ if (!autocvar_g_ca_spectate_enemies && this.caplayer)
{
do { spec_player = spec_player.chain; }
- while(spec_player && DIFF_TEAM(spec_player, self));
+ while(spec_player && DIFF_TEAM(spec_player, this));
if (!spec_player)
{
- spec_player = spec_first;
- while(spec_player && DIFF_TEAM(spec_player, self))
- spec_player = spec_player.chain;
- if(spec_player == self.enemy)
+ for (spec_player = spec_first; spec_player && DIFF_TEAM(spec_player, this); spec_player = spec_player.chain);
+
+ if (spec_player == this.enemy)
return MUT_SPECPREV_RETURN;
}
}
MUTATOR_HOOKFUNCTION(ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
- if(IS_PLAYER(it) || it.caplayer == 1)
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
+ if (IS_PLAYER(it) || it.caplayer == 1)
++bot_activerealplayers;
++bot_realplayers;
- ));
-
+ });
return true;
}
MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate)
{
- if(self.caplayer)
+ SELFPARAM();
+ if (this.caplayer)
{
// they're going to spec, we can do other checks
- if(autocvar_sv_spectate && (IS_SPEC(self) || IS_OBSERVER(self)))
- Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_LEAVE);
+ if (autocvar_sv_spectate && (IS_SPEC(this) || IS_OBSERVER(this)))
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CA_LEAVE);
return MUT_SPECCMD_FORCE;
}
MUTATOR_HOOKFUNCTION(ca, GetPlayerStatus)
{
- if(set_player.caplayer == 1)
- return true;
- return false;
+ return set_player.caplayer == 1;
}
MUTATOR_HOOKFUNCTION(ca, SetWeaponArena)
{
// most weapons arena
- if(ret_string == "0" || ret_string == "")
- ret_string = "most";
- return false;
-}
-
-void ca_Initialize()
-{
- allowed_to_spawn = true;
-
- ca_teams = autocvar_g_ca_teams_override;
- if(ca_teams < 2)
- ca_teams = autocvar_g_ca_teams;
- ca_teams = bound(2, ca_teams, 4);
- ret_float = ca_teams;
- ca_ScoreRules(ca_teams);
-
- round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart);
- round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
-
- EliminatedPlayers_Init(ca_isEliminated);
+ if (ret_string == "0" || ret_string == "") ret_string = "most";
}
#endif
self.classname = STR_OBSERVER;
Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_NOLIVES);
}
-
- return false;
}
MUTATOR_HOOKFUNCTION(lms, PlayerDies)
}
MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver)
-{SELFPARAM();
- lms_RemovePlayer(self);
- return false;
+{
+ SELFPARAM();
+ lms_RemovePlayer(this);
+ return true; // prevent team reset
}
MUTATOR_HOOKFUNCTION(lms, ClientConnect)
-#define DEBUGPATHING
+#ifndef DEBUGPATHING
+ #define DEBUGPATHING 0
+#endif
#include "costs.qc"
#include "expandnode.qc"
#include "movenode.qc"
#include "path_waypoint.qc"
#include "utility.qc"
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
#include "debug.qc"
#endif
n.nextthink = time;
}
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
void pathlib_showpath(entity start);
void pathlib_showpath2(entity path);
+void pathlib_showsquare(vector where,float goodsquare,float _lifetime);
#endif
-void pathlib_showsquare(vector where,float goodsquare,float _lifetime);
-void pathlib_showsquare2(entity node ,vector ncolor,float align);
entity pathlib_mknode(vector where,entity parent)
{
setorigin(node, where);
node.medium = pointcontents(where);
+#if DEBUGPATHING
pathlib_showsquare(where, 1 ,15);
-
+#endif
++pathlib_made_cnt;
++pathlib_open_cnt;
if (!tile_check(where))
{
LOG_TRACE("tile_check fail\n");
+#if DEBUGPATHING
pathlib_showsquare(where, 0 ,30);
+#endif
return 0;
}
ctime = gettime(GETTIME_REALTIME) - ctime;
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
pathlib_showpath2(start);
LOG_TRACE("Time used - pathfinding: ", ftos(ptime),"\n");
const vector PLIB_RIGHT = '1 0 0';
//#define PLIB_LEFT '-1 0 0'
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
void pathlib_showpath(entity start);
void pathlib_showpath2(entity path);
#endif
// now move the shotorg forward as much as requested if possible
if(antilag)
{
- if(ent.antilag_debug)
- tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent, ent.antilag_debug);
+ if(CS(ent).antilag_debug)
+ tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent, CS(ent).antilag_debug);
else
tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
}
o = self;
while (1)
{
- if(self.antilag_debug)
- WarpZone_traceline_antilag (self, start, end, false, o, self.antilag_debug);
+ if(CS(self).antilag_debug)
+ WarpZone_traceline_antilag (self, start, end, false, o, CS(self).antilag_debug);
else
WarpZone_traceline_antilag (self, start, end, false, o, ANTILAG_LATENCY(self));
if(o && WarpZone_trace_firstzone)