This commit is contained in:
Future committed 2023-04-13 17:30:38 +02:00
commit 013c6f3b4d
921 files changed
+337975

No files matched your search

+497
View File
@@ -0,0 +1,497 @@
#using scripts\codescripts\struct;
#using scripts\shared\callbacks_shared;
#using scripts\shared\persistence_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;
Line truncated
#using scripts\mp\gametypes\_globallogic_ui;
#using scripts\mp\gametypes\_spectating;
#using scripts\mp\_util;
#precache( "material", "mpflag_spectator" );
#precache( "string", "MP_AUTOBALANCE_NOW" );
#namespace teams;
function autoexec __init__sytem__() { system::register("teams",&__init__,undefined,undefined); }
function __init__()
{
callback::on_start_gametype( &init );
level.getEnemyTeam = &getEnemyTeam;
level.use_team_based_logic_for_locking_on = true;
}
function init()
{
game["strings"]["autobalance"] = &"MP_AUTOBALANCE_NOW";
if(GetDvarString( "scr_teambalance") == "")
SetDvar("scr_teambalance", "0");
level.teambalance = GetDvarint( "scr_teambalance");
level.teambalancetimer = 0;
if(GetDvarString( "scr_timeplayedcap") == "")
SetDvar("scr_timeplayedcap", "1800");
level.timeplayedcap = int(GetDvarint( "scr_timeplayedcap"));
level.freeplayers = [];
if( level.teamBased )
{
level.alliesplayers = [];
level.axisplayers = [];
callback::on_connect( &on_player_connect );
callback::on_joined_team( &on_joined_team );
callback::on_joined_spectate( &on_joined_spectators );
level thread update_balance_dvar();
wait .15;
if ( level.onlineGame )
{
level thread update_player_times();
}
}
else
{
callback::on_connect( &on_free_player_connect );
wait .15;
if ( level.onlineGame)
{
level thread update_player_times();
}
}
}
function on_player_connect()
{
self thread track_played_time();
}
function on_free_player_connect()
{
self thread track_free_played_time();
}
function on_joined_team()
{
/#println( "joined team: " + self.pers["team"] );#/
self update_time();
}
function on_joined_spectators()
{
self.pers["teamTime"] = undefined;
}
function track_played_time()
{
self endon( "disconnect" );
if ( !isdefined( self.pers["totalTimePlayed"] ) )
{
self.pers["totalTimePlayed"] = 0;
}
foreach ( team in level.teams )
{
self.timePlayed[team] = 0;
}
self.timePlayed["free"] = 0;
self.timePlayed["other"] = 0;
self.timePlayed["alive"] = 0;
// dont reset time played in War when going into final fight, this is used for calculating match bonus
if ( !isdefined( self.timePlayed["total"] ) || !( (level.gameType == "twar") && (0 < game["roundsplayed"]) && (0 < self.timeplayed["total"]) ) )
self.timePlayed["total"] = 0;
while ( level.inPrematchPeriod )
{wait(.05);};
for ( ;; )
{
if ( game["state"] == "playing" )
{
if ( isdefined( level.teams[self.sessionteam] ) )
{
self.timePlayed[self.sessionteam]++;
self.timePlayed["total"]++;
if ( level.mpCustomMatch )
{
self.pers["sbtimeplayed"] = self.timeplayed["total"];
self.sbtimeplayed = self.pers["sbtimeplayed"];
}
if ( IsAlive( self ) )
self.timePlayed["alive"]++;
}
else if ( self.sessionteam == "spectator" )
{
self.timePlayed["other"]++;
}
}
wait ( 1.0 );
}
}
function update_player_times()
{
const minWait = 10.0;
const step = 1.0;
varWait = minWait;
nextToUpdate = 0;
for ( ;; )
{
varWait = varWait - step;
nextToUpdate++;
if ( nextToUpdate >= level.players.size )
{
nextToUpdate = 0;
if ( varWait > 0 )
{
wait ( varWait );
}
varWait = minWait;
}
if ( isdefined( level.players[nextToUpdate] ) )
{
level.players[nextToUpdate] update_played_time();
level.players[nextToUpdate] persistence::check_contract_expirations();
}
wait ( step );
}
}
function update_played_time()
{
pixbeginevent("updatePlayedTime");
if ( level.rankedMatch || level.leagueMatch )
{
foreach( team in level.teams )
{
if ( self.timePlayed[team] )
{
if ( level.teambased )
{
self AddPlayerStat( "time_played_"+team, int( min( self.timePlayed[team], level.timeplayedcap ) ) );
}
self AddPlayerStatWithGameType( "time_played_total", int( min( self.timePlayed[team], level.timeplayedcap ) ) );
}
}
if ( self.timePlayed["other"] )
{
self AddPlayerStat( "time_played_other", int( min( self.timePlayed["other"], level.timeplayedcap ) ) );
self AddPlayerStatWithGameType( "time_played_total", int( min( self.timePlayed["other"], level.timeplayedcap ) ) );
}
if ( self.timePlayed["alive"] )
{
timeAlive = int( min( self.timePlayed["alive"], level.timeplayedcap ) );
self persistence::increment_contract_times( timeAlive );
self AddPlayerStat( "time_played_alive", timeAlive );
}
}
if ( level.onlineGame )
{
timeAlive = int( min( self.timePlayed["alive"], level.timeplayedcap ) );
self.pers["time_played_alive"] += timeAlive;
}
pixendevent();
if ( game["state"] == "postgame" )
return;
foreach( team in level.teams )
{
self.timePlayed[team] = 0;
}
self.timePlayed["other"] = 0;
self.timePlayed["alive"] = 0;
}
function update_time()
{
if ( game["state"] != "playing" )
return;
self.pers["teamTime"] = getTime();
}
function update_balance_dvar()
{
for(;;)
{
teambalance = GetDvarint( "scr_teambalance");
if(level.teambalance != teambalance)
level.teambalance = GetDvarint( "scr_teambalance");
timeplayedcap = GetDvarint( "scr_timeplayedcap");
if(level.timeplayedcap != timeplayedcap)
level.timeplayedcap = int(GetDvarint( "scr_timeplayedcap"));
wait 1;
}
}
function change( team )
{
if (self.sessionstate != "dead")
{
// Set a flag on the player to they aren't robbed points for dying - the callback will remove the flag
self.switching_teams = true;
self.switchedTeamsResetGadgets = true;
self.joining_team = team;
self.leaving_team = self.pers["team"];
// Suicide the player so they can't hit escape and fail the team balance
self suicide();
}
self.pers["team"] = team;
self.team = team;
self.pers["weapon"] = undefined;
self.pers["spawnweapon"] = undefined;
self.pers["savedmodel"] = undefined;
self.pers["teamTime"] = undefined;
self.sessionteam = self.pers["team"];
self globallogic_ui::updateObjectiveText();
// update spectator permissions immediately on change of team
self spectating::set_permissions();
self SetClientScriptMainMenu( game[ "menu_start_menu" ] );
self openMenu(game[ "menu_start_menu" ]);
self notify("end_respawn");
}
function count_players()
{
players = level.players;
playerCounts = [];
foreach( team in level.teams )
{
playerCounts[team] = 0;
}
foreach( player in level.players )
{
if( player == self )
continue;
team = player.pers["team"];
if( isdefined(team) && isdefined( level.teams[team] ) )
playerCounts[team]++;
}
return playerCounts;
}
function track_free_played_time()
{
self endon( "disconnect" );
foreach( team in level.teams )
{
self.timePlayed[team] = 0;
}
self.timePlayed["other"] = 0;
self.timePlayed["total"] = 0;
self.timePlayed["alive"] = 0;
for ( ;; )
{
if ( game["state"] == "playing" )
{
team = self.pers["team"];
if ( isdefined( team ) && isdefined( level.teams[team] ) && self.sessionteam != "spectator" )
{
self.timePlayed[team]++;
self.timePlayed["total"]++;
if ( IsAlive( self ) )
self.timePlayed["alive"]++;
}
else
{
self.timePlayed["other"]++;
}
}
wait ( 1.0 );
}
}
function set_player_model( team, weapon )
{
self DetachAll();
self SetMoveSpeedScale( 1 );
self SetSprintDuration( 4 );
self SetSprintCooldown( 0 );
}
function get_flag_model( teamRef )
{
assert(isdefined(game["flagmodels"]));
assert(isdefined(game["flagmodels"][teamRef]));
return ( game["flagmodels"][teamRef] );
}
function get_flag_carry_model( teamRef )
{
assert(isdefined(game["carry_flagmodels"]));
assert(isdefined(game["carry_flagmodels"][teamRef]));
return ( game["carry_flagmodels"][teamRef] );
}
function getTeamIndex( team )
{
if( !isdefined( team ) )
{
return 0;
}
if( team == "free" )
{
return 0;
}
if( team == "allies" )
{
return 1;
}
if( team == "axis" )
{
return 2;
}
return 0;
}
function getEnemyTeam( player_team )
{
foreach( team in level.teams )
{
if ( team == player_team )
continue;
if ( team == "spectator" )
continue;
return team;
}
return util::getOtherTeam( player_team );
}
function GetEnemyPlayers()
{
enemies = [];
foreach( player in level.players )
{
if( player.team == "spectator" )
{
continue;
}
if( ( level.teamBased && player.team != self.team ) || ( !level.teamBased && player != self ) )
{
if ( !isdefined( enemies ) ) enemies = []; else if ( !IsArray( enemies ) ) enemies = array( enemies ); enemies[enemies.size]=player;;
}
}
return enemies;
}
function GetFriendlyPlayers()
{
friendlies = [];
foreach( player in level.players )
{
if( ( player.team == self.team ) && ( player != self ) )
{
if ( !isdefined( friendlies ) ) friendlies = []; else if ( !IsArray( friendlies ) ) friendlies = array( friendlies ); friendlies[friendlies.size]=player;;
}
}
return friendlies;
}
function WaitUntilTeamChange( player, callback, arg, end_condition1, end_condition2, end_condition3 )
{
if( isdefined( end_condition1 ) )
self endon( end_condition1 );
if( isdefined( end_condition2 ) )
self endon( end_condition2 );
if( isdefined( end_condition3 ) )
self endon( end_condition3 );
event = player util::waittill_any( "joined_team", "disconnect", "joined_spectators" );
if( isdefined( callback ) )
{
self [[ callback ]]( arg, event );
}
}
function WaitUntilTeamChangeSingleTon( player, singletonString, callback, arg, end_condition1, end_condition2, end_condition3 )
{
self notify( singletonString );
self endon( singletonString );
if( isdefined( end_condition1 ) )
self endon( end_condition1 );
if( isdefined( end_condition2 ) )
self endon( end_condition2 );
if( isdefined( end_condition3 ) )
self endon( end_condition3 );
event = player util::waittill_any( "joined_team", "disconnect", "joined_spectators" );
if( isdefined( callback ) )
{
self thread [[ callback ]]( arg, event );
}
}
function HideToSameTeam()
{
if( level.teambased )
{
self SetVisibleToAllExceptTeam( self.team );
}
else
{
self SetVisibleToAll();
self SetInvisibleToPlayer( self.owner );
}
}
+51
View File
@@ -0,0 +1,51 @@
#using scripts\codescripts\struct;
Line truncated
//#precache( "string", "MP_CUSTOMTEAM_WIN_MATCH" );
//#precache( "string", "MP_CUSTOMTEAM_WIN_ROUND" );
//#precache( "string", "MP_CUSTOMTEAM_MISSION_ACCOMPLISHED" );
//#precache( "string", "MP_CUSTOMTEAM_ELIMINATED" );
//#precache( "string", "MP_CUSTOMTEAM_FORFEITED" );
//#precache( "string", "MP_CUSTOMTEAM_NAME" );
function init()
{
if ( !isdefined( game["flagmodels"] ) )
game["flagmodels"] = [];
if ( !isdefined( game["carry_flagmodels"] ) )
game["carry_flagmodels"] = [];
if ( !isdefined( game["carry_icon"] ) )
game["carry_icon"] = [];
game["flagmodels"]["neutral"] = "p7_mp_flag_neutral";
}
function customteam_init()
{
if( GetDvarString( "g_customTeamName_Allies") != "" )
{
SetDvar("g_TeamName_Allies", GetDvarString( "g_customTeamName_Allies") );
// game["strings"]["allies_win"] = &"MP_CUSTOMTEAM_WIN_MATCH";
// game["strings"]["allies_win_round"] = &"MP_CUSTOMTEAM_WIN_ROUND";
// game["strings"]["allies_mission_accomplished"] = &"MP_CUSTOMTEAM_MISSION_ACCOMPLISHED";
// game["strings"]["allies_eliminated"] = &"MP_CUSTOMTEAM_ELIMINATED";
// game["strings"]["allies_forfeited"] = &"MP_CUSTOMTEAM_FORFEITED";
// game["strings"]["allies_name"] = &"MP_CUSTOMTEAM_NAME";
}
if( GetDvarString( "g_customTeamName_Axis") != "" )
{
SetDvar("g_TeamName_Axis", GetDvarString( "g_customTeamName_Axis") );
// game["strings"]["axis_win"] = &"MP_CUSTOMTEAM_WIN_MATCH";
// game["strings"]["axis_win_round"] = &"MP_CUSTOMTEAM_WIN_ROUND";
// game["strings"]["axis_mission_accomplished"] = &"MP_CUSTOMTEAM_MISSION_ACCOMPLISHED";
// game["strings"]["axis_eliminated"] = &"MP_CUSTOMTEAM_ELIMINATED";
// game["strings"]["axis_forfeited"] = &"MP_CUSTOMTEAM_FORFEITED";
// game["strings"]["axis_name"] = &"MP_CUSTOMTEAM_NAME";
}
}
+80
View File
@@ -0,0 +1,80 @@
#using scripts\codescripts\struct;
Line truncated
#using scripts\mp\teams\_teamset;
#precache( "material", "faction_allies" );
#precache( "string", "MP_BLACK_OPS_WIN_MATCH" );
#precache( "string", "MP_BLACK_OPS_WIN_ROUND" );
#precache( "string", "MP_BLACK_OPS_MISSION_ACCOMPLISHED" );
#precache( "string", "MP_BLACK_OPS_ELIMINATED" );
#precache( "string", "MP_BLACK_OPS_FORFEITED" );
#precache( "string", "MP_BLACK_OPS_NAME" );
function main()
{
init( "free" );
foreach( team in level.teams )
{
if ( team == "axis" )
continue;
init( team );
}
_teamset::customteam_init();
precache();
}
function init( team )
{
_teamset::init();
game[team] = "allies";
game["attackers"] = team;
// head icons
game["entity_headicon_" + team] = "faction_allies";
game["headicon_" + team] = "faction_allies";
// battle chatter
level.teamPrefix[team] = "vox_st";
level.teamPostfix[team] = "st6";
// scoreboard
SetDvar("g_TeamName_" + team, &"MPUI_ALLIES_SHORT");
//SetDvar("g_TeamColor_" + team, "0.6 0.64 0.69");
//SetDvar("g_ScoresColor_" + team, "0.6 0.64 0.69");
SetDvar("g_FactionName_" + team, "allies" );
game["strings"][team + "_win"] = &"MP_BLACK_OPS_WIN_MATCH";
game["strings"][team + "_win_round"] = &"MP_BLACK_OPS_WIN_ROUND";
game["strings"][team + "_mission_accomplished"] = &"MP_BLACK_OPS_MISSION_ACCOMPLISHED";
game["strings"][team + "_eliminated"] = &"MP_BLACK_OPS_ELIMINATED";
game["strings"][team + "_forfeited"] = &"MP_BLACK_OPS_FORFEITED";
game["strings"][team + "_name"] = &"MP_BLACK_OPS_NAME";
//Music
game["music"]["spawn_" + team] = "SPAWN_ST6";
game["music"]["spawn_short" + team] = "SPAWN_SHORT_ST6";
game["music"]["victory_" + team] = "VICTORY_ST6";
game["icons"][team] = "faction_allies";
game["voice"][team] = "vox_st6_";
SetDvar( "scr_" + team, "marines" );
level.heli_vo[team]["hit"] = "vox_ops_2_kls_attackheli_hit";
// flag assets
game["flagmodels"][team] = "p7_mp_flag_allies";
game["carry_flagmodels"][team] = "p7_mp_flag_allies_carry";
game["flagmodels"]["neutral"] = "p7_mp_flag_neutral";
}
function precache()
{
}
+70
View File
@@ -0,0 +1,70 @@
#using scripts\codescripts\struct;
Line truncated
#using scripts\mp\teams\_teamset;
#precache( "material", "faction_axis" );
#precache( "string", "MP_CDP_WIN_MATCH" );
#precache( "string", "MP_CDP_WIN_ROUND" );
#precache( "string", "MP_CDP_MISSION_ACCOMPLISHED" );
#precache( "string", "MP_CDP_ELIMINATED" );
#precache( "string", "MP_CDP_FORFEITED" );
#precache( "string", "MP_CDP_NAME" );
function main()
{
init( "axis" );
_teamset::customteam_init();
precache();
}
function init( team )
{
_teamset::init();
game[team] = "axis";
game["defenders"] = team;
// head icons
game["entity_headicon_" + team] = "faction_axis";
game["headicon_" + team] = "faction_axis";
// battle chatter
level.teamPrefix[team] = "vox_pm";
level.teamPostfix[team] = "axis";
// scoreboard
SetDvar("g_TeamName_" + team, &"MPUI_AXIS_SHORT");
//SetDvar("g_TeamColor_" + team, "0.65 0.57 0.41");
//SetDvar("g_ScoresColor_" + team, "0.65 0.57 0.41");
SetDvar("g_FactionName_" + team, "axis" );
game["strings"][team + "_win"] = &"MP_CDP_WIN_MATCH";
game["strings"][team + "_win_round"] = &"MP_CDP_WIN_ROUND";
game["strings"][team + "_mission_accomplished"] = &"MP_CDP_MISSION_ACCOMPLISHED";
game["strings"][team + "_eliminated"] = &"MP_CDP_ELIMINATED";
game["strings"][team + "_forfeited"] = &"MP_CDP_FORFEITED";
game["strings"][team + "_name"] = &"MP_CDP_NAME";
game["music"]["spawn_" + team] = "SPAWN_PMC";
game["music"]["spawn_short" + team] = "SPAWN_SHORT_PMC";
game["music"]["victory_" + team] = "VICTORY_PMC";
game["icons"][team] = "faction_axis";
game["voice"][team] = "vox_pmc_";
SetDvar( "scr_" + team, "ussr" );
level.heli_vo[team]["hit"] = "vox_rus_0_kls_attackheli_hit";
// flag assets
game["flagmodels"][team] = "p7_mp_flag_axis";
game["carry_flagmodels"][team] = "p7_mp_flag_axis_carry";
game["flagmodels"]["neutral"] = "p7_mp_flag_neutral";
}
function precache()
{
}
+138
View File
@@ -0,0 +1,138 @@
#using scripts\codescripts\struct;
Line truncated
#using scripts\mp\teams\_teamset;
#using scripts\mp\teams\_teamset_axis;
#using scripts\mp\teams\_teamset_allies;
#precache( "material", "faction_allies" );
#precache( "material", "faction_axis" );
#precache( "string", "MP_SEALS_WIN_MATCH" );
#precache( "string", "MP_SEALS_WIN_ROUND" );
#precache( "string", "MP_SEALS_MISSION_ACCOMPLISHED" );
#precache( "string", "MP_SEALS_ELIMINATED" );
#precache( "string", "MP_SEALS_FORFEITED" );
#precache( "string", "MP_SEALS_NAME" );
#precache( "string", "MP_PMC_WIN_MATCH" );
#precache( "string", "MP_PMC_WIN_ROUND" );
#precache( "string", "MP_PMC_MISSION_ACCOMPLISHED" );
#precache( "string", "MP_PMC_ELIMINATED" );
#precache( "string", "MP_PMC_FORFEITED" );
#precache( "string", "MP_PMC_NAME" );
function main()
{
_teamset::init();
toggle = 0;
foreach ( team in level.teams )
{
if ( toggle % 2 )
{
init_axis( team );
}
else
{
init_allies( team );
}
toggle++;
}
precache();
}
function precache()
{
_teamset_allies::precache();
_teamset_axis::precache();
}
// MTEAM: TODO: instead of duplicating all of this data here, get it out of a table
function init_allies( team )
{
game[team] = "allies";
game["attackers"] = team;
// head icons
game["entity_headicon_" + team] = "faction_allies";
game["headicon_" + team] = "faction_allies";
// battle chatter
level.teamPrefix[team] = "vox_st";
level.teamPostfix[team] = "st6";
// scoreboard
SetDvar("g_TeamName_" + team, &"MPUI_ALLIES_SHORT");
SetDvar("g_TeamColor_" + team, "0.6 0.64 0.69");
SetDvar("g_ScoresColor_" + team, "0.6 0.64 0.69");
SetDvar("g_FactionName_" + team, game[team] );
game["strings"][team + "_win"] = &"MP_SEALS_WIN_MATCH";
game["strings"][team + "_win_round"] = &"MP_SEALS_WIN_ROUND";
game["strings"][team + "_mission_accomplished"] = &"MP_SEALS_MISSION_ACCOMPLISHED";
game["strings"][team + "_eliminated"] = &"MP_SEALS_ELIMINATED";
game["strings"][team + "_forfeited"] = &"MP_SEALS_FORFEITED";
game["strings"][team + "_name"] = &"MP_SEALS_NAME";
//Music
game["music"]["spawn_" + team] = "SPAWN_ST6";
game["music"]["spawn_short" + team] = "SPAWN_SHORT_ST6";
game["music"]["victory_" + team] = "VICTORY_ST6";
game["icons"][team] = "faction_allies";
game["voice"][team] = "vox_st6_";
SetDvar( "scr_" + team, "marines" );
level.heli_vo[team]["hit"] = "vox_ops_2_kls_attackheli_hit";
// flag assets
game["flagmodels"][team] = "mp_flag_allies_1";
game["carry_flagmodels"][team] = "mp_flag_allies_1_carry";
}
function init_axis( team )
{
game[team] = "axis";
game["defenders"] = team;
// head icons
game["entity_headicon_" + team] = "faction_axis";
game["headicon_" + team] = "faction_axis";
// battle chatter
level.teamPrefix[team] = "vox_pm";
level.teamPostfix[team] = "init_axis";
// scoreboard
SetDvar("g_TeamName_" + team, &"MPUI_AXIS_SHORT");
SetDvar("g_TeamColor_" + team, "0.65 0.57 0.41");
SetDvar("g_ScoresColor_" + team, "0.65 0.57 0.41");
SetDvar("g_FactionName_" + team, game[team] );
game["strings"][team + "_win"] = &"MP_PMC_WIN_MATCH";
game["strings"][team + "_win_round"] = &"MP_PMC_WIN_ROUND";
game["strings"][team + "_mission_accomplished"] = &"MP_PMC_MISSION_ACCOMPLISHED";
game["strings"][team + "_eliminated"] = &"MP_PMC_ELIMINATED";
game["strings"][team + "_forfeited"] = &"MP_PMC_FORFEITED";
game["strings"][team + "_name"] = &"MP_PMC_NAME";
// music
game["music"]["spawn_" + team] = "SPAWN_PMC";
game["music"]["spawn_short" + team] = "SPAWN_SHORT_PMC";
game["music"]["victory_" + team] = "VICTORY_PMC";
game["icons"][team] = "faction_axis";
game["voice"][team] = "vox_pmc_";
SetDvar( "scr_" + team, "ussr" );
level.heli_vo[team]["hit"] = "vox_rus_0_kls_attackheli_hit";
// flag assets
game["flagmodels"][team] = "mp_flag_axis_1";
game["carry_flagmodels"][team] = "mp_flag_axis_1_carry";
}