More GSC fixes for Gun Game and Infected

Backport setOverrideWatchDvar from IW5
pull/4/head
efinst0rm 2023-09-11 18:56:23 -05:00
parent 71cd4dfe48
commit d14eca4f21
5 changed files with 173 additions and 137 deletions

View File

@ -1415,9 +1415,22 @@ registerWatchDvar( nameString, defaultValue )
} }
setOverrideWatchDvar( dvarString, value )
{
dvarString = "scr_" + level.gameType + "_" + dvarString;
level.overrideWatchDvars[dvarString] = value;
}
getWatchedDvar( dvarString ) getWatchedDvar( dvarString )
{ {
dvarString = "scr_" + level.gameType + "_" + dvarString; dvarString = "scr_" + level.gameType + "_" + dvarString;
if ( isDefined( level.overrideWatchDvars ) && isDefined( level.overrideWatchDvars[dvarString] ) )
{
return level.overrideWatchDvars[dvarString];
}
return( level.watchDvars[ dvarString ].value ); return( level.watchDvars[ dvarString ].value );
} }

View File

@ -60,7 +60,6 @@ init()
level thread onPlayerConnecting(); level thread onPlayerConnecting();
} }
getClassChoice( response ) getClassChoice( response )
{ {
assert( isDefined( level.classMap[response] ) ); assert( isDefined( level.classMap[response] ) );
@ -77,7 +76,6 @@ getWeaponChoice( response )
return 0; return 0;
} }
logClassChoice( class, primaryWeapon, specialType, perks ) logClassChoice( class, primaryWeapon, specialType, perks )
{ {
if ( class == self.lastClass ) if ( class == self.lastClass )
@ -90,7 +88,6 @@ logClassChoice( class, primaryWeapon, specialType, perks )
self.lastClass = class; self.lastClass = class;
} }
cac_getWeapon( classIndex, weaponIndex ) cac_getWeapon( classIndex, weaponIndex )
{ {
return self getPlayerData( "customClasses", classIndex, "weaponSetups", weaponIndex, "weapon" ); return self getPlayerData( "customClasses", classIndex, "weaponSetups", weaponIndex, "weapon" );
@ -131,8 +128,6 @@ cac_getOffhand( classIndex )
return self getPlayerData( "customClasses", classIndex, "specialGrenade" ); return self getPlayerData( "customClasses", classIndex, "specialGrenade" );
} }
table_getWeapon( tableName, classIndex, weaponIndex ) table_getWeapon( tableName, classIndex, weaponIndex )
{ {
if ( weaponIndex == 0 ) if ( weaponIndex == 0 )
@ -506,6 +501,31 @@ giveLoadout( team, class, allowCopycat )
//loadoutSecondaryCamo = "none"; //loadoutSecondaryCamo = "none";
self.loadoutPrimaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutPrimaryCamo, 0 ));
self.loadoutPrimary = loadoutPrimary;
self.loadoutSecondary = loadoutSecondary;
self.loadoutSecondaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ));
if ( loadoutSecondary == "none" )
secondaryName = "none";
else
{
secondaryName = buildWeaponName( loadoutSecondary, loadoutSecondaryAttachment, loadoutSecondaryAttachment2 );
self _giveWeapon( secondaryName, int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ) ) );
}
self SetOffhandPrimaryClass( "other" );
// Action Slots
//self _SetActionSlot( 1, "" );
self _SetActionSlot( 1, "nightvision" );
self _SetActionSlot( 3, "altMode" );
self _SetActionSlot( 4, "" );
// Perks
self _clearPerks();
self _detachAll();
if ( level.killstreakRewards ) if ( level.killstreakRewards )
{ {
@ -529,50 +549,11 @@ giveLoadout( team, class, allowCopycat )
loadoutKillstreak3 = "none"; loadoutKillstreak3 = "none";
} }
secondaryName = buildWeaponName( loadoutSecondary, loadoutSecondaryAttachment, loadoutSecondaryAttachment2 );
self _giveWeapon( secondaryName, int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ) ) );
self.loadoutPrimaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutPrimaryCamo, 0 ));
self.loadoutPrimary = loadoutPrimary;
self.loadoutSecondary = loadoutSecondary;
self.loadoutSecondaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ));
self SetOffhandPrimaryClass( "other" );
// Action Slots
//self _SetActionSlot( 1, "" );
self _SetActionSlot( 1, "nightvision" );
self _SetActionSlot( 3, "altMode" );
self _SetActionSlot( 4, "" );
// Perks
self _clearPerks();
self _detachAll();
// these special case giving pistol death have to come before // these special case giving pistol death have to come before
// perk loadout to ensure player perk icons arent overwritten // perk loadout to ensure player perk icons arent overwritten
if ( level.dieHardMode ) if ( level.dieHardMode )
self maps\mp\perks\_perks::givePerk( "specialty_pistoldeath" ); self maps\mp\perks\_perks::givePerk( "specialty_pistoldeath" );
// only give the deathstreak for the initial spawn for this life.
if ( loadoutDeathStreak != "specialty_null" && getTime() == self.spawnTime )
{
deathVal = int( tableLookup( "mp/perkTable.csv", 1, loadoutDeathStreak, 6 ) );
if ( self getPerkUpgrade( loadoutPerk1 ) == "specialty_rollover" || self getPerkUpgrade( loadoutPerk2 ) == "specialty_rollover" || self getPerkUpgrade( loadoutPerk3 ) == "specialty_rollover" )
deathVal -= 1;
if ( self.pers["cur_death_streak"] == deathVal )
{
self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
self thread maps\mp\gametypes\_hud_message::splashNotify( loadoutDeathStreak );
}
else if ( self.pers["cur_death_streak"] > deathVal )
{
self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
}
}
self loadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3 ); self loadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3 );
self setKillstreaks( loadoutKillstreak1, loadoutKillstreak2, loadoutKillstreak3 ); self setKillstreaks( loadoutKillstreak1, loadoutKillstreak2, loadoutKillstreak3 );
@ -580,6 +561,28 @@ giveLoadout( team, class, allowCopycat )
if ( self hasPerk( "specialty_extraammo", true ) && getWeaponClass( secondaryName ) != "weapon_projectile" ) if ( self hasPerk( "specialty_extraammo", true ) && getWeaponClass( secondaryName ) != "weapon_projectile" )
self giveMaxAmmo( secondaryName ); self giveMaxAmmo( secondaryName );
// only give the deathstreak for the initial spawn for this life.
if( self.pers["cur_death_streak"] > 0 )
{
if ( loadoutDeathStreak != "specialty_null" )
{
deathVal = int( tableLookup( "mp/perkTable.csv", 1, loadoutDeathStreak, 6 ) );
if ( self getPerkUpgrade( loadoutPerk1 ) == "specialty_rollover" || self getPerkUpgrade( loadoutPerk2 ) == "specialty_rollover" || self getPerkUpgrade( loadoutPerk3 ) == "specialty_rollover" )
deathVal -= 1;
if ( self.pers["cur_death_streak"] == deathVal )
{
self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
self thread maps\mp\gametypes\_hud_message::splashNotify( loadoutDeathStreak );
}
else if ( self.pers["cur_death_streak"] > deathVal )
{
self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
}
}
}
// Primary Weapon // Primary Weapon
primaryName = buildWeaponName( loadoutPrimary, loadoutPrimaryAttachment, loadoutPrimaryAttachment2 ); primaryName = buildWeaponName( loadoutPrimary, loadoutPrimaryAttachment, loadoutPrimaryAttachment2 );
self _giveWeapon( primaryName, self.loadoutPrimaryCamo ); self _giveWeapon( primaryName, self.loadoutPrimaryCamo );
@ -599,21 +602,34 @@ giveLoadout( team, class, allowCopycat )
// Primary Offhand was given by givePerk (it's your perk1) // Primary Offhand was given by givePerk (it's your perk1)
// Secondary Offhand // Secondary Offhand
offhandSecondaryWeapon = loadoutOffhand + "_mp"; offhandSecondaryWeapon = loadoutOffhand;
if ( loadoutOffhand == "flash_grenade" )
self SetOffhandSecondaryClass( "flash" );
else
self SetOffhandSecondaryClass( "smoke" );
self giveWeapon( offhandSecondaryWeapon ); if ( loadoutOffhand == "none" )
if( loadOutOffhand == "smoke_grenade" ) self SetOffhandSecondaryClass( "none" );
self setWeaponAmmoClip( offhandSecondaryWeapon, 1 ); else if ( loadoutOffhand == "flash_grenade_mp" )
else if( loadOutOffhand == "flash_grenade" ) self SetOffhandSecondaryClass( "flash" );
self setWeaponAmmoClip( offhandSecondaryWeapon, 2 ); else if ( loadoutOffhand == "smoke_grenade_mp" || loadoutOffhand == "concussion_grenade_mp" )
else if( loadOutOffhand == "concussion_grenade" ) self SetOffhandSecondaryClass( "smoke" );
self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
else else
self setWeaponAmmoClip( offhandSecondaryWeapon, 1 ); self SetOffhandSecondaryClass( "flash" );
switch( offhandSecondaryWeapon )
{
case "none":
break;
default:
self giveWeapon( offhandSecondaryWeapon );
if( loadOutOffhand == "smoke_grenade" )
self setWeaponAmmoClip( offhandSecondaryWeapon, 1 );
else if( loadOutOffhand == "flash_grenade" )
self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
else if( loadOutOffhand == "concussion_grenade" )
self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
else
self setWeaponAmmoClip( offhandSecondaryWeapon, 1 );
break;
}
primaryWeapon = primaryName; primaryWeapon = primaryName;
self.primaryWeapon = primaryWeapon; self.primaryWeapon = primaryWeapon;
@ -780,7 +796,6 @@ trackRiotShield()
} }
} }
tryAttach( placement ) // deprecated; hopefully we won't need to bring this defensive function back tryAttach( placement ) // deprecated; hopefully we won't need to bring this defensive function back
{ {
if ( !isDefined( placement ) || placement != "back" ) if ( !isDefined( placement ) || placement != "back" )
@ -824,8 +839,6 @@ tryDetach( placement ) // deprecated; hopefully we won't need to bring this defe
return; return;
} }
buildWeaponName( baseName, attachment1, attachment2 ) buildWeaponName( baseName, attachment1, attachment2 )
{ {
if ( !isDefined( level.letterToNumber ) ) if ( !isDefined( level.letterToNumber ) )
@ -891,7 +904,6 @@ buildWeaponName( baseName, attachment1, attachment2 )
return ( weaponName + "_mp" ); return ( weaponName + "_mp" );
} }
makeLettersToNumbers() makeLettersToNumbers()
{ {
array = []; array = [];
@ -1011,7 +1023,6 @@ setKillstreaks( streak1, streak2, streak3 )
self.killstreaks = newKillstreaks; self.killstreaks = newKillstreaks;
} }
replenishLoadout() // used by ammo hardpoint. replenishLoadout() // used by ammo hardpoint.
{ {
team = self.pers["team"]; team = self.pers["team"];
@ -1036,7 +1047,6 @@ replenishLoadout() // used by ammo hardpoint.
self SetWeaponAmmoClip( level.classGrenades[class]["secondary"]["type"], level.classGrenades[class]["secondary"]["count"] ); self SetWeaponAmmoClip( level.classGrenades[class]["secondary"]["type"], level.classGrenades[class]["secondary"]["count"] );
} }
onPlayerConnecting() onPlayerConnecting()
{ {
for(;;) for(;;)
@ -1047,14 +1057,18 @@ onPlayerConnecting()
{ {
player.pers["class"] = ""; player.pers["class"] = "";
} }
if ( !isDefined( player.pers["lastClass"] ) )
{
player.pers["lastClass"] = "";
}
player.class = player.pers["class"]; player.class = player.pers["class"];
player.lastClass = ""; player.lastClass = player.pers["lastClass"];
player.detectExplosives = false; player.detectExplosives = false;
player.bombSquadIcons = []; player.bombSquadIcons = [];
player.bombSquadIds = []; player.bombSquadIds = [];
} }
}
}
fadeAway( waitDelay, fadeDelay ) fadeAway( waitDelay, fadeDelay )
{ {
@ -1064,7 +1078,6 @@ fadeAway( waitDelay, fadeDelay )
self.alpha = 0; self.alpha = 0;
} }
setClass( newClass ) setClass( newClass )
{ {
self.curClass = newClass; self.curClass = newClass;
@ -1080,7 +1093,6 @@ getPerkForClass( perkSlot, className )
return table_getPerk( level.classTableName, class_num, perkSlot ); return table_getPerk( level.classTableName, class_num, perkSlot );
} }
classHasPerk( className, perkName ) classHasPerk( className, perkName )
{ {
return( getPerkForClass( 0, className ) == perkName || getPerkForClass( 1, className ) == perkName || getPerkForClass( 2, className ) == perkName ); return( getPerkForClass( 0, className ) == perkName || getPerkForClass( 1, className ) == perkName || getPerkForClass( 2, className ) == perkName );

View File

@ -510,13 +510,16 @@ tiValidationCheck()
return true; return true;
} }
spawnPlayer() spawnPlayer( fauxSpawn )
{ {
self endon( "disconnect" ); self endon( "disconnect" );
self endon( "joined_spectators" ); self endon( "joined_spectators" );
self notify( "spawned" ); self notify( "spawned" );
self notify( "end_respawn" ); self notify( "end_respawn" );
if ( !isDefined( fauxSpawn ) )
fauxSpawn = false;
if ( isDefined( self.setSpawnPoint ) && self tiValidationCheck() ) if ( isDefined( self.setSpawnPoint ) && self tiValidationCheck() )
{ {
spawnPoint = self.setSpawnPoint; spawnPoint = self.setSpawnPoint;
@ -565,62 +568,69 @@ spawnPlayer()
self.fauxDead = undefined; self.fauxDead = undefined;
self.killsThisLife = []; if ( !fauxSpawn )
{
self.killsThisLife = [];
self updateSessionState( "playing", "" ); self updateSessionState( "playing", "" );
self ClearKillcamState(); self ClearKillcamState();
self.cancelkillcam = 1; self.cancelkillcam = 1;
self openMenu( "killedby_card_hide" ); self openMenu( "killedby_card_hide" );
self.maxhealth = maps\mp\gametypes\_tweakables::getTweakableValue( "player", "maxhealth" ); self.maxhealth = maps\mp\gametypes\_tweakables::getTweakableValue( "player", "maxhealth" );
self.health = self.maxhealth; self.health = self.maxhealth;
self.friendlydamage = undefined; self.friendlydamage = undefined;
self.hasSpawned = true; self.hasSpawned = true;
self.spawnTime = getTime(); self.spawnTime = getTime();
self.wasTI = !isDefined( spawnPoint ); self.wasTI = !isDefined( spawnPoint );
self.afk = false; self.afk = false;
self.lastStand = undefined; self.lastStand = undefined;
self.infinalStand = undefined; self.infinalStand = undefined;
self.inC4Death = undefined; self.inC4Death = undefined;
self.damagedPlayers = []; self.damagedPlayers = [];
self.moveSpeedScaler = 1; self.moveSpeedScaler = 1;
self.killStreakScaler = 1; self.killStreakScaler = 1;
self.xpScaler = 1; self.xpScaler = 1;
self.objectiveScaler = 1; self.objectiveScaler = 1;
self.inLastStand = false; self.inLastStand = false;
self.clampedHealth = undefined; self.clampedHealth = undefined;
self.shieldDamage = 0; self.shieldDamage = 0;
self.shieldBulletHits = 0; self.shieldBulletHits = 0;
self.recentShieldXP = 0; self.recentShieldXP = 0;
}
self.disabledWeapon = 0; self.disabledWeapon = 0;
self.disabledWeaponSwitch = 0; self.disabledWeaponSwitch = 0;
self.disabledOffhandWeapons = 0; self.disabledOffhandWeapons = 0;
self resetUsability(); self resetUsability();
if ( self.pers["lives"] == getGametypeNumLives() ) if ( !fauxSpawn )
{ {
maps\mp\gametypes\_playerlogic::addToLivesCount();
}
if ( self.pers["lives"] ) if ( self.pers["lives"] == getGametypeNumLives() )
self.pers["lives"]--; {
maps\mp\gametypes\_playerlogic::addToLivesCount();
}
self maps\mp\gametypes\_playerlogic::addToAliveCount(); if ( self.pers["lives"] )
self.pers["lives"]--;
if ( !hadSpawned || gameHasStarted() || (gameHasStarted() && level.inGracePeriod && self.hasDoneCombat) ) self maps\mp\gametypes\_playerlogic::addToAliveCount();
self maps\mp\gametypes\_playerlogic::removeFromLivesCount();
if ( !self.wasAliveAtMatchStart ) if ( !hadSpawned || gameHasStarted() || (gameHasStarted() && level.inGracePeriod && self.hasDoneCombat) )
{ self maps\mp\gametypes\_playerlogic::removeFromLivesCount();
acceptablePassedTime = 20;
if ( getTimeLimit() > 0 && acceptablePassedTime < getTimeLimit() * 60 / 4 )
acceptablePassedTime = getTimeLimit() * 60 / 4;
if ( level.inGracePeriod || getTimePassed() < acceptablePassedTime * 1000 ) if ( !self.wasAliveAtMatchStart )
self.wasAliveAtMatchStart = true; {
acceptablePassedTime = 20;
if ( getTimeLimit() > 0 && acceptablePassedTime < getTimeLimit() * 60 / 4 )
acceptablePassedTime = getTimeLimit() * 60 / 4;
if ( level.inGracePeriod || getTimePassed() < acceptablePassedTime * 1000 )
self.wasAliveAtMatchStart = true;
}
} }
self setClientDvar( "cg_thirdPerson", "0" ); self setClientDvar( "cg_thirdPerson", "0" );
@ -642,6 +652,14 @@ spawnPlayer()
self.spawnPos = spawnOrigin; self.spawnPos = spawnOrigin;
self spawn( spawnOrigin, spawnAngles ); self spawn( spawnOrigin, spawnAngles );
// immediately fix our stance if we were spawned in place so we don't get stuck in geo
if ( fauxSpawn && isDefined( self.faux_spawn_stance ) )
{
self setStance( self.faux_spawn_stance );
self.faux_spawn_stance = undefined;
}
[[level.onSpawnPlayer]](); [[level.onSpawnPlayer]]();
// Don't do this stuff for TI spawn points // Don't do this stuff for TI spawn points
@ -1272,16 +1290,12 @@ Callback_PlayerConnect()
if ( self.pers["team"] == "spectator" ) if ( self.pers["team"] == "spectator" )
{ {
if ( allowTeamChoice() ) if ( allowTeamChoice() )
{
self maps\mp\gametypes\_menus::beginTeamChoice(); self maps\mp\gametypes\_menus::beginTeamChoice();
return; else
} self [[level.autoassign]]();
self [[ level.autoassign ]]();
return;
} }
else
self maps\mp\gametypes\_menus::beginClassChoice(); self maps\mp\gametypes\_menus::beginClassChoice();
} }
/# /#

View File

@ -36,14 +36,12 @@ main()
setGuns(); setGuns();
scoreLimit = level.gun_guns.size; scoreLimit = level.gun_guns.size;
SetDvar( "scr_gun_scorelimit", scoreLimit ); registerTimeLimitDvar( level.gameType, 10, 0, 20 );
registerScoreLimitDvar( level.gameType, scoreLimit ); registerScoreLimitDvar( level.gameType, scoreLimit );
SetDvar( "scr_gun_winlimit", 1 ); registerRoundLimitDvar( level.gameType, 1, 0, 10 );
registerWinLimitDvar( "gun", 1 ); registerWinLimitDvar( level.gameType, 1, 0, 10 );
SetDvar( "scr_gun_roundlimit", 1 ); registerNumLivesDvar( level.gameType, 0, 0, 10 );
registerRoundLimitDvar( "gun", 1 ); registerHalfTimeDvar( level.gameType, 0, 0, 1 );
SetDvar( "scr_gun_halftime", 0 );
registerHalfTimeDvar( "gun", 0 );
setSpecialLoadout(); setSpecialLoadout();
@ -192,7 +190,7 @@ waitLoadoutDone()
self waittill( "spawned_player" ); self waittill( "spawned_player" );
self _setPerk( "specialty_bling", false ); self _setPerk( "specialty_bling" );
self giveNextGun( true ); self giveNextGun( true );
} }

View File

@ -8,9 +8,8 @@ main()
maps\mp\gametypes\_callbacksetup::SetupCallbacks(); maps\mp\gametypes\_callbacksetup::SetupCallbacks();
maps\mp\gametypes\_globallogic::SetupCallbacks(); maps\mp\gametypes\_globallogic::SetupCallbacks();
registerTimeLimitDvar( level.gameType, 10 ); registerTimeLimitDvar( level.gameType, 10 );
setDvar( "scorelimit", 0 ); setOverrideWatchDvar( "scorelimit", 0 );
registerRoundLimitDvar( level.gameType, 1 ); registerRoundLimitDvar( level.gameType, 1 );
registerWinLimitDvar( level.gameType, 1 ); registerWinLimitDvar( level.gameType, 1 );
registerNumLivesDvar( level.gameType, 0 ); registerNumLivesDvar( level.gameType, 0 );