}
float ClientData_Send(entity to, int sf)
-{
+{SELFPARAM();
if(to != self.owner)
{
error("wtf");
}
void ClientData_Attach()
-{
+{SELFPARAM();
Net_LinkEntity(self.clientdata = spawn(), false, 0, ClientData_Send);
self.clientdata.drawonlytoclient = self;
self.clientdata.owner = self;
}
void ClientData_Detach()
-{
+{SELFPARAM();
remove(self.clientdata);
self.clientdata = world;
}
void setplayermodel(entity e, string modelname)
{
precache_model(modelname);
- setmodel(e, modelname);
+ _setmodel(e, modelname);
player_setupanimsformodel();
UpdatePlayerSounds();
}
*/
void FixPlayermodel();
void PutObserverInServer (void)
-{
+{SELFPARAM();
entity spot;
self.hud = HUD_NORMAL;
self.weapons = '0 0 0';
self.model = "";
FixPlayermodel();
- setmodel(self, "null");
+ setmodel(self, MDL_Null);
self.drawonlytoclient = self;
setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
.float model_randomizer;
void FixPlayermodel()
-{
+{SELFPARAM();
string defaultmodel;
float defaultskin, chmdl, oldskin, n, i;
vector m1, m2;
}
}
- MUTATOR_CALLHOOK(FixPlayermodel, defaultmodel);
+ MUTATOR_CALLHOOK(FixPlayermodel, defaultmodel, defaultskin);
defaultmodel = ret_string;
+ defaultskin = ret_int;
if(defaultmodel != "")
{
setcolor(self, stof(autocvar_sv_defaultplayercolors));
}
-/*
-=============
-PutClientInServer
-Called when a client spawns in the server
-=============
-*/
-void PutClientInServer (void)
+/** Called when a client spawns in the server */
+void PutClientInServer()
{
+ SELFPARAM();
if(IS_BOT_CLIENT(self))
self.classname = "player";
else if(IS_REAL_CLIENT(self))
if(IS_PLAYER(self))
{
- entity spot, oldself;
+ entity spot;
accuracy_resend(self);
self.frags = FRAGS_PLAYER;
if(INDEPENDENT_PLAYERS)
MAKE_INDEPENDENT_PLAYER(self);
- self.flags = FL_CLIENT;
+ self.flags = FL_CLIENT | FL_PICKUPITEMS;
if(autocvar__notarget)
self.flags |= FL_NOTARGET;
self.takedamage = DAMAGE_AIM;
self.killcount = 0;
}
- CL_SpawnWeaponentity();
+ CL_SpawnWeaponentity(self);
self.alpha = default_player_alpha;
self.colormod = '1 1 1' * autocvar_g_player_brightness;
self.exteriorweaponentity.alpha = default_weapon_alpha;
self.(weapon_load[j]) = e.reloading_ammo;
}
- oldself = self;
- self = spot;
- activator = oldself;
- string s;
- s = self.target;
- self.target = string_null;
- SUB_UseTargets();
- self.target = s;
- activator = world;
- self = oldself;
+ string s = spot.target;
+ spot.target = string_null;
+ activator = self;
+ WITH(entity, self, spot, SUB_UseTargets());
+ activator = world;
+ spot.target = s;
Unfreeze(self);
// TODO do we need all these fields, or should we stop autodetecting runtime
// changes and just have a console command to update this?
float ClientInit_SendEntity(entity to, int sf)
-{
+{SELFPARAM();
WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
WriteByte(MSG_ENTITY, g_nexball_meter_period * 32);
WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[0]));
}
void ClientInit_CheckUpdate()
-{
+{SELFPARAM();
self.nextthink = time;
if(self.count != autocvar_g_balance_armor_blockpercent)
{
}
void ClientInit_Spawn()
-{
- entity o;
- entity e;
- e = spawn();
+{SELFPARAM();
+ entity e = spawn();
e.classname = "clientinit";
e.think = ClientInit_CheckUpdate;
Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
- o = self;
- self = e;
- ClientInit_CheckUpdate();
- self = o;
+ WITH(entity, self, e, ClientInit_CheckUpdate());
}
/*
=============
*/
void SetChangeParms (void)
-{
+{SELFPARAM();
// save parms for level change
parm1 = self.parm_idlesince - time;
}
=============
*/
void DecodeLevelParms (void)
-{
+{SELFPARAM();
// load parms
self.parm_idlesince = parm1;
if(self.parm_idlesince == -(86400 * 366))
.float clientkill_nexttime;
void ClientKill_Now_TeamChange()
-{
+{SELFPARAM();
if(self.killindicator_teamchange == -1)
{
JoinBestTeam( self, false, true );
}
void ClientKill_Now()
-{
+{SELFPARAM();
if(self.vehicle)
{
vehicles_exit(VHEF_RELEASE);
// now I am sure the player IS dead
}
void KillIndicator_Think()
-{
+{SELFPARAM();
if (gameover)
{
self.owner.killindicator = world;
if(self.cnt <= 0)
{
- self = self.owner;
- ClientKill_Now(); // no oldself needed
+ WITH(entity, self, self.owner, ClientKill_Now());
return;
}
else if(g_cts && self.health == 1) // health == 1 means that it's silent
else
{
if(self.cnt <= 10)
- setmodel(self, strcat("models/sprites/", ftos(self.cnt), ".spr32"));
+ setmodel(self, MDL_NUM(self.cnt));
if(IS_REAL_CLIENT(self.owner))
{
if(self.cnt <= 10)
float clientkilltime;
void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec
-{
+{SELFPARAM();
float killtime;
float starttime;
entity e;
}
void ClientKill (void)
-{
+{SELFPARAM();
if(gameover) return;
if(self.player_blocked) return;
if(self.frozen) return;
=============
*/
void ClientPreConnect (void)
-{
+{SELFPARAM();
if(autocvar_sv_eventlog)
{
GameLogEcho(sprintf(":connect:%d:%d:%s",
=============
*/
void DecodeLevelParms (void);
-//void dom_player_join_team(entity pl);
-void set_dom_state(entity e);
void ClientConnect (void)
-{
+{SELFPARAM();
float t;
if(IS_CLIENT(self))
CheatInitClient();
- CSQCMODEL_AUTOINIT();
+ CSQCMODEL_AUTOINIT(self);
self.model_randomizer = random();
sv_notice_join();
for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
- entity oldself = self;
- self = e;
- e.init_for_player(oldself);
- self = oldself;
+ WITH(entity, self, e, e.init_for_player(this));
}
MUTATOR_CALLHOOK(ClientConnect, self);
.entity chatbubbleentity;
void ReadyCount();
void ClientDisconnect (void)
-{
+{SELFPARAM();
if(self.vehicle)
vehicles_exit(VHEF_RELEASE);
.float BUTTON_CHAT;
void ChatBubbleThink()
-{
+{SELFPARAM();
self.nextthink = time;
if ((self.owner.alpha < 0) || self.owner.chatbubbleentity != self)
{
remove(self);
return;
}
-
+
self.mdl = "";
-
+
if ( !self.owner.deadflag && IS_PLAYER(self.owner) )
{
if ( self.owner.active_minigame )
else if ( self.owner.BUTTON_CHAT )
self.mdl = "models/misc/chatbubble.spr";
}
-
+
if ( self.model != self.mdl )
- setmodel(self, self.mdl);
+ _setmodel(self, self.mdl);
}
void UpdateChatBubble()
-{
+{SELFPARAM();
if (self.alpha < 0)
return;
// spawn a chatbubble entity if needed
self.chatbubbleentity.exteriormodeltoclient = self;
self.chatbubbleentity.think = ChatBubbleThink;
self.chatbubbleentity.nextthink = time;
- setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
+ setmodel(self.chatbubbleentity, MDL_CHAT); // precision set below
//setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
setorigin(self.chatbubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
setattachment(self.chatbubbleentity, self, ""); // sticks to moving player better, also conserves bandwidth
}*/
void respawn(void)
-{
+{SELFPARAM();
if(self.alpha >= 0 && autocvar_g_respawn_ghosts)
{
self.solid = SOLID_NOT;
}
void play_countdown(float finished, string samp)
-{
+{SELFPARAM();
if(IS_REAL_CLIENT(self))
if(floor(finished - time - frametime) != floor(finished - time))
if(finished - time < 6)
}
void player_powerups (void)
-{
+{SELFPARAM();
// add a way to see what the items were BEFORE all of these checks for the mutator hook
int items_prev = self.items;
}
void player_regen (void)
-{
+{SELFPARAM();
float max_mod, regen_mod, rot_mod, limit_mod;
max_mod = regen_mod = rot_mod = limit_mod = 1;
regen_mod_max = max_mod;
float zoomstate_set;
void SetZoomState(float z)
-{
+{SELFPARAM();
if(z != self.zoomstate)
{
self.zoomstate = z;
zoomstate_set = 1;
}
-void GetPressedKeys(void) {
+void GetPressedKeys()
+{SELFPARAM();
MUTATOR_CALLHOOK(GetPressedKeys);
#define X(var,bit,flag) (flag ? var |= bit : var &= ~bit)
X(self.pressedkeys, KEY_FORWARD, self.movement_x > 0);
======================
*/
-void SpectateCopy(entity spectatee) {
+void SpectateCopy(entity spectatee)
+{SELFPARAM();
MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
self.armortype = spectatee.armortype;
self.armorvalue = spectatee.armorvalue;
}
}
-float SpectateUpdate()
-{
+bool SpectateUpdate()
+{SELFPARAM();
if(!self.enemy)
- return 0;
+ return false;
if(!IS_PLAYER(self.enemy) || self == self.enemy)
{
SetSpectator(self, world);
- return 0;
+ return false;
}
SpectateCopy(self.enemy);
- return 1;
+ return true;
}
-float SpectateSet()
-{
- if(self.enemy.classname != "player")
+bool SpectateSet()
+{SELFPARAM();
+ if(!IS_PLAYER(self.enemy))
return false;
- /*if(self.enemy.vehicle)
- {
- msg_entity = self;
- WriteByte(MSG_ONE, SVC_SETVIEW);
- WriteEntity(MSG_ONE, self.enemy);
- //stuffcmd(self, "set viewsize $tmpviewsize \n");
+ msg_entity = self;
+ WriteByte(MSG_ONE, SVC_SETVIEW);
+ WriteEntity(MSG_ONE, self.enemy);
+ self.movetype = MOVETYPE_NONE;
+ accuracy_resend(self);
- self.movetype = MOVETYPE_NONE;
- accuracy_resend(self);
- }
- else
- {*/
- msg_entity = self;
- WriteByte(MSG_ONE, SVC_SETVIEW);
- WriteEntity(MSG_ONE, self.enemy);
- //stuffcmd(self, "set viewsize $tmpviewsize \n");
- self.movetype = MOVETYPE_NONE;
- accuracy_resend(self);
+ if(!SpectateUpdate())
+ PutObserverInServer();
- if(!SpectateUpdate())
- PutObserverInServer();
- //}
return true;
}
if(player.enemy && player.enemy.arc_beam) { player.enemy.arc_beam.SendFlags |= ARC_SF_SETTINGS; }
}
-float Spectate(entity pl)
-{
+bool Spectate(entity pl)
+{SELFPARAM();
if(g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer)
- if(pl.team != self.team)
- return 0;
+ if(DIFF_TEAM(pl, self))
+ return false;
SetSpectator(self, pl);
return SpectateSet();
}
// Returns next available player to spectate if g_ca_spectate_enemies == 0
-entity CA_SpectateNext(entity start) {
- if (start.team == self.team) {
+entity CA_SpectateNext(entity start)
+{SELFPARAM();
+ if(SAME_TEAM(start, self))
return start;
- }
other = start;
// continue from current player
- while(other && other.team != self.team) {
+ while(other && DIFF_TEAM(other, self))
other = find(other, classname, "player");
- }
- if (!other) {
+ if (!other)
+ {
// restart from begining
other = find(other, classname, "player");
- while(other && other.team != self.team) {
+ while(other && DIFF_TEAM(other, self))
other = find(other, classname, "player");
- }
}
return other;
}
-float SpectateNext()
-{
+bool SpectateNext()
+{SELFPARAM();
other = find(self.enemy, classname, "player");
- if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer) {
+ if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer)
// CA and ca players when spectating enemies is forbidden
other = CA_SpectateNext(other);
- } else {
+ else
+ {
// other modes and ca spectators or spectating enemies is allowed
if (!other)
other = find(other, classname, "player");
return SpectateSet();
}
-float SpectatePrev()
-{
+bool SpectatePrev()
+{SELFPARAM();
// NOTE: chain order is from the highest to the lower entnum (unlike find)
other = findchain(classname, "player");
if (!other) // no player
if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer)
{
do { other = other.chain; }
- while(other && other.team != self.team);
+ while(other && DIFF_TEAM(other, self));
if (!other)
{
other = first;
- while(other.team != self.team)
+ while(other && DIFF_TEAM(other, self))
other = other.chain;
if(other == self.enemy)
return true;
=============
*/
void ShowRespawnCountdown()
-{
+{SELFPARAM();
float number;
if(self.deadflag == DEAD_NO) // just respawned?
return;
}
void LeaveSpectatorMode()
-{
+{SELFPARAM();
if(self.caplayer)
return;
if(nJoinAllowed(self))
* it checks whether the number of currently playing players exceeds g_maxplayers.
* @return int number of free slots for players, 0 if none
*/
-float nJoinAllowed(entity ignore) {
+float nJoinAllowed(entity ignore)
+{SELFPARAM();
if(!ignore)
// this is called that way when checking if anyone may be able to join (to build qcstatus)
// so report 0 free slots if restricted
* Checks whether the client is an observer or spectator, if so, he will get kicked after
* g_maxplayers_spectator_blocktime seconds
*/
-void checkSpectatorBlock() {
+void checkSpectatorBlock()
+{SELFPARAM();
if(IS_SPEC(self) || IS_OBSERVER(self))
if(!self.caplayer)
if(IS_REAL_CLIENT(self))
}
void PrintWelcomeMessage()
-{
+{SELFPARAM();
if(self.motd_actived_time == 0)
{
if (autocvar_g_campaign) {
}
void ObserverThink()
-{
+{SELFPARAM();
if ( self.impulse )
{
MinigameImpulse(self.impulse);
}
void SpectatorThink()
-{
+{SELFPARAM();
if ( self.impulse )
{
if(MinigameImpulse(self.impulse))
void vehicles_enter (entity pl, entity veh);
void PlayerUseKey()
-{
+{SELFPARAM();
if (!IS_PLAYER(self))
return;
.float last_vehiclecheck;
.int items_added;
void PlayerPreThink (void)
-{
+{SELFPARAM();
WarpZone_PlayerPhysics_FixVAngle();
self.stat_game_starttime = game_starttime;
// Savage: Check for nameless players
if (isInvisibleString(self.netname)) {
- string new_name = strzone(strcat("Player@", self.netaddress));
+ string new_name = strzone(strcat("Player@", ftos(self.playerid)));
if(autocvar_sv_eventlog)
GameLogEcho(strcat(":name:", ftos(self.playerid), ":", new_name));
if(self.netname_previous)
{
self.teamkill_soundtime = 0;
- entity oldpusher, oldself;
-
- oldself = self; self = self.teamkill_soundsource;
- oldpusher = self.pusher; self.pusher = oldself;
+ setself(self.teamkill_soundsource);
+ entity oldpusher = self.pusher;
+ self.pusher = this;
PlayerSound(playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY);
self.pusher = oldpusher;
- self = oldself;
+ setself(this);
}
if(self.taunt_soundtime)
*/
.float idlekick_lasttimeleft;
void PlayerPostThink (void)
-{
+{SELFPARAM();
if(sv_maxidle > 0 && frametime) // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
+ if(IS_REAL_CLIENT(self))
if(IS_PLAYER(self) || sv_maxidle_spectatorsareidle)
{
if (time - self.parm_idlesince < 1) // instead of (time == self.parm_idlesince) to support sv_maxidle <= 10
playerdemo_write();
- CSQCMODEL_AUTOUPDATE();
+ CSQCMODEL_AUTOUPDATE(self);
}