Merge branch 'main' into show_speed

This commit is contained in:
erysdren 2024-12-08 08:26:28 -06:00 committed by GitHub
commit 9f1963ef7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 144 additions and 117 deletions

View file

@ -258,7 +258,7 @@ void(float amount, float playernum) RegisterPointChange =
// set our x and y positions
point_elements[index].x_position = 0;
point_elements[index].y_position = (g_height - 90) - (25*(playernum - 1));
point_elements[index].y_position = (g_height - 90) - (25 * (playernum - 1));
// start with an opacity of 1
point_elements[index].opacity = 1;
@ -315,10 +315,10 @@ void(float width, float height) HUD_Points =
for (int i = 3; i >= 0; i = i - 1)
{
float player_number = getplayerkeyfloat(i, "viewentity");
float player_number = getplayerkeyfloat(i, "client_index");
entity client = findfloat(world, playernum, player_number);
if (client == world || client.movetype == MOVETYPE_BOUNCE)
if ((client == world || !client.classname) && !client.is_spectator)
continue;
switch(i) {
@ -331,7 +331,7 @@ void(float width, float height) HUD_Points =
pointwidth = getTextWidth(ftos(client.points), 12);
x = (99 - pointwidth)/2 + GetUltraWideOffset();
if ((i + 1) == getstatf(STAT_PLAYERNUM)) {
if (player_number == getstatf(STAT_PLAYERNUM)) {
drawpic([3 + GetUltraWideOffset(), g_height - 97 - (i * 25)], "gfx/hud/moneyback.tga", [96, 24], [1,1,1], 1);
Draw_String([x, g_height - 92 - (i * 25)], ftos(client.points), [12, 12], TEXTCOLOR, 1, 0);
} else {
@ -339,7 +339,7 @@ void(float width, float height) HUD_Points =
Draw_String([x - 9, g_height - 92 - (i * 25)], ftos(client.points), [12, 12], TEXTCOLOR, 1, 0);
}
PointUpdate(x + 70, width, height, i + 1);
PointUpdate(x + 70, width, height, player_number);
}
}
@ -1524,11 +1524,11 @@ void() HUD_Scores =
for (int i = 0; i < 4; i = i + 1)
{
float player_number = getplayerkeyfloat(i, "viewentity");
float player_number = getplayerkeyfloat(i, "client_index");
entity client = findfloat(world, playernum, player_number);
if (client == world || client.movetype == MOVETYPE_BOUNCE)
break;
if ((client == world || !client.classname) && !client.is_spectator)
continue;
switch(i) {
case 1: TEXTCOLOR = TEXT_LIGHTBLUE; break;
@ -1795,18 +1795,27 @@ void(float width, float height) HUD_Waypoint =
HUD_DrawWaypointModeString(5, 175, "impulse 24", "Save current Waypoints");
}
void(float width, float height) HUD_Spectator =
{
drawfill([0, 4], [250, 60], [0, 0, 0], 0.75, 0);
Draw_String([5, 8], "SPECTATING", [18, 18], [1, 1, 1], 1, 0);
Draw_String([5, 30], "You will spawn next Round", [12, 12], [1, 1, 0], 1, 0);
Draw_String([5, 45], "(Fly around or go grab a snack!)", [10, 10], [1, 1, 1], 1, 0);
drawfill([5, 60], [240, 3], [0.3, 0.3, 0.3], 1, 0);
}
void(float width, float height) HUD_PlayerNames =
{
for (float i = 3; i >= 0; i = i - 1) {
if ((i+1) == getstatf(STAT_PLAYERNUM))
float player_number = getplayerkeyfloat(i, "client_index");
if (player_number == getstatf(STAT_PLAYERNUM))
continue;
float player_number = getplayerkeyfloat(i, "viewentity");
string text = getplayerkeyvalue(i, "name");
entity client = findfloat(world, playernum, player_number);
if (client == world || client.movetype == MOVETYPE_BOUNCE)
if (client == world || !client.classname || client.is_spectator)
continue;
// Append "[CHAT] " to the player name if the user is in message mode
@ -1856,13 +1865,13 @@ void(float width, float height) HUD_ReviveIcons =
if (revive_icons[player_index].state == 1)
revive_icons[player_index].timer += frametime;
float player_number = getplayerkeyfloat(i, "viewentity");
float player_number = getplayerkeyfloat(i, "client_index");
//string text = getplayerkeyvalue(i, "name");
entity client = findfloat(world, playernum, player_number);
// Client does not exist/is spectating.
if (client == world || client.movetype == MOVETYPE_BOUNCE)
// Client does not exist.
if (client == world || !client.classname || client.is_spectator)
continue;
entity plr = findfloat(world, playernum, player_number);
@ -1970,8 +1979,14 @@ void(float width, float height) HUD_Draw =
{
if (cvar("cl_cinematic"))
return;
if (getstatf(STAT_SPECTATING)) {
HUD_Rounds(width, height);
HUD_Spectator(width, height);
return;
}
if (!getstatf(STAT_SPECTATING) && (getstatf(STAT_HEALTH) > 1) && !score_show)
if ((getstatf(STAT_HEALTH) > 1) && !score_show)
{
Draw_Crosshair();

View file

@ -31,7 +31,7 @@ void() ToggleMenu =
{
if (serverkey("constate") != "disconnected")
{
if (player_count == 0)
if (player_count == 1)
localcmd("cmd pause\n");
if(current_menu == MENU_NONE)
@ -432,18 +432,19 @@ noref void(float isnew) CSQC_Ent_Update =
self.points = readfloat(); // FIXME: this should be made a short, but I know we use price of 1 for some test maps, so I can't do /10 *10 shenanigans.
self.kills = readshort();
self.is_in_menu = readbyte();
self.is_spectator = readbyte();
// set for HUD_PlayerDebugInfo
player_velocity = self.velocity;
RegisterPointChange(self.points - old_points, self.playernum);
setmodelindex(self, self.modelindex);
if (self.movetype == MOVETYPE_BOUNCE)
if (self.is_spectator)
self.solid = SOLID_NOT;
else
self.solid = SOLID_SLIDEBOX;
setmodelindex(self, self.modelindex);
RegisterPointChange(self.points - old_points, self.playernum);
if (map_compatibility_mode != MAP_COMPAT_BETA) {
if (self.stance == 2)
@ -453,6 +454,13 @@ noref void(float isnew) CSQC_Ent_Update =
} else {
setsize(self, PLAYER_MINS_QUAKE, PLAYER_MAXS_QUAKE);
}
if (self.modelindex == getmodelindex("models/sprites/null.spr") && !self.playernum) {
self.solid = SOLID_NOT;
self.classname = "";
} else {
self.classname = "player";
}
}
// Power-Up
else if (ent_type == 2) {

View file

@ -100,7 +100,7 @@ entity(entity blarg) find_new_enemy =
while(targets != world) {
// Don't target downed players.
if (targets.downed == true || targets.isspec == true) {
if (targets.downed == true || targets.is_spectator == true) {
targets = find(targets, classname, "player");
continue;
}

View file

@ -422,7 +422,7 @@ float() spawn_a_dogA =
FAIL = false;
pcount = 0;
szombie = getFreeZombieEnt();
if(szombie == world || dogCount >= (2 * (player_count + 1)))
if(szombie == world || dogCount >= (2 * (player_count)))
{
return 0;
}

View file

@ -440,7 +440,7 @@ void(entity target, string player_name) nzp_setplayername =
};
void(string chaptertitle, string location, string date, string person, entity who) WorldText = {
if (player_count == 0) {
if (player_count == 1) {
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EVENT_WORLDDATA);
WriteString(MSG_MULTICAST, chaptertitle);
@ -472,8 +472,8 @@ void (float achievement_id, optional entity who) GiveAchievement =
#endif // FTE
// this is an achievement specific to an individual
if ((who && who != world) || player_count == 0) {
if (player_count == 0) who = find(world, classname, "player");
if ((who && who != world) || player_count == 1) {
if (player_count == 1) who = find(world, classname, "player");
#ifndef FTE
@ -549,6 +549,7 @@ float Player_SendEntity( entity ePVEnt, float flChanged ) {
WriteFloat( MSG_ENTITY, self.points ); // Player Score
WriteShort( MSG_ENTITY, self.kills ); // Player Kills
WriteByte( MSG_ENTITY, self.is_in_menu ); // Player is in a Menu State
WriteByte( MSG_ENTITY, self.is_spectator ); // Player is spectating
return TRUE;
}

View file

@ -146,7 +146,7 @@ void() EndGameSetup =
self.weapon2model = "";
self.animend = SUB_Null;
self.perks = 0;
self.isspec = true;
self.is_spectator = true;
self.movetype = MOVETYPE_TOSS;
if (!game_over) {

View file

@ -80,11 +80,9 @@ float global_trace_damage_multiplier;
.vector oldvelocity;
.float lastsound_time;
.float isspec;
string mappath;
.float ads_toggle;
float player_count;
entity pl1;
.string fog; // used for hacking in changing fog from world.fog for legacy maps
entity local_client;

View file

@ -252,7 +252,7 @@ void() touch_perk =
float perk_purchase_limit;
if (player_count >= 1)
if (player_count > 1)
perk_purchase_limit = self.perk_purchase_limit_coop;
else
perk_purchase_limit = self.perk_purchase_limit_solo;
@ -265,7 +265,7 @@ void() touch_perk =
float price;
// Check if we're playing in Co-Op, adjust price if so.
if (player_count >= 1)
if (player_count > 1)
price = self.cost2;
// Nope, use normal/solo cost.
else
@ -374,7 +374,7 @@ void() Perk_Jingle =
{
float perk_purchase_limit;
if (player_count >= 1)
if (player_count > 1)
perk_purchase_limit = self.perk_purchase_limit_coop;
else
perk_purchase_limit = self.perk_purchase_limit_solo;
@ -413,8 +413,8 @@ void() setup_perk =
// Check for Power
if (power != world && !isPowerOn) {
// Power Switch is present -- but does this machine have an override?
if ((self.perk_requires_power_coop < 0 && player_count >= 1) ||
(self.perk_requires_power_solo < 0 && !player_count))
if ((self.perk_requires_power_coop < 0 && player_count > 1) ||
(self.perk_requires_power_solo < 0 && player_count == 1))
self.requirespower = false;
else
self.requirespower = true;

View file

@ -399,7 +399,7 @@ void() PU_CarpenterFinalize =
// Reset all windows
while(windows) {
windows.isspec = 0;
windows.is_spectator = 0;
windows.box1owner = world;
windows.usedent = world;
windows.owner = world;
@ -424,7 +424,7 @@ entity() PU_CarpenterFindWindow =
while(windows != world) {
// Window needs repaired and is repairable
if (windows.health < 6 && windows.health != -10 && !windows.isspec
if (windows.health < 6 && windows.health != -10 && !windows.is_spectator
&& !windows.ads_release)
return windows;
@ -442,7 +442,7 @@ entity() PU_CarpenterFindWindow =
void() PU_CarpenterRepair =
{
// Find a new Barricade to Repair
if (self.goaldummy == world || self.goaldummy.isspec == 0) {
if (self.goaldummy == world || self.goaldummy.is_spectator == 0) {
if (self.goaldummy != world)
self.goaldummy.owner = world;
@ -458,7 +458,7 @@ void() PU_CarpenterRepair =
}
// Mark the window as being Repaired
self.goaldummy.isspec = 1;
self.goaldummy.is_spectator = 1;
self.goaldummy.ads_release = 1;
self.goaldummy.owner = self;
}
@ -484,7 +484,7 @@ void() PU_CarpenterRepair =
} else {
if (self.ltime < time) {
self.goaldummy.frame = 88;
self.goaldummy.isspec = 0;
self.goaldummy.is_spectator = 0;
self.goaldummy.health = 6;
}
}

View file

@ -238,7 +238,7 @@ void() window_carpenter_8 =[ 8, window_carpenter_9 ] {self.frame = 72;};
void() window_carpenter_9 =[ 7, window_carpenter_10 ] {self.frame = 79; Sound_PlaySound(self, self.oldmodel, SOUND_TYPE_ENV_OBJECT, SOUND_PRIORITY_PLAYALWAYS); };
void() window_carpenter_10 =[ 8, window_carpenter_11 ] {self.frame = 80;};
void() window_carpenter_11 =[ 7, window_carpenter_12 ] {self.frame = 87; Sound_PlaySound(self, self.oldmodel, SOUND_TYPE_ENV_OBJECT, SOUND_PRIORITY_PLAYALWAYS); };
void() window_carpenter_12 =[ 8, SUB_Null ] {self.frame = 88;self.isspec = 0;};
void() window_carpenter_12 =[ 8, SUB_Null ] {self.frame = 88;self.is_spectator = 0;};
void() Window_Damage =

View file

@ -370,7 +370,7 @@ void() worldspawn =
clientstat(STAT_WEAPONZOOM, EV_FLOAT, zoom);
clientstat(STAT_INSTA, EV_FLOAT, insta_icon);
clientstat(STAT_X2, EV_FLOAT, x2_icon);
clientstat(STAT_SPECTATING, EV_FLOAT, isspec);
clientstat(STAT_SPECTATING, EV_FLOAT, is_spectator);
clientstat(STAT_PLAYERNUM, EV_FLOAT, playernum); // literally useless but will be kept in case
clientstat(STAT_PLAYERSTANCE, EV_FLOAT, stance);
clientstat(STAT_FACINGENEMY, EV_FLOAT, facingenemy);

View file

@ -176,7 +176,7 @@ void(entity client) LastStand_AssignWeapon =
self.weapons[0].weapon_reserve = 0;
}
} else {
if (!player_count) {
if (player_count == 1) {
Weapon_AssignWeapon(0, W_BIATCH, 6, 12);
} else {
Weapon_AssignWeapon(0, W_COLT, 8, 16);
@ -461,7 +461,7 @@ void(entity client) LastStand_Begin =
// End the game if no one else is alive.
float players_still_alive = PollPlayersAlive();
if ((player_count && !players_still_alive) || (!player_count && !(self.perks & P_REVIVE))) {
if ((player_count > 1&& !players_still_alive) || (player_count == 1 && !(self.perks & P_REVIVE))) {
EndGameSetup();
return;
}
@ -476,7 +476,7 @@ void(entity client) LastStand_Begin =
self.health = 19;
// Initiate Self-Revive on Solo
if ((self.perks & P_REVIVE) && !player_count) {
if ((self.perks & P_REVIVE) && player_count == 1) {
LastStand_InitiateSoloRevive(self);
}
// Spawn the Revive Trigger
@ -494,7 +494,7 @@ void(entity client) LastStand_Begin =
LastStand_AssignWeapon(self);
// Spawn Revive Sprite in Co-Op
if (player_count) {
if (player_count > 1) {
EnableReviveIcon(self.playernum);
}

View file

@ -536,34 +536,9 @@ void() PlayerPreThink =
if (!self.isBuying)
self.maxspeed *= GetWeaponWalkSpeed(self.perks, self.weapon);
}
if(self.isspec != 0 && !self.downed)
if (self.is_spectator)
{
if(self.button0 && self.fire_delay < time)
{
self.aiment = find(self.aiment, classname, "player");
if(self.aiment != world)
{
sprint(self, PRINT_HIGH, "Now spectating ");
sprint(self, PRINT_HIGH, self.aiment.netname);
sprint(self, PRINT_HIGH, "\n");
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;
}
else
{
sprint(self, PRINT_HIGH, "Freefly spectate\n");
self.movetype = MOVETYPE_FLY;
}
self.fire_delay = time + 0.25;
}
if(self.aiment != world)
{
self.origin = self.aiment.origin;
self.angles = self.aiment.v_angle;
self.velocity = self.aiment.velocity;
self.fixangle = TRUE;
}
self.movetype = MOVETYPE_NOCLIP;
return;
}
@ -624,7 +599,7 @@ void() PlayerPostThink =
#endif // FTE
if(self.isspec)
if(self.is_spectator)
return;
//landsound
@ -871,12 +846,13 @@ void() Player_PickSpawnPoint =
self = tempe;
};
void() SpectatorSpawn;
void() PlayerSpawn =
{
entity spawnpoint = world;
local_client = self;
self.isspec = FALSE;
self.is_spectator = false;
self.classname = "player";
self.solid = SOLID_BBOX;
self.flags = FL_CLIENT;
@ -895,21 +871,27 @@ void() PlayerSpawn =
setmodel(self, "models/player.mdl");
self.movetype = MOVETYPE_WALK;
self.max_health = self.health = PLAYER_START_HEALTH;
entity who = find(world,classname,"player");
while(who != self && !self.playernum)
{
if(who)
{
player_count++;
break;
}
}
// Pick an available slot from 1-4 inclusive.
if (!self.playernum) {
self.playernum = player_count + 1;
if (self.playernum == 1)
pl1 = self;
for (float i = 1; i <= 4; i++) {
entity potential_player = findfloat(world, playernum, i);
if (potential_player == world) {
self.playernum = i;
#ifdef FTE
clientcommand(self, sprintf("setinfo client_index %d\n", self.playernum));
#endif // FTE
break;
}
}
// All four slots are occupied.
if (!self.playernum) {
SpectatorSpawn();
return;
}
}
// Assign them a spawn location.
@ -949,8 +931,6 @@ void() PlayerSpawn =
self.stamina = 3;
self.reviving = 0;
self.perks = G_PERKS;
UpdatePlayerCount(player_count);
#ifdef FTE
@ -984,20 +964,40 @@ void() PlayerSpawn =
void() SpectatorSpawn =
{
local entity spawnpoint;
spawnpoint = find(world, classname, "info_player_1_spawn");
self.isspec = TRUE;
self.health = 420;
entity spawnpoint = find(world, classname, "info_player_1_spawn");
local_client = self;
self.is_spectator = true;
self.classname = "spectator";
self.solid = SOLID_CORPSE;
self.solid = SOLID_NOT;
self.flags = FL_CLIENT;
self.onfire = false;
self.fire_timeout = 0;
setmodel(self, "models/sprites/null.spr");
self.movetype = MOVETYPE_FLY;
self.origin = spawnpoint.origin + [0,0,1];
self.fixangle = TRUE;
setsize(self, PLAYER_MINS_STANDING, PLAYER_MAXS_STANDING);
self.view_ofs = '0 0 22';
self.aiment = world;
self.movetype = MOVETYPE_NOCLIP;
self.max_health = self.health = PLAYER_START_HEALTH;
self.fixangle = true;
// NZ:P Beta used Quake BSP 29, so set bounding box accordingly.
if (map_compatibility_mode == MAP_COMPAT_BETA) {
self.view_ofs = VIEW_OFS_QK;
setsize(self, PLAYER_MINS_QUAKE, PLAYER_MAXS_QUAKE);
} else {
self.view_ofs = VIEW_OFS_HL;
setsize(self, PLAYER_MINS_STANDING, PLAYER_MAXS_STANDING);
}
#ifdef FTE
self.viewzoom = 1;
self.SendEntity = Player_SendEntity;
#endif // FTE
setorigin(self, spawnpoint.origin + '0 0 20');
};
//called when a client loads a map
@ -1010,6 +1010,9 @@ void() PutClientInServer =
spawns_initialized = true;
}
player_count++;
UpdatePlayerCount(player_count);
if(cvar("developer") || player_count > 1) {
bprint(PRINT_HIGH, self.netname);
bprint(PRINT_HIGH, " has joined the game.\n");
@ -1026,6 +1029,7 @@ void() PutClientInServer =
// Force the client to always be networked to other clients, even when
// outside of the same PVS.
self.pvsflags |= PVSF_IGNOREPVS;
FTE_IncrementRound(rounds);
#endif // FTE
@ -1042,8 +1046,9 @@ void() ClientDisconnect =
self.classname = "disconnected";
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_BOUNCE;
self.nextthink = -1;
self.playernum = 0;
self.is_spectator = false;
setmodel(self, "models/sprites/null.spr");
GameRestart_ResetPerkaColas();

View file

@ -59,19 +59,18 @@ float(float a, float b) qc_max =
float() getZombieTotal = {
if (roundtype == 1) {
float count, multiplier, plrcnt;
float count, multiplier;
count = 24;
plrcnt = player_count + 1;
multiplier = qc_max(rounds/5, 1);
if (rounds >= 10)
multiplier *= rounds * 0.15;
if (plrcnt == 1)
if (player_count == 1)
count += rint((0.5 * 6) * multiplier);
else
count += rint(((plrcnt - 1) * 6) * multiplier);
count += rint(((player_count - 1) * 6) * multiplier);
if (rounds < 2)
count = floor(count * 0.25);
@ -88,9 +87,9 @@ float() getZombieTotal = {
} else { //dogs
// 2 waves
if (rounds <= 14)
return 6 * (player_count + 1);
return 6 * (player_count);
return 8 * (player_count + 1);
return 8 * (player_count);
}
return 0;
}
@ -129,7 +128,7 @@ void() EndRound =
entity who = find(world,classname,"spectator");
while(who != world)
{
if(who.isspec)
if(who.is_spectator)
{
self = who;
PlayerSpawn();

View file

@ -44,7 +44,7 @@ float client_parse_override;
float(string params) Command_give =
{
// Anti-Cheat in Co-Op.
if (player_count && cheats_have_been_activated == false) {
if (player_count > 1 && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue Give in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -69,7 +69,7 @@ float(string params) Command_give =
float(string params) Command_addmoney =
{
// Anti-Cheat in Co-Op.
if (player_count && cheats_have_been_activated == false) {
if (player_count > 1 && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue Add Money in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -109,7 +109,7 @@ float(string params) Command_softrestart =
float(string params) Command_godmode =
{
// Anti-Cheat in Co-Op.
if (player_count && cheats_have_been_activated == false) {
if (player_count > 1 && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue God Mode in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -125,7 +125,7 @@ float(string params) Command_godmode =
float(string params) Command_noclip =
{
// Anti-Cheat in Co-Op.
if (player_count && cheats_have_been_activated == false) {
if (player_count > 1 && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue No-Clip in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -148,7 +148,7 @@ float(string params) Command_noclip =
float(string params) Command_powerup =
{
// Anti-Cheat in Co-Op.
if (player_count && cheats_have_been_activated == false) {
if (player_count > 1 && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue spawn_pu in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -170,7 +170,7 @@ float(string params) Command_powerup =
float(string params) Command_tracedmgmultiplier =
{
// Anti-Cheat in Co-Op.
if (player_count && cheats_have_been_activated == false) {
if (player_count > 1 && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue sv_tracedmgmultiplier in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}

View file

@ -368,7 +368,7 @@ void() Soft_Restart = {
self.pri_grenade_state = 0;
InitRounds();
self.isspec = false;
self.is_spectator = true;
PutClientInServer();
nzp_screenflash(world, SCREENFLASH_COLOR_BLACK, 1, SCREENFLASH_FADE_OUT);

View file

@ -311,6 +311,7 @@ float map_compatibility_mode;
#define STAT_PERKS 69
.float playernum;
.float is_spectator;
float game_over;
#ifdef FTE