2023-04-13 17:30:38 +02:00

540 lines
22 KiB
Plaintext

#using scripts\shared\gameobjects_shared;
#using scripts\shared\math_shared;
#using scripts\shared\persistence_shared;
#using scripts\shared\rank_shared;
#using scripts\shared\scoreevents_shared;
#using scripts\shared\weapons\_weapon_utils;
#using scripts\mp\gametypes\_globallogic;
#using scripts\mp\gametypes\_globallogic_audio;
#using scripts\mp\gametypes\_globallogic_score;
#using scripts\mp\gametypes\_globallogic_utils;
#using scripts\mp\gametypes\_loadout;
#using scripts\mp\gametypes\_spawning;
#using scripts\mp\gametypes\_spawnlogic;
#using scripts\mp\_util;
/*
Deathmatch
Objective: Score points by eliminating other players
Map ends: When one player reaches the score limit, or time limit is reached
Respawning: No wait / Away from other players
Level requirements
------------------
Spawnpoints:
classname mp_dm_spawn_start
classname mp_dm_spawn
All players spawn from these. The spawnpoint chosen is dependent on the current locations of enemies at the time of spawn.
Players generally spawn away from enemies.
Spectator Spawnpoints:
classname mp_global_intermission
Spectators spawn from these and intermission is viewed from these positions.
Atleast one is required, any more and they are randomly chosen between.
Level script requirements
-------------------------
Team Definitions:
If using minefields or exploders:
load::main();
Optional level script settings
------------------------------
*/
/*QUAKED mp_wager_spawn (1.0 0.5 0.0) (-16 -16 0) (16 16 72)
Players spawn away from enemies at one of these positions.*/
#precache( "string", "OBJECTIVES_GUN" );
#precache( "string", "OBJECTIVES_GUN_SCORE" );
#precache( "string", "OBJECTIVES_GUN_HINT" );
#precache( "string", "MPUI_PLAYER_KILLED" );
#precache( "string", "MP_GUN_NEXT_LEVEL" );
#precache( "string", "MP_GUN_PREV_LEVEL" );
#precache( "string", "MP_GUN_PREV_LEVEL_OTHER" );
#precache( "string", "MP_HUMILIATION" );
#precache( "string", "MP_HUMILIATED" );
function main()
{
globallogic::init();
level.onStartGameType =&onStartGameType;
level.onSpawnPlayer =&onSpawnPlayer;
level.onPlayerKilled =&onPlayerKilled;
level.onEndGame = &onEndGame;
globallogic_audio::set_leader_gametype_dialog ( "startGunGame", "hcSstartGunGame", "", "" );
level.giveCustomLoadout =&giveCustomLoadout;
level.setBacksPerDemotion = GetGametypeSetting( "setbacks" );
level.inactivityKick = 60; // GetGametypeSetting( "inactivityKick" );
gameobjects::register_allowed_gameobject( level.gameType );
level.weapon_lmg_infinite = GetWeapon( "lmg_infinite" );
populateGunList();
util::registerTimeLimit( 0, 1440 );
util::registerRoundLimit( 0, 10 );
util::registerRoundWinLimit( 0, 10 );
util::registerNumLives( 0, 100 );
// Sets the scoreboard columns and determines with data is sent across the network
if ( !SessionModeIsSystemlink() && !SessionModeIsOnlineGame() && IsSplitScreen() )
// local matches only show the first three columns
globallogic::setvisiblescoreboardcolumns( "pointstowin", "kills", "stabs", "humiliated", "deaths" );
else
globallogic::setvisiblescoreboardcolumns( "pointstowin", "kills", "deaths", "stabs", "humiliated" );
}
function populateBlackMarketGunList()
{
//Black Market List
addGunToProgression( "pistol_m1911" );
addGunToProgression( "pistol_shotgun_dw" );
addGunToProgression( "shotgun_olympia", "reddot" );
addGunToProgression( "shotgun_energy", "reflex" );
addGunToProgression( "smg_ak74u", "grip", "extbarrel" );
addGunToProgression( "smg_ppsh", "reflex", "steadyaim" );
addGunToProgression( "smg_msmc", "fastreload", "reddot" );
addGunToProgression( "ar_an94", "rf", "fastreload" );
addGunToProgression( "ar_m16", "reddot", "damage" );
addGunToProgression( "ar_peacekeeper", "reddot", "quickdraw" );
addGunToProgression( "ar_galil", "reflex", "extbarrel" );
addGunToProgression( "ar_garand", "acog" );
addGunToProgression( "ar_pulse", "fastreload", "steadyaim" );
addGunToProgression( "lmg_infinite", "rf" );
addGunToProgression( "sniper_quickscope", "swayreduc" );
addGunToProgression( "sniper_double", "acog", "swayreduc" );
addGunToProgression( "launcher_ex41" );
addGunToProgression( "special_discgun" );
addGunToProgression( "special_crossbow" );
addGunToProgression( "knife_ballistic" );
}
function populateNormalGunList()
{
//Normal List
addGunToProgression( "pistol_standard", "fastreload", "steadyaim" );
addGunToProgression( "pistol_burst_dw" );
addGunToProgression( "pistol_fullauto", "reflex" );
addGunToProgression( "shotgun_pump", "extbarrel", "suppressed" );
addGunToProgression( "shotgun_precision", "qucikdraw", "holo" );
addGunToProgression( "shotgun_fullauto", "extclip" );
addGunToProgression( "smg_versatile", "grip", "extbarrel" );
addGunToProgression( "smg_burst", "suppressed" );
addGunToProgression( "smg_longrange", "reflex" );
addGunToProgression( "ar_cqb", "rf", "fastreload" );
addGunToProgression( "ar_standard", "fmj", "damage" );
addGunToProgression( "ar_longburst", "acog" );
addGunToProgression( "ar_marksman", "ir" );
addGunToProgression( "lmg_slowfire", "extclip" );
addGunToProgression( "lmg_cqb", "quickdraw", "steadyaim" );
addGunToProgression( "sniper_fastbolt", "swayreduc" );
addGunToProgression( "sniper_powerbolt", "reddot" );
addGunToProgression( "launcher_standard" );
addGunToProgression( "knife_loadout" );
addGunToProgression( "bare_hands" );
}
function populateGunListNormalSetting()
{
if ( GetDvarInt( "black_market_gun_game", 0 ) > 0 )
{
populateBlackMarketGunList();
}
else
{
populateNormalGunList();
}
}
function populateGunList()
{
level.gunProgression = [];
//use this variable for assigning cusom game lists
gunList = GetGametypeSetting( "gunSelection" );
if ( gunList == 3 )
{
gunList = RandomIntRange( 0, 3 );
}
switch ( gunList )
{
case 0:
populateGunListNormalSetting();
break;
case 1:
//Close Quarters
addGunToProgression( "pistol_standard", "reddot" );
addGunToProgression( "pistol_fullauto_dw", "reflex" );
addGunToProgression( "pistol_standard_dw" );
addGunToProgression( "pistol_burst_dw" );
addGunToProgression( "pistol_fullauto_dw" );
addGunToProgression( "shotgun_semiauto", "steadyaim" );
addGunToProgression( "shotgun_fullauto", "suppressed" );
addGunToProgression( "shotgun_pump", "quickdraw" );
addGunToProgression( "shotgun_precision", "reddot" );
addGunToProgression( "smg_fastfire", "holo" );
addGunToProgression( "smg_standard", "quickdraw" );
addGunToProgression( "smg_versatile", "suppressed" );
addGunToProgression( "smg_capacity", "stalker" );
addGunToProgression( "smg_longrange", "rf" );
addGunToProgression( "smg_burst", "reddot" );
addGunToProgression( "lmg_cqb", "quickdraw" );
addGunToProgression( "launcher_standard" );
addGunToProgression( "sniper_powerbolt", "reddot" );
addGunToProgression( "knife_loadout" );
addGunToProgression( "bare_hands" );
break;
case 2:
//Marksman
addGunToProgression( "smg_capacity", "holo", "quickdraw" );
addGunToProgression( "smg_longrange", "acog", "extclip" );
addGunToProgression( "smg_burst", "acog", "extbarrel" );
addGunToProgression( "ar_cqb", "acog" );
addGunToProgression( "ar_standard", "reflex" );
addGunToProgression( "ar_longburst", "extbarrel" );
addGunToProgression( "ar_fastburst", "holo" );
addGunToProgression( "ar_marksman", "acog" );
addGunToProgression( "ar_damage", "reddot" );
addGunToProgression( "ar_accurate", "ir", "extbarrel" );
addGunToProgression( "lmg_light", "ir" );
addGunToProgression( "lmg_cqb", "reflex" );
addGunToProgression( "lmg_heavy", "acog" );
addGunToProgression( "lmg_slowfire", "ir", "extclip" );
addGunToProgression( "sniper_fastsemi", "swayreduc", "stalker" );
addGunToProgression( "sniper_fastbolt", "ir", "rf" );
addGunToProgression( "sniper_powerbolt", "swayreduc" );
addGunToProgression( "launcher_standard" );
addGunToProgression( "knife_loadout" );
addGunToProgression( "bare_hands" );
break;
}
}
// Game Events
//========================================
function onStartGameType()
{
level.gunGameKillScore = rank::getScoreInfoValue( "kill_gun" );
util::registerScoreLimit( level.gunProgression.size * level.gunGameKillScore, level.gunProgression.size * level.gunGameKillScore );
SetDvar( "ui_weapon_tiers", level.gunProgression.size );
setClientNameMode("auto_change");
level.spawnMins = ( 0, 0, 0 );
level.spawnMaxs = ( 0, 0, 0 );
foreach( team in level.teams )
{
setupTeam( team );
}
level.useStartSpawns = true;
level.spawn_start = spawnlogic::get_spawnpoint_array( "mp_dm_spawn_start" );
// now that the game objects have been deleted place the influencers
spawning::create_map_placed_influencers();
spawning::updateAllSpawnPoints();
level.mapCenter = math::find_box_center( level.spawnMins, level.spawnMaxs );
setMapCenter( level.mapCenter );
spawnpoint = spawnlogic::get_random_intermission_point();
setDemoIntermissionPoint( spawnpoint.origin, spawnpoint.angles );
level.displayRoundEndText = false;
}
function inactivityKick()
{
self endon("disconnect");
self endon("death");
if ( SessionModeIsPrivate() )
return;
if ( level.inactivityKick == 0 )
return;
while ( level.inactivityKick > self.timePlayed["total"] )
{
wait( 1 );
}
if ( self.pers["participation"] == 0 && self.pers["time_played_moving"] < 1 )
{
globallogic::gameHistoryPlayerKicked();
kick( self getEntityNumber(), "GAME_DROPPEDFORINACTIVITY" );
}
if ( self.pers["participation"] == 0 && self.timePlayed["total"] > 60 )
{
globallogic::gameHistoryPlayerKicked();
kick( self getEntityNumber(), "GAME_DROPPEDFORINACTIVITY" );
}
}
function onSpawnPlayer(predictedSpawn)
{
if( !level.inPrematchPeriod )
{
level.useStartSpawns = false;
}
spawning::onSpawnPlayer(predictedSpawn);
self thread infiniteAmmo();
self thread inactivityKick();
}
function onPlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration )
{
level.useStartSpawns = false;
if ( ( sMeansOfDeath == "MOD_SUICIDE" ) || ( sMeansOfDeath == "MOD_TRIGGER_HURT" ) )
{
self thread demotePlayer();
return;
}
if ( isdefined( attacker ) && IsPlayer( attacker ) )
{
if ( attacker == self )
{
self thread demotePlayer(attacker);
return;
}
if ( isdefined( attacker.lastPromotionTime ) && attacker.lastPromotionTime + 3000 > getTime() )
{
scoreevents::processScoreEvent( "kill_in_3_seconds_gun", attacker, self, weapon );
}
if ( weapon_utils::isMeleeMOD( sMeansOfDeath ) )
{
scoreevents::processScoreEvent( "humiliation_gun", attacker, self, weapon );
if ( globallogic_score::getHighestScoringPlayer() === self )
{
scoreevents::processScoreEvent( "melee_leader_gun", attacker, self, weapon );
}
self thread demotePlayer(attacker);
}
if ( ( !weapon.isBallisticKnife && sMeansOfDeath != "MOD_MELEE_WEAPON_BUTT" ) || ( weapon.isBallisticKnife && sMeansOfDeath != "MOD_MELEE" ) )
{
attacker thread promotePlayer( weapon );
}
}
}
function onEndGame( winningPlayer )
{
if ( isDefined( winningPlayer ) && isPlayer( winningPlayer ) )
[[level._setPlayerScore]]( winningPlayer, [[level._getPlayerScore]]( winningPlayer ) + level.gunGameKillScore );
}
// Game Setup
//========================================
function addGunToProgression( weaponName, attachment1, attachment2, attachment3, attachment4, attachment5, attachment6, attachment7, attachment8 )
{
attachments = [];
if ( isdefined( attachment1 ) )
attachments[attachments.size] = attachment1;
if ( isdefined( attachment2 ) )
attachments[attachments.size] = attachment2;
if ( isdefined( attachment3 ) )
attachments[attachments.size] = attachment3;
if ( isdefined( attachment4 ) )
attachments[attachments.size] = attachment4;
if ( isdefined( attachment5 ) )
attachments[attachments.size] = attachment5;
if ( isdefined( attachment6 ) )
attachments[attachments.size] = attachment6;
if ( isdefined( attachment7 ) )
attachments[attachments.size] = attachment7;
if ( isdefined( attachment8 ) )
attachments[attachments.size] = attachment8;
weapon = GetWeapon( weaponName, attachments );
level.gunProgression[level.gunProgression.size] = weapon;
}
function setupTeam( team )
{
util::setObjectiveText( team, &"OBJECTIVES_GUN" );
if ( level.splitscreen )
{
util::setObjectiveScoreText( team, &"OBJECTIVES_GUN" );
}
else
{
util::setObjectiveScoreText( team, &"OBJECTIVES_GUN_SCORE" );
}
util::setObjectiveHintText( team, &"OBJECTIVES_GUN_HINT" );
spawnlogic::add_spawn_points( team, "mp_dm_spawn" );
spawnlogic::place_spawn_points( "mp_dm_spawn_start" );
}
// Gun Game
//========================================
function takeOldWeapon( oldWeapon )
{
self endon ( "death" );
self endon ( "disconnect" );
wait( 1 );
self takeweapon( oldWeapon );
}
function giveCustomLoadout( takeOldWeapon )
{
if(!isdefined(takeOldWeapon))takeOldWeapon=false;
self loadout::giveLoadout_init( !takeOldWeapon );
self loadout::setClassNum( "CLASS_ASSAULT" );
if ( takeOldWeapon )
{
oldWeapon = self GetCurrentWeapon();
weapons = self GetWeaponsList();
foreach ( weapon in weapons )
{
if( weapon != oldWeapon )
{
self takeweapon( weapon );
}
}
self thread takeOldWeapon( oldWeapon );
}
if(!isdefined(self.gunProgress))self.gunProgress=0;
currentWeapon = level.gunProgression[self.gunProgress];
self giveWeapon( currentWeapon );
self switchToWeapon( currentWeapon );
self disableweaponcycling();
if ( self.firstSpawn !== false )
{
self setSpawnWeapon( currentWeapon );
}
return currentWeapon;
}
function promotePlayer( weaponUsed )
{
self endon( "disconnect" );
self endon( "cancel_promotion" );
level endon( "game_ended" );
{wait(.05);}; // If you suicide simultaneously, you shouldn't get the promotion
if ( weaponUsed.rootweapon == level.gunProgression[self.gunProgress].rootweapon || ( isdefined( level.gunProgression[self.gunProgress].dualwieldweapon ) && level.gunProgression[self.gunProgress].dualwieldweapon.rootweapon == weaponUsed.rootweapon ) )
{
if ( self.gunProgress < level.gunProgression.size-1 )
{
self.gunProgress++;
if ( IsAlive( self ) ) // Player may have died during the wait through no fault of their own
{
self thread giveCustomLoadout( true );
}
}
pointsToWin = self.pers["pointstowin"];
if ( pointsToWin < level.scorelimit )
{
self globallogic_score::givePointsToWin( level.gunGameKillScore );
scoreevents::processScoreEvent( "kill_gun", self );
}
self.lastPromotionTime = getTime();
}
}
function demotePlayer( attacker )
{
self endon( "disconnect" );
self notify( "cancel_promotion" );
currentGunProgress = self.gunProgress;
for ( i = 0 ; i < level.setBacksPerDemotion ; i++ )
{
if ( self.gunProgress <= 0 )
{
break;
}
self globallogic_score::givePointsToWin( level.gunGameKillScore * -1 );
self.gunProgress--;
}
if ( currentGunProgress != self.gunProgress && IsAlive( self ) )
{
self thread giveCustomLoadout( true );
}
if ( isdefined( attacker ) )
{
self AddPlayerStatWithGameType( "HUMILIATE_ATTACKER", 1 );
// record attacker's melee event
attacker RecordGameEvent("capture");
}
self AddPlayerStatWithGameType( "HUMILIATE_VICTIM", 1 );
self.pers["humiliated"]++;
self.humiliated = self.pers["humiliated"];
// record victim's demote event
self RecordGameEvent("return");
self PlayLocalSound( "mpl_wager_humiliate" );
self globallogic_audio::leader_dialog_on_player( "humiliated" );
}
function infiniteAmmo()
{
self endon( "death" );
self endon( "disconnect" );
while( 1 )
{
wait( 0.1 );
weapon = self GetCurrentWeapon();
if ( weapon.rootWeapon == level.weapon_lmg_infinite )
continue;
self GiveMaxAmmo( weapon );
}
}