X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_client.qc;h=bd9c46a9b09de09f634d092f47fe4f6c3f91279f;hb=234a0c0c12c8b0e70f9b5f6be86bd6e3e5edf5d4;hp=03ab777b941c151ce93fe5cccc92e87cd1d9248e;hpb=b5c7eb4ebce0271e742eb850ad9b974a1540fef3;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 03ab777b9..bd9c46a9b 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1,14 +1,64 @@ +#include "cl_client.qh" + +#include "anticheat.qh" +#include "cl_impulse.qh" +#include "cl_player.qh" +#include "ent_cs.qh" +#include "ipban.qh" +#include "miscfunctions.qh" +#include "portals.qh" +#include "teamplay.qh" +#include "playerdemo.qh" +#include "spawnpoints.qh" +#include "g_damage.qh" +#include "g_hook.qh" +#include "command/common.qh" +#include "cheats.qh" +#include "g_world.qh" +#include "race.qh" +#include "antilag.qh" +#include "campaign.qh" +#include "command/common.qh" + +#include "bot/bot.qh" +#include "bot/navigation.qh" + +#include "../common/vehicles/all.qh" + +#include "weapons/hitplot.qh" +#include "weapons/weaponsystem.qh" + +#include "../common/net_notice.qh" +#include "../common/physics.qh" + +#include "../common/items/all.qc" + +#include "../common/mutators/mutator/waypoints/all.qh" + +#include "../common/triggers/subs.qh" +#include "../common/triggers/triggers.qh" +#include "../common/triggers/trigger/secret.qh" + +#include "../common/minigames/sv_minigames.qh" + +#include "../common/items/inventory.qh" + +#include "../common/monsters/sv_monsters.qh" + +#include "../warpzonelib/server.qh" + + void send_CSQC_teamnagger() { WriteByte(MSG_BROADCAST, SVC_TEMPENTITY); WriteByte(MSG_BROADCAST, TE_CSQC_TEAMNAGGER); } -float ClientData_Send(entity to, float sf) -{ +float ClientData_Send(entity to, int sf) +{SELFPARAM(); if(to != self.owner) { error("wtf"); - return FALSE; + return false; } entity e; @@ -36,22 +86,22 @@ float ClientData_Send(entity to, float sf) if(sf & 8) { - WriteAngle(MSG_ENTITY, e.v_angle_x); - WriteAngle(MSG_ENTITY, e.v_angle_y); + WriteAngle(MSG_ENTITY, e.v_angle.x); + WriteAngle(MSG_ENTITY, e.v_angle.y); } - return TRUE; + return true; } void ClientData_Attach() -{ - Net_LinkEntity(self.clientdata = spawn(), FALSE, 0, ClientData_Send); +{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; } @@ -122,7 +172,7 @@ string CheckPlayerModel(string plyermodel) { void setplayermodel(entity e, string modelname) { precache_model(modelname); - setmodel(e, modelname); + _setmodel(e, modelname); player_setupanimsformodel(); UpdatePlayerSounds(); } @@ -136,13 +186,13 @@ putting a client as observer in the server */ void FixPlayermodel(); void PutObserverInServer (void) -{ +{SELFPARAM(); entity spot; self.hud = HUD_NORMAL; - if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); } + if(IS_PLAYER(self)) { Send_Effect(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); } - spot = SelectSpawnPoint (TRUE); + spot = SelectSpawnPoint (true); if(!spot) error("No spawnpoints for observers?!?\n"); RemoveGrapplingHook(self); // Wazat's Grappling Hook @@ -170,7 +220,7 @@ void PutObserverInServer (void) } if(self.vehicle) - vehicles_exit(VHEF_RELESE); + vehicles_exit(VHEF_RELEASE); WaypointSprite_PlayerDead(); @@ -180,13 +230,14 @@ void PutObserverInServer (void) if(self.killcount != -666) { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, self.netname); - if(autocvar_g_chat_nospectators == 1 || (cvar("g_warmup") && !(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2)) + if(!intermission_running) + if(autocvar_g_chat_nospectators == 1 || (!(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2)) Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CHAT_NOSPECTATORS); - if(self.just_joined == FALSE) { + if(self.just_joined == false) { LogTeamchange(self.playerid, -1, 4); } else - self.just_joined = FALSE; + self.just_joined = false; } PlayerScore_Clear(self); // clear scores when needed @@ -196,9 +247,9 @@ void PutObserverInServer (void) self.spectatortime = time; self.classname = "observer"; - self.iscreature = FALSE; + self.iscreature = false; self.teleportable = TELEPORT_SIMPLE; - self.damagedbycontents = FALSE; + self.damagedbycontents = false; self.health = -666; self.takedamage = DAMAGE_NO; self.solid = SOLID_NOT; @@ -231,8 +282,8 @@ void PutObserverInServer (void) self.deadflag = DEAD_NO; self.angles = spot.angles; self.angles_z = 0; - self.fixangle = TRUE; - self.crouch = FALSE; + self.fixangle = true; + self.crouch = false; self.revival_time = 0; setorigin (self, (spot.origin + PL_VIEW_OFS)); // offset it so that the spectator spawns higher off the ground, looks better this way @@ -241,7 +292,7 @@ void PutObserverInServer (void) 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 @@ -265,16 +316,16 @@ void PutObserverInServer (void) .float model_randomizer; void FixPlayermodel() -{ +{SELFPARAM(); string defaultmodel; float defaultskin, chmdl, oldskin, n, i; vector m1, m2; defaultmodel = ""; defaultskin = 0; - chmdl = FALSE; + chmdl = false; - if(autocvar_sv_defaultcharacter == 1) + if(autocvar_sv_defaultcharacter) { if(teamplay) { @@ -311,6 +362,10 @@ void FixPlayermodel() } } + MUTATOR_CALLHOOK(FixPlayermodel, defaultmodel, defaultskin); + defaultmodel = ret_string; + defaultskin = ret_int; + if(defaultmodel != "") { if (defaultmodel != self.model) @@ -319,7 +374,7 @@ void FixPlayermodel() m2 = self.maxs; setplayermodel (self, defaultmodel); setsize (self, m1, m2); - chmdl = TRUE; + chmdl = true; } oldskin = self.skin; @@ -332,7 +387,7 @@ void FixPlayermodel() m2 = self.maxs; setplayermodel (self, self.playermodel); setsize (self, m1, m2); - chmdl = TRUE; + chmdl = true; } oldskin = self.skin; @@ -351,15 +406,11 @@ void FixPlayermodel() 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)) @@ -374,22 +425,21 @@ void PutClientInServer (void) // reset player keys self.itemkeys = 0; - MUTATOR_CALLHOOK(PutClientInServer); + MUTATOR_CALLHOOK(PutClientInServer, self); if(gameover) self.classname = "observer"; if(IS_PLAYER(self)) { - entity spot, oldself; - float j; + entity spot; accuracy_resend(self); if(self.team < 0) - JoinBestTeam(self, FALSE, TRUE); + JoinBestTeam(self, false, true); - spot = SelectSpawnPoint (FALSE); + spot = SelectSpawnPoint (false); if(!spot) { Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_NOSPAWNS); @@ -398,14 +448,11 @@ void PutClientInServer (void) RemoveGrapplingHook(self); // Wazat's Grappling Hook - if(self.vehicle) - vehicles_exit(VHEF_RELESE); - self.classname = "player"; - self.wasplayer = TRUE; - self.iscreature = TRUE; + self.wasplayer = true; + self.iscreature = true; self.teleportable = TELEPORT_NORMAL; - self.damagedbycontents = TRUE; + self.damagedbycontents = true; self.movetype = MOVETYPE_WALK; self.solid = SOLID_SLIDEBOX; self.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID; @@ -416,7 +463,7 @@ void PutClientInServer (void) 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; @@ -489,7 +536,7 @@ void PutClientInServer (void) self.respawn_flags = 0; self.respawn_time = 0; self.stat_respawn_time = 0; - self.scale = 0; + self.scale = autocvar_sv_player_scale; self.fade_time = 0; self.pain_frame = 0; self.pain_finished = 0; @@ -512,7 +559,7 @@ void PutClientInServer (void) self.angles_z = 0; // never spawn tilted even if the spot says to if(IS_BOT_CLIENT(self)) self.v_angle = self.angles; - self.fixangle = TRUE; // turn this way immediately + self.fixangle = true; // turn this way immediately self.velocity = '0 0 0'; self.avelocity = '0 0 0'; self.punchangle = '0 0 0'; @@ -523,7 +570,7 @@ void PutClientInServer (void) entity spawnevent = spawn(); spawnevent.owner = self; - Net_LinkEntity(spawnevent, FALSE, 0.5, SpawnEvent_Send); + Net_LinkEntity(spawnevent, false, 0.5, SpawnEvent_Send); // Cut off any still running player sounds. stopsound(self, CH_PLAYER_SINGLE); @@ -532,11 +579,11 @@ void PutClientInServer (void) FixPlayermodel(); self.drawonlytoclient = world; - self.crouch = FALSE; + self.crouch = false; self.view_ofs = PL_VIEW_OFS; setsize (self, PL_MIN, PL_MAX); self.spawnorigin = spot.origin; - setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24)); + setorigin (self, spot.origin + '0 0 1' * (1 - self.mins.z - 24)); // don't reset back to last position, even if new position is stuck in solid self.oldorigin = self.origin; self.prevorigin = self.origin; @@ -546,9 +593,9 @@ void PutClientInServer (void) self.event_damage = PlayerDamage; - self.bot_attack = TRUE; - self.monster_attack = TRUE; - + self.bot_attack = true; + self.monster_attack = true; + self.spider_slowness = 0; self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = 0; @@ -558,12 +605,12 @@ void PutClientInServer (void) 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.speedrunning = FALSE; + self.speedrunning = false; //stuffcmd(self, "chase_active 0"); //stuffcmd(self, "set viewsize $tmpviewsize \n"); @@ -571,32 +618,26 @@ void PutClientInServer (void) target_voicescript_clear(self); // reset fields the weapons may use - for (j = WEP_FIRST; j <= WEP_LAST; ++j) + for (int j = WEP_FIRST; j <= WEP_LAST; ++j) { WEP_ACTION(j, WR_RESETPLAYER); // all weapons must be fully loaded when we spawn - entity e; - e = get_weaponinfo(j); - if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars + entity e = get_weaponinfo(j); + if (e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars 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); - spawn_spot = spot; - MUTATOR_CALLHOOK(PlayerSpawn); + MUTATOR_CALLHOOK(PlayerSpawn, spot); if(autocvar_spawn_debug) { @@ -625,8 +666,8 @@ void PutClientInServer (void) .float ebouncefactor, ebouncestop; // electro's values // 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, float sf) -{ +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])); @@ -654,11 +695,11 @@ float ClientInit_SendEntity(entity to, float sf) WriteByte(MSG_ENTITY, WEP_CVAR_SEC(hagar, load_max)); // hagar max loadable rockets // WEAPONTODO WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange); WriteByte(MSG_ENTITY, WEP_CVAR(porto, secondary)); // WEAPONTODO - return TRUE; + return true; } void ClientInit_CheckUpdate() -{ +{SELFPARAM(); self.nextthink = time; if(self.count != autocvar_g_balance_armor_blockpercent) { @@ -688,18 +729,13 @@ void ClientInit_CheckUpdate() } 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); + Net_LinkEntity(e, false, 0, ClientInit_SendEntity); - o = self; - self = e; - ClientInit_CheckUpdate(); - self = o; + WITH(entity, self, e, ClientInit_CheckUpdate()); } /* @@ -719,7 +755,7 @@ SetChangeParms ============= */ void SetChangeParms (void) -{ +{SELFPARAM(); // save parms for level change parm1 = self.parm_idlesince - time; } @@ -730,7 +766,7 @@ DecodeLevelParms ============= */ void DecodeLevelParms (void) -{ +{SELFPARAM(); // load parms self.parm_idlesince = parm1; if(self.parm_idlesince == -(86400 * 366)) @@ -750,10 +786,10 @@ Called when a client types 'kill' in the console .float clientkill_nexttime; void ClientKill_Now_TeamChange() -{ +{SELFPARAM(); if(self.killindicator_teamchange == -1) { - JoinBestTeam( self, FALSE, TRUE ); + JoinBestTeam( self, false, true ); } else if(self.killindicator_teamchange == -2) { @@ -767,10 +803,10 @@ void ClientKill_Now_TeamChange() } void ClientKill_Now() -{ +{SELFPARAM(); if(self.vehicle) { - vehicles_exit(VHEF_RELESE); + vehicles_exit(VHEF_RELEASE); if(!self.killindicator_teamchange) { self.vehicle_health = -1; @@ -792,7 +828,7 @@ void ClientKill_Now() // now I am sure the player IS dead } void KillIndicator_Think() -{ +{SELFPARAM(); if (gameover) { self.owner.killindicator = world; @@ -809,8 +845,7 @@ void KillIndicator_Think() 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 @@ -821,7 +856,7 @@ void KillIndicator_Think() 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) @@ -834,7 +869,7 @@ void KillIndicator_Think() float clientkilltime; void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec -{ +{SELFPARAM(); float killtime; float starttime; entity e; @@ -938,7 +973,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 } void ClientKill (void) -{ +{SELFPARAM(); if(gameover) return; if(self.player_blocked) return; if(self.frozen) return; @@ -974,7 +1009,7 @@ float PlayerInIDList(entity p, string idlist) float n, i; string s; - // NOTE: we do NOT check crypto_keyfp here, an unsigned ID is fine too for this + // NOTE: we do NOT check crypto_idfp_signed here, an unsigned ID is fine too for this if (!p.crypto_idfp) return 0; @@ -990,6 +1025,27 @@ float PlayerInIDList(entity p, string idlist) return 0; } +#ifdef DP_EXT_PRECONNECT +/* +============= +ClientPreConnect + +Called once (not at each match start) when a client begins a connection to the server +============= +*/ +void ClientPreConnect (void) +{SELFPARAM(); + if(autocvar_sv_eventlog) + { + GameLogEcho(sprintf(":connect:%d:%d:%s", + self.playerid, + num_for_edict(self), + ((IS_REAL_CLIENT(self)) ? self.netaddress : "bot") + )); + } +} +#endif + /* ============= ClientConnect @@ -998,15 +1054,13 @@ Called when a client connects to the server ============= */ 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)) { - print("Warning: ClientConnect, but already connected!\n"); + LOG_INFO("Warning: ClientConnect, but already connected!\n"); return; } @@ -1026,7 +1080,7 @@ void ClientConnect (void) if(player_count<0) { - dprint("BUG player count is lower than zero, this cannot happen!\n"); + LOG_TRACE("BUG player count is lower than zero, this cannot happen!\n"); player_count = 0; } @@ -1035,6 +1089,7 @@ void ClientConnect (void) PlayerScore_Attach(self); ClientData_Attach(); accuracy_init(self); + Inventory_new(self); bot_clientconnect(); @@ -1084,7 +1139,7 @@ void ClientConnect (void) if(self.team_forced > 0) self.team_forced = 0; - JoinBestTeam(self, FALSE, FALSE); // if the team number is valid, keep it + JoinBestTeam(self, false, false); // if the team number is valid, keep it if((autocvar_sv_spectate == 1) || autocvar_g_campaign || self.team_forced < 0) { self.classname = "observer"; @@ -1120,7 +1175,7 @@ void ClientConnect (void) LogTeamchange(self.playerid, self.team, 1); - self.just_joined = TRUE; // stop spamming the eventlog with additional lines when the client connects + self.just_joined = true; // stop spamming the eventlog with additional lines when the client connects self.netname_previous = strzone(self.netname); @@ -1195,14 +1250,18 @@ void ClientConnect (void) CheatInitClient(); - CSQCMODEL_AUTOINIT(); + CSQCMODEL_AUTOINIT(self); self.model_randomizer = random(); if(IS_REAL_CLIENT(self)) sv_notice_join(); - MUTATOR_CALLHOOK(ClientConnect); + for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) { + WITH(entity, self, e, e.init_for_player(this)); + } + + MUTATOR_CALLHOOK(ClientConnect, self); } /* ============= @@ -1214,19 +1273,22 @@ Called when a client disconnects from the server .entity chatbubbleentity; void ReadyCount(); void ClientDisconnect (void) -{ +{SELFPARAM(); if(self.vehicle) - vehicles_exit(VHEF_RELESE); + vehicles_exit(VHEF_RELEASE); if (!IS_CLIENT(self)) { - print("Warning: ClientDisconnect without ClientConnect\n"); + LOG_INFO("Warning: ClientDisconnect without ClientConnect\n"); return; } PlayerStats_GameReport_FinalizePlayer(self); - if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); } + if ( self.active_minigame ) + part_minigame(self); + + if(IS_PLAYER(self)) { Send_Effect(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); } CheatShutdownClient(); @@ -1270,6 +1332,7 @@ void ClientDisconnect (void) bot_relinkplayerlist(); accuracy_free(self); + Inventory_delete(self); ClientData_Detach(); PlayerScore_Detach(self); @@ -1294,7 +1357,7 @@ void ClientDisconnect (void) .float BUTTON_CHAT; void ChatBubbleThink() -{ +{SELFPARAM(); self.nextthink = time; if ((self.owner.alpha < 0) || self.owner.chatbubbleentity != self) { @@ -1303,18 +1366,24 @@ void ChatBubbleThink() remove(self); return; } - if ((self.owner.BUTTON_CHAT && !self.owner.deadflag) -#ifdef TETRIS - || self.owner.tetris_on -#endif - ) - self.model = self.mdl; - else - self.model = ""; + + self.mdl = ""; + + if ( !self.owner.deadflag && IS_PLAYER(self.owner) ) + { + if ( self.owner.active_minigame ) + self.mdl = "models/sprites/minigame_busy.iqm"; + else if ( self.owner.BUTTON_CHAT ) + self.mdl = "models/misc/chatbubble.spr"; + } + + if ( self.model != self.mdl ) + _setmodel(self, self.mdl); + } void UpdateChatBubble() -{ +{SELFPARAM(); if (self.alpha < 0) return; // spawn a chatbubble entity if needed @@ -1325,12 +1394,12 @@ void UpdateChatBubble() 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 self.chatbubbleentity.mdl = self.chatbubbleentity.model; - self.chatbubbleentity.model = ""; + //self.chatbubbleentity.model = ""; self.chatbubbleentity.effects = EF_LOWPRECISION; } } @@ -1353,7 +1422,7 @@ void UpdateChatBubble() }*/ void respawn(void) -{ +{SELFPARAM(); if(self.alpha >= 0 && autocvar_g_respawn_ghosts) { self.solid = SOLID_NOT; @@ -1362,7 +1431,7 @@ void respawn(void) self.velocity = '0 0 1' * autocvar_g_respawn_ghosts_speed; self.avelocity = randomvec() * autocvar_g_respawn_ghosts_speed * 3 - randomvec() * autocvar_g_respawn_ghosts_speed * 3; self.effects |= CSQCMODEL_EF_RESPAWNGHOST; - pointparticles(particleeffectnum("respawn_ghost"), self.origin, '0 0 0', 1); + Send_Effect(EFFECT_RESPAWN_GHOST, self.origin, '0 0 0', 1); if(autocvar_g_respawn_ghosts_maxtime) SUB_SetFade (self, time + autocvar_g_respawn_ghosts_maxtime / 2 + random () * (autocvar_g_respawn_ghosts_maxtime - autocvar_g_respawn_ghosts_maxtime / 2), 1.5); } @@ -1374,7 +1443,7 @@ void respawn(void) } 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) @@ -1382,9 +1451,9 @@ void play_countdown(float finished, string samp) } void player_powerups (void) -{ +{SELFPARAM(); // add a way to see what the items were BEFORE all of these checks for the mutator hook - olditems = self.items; + int items_prev = self.items; if((self.items & IT_USING_JETPACK) && !self.deadflag && !gameover) self.modelflags |= MF_ROCKET; @@ -1401,13 +1470,13 @@ void player_powerups (void) if (!g_instagib) { - if (self.items & IT_STRENGTH) + if (self.items & ITEM_Strength.m_itemid) { play_countdown(self.strength_finished, "misc/poweroff.wav"); self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT); if (time > self.strength_finished) { - self.items = self.items - (self.items & IT_STRENGTH); + self.items = self.items - (self.items & ITEM_Strength.m_itemid); //Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERDOWN_STRENGTH, self.netname); Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_STRENGTH); } @@ -1416,18 +1485,18 @@ void player_powerups (void) { if (time < self.strength_finished) { - self.items = self.items | IT_STRENGTH; + self.items = self.items | ITEM_Strength.m_itemid; Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_STRENGTH, self.netname); Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_STRENGTH); } } - if (self.items & IT_INVINCIBLE) + if (self.items & ITEM_Shield.m_itemid) { play_countdown(self.invincible_finished, "misc/poweroff.wav"); self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT); if (time > self.invincible_finished) { - self.items = self.items - (self.items & IT_INVINCIBLE); + self.items = self.items - (self.items & ITEM_Shield.m_itemid); //Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERDOWN_SHIELD, self.netname); Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SHIELD); } @@ -1436,7 +1505,7 @@ void player_powerups (void) { if (time < self.invincible_finished) { - self.items = self.items | IT_INVINCIBLE; + self.items = self.items | ITEM_Shield.m_itemid; Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SHIELD, self.netname); Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SHIELD); } @@ -1496,7 +1565,7 @@ void player_powerups (void) if (time < self.spawnshieldtime) self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT); - MUTATOR_CALLHOOK(PlayerPowerups); + MUTATOR_CALLHOOK(PlayerPowerups, self, items_prev); } float CalcRegen(float current, float stable, float regenfactor, float regenframetime) @@ -1545,20 +1614,25 @@ float CalcRotRegen(float current, float regenstable, float regenfactor, float re } 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; regen_mod_regen = regen_mod; regen_mod_rot = rot_mod; regen_mod_limit = limit_mod; + + regen_health = autocvar_g_balance_health_regen; + regen_health_linear = autocvar_g_balance_health_regenlinear; + regen_health_rot = autocvar_g_balance_health_rot; + regen_health_rotlinear = autocvar_g_balance_health_rotlinear; + regen_health_stable = autocvar_g_balance_health_regenstable; + regen_health_rotstable = autocvar_g_balance_health_rotstable; if(!MUTATOR_CALLHOOK(PlayerRegen)) if(!self.frozen) { - float minh, mina, maxh, maxa, limith, limita; - maxh = autocvar_g_balance_health_rotstable; + float mina, maxa, limith, limita; maxa = autocvar_g_balance_armor_rotstable; - minh = autocvar_g_balance_health_regenstable; mina = autocvar_g_balance_armor_regenstable; limith = autocvar_g_balance_health_limit; limita = autocvar_g_balance_armor_limit; @@ -1568,19 +1642,23 @@ void player_regen (void) rot_mod = regen_mod_rot; limit_mod = regen_mod_limit; - maxh = maxh * max_mod; - minh = minh * max_mod; + regen_health_rotstable = regen_health_rotstable * max_mod; + regen_health_stable = regen_health_stable * max_mod; limith = limith * limit_mod; limita = limita * limit_mod; self.armorvalue = CalcRotRegen(self.armorvalue, mina, autocvar_g_balance_armor_regen, autocvar_g_balance_armor_regenlinear, regen_mod * frametime * (time > self.pauseregen_finished), maxa, autocvar_g_balance_armor_rot, autocvar_g_balance_armor_rotlinear, rot_mod * frametime * (time > self.pauserotarmor_finished), limita); - self.health = CalcRotRegen(self.health, minh, autocvar_g_balance_health_regen, autocvar_g_balance_health_regenlinear, regen_mod * frametime * (time > self.pauseregen_finished), maxh, autocvar_g_balance_health_rot, autocvar_g_balance_health_rotlinear, rot_mod * frametime * (time > self.pauserothealth_finished), limith); + self.health = CalcRotRegen(self.health, regen_health_stable, regen_health, regen_health_linear, regen_mod * frametime * (time > self.pauseregen_finished), regen_health_rotstable, regen_health_rot, regen_health_rotlinear, rot_mod * frametime * (time > self.pauserothealth_finished), limith); } // if player rotted to death... die! // check this outside above checks, as player may still be able to rot to death if(self.health < 1) + { + if(self.vehicle) + vehicles_exit(VHEF_RELEASE); self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0'); + } if (!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { @@ -1590,13 +1668,13 @@ void player_regen (void) minf = autocvar_g_balance_fuel_regenstable; limitf = autocvar_g_balance_fuel_limit; - self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, frametime * (time > self.pauseregen_finished) * ((self.items & IT_FUEL_REGEN) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > self.pauserotfuel_finished), limitf); + self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, frametime * (time > self.pauseregen_finished) * ((self.items & ITEM_JetpackRegen.m_itemid) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > self.pauserotfuel_finished), limitf); } } float zoomstate_set; void SetZoomState(float z) -{ +{SELFPARAM(); if(z != self.zoomstate) { self.zoomstate = z; @@ -1605,57 +1683,20 @@ void SetZoomState(float z) zoomstate_set = 1; } -void GetPressedKeys(void) { +void GetPressedKeys() +{SELFPARAM(); MUTATOR_CALLHOOK(GetPressedKeys); - if (self.movement_x > 0) // get if movement keys are pressed - { // forward key pressed - self.pressedkeys |= KEY_FORWARD; - self.pressedkeys &= ~KEY_BACKWARD; - } - else if (self.movement_x < 0) - { // backward key pressed - self.pressedkeys |= KEY_BACKWARD; - self.pressedkeys &= ~KEY_FORWARD; - } - else - { // no x input - self.pressedkeys &= ~KEY_FORWARD; - self.pressedkeys &= ~KEY_BACKWARD; - } - - if (self.movement_y > 0) - { // right key pressed - self.pressedkeys |= KEY_RIGHT; - self.pressedkeys &= ~KEY_LEFT; - } - else if (self.movement_y < 0) - { // left key pressed - self.pressedkeys |= KEY_LEFT; - self.pressedkeys &= ~KEY_RIGHT; - } - else - { // no y input - self.pressedkeys &= ~KEY_RIGHT; - self.pressedkeys &= ~KEY_LEFT; - } - - if (self.BUTTON_JUMP) // get if jump and crouch keys are pressed - self.pressedkeys |= KEY_JUMP; - else - self.pressedkeys &= ~KEY_JUMP; - if (self.BUTTON_CROUCH) - self.pressedkeys |= KEY_CROUCH; - else - self.pressedkeys &= ~KEY_CROUCH; - - if (self.BUTTON_ATCK) - self.pressedkeys |= KEY_ATCK; - else - self.pressedkeys &= ~KEY_ATCK; - if (self.BUTTON_ATCK2) - self.pressedkeys |= KEY_ATCK2; - else - self.pressedkeys &= ~KEY_ATCK2; + #define X(var,bit,flag) (flag ? var |= bit : var &= ~bit) + X(self.pressedkeys, KEY_FORWARD, self.movement_x > 0); + X(self.pressedkeys, KEY_BACKWARD, self.movement_x < 0); + X(self.pressedkeys, KEY_RIGHT, self.movement_y > 0); + X(self.pressedkeys, KEY_LEFT, self.movement_y < 0); + + X(self.pressedkeys, KEY_JUMP, PHYS_INPUT_BUTTON_JUMP(self)); + X(self.pressedkeys, KEY_CROUCH, PHYS_INPUT_BUTTON_CROUCH(self)); + X(self.pressedkeys, KEY_ATCK, PHYS_INPUT_BUTTON_ATCK(self)); + X(self.pressedkeys, KEY_ATCK2, PHYS_INPUT_BUTTON_ATCK2(self)); + #undef X } /* @@ -1664,9 +1705,9 @@ spectate mode routines ====================== */ -void SpectateCopy(entity spectatee) { - other = spectatee; - MUTATOR_CALLHOOK(SpectateCopy); +void SpectateCopy(entity spectatee) +{SELFPARAM(); + MUTATOR_CALLHOOK(SpectateCopy, spectatee, self); self.armortype = spectatee.armortype; self.armorvalue = spectatee.armorvalue; self.ammo_cells = spectatee.ammo_cells; @@ -1707,7 +1748,7 @@ void SpectateCopy(entity spectatee) { self.frozen = spectatee.frozen; self.revive_progress = spectatee.revive_progress; if(!self.BUTTON_USE) - self.fixangle = TRUE; + self.fixangle = true; setorigin(self, spectatee.origin); setsize(self, spectatee.mins, spectatee.maxs); SetZoomState(spectatee.zoomstate); @@ -1716,7 +1757,7 @@ void SpectateCopy(entity spectatee) { self.hud = spectatee.hud; if(spectatee.vehicle) { - self.fixangle = FALSE; + self.fixangle = false; //self.velocity = spectatee.vehicle.velocity; self.vehicle_health = spectatee.vehicle_health; self.vehicle_shield = spectatee.vehicle_shield; @@ -1729,9 +1770,9 @@ void SpectateCopy(entity spectatee) { msg_entity = self; WriteByte (MSG_ONE, SVC_SETVIEWANGLES); - WriteAngle(MSG_ONE, spectatee.v_angle_x); - WriteAngle(MSG_ONE, spectatee.v_angle_y); - WriteAngle(MSG_ONE, spectatee.v_angle_z); + WriteAngle(MSG_ONE, spectatee.v_angle.x); + WriteAngle(MSG_ONE, spectatee.v_angle.y); + WriteAngle(MSG_ONE, spectatee.v_angle.z); //WriteByte (MSG_ONE, SVC_SETVIEW); // WriteEntity(MSG_ONE, self); @@ -1740,50 +1781,37 @@ void SpectateCopy(entity spectatee) { } } -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") - return FALSE; - /*if(self.enemy.vehicle) - { +bool SpectateSet() +{SELFPARAM(); + if(!IS_PLAYER(self.enemy)) + return false; - 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; + return true; } void SetSpectator(entity player, entity spectatee) @@ -1798,47 +1826,47 @@ void SetSpectator(entity player, entity spectatee) 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"); @@ -1849,12 +1877,12 @@ float SpectateNext() 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 - return FALSE; + return false; entity first = other; // skip players until current spectated player @@ -1865,15 +1893,15 @@ float SpectatePrev() 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; + return true; } } else @@ -1895,7 +1923,7 @@ Update a respawn countdown display. ============= */ void ShowRespawnCountdown() -{ +{SELFPARAM(); float number; if(self.deadflag == DEAD_NO) // just respawned? return; @@ -1914,7 +1942,7 @@ void ShowRespawnCountdown() } void LeaveSpectatorMode() -{ +{SELFPARAM(); if(self.caplayer) return; if(nJoinAllowed(self)) @@ -1925,7 +1953,7 @@ void LeaveSpectatorMode() nades_RemoveBonus(self); if(autocvar_g_campaign || autocvar_g_balance_teams) - { JoinBestTeam(self, FALSE, TRUE); } + { JoinBestTeam(self, false, true); } if(autocvar_g_campaign) { campaign_bots_may_start = 1; } @@ -1948,11 +1976,12 @@ void LeaveSpectatorMode() /** * Determines whether the player is allowed to join. This depends on cvar - * g_maxplayers, if it isn't used this function always return TRUE, otherwise + * g_maxplayers, if it isn't used this function always return true, otherwise * 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 @@ -1991,7 +2020,8 @@ float nJoinAllowed(entity ignore) { * 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)) @@ -2004,7 +2034,7 @@ void checkSpectatorBlock() { } void PrintWelcomeMessage() -{ +{SELFPARAM(); if(self.motd_actived_time == 0) { if (autocvar_g_campaign) { @@ -2051,7 +2081,12 @@ void PrintWelcomeMessage() } void ObserverThink() -{ +{SELFPARAM(); + if ( self.impulse ) + { + MinigameImpulse(self.impulse); + self.impulse = 0; + } float prefered_movetype; if (self.flags & FL_JUMPRELEASED) { if (self.BUTTON_JUMP && !self.version_mismatch) { @@ -2081,7 +2116,12 @@ void ObserverThink() } void SpectatorThink() -{ +{SELFPARAM(); + if ( self.impulse ) + { + if(MinigameImpulse(self.impulse)) + self.impulse = 0; + } if (self.flags & FL_JUMPRELEASED) { if (self.BUTTON_JUMP && !self.version_mismatch) { self.flags &= ~FL_JUMPRELEASED; @@ -2129,15 +2169,49 @@ void SpectatorThink() self.flags |= FL_CLIENT | FL_NOTARGET; } +void vehicles_enter (entity pl, entity veh); void PlayerUseKey() -{ +{SELFPARAM(); if (!IS_PLAYER(self)) return; if(self.vehicle) { - vehicles_exit(VHEF_NORMAL); - return; + if(!gameover) + { + vehicles_exit(VHEF_NORMAL); + return; + } + } + else if(autocvar_g_vehicles_enter) + { + if(!self.frozen) + if(self.deadflag == DEAD_NO) + if(!gameover) + { + entity head, closest_target = world; + head = WarpZone_FindRadius(self.origin, autocvar_g_vehicles_enter_radius, TRUE); + + while(head) // find the closest acceptable target to enter + { + if(head.vehicle_flags & VHF_ISVEHICLE) + if(head.deadflag == DEAD_NO) + if(!head.owner || ((head.vehicle_flags & VHF_MULTISLOT) && SAME_TEAM(head.owner, self))) + if(head.takedamage != DAMAGE_NO) + { + if(closest_target) + { + if(vlen(self.origin - head.origin) < vlen(self.origin - closest_target.origin)) + { closest_target = head; } + } + else { closest_target = head; } + } + + head = head.chain; + } + + if(closest_target) { vehicles_enter(self, closest_target); return; } + } } // a use key was pressed; call handlers @@ -2159,16 +2233,16 @@ float isInvisibleString(string s) case 192: // charmap space if (!autocvar_utf8_enable) break; - return FALSE; + return false; case 160: // space in unicode fonts case 0xE000 + 192: // utf8 charmap space if (autocvar_utf8_enable) break; default: - return FALSE; + return false; } } - return TRUE; + return true; } /* @@ -2180,9 +2254,10 @@ Called every frame for each client before the physics are run */ .float usekeypressed; void() nexball_setstatus; -.float items_added; +.float last_vehiclecheck; +.int items_added; void PlayerPreThink (void) -{ +{SELFPARAM(); WarpZone_PlayerPhysics_FixVAngle(); self.stat_game_starttime = game_starttime; @@ -2190,6 +2265,8 @@ void PlayerPreThink (void) self.stat_allow_oldvortexbeam = autocvar_g_allow_oldvortexbeam; self.stat_leadlimit = autocvar_leadlimit; + self.weaponsinmap = weaponsInMap; + if(frametime) { // physics frames: update anticheat stuff @@ -2204,7 +2281,7 @@ void PlayerPreThink (void) // 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) @@ -2231,7 +2308,7 @@ void PlayerPreThink (void) if(strstr(autocvar_g_xonoticversion, "git", 0) >= 0 || strstr(autocvar_g_xonoticversion, "autobuild", 0) >= 0) { // notify release users if connecting to git - dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Xonotic ", autocvar_g_xonoticversion, " (beta)^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n"); + LOG_TRACE("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Xonotic ", autocvar_g_xonoticversion, " (beta)^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n"); Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_VERSION_BETA, autocvar_g_xonoticversion, self.cvar_g_xonoticversion); } else @@ -2241,13 +2318,13 @@ void PlayerPreThink (void) if(r < 0) { // give users new version - dprint("^1NOTE^7 to ", self.netname, "^7 - ^3Xonotic ", autocvar_g_xonoticversion, "^7 is out, and you still have ^3Xonotic ", self.cvar_g_xonoticversion, "^1 - get the update from ^4http://www.xonotic.org/^1!\n"); + LOG_TRACE("^1NOTE^7 to ", self.netname, "^7 - ^3Xonotic ", autocvar_g_xonoticversion, "^7 is out, and you still have ^3Xonotic ", self.cvar_g_xonoticversion, "^1 - get the update from ^4http://www.xonotic.org/^1!\n"); Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_VERSION_OUTDATED, autocvar_g_xonoticversion, self.cvar_g_xonoticversion); } else if(r > 0) { // notify users about old server version - print("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Xonotic ", autocvar_g_xonoticversion, "^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n"); + LOG_INFO("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Xonotic ", autocvar_g_xonoticversion, "^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n"); Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_VERSION_OLD, autocvar_g_xonoticversion, self.cvar_g_xonoticversion); } } @@ -2262,11 +2339,6 @@ void PlayerPreThink (void) self.max_armorvalue = 0; } -#ifdef TETRIS - if (TetrisPreFrame()) - return; -#endif - if(self.frozen == 2) { self.revive_progress = bound(0, self.revive_progress + frametime * self.revive_speed, 1); @@ -2280,11 +2352,11 @@ void PlayerPreThink (void) { self.revive_progress = bound(0, self.revive_progress - frametime * self.revive_speed, 1); self.health = max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * self.revive_progress ); - + if(self.health < 1) { if(self.vehicle) - vehicles_exit(VHEF_RELESE); + vehicles_exit(VHEF_RELEASE); self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE, self.origin, '0 0 0'); } else if ( self.revive_progress <= 0 ) @@ -2293,6 +2365,30 @@ void PlayerPreThink (void) MUTATOR_CALLHOOK(PlayerPreThink); + if(autocvar_g_vehicles_enter) + if(time > self.last_vehiclecheck) + if(IS_PLAYER(self)) + if(!gameover) + if(!self.frozen) + if(!self.vehicle) + if(self.deadflag == DEAD_NO) + { + entity veh; + for(veh = world; (veh = findflags(veh, vehicle_flags, VHF_ISVEHICLE)); ) + if(vlen(veh.origin - self.origin) < autocvar_g_vehicles_enter_radius) + if(veh.deadflag == DEAD_NO) + if(veh.takedamage != DAMAGE_NO) + if((veh.vehicle_flags & VHF_MULTISLOT) && SAME_TEAM(veh.owner, self)) + Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_VEHICLE_ENTER_GUNNER); + else if(!veh.owner) + if(!veh.team || SAME_TEAM(self, veh)) + Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_VEHICLE_ENTER); + else if(autocvar_g_vehicles_steal) + Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_VEHICLE_ENTER_STEAL); + + self.last_vehiclecheck = time + 1; + } + if(!self.cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button { if(self.BUTTON_USE && !self.usekeypressed) @@ -2319,12 +2415,12 @@ void PlayerPreThink (void) // FIXME turn this into CSQC stuff self.v_angle = self.lastV_angle; self.angles = self.lastV_angle; - self.fixangle = TRUE; + self.fixangle = true; } if(frametime) { - if(self.weapon == WEP_VORTEX && WEP_CVAR(vortex, charge)) + if(self.weapon == WEP_VORTEX.m_id && WEP_CVAR(vortex, charge)) { self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit)); self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit)); @@ -2332,13 +2428,13 @@ void PlayerPreThink (void) if(self.vortex_charge > WEP_CVAR(vortex, charge_animlimit)) { - self.weaponentity_glowmod_x = self.weaponentity_glowmod_x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit)); - self.weaponentity_glowmod_y = self.weaponentity_glowmod_y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit)); - self.weaponentity_glowmod_z = self.weaponentity_glowmod_z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit)); + self.weaponentity_glowmod_x = self.weaponentity_glowmod.x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit)); + self.weaponentity_glowmod_y = self.weaponentity_glowmod.y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit)); + self.weaponentity_glowmod_z = self.weaponentity_glowmod.z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit)); } } else - self.weaponentity_glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2; + self.weaponentity_glowmod = colormapPaletteColor(self.clientcolors & 0x0F, true) * 2; player_powerups(); } @@ -2419,30 +2515,30 @@ void PlayerPreThink (void) do_crouch = 0; // WEAPONTODO: THIS SHIT NEEDS TO GO EVENTUALLY - // It cannot be predicted by the engine! - if((self.weapon == WEP_SHOCKWAVE || self.weapon == WEP_SHOTGUN) && self.weaponentity.wframe == WFRAME_FIRE2 && time < self.weapon_nextthink) + // It cannot be predicted by the engine! + if((self.weapon == WEP_SHOCKWAVE.m_id || self.weapon == WEP_SHOTGUN.m_id) && self.weaponentity.wframe == WFRAME_FIRE2 && time < self.weapon_nextthink) do_crouch = 0; if (do_crouch) { if (!self.crouch) { - self.crouch = TRUE; - self.view_ofs = PL_CROUCH_VIEW_OFS; - setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX); - // setanim(self, self.anim_duck, FALSE, TRUE, TRUE); // this anim is BROKEN anyway + self.crouch = true; + self.view_ofs = self.stat_pl_crouch_view_ofs; + setsize (self, self.stat_pl_crouch_min, self.stat_pl_crouch_max); + // setanim(self, self.anim_duck, false, true, true); // this anim is BROKEN anyway } } else { if (self.crouch) { - tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self); + tracebox(self.origin, self.stat_pl_min, self.stat_pl_max, self.origin, false, self); if (!trace_startsolid) { - self.crouch = FALSE; - self.view_ofs = PL_VIEW_OFS; - setsize (self, PL_MIN, PL_MAX); + self.crouch = false; + self.view_ofs = self.stat_pl_view_ofs; + setsize (self, self.stat_pl_min, self.stat_pl_max); } } } @@ -2459,8 +2555,8 @@ void PlayerPreThink (void) W_WeaponFrame(); self.items_added = 0; - if(self.items & IT_JETPACK) - if(self.items & IT_FUEL_REGEN || self.ammo_fuel >= 0.01) + if(self.items & ITEM_Jetpack.m_itemid) + if(self.items & ITEM_JetpackRegen.m_itemid || self.ammo_fuel >= 0.01) self.items_added |= IT_FUEL; self.items |= self.items_added; @@ -2468,7 +2564,7 @@ void PlayerPreThink (void) player_regen(); - // WEAPONTODO: Add a weapon request for this + // WEAPONTODO: Add a weapon request for this // rot vortex charge to the charge limit if(WEP_CVAR(vortex, charge_rot_rate) && self.vortex_charge > WEP_CVAR(vortex, charge_limit) && self.vortex_charge_rottime < time) self.vortex_charge = bound(WEP_CVAR(vortex, charge_limit), self.vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1); @@ -2497,7 +2593,7 @@ void PlayerPreThink (void) // WEAPONTODO: Add weapon request for this if(!zoomstate_set) - SetZoomState(self.BUTTON_ZOOM || self.BUTTON_ZOOMSCRIPT || (self.BUTTON_ATCK2 && self.weapon == WEP_VORTEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_RIFLE && WEP_CVAR(rifle, secondary) == 0)); // WEAPONTODO + SetZoomState(self.BUTTON_ZOOM || self.BUTTON_ZOOMSCRIPT || (self.BUTTON_ATCK2 && self.weapon == WEP_VORTEX.m_id) || (self.BUTTON_ATCK2 && self.weapon == WEP_RIFLE.m_id && WEP_CVAR(rifle, secondary) == 0)); // WEAPONTODO float oldspectatee_status; oldspectatee_status = self.spectatee_status; @@ -2517,15 +2613,14 @@ void PlayerPreThink (void) { 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) @@ -2552,8 +2647,9 @@ Called every frame for each client after the physics are run */ .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 @@ -2588,13 +2684,6 @@ void PlayerPostThink (void) } } -#ifdef TETRIS - if(self.impulse == 100) - ImpulseCommands(); - if (!TetrisPostFrame()) - { -#endif - CheatFrame(); //CheckPlayerJump(); @@ -2609,10 +2698,6 @@ void PlayerPostThink (void) GetPressedKeys(); } -#ifdef TETRIS - } -#endif - /* float i; for(i = 0; i < 1000; ++i) @@ -2634,5 +2719,5 @@ void PlayerPostThink (void) playerdemo_write(); - CSQCMODEL_AUTOUPDATE(); + CSQCMODEL_AUTOUPDATE(self); }