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,33 +549,22 @@ 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" );
self loadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3 );
self setKillstreaks( loadoutKillstreak1, loadoutKillstreak2, loadoutKillstreak3 );
if ( self hasPerk( "specialty_extraammo", true ) && getWeaponClass( secondaryName ) != "weapon_projectile" )
self giveMaxAmmo( secondaryName );
// only give the deathstreak for the initial spawn for this life. // only give the deathstreak for the initial spawn for this life.
if ( loadoutDeathStreak != "specialty_null" && getTime() == self.spawnTime ) if( self.pers["cur_death_streak"] > 0 )
{
if ( loadoutDeathStreak != "specialty_null" )
{ {
deathVal = int( tableLookup( "mp/perkTable.csv", 1, loadoutDeathStreak, 6 ) ); deathVal = int( tableLookup( "mp/perkTable.csv", 1, loadoutDeathStreak, 6 ) );
@ -572,13 +581,7 @@ giveLoadout( team, class, allowCopycat )
self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak ); self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
} }
} }
}
self loadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3 );
self setKillstreaks( loadoutKillstreak1, loadoutKillstreak2, loadoutKillstreak3 );
if ( self hasPerk( "specialty_extraammo", true ) && getWeaponClass( secondaryName ) != "weapon_projectile" )
self giveMaxAmmo( secondaryName );
// Primary Weapon // Primary Weapon
primaryName = buildWeaponName( loadoutPrimary, loadoutPrimaryAttachment, loadoutPrimaryAttachment2 ); primaryName = buildWeaponName( loadoutPrimary, loadoutPrimaryAttachment, loadoutPrimaryAttachment2 );
@ -599,13 +602,24 @@ 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" );
if ( loadoutOffhand == "none" )
self SetOffhandSecondaryClass( "none" );
else if ( loadoutOffhand == "flash_grenade_mp" )
self SetOffhandSecondaryClass( "flash" );
else if ( loadoutOffhand == "smoke_grenade_mp" || loadoutOffhand == "concussion_grenade_mp" )
self SetOffhandSecondaryClass( "smoke" );
else
self SetOffhandSecondaryClass( "flash" );
switch( offhandSecondaryWeapon )
{
case "none":
break;
default:
self giveWeapon( offhandSecondaryWeapon ); self giveWeapon( offhandSecondaryWeapon );
if( loadOutOffhand == "smoke_grenade" ) if( loadOutOffhand == "smoke_grenade" )
self setWeaponAmmoClip( offhandSecondaryWeapon, 1 ); self setWeaponAmmoClip( offhandSecondaryWeapon, 1 );
else if( loadOutOffhand == "flash_grenade" ) else if( loadOutOffhand == "flash_grenade" )
@ -614,6 +628,8 @@ giveLoadout( team, class, allowCopycat )
self setWeaponAmmoClip( offhandSecondaryWeapon, 2 ); self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
else else
self setWeaponAmmoClip( offhandSecondaryWeapon, 1 ); 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,6 +568,8 @@ spawnPlayer()
self.fauxDead = undefined; self.fauxDead = undefined;
if ( !fauxSpawn )
{
self.killsThisLife = []; self.killsThisLife = [];
self updateSessionState( "playing", "" ); self updateSessionState( "playing", "" );
@ -594,12 +599,16 @@ spawnPlayer()
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 ( !fauxSpawn )
{
if ( self.pers["lives"] == getGametypeNumLives() ) if ( self.pers["lives"] == getGametypeNumLives() )
{ {
maps\mp\gametypes\_playerlogic::addToLivesCount(); maps\mp\gametypes\_playerlogic::addToLivesCount();
@ -622,6 +631,7 @@ spawnPlayer()
if ( level.inGracePeriod || getTimePassed() < acceptablePassedTime * 1000 ) if ( level.inGracePeriod || getTimePassed() < acceptablePassedTime * 1000 )
self.wasAliveAtMatchStart = true; self.wasAliveAtMatchStart = true;
} }
}
self setClientDvar( "cg_thirdPerson", "0" ); self setClientDvar( "cg_thirdPerson", "0" );
self setDepthOfField( 0, 0, 512, 512, 4, 0 ); self setDepthOfField( 0, 0, 512, 512, 4, 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,15 +1290,11 @@ 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 );