- wget -O data/maps/stormkeep.waypoints https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints
- wget -O data/maps/stormkeep.waypoints.cache https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints.cache
- make
- - EXPECT=61265f867b0817396a503ecc0411dc25
+ - EXPECT=585cfa6d62ce59f4854bedfce7c51c20
- HASH=$(${ENGINE} -noconfig -nohome +exec serverbench.cfg
| tee /dev/stderr
| grep '^:'
-cmake_minimum_required(VERSION 2.8.11)
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
-project(xonotic-data LANGUAGES ASM)
+cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
+project(xonotic-data ASM)
+
+set(checks qc-checks)
+add_custom_target(${checks})
+
+# depend on qcc
+if (TARGET gmqcc)
+ add_dependencies(${checks} gmqcc)
+endif ()
+
+add_dependencies(${checks} data-check-cvars)
+add_custom_target(data-check-cvars
+ COMMENT "checking cvars"
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
+ VERBATIM COMMAND ${CMAKE_COMMAND} -E
+ env "CMAKE=1"
+ "${PROJECT_SOURCE_DIR}/check-cvars.sh"
+ )
+
+add_dependencies(${checks} qc-genmod)
+add_custom_target(qc-genmod
+ COMMENT "genmod.sh"
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/qcsrc"
+ VERBATIM COMMAND ./tools/genmod.sh
+ )
+
+add_dependencies(${checks} qc-headerstyle)
+add_custom_target(qc-headerstyle
+ COMMENT "headerstyle.sh"
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/qcsrc"
+ VERBATIM COMMAND ${CMAKE_COMMAND} -E
+ env "VERBOSE=0"
+ ./tools/headerstyle.sh
+ )
+
+add_dependencies(${checks} qc-whitespace)
+add_custom_target(qc-whitespace
+ COMMENT "whitespace.sh"
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/qcsrc"
+ VERBATIM COMMAND ./tools/whitespace.sh
+ )
include_directories(qcsrc)
add_definitions(-DENABLE_DEBUGDRAW=0)
add_definitions(-DENABLE_DEBUGTRACE=0)
-find_package(Git REQUIRED)
if (DEFINED ENV{VERSION})
set(GIT_DESC "$ENV{VERSION}")
else ()
+ find_package(Git REQUIRED)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=~
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
add_executable(csprogs qcsrc/client/progs.inc)
+add_dependencies(csprogs ${checks})
target_compile_definitions(csprogs PRIVATE -DGAMEQC -DCSQC)
-if (TARGET gmqcc)
- add_dependencies(csprogs gmqcc)
-endif ()
add_executable(progs qcsrc/server/progs.inc)
+add_dependencies(progs ${checks})
target_compile_definitions(progs PRIVATE -DGAMEQC -DSVQC)
-if (TARGET gmqcc)
- add_dependencies(progs gmqcc)
-endif ()
add_executable(menu qcsrc/menu/progs.inc)
+add_dependencies(menu ${checks})
target_compile_definitions(menu PRIVATE -DMENUQC)
-if (TARGET gmqcc)
- add_dependencies(menu gmqcc)
-endif ()
function(set_prelude target prelude)
get_target_property(MY_PROJECT_SOURCES target SOURCES)
check_files "_hud_descriptions.cfg" "hud_*.cfg" "/^seta? hud_/"
if $errord; then
+ if [ "$CMAKE" != "" ]; then
+ exit 1
+ fi
echo "Please wait for 30 seconds, so you have had enough time to read this..."
sleep 30
fi
+++ /dev/null
-#include <client/_all.qh>
-#include "_mod.inc"
-
-#include "commands/_mod.inc"
-#include "hud/_mod.inc"
-#include "mutators/_mod.inc"
-#include "weapons/_mod.inc"
-
-#include <common/_all.inc>
-#include <common/effects/qc/all.qc>
-
-#include <lib/csqcmodel/cl_model.qc>
-#include <lib/csqcmodel/cl_player.qc>
-#include <lib/csqcmodel/interpolate.qc>
-
-#include <lib/warpzone/anglestransform.qc>
-#include <lib/warpzone/common.qc>
-#include <lib/warpzone/client.qc>
-#include <lib/warpzone/server.qc>
-#include <lib/warpzone/util_server.qc>
+++ /dev/null
-#pragma once
-//#include "_mod.qh"
-
-#include <common/util.qh>
-
-#include <common/effects/all.qh>
-#include <common/models/all.qh>
-#include <common/sounds/all.qh>
-
-#include "autocvars.qh"
-#include "defs.qh"
-#include "main.qh"
-#include "miscfunctions.qh"
-#include "view.qh"
-
-#include <common/ent_cs.qh>
-#include <common/wepent.qh>
#include <client/teamradar.qc>
#include <client/view.qc>
#include <client/wall.qc>
+
+#include <client/commands/_mod.inc>
+#include <client/hud/_mod.inc>
+#include <client/mutators/_mod.inc>
+#include <client/weapons/_mod.inc>
#include <client/teamradar.qh>
#include <client/view.qh>
#include <client/wall.qh>
+
+#include <client/commands/_mod.qh>
+#include <client/hud/_mod.qh>
+#include <client/mutators/_mod.qh>
+#include <client/weapons/_mod.qh>
#include "bgmscript.qh"
+#include <common/util.qh>
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/main.qh>
+
#define CONSTANT_SPEED_DECAY
float bgmscriptbuf;
#include "csqcmodel_hooks.qh"
+#include "autocvars.qh"
+#include "csqcmodel_hooks.qh"
+#include "miscfunctions.qh"
#include "mutators/events.qh"
#include "player_skeleton.qh"
#include "weapons/projectile.qh"
#include <common/ent_cs.qh>
#include <common/physics/movetypes/movetypes.qh>
#include <common/viewloc.qh>
+#include <common/effects/all.qh>
+#include <common/effects/all.inc>
#include <lib/csqcmodel/cl_model.qh>
#include <lib/csqcmodel/cl_player.qh>
#include <lib/csqcmodel/interpolate.qh>
}
void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
{
+ if(MUTATOR_CALLHOOK(ForcePlayermodels_Skip, this, islocalplayer))
+ goto skipforcemodels;
+
// FORCEMODEL
// which one is ALWAYS good?
if (!forceplayermodels_goodmodel)
this.colormap = player_localnum + 1;
}
+ LABEL(skipforcemodels)
+
// GLOWMOD AND DEATH FADING
if(this.colormap > 0)
this.glowmod = colormapPaletteColor(((this.colormap >= 1024) ? this.colormap : entcs_GetClientColors(this.colormap - 1)) & 0x0F, true) * 2;
#include "hud.qh"
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include "panel/scoreboard.qh"
#include "hud_config.qh"
#include "../mapvoting.qh"
#include <common/minigames/cl_minigames.qh>
#include <common/t_items.qh>
#include <common/deathtypes/all.qh>
+#include <common/ent_cs.qh>
#include <common/items/_mod.qh>
#include <common/mapinfo.qh>
#include <common/vehicles/all.qh>
#include "hud.qh"
#include "panel/scoreboard.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#define HUD_Write(s) fputs(fh, s)
#define HUD_Write_Cvar(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
#include "ammo.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
+#include <client/view.qh>
#include <common/t_items.qh>
+#include <common/wepent.qh>
// Ammo (#1)
#include "scoreboard.qh"
#include <common/notifications/all.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
// CenterPrint (#16)
#include "chat.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
+
// Chat (#12)
void HUD_Chat()
#include "engineinfo.qh"
+#include <client/autocvars.qh>
+#include <client/miscfunctions.qh>
+
// Engine info (#13)
float prevfps;
#include "healtharmor.qh"
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
+
#include <common/deathtypes/all.qh>
// Health/armor (#3)
#include "infomessages.qh"
+#include <client/autocvars.qh>
+#include <client/miscfunctions.qh>
+
#include <common/ent_cs.qh>
#include <common/mapinfo.qh>
#include "modicons.qh"
+#include <client/miscfunctions.qh>
+#include <client/autocvars.qh>
#include <common/mapinfo.qh>
#include <common/ent_cs.qh>
#include <common/scores.qh>
void HUD_Mod_Race(vector pos, vector mySize)
{
- entity me;
- me = playerslots[player_localnum];
- float score;
- score = me.(scores(ps_primary));
+ entity me = playerslots[player_localnum];
+ float score = me.(scores(ps_primary));
if(!(scores_flags(ps_primary) & SFL_TIME) || teamplay) // race/cts record display on HUD
{
}
// race "awards"
- float a;
- a = bound(0, race_status_time - time, 1);
+ float a = bound(0, race_status_time - time, 1);
+ string s = textShortenToWidth(ColorTranslateRGB(race_status_name), squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
- string s;
- s = textShortenToWidth(ColorTranslateRGB(race_status_name), squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
-
- float rank;
+ float rank = 0;
if(race_status > 0)
rank = race_CheckName(race_status_name);
- else
- rank = 0;
- string rankname;
- rankname = count_ordinal(rank);
-
- vector namepos;
- namepos = medalPos + '0 0.8 0' * squareSize;
- vector rankpos;
- rankpos = medalPos + '0 0.15 0' * squareSize;
+ string rankname = count_ordinal(rank);
+ vector namepos = medalPos + '0 0.8 0' * squareSize;
+ vector rankpos = medalPos + '0 0.15 0' * squareSize;
if(race_status == 0)
drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
#include "notify.qh"
+#include <client/autocvars.qh>
+#include <client/miscfunctions.qh>
// Notifications (#4)
#include "physics.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include <client/main.qh>
#include <common/mapinfo.qh>
#include <lib/csqcmodel/cl_player.qh>
#include "powerups.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include <common/items/_mod.qh>
// Powerups (#2)
#include "pressedkeys.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
// Pressed keys (#11)
#include "quickmenu.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include <common/ent_cs.qh>
#include <client/hud/_mod.qh>
#include <client/mapvoting.qh>
#include "racetimer.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include <common/mapinfo.qh>
// Race timer (#6)
#include "radar.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include <common/ent_cs.qh>
#include <common/mapinfo.qh>
#include <client/mapvoting.qh>
#include "score.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include "scoreboard.qh"
#include <common/ent_cs.qh>
#include <common/mapinfo.qh>
#include "scoreboard.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include "quickmenu.qh"
#include <common/ent_cs.qh>
#include <common/constants.qh>
#include "timer.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
+
// Timer (#5)
void HUD_Timer()
#include "vote.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
#include <common/mapinfo.qh>
// Vote (#9)
#include "weapons.qh"
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
+#include <client/view.qh>
+#include <common/wepent.qh>
// Weapons (#0)
#include "main.qh"
+#include "miscfunctions.qh"
+#include <common/effects/effect.qh>
#include <common/effects/qc/all.qh>
+#include <common/effects/all.qh>
+#include <common/effects/all.inc>
#include "hud/_mod.qh"
#include "mapvoting.qh"
#include "mutators/events.qh"
void Spawn_Draw(entity this)
{
+ if(this.alpha <= 0)
+ return;
+
__pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
}
float alph;
vector org = getpropertyvec(VF_ORIGIN);
if(this.fade_start)
- alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1);
+ {
+ if(vdist(org - this.origin, >, this.fade_end))
+ alph = 0; // save on some processing
+ else if(vdist(org - this.origin, <, this.fade_start))
+ alph = 1; // more processing saved
+ else
+ alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1);
+ }
else
alph = 1;
//printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
race_nextcheckpoint = ReadByte();
race_nextbesttime = ReadInt24_t();
- race_mybesttime = ReadInt24_t();
+ if(b != RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING) // not while spectating (matches server)
+ race_mybesttime = ReadInt24_t();
if(race_nextbestname)
strunzone(race_nextbestname);
string newname = ReadString();
- if(autocvar_cl_race_cptimes_onlyself)
+ if(autocvar_cl_race_cptimes_onlyself && b != RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING)
{
race_nextbesttime = race_mybesttime;
race_mybesttime = 0;
#include "mapvoting.qh"
+#include "autocvars.qh"
+#include "miscfunctions.qh"
+#include "defs.qh"
#include "hud/_mod.qh"
#include "hud/panel/scoreboard.qh"
#include "miscfunctions.qh"
+#include "autocvars.qh"
+#include "defs.qh"
#include "hud/_mod.qh"
#include <common/command/_mod.qh>
/** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(DrawViewModel, EV_DrawViewModel);
+
+/** Called when updating the view's liquid contents, return true to disable the standard checks and apply your own */
+MUTATOR_HOOKABLE(HUD_Contents, EV_NO_ARGS);
+
+/** Return true to disable player model/color forcing */
+#define EV_ForcePlayermodels_Skip(i, o) \
+ /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** is local */ i(bool, MUTATOR_ARGV_1_bool) \
+ /**/
+MUTATOR_HOOKABLE(ForcePlayermodels_Skip, EV_ForcePlayermodels_Skip);
+
+/** Called when damage info is received on the client, useful for playing explosion effects */
+#define EV_DamageInfo(i, o) \
+ /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** death type */ i(int, MUTATOR_ARGV_1_int) \
+ /** hit origin */ i(vector, MUTATOR_ARGV_2_vector) \
+ /**/
+MUTATOR_HOOKABLE(DamageInfo, EV_DamageInfo);
#pragma once
+#include <common/util.qh>
+
void free_skeleton_from_frames(entity e);
void skeleton_from_frames(entity e, float is_dead);
void skeleton_loadinfo(entity e);
#include <lib/_all.inc>
#if XONOTIC
-#include <client/_all.inc>
+
+#include <client/_mod.inc>
+
+#include <common/_all.inc>
+#include <common/effects/qc/all.qc>
+
+#include <lib/csqcmodel/cl_model.qc>
+#include <lib/csqcmodel/cl_player.qc>
+#include <lib/csqcmodel/interpolate.qc>
+
+#include <lib/warpzone/anglestransform.qc>
+#include <lib/warpzone/common.qc>
+#include <lib/warpzone/client.qc>
+#include <lib/warpzone/server.qc>
+#include <lib/warpzone/util_server.qc>
#include <ecs/_mod.inc>
#endif
#include "shownames.qh"
+#include "autocvars.qh"
+#include "miscfunctions.qh"
#include "hud/_mod.qh"
#include <common/ent_cs.qh>
#include "teamradar.qh"
+#include "autocvars.qh"
#include "hud/_mod.qh"
#include <common/mutators/mutator/waypoints/all.qh>
#include "view.qh"
+#include "autocvars.qh"
+#include "miscfunctions.qh"
#include "announcer.qh"
#include "hud/_mod.qh"
#include "mapvoting.qh"
#include <common/stats.qh>
#include <common/triggers/target/music.qh>
#include <common/teams.qh>
+#include <common/wepent.qh>
#include <common/weapons/weapon/tuba.qh>
e.csqcmodel_effects = fx;
CSQCModel_Effects_Apply(e);
}
+ if(a >= 0)
{
string name = wep.mdl;
string newname = wep.wr_viewmodel(wep, this);
// improved polyblend
- if(autocvar_hud_contents)
+ if(autocvar_hud_contents && !MUTATOR_CALLHOOK(HUD_Contents))
{
float contentalpha_temp, incontent, liquidalpha, contentfadetime;
vector liquidcolor;
#pragma once
+#include <common/weapons/weapon.qh>
+
vector crosshair_getcolor(entity this, float health_stat);
entity viewmodels[MAX_WEAPONSLOTS];
#include "wall.qh"
+#include "autocvars.qh"
+#include "main.qh"
#include "bgmscript.qh"
#include "../mutators/events.qh"
#include <common/constants.qh>
+#include <common/effects/effect.qh>
+#include <common/effects/all.qh>
#include <common/net_linked.qh>
#include <common/physics/movetypes/movetypes.qh>
#pragma once
+#include <common/sounds/sound.qh>
+
entityclass(Projectile);
class(Projectile).int traileffect;
}
else // add it to the end of the list if the list doesn't already have it
{
- argc = tokenizebyseparator(cvar_string(original_cvar), " ");
- int i;
- for(i = 0; i < argc; ++i)
- if(argv(i) == tmp_string)
- return; // already in list
+ FOREACH_WORD(cvar_string(original_cvar), it == tmp_string,
+ {
+ return; // already in the list
+ });
- cvar_set(original_cvar, strcat(tmp_string, " ", cvar_string(original_cvar)));
+ cvar_set(original_cvar, cons(cvar_string(original_cvar), tmp_string));
}
return;
}
{
if(argc == 3)
{
- float i;
string original_cvar = argv(1);
string removal = argv(2);
- string tmp_string;
- argc = tokenizebyseparator(cvar_string(original_cvar), " ");
-
- tmp_string = "";
- for(i = 0; i < argc; ++i)
- if(argv(i) != removal)
- tmp_string = strcat(tmp_string, " ", argv(i));
+ string tmp_string = "";
+ FOREACH_WORD(cvar_string(original_cvar), it != removal,
+ {
+ tmp_string = cons(tmp_string, it);
+ });
- tmp_string = substring(tmp_string, 1, strlen(tmp_string) - 1);
cvar_set(original_cvar, tmp_string);
return;
+#pragma once
// Global list of effects, networked to CSQC by ID to save bandwidth and to use client particle numbers (allows mismatching effectinfos to some degree)
// Not too concerned about the order of this list, just keep the weapon effects together!
}
}
+ MUTATOR_CALLHOOK(DamageInfo, this, w_deathtype, w_org);
+
// TODO spawn particle effects and sounds based on w_deathtype
if(!DEATH_ISSPECIAL(w_deathtype))
if(!hitplayer || rad) // don't show ground impacts for hitscan weapons if a player was hit
#pragma once
+#ifdef CSQC
+#include <client/defs.qh>
+#endif
+
REGISTER_NET_LINKED(ENT_CLIENT_ENTCS)
REGISTER_NET_TEMP(CLIENT_ENTCS)
REGISTRY(Items, BITS(7))
#define Items_from(i) _Items_from(i, NULL)
+#ifdef GAMEQC
+REGISTRY_DEPENDS(Items, Models)
+#endif
REGISTER_REGISTRY(Items)
#define REGISTER_ITEM(id, class) REGISTER(Items, ITEM, id, m_id, NEW(class))
#pragma once
#include <common/t_items.qh>
+#ifdef GAMEQC
+#include <common/sounds/all.qh>
+#include <common/sounds/all.inc>
+#endif
+
const int IT_UNLIMITED_WEAPON_AMMO = BIT(0); // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
const int IT_UNLIMITED_SUPERWEAPONS = BIT(1); // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
#include <common/items/item.qh>
#include <common/t_items.qh>
+#ifdef GAMEQC
+#include <common/models/all.qh>
+#include <common/sounds/all.qh>
+#include <common/sounds/all.inc>
+#endif
+
CLASS(Pickup, GameItem)
#ifdef GAMEQC
ATTRIB(Pickup, m_model, Model);
#include "cl_minigames_hud.qh"
+#include <client/autocvars.qh>
#include <common/ent_cs.qh>
#include "minigames.qh"
minigame_drawpic_centered( tile_pos,
minigame_texture(thepiece),
tile_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL );
- }
+ }
}
else if ( e.classname == "minigame_board_piece" )
{
default:
case BD_DIR_DN: theang = M_PI; break;
case BD_DIR_LF: theang = M_PI * 3 / 2; break;
- case BD_DIR_RT: theang = M_PI / 2; break;
+ case BD_DIR_RT: theang = M_PI / 2; break;
}
drawrotpic(tile_pos, theang, minigame_texture("bd/dozer"),
#include "nmm.qh"
+
+#ifdef CSQC
+#include <client/miscfunctions.qh>
+#endif
+
REGISTER_MINIGAME(nmm, "Nine Men's Morris");
const int NMM_TURN_PLACE = 0x0100; // player has to place a piece on the board
GameLogEcho(strcat(":minigame:part:",minigame_session.netname,":",
ftos(etof(player)),":",player.netname));
minigame_session.minigame_players = p.list_next;
- delete ( p );
+ delete( p );
player_clear_minigame(player);
}
else
#ifdef SVQC
#include <common/monsters/sv_spawn.qh>
#endif
+#ifdef SVQC
+ #include <common/monsters/sv_spawner.qh>
+#endif
#include <common/monsters/monster/_mod.qh>
Send_Effect(EFFECT_EXPLOSION_SMALL, this.origin, '0 0 0', 1);
RadiusDamage (this, this.realowner, (autocvar_g_monster_mage_attack_spike_damage), (autocvar_g_monster_mage_attack_spike_damage) * 0.5, (autocvar_g_monster_mage_attack_spike_radius), NULL, NULL, 0, DEATH_MONSTER_MAGE.m_id, directhitentity);
- delete (this);
+ delete(this);
}
void M_Mage_Attack_Spike_Touch(entity this, entity toucher)
if(monster == "random")
{
- RandomSelection_Init();
+ RandomSelection_Init();
FOREACH(Monsters, it != MON_Null && !(it.spawnflags & MONSTER_TYPE_PASSIVE) && !(it.spawnflags & MON_FLAG_HIDDEN),
{
RandomSelection_AddEnt(it, 1, 1);
+#include "sv_spawner.qh"
#include "sv_spawn.qh"
void spawner_use(entity this, entity actor, entity trigger)
--- /dev/null
+#pragma once
#pragma once
+#ifdef CSQC
+#include <client/main.qh>
+#endif
+
const int CBC_ORDER_FIRST = 1;
const int CBC_ORDER_LAST = 2;
const int CBC_ORDER_EXCLUSIVE = 3;
void NET_Mutator_Remove(entity this)
{
string s = this.netname;
- WITH(bool, mutator_log, true, LAMBDA(
+ WITH(bool, mutator_log, true, {
FOREACH(Mutators, it.registered_id == s, Mutator_Remove(it));
- ));
+ });
}
NET_HANDLE(Mutator, bool isNew)
{
make_pure(this);
this.entremove = NET_Mutator_Remove;
int added = 0;
- WITH(bool, mutator_log, true, LAMBDA(
+ WITH(bool, mutator_log, true, {
FOREACH(Mutators, it.registered_id == s, { Mutator_Add(it); ++added; });
- ));
+ });
if (added > 1) LOG_WARNF("Added more than one mutator for %s", s);
}
}
{
if (flags)
{
- FOREACH(Buffs, it.m_itemid & _buffs, LAMBDA(return it));
+ FOREACH(Buffs, it.m_itemid & _buffs, { return it; });
}
return BUFF_Null;
}
MUTATOR_HOOKFUNCTION(cl_buffs, HUD_Powerups_add)
{
int allBuffs = STAT(BUFFS);
- FOREACH(Buffs, it.m_itemid & allBuffs, LAMBDA(
+ FOREACH(Buffs, it.m_itemid & allBuffs, {
addPowerupItem(it.m_prettyName, strcat("buff_", it.m_name), it.m_color, bound(0, STAT(BUFF_TIME) - time, 99), 60);
- ));
+ });
}
MUTATOR_HOOKFUNCTION(cl_buffs, WP_Format)
{
{
float best_distance = autocvar_g_buffs_swapper_range;
entity closest = NULL;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(!IS_DEAD(it) && !STAT(FROZEN, it) && !it.vehicle)
if(DIFF_TEAM(it, player))
{
closest = it;
}
}
- ));
+ });
if(closest)
{
const float armor = M_ARGV(3, float);
const int deathtype = M_ARGV(5, int);
const float potential_damage = M_ARGV(6, float);
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
if (
(SV_DAMAGETEXT_ALL()) ||
(SV_DAMAGETEXT_PLAYERS() && it == attacker) ||
else WriteShort(MSG_ONE, potential_damage * DAMAGETEXT_PRECISION_MULTIPLIER);
}
}
- ));
+ });
}
MUTATOR_HOOKFUNCTION(mutator_instagib, MatchEnd)
{
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(instagib_stop_countdown(it)));
+ FOREACH_CLIENT(IS_PLAYER(it), { instagib_stop_countdown(it); });
}
MUTATOR_HOOKFUNCTION(mutator_instagib, MonsterDropItem)
#ifdef CSQC
void Item_ItemsTime_Init()
{
- FOREACH(Items, true, LAMBDA(
+ FOREACH(Items, true, {
ItemsTime_time[it.m_id] = -1;
- ));
+ });
ItemsTime_time[Items_MAX] = -1;
}
void Item_ItemsTime_Init()
{
- FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it), {
it_times[it.m_id] = -1;
- ));
+ });
it_times[Items_MAX] = -1;
}
void Item_ItemsTime_ResetTimes()
{
- FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it), {
it_times[it.m_id] = (it_times[it.m_id] == -1) ? -1 : 0;
- ));
+ });
it_times[Items_MAX] = (it_times[Items_MAX] == -1) ? -1 : 0;
}
void Item_ItemsTime_ResetTimesForPlayer(entity e)
{
- FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it), {
IT_Write(e, it.m_id, (it_times[it.m_id] == -1) ? -1 : 0);
- ));
+ });
IT_Write(e, Items_MAX, (it_times[Items_MAX] == -1) ? -1 : 0);
}
void Item_ItemsTime_SetTimesForPlayer(entity e)
{
- FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it), {
IT_Write(e, it.m_id, it_times[it.m_id]);
- ));
+ });
IT_Write(e, Items_MAX, it_times[Items_MAX]);
}
void Item_ItemsTime_SetTimesForAllPlayers()
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && (warmup_stage || !IS_PLAYER(it) || autocvar_sv_itemstime == 2), LAMBDA(Item_ItemsTime_SetTimesForPlayer(it)));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && (warmup_stage || !IS_PLAYER(it) || autocvar_sv_itemstime == 2), { Item_ItemsTime_SetTimesForPlayer(it); });
}
float Item_ItemsTime_UpdateTime(entity e, float t)
int count = 0;
if (autocvar_hud_panel_itemstime_hidespawned == 1)
{
- FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it), {
count += (Item_ItemsTime_GetTime(it.m_id) > time || -Item_ItemsTime_GetTime(it.m_id) > time);
- ));
+ });
count += (Item_ItemsTime_GetTime(Items_MAX) > time || -Item_ItemsTime_GetTime(Items_MAX) > time);
}
else if (autocvar_hud_panel_itemstime_hidespawned == 2)
{
- FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it), {
count += (Item_ItemsTime_GetTime(it.m_id) > time);
- ));
+ });
count += (Item_ItemsTime_GetTime(Items_MAX) > time);
}
else
{
- FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it), {
count += (Item_ItemsTime_GetTime(it.m_id) != -1);
- ));
+ });
count += (Item_ItemsTime_GetTime(Items_MAX) != -1);
}
if (count == 0)
bool item_available;
int id = 0;
string icon = "";
- FOREACH(Items, Item_ItemsTime_Allow(it) && Item_ItemsTime_GetTime(it.m_id) != -1, LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it) && Item_ItemsTime_GetTime(it.m_id) != -1, {
id = it.m_id;
icon = it.m_icon;
}
if(id == Items_MAX) // can happen only in the last fake iteration
break;
- ));
+ });
// add another fake iteration for superweapons time
if(id < Items_MAX && Item_ItemsTime_GetTime(Items_MAX) != -1)
{
case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team);
}
- FOREACH(Nades, true, LAMBDA(
+ FOREACH(Nades, true, {
for (int j = 0; j < 2; j++)
{
if (it.m_projectile[j] == proj)
break;
}
}
- ));
+ });
return EFFECT_Null;
}
{
vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
n = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
if(!IS_DEAD(it))
if(STAT(FROZEN, it) == 0)
if(SAME_TEAM(it, player))
it.reviving = true;
++n;
}
- ));
+ });
}
if(n && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
}
- FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
it.revive_progress = player.revive_progress;
it.reviving = false;
- ));
+ });
}
}
Nade Nade_FromProjectile(int proj)
{
- FOREACH(Nades, true, LAMBDA(
+ FOREACH(Nades, true, {
for (int j = 0; j < 2; j++)
{
if (it.m_projectile[j] == proj) return it;
}
- ));
+ });
return NADE_TYPE_Null;
}
error("This cannot be added at runtime\n");
// mark the guns as ok to use by e.g. impulse 99
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(nt_IsNewToy(it.m_id))
it.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
- ));
+ });
}
MUTATOR_ONROLLBACK_OR_REMOVE
{
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(nt_IsNewToy(it.m_id))
it.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
- ));
+ });
}
MUTATOR_ONREMOVE
WepSet seti = '0 0 0';
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
seti = it.m_wepset;
n = tokenize_console(nt_GetReplacement(it.netname, autocvar_g_new_toys_autoreplace));
for(j = 0; j < n; ++j)
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(it.netname == argv(j))
{
WepSet setk = it.m_wepset;
if(start_weapons & seti) newdefault |= setk;
if(warmup_start_weapons & seti) warmup_newdefault |= setk;
}
- ));
- ));
+ });
+ });
newdefault &= start_weapons_defaultmask;
start_weapons &= ~start_weapons_defaultmask;
nix_nextchange = 0;
nix_nextweapon = 0;
- FOREACH(Weapons, it != WEP_Null && NIX_CanChooseWeapon(it.m_id), LAMBDA(it.wr_init(it)));
+ FOREACH(Weapons, it != WEP_Null && NIX_CanChooseWeapon(it.m_id), { it.wr_init(it); });
}
MUTATOR_ONROLLBACK_OR_REMOVE
void NIX_ChooseNextWeapon()
{
RandomSelection_Init();
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(NIX_CanChooseWeapon(it.m_id))
RandomSelection_AddFloat(it.m_id, 1, (it.m_id != nix_weapon));
- ));
+ });
nix_nextweapon = RandomSelection_chosen_float;
}
RadiusDamage (this, this.realowner, WEP_CVAR(rpc, damage), WEP_CVAR(rpc, edgedamage), WEP_CVAR(rpc, radius), NULL, NULL, WEP_CVAR(rpc, force), this.projectiledeathtype, directhitentity);
- delete (this);
+ delete(this);
}
void W_RocketPropelledChainsaw_Explode_think(entity this)
CLASS(RocketPropelledChainsaw, Weapon)
/* ammotype */ ATTRIB(RocketPropelledChainsaw, ammo_field, .int, ammo_rockets);
-/* impulse */ ATTRIB(RocketPropelledChainsaw, impulse, int, 7);
+/* impulse */ ATTRIB(RocketPropelledChainsaw, impulse, int, 9);
/* flags */ ATTRIB(RocketPropelledChainsaw, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH | WEP_FLAG_SUPERWEAPON);
/* rating */ ATTRIB(RocketPropelledChainsaw, bot_pickupbasevalue, float, 10000);
/* color */ ATTRIB(RocketPropelledChainsaw, wpcolor, vector, '0.5 0.5 0');
if(frag_target.(weaponentity).m_weapon == WEP_Null)
continue;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(frag_target.weapons & WepSet_FromWeapon(it))
if(frag_target.(weaponentity).m_weapon != it)
if(W_IsWeaponThrowable(frag_target, it.m_id))
W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325', weaponentity);
- ));
+ });
}
return true;
// since if the owning player disconnects, the object's owner should also be reset.
// bots can't have objects
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
if(this.crypto_idfp == it.crypto_idfp)
{
this.realowner = it;
break;
}
this.realowner = NULL;
- ));
+ });
this.nextthink = time;
sandbox_ObjectAttach_Remove(e); // detach child objects
// if the object being removed has been selected for attachment by a player, unset it
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.object_attach == e, LAMBDA(it.object_attach = NULL));
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.object_attach == e, { it.object_attach = NULL; });
if(e.material) { strunzone(e.material); e.material = string_null; }
if(e.crypto_idfp) { strunzone(e.crypto_idfp); e.crypto_idfp = string_null; }
return;
RandomSelection_Init();
- FOREACH_CLIENT(IS_PLAYER(it) && it != player && SAME_TEAM(it, player) && !IS_DEAD(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != player && SAME_TEAM(it, player) && !IS_DEAD(it), {
if(vdist(spawn_spot.origin - it.origin, >, autocvar_g_spawn_near_teammate_distance))
continue;
if(vdist(spawn_spot.origin - it.origin, <, 48))
if(!checkpvs(spawn_spot.origin, it))
continue;
RandomSelection_AddEnt(it, 1, 1);
- ));
+ });
if(RandomSelection_chosen_ent)
{
vector best_pos = '0 0 0';
float best_dist2 = FLOAT_MAX;
int tested = 0;
- FOREACH_CLIENT_RANDOM(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT_RANDOM(IS_PLAYER(it), {
if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_max && tested >= autocvar_g_spawn_near_teammate_ignore_spawnpoint_max) break;
if (PHYS_INPUT_BUTTON_CHAT(it)) continue;
break; // don't test the other spots near this teammate, go to the next one
}
}
- ));
+ });
if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
if(best_mate)
entity item = M_ARGV(0, entity);
entity toucher = M_ARGV(1, entity);
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
if(!IS_SPEC(it) && !IS_OBSERVER(it))
continue;
if(it.superspec_flags & SSF_ITEMMSG)
}
}
}
- ));
+ });
return MUT_ITEMTOUCH_CONTINUE;
}
if(cmd_name == "followpowerup")
{
- FOREACH_CLIENT(IS_PLAYER(it) && (it.strength_finished > time || it.invincible_finished > time), LAMBDA(return superspec_Spectate(player, it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && (it.strength_finished > time || it.invincible_finished > time), { return superspec_Spectate(player, it); });
superspec_msg("", "", player, "No active powerup\n", 1);
return true;
if(cmd_name == "followstrength")
{
- FOREACH_CLIENT(IS_PLAYER(it) && it.strength_finished > time, LAMBDA(return superspec_Spectate(player, it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && it.strength_finished > time, { return superspec_Spectate(player, it); });
superspec_msg("", "", player, "No active Strength\n", 1);
return true;
if(cmd_name == "followshield")
{
- FOREACH_CLIENT(IS_PLAYER(it) && it.invincible_finished > time, LAMBDA(return superspec_Spectate(player, it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && it.invincible_finished > time, { return superspec_Spectate(player, it); });
superspec_msg("", "", player, "No active Shield\n", 1);
return true;
entity frag_attacker = M_ARGV(1, entity);
entity frag_target = M_ARGV(2, entity);
- FOREACH_CLIENT(IS_SPEC(it), LAMBDA(
+ FOREACH_CLIENT(IS_SPEC(it), {
if(it.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && it.enemy == frag_target)
{
if(it.autospec_flags & ASF_SHOWWHAT)
superspec_Spectate(it, frag_attacker);
}
- ));
+ });
}
MUTATOR_HOOKFUNCTION(superspec, ClientDisconnect)
if(IS_PLAYER(player))
if(!IS_DEAD(player))
if(!IS_INDEPENDENT_PLAYER(player))
- FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
if(time > it.touchexplode_time)
if(!STAT(FROZEN, it))
if(!IS_DEAD(it))
PlayerTouchExplode(player, it);
player.touchexplode_time = it.touchexplode_time = time + 0.2;
}
- ));
+ });
}
if(!IS_DEAD(player))
{
vector plane_normal = PlayerTouchWall(player);
-
+
if(plane_normal != '0 0 0')
{
float wj_force = PHYS_WALLJUMP_FORCE(player);
}
// need to loop, as our netname could be one of three
- FOREACH(Waypoints, it.netname == s, LAMBDA(
+ FOREACH(Waypoints, it.netname == s, {
return it.m_name;
- ));
+ });
return s;
}
MSG_INFO_NOTIF(CHAT_NOSPECTATORS, N_CHATCON, 0, 0, "", "", "", _("^F4NOTE: ^BGSpectator chat is not sent to players during the match"), "")
MULTITEAM_INFO(CTF_CAPTURE, 4, N_CONSOLE, 1, 0, "s1", "s1", "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag"), "", FLAG)
- MULTITEAM_INFO(CTF_CAPTURE_BROKEN, 4, N_CONSOLE, 2, 2, "s1 f1p2dec s2 f2p2dec", "s1", "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%s^BG seconds, breaking ^BG%s^BG's previous record of ^F2%s^BG seconds"), "", FLAG)
+ MULTITEAM_INFO(CTF_CAPTURE_BROKEN, 4, N_CONSOLE, 2, 2, "s1 f1dtime s2 f2dtime", "s1", "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%s^BG seconds, breaking ^BG%s^BG's previous record of ^F2%s^BG seconds"), "", FLAG)
MSG_INFO_NOTIF(CTF_CAPTURE_NEUTRAL, N_CONSOLE, 1, 0, "s1", "s1", "notify_neutral_captured", _("^BG%s^BG captured the flag"), "")
- MULTITEAM_INFO(CTF_CAPTURE_TIME, 4, N_CONSOLE, 1, 1, "s1 f1p2dec", "s1", "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%s^BG seconds"), "", FLAG)
- MULTITEAM_INFO(CTF_CAPTURE_UNBROKEN, 4, N_CONSOLE, 2, 2, "s1 f1p2dec s2 f2p2dec", "s1", "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F2%s^BG seconds, failing to break ^BG%s^BG's previous record of ^F1%s^BG seconds"), "", FLAG)
+ MULTITEAM_INFO(CTF_CAPTURE_TIME, 4, N_CONSOLE, 1, 1, "s1 f1dtime", "s1", "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F1%s^BG seconds"), "", FLAG)
+ MULTITEAM_INFO(CTF_CAPTURE_UNBROKEN, 4, N_CONSOLE, 2, 2, "s1 f1dtime s2 f2dtime", "s1", "notify_%s_captured", _("^BG%s^BG captured the ^TC^TT^BG flag in ^F2%s^BG seconds, failing to break ^BG%s^BG's previous record of ^F1%s^BG seconds"), "", FLAG)
MULTITEAM_INFO(CTF_FLAGRETURN_ABORTRUN, 4, N_CONSOLE, 0, 0, "", "", "", _("^BGThe ^TC^TT^BG flag was returned to base by its owner"), "", FLAG)
MSG_INFO_NOTIF(CTF_FLAGRETURN_ABORTRUN_NEUTRAL, N_CONSOLE, 0, 0, "", "", "", _("^BGThe flag was returned by its owner"), "")
MULTITEAM_INFO(CTF_FLAGRETURN_DAMAGED, 4, N_CONSOLE, 0, 0, "", "", "", _("^BGThe ^TC^TT^BG flag was destroyed and returned to base"), "", FLAG)
MSG_INFO_NOTIF(CTF_FLAGRETURN_DROPPED_NEUTRAL, N_CONSOLE, 0, 0, "", "", "", _("^BGThe flag was dropped in the base and returned itself"), "")
MULTITEAM_INFO(CTF_FLAGRETURN_NEEDKILL, 4, N_CONSOLE, 0, 0, "", "", "", _("^BGThe ^TC^TT^BG flag fell somewhere it couldn't be reached and returned to base"), "", FLAG)
MSG_INFO_NOTIF(CTF_FLAGRETURN_NEEDKILL_NEUTRAL, N_CONSOLE, 0, 0, "", "", "", _("^BGThe flag fell somewhere it couldn't be reached and returned to base"), "")
- MULTITEAM_INFO(CTF_FLAGRETURN_SPEEDRUN, 4, N_CONSOLE, 0, 1, "f1p2dec", "", "", _("^BGThe ^TC^TT^BG flag became impatient after ^F1%.2f^BG seconds and returned itself"), "", FLAG)
- MSG_INFO_NOTIF(CTF_FLAGRETURN_SPEEDRUN_NEUTRAL, N_CONSOLE, 0, 1, "f1p2dec", "", "", _("^BGThe flag became impatient after ^F1%.2f^BG seconds and returned itself"), "")
+ MULTITEAM_INFO(CTF_FLAGRETURN_SPEEDRUN, 4, N_CONSOLE, 0, 1, "f1dtime", "", "", _("^BGThe ^TC^TT^BG flag became impatient after ^F1%.2f^BG seconds and returned itself"), "", FLAG)
+ MSG_INFO_NOTIF(CTF_FLAGRETURN_SPEEDRUN_NEUTRAL, N_CONSOLE, 0, 1, "f1dtime", "", "", _("^BGThe flag became impatient after ^F1%.2f^BG seconds and returned itself"), "")
MULTITEAM_INFO(CTF_FLAGRETURN_TIMEOUT, 4, N_CONSOLE, 0, 0, "", "", "", _("^BGThe ^TC^TT^BG flag has returned to the base"), "", FLAG)
MSG_INFO_NOTIF(CTF_FLAGRETURN_TIMEOUT_NEUTRAL, N_CONSOLE, 0, 0, "", "", "", _("^BGThe flag has returned to the base"), "")
MULTITEAM_INFO(CTF_LOST, 4, N_CONSOLE, 1, 0, "s1", "s1", "notify_%s_lost", _("^BG%s^BG lost the ^TC^TT^BG flag"), "", FLAG)
#include <common/teams.qh>
#include <common/util.qh>
+#ifdef CSQC
+#include <client/autocvars.qh>
+#endif
+
/** main types/groups of notifications */
ENUMCLASS(MSG)
/** "Global" AND "personal" announcer messages */
ARG_CASE(ARG_CS_SV_DC, "f2", ftos(f2)) \
ARG_CASE(ARG_CS_SV, "f3", ftos(f3)) \
ARG_CASE(ARG_CS_SV, "f4", ftos(f4)) \
- ARG_CASE(ARG_CS_SV, "f1p2dec", ftos_decimals(f1/100, 2)) \
- ARG_CASE(ARG_CS_SV, "f2p2dec", ftos_decimals(f2/100, 2)) \
+ ARG_CASE(ARG_CS_SV, "f1dtime", ftos_decimals(TIME_DECODE(f1), 2)) \
+ ARG_CASE(ARG_CS_SV, "f2dtime", ftos_decimals(TIME_DECODE(f2), 2)) \
ARG_CASE(ARG_CS, "f2primsec", (f2 ? _("secondary") : _("primary"))) \
ARG_CASE(ARG_CS, "f3primsec", (f3 ? _("secondary") : _("primary"))) \
ARG_CASE(ARG_CS, "f1secs", count_seconds(f1)) \
{
#ifdef SVQC
// needs to be called before physics are run!
- PM_UpdateButtons(this, CS(this));
+ if(IS_REAL_CLIENT(this))
+ PM_UpdateButtons(this, CS(this));
#endif
sys_phys_update(this, PHYS_INPUT_TIMELENGTH);
+#pragma once
+
// Global list of sounds
// TODO: remove uses of _sound
#include "all.qh"
#ifdef SVQC
+#include <server/utils.qh>
+
bool autocvar_bot_sound_monopoly;
.entity realowner;
#pragma once
#ifdef SVQC
+#include <server/autocvars.qh>
#include <server/client.qh>
#endif
}
float alph;
vector org = getpropertyvec(VF_ORIGIN);
- if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones
- alph = 0;
- else if(this.fade_start)
- alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1);
+ //if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones
+ //alph = 0; // this shouldn't be needed, since items behind walls are culled anyway
+ if(this.fade_start)
+ {
+ if(vdist(org - this.origin, >, this.fade_end))
+ alph = 0; // save on some processing
+ else if(vdist(org - this.origin, <, this.fade_start))
+ alph = 1; // more processing saved
+ else
+ alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1);
+ }
else
alph = 1;
//printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
_sound (toucher, (this.itemdef.instanceOfPowerup ? CH_TRIGGER_SINGLE : CH_TRIGGER), (this.item_pickupsound ? this.item_pickupsound : Sound_fixpath(this.item_pickupsound_ent)), VOL_BASE, ATTEN_NORM);
if (this.classname == "droppedweapon")
- delete (this);
+ delete(this);
else if (this.spawnshieldtime)
{
entity e;
if(!have_pickup_item(this))
{
startitem_failed = true;
- delete (this);
+ delete(this);
return;
}
// target_give not yet supported; maybe later
print("removed targeted ", this.classname, "\n");
startitem_failed = true;
- remove (this);
+ delete(this);
return;
}
*/
#pragma once
+#ifdef SVQC
+#include <server/defs.qh>
+#endif
+
const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
// item networking
else
{
// remove
- delete (ent);
+ delete(ent);
}
}
// generated file; do not modify
#include <common/triggers/target/changelevel.qh>
#include <common/triggers/target/include.qh>
+#include <common/triggers/target/kill.qh>
#include <common/triggers/target/levelwarp.qh>
#include <common/triggers/target/location.qh>
#include <common/triggers/target/music.qh>
+#include "kill.qh"
#include "location.qh"
#ifdef SVQC
--- /dev/null
+#pragma once
multi_wait(this); // waiting finished
}
else
- { // we can't just remove (this) here, because this is a touch function
+ { // we can't just delete(this) here, because this is a touch function
// called while C code is looping through area links...
settouch(this, func_null);
}
// handle normal trigger features
multi_touch(this, toucher);
- // we can't just remove (this) here, because this is a touch function
+ // we can't just delete(this) here, because this is a touch function
// called while C code is looping through area links...
//delete(this);
}
setthink(e, turrets_manager_think);
e.nextthink = time + 2;
}
-
+
entity targ = find(NULL, targetname, this.target);
if(targ.classname == "turret_checkpoint")
return; // turrets don't defend checkpoints?
#pragma once
+#include <server/miscfunctions.qh>
+
entity turret_projectile(entity actor, Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim);
void turret_projectile_explode(entity this);
float turret_validate_target(entity e_turret, entity e_target, float validate_flags);
void walker_rocket_explode(entity this)
{
RadiusDamage (this, this.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), this, NULL, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id, NULL);
- delete (this);
+ delete(this);
}
void walker_rocket_touch(entity this, entity toucher)
// for each element, funcPre is called first, then funcPre and funcPost for all its children, and funcPost last
void depthfirst(entity start, .entity up, .entity downleft, .entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass);
-// adding just 0.4 for race times so it rounds down in the .5 case (matching the timer display)
-// FIXME it doesn't round properly
-#define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.4)
+#define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.5)
const int TIME_DECIMALS = 2;
const float TIME_FACTOR = 100;
this.event_damage = func_null;
RadiusDamage (this, this.realowner, this.shot_dmg, 0, this.shot_radius, this, NULL, this.shot_force, this.totalfrags, toucher);
- delete (this);
+ delete(this);
}
void vehicles_projectile_explode_think(entity this)
}
if (!PHYS_INPUT_BUTTON_JUMP(this))
- PHYS_INPUT_BUTTON_JUMP(vehic) = false;
+ vehic.button2 = false;
- if((IS_ONGROUND(vehic)) && PHYS_INPUT_BUTTON_JUMP(this) && !PHYS_INPUT_BUTTON_JUMP(vehic) && vehic.tur_head.wait < time)
+ if((IS_ONGROUND(vehic)) && PHYS_INPUT_BUTTON_JUMP(this) && !vehic.button2 && vehic.tur_head.wait < time)
{
sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
//dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
vehic.tur_head.wait = time + 2;
vehic.jump_delay = time + 2;
- PHYS_INPUT_BUTTON_JUMP(vehic) = true; // set spider's jump
+ vehic.button2 = true; // set spider's jump
//PHYS_INPUT_BUTTON_JUMP(this) = false;
vector movefix = '0 0 0';
#include <common/stats.qh>
#include "config.qh"
-// weapon sets
-USING(WepSet, vector);
+#include "weapon.qh"
+
#ifdef SVQC
void WriteWepSet(float dest, WepSet w);
#endif
WepSet ReadWepSet();
#endif
-#include "weapon.qh"
-
#ifdef GAMEQC
#include "calculations.qh"
#include "projectiles.qh"
#include <common/effects/qc/all.qh>
#endif
+USING(WepSet, vector);
+
const int MAX_WEAPONSLOTS = 2;
.entity weaponentities[MAX_WEAPONSLOTS];
sys_in_update(this, dt);
sys_phys_fix(this, dt);
- if (sys_phys_override(this, dt)) { return; } sys_phys_monitor(this, dt);
+ if (sys_phys_override(this, dt))
+ return;
+
+ sys_phys_monitor(this, dt);
PHYS_CS(this).movement_old = PHYS_CS(this).movement;
PHYS_CS(this).v_angle_old = this.v_angle;
*/
#define REGISTRY(id, max) \
void Register##id(); \
+ [[accumulate]] void REGISTRY_DEPENDS_(id) {} \
[[accumulate]] REGISTRY_BEGIN(id) {} \
[[accumulate]] REGISTRY_END(id) {} \
void _Register##id() {} \
- void Register##id() { REGISTRY_BEGIN_(id); _Register##id(); REGISTRY_END_(id); } \
+ int id##_state = 0; \
+ void Register##id() { if (id##_state) return; id##_state = 1; REGISTRY_DEPENDS_(id); REGISTRY_BEGIN_(id); _Register##id(); id##_state = 2; REGISTRY_END_(id); } \
const int id##_MAX = max; \
int id##_COUNT; \
noref entity id##_first, id##_last; \
SHUTDOWN(id) { _R_DEL(_##id); } \
entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _R_GET(_##id, i); if (e) return e; } return null; }
+/** Add registry dependencies to a registry */
+#define REGISTRY_DEPENDS(id, dep) void Register##dep(); void REGISTRY_DEPENDS_(id) { Register##dep(); }
+#define REGISTRY_DEPENDS_(id) Register##id##_Depends()
+
/** Called before initializing a registry. */
#define REGISTRY_BEGIN(id) [[accumulate]] void REGISTRY_BEGIN_(id) { noref void() f = Register##id; } void REGISTRY_BEGIN_(id)
#define REGISTRY_BEGIN_(id) Register##id##_First()
ENDCLASS(id##Registry) \
REGISTER(Registries, REGISTRY, id, m_id, NEW(id##Registry)); \
METHOD(id##Registry, m_reload, void()) { \
+ id##_state = 0; \
Register##id(); \
}
return e;
}
-float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
+bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
{
return !WarpZoneLib_BoxTouchesBrush(toucher.absmin, toucher.absmax, this, toucher);
}
}
}
-float WarpZoneLib_MoveOutOfSolid(entity e)
+bool WarpZoneLib_MoveOutOfSolid(entity e)
{
- vector o, m0, m1;
-
- o = e.origin;
+ vector o = e.origin;
traceline(o, o, MOVE_WORLDONLY, e);
if (trace_startsolid)
return false;
if (!trace_startsolid)
return true;
- m0 = e.mins;
- m1 = e.maxs;
+ vector m0 = e.mins;
+ vector m1 = e.maxs;
e.mins = '0 0 0';
e.maxs = '0 0 0';
- WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m0_x);
- e.mins_x = m0_x;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m1_x);
- e.maxs_x = m1_x;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m0_y);
- e.mins_y = m0_y;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m1_y);
- e.maxs_y = m1_y;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m0_z);
- e.mins_z = m0_z;
- WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m1_z);
- e.maxs_z = m1_z;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, eX * m0.x); e.mins.x = m0.x;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, eX * m1.x); e.maxs.x = m1.x;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, eY * m0.y); e.mins.y = m0.y;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, eY * m1.y); e.maxs.y = m1.y;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, eZ * m0.z); e.mins.z = m0.z;
+ WarpZoneLib_MoveOutOfSolid_Expand(e, eZ * m1.z); e.maxs.z = m1.z;
setorigin(e, e.origin);
tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
#ifndef BITXOR_ASSIGN
# define BITXOR_ASSIGN(a,b) ((a) = ((a) | (b)) - ((a) & (b)))
#endif
-float WarpZoneLib_MoveOutOfSolid(entity e);
+bool WarpZoneLib_MoveOutOfSolid(entity e);
#define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
-float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
+bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
void WarpZoneLib_ExactTrigger_Init(entity this);
// WARNING: this kills the trace globals
WarpZone_StoreProjectileData(it);
});
}
-
+
FOREACH_CLIENT(true,
{
#pragma once
-float WarpZoneLib_MoveOutOfSolid(entity e);
-float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
+bool WarpZoneLib_MoveOutOfSolid(entity e);
+bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
#ifdef SVQC
void WarpZoneLib_ExactTrigger_Init(entity this);
#endif
+++ /dev/null
-#include <menu/_all.qh>
-#include "_mod.inc"
-
-#include "anim/_mod.inc"
-#include "command/_mod.inc"
-#include "item/_mod.inc"
-#include "mutators/_mod.inc"
-#include "xonotic/_mod.inc"
-
-#include <common/_all.inc>
+++ /dev/null
-#pragma once
-
-#include "draw.qh"
-#include "xonotic/util.qh"
-#include "menu.qh"
#include <menu/item.qc>
#include <menu/matrix.qc>
#include <menu/menu.qc>
+
+#include <menu/anim/_mod.inc>
+#include <menu/command/_mod.inc>
+#include <menu/item/_mod.inc>
+#include <menu/mutators/_mod.inc>
+#include <menu/xonotic/_mod.inc>
#include <menu/item.qh>
#include <menu/matrix.qh>
#include <menu/menu.qh>
+
+#include <menu/anim/_mod.qh>
+#include <menu/command/_mod.qh>
+#include <menu/item/_mod.qh>
+#include <menu/mutators/_mod.qh>
+#include <menu/xonotic/_mod.qh>
// convenience
#include "skin.qh"
+#include "draw.qh"
+#include "menu.qh"
CLASS(Item, Object)
METHOD(Item, draw, void(Item));
#include <lib/_all.inc>
#if XONOTIC
-#include <menu/_all.inc>
+
+#include "_mod.inc"
+
+#include <common/_all.inc>
+
#endif
#ifdef BUILD_MOD
s = "";
for(i = 0; i < n; ++i)
{
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(argv(i) == it.netname)
s = strcat(s, " & ", it.m_name);
- ));
+ });
}
s = sprintf(_("%s Arena"), substring(s, 3, strlen(s) - 3));
int i;
#define ADD_TO_W_LIST(pred) \
- FOREACH(Weapons, it != WEP_Null, LAMBDA( \
+ FOREACH(Weapons, it != WEP_Null, { \
if (it.impulse != imp) continue; \
if (!(pred)) continue; \
w_list = strcat(w_list, it.m_name, " / "); \
- ))
+ })
for(int imp = 1; imp <= 9; ++imp)
{
+++ /dev/null
-#include <server/_all.qh>
-#include "_mod.inc"
-
-#include "bot/_mod.inc"
-#include "command/_mod.inc"
-#include "compat/_mod.inc"
-#include "mutators/_mod.inc"
-#include "pathlib/_mod.inc"
-#include "weapons/_mod.inc"
-
-#include <common/_all.inc>
-#include <common/effects/qc/all.qc>
-
-#include <lib/csqcmodel/sv_model.qc>
-
-#include <lib/warpzone/anglestransform.qc>
-#include <lib/warpzone/common.qc>
-#include <lib/warpzone/server.qc>
-#include <lib/warpzone/util_server.qc>
+++ /dev/null
-#pragma once
-
-int maxclients;
-
-const string STR_PLAYER = "player";
-const string STR_SPECTATOR = "spectator";
-const string STR_OBSERVER = "observer";
-
-#define IS_PLAYER(v) ((v).classname == STR_PLAYER)
-#define IS_SPEC(v) ((v).classname == STR_SPECTATOR)
-#define IS_OBSERVER(v) ((v).classname == STR_OBSERVER)
-
-#define IS_CLIENT(v) (v.flags & FL_CLIENT)
-/** want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v)) */
-#define IS_BOT_CLIENT(v) (clienttype(v) == CLIENTTYPE_BOT)
-#define IS_FAKE_CLIENT(v) (clienttype(v) == CLIENTTYPE_NOTACLIENT)
-#define IS_REAL_CLIENT(v) (clienttype(v) == CLIENTTYPE_REAL)
-/** was: (clienttype(v) == CLIENTTYPE_NOTACLIENT) */
-#define IS_NOT_A_CLIENT(v) (!IS_CLIENT(v))
-
-#define IS_MONSTER(v) (v.flags & FL_MONSTER)
-#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, { 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), { 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 { \
- for(int _i = 1; _i <= maxclients; ++_i) \
- { \
- const noref int i = _i; \
- ITER_CONST noref entity it = ftoe(i); \
- if(cond) { LAMBDA(body) } \
- } \
- } MACRO_END
-
-#define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
-
-// using the "inside out" version of knuth-fisher-yates shuffle
-// https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
-entity _FCR_clients[255];
-bool _FCR_entered = false;
-#define FOREACH_CLIENT_RANDOM(cond, body) \
- MACRO_BEGIN { \
- if (_FCR_entered) LOG_FATAL("FOREACH_CLIENT_RANDOM must not be nested"); \
- _FCR_entered = true; \
- int _cnt = 0; \
- FOREACH_CLIENT(cond, LAMBDA( \
- int _j = floor(random() * (_cnt + 1)); \
- if (_j == _cnt) \
- { \
- _FCR_clients[_cnt] = it; \
- } \
- else \
- { \
- _FCR_clients[_cnt] = _FCR_clients[_j]; \
- _FCR_clients[_j] = it; \
- } \
- _cnt++; \
- )); \
- for (int _i = 0; _i < _cnt; ++_i) \
- { \
- const noref int i = _i; \
- ITER_CONST noref entity it = _FCR_clients[i]; \
- if (cond) { LAMBDA(body) } \
- } \
- _FCR_entered = false; \
- } MACRO_END
-
-// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: IL_EACH(g_monsters, true, { code; });
-
-#include <common/effects/all.qh>
-#include <common/models/all.qh>
-#include <common/sounds/all.qh>
-
-#include "autocvars.qh"
-#include "constants.qh"
-#include "defs.qh"
-#include "miscfunctions.qh"
#endif
#include <server/teamplay.qc>
#include <server/tests.qc>
+
+#include <server/bot/_mod.inc>
+#include <server/command/_mod.inc>
+#include <server/compat/_mod.inc>
+#include <server/mutators/_mod.inc>
+#include <server/pathlib/_mod.inc>
+#include <server/weapons/_mod.inc>
#endif
#include <server/teamplay.qh>
#include <server/tests.qh>
+
+#include <server/bot/_mod.qh>
+#include <server/command/_mod.qh>
+#include <server/compat/_mod.qh>
+#include <server/mutators/_mod.qh>
+#include <server/pathlib/_mod.qh>
+#include <server/weapons/_mod.qh>
#if defined(CSQC)
#elif defined(MENUQC)
#elif defined(SVQC)
+ #include <server/defs.qh>
#include <common/state.qh>
#include <common/vehicles/all.qh>
#include "antilag.qh"
#pragma once
+#include <server/defs.qh>
#include <common/weapons/_all.qh>
const int WAYPOINTFLAG_GENERATED = BIT(23);
#include "aim.qh"
+#include <server/defs.qh>
+
#include "cvars.qh"
#include "bot.qh"
continue;
s = argv(0);
prio = 1;
- FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_BOT_CLIENT(it), {
if(s == it.cleanname)
{
prio = 0;
break;
}
- ));
+ });
RandomSelection_AddString(readfile, 1, prio);
}
readfile = RandomSelection_chosen_string;
// number bots with identical names
int j = 0;
- FOREACH_CLIENT(IS_BOT_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_BOT_CLIENT(it), {
if(it.cleanname == name)
++j;
- ));
+ });
if (j)
this.netname = this.netname_freeme = strzone(strcat(prefix, name, "(", ftos(j), ")", suffix));
else
bestbot = -1;
bestplayer = -1;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(IS_REAL_CLIENT(it))
bestplayer = max(bestplayer, it.totalfrags - it.totalfrags_lastcheck);
else
bestbot = max(bestbot, it.totalfrags - it.totalfrags_lastcheck);
- ));
+ });
LOG_DEBUG("autoskill: best player got ", ftos(bestplayer), ", ");
LOG_DEBUG("best bot got ", ftos(bestbot), "; ");
// don't reset counters, wait for them to accumulate
}
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.totalfrags_lastcheck = it.totalfrags));
+ FOREACH_CLIENT(IS_PLAYER(it), { it.totalfrags_lastcheck = it.totalfrags; });
}
void bot_calculate_stepheightvec()
activerealplayers = M_ARGV(0, int);
realplayers = M_ARGV(1, int);
} else {
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
if(IS_PLAYER(it))
++activerealplayers;
++realplayers;
- ));
+ });
}
int bots;
#include "havocbot.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "../cvars.qh"
#include "../aim.qh"
if(skill >= 5) // bots can only look for unloaded weapons past this skill
if(this.(weaponentity).clip_load >= 0) // only if we're not reloading a weapon already
{
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if((this.weapons & (it.m_wepset)) && (it.spawnflags & WEP_FLAG_RELOADABLE) && (this.(weaponentity).weapon_load[it.m_id] < it.reloading_ammo))
{
this.(weaponentity).m_switchweapon = it;
break;
}
- ));
+ });
}
}
}
if(checkdistance)
{
this.aistatus &= ~AI_STATUS_RUNNING;
- // increase stop distance in case the goal is on a slope or a lower platform
+ // increase stop distance in case the goal is on a slope or a lower platform
if(bunnyhopdistance > autocvar_bot_ai_bunnyhop_stopdistance + (this.origin.z - gco.z))
PHYS_INPUT_BUTTON_JUMP(this) = true;
}
// if this weapon is scheduled for reloading, don't switch to it during combat
if (this.(weaponentity).weapon_load[new_weapon] < 0)
{
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(it.wr_checkammo1(it, this, weaponentity) + it.wr_checkammo2(it, this, weaponentity))
return true; // other weapon available
- ));
+ });
}
return false;
{
// If no weapon was chosen get the first available weapon
if(this.(weaponentity).m_weapon==WEP_Null)
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(client_hasweapon(this, it, weaponentity, true, false))
{
this.(weaponentity).m_switchweapon = it;
return;
}
- ));
+ });
return;
}
#include "roles.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "havocbot.qh"
#include "../cvars.qh"
ratingscale = ratingscale * 0.00005; // enemies are rated around 20000 already
float t;
- FOREACH_CLIENT(IS_PLAYER(it) && bot_shouldattack(this, it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && bot_shouldattack(this, it), {
// TODO: Merge this logic with the bot_shouldattack function
if(vdist(it.origin - org, <, 100) || vdist(it.origin - org, >, sradius))
continue;
ratingscale *= t;
if (ratingscale > 0)
navigation_routerating(this, it, ratingscale * BOT_RATING_ENEMY, 2000);
- ));
+ });
}
// legacy bot role for standard gamemodes
#include "navigation.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "cvars.qh"
#include "bot.qh"
#include "scripting.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "cvars.qh"
#include <common/state.qh>
if(this.bot_barrier == 1) // find other bots
{
- FOREACH_CLIENT(it.isbot, LAMBDA(
+ FOREACH_CLIENT(it.isbot, {
if(it.bot_cmdqueuebuf_allocated)
if(it.bot_barrier != 1)
return CMD_STATUS_EXECUTING; // not all are at the barrier yet
- ));
+ });
// all bots hit the barrier!
// acknowledge barrier
- FOREACH_CLIENT(it.isbot, LAMBDA(it.bot_barrier = 2));
+ FOREACH_CLIENT(it.isbot, { it.bot_barrier = 2; });
bot_barriertime = time;
}
void bot_resetqueues()
{
- FOREACH_CLIENT(it.isbot, LAMBDA(
+ FOREACH_CLIENT(it.isbot, {
it.bot_cmd_execution_index = 0;
bot_clearqueue(it);
// also, cancel all barriers
it.(bot_placenames[i]) = string_null;
}
it.bot_places_count = 0;
- ));
+ });
bot_barriertime = time;
}
#include "waypoints.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "cvars.qh"
#include "bot.qh"
void botframe_autowaypoints()
{
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && !IS_DEAD(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && !IS_DEAD(it), {
// going back is broken, so only fix waypoints to walk TO the player
//botframe_autowaypoints_fix(p, false, botframe_autowaypoints_lastwp0);
botframe_autowaypoints_fix(it, true, botframe_autowaypoints_lastwp1);
//te_explosion(p.botframe_autowaypoints_lastwp0.origin);
- ));
+ });
if (autocvar_g_waypointeditor_auto >= 2) {
botframe_deleteuselesswaypoints();
#include "campaign.qh"
+
+#include "defs.qh"
+
#include "cheats.qh"
#include "miscfunctions.qh"
#include "g_world.qh"
int lost = 0;
string savevar;
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
if(it.winning)
won += 1;
else
lost += 1;
- ));
+ });
if(autocvar__campaign_testrun)
{
#include "cheats.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+#include <common/effects/all.qh>
+
#include "g_damage.qh"
#include "race.qh"
#include "../common/triggers/teleporters.qh"
case CHIMPULSE_R00T.impulse:
IS_CHEAT(this, imp, 0, 0);
RandomSelection_Init();
- FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && DIFF_TEAM(it, this), LAMBDA(RandomSelection_AddEnt(it, 1, 1)));
+ FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && DIFF_TEAM(it, this), { RandomSelection_AddEnt(it, 1, 1); });
if(RandomSelection_chosen_ent)
e = RandomSelection_chosen_ent;
else
#include "client.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+#include <common/effects/all.qh>
#include "anticheat.qh"
#include "impulse.qh"
#include "player.qh"
CS(e).clientdata.SendFlags = 1;
// make it spectatable
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, LAMBDA(CS(it).clientdata.SendFlags = 1));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, { CS(it).clientdata.SendFlags = 1; });
}
void SetSpectatee(entity this, entity spectatee);
target_voicescript_clear(this);
// reset fields the weapons may use
- FOREACH(Weapons, true, LAMBDA(
+ FOREACH(Weapons, true, {
it.wr_resetplayer(it, this);
// reload all reloadable weapons
if (it.spawnflags & WEP_FLAG_RELOADABLE) {
this.(weaponentity).weapon_load[it.m_id] = it.reloading_ammo;
}
}
- ));
+ });
{
string s = spot.target;
// TODO simplify this
int totalClients = 0;
int currentlyPlaying = 0;
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
if(it != ignore)
++totalClients;
if(IS_REAL_CLIENT(it))
if(IS_PLAYER(it) || it.caplayer)
++currentlyPlaying;
- ));
+ });
float free_slots = 0;
if (!autocvar_g_maxplayers)
#pragma once
+#include "utils.qh"
+#include <common/sounds/all.qh>
+
void ClientState_attach(entity this);
IntrusiveList g_players;
ENDCLASS(Spectator)
CLASS(Player, Client)
-
+
// custom
ATTRIB(Player, dual_weapons, vector, this.dual_weapons); // TODO: actually WepSet!
#include "banning.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include <common/state.qh>
#include <common/command/_mod.qh>
#include "banning.qh"
#include "cmd.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
#include <common/command/_mod.qh>
#include "common.qh"
#include "common.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
#include <common/command/_mod.qh>
#include "common.qh"
}
else // no, maybe it's a name?
{
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
if(strdecolorize(it.netname) == strdecolorize(argv(start_index)))
{
selection = it;
break; // no reason to keep looking
}
- ));
+ });
index = (start_index + 1);
}
else
{
selection = NULL;
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
if(strdecolorize(it.netname) == strdecolorize(input))
{
selection = it;
break; // no reason to keep looking
}
- ));
+ });
}
return selection;
cvar_set("slowmo", ftos(orig_slowmo));
// unlock the view for players so they can move around again
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
it.fixangle = false;
- ));
+ });
timeout_handler_reset(this);
}
cvar_set("slowmo", ftos(TIMEOUT_SLOWMO_VALUE));
// reset all the flood variables
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
it.nickspamcount = it.nickspamtime = it.floodcontrol_chat =
it.floodcontrol_chatteam = it.floodcontrol_chattell =
it.floodcontrol_voice = it.floodcontrol_voiceteam = 0;
- ));
+ });
// copy .v_angle to .lastV_angle for every player in order to fix their view during pause (see PlayerPreThink)
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
it.lastV_angle = it.v_angle;
- ));
+ });
this.nextthink = time; // think again next frame to handle it under TIMEOUT_ACTIVE code
}
"ent", "nickname", "ping", "pl", "time", "ip", "crypto_id"));
total_listed_players = 0;
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
is_bot = (IS_BOT_CLIENT(it));
if (is_bot)
tmp_crypto_idfp));
++total_listed_players;
- ));
+ });
print_to(caller, strcat("Finished listing ", ftos(total_listed_players), " client(s) out of ", ftos(maxclients), " slots."));
METHOD(commoncommand_##id, m_invokecmd, void(commoncommand_##id this, int request, entity caller, int arguments, string command))
STATIC_INIT(COMMON_COMMANDS_aliases) {
- FOREACH(COMMON_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svcmd"))));
+ FOREACH(COMMON_COMMANDS, true, { localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svcmd")); });
}
#include "vote.qh"
void CommonCommand_macro_help(entity caller)
{
- FOREACH(COMMON_COMMANDS, true, LAMBDA(print_to(caller, sprintf(" ^2%s^7: %s", it.m_name, it.m_description))));
+ FOREACH(COMMON_COMMANDS, true, { print_to(caller, sprintf(" ^2%s^7: %s", it.m_name, it.m_description)); });
}
float CommonCommand_macro_command(float argc, entity caller, string command)
{
string c = strtolower(argv(0));
- FOREACH(COMMON_COMMANDS, it.m_name == c, LAMBDA(
+ FOREACH(COMMON_COMMANDS, it.m_name == c, {
it.m_invokecmd(it, CMD_REQUEST_COMMAND, caller, argc, command);
return true;
- ));
+ });
return false;
}
float CommonCommand_macro_usage(float argc, entity caller)
{
string c = strtolower(argv(1));
- FOREACH(COMMON_COMMANDS, it.m_name == c, LAMBDA(
+ FOREACH(COMMON_COMMANDS, it.m_name == c, {
it.m_invokecmd(it, CMD_REQUEST_USAGE, caller, argc, "");
return true;
- ));
+ });
return false;
}
void CommonCommand_macro_write_aliases(float fh)
{
- FOREACH(COMMON_COMMANDS, true, LAMBDA(CMD_Write_Alias("qc_cmd_svcmd", it.m_name, it.m_description)));
+ FOREACH(COMMON_COMMANDS, true, { CMD_Write_Alias("qc_cmd_svcmd", it.m_name, it.m_description); });
}
#include "getreplies.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
#include <common/command/_mod.qh>
#include "getreplies.qh"
+#include "radarmap.qh"
#ifdef RADARMAP
-#include "radarmap.qh"
#include <common/command/_mod.qh>
-#include "radarmap.qh"
#include "../g_world.qh"
#include "../g_subs.qh"
METHOD(servercommand_##id, m_invokecmd, void(servercommand_##id this, int request, entity caller, int arguments, string command))
STATIC_INIT(SERVER_COMMANDS_aliases) {
- FOREACH(SERVER_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_sv"))));
+ FOREACH(SERVER_COMMANDS, true, { localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_sv")); });
}
#include "sv_cmd.qh"
#include "_mod.qh"
+#include <common/effects/all.qh>
+
#include "banning.qh"
#include "cmd.qh"
#include "common.qh"
{
string reason = argv(1);
int n = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
if (it.caplayer) it.caplayer = 0;
PutObserverInServer(it);
++n;
- ));
+ });
if (n) bprint(strcat("Successfully forced all (", ftos(n), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n"));
else LOG_INFO("No players found to spectate.\n");
return;
int n = 0;
float argc;
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
argc = tokenize_console(strcat("defer_clear ", ftos(etof(it))));
GameCommand_defer_clear(CMD_REQUEST_COMMAND, argc);
++n;
- ));
+ });
if (n) LOG_INFO(strcat("Successfully stuffed defer clear to all clients (", ftos(n), ")\n")); // should a message be added if no players were found?
return;
}
{
blockSpectators = 1;
// give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, {
if(!it.caplayer)
{
CS(it).spectatortime = time;
Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
}
- ));
+ });
bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
return;
}
return;
}
- FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
if (it.team_forced) {
// we could theoretically assign forced players to their teams
// and shuffle the rest to fill the empty spots but in practise
LOG_INFO("Can't shuffle teams because at least one player has a forced team.\n");
return;
}
- ));
+ });
int number_of_teams = 0;
CheckAllowedTeams(NULL);
if (c4 >= 0) number_of_teams = max(4, number_of_teams);
int team_index = 0;
- FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, LAMBDA(
+ FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
int target_team_number = Team_NumberToTeam(team_index + 1);
if (it.team != target_team_number) MoveToTeam(it, target_team_number, 6);
team_index = (team_index + 1) % number_of_teams;
- ));
+ });
bprint("Successfully shuffled the players around randomly.\n");
return;
void GameCommand_macro_help()
{
- FOREACH(SERVER_COMMANDS, true, LAMBDA(LOG_INFOF(" ^2%s^7: %s\n", it.m_name, it.m_description)));
+ FOREACH(SERVER_COMMANDS, true, { LOG_INFOF(" ^2%s^7: %s\n", it.m_name, it.m_description); });
}
float GameCommand_macro_command(float argc, string command)
{
string c = strtolower(argv(0));
- FOREACH(SERVER_COMMANDS, it.m_name == c, LAMBDA(
+ FOREACH(SERVER_COMMANDS, it.m_name == c, {
it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command);
return true;
- ));
+ });
return false;
}
float GameCommand_macro_usage(float argc)
{
string c = strtolower(argv(1));
- FOREACH(SERVER_COMMANDS, it.m_name == c, LAMBDA(
+ FOREACH(SERVER_COMMANDS, it.m_name == c, {
it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, "");
return true;
- ));
+ });
return false;
}
void GameCommand_macro_write_aliases(float fh)
{
- FOREACH(SERVER_COMMANDS, true, LAMBDA(CMD_Write_Alias("qc_cmd_sv", it.m_name, it.m_description)));
+ FOREACH(SERVER_COMMANDS, true, { CMD_Write_Alias("qc_cmd_sv", it.m_name, it.m_description); });
}
#include "vote.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
#include <common/command/_mod.qh>
#include "vote.qh"
void VoteReset()
{
- FOREACH_CLIENT(true, LAMBDA(it.vote_selection = 0));
+ FOREACH_CLIENT(true, { it.vote_selection = 0; });
if (vote_called)
{
Nagger_VoteCountChanged();
// add up all the votes from each connected client
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && IS_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && IS_CLIENT(it), {
++vote_player_count;
if (IS_PLAYER(it)) ++vote_real_player_count;
switch (it.vote_selection)
}
default: break;
}
- ));
+ });
// Check to see if there are enough players on the server to allow master voting... otherwise, vote master could be used for evil.
if ((vote_called == VOTE_MASTER) && autocvar_sv_vote_master_playerlimit > vote_player_count)
if (it.reset2) it.reset2(it);
});
- FOREACH_CLIENT(IS_PLAYER(it) && STAT(FROZEN, it), LAMBDA(Unfreeze(it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && STAT(FROZEN, it), { Unfreeze(it); });
// Moving the player reset code here since the player-reset depends
// on spawnpoint entities which have to be reset first --blub
game_starttime = time + RESTART_COUNTDOWN;
// clear player attributes
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
it.alivetime = 0;
CS(it).killcount = 0;
PS_GR_P_ADDVAL(it, PLAYERSTATS_ALIVETIME, -PS_GR_P_ADDVAL(it, PLAYERSTATS_ALIVETIME, 0));
- ));
+ });
restart_mapalreadyrestarted = false; // reset this var, needed when cvar sv_ready_restart_repeatable is in use
warmup_stage = 0; // once the game is restarted the game is in match stage
// reset the .ready status of all players (also spectators)
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(it.ready = false));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { it.ready = false; });
readycount = 0;
Nagger_ReadyCounted(); // NOTE: this causes a resend of that entity, and will also turn off warmup state on the client
// after a restart every players number of allowed timeouts gets reset, too
if (autocvar_sv_timeout)
{
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(CS(it).allowed_timeouts = autocvar_sv_timeout_number));
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { CS(it).allowed_timeouts = autocvar_sv_timeout_number; });
}
// reset map immediately if this cvar is not set
if (!autocvar_sv_ready_restart_after_countdown) reset_map(true);
float ready_needed_factor, ready_needed_count;
float t_ready = 0, t_players = 0;
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_PLAYER(it) || it.caplayer == 1), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_PLAYER(it) || it.caplayer == 1), {
++t_players;
if (it.ready) ++t_ready;
- ));
+ });
readycount = t_ready;
msg_entity = caller;
}
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(++tmp_playercount));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { ++tmp_playercount; });
if (tmp_playercount > 1) Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_VOTE_CALL); // don't announce a "vote now" sound if player is alone
bprint("\{1}^2* ^3", OriginalCallerName(), "^2 calls a vote for ", vote_called_display, "\n");
#include "quake.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include <common/weapons/_all.qh>
spawnfunc(weapon_electro);
#include "quake3.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include <common/weapons/_all.qh>
spawnfunc(weapon_crylink);
#include "wop.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include <common/weapons/_all.qh>
// #include <server/mutators/gamemode.qh>
#include "g_damage.qh"
+#include <common/effects/all.qh>
#include "bot/api.qh"
#include "g_hook.qh"
#include "mutators/_mod.qh"
if(!IS_INDEPENDENT_PLAYER(e))
if(!STAT(FROZEN, e))
- FOREACH_CLIENT(IS_PLAYER(it) && it != e, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != e, {
if(!IS_DEAD(it))
if(!IS_INDEPENDENT_PLAYER(it))
if(boxesoverlap(e.absmin, e.absmax, it.absmin, it.absmax))
d = autocvar_g_balance_firetransfer_damage * e.fire_damagepersec * t;
Fire_AddDamage(it, o, d, t, DEATH_FIRE.m_id);
}
- ));
+ });
}
void Fire_ApplyEffect(entity e)
#if defined(CSQC)
#elif defined(MENUQC)
#elif defined(SVQC)
+ #include <server/defs.qh>
+ #include <server/miscfunctions.qh>
#include <lib/warpzone/common.qh>
#include <common/constants.qh>
#include <common/teams.qh>
#include "g_hook.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+#include <common/effects/all.qh>
#include "weapons/common.qh"
#include "weapons/csqcprojectile.qh"
#include "weapons/weaponsystem.qh"
#include "g_lights.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
void train_next(entity this);
const float LOOP = 1;
#include "g_models.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "g_subs.qh"
#include <common/net_linked.qh>
#include "../common/triggers/subs.qh"
#include "g_subs.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "antilag.qh"
#include "command/common.qh"
#include "../common/state.qh"
// these can contain player IDs, so better hide
BADPREFIX("g_forced_team_");
BADCVAR("sv_muteban_list");
+ BADCVAR("sv_allow_customplayermodels_idlist");
+ BADCVAR("sv_allow_customplayermodels_speciallist");
// mapinfo
BADCVAR("fraglimit");
if(to_file)
fputs(file, strcat(s, "\n"));
- FOREACH_CLIENT(IS_REAL_CLIENT(it) || (IS_BOT_CLIENT(it) && autocvar_sv_logscores_bots), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) || (IS_BOT_CLIENT(it) && autocvar_sv_logscores_bots), {
s = strcat(":player:see-labels:", GetPlayerScoreString(it, 0), ":");
s = strcat(s, ftos(rint(time - CS(it).jointime)), ":");
if(IS_PLAYER(it) || MUTATOR_CALLHOOK(GetPlayerStatus, it))
GameLogEcho(strcat(s, ftos(it.playerid), ":", playername(it, false)));
if(to_file)
fputs(file, strcat(s, playername(it, false), "\n"));
- ));
+ });
if(teamplay)
{
{
stuffcmd(e, "\nscr_printspeed 1000000\n");
RandomSelection_Init();
- FOREACH_WORD(autocvar_sv_intermission_cdtrack, true, LAMBDA(
+ FOREACH_WORD(autocvar_sv_intermission_cdtrack, true, {
RandomSelection_AddString(it, 1, 1);
- ));
+ });
if (RandomSelection_chosen_string != "")
{
stuffcmd(e, sprintf("\ncd loop %s\n", RandomSelection_chosen_string));
GameLogClose();
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
FixIntermissionClient(it);
if(it.winning)
bprint(playername(it, false), " ^7wins.\n");
- ));
+ });
target_music_kill();
// set the .winning flag for exactly those players with a given field value
void SetWinners(.float field, float value)
{
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.winning = (it.(field) == value)));
+ FOREACH_CLIENT(IS_PLAYER(it), { it.winning = (it.(field) == value); });
}
// set the .winning flag for those players with a given field value
void AddWinners(.float field, float value)
{
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(it.(field) == value)
it.winning = 1;
- ));
+ });
}
// clear the .winning flags
void ClearWinners()
{
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.winning = 0));
+ FOREACH_CLIENT(IS_PLAYER(it), { it.winning = 0; });
}
void ShuffleMaplist()
team1_score = team2_score = team3_score = team4_score = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
switch(it.team)
{
case NUM_TEAM_1: team1_score = 1; break;
case NUM_TEAM_3: team3_score = 1; break;
case NUM_TEAM_4: team4_score = 1; break;
}
- ));
+ });
IL_EACH(g_spawnpoints, true,
{
float playerswithlaps;
float readyplayers;
totalplayers = playerswithlaps = readyplayers = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
++totalplayers;
if(PlayerScore_Add(it, SP_RACE_FASTEST, 0))
++playerswithlaps;
if(it.ready)
++readyplayers;
- ));
+ });
// at least 2 of the players have completed a lap: start the RACE
// otherwise, the players should end the qualifying on their own
redirection_nextthink = time + 1;
clients_found = 0;
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
// TODO add timer
LOG_INFO("Redirecting: sending connect command to ", it.netname, "\n");
if(redirection_target == "self")
else
stuffcmd(it, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
++clients_found;
- ));
+ });
LOG_INFO("Redirecting: ", ftos(clients_found), " clients left.\n");
#include "ipban.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "autocvars.qh"
#include "command/banning.qh"
#include "defs.qh"
#include "mapvoting.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "g_world.qh"
#include "command/cmd.qh"
#include "command/getreplies.qh"
void MapVote_ClearAllVotes()
{
- FOREACH_CLIENT(true, LAMBDA(it.mapvote = 0));
+ FOREACH_CLIENT(true, { it.mapvote = 0; });
}
void MapVote_UnzoneStrings()
GameLogEcho(strcat(":vote:suggestion_accepted:", mapvote_maps[mappos]));
}
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(FixClientCvars(it)));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { FixClientCvars(it); });
if(gametypevote)
{
return;
int totalvotes = 0;
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
// hide scoreboard again
if(it.health != 2342)
{
if(it.mapvote)
++totalvotes;
- ));
+ });
MapVote_CheckRules_1(); // just count
}
#include "miscfunctions.qh"
+
#include "antilag.qh"
#include "command/common.qh"
#include "constants.qh"
return strcat(t, strdecolorize(p.netname));
}
else
- return ColorTranslateRGB(p.netname);
+ return p.netname;
}
float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still needs done?
{
g_weaponarena = 1;
g_weaponarena_list = "All Weapons";
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
g_weaponarena_weapons |= (it.m_wepset);
- ));
+ });
}
else if (s == "devall")
{
{
g_weaponarena = 1;
g_weaponarena_list = "Most Weapons";
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
if(it.spawnflags & WEP_FLAG_NORMAL)
g_weaponarena_weapons |= (it.m_wepset);
- ));
+ });
}
else if (s == "none")
{
for (i = 0; i < t; ++i)
{
s = argv(i);
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(it.netname == s)
{
g_weaponarena_weapons |= (it.m_wepset);
g_weaponarena_list = strcat(g_weaponarena_list, it.m_name, " & ");
break;
}
- ));
+ });
}
g_weaponarena_list = strzone(substring(g_weaponarena_list, 0, strlen(g_weaponarena_list) - 3));
}
}
else
{
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
int w = want_weapon(it, false);
WepSet s = it.m_wepset;
if(w & 1)
start_weapons_default |= s;
if(w & 4)
start_weapons_defaultmask |= s;
- ));
+ });
}
if(!cvar("g_use_ammunition"))
warmup_start_weapons = '0 0 0';
warmup_start_weapons_default = '0 0 0';
warmup_start_weapons_defaultmask = '0 0 0';
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
int w = want_weapon(it, g_warmup_allguns);
WepSet s = (it.m_wepset);
if(w & 1)
warmup_start_weapons_default |= s;
if(w & 4)
warmup_start_weapons_defaultmask |= s;
- ));
+ });
}
}
WepSet precache_weapons = start_weapons;
if (g_warmup_allguns != 1)
precache_weapons |= warmup_start_weapons;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(precache_weapons & (it.m_wepset))
it.wr_init(it);
- ));
+ });
start_ammo_shells = max(0, start_ammo_shells);
start_ammo_nails = max(0, start_ammo_nails);
void precache_playermodels(string s)
{
- FOREACH_WORD(s, true, LAMBDA(precache_playermodel(it)));
+ FOREACH_WORD(s, true, { precache_playermodel(it); });
}
void precache()
#pragma once
+#include <server/defs.qh>
+
#include <common/t_items.qh>
#include "mutators/events.qh"
if (!warmup_stage)
game_starttime = time + cvar("g_start_delay");
- FOREACH(Weapons, it != WEP_Null, LAMBDA(it.wr_init(it)));
+ FOREACH(Weapons, it != WEP_Null, { it.wr_init(it); });
readplayerstartcvars();
}
#pragma once
+#include <server/miscfunctions.qh>
#include <server/g_world.qh>
#include <server/round_handler.qh>
#include <server/scores.qh>
#include "loader.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
STATIC_INIT_LATE(Gametype) {
Gametype g = MapInfo_CurrentGametype();
if (g) {
for (string _s = g.m_mutators; _s != ""; _s = cdr(_s)) {
string s = car(_s);
- FOREACH(Mutators, it.m_name == s, LAMBDA(Mutator_Add(it); break));
+ FOREACH(Mutators, it.m_name == s, { Mutator_Add(it); break; });
}
}
}
this.enemy.health = -1;
if(this.enemy.message)
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(centerprint(it, this.enemy.message)));
+ FOREACH_CLIENT(IS_PLAYER(it), { centerprint(it, this.enemy.message); });
SUB_UseTargets(this.enemy, this, trigger);
}
void CA_count_alive_players()
{
total_players = redalive = bluealive = yellowalive = pinkalive = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
switch(it.team)
{
case NUM_TEAM_1: ++total_players; if(!IS_DEAD(it)) ++redalive; break;
case NUM_TEAM_3: ++total_players; if(!IS_DEAD(it)) ++yellowalive; break;
case NUM_TEAM_4: ++total_players; if(!IS_DEAD(it)) ++pinkalive; break;
}
- ));
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ });
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
it.redalive_stat = redalive;
it.bluealive_stat = bluealive;
it.yellowalive_stat = yellowalive;
it.pinkalive_stat = pinkalive;
- ));
+ });
}
float CA_GetWinnerTeam()
{
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(nades_Clear(it)));
+ FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
allowed_to_spawn = false;
game_stopped = true;
game_stopped = true;
round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(nades_Clear(it)));
+ FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
return 1;
}
#include "gamemode_ctf.qh"
#ifndef CSQC
+#include <common/effects/all.qh>
void ctf_Initialize();
REGISTER_MUTATOR(ctf, false)
if(ctf_oneflag)
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_CTF_CAPTURE_NEUTRAL, player.netname);
else if(!ctf_captimerecord)
- Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_TIME), player.netname, (cap_time * 100));
+ Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_TIME), player.netname, TIME_ENCODE(cap_time));
else if(cap_time < cap_record)
- Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_BROKEN), player.netname, refername, (cap_time * 100), (cap_record * 100));
+ Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_BROKEN), player.netname, refername, TIME_ENCODE(cap_time), TIME_ENCODE(cap_record));
else
- Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_UNBROKEN), player.netname, refername, (cap_time * 100), (cap_record * 100));
+ Send_Notification(NOTIF_ALL, NULL, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_CAPTURE_UNBROKEN), player.netname, refername, TIME_ENCODE(cap_time), TIME_ENCODE(cap_record));
// write that shit in the database
if(!ctf_oneflag) // but not in 1-flag mode
ctf_captimerecord = cap_time;
db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(cap_time));
db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), player.netname);
- write_recordmarker(player, (time - cap_time), cap_time);
+ write_recordmarker(player, flag.ctf_pickuptime, cap_time);
}
if(autocvar_g_ctf_leaderboard && !ctf_oneflag)
return false;
players_total = players_worseeq = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(DIFF_TEAM(it, p))
continue;
se = PlayerScore_Add(it, SP_CTF_CAPS, 0);
if(ser <= sr)
++players_worseeq;
++players_total;
- ));
+ });
// player is in the worse half, if >= half the players are better than him, or consequently, if < half of the players are worse
// use this rule here
_sound(player, CH_TRIGGER, flag.snd_flag_pass, VOL_BASE, ATTEN_NORM);
ctf_EventLog("receive", flag.team, player);
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
if(it == sender)
Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_NUM(flag.team, CENTER_CTF_PASS_SENT), player.netname);
else if(it == player)
Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_NUM(flag.team, CENTER_CTF_PASS_RECEIVED), sender.netname);
else if(SAME_TEAM(it, sender))
Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_NUM(flag.team, CENTER_CTF_PASS_OTHER), sender.netname, player.netname);
- ));
+ });
// create new waypoint
ctf_FlagcarrierWaypoints(player);
Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, APP_NUM(flag.team, CHOICE_CTF_PICKUP_TEAM), Team_ColorCode(player.team), player.netname);
if(!flag.team)
- FOREACH_CLIENT(IS_PLAYER(it) && it != player && DIFF_TEAM(it, player), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CHOICE, CHOICE_CTF_PICKUP_ENEMY_NEUTRAL, Team_ColorCode(player.team), player.netname)));
+ FOREACH_CLIENT(IS_PLAYER(it) && it != player && DIFF_TEAM(it, player), { Send_Notification(NOTIF_ONE, it, MSG_CHOICE, CHOICE_CTF_PICKUP_ENEMY_NEUTRAL, Team_ColorCode(player.team), player.netname); });
if(flag.team)
- FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
if(CTF_SAMETEAM(flag, it))
if(SAME_TEAM(player, it))
Send_Notification(NOTIF_ONE, it, MSG_CHOICE, APP_TEAM_NUM(flag.team, CHOICE_CTF_PICKUP_TEAM), Team_ColorCode(player.team), player.netname);
else
Send_Notification(NOTIF_ONE, it, MSG_CHOICE, ((SAME_TEAM(flag, player)) ? CHOICE_CTF_PICKUP_ENEMY_TEAM : CHOICE_CTF_PICKUP_ENEMY), Team_ColorCode(player.team), player.netname);
- ));
+ });
_sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTEN_NONE);
case RETURN_DAMAGE:
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_NUM(flag.team, INFO_CTF_FLAGRETURN_DAMAGED)); break;
case RETURN_SPEEDRUN:
- Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_NUM(flag.team, INFO_CTF_FLAGRETURN_SPEEDRUN), ctf_captimerecord); break;
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_NUM(flag.team, INFO_CTF_FLAGRETURN_SPEEDRUN), TIME_ENCODE(ctf_captimerecord)); break;
case RETURN_NEEDKILL:
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_NUM(flag.team, INFO_CTF_FLAGRETURN_NEEDKILL)); break;
default:
if (!wpforenemy_announced)
{
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, ((it.flagcarried) ? CENTER_CTF_STALEMATE_CARRIER : CENTER_CTF_STALEMATE_OTHER))));
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { Send_Notification(NOTIF_ONE, it, MSG_CENTER, ((it.flagcarried) ? CENTER_CTF_STALEMATE_CARRIER : CENTER_CTF_STALEMATE_OTHER)); });
wpforenemy_announced = true;
}
// captureshield
if(this == ctf_worldflaglist) // only for the first flag
- FOREACH_CLIENT(true, LAMBDA(ctf_CaptureShield_Update(it, 1))); // release shield only
+ FOREACH_CLIENT(true, { ctf_CaptureShield_Update(it, 1); }); // release shield only
// sanity checks
if(this.mins != this.m_mins || this.maxs != this.m_maxs) { // reset the flag boundaries in case it got squished
int c = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(DIFF_TEAM(it, bot) || IS_DEAD(it) || it == bot)
continue;
if(vdist(it.origin - org, <, tc_radius))
++c;
- ));
+ });
return c;
}
// if there is only me on the team switch to offense
c = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this), LAMBDA(++c));
+ FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this), { ++c; });
if(c==1)
{
// if enemies are closer to our base, go there
entity closestplayer = NULL;
float distance, bestdistance = 10000;
- FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
distance = vlen(org - it.origin);
if(distance<bestdistance)
{
closestplayer = it;
bestdistance = distance;
}
- ));
+ });
if(closestplayer)
if(DIFF_TEAM(closestplayer, this))
}
}
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(it.flagcarried && (it.team == _team || _team == 0))
{
found = true;
continue; // already spectating this fc, try another
return superspec_Spectate(player, it);
}
- ));
+ });
if(!found)
superspec_msg("", "", player, "No active flag carrier\n", 1);
race_ClearRecords();
PlayerScore_Sort(race_place, 0, 1, 0);
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
if(it.race_place)
{
s = PlayerScore_Add(it, SP_RACE_FASTEST, 0);
it.race_place = 0;
}
cts_EventLog(ftos(it.race_place), it);
- ));
+ });
if(g_race_qualifying == 2)
{
this.captime = time;
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(set_dom_state(it)));
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { set_dom_state(it); });
}
void AnimateDomPoint(entity this)
void Domination_RoundStart()
{
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.player_blocked = false));
+ FOREACH_CLIENT(IS_PLAYER(it), { it.player_blocked = false; });
}
//go to best items, or control points you don't own
MUTATOR_HOOKFUNCTION(dom, reset_map_players)
{
total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
PutClientInServer(it);
if(domination_roundbased)
it.player_blocked = 1;
if(IS_REAL_CLIENT(it))
set_dom_state(it);
- ));
+ });
return true;
}
void freezetag_count_alive_players()
{
total_players = redalive = bluealive = yellowalive = pinkalive = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
switch(it.team)
{
case NUM_TEAM_1: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++redalive; break;
case NUM_TEAM_3: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++yellowalive; break;
case NUM_TEAM_4: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++pinkalive; break;
}
- ));
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ });
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
it.redalive_stat = redalive;
it.bluealive_stat = bluealive;
it.yellowalive_stat = yellowalive;
it.pinkalive_stat = pinkalive;
- ));
+ });
eliminatedPlayers.SendFlags |= 1;
}
{
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
it.freezetag_frozen_timeout = 0;
nades_Clear(it);
- ));
+ });
game_stopped = true;
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
return 1;
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
}
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
it.freezetag_frozen_timeout = 0;
nades_Clear(it);
- ));
+ });
game_stopped = true;
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
entity freezetag_LastPlayerForTeam(entity this)
{
entity last_pl = NULL;
- FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
if(it.health >= 1)
if(!STAT(FROZEN, it))
if(SAME_TEAM(it, this))
last_pl = it;
else
return NULL;
- ));
+ });
return last_pl;
}
void havocbot_goalrating_freeplayers(entity this, float ratingscale, vector org, float sradius)
{
float t;
- FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
if (STAT(FROZEN, it) == 1)
{
if(vdist(it.origin - org, >, sradius))
t = 0.2 * 150 / (this.health + this.armorvalue);
navigation_routerating(this, it, t * ratingscale, 2000);
}
- ));
+ });
}
void havocbot_role_ft_offense(entity this)
// Count how many players on team are unfrozen.
int unfrozen = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !(STAT(FROZEN, it) != 1), LAMBDA(unfrozen++));
+ FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !(STAT(FROZEN, it) != 1), { unfrozen++; });
// If only one left on team or if role has timed out then start trying to free players.
if (((unfrozen == 0) && (!STAT(FROZEN, this))) || (time > this.havocbot_role_timeout))
MUTATOR_HOOKFUNCTION(ft, reset_map_players)
{
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
CS(it).killcount = 0;
it.freezetag_frozen_timeout = -1;
PutClientInServer(it);
it.freezetag_frozen_timeout = 0;
- ));
+ });
freezetag_count_alive_players();
return true;
}
{
vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
n = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
if(STAT(FROZEN, it) == 0)
if(!IS_DEAD(it))
if(SAME_TEAM(it, player))
it.reviving = true;
++n;
}
- ));
+ });
}
}
// EVERY team mate nearby gets a point (even if multiple!)
- FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
PlayerScore_Add(it, SP_FREEZETAG_REVIVALS, +1);
PlayerScore_Add(it, SP_SCORE, +1);
nades_GiveBonus(it,autocvar_g_nades_bonus_score_low);
- ));
+ });
Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, o.netname);
}
- FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
it.revive_progress = player.revive_progress;
it.reviving = false;
- ));
+ });
}
else if(!n && STAT(FROZEN, player) == 1) // only if no teammate is nearby will we reset
{
}
else
{
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
float cs = PlayerScore_Add(it, SP_KILLS, 0);
if(cs > winning_score)
{
winning_score = cs;
winner = it;
}
- ));
+ });
}
IL_EACH(g_monsters, true,
void Invasion_RoundStart()
{
int numplayers = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
it.player_blocked = false;
++numplayers;
- ));
+ });
if(inv_roundcnt < inv_maxrounds)
inv_roundcnt += 1; // a limiter to stop crazy counts
#include "gamemode_keepaway.qh"
+#include <common/effects/all.qh>
+
int autocvar_g_keepaway_ballcarrier_effects;
float autocvar_g_keepaway_ballcarrier_damage;
float autocvar_g_keepaway_ballcarrier_force;
s |= (32 ** key.count) * f;
}
- FOREACH_CLIENT(true, LAMBDA(it.kh_state = s));
+ FOREACH_CLIENT(true, { it.kh_state = s; });
FOR_EACH_KH_KEY(key)
{
{
if (!k.owner) continue;
entity first = WP_Null;
- FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, LAMBDA(first = it; break));
+ FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, { first = it; break; });
entity third = WP_Null;
- FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, LAMBDA(third = it; break));
+ FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, { third = it; break; });
WaypointSprite_UpdateSprites(k.owner.waypointsprite_attachedforcarrier, first, WP_KeyCarrierFinish, third);
}
}
{
if (!k.owner) continue;
entity first = WP_Null;
- FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, LAMBDA(first = it; break));
+ FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, { first = it; break; });
entity third = WP_Null;
- FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, LAMBDA(third = it; break));
+ FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, { third = it; break; });
WaypointSprite_UpdateSprites(k.owner.waypointsprite_attachedforcarrier, first, WP_KeyCarrierFriend, third);
}
}
int players = 0;
float of = autocvar_g_balance_keyhunt_score_destroyed_ownfactor;
- FOREACH_CLIENT(IS_PLAYER(it) && it.team != loser_team, LAMBDA(++players));
+ FOREACH_CLIENT(IS_PLAYER(it) && it.team != loser_team, { ++players; });
entity key;
int keys = 0;
continue;
players = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && it.team == thisteam, LAMBDA(++players));
+ FOREACH_CLIENT(IS_PLAYER(it) && it.team == thisteam, { ++players; });
DistributeEvenly_Init(fragsleft, j);
fragsleft = DistributeEvenly_Get(j - 1);
DistributeEvenly_Init(DistributeEvenly_Get(1), players);
- FOREACH_CLIENT(IS_PLAYER(it) && it.team == thisteam, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it.team == thisteam, {
f = DistributeEvenly_Get(1);
kh_Scores_Event(it, NULL, "destroyed", f, 0);
- ));
+ });
--j;
}
if(kh_interferemsg_time && time > kh_interferemsg_time)
{
kh_interferemsg_time = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(it.team == kh_interferemsg_team)
if(it.kh_next)
Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_KEYHUNT_MEET);
Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_KEYHUNT_HELP);
else
Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(kh_interferemsg_team, CENTER_KEYHUNT_INTERFERE));
- ));
+ });
}
this.nextthink = time + 0.05;
{
int teem = kh_Team_ByID(i);
int players = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(!IS_DEAD(it) && !PHYS_INPUT_BUTTON_CHAT(it) && it.team == teem)
++players;
- ));
+ });
if (!players)
missing_teams |= (2 ** i);
}
int teem = kh_Team_ByID(i);
int players = 0;
entity my_player = NULL;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(!IS_DEAD(it) && !PHYS_INPUT_BUTTON_CHAT(it) && it.team == teem)
{
++players;
if(random() * players <= 1)
my_player = it;
}
- ));
+ });
kh_Key_Spawn(my_player, 360 * i / NumTeams(kh_teams), i);
}
MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
++M_ARGV(0, int); // activerealplayers
++M_ARGV(1, int); // realplayers
- ));
+ });
return true;
}
n = 0;
c = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
++n;
if(CS(it).race_completed)
++c;
- ));
+ });
if(n && (n == c))
return WINNING_YES;
wc = WinningCondition_Scores(fraglimit, 0);
race_ClearRecords();
PlayerScore_Sort(race_place, 0, 1, 0);
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
if(it.race_place)
{
s = PlayerScore_Add(it, SP_RACE_FASTEST, 0);
it.race_place = 0;
}
race_EventLog(ftos(it.race_place), it);
- ));
+ });
if(g_race_qualifying == 2)
{
#include "main.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "pathlib.qh"
#include "utility.qh"
#include "../command/common.qh"
#include "movenode.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "pathlib.qh"
#include "utility.qh"
#include "utility.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "pathlib.qh"
bool location_isok(vector point, bool waterok, bool air_isok)
#include "player.qh"
+#include <common/effects/all.qh>
#include "bot/api.qh"
#include "cheats.qh"
#include "g_damage.qh"
float pcount = 1; // Include myself whether or not team is already set right and I'm a "player".
if (teamplay)
{
- FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
if(it.team == this.team)
++pcount;
- ));
+ });
if (sdelay_small_count == 0)
sdelay_small_count = 1;
if (sdelay_large_count == 0)
}
else
{
- FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
++pcount;
- ));
+ });
if (sdelay_small_count == 0)
{
if (IS_INDEPENDENT_PLAYER(this))
#include "portals.qh"
+#include <common/effects/all.qh>
#include "g_hook.qh"
#include "mutators/_mod.qh"
#include "../common/constants.qh"
fixedmakevectors(this.mangle);
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
if(it != o)
if(IS_INDEPENDENT_PLAYER(it) || IS_INDEPENDENT_PLAYER(o))
continue; // cannot go through someone else's portal
if(it.(weaponentity).hook)
Portal_Think_TryTeleportPlayer(this, it.(weaponentity).hook, g);
}
- ));
+ });
this.solid = SOLID_TRIGGER;
this.aiment = o;
#endif
#include <lib/_all.inc>
#if XONOTIC
-#include <server/_all.inc>
+
+#include <server/_mod.inc>
+
+#include <common/_all.inc>
+#include <common/effects/qc/all.qc>
+
+#include <lib/csqcmodel/sv_model.qc>
+
+#include <lib/warpzone/anglestransform.qc>
+#include <lib/warpzone/common.qc>
+#include <lib/warpzone/server.qc>
+#include <lib/warpzone/util_server.qc>
#include <ecs/_mod.inc>
#endif
#include "race.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "client.qh"
#include "portals.qh"
#include "scores.qh"
strunzone(race_checkpoint_recordholders[cp]);
race_checkpoint_recordholders[cp] = strzone(e.netname);
if(g_race_qualifying)
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.race_checkpoint == cp, LAMBDA(race_SendNextCheckpoint(it, 0)));
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.race_checkpoint == cp, { race_SendNextCheckpoint(it, 0); });
}
}
g_race_qualifying = qual;
- IL_EACH(g_race_targets, true,
+ IL_EACH(g_race_targets, it.classname == "target_checkpoint" || it.classname == "target_startTimer" || it.classname == "target_stopTimer",
{
+ if(it.targetname == "" || !it.targetname) // somehow this is a case...
+ continue;
entity cpt = it;
FOREACH_ENTITY_STRING(target, cpt.targetname,
{
if (race_timed_checkpoint) {
if (defrag_ents) {
- IL_EACH(g_race_targets, true,
+ IL_EACH(g_race_targets, it.classname == "target_checkpoint" || it.classname == "target_startTimer" || it.classname == "target_stopTimer",
{
entity cpt = it;
if(it.classname == "target_startTimer" || it.classname == "target_stopTimer") {
+ if(it.targetname == "" || !it.targetname) // somehow this is a case...
+ continue;
FOREACH_ENTITY_STRING(target, cpt.targetname, {
- WaypointSprite_UpdateSprites(it.sprite, ((cpt.classname == "target_startTimer") ? WP_RaceStart : WP_RaceFinish), WP_Null, WP_Null);
+ if(it.sprite)
+ WaypointSprite_UpdateSprites(it.sprite, ((cpt.classname == "target_startTimer") ? WP_RaceStart : WP_RaceFinish), WP_Null, WP_Null);
});
}
if(it.classname == "target_checkpoint") {
void race_StartCompleting()
{
race_completing = 1;
- FOREACH_CLIENT(IS_PLAYER(it) && IS_DEAD(it), LAMBDA(race_AbandonRaceCheck(it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_DEAD(it), { race_AbandonRaceCheck(it); });
}
void race_PreparePlayer(entity this)
race_checkpoint_recordholders[j] = string_null;
}
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
float p = it.race_place;
race_PreparePlayer(it);
it.race_place = p;
- ));
+ });
}
void race_ImposePenaltyTime(entity pl, float penalty, string reason)
#include "round_handler.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "campaign.qh"
#include "command/vote.qh"
#include "../common/util.qh"
WinningConditionHelper_second = NULL;
winnerscorekeeper = NULL;
secondscorekeeper = NULL;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
sk = CS(it).scorekeeper;
c = PlayerScore_Compare(winnerscorekeeper, sk, 1);
if(c < 0)
secondscorekeeper = sk;
}
}
- ));
+ });
WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0);
if(WinningConditionHelper_equality)
strunzone(worldstatus);
worldstatus = strzone(s);
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
string s = "";
if(fullstatus)
{
if(it.clientstatus)
strunzone(it.clientstatus);
it.clientstatus = strzone(s);
- ));
+ });
}
string GetScoreLogLabel(string label, float fl)
plist = NULL;
- FOREACH_CLIENT(true, LAMBDA(it.(field) = 0));
+ FOREACH_CLIENT(true, { it.(field) = 0; });
FOREACH_CLIENT(CS(it).scorekeeper,
{
}
t = 0;
- FOREACH_CLIENT(!IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(!IS_PLAYER(it), {
if (!t)
Score_NicePrint_Spectators(to);
Score_NicePrint_Spectator(to, it);
t = 1;
- ));
+ });
}
void PlayerScore_PlayerStats(entity p)
#include "scores_rules.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "client.qh"
#include "scores.qh"
}
shortest = vlen(world.maxs - world.mins);
- FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
thisdist = vlen(it.origin - spot.origin);
if (thisdist < shortest)
shortest = thisdist;
- ));
+ });
if(shortest > mindist)
prio += SPAWN_PRIO_GOOD_DISTANCE;
void Pause_TryPause(bool ispaused)
{
int n = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
if (PHYS_INPUT_BUTTON_CHAT(it) != ispaused) return;
++n;
- ));
+ });
if (!n) return;
setpause(ispaused);
}
LOG_INFO("CEFC time: ", ftos(t * 1000), "ms; ");
int c_seeing = 0;
int c_seen = 0;
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
if(IS_REAL_CLIENT(it))
++c_seeing;
if(IS_PLAYER(it))
++c_seen;
- ));
+ });
LOG_INFO("CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ");
LOG_INFO("CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0'), "\n");
// FIXME: also find and memorize the lowest-scoring bot on each team (in case players must be shuffled around)
// also remember the lowest-scoring player
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
float t;
if(IS_PLAYER(it) || it.caplayer)
t = it.team;
}
}
}
- ));
+ });
// if the player who has a forced team has not joined yet, reserve the spot
if(autocvar_g_campaign)
lowest_player_score = 999999999;
// find the lowest-scoring player & bot of that team
- FOREACH_CLIENT(IS_PLAYER(it) && it.team == steam, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it.team == steam, {
if(it.isbot)
{
if(it.totalfrags < lowest_bot_score)
lowest_player_score = it.totalfrags;
}
}
- ));
+ });
// prefers to move a bot...
if(lowest_bot != NULL)
#pragma once
+#include "defs.qh"
+#include "miscfunctions.qh"
#include "autocvars.qh"
#include "client.qh"
#include "command/_mod.qh"
--- /dev/null
+#pragma once
+
+int maxclients;
+
+const string STR_PLAYER = "player";
+const string STR_SPECTATOR = "spectator";
+const string STR_OBSERVER = "observer";
+
+#define IS_PLAYER(v) ((v).classname == STR_PLAYER)
+#define IS_SPEC(v) ((v).classname == STR_SPECTATOR)
+#define IS_OBSERVER(v) ((v).classname == STR_OBSERVER)
+
+#define IS_CLIENT(v) (v.flags & FL_CLIENT)
+/** want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v)) */
+#define IS_BOT_CLIENT(v) (clienttype(v) == CLIENTTYPE_BOT)
+#define IS_FAKE_CLIENT(v) (clienttype(v) == CLIENTTYPE_NOTACLIENT)
+#define IS_REAL_CLIENT(v) (clienttype(v) == CLIENTTYPE_REAL)
+/** was: (clienttype(v) == CLIENTTYPE_NOTACLIENT) */
+#define IS_NOT_A_CLIENT(v) (!IS_CLIENT(v))
+
+#define IS_MONSTER(v) (v.flags & FL_MONSTER)
+#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, { 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), { 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 { \
+ for(int _i = 1; _i <= maxclients; ++_i) \
+ { \
+ const noref int i = _i; \
+ ITER_CONST noref entity it = ftoe(i); \
+ if(cond) { LAMBDA(body) } \
+ } \
+ } MACRO_END
+
+#define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
+
+// using the "inside out" version of knuth-fisher-yates shuffle
+// https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
+entity _FCR_clients[255];
+bool _FCR_entered = false;
+#define FOREACH_CLIENT_RANDOM(cond, body) \
+ MACRO_BEGIN { \
+ if (_FCR_entered) LOG_FATAL("FOREACH_CLIENT_RANDOM must not be nested"); \
+ _FCR_entered = true; \
+ int _cnt = 0; \
+ FOREACH_CLIENT(cond, { \
+ int _j = floor(random() * (_cnt + 1)); \
+ if (_j == _cnt) \
+ { \
+ _FCR_clients[_cnt] = it; \
+ } \
+ else \
+ { \
+ _FCR_clients[_cnt] = _FCR_clients[_j]; \
+ _FCR_clients[_j] = it; \
+ } \
+ _cnt++; \
+ }); \
+ for (int _i = 0; _i < _cnt; ++_i) \
+ { \
+ const noref int i = _i; \
+ ITER_CONST noref entity it = _FCR_clients[i]; \
+ if (cond) { LAMBDA(body) } \
+ } \
+ _FCR_entered = false; \
+ } MACRO_END
+
+// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: IL_EACH(g_monsters, true, { code; });
if (b == accuracy_byte(a.accuracy_hit[w], a.accuracy_fired[w])) return; // no change
int sf = 1 << (w % 24);
a.SendFlags |= sf;
- FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, LAMBDA(CS(it).accuracy.SendFlags |= sf));
+ FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, { CS(it).accuracy.SendFlags |= sf; });
}
bool accuracy_isgooddamage(entity attacker, entity targ)
#pragma once
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
.bool cvar_cl_accuracy_data_share;
REPLICATE(cvar_cl_accuracy_data_share, bool, "cl_accuracy_data_share");
.bool cvar_cl_accuracy_data_receive;
#include "common.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include <common/t_items.qh>
#include <common/constants.qh>
#include <common/net_linked.qh>
#include "csqcprojectile.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include <common/t_items.qh>
#include "../command/common.qh"
#include "hitplot.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "../antilag.qh"
#include "../g_subs.qh"
#include <common/weapons/_all.qh>
#pragma once
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
// switch between weapons
void Send_WeaponComplain(entity e, float wpn, float type);
for (int i = 1; i < t; ++i)
{
s = argv(i);
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(it.netname == s)
{
entity replacement = spawn();
weapon_defaultspawnfunc(replacement, it);
break;
}
- ));
+ });
}
}
if (t >= 1) // always the case!
{
s = argv(0);
wpn = WEP_Null;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
if(it.netname == s)
{
wpn = it;
break;
}
- ));
+ });
}
if (wpn == WEP_Null)
{
#pragma once
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
string W_Apply_Weaponreplace(string in);
void weapon_defaultspawnfunc(entity this, Weapon e);
else
{
int superweapons = 1;
- FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ FOREACH(Weapons, it != WEP_Null, {
WepSet set = it.m_wepset;
if((set & WEPSET_SUPERWEAPONS) && (own.weapons & set)) ++superweapons;
- ));
+ });
if(superweapons <= 1)
{
wep.superweapons_finished = own.superweapons_finished;
#pragma once
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
.float savenextthink;
void thrown_wep_think(entity this);
#include "tracing.qh"
+#include <common/effects/all.qh>
+
#include "accuracy.qh"
#include "common.qh"
#include "hitplot.qh"
// Find all non-hit players the beam passed close by
if(deathtype == WEP_VAPORIZER.m_id || deathtype == WEP_VORTEX.m_id)
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != this, LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != this, {
if(!it.railgunhit)
if(!(IS_SPEC(it) && it.enemy == this))
{
pseudoprojectile = spawn(); // we need this so the sound uses the "entchannel4" volume
soundtoat(MSG_ONE, pseudoprojectile, beampos, CH_SHOTS, SND(NEXWHOOSH_RANDOM()), VOL_BASE * f, ATTEN_NONE);
}
- ));
+ });
if(pseudoprojectile)
delete(pseudoprojectile);
#pragma once
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
vector w_shotorg;
vector w_shotdir;
vector w_shotend;
#include "weaponstats.qh"
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
#include "../g_world.qh"
#include <common/weapons/_all.qh>
if (this)
{
- FOREACH_CLIENT(true, LAMBDA(
+ FOREACH_CLIENT(true, {
if(it == actor || (IS_SPEC(it) && it.enemy == actor))
wframe_send(it, this, a, restartanim);
- ));
+ });
}
if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
#pragma once
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
float internalteam;
float weaponswapping;
entity weapon_dropevent_item;
declare -l prog="${1}"
declare -l file="${2}"
MODE=${prog}
+ includes="-include lib/_all.inc"
+ [ -f ${prog}/_all.qh ] && includes="${includes} -include ${prog}/_all.qh"
qpp ${file} test.dat \
- -include lib/_all.inc -include ${prog}/_all.qh \
+ ${includes} \
-I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${prog}.qc
qcc ${QCCFLAGS} -o ../${WORKDIR}/test.dat ../${WORKDIR}/${prog}.qc >/dev/null
}
MOD=_mod
+function hash() {
+ git hash-object $1
+}
+
function genmod() {
# use context to work around cmake issue #12619
CTX="${PWD#$ROOT}/"
+ oldHashC=$(hash ${MOD}.inc)
+ oldTimeC=$(stat -c "%Y" ${MOD}.inc)
+ oldHashH=$(hash ${MOD}.qh)
+ oldTimeH=$(stat -c "%Y" ${MOD}.qh)
echo '// generated file; do not modify' > ${MOD}.inc
echo '// generated file; do not modify' > ${MOD}.qh
for f in $(ls | sort -k 1,1 -t .); do
echo "#include <${CTX}$f/${mod}.qh>" >> ${MOD}.qh
fi
fi; done
+ newHashC=$(hash ${MOD}.inc)
+ if [[ $newHashC == $oldHashC ]]; then touch -d @$oldTimeC ${MOD}.inc; fi
+ newHashH=$(hash ${MOD}.qh)
+ if [[ $newHashH == $oldHashH ]]; then touch -d @$oldTimeH ${MOD}.qh; fi
}
(cd lib; genmod)
cd ${0%/*}
cd ..
+VERBOSE=${VERBOSE:-1}
+
function startswith() {
declare -l file="${1}"
declare -l prelude="${2}"
function check() {
declare -l base="${1}"
find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
- echo "$file"
+ [ "$VERBOSE" != "0" ] && echo "$file"
declare -l file_h="${file%.qc}.qh"
if [[ ! -f "$file_h" ]]; then echo "#pragma once" > "$file_h"; fi
startswith "$file" "$include"
done
find "$base" -type f -name '*.qh' -a \! -name '_mod.qh' -print0 | sort -z | while read -r -d '' file; do
- echo "$file"
+ [ "$VERBOSE" != "0" ] && echo "$file"
startswith "$file" "#pragma once"
done
}
cd ${0%/*}
cd ..
+function hash() {
+ git hash-object $1
+}
+
function check() {
declare -l base="${1}"
- find "$base" -type f -print0 | sort -z | xargs -0 sed -i \
- `# strip trailing spaces` \
- -e 's/[[:space:]]*$//' \
- `# line feed at EOF for #include to work properly` \
- -e '$a\'
+ # strip trailing spaces
+ STRIP_TRAILING_WS='s/[[:space:]]\+$//'
+ # line feed at EOF for #include to work properly
+ ENSURE_EOFLF='$a\'
+ find "$base" -type f -print0 | sort -z | while read -r -d '' file; do
+ oldHash=$(hash ${file})
+ oldTime=$(stat -c "%Y" ${file})
+ sed -i -e ${STRIP_TRAILING_WS} -e ${ENSURE_EOFLF} ${file}
+ newHash=$(hash ${file})
+ if [[ $newHash == $oldHash ]]; then touch -d @$oldTime ${file}; fi
+ done
}
check lib