Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //**********************************************************************************
- //**********************************************************************************
- //
- // _ _ _ ___ ___ _ ___ ___ _
- // | | | | | | | \/ | | | | \/ | | |
- // | |_| | ___ | |_ _ | . . | ___ | |_ _ | . . | ___ __| |___
- // | _ |/ _ \| | | | | | |\/| |/ _ \| | | | | | |\/| |/ _ \ / _` / __|
- // | | | | (_) | | |_| | | | | | (_) | | |_| | | | | | (_) | (_| \__ \
- // \_| |_/\___/|_|\__, | \_| |_/\___/|_|\__, | \_| |_/\___/ \__,_|___/
- // __/ | __/ |
- // |___/ |___/
- //
- // Website: http://www.holymolymods.com
- //*********************************************************************************
- // Coded for Openwarfare Mod by [105]HolyMoly Sept 15/2012
- // V.0.Final
- #include common_scripts\utility;
- #include maps\mp\_utility;
- #include maps\mp\gametypes\_hud_util;
- #include InfectedScript\_utility;
- #include InfectedScript\mp\_playerdvars;
- /*
- Infection
- Teams: Allies = Infected, Axis = Survivors
- Objective: Infected must knife kill all the Survivors to win.
- Map ends: When there are no more Survivors or time limit is reached.
- Respawning: No wait / Near teammates
- Spectating: No Spectating at all.......... Really screws with the code! :(
- Level requirements
- ------------------
- Spawnpoints:
- classname mp_tdm_spawn
- All players spawn from these. The spawnpoint chosen is dependent on the current locations of teammates and enemies
- at the time of spawn. Players generally spawn behind their teammates relative to the direction of 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:
- game["allies"] = "marines";
- game["axis"] = "opfor";
- This sets the nationalities of the teams. Allies can be american, british, or russian. Axis can be german.
- If using minefields or exploders:
- maps\mp\_load::main();
- Optional level script settings
- ------------------------------
- Soldier Type and Variation:
- game["american_soldiertype"] = "normandy";
- game["german_soldiertype"] = "normandy";
- This sets what character models are used for each nationality on a particular map.
- Valid settings:
- american_soldiertype normandy
- british_soldiertype normandy, africa
- russian_soldiertype coats, padded
- german_soldiertype normandy, africa, winterlight, winterdark
- */
- /*QUAKED mp_tdm_spawn (0.0 0.0 1.0) (-16 -16 0) (16 16 72)
- Players spawn away from enemies and near their team at one of these positions.*/
- /*QUAKED mp_tdm_spawn_axis_start (0.5 0.0 1.0) (-16 -16 0) (16 16 72)
- Axis players spawn away from enemies and near their team at one of these positions at the start of a round.*/
- /*QUAKED mp_tdm_spawn_allies_start (0.0 0.5 1.0) (-16 -16 0) (16 16 72)
- Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
- main()
- {
- if(getdvar("mapname") == "mp_background")
- return;
- if ( !isdefined( game["switchedsides"] ) )
- game["switchedsides"] = false;
- // Shut Off Dvars
- setDvar( "scr_forfeit_enable_inf", "0" );
- setDvar( "scr_force_autoassign_inf", "1" );
- setDvar( "scr_force_autoassign_clan_tags_inf", "" );
- setDvar( "scr_clan_vs_all_team_inf", "" );
- setDvar( "scr_health_death_sound_inf", "0" );
- setDvar( "scr_jump_slowdown_enable_inf", "1" );
- setDvar( "scr_cap_enable_inf", "0" );
- setDvar( "scr_deleteexplosivesondeath_inf", "1" );
- setDvar( "scr_teambalance_inf", "0" );
- // Game Dvars.......... Too many :P Ya think!!!!!!
- level.scr_inf_forcestartspawns = getdvarx( "scr_inf_forcestartspawns", "int", 0, 0, 1 );
- level.scr_inf_pick_time = getdvarx( "scr_inf_pick_time", "int", 9, 5, 60 );
- level.scr_inf_ammo_bag_removal_time = getdvarx( "scr_inf_ammo_bag_removal_time", "int", 15, 1, 60 );
- level.scr_inf_allow_ammo_bags = getdvarx( "scr_inf_allow_ammo_bags", "int", 0, 0, 0 );
- level.scr_inf_rand_ammo_bag = getdvarx( "scr_inf_rand_ammo_bag", "int", 0, 0, 0 );
- level.scr_inf_percent_primary_ammo_bag = getdvarx( "scr_inf_percent_primary_ammo_bag", "int", 0, 0, 0 );
- level.scr_inf_nep_message = getdvarx( "scr_inf_nep_message", "string", "" );
- level.scr_inf_min_players = getdvarx( "scr_inf_min_players", "int", 3, 2, 10 );
- level.scr_inf_survival_points = getdvarx( "scr_inf_survival_points", "int", 100, 0, 1000 );
- level.scr_inf_last_survivor_points = getdvarx( "scr_inf_last_survivor_points", "int", 250, 0, 1000 );
- level.scr_inf_allow_last_survivor_enemy_ping = getdvarx( "scr_inf_allow_last_survivor_enemy_ping", "int", 0, 0, 0 );
- level.scr_inf_death_sounds = getdvarx( "scr_inf_death_sounds", "int", 0, 0, 0 );
- level.scr_inf_attack_sounds = getdvarx( "scr_inf_attack_sounds", "int", 0, 0, 0 );
- level.scr_inf_ambient_sounds = getdvarx( "scr_inf_ambient_sounds", "int", 0, 0, 0 );
- level.scr_inf_scream_on_spawn = getdvarx( "scr_inf_scream_on_spawn", "int", 0, 0, 0 );
- level.scr_inf_vision_infected_on = getdvarx( "scr_inf_vision_infected_on", "int", 0, 0, 0 );
- level.scr_inf_ammo_infected = getdvarx( "scr_inf_ammo_infected", "int", 0, 0, 100 );
- level.scr_inf_infected_ammo_amount = getdvarx( "scr_inf_infected_ammo_amount", "int", 0, 0, 100 );
- level.scr_inf_base_speed_infected = getdvarx( "scr_inf_base_speed_infected", "float", 1, 1, 1 );
- level.scr_inf_kill_points_infected = getdvarx( "scr_inf_kill_points_infected", "int", 10, 0, 1000 );
- level.scr_inf_kill_points_infected_last_kill = getdvarx( "scr_inf_kill_points_infected_last_kill", "int", 80, 0, 1000 );
- level.scr_inf_kill_points_last_survivor = getdvarx( "scr_inf_kill_points_last_survivor", "int", 140, 0, 1000 );
- level.scr_inf_use_infected_model = getdvarx( "scr_inf_use_infected_model", "int", 1, 0, 1 );
- level.scr_inf_ammo_bag_messages = getdvarx( "scr_inf_ammo_bag_messages", "int", 0, 0, 0 );
- level.scr_inf_limit_planted_c4s = getdvarx( "scr_inf_limit_planted_c4s", "int", 6, 0, 999 );
- level.scr_inf_limit_planted_claymores = getdvarx( "scr_inf_limit_planted_claymores", "int", 6, 0, 999 );
- level.scr_inf_custom_teams_disable = getdvarx( "scr_inf_custom_teams_disable", "int", 0, 0, 1 );
- level.scr_inf_scavenger_icon = getdvarx( "scr_inf_scavenger_icon", "int", 0, 0, 0 );
- level.scr_inf_infected_burn = getdvarx( "scr_inf_infected_burn", "int", 0, 0, 0 );
- level.scr_inf_infected_burn_sounds = getdvarx( "scr_inf_infected_burn_sounds", "int", 0, 0, 0 );
- level.scr_inf_allow_hardpoint_ammobags = getdvarx( "scr_inf_allow_hardpoint_ammobags", "int", 0, 0, 0 );
- level.scr_inf_last_survivor_weapon_enable = getdvarx( "scr_inf_last_survivor_weapon_enable", "int", 0, 0, 1 );
- level.scr_inf_extra_knife_kill = getdvarx( "scr_inf_extra_knife_kill", "int", 0, 0, 0 );
- level.scr_inf_allow_hardpoints_infected = getdvarx( "scr_inf_allow_hardpoints_infected", "int", 0, 0, 1 );
- level.scr_inf_count_respawns = getdvarx( "scr_inf_count_respawns", "int", 0, 0, 0 );
- level.scr_inf_count_respawns_amount = getdvarx( "scr_inf_count_respawns_amount", "int", 0, 0, 0 );
- level.scr_inf_night_mode = getdvarx( "scr_inf_night_mode", "int", 0, 0, 0 );
- level.scr_inf_night_mode_startDist = getdvarx( "scr_inf_night_mode_startDist", "int", 50, 0, 500 );
- level.scr_inf_night_mode_halfwayDist = getdvarx( "scr_inf_night_mode_halfwayDist", "int", 700, 0, 1000 );
- // Trickery! Must have default setting in gametype :)
- setDvar( "scr_limit_planted_c4s_inf", level.scr_inf_limit_planted_c4s );
- setDvar( "scr_limit_planted_claymores_inf", level.scr_inf_limit_planted_claymores );
- setDvar( "scr_custom_teams_enable_inf", level.scr_inf_custom_teams_disable );
- level.scr_inf_sur_force_weapon = toLower( getdvarx( "scr_inf_sur_force_weapon", "string", "winchester1200_mp;winchester1200_reflex_mp;winchester1200_grip_mp" ) );
- level.scr_inf_sur_force_weapon = strtok( level.scr_inf_sur_force_weapon, ";" );
- level.scr_inf_sur_force_pistol = toLower( getdvarx( "scr_inf_sur_force_pistol", "string", "" ) );
- level.scr_inf_sur_force_pistol = strtok( level.scr_inf_sur_force_pistol, ";" );
- level.scr_inf_sur_weapon_secondary = toLower( getdvarx( "scr_inf_sur_weapon_secondary", "string", "claymore_mp" ) );
- level.scr_inf_sur_weapon_secondary = strtok( level.scr_inf_sur_weapon_secondary, ";" );
- level.scr_inf_sur_specialty_slot0 = getdvarx( "scr_inf_sur_specialty_slot0", "string", "specialty_parabolic" );
- if ( !issubstr( "specialty_null;specialty_parabolic;specialty_bulletdamage", level.scr_inf_sur_specialty_slot0 ) ) {
- level.scr_inf_sur_specialty_slot0 = "specialty_parabolic";
- }
- level.scr_inf_sur_specialty_slot1 = getdvarx( "scr_inf_sur_specialty_slot1", "string", "specialty_fastreload" );
- if ( !issubstr( "specialty_null;specialty_fastreload;specialty_rof;specialty_explosivedamage", level.scr_inf_sur_specialty_slot1 ) ) {
- level.scr_inf_sur_specialty_slot1 = "specialty_fastreload";
- }
- level.scr_inf_sur_specialty_slot2 = getdvarx( "scr_inf_sur_specialty_slot2", "string", "specialty_bulletaccuracy" );
- if ( !issubstr( "specialty_null;specialty_bulletaccuracy;specialty_bulletpenetration", level.scr_inf_sur_specialty_slot2 ) ) {
- level.scr_inf_sur_specialty_slot2 = "specialty_bulletaccuracy";
- }
- level.scr_inf_force_weapon = toLower( getdvarx( "scr_inf_force_weapon", "string", "deserteaglegold_mp" ) );
- level.scr_inf_force_weapon = strtok( level.scr_inf_force_weapon, ";" );
- level.scr_inf_sur_weapon_flash = getdvarx( "scr_inf_sur_weapon_flash", "string", "concussion_grenade_mp" );
- if ( !issubstr( "beretta_mp;concussion_grenade_mp;colt45_mp;usp_mp;deserteagle_mp;deserteaglegold_mp", level.scr_inf_sur_weapon_flash ) ) {
- level.scr_inf_sur_weapon_flash = "concussion_grenade_mp";
- }
- level.scr_inf_force_weapon_secondary = getdvarx( "scr_inf_force_weapon_secondary", "string", "throwingknife_mp" );
- if ( !issubstr( "throwingknife_mp", level.scr_inf_force_weapon_secondary ) ) {
- level.scr_inf_force_weapon_secondary = "throwingknife_mp";
- }
- level.scr_inf_specialty_slot0 = getdvarx( "scr_inf_specialty_slot0", "string", "specialty_fastreload" );
- if ( !issubstr( "specialty_null;specialty_fastreload", level.scr_inf_specialty_slot0 ) ) {
- level.scr_inf_specialty_slot0 = "specialty_fastreload";
- }
- level.scr_inf_specialty_slot1 = getdvarx( "scr_inf_specialty_slot1", "string", "specialty_longersprint" );
- if ( !issubstr( "specialty_null;specialty_longersprint;specialty_specialty_gpsjammer", level.scr_inf_specialty_slot1 ) ) {
- level.scr_inf_specialty_slot1 = "specialty_longersprint";
- }
- level.scr_inf_specialty_slot2 = getdvarx( "scr_inf_specialty_slot2", "string", "specialty_tactical_insertion" );
- if ( !issubstr( "specialty_tactical_insertion;specialty_quieter;specialty_longersprint", level.scr_inf_specialty_slot2 ) ) {
- level.scr_inf_specialty_slot2 = "specialty_tactical_insertion";
- }
- level.scr_inf_last_survivor_weapon = getdvarx( "scr_inf_last_survivor_weapon", "string", "winchester1200_reflex_mp" );
- if ( !issubstr( "saw_mp;winchester1200_reflex_mp;m60e4_mp", level.scr_inf_last_survivor_weapon ) ) {
- level.scr_inf_last_survivor_weapon = "winchester1200_reflex_mp";
- }
- maps\mp\gametypes\_globallogic::init();
- maps\mp\gametypes\_callbacksetup::SetupCallbacks();
- maps\mp\gametypes\_globallogic::SetupCallbacks();
- maps\mp\gametypes\_globallogic::registerNumLivesDvar( level.gameType, 0, 0, 0 );
- maps\mp\gametypes\_globallogic::registerRoundLimitDvar( level.gameType, 1, 1, 1 );
- maps\mp\gametypes\_globallogic::registerRoundSwitchDvar( level.gameType, 0, 0, 0 );
- maps\mp\gametypes\_globallogic::registerScoreLimitDvar( level.gameType, 0, 0, 0 );
- maps\mp\gametypes\_globallogic::registerTimeLimitDvar( level.gameType, 12, 0, 1440 );
- level.teamBased = true;
- level.onStartGameType = ::onStartGameType;
- level.onSpawnPlayer = ::onSpawnPlayer;
- level.onLoadoutGiven = ::onLoadoutGiven;
- level.onPrecacheGametype = ::onPrecacheGametype;
- level.onPlayerKilled = ::onPlayerKilled;
- level.onPlayerDisconnect = ::onPlayerDisconnect;
- level.onTimeLimit = ::onTimeLimit;
- }
- onStartGameType()
- {
- setClientNameMode("auto_change");
- maps\mp\gametypes\_globallogic::setObjectiveText( "allies", &"OW_OBJECTIVES_INF_ALLIES" );
- maps\mp\gametypes\_globallogic::setObjectiveText( "axis", &"OW_OBJECTIVES_INF_AXIS" );
- if ( level.splitscreen )
- {
- maps\mp\gametypes\_globallogic::setObjectiveScoreText( "allies", &"OW_OBJECTIVES_INF_ALLIES" );
- maps\mp\gametypes\_globallogic::setObjectiveScoreText( "axis", &"OW_OBJECTIVES_INF_AXIS" );
- }
- else
- {
- maps\mp\gametypes\_globallogic::setObjectiveScoreText( "allies", &"OW_OBJECTIVES_INF_SCORE_ALLIES" );
- maps\mp\gametypes\_globallogic::setObjectiveScoreText( "axis", &"OW_OBJECTIVES_INF_SCORE_AXIS" );
- }
- maps\mp\gametypes\_globallogic::setObjectiveHintText( "allies", &"OW_OBJECTIVES_INF_HINT_ALLIES" );
- maps\mp\gametypes\_globallogic::setObjectiveHintText( "axis", &"OW_OBJECTIVES_INF_HINT_AXIS" );
- level.spawnMins = ( 0, 0, 0 );
- level.spawnMaxs = ( 0, 0, 0 );
- maps\mp\gametypes\_spawnlogic::placeSpawnPoints( "mp_tdm_spawn_allies_start" );
- maps\mp\gametypes\_spawnlogic::placeSpawnPoints( "mp_tdm_spawn_axis_start" );
- maps\mp\gametypes\_spawnlogic::addSpawnPoints( "allies", "mp_tdm_spawn" );
- maps\mp\gametypes\_spawnlogic::addSpawnPoints( "axis", "mp_tdm_spawn" );
- level.mapCenter = maps\mp\gametypes\_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );
- setMapCenter( level.mapCenter );
- allowed[0] = "war";
- if ( getDvarInt( "scr_oldHardpoints" ) > 0 )
- allowed[1] = "hardpoint";
- level.displayRoundEndText = false;
- maps\mp\gametypes\_gameobjects::main(allowed);
- level thread onPlayerConnecting();
- level thread updateTeamScores();
- level thread serverCheck();
- // Night Mode
- if( level.scr_inf_night_mode == 1 ) thread infectionNightMode();
- }
- onPrecacheGametype()
- {
- // Precache Model and View Hands Infected
- precacheModel( "mp_body_infected_a" );
- // Precache Shaders
- precacheShader( "hud_infection" );
- precacheShader( "hud_survivor" );
- precacheShader( "hud_scavenger" );
- // Precache strings
- precacheString( &"OW_INF_NEW_TIMER" );
- precacheString( &"OW_INF_SURVIVORS_WIN" );
- precacheString( &"OW_INF_INFECTED_WINS" );
- precacheString( &"OW_INF_START_OVER" );
- precacheString( &"OW_INF_PICK_AGAIN" );
- precacheString( &"OW_INF_NOT_ENOUGH_PLAYERS" );
- precacheString( &"OW_INF_INFECTED" );
- precacheString( &"OW_INF_SURVIVORS" );
- }
- onSpawnPlayer()
- {
- if ( isDefined( self.inf_scavengerIcon ) ) self.inf_scavengerIcon destroy();
- if( isDefined( self.firstSpawn ) && self.firstSpawn == true )
- {
- self.firstSpawn = false;
- if( self.pers["team"] == "allies" )
- {
- self.switching_teams = true;
- self.joining_team = "axis";
- self.leaving_team = "allies";
- self.sessionteam = "axis";
- self.pers["team"] = "axis";
- self.team = "axis";
- self notify("joined_team");
- self maps\mp\gametypes\_globallogic::updateObjectiveText();
- self maps\mp\gametypes\_spectating::setSpectatePermissions();
- self notify( "end_respawn" );
- }
- self.isSurvivor = true;
- self.isInfected = false;
- self.isFirstInfected = false;
- self.isLastSurvivor = false;
- self.lastSurvivorRespawns = 0;
- self.getsSurvivorAmmo = true;
- }
- if( self.pers["team"] == "allies" ) {
- self.isSurvivor = false;
- self.isInfected = true;
- }
- // Check which spawn points should be used
- if ( game["switchedsides"] ) {
- spawnTeam = level.otherTeam[ self.pers["team"] ];
- } else {
- spawnTeam = self.pers["team"];
- }
- self.usingObj = undefined;
- if ( level.inGracePeriod || level.scr_inf_forcestartspawns )
- {
- spawnPoints = getentarray("mp_tdm_spawn_" + spawnTeam + "_start", "classname");
- if ( !spawnPoints.size )
- spawnPoints = getentarray("mp_sab_spawn_" + spawnTeam + "_start", "classname");
- if ( !spawnPoints.size )
- {
- spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( spawnTeam );
- spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam( spawnPoints );
- }
- else
- {
- spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random( spawnPoints );
- }
- }
- else
- {
- spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( spawnTeam );
- spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam( spawnPoints );
- }
- self spawn( spawnPoint.origin, spawnPoint.angles );
- // Scavenger Icon
- if ( !isDefined( self.inf_scavengerIcon ) ) {
- self.inf_scavengerIcon = self createIcon( "hud_scavenger", 65, 65 );
- self.inf_scavengerIcon setPoint( "CENTER", "CENTER", 290, 130 );
- self.inf_scavengerIcon.archived = true;
- self.inf_scavengerIcon.hideWhenInMenu = true;
- self.inf_scavengerIcon.sort = -3;
- self.inf_scavengerIcon.alpha = 0;
- }
- self.isBurning = false;
- }
- onPlayerConnecting()
- {
- for ( ;; )
- {
- level waittill( "connected", player );
- player.firstSpawn = true;
- }
- }
- updateTeamScores()
- {
- for(;;)
- {
- // Infected - Allies
- game["teamScores"]["allies"] = getInfectedPlayers();
- setTeamScore( "allies", getInfectedPlayers() );
- // Survivor - Axis
- game["teamScores"]["axis"] = getSurvivorPlayers();
- setTeamScore( "axis", getSurvivorPlayers() );
- wait( 0.05 );
- }
- }
- onPlayerDisconnect()
- {
- howManySurvivors = getSurvivorPlayers();
- howManyInfected = getInfectedPlayers();
- // More than 2 Survivors, so pick Infected
- if ( howManyInfected == 0 && howManySurvivors > 1 ) {
- // Pick Infected Player again
- players = level.players;
- for(i = 0; i < players.size; i++)
- if( isDefined( players[i] ) && players[i].pers["team"] == "axis" )
- players[i] thread maps\mp\gametypes\_hud_message::oldNotifyMessage( &"OW_INF_START_OVER", &"OW_INF_PICK_AGAIN" );
- level thread timer();
- }
- // Only 1 Survivor left, not enough to pick Infected, End game!
- if ( howManyInfected == 0 && howManySurvivors == 1 ) {
- game["teamScores"]["allies"] = 0;
- setTeamScore( "allies", 0 );
- thread maps\mp\gametypes\_finalkillcam::endGameFK( "axis", game["strings"]["score_limit_reached"] );
- level thread maps\mp\gametypes\_globallogic::endGame( "axis", &"OW_INF_SURVIVORS_WIN" );
- }
- // Survivors are scared! End game!
- if ( howManySurvivors == 0 ) {
- game["teamScores"]["axis"] = 0;
- setTeamScore( "axis", 0 );
- thread maps\mp\gametypes\_finalkillcam::endGameFK( "allies", game["strings"]["score_limit_reached"] );
- level thread maps\mp\gametypes\_globallogic::endGame( "allies", &"OW_INF_INFECTED_WINS" );
- }
- }
- onTimeLimit()
- {
- // Check on how many Survivors left
- howManySurvivors = getSurvivorPlayers();
- howManyInfected = getInfectedPlayers();
- // Survivors higher score than Infected, Survivors Win!
- if( howManySurvivors > howManyInfected ) {
- thread maps\mp\gametypes\_finalkillcam::endGameFK( "axis", game["strings"]["time_limit_reached"] );
- thread maps\mp\gametypes\_globallogic::endGame( "axis", &"OW_INF_SURVIVORS_WIN" );
- // Survivors still have 1 player left, Survivors Win!
- } else if( howManySurvivors < howManyInfected ) {
- game["teamScores"]["axis"] = howManyInfected + 1;
- setTeamScore( "axis", howManyInfected + 1 );
- thread maps\mp\gametypes\_finalkillcam::endGameFK( "axis", game["strings"]["time_limit_reached"] );
- thread maps\mp\gametypes\_globallogic::endGame( "axis", &"OW_INF_SURVIVORS_WIN" );
- // Score tied, Survivors alive, give extra point to Survivors to Win!
- } else if( howManySurvivors == howManyInfected ) {
- game["teamScores"]["axis"] = howManyInfected + 1;
- setTeamScore( "axis", howManyInfected + 1 );
- thread maps\mp\gametypes\_finalkillcam::endGameFK( "axis", game["strings"]["time_limit_reached"] );
- thread maps\mp\gametypes\_globallogic::endGame( "axis", &"OW_INF_SURVIVORS_WIN" );
- }
- }
- timer()
- {
- level endon( "game_over" );
- level endon( "timer_over" );
- level endon( "intermission" );
- tickSounds = 5;
- while ( level.inPrematchPeriod )
- wait( 0.05 );
- xWait( 1.0 );
- timerDisplay = [];
- timerDisplay = createServerTimer( "objective", 1.4 );
- timerDisplay setPoint( "TOPRIGHT", "TOPRIGHT", 0, 0 );
- timerDisplay.label = &"OW_INF_NEW_TIMER";
- timerDisplay.alpha = 1;
- timerDisplay.archived = false;
- timerDisplay.hideWhenInMenu = true;
- timeLeft = level.scr_inf_pick_time;
- timerDisplay.color = ( 1, 1 ,1 );
- timerDisplay setTimer( timeLeft );
- while ( timeLeft > 0 ) {
- // Do we need to play a tick sound?
- if ( timeLeft <= tickSounds ) {
- timerDisplay.color = ( 1, 0.5 ,0 );
- for ( p = 0; p < level.players.size; p++ ) {
- player = level.players[p];
- if ( isDefined( player ) ) {
- player playLocalSound( "ui_mp_suitcasebomb_timer" );
- }
- }
- }
- wait( 1.0 );
- timeLeft--;
- }
- // Hide timer
- timerDisplay.alpha = 0;
- level thread pickFirstInfected();
- level notify( "timer_over" );
- }
- pickFirstInfected()
- {
- level endon( "infected_picked" );
- // Build an array with all the players that are alive
- infCandidates = [];
- for ( index = 0; index < level.players.size; index++ )
- {
- wait( 0.05 );
- player = level.players[index];
- if ( isDefined( player ) && isAlive( player ) && player.pers["team"] != "spectator" && player.pers["team"] == "axis" )
- {
- infCandidates[infCandidates.size] = player;
- }
- }
- // Get a random player from the list of candidates
- infPlayer = randomIntRange( 0, infCandidates.size );
- // Infected is picked
- player = infCandidates[infPlayer];
- // Set new player info
- player switchPlayerTeam( level.otherTeam[ player.pers["team"] ], false );
- notifyData = spawnStruct();
- notifyData.titleText = "First Infected";
- notifyData.notifyText = "Kill Survivors to Win";
- notifyData.iconName = "hud_infection";
- notifyData.glowColor = ( 1, 0, 0 ); // Red
- notifyData.sound = "mp_enemy_obj_captured";
- notifyData.duration = 4.0;
- player thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
- player.isSurvivor = false;
- player.isInfected = true;
- player.isFirstInfected = true;
- // Play a sound to tell Infected has been picked
- players = level.players;
- for(i = 0; i < players.size; i++)
- if( players[i].pers["team"] != "spectator" && isAlive( players[i] ) && players[i] != player ) {
- players[i] playLocalSound( "mp_challenge_complete" );
- players[i] thread maps\mp\gametypes\_hud_message::oldNotifyMessage( &"OW_INF_FIRST_INFECTED", player.name );
- }
- level notify( "infected_picked" );
- }
- onLoadoutGiven()
- {
- if( isDefined( self.isSurvivor ) && self.isSurvivor == true )
- {
- if( !level.inPrematchPeriod && level.infReady == true )
- {
- howManySurvivors = getSurvivorPlayers();
- if( howManySurvivors == 1 ) {
- self.isLastSurvivor = true;
- } else {
- self.isLastSurvivor = false;
- self.lastSurvivorRespawns = 0;
- }
- }
- self getSurvivorLoadout();
- }
- if( isDefined( self.isInfected ) && self.isInfected == true ) self getInfectedLoadout();
- }
- getSurvivorLoadout()
- {
- self endon( "disconnect" );
- survivorWeapon = "";
- secondaryWeapon = "";
- pistolWeapon = "";
- // Remove all weapons and perks from the survivor
- self thread maps\mp\gametypes\_gameobjects::_disableWeapon();
- self takeAllWeapons();
- self clearPerks();
- self.isInfected = false;
- self.isSurvivor = true;
- // Give the Survivor fixed specialties
- self.specialty = [];
- self.specialty[0] = level.scr_inf_sur_specialty_slot0;
- if ( self.specialty[0] != "specialty_null" )
- self setPerk( self.specialty[0] );
- self.specialty[1] = level.scr_inf_sur_specialty_slot1;
- if ( self.specialty[1] != "specialty_null" )
- self setPerk( self.specialty[1] );
- self.specialty[2] = level.scr_inf_sur_specialty_slot2;
- if ( self.specialty[2] != "specialty_null" )
- self setPerk( self.specialty[2] );
- // Process Time
- wait( 0.05 );
- // Check if the Survivor has no weapon, then force default
- if ( level.scr_inf_sur_force_weapon != "" ) {
- survivorWeapon = level.scr_inf_sur_force_weapon[ randomIntRange( 0, level.scr_inf_sur_force_weapon.size ) ];
- }
- // Give start ammo for Survivor weapon and switch to it
- self giveWeapon( survivorWeapon );
- if( self.getsSurvivorAmmo == true ) {
- self giveStartAmmo( survivorWeapon );
- } else {
- self setWeaponAmmoClip( survivorWeapon, 0 );
- self setWeaponAmmoStock( survivorWeapon, 0 );
- }
- self setSpawnWeapon( survivorWeapon );
- self switchToWeapon( survivorWeapon );
- // Check if the Survivor has secondary weapon
- if ( level.scr_inf_sur_weapon_secondary != "" ) {
- secondaryWeapon = level.scr_inf_sur_weapon_secondary[ randomIntRange( 0, level.scr_inf_sur_weapon_secondary.size ) ];
- // Give secondary weapon and start ammo
- self giveWeapon( secondaryWeapon );
- if( self.getsSurvivorAmmo == true ) {
- self giveMaxAmmo( secondaryWeapon );
- } else {
- self setWeaponAmmoClip( secondaryWeapon, 1 );
- self setWeaponAmmoStock( secondaryWeapon, 1 );
- }
- self thread giveActionSlot3AfterDelay( secondaryWeapon );
- self setActionSlot( 4, "" );
- }
- // Check if the Survivor has a pistol
- if ( level.scr_inf_sur_force_pistol != "" ) {
- pistolWeapon = level.scr_inf_sur_force_pistol[ randomIntRange( 0, level.scr_inf_sur_force_pistol.size ) ];
- // Give secondary weapon and start ammo
- self giveWeapon( pistolWeapon );
- if( self.getsSurvivorAmmo == true ) {
- self giveMaxAmmo( pistolWeapon );
- } else {
- self setWeaponAmmoClip( pistolWeapon, 0 );
- self setWeaponAmmoStock( pistolWeapon, 0 );
- }
- }
- if( isDefined( self.isLastSurvivor ) && self.isLastSurvivor == true )
- {
- if( level.scr_inf_count_respawns == 1 ) self.lastSurvivorRespawns++;
- if( level.scr_inf_last_survivor_weapon_enable == 1 )
- {
- self takeWeapon( survivorWeapon );
- self giveWeapon( level.scr_inf_last_survivor_weapon );
- if( self.getsSurvivorAmmo == false )
- {
- self setWeaponAmmoClip( level.scr_inf_last_survivor_weapon, 0 );
- self setWeaponAmmoStock( level.scr_inf_last_survivor_weapon, 0 );
- self setSpawnWeapon( level.scr_inf_last_survivor_weapon );
- self switchToWeapon( level.scr_inf_last_survivor_weapon );
- } else {
- self giveStartAmmo( level.scr_inf_last_survivor_weapon );
- self setSpawnWeapon( level.scr_inf_last_survivor_weapon );
- self switchToWeapon( level.scr_inf_last_survivor_weapon );
- }
- }
- // Give player max health
- self.maxhealth = getDvarInt( "scr_player_maxhealth" );
- self.health = getDvarInt( "scr_player_maxhealth" );
- if( level.scr_inf_allow_last_survivor_enemy_ping == 1 ) self setClientDvar( "g_compassshowenemies", "1" );
- notifyData = spawnStruct();
- notifyData.titleText = "Last Survivor!";
- notifyData.notifyText = "Kick Ass, Soldier!";
- notifyData.glowColor = ( 0, 1, 0 ); // Green
- notifyData.iconName = "hud_survivor";
- notifyData.sound = "mp_obj_captured";
- notifyData.duration = 4.0;
- self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
- if( self.lastSurvivorRespawns == 1 ) {
- self givePlayerScore( "challenge", level.scr_inf_last_survivor_points );
- }
- }
- // Enable the Weapons
- self thread maps\mp\gametypes\_gameobjects::_enableWeapon();
- }
- getInfectedLoadout()
- {
- self endon( "disconnect" );
- chanceScream = randomIntRange( 1, 101 );
- chanceAmmo = randomIntRange( 1, 101 );
- chanceBurn = randomIntRange( 1, 101 );
- // Random or Fixed Ammo
- if( level.scr_inf_infected_ammo_amount > 0 ) {
- howMuchAmmo = level.scr_inf_infected_ammo_amount;
- }else {
- howMuchAmmo = randomIntRange( 1, 11 );
- }
- // Scream on spawn
- if( chanceScream <= level.scr_inf_scream_on_spawn ) self playLocalSound( "attack" );
- // Remove all weapons and perks from the survivor
- self thread maps\mp\gametypes\_gameobjects::_disableWeapon();
- self takeAllWeapons();
- self clearPerks();
- // Change to Infected Model
- if( level.scr_inf_use_infected_model == 1 )
- {
- self detachHead();
- self setModel( "mp_body_infected_a" );
- self setViewModel( "viewmodel_jap_infantry_arms" );
- }
- self.isInfected = true;
- self.isSurvivor = false;
- // Remove any hardpoints from the infected player
- if ( isDefined( self.pers["hardPointItem"] ) ) {
- self.pers["hardPointItem"] = undefined;
- self.cur_kill_streak = 0;
- }
- // Give the Infected fixed specialties
- self.specialty = [];
- self.specialty[0] = level.scr_inf_specialty_slot0;
- if ( self.specialty[0] != "specialty_null" )
- self setPerk( self.specialty[0] );
- self.specialty[1] = level.scr_inf_specialty_slot1;
- if ( self.specialty[1] != "specialty_null" )
- self setPerk( self.specialty[1] );
- self.specialty[2] = level.scr_inf_specialty_slot2;
- if ( self.specialty[2] != "specialty_null" )
- self setPerk( self.specialty[2] );
- infectedWeapon = "";
- infthrowingknife = "";
- // Check if the Infected has no weapon, then force default
- if ( level.scr_inf_force_weapon != "" ) {
- infectedWeapon = level.scr_inf_force_weapon[ randomIntRange( 0, level.scr_inf_force_weapon.size ) ];
- }
- // Check if the Infected has secondary weapon
- if ( level.scr_inf_force_weapon_secondary != "" ) {
- infthrowingknife = level.scr_inf_force_weapon_secondary;
- // Give secondary weapon and start ammo
- self giveWeapon( infthrowingknife );
- if( self.getsSurvivorAmmo == false ) {
- self giveMaxAmmo( infthrowingknife );
- } else {
- self setWeaponAmmoClip( infthrowingknife, 1 );
- self setWeaponAmmoStock( infthrowingknife, 1 );
- }
- self thread giveActionSlot3AfterDelay( infthrowingknife );
- self setActionSlot( 4, "" );
- }
- // Give ammo for Infected weapon and switch to it
- self giveWeapon( infectedWeapon );
- if( chanceAmmo <= level.scr_inf_ammo_infected ) {
- self setWeaponAmmoClip( infectedWeapon, 0 );
- self setWeaponAmmoStock( infectedWeapon, howMuchAmmo );
- } else {
- self setWeaponAmmoClip( infectedWeapon, 0 );
- self setWeaponAmmoStock( infectedWeapon, 0 );
- }
- self setSpawnWeapon( infectedWeapon );
- self switchToWeapon( infectedWeapon );
- // Enable the Weapons
- self thread maps\mp\gametypes\_gameobjects::_enableWeapon();
- // Move speed for Infected
- self thread InfectedScript\mp\_speedcontrol::setBaseSpeed( level.scr_inf_base_speed_infected );
- // Burn Infected player
- if( chanceBurn <= level.scr_inf_infected_burn ) {
- self.isBurning = true;
- self thread infectedBurn();
- }
- // Attack Sounds when Melee
- if( level.scr_inf_attack_sounds >= 1 && self.isBurning == false ) self thread watchMeleeButton();
- // Ambient Growl Sounds
- if( level.scr_inf_ambient_sounds == 1 && self.isBurning == false ) self thread ambientSounds();
- // Infected Vision
- if( level.scr_inf_vision_infected_on == 1 ) { // Green
- self setClientDvar( "cg_fovscale", 1.33 );
- self setGlowTweaks( 1, 0.6, 0.5, 8, 8 );
- self setFilmTweaks( 1, 0, 1, "1 1 1 1", "0 2 0 0.001", 0, 1.3 );
- self setDepthOfField( 40, 80, 100, 900, 5, 1.5 ); // ( nearstart, nearend, farstart, farend, nearblur, farblur )
- }
- if( level.scr_inf_vision_infected_on == 2 ) { // Clear
- self setClientDvar( "cg_fovscale", 1.33 );
- self setGlowTweaks( 1, 0.6, 0.5, 8, 8 );
- self setFilmTweaks( 1, 0, 1, "1 1 1 1", "1 1 1 0.001", 0, 1.3 );
- self setDepthOfField( 40, 80, 100, 900, 5, 1.5 ); // ( nearstart, nearend, farstart, farend, nearblur, farblur )
- }
- }
- infectedBurn()
- {
- self endon("disconnect");
- self endon("death");
- if( level.scr_inf_infected_burn_sounds == 1 ) self thread infectedBurnSounds();
- for(;;)
- {
- playFXOnTag( level.fx_infected_burn, self, "back_low" );
- wait( 0.08 );
- }
- }
- infectedBurnSounds()
- {
- self endon("disconnect");
- self endon("death");
- self endon( "joined_spectators" );
- for(;;)
- {
- self playSound( "death" );
- wait( randomFloatRange( 1.5, 3.0 ) );
- }
- }
- setGlowTweaks( on, cutoff, desaturation, intensity, radius )
- {
- self setClientDvars( "r_glowUseTweaks", 1, "r_glow", 1, "r_glowTweakEnable", on, "r_glowTweakBloomCutOff", cutoff, "r_glowTweakBloomDesaturation", desaturation, "r_glowTweakBloomIntensity0", intensity, "r_glowTweakRadius0", radius );
- }
- setFilmTweaks( on, invert, desaturation, darktint, lighttint, brightness, contrast )
- {
- self setClientDvars( "r_filmusetweaks", 1, "r_filmtweaks", 1, "r_filmtweakenable", on, "r_filmtweakinvert", invert, "r_filmtweakdesaturation", desaturation , "r_filmtweakdarktint", darktint, "r_filmtweaklighttint", lighttint, "r_filmtweakbrightness", brightness, "r_filmtweakcontrast", contrast );
- }
- watchMeleeButton()
- {
- self endon( "disconnect" );
- self endon( "death" );
- self endon ( "game_ended" );
- self endon( "joined_spectators" );
- level endon( "intermission" ); // End game
- for (;;)
- {
- self.isAttacking = false;
- chanceAttack = randomIntRange( 1, 101 );
- // Check if Melee button pressed & not Growling
- if ( ( isDefined( self.isGrowling ) && self.isGrowling == false ) && chanceAttack <= level.scr_inf_attack_sounds && self meleeButtonPressed() ) {
- self.isAttacking = true;
- self playSound( "attack" );
- wait( 1.14 ); // Longest attack sound, so sounds do not overlap
- while( self meleeButtonPressed() ) wait( 0.05 );
- }
- wait( 0.05 );
- }
- }
- ambientSounds()
- {
- self endon( "disconnect" );
- self endon( "death" );
- self endon ( "game_ended" );
- self endon( "joined_spectators" );
- for (;;)
- {
- self.isGrowling = false;
- wait( randomIntRange( 15, 31 ) );
- if( isDefined( self.isAttacking ) && self.isAttacking == false ) {
- self.isGrowling = true;
- self playSound( "ambient" );
- wait( 1.99 ); // Longest growling sound
- }
- }
- }
- onPlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration )
- {
- thread maps\mp\gametypes\_finalkillcam::onPlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration);
- if( isDefined( self.isSurvivor ) && self.isSurvivor == true )
- {
- // Switch player to allies
- self switchPlayerTeam( level.otherTeam[ self.pers["team"] ], false );
- // Give attacker extra points for kill
- attacker givePlayerScore( "kill", level.scr_inf_kill_points_infected );
- howManySurvivors = getSurvivorPlayers();
- if( howManySurvivors == 0 ) {
- wait( 0.08 );
- // Give Infected Player Bonus for Last Kill
- attacker givePlayerScore( "kill", level.scr_inf_kill_points_infected_last_kill );
- // End Game
- thread maps\mp\gametypes\_finalkillcam::endGameFK( "allies", game["strings"]["score_limit_reached"] );
- thread maps\mp\gametypes\_globallogic::endGame( "allies", &"OW_INF_INFECTED_WINS" );
- }
- if( !level.gameEnded )
- {
- notifyData = spawnStruct();
- notifyData.titleText = "Infected";
- notifyData.notifyText = "Knife Survivors to Win";
- notifyData.iconName = "hud_infection";
- notifyData.glowColor = ( 1, 0, 0 ); // Red
- notifyData.sound = "mp_enemy_obj_captured";
- notifyData.duration = 4.0;
- self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
- iprintln( "^2" + self.name + " ^7got Infected" );
- // Debug
- // iprintln( "Infected" );
- }
- // Sound and rewards for Surviving a kill
- if( howManySurvivors > 1 ) {
- players = level.players;
- for(i = 0; i < players.size; i++)
- if( isDefined( players[i] ) && players[i].pers["team"] == "axis" ) {
- notifyData = spawnStruct();
- notifyData.titleText = "Survivor!";
- notifyData.notifyText = "Bonus";
- notifyData.glowColor = ( 0, 1, 0 ); // Green
- notifyData.iconName = "hud_survivor";
- notifyData.sound = "mp_enemy_obj_captured";
- notifyData.duration = 4.0;
- players[i] thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
- players[i] givePlayerScore( "challenge", level.scr_inf_survival_points );
- //Debug
- // iprintln( "Survival Bonus" );
- }
- }
- // Last Survivor
- if( howManySurvivors == 1 )
- {
- players = level.players;
- for(i = 0; i < players.size; i++)
- if( isDefined( players[i] ) && players[i].pers["team"] == "axis" ) {
- notifyData = spawnStruct();
- notifyData.titleText = "Last Survivor!";
- notifyData.notifyText = "Kick Ass, Soldier!";
- notifyData.glowColor = ( 0, 1, 0 ); // Green
- notifyData.iconName = "hud_survivor";
- notifyData.sound = "mp_obj_captured";
- notifyData.duration = 4.0;
- players[i] thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
- players[i] givePlayerScore( "challenge", level.scr_inf_last_survivor_points );
- players[i].isLastSurvivor = true;
- if( level.scr_inf_allow_last_survivor_enemy_ping == 1 ) players[i] setClientDvar( "g_compassshowenemies", "1" );
- if( level.scr_inf_last_survivor_weapon_enable == 1 )
- {
- // Remove all weapons from the last survivor
- players[i] thread maps\mp\gametypes\_gameobjects::_disableWeapon();
- players[i] takeAllWeapons();
- lastSurvivorWeapon = "";
- // Check if the Survivor has no weapon, then force default
- if ( level.scr_inf_last_survivor_weapon != "" ) {
- lastSurvivorWeapon = level.scr_inf_last_survivor_weapon;
- }
- // Give max ammo for Survivor weapon and switch to it
- players[i] giveWeapon( lastSurvivorWeapon );
- players[i] giveMaxAmmo( lastSurvivorWeapon );
- players[i] setSpawnWeapon( lastSurvivorWeapon );
- players[i] switchToWeapon( lastSurvivorWeapon );
- // Enable the Weapons
- players[i] thread maps\mp\gametypes\_gameobjects::_enableWeapon();
- // Give player max health
- players[i].maxhealth = getDvarInt( "scr_player_maxhealth" );
- players[i].health = getDvarInt( "scr_player_maxhealth" );
- }
- // Debug
- // iprintln( "Last Survivor" );
- if( level.scr_inf_count_respawns == 1 ) self.lastSurvivorRespawns++;
- }
- }
- }
- if( isDefined( self.isInfected ) && self.isInfected == true )
- {
- chanceDeath = randomIntRange( 1, 101 );
- // Death Sounds
- if( chanceDeath <= level.scr_inf_death_sounds ) self playSound( "death" );
- chanceBags = randomIntRange( 1, 101 );
- if( chanceBags <= level.scr_inf_allow_ammo_bags )
- {
- if( isHardpointWeapon( sWeapon ) && level.scr_inf_allow_hardpoint_ammobags == 0 )
- return;
- // Place spawnpoint on the ground based on player box size
- basePosition = playerPhysicsTrace( self.origin, self.origin + ( 0, 0, -99999 ) );
- // Create pickup trigger and ammo bag
- ammoBagTrigger = spawn( "trigger_radius", basePosition, 0, 15, 10 );
- ammoBag = spawn( "script_model", basePosition );
- ammoBag setmodel( "ap_luggage03" );
- ammoBag.angles = ( 0, randomint( 360 ), 0 );
- ammobag solid();
- // Wait for Survivor to pickup the ammoBag
- ammoBagTrigger thread onBagPickup( ammoBag, ammoBagTrigger );
- // Remove the trigger and ammoBag on time limit
- ammoBagTrigger thread removeAmmoBagTriggerOnTimeout( ammoBag, ammoBagTrigger );
- }
- if( isDefined( attacker.isLastSurvivor ) && attacker.isLastSurvivor )
- {
- // Give extra points to last Survivor on every kill if desired
- if( level.scr_inf_kill_points_last_survivor > 0 )
- attacker givePlayerScore( "kill", level.scr_inf_kill_points_last_survivor );
- }
- if( isDefined( self.isBurning ) && self.isBurning == true )
- {
- phyExpMagnitude = 2.5;
- minDamage = 1;
- maxDamage = 250;
- blastRadius = 190;
- self radiusDamage( self.origin + ( 0, 0, 30 ), blastRadius, maxDamage, minDamage, self, "MOD_PROJECTILE_SPLASH" );
- physicsExplosionSphere( self.origin + ( 0, 0, 30 ), blastRadius, blastRadius/2, phyExpMagnitude );
- self maps\mp\gametypes\_shellshock::barrel_earthQuake();
- //Death FX
- playfx( level.fx_infected_explode, self.origin );
- self playSound( "explo_metal_rand" );
- }
- }
- if( isDefined( self.isLastSurvivor ) && self.isLastSurvivor == true ) {
- // Do not count kills from pistol, rifle, Infected Burn Explosions, and headshots!
- if( sMeansofDeath != "MOD_PISTOL_BULLET" && sMeansofDeath != "MOD_RIFLE_BULLET" && sMeansofDeath != "MOD_HEAD_SHOT" ) {
- if( self.lastSurvivorRespawns >= level.scr_inf_count_respawns_amount ) {
- game["teamScores"]["axis"] = 0;
- setTeamScore( "axis", 0 );
- thread maps\mp\gametypes\_finalkillcam::endGameFK( "allies", game["strings"]["score_limit_reached"] );
- level thread maps\mp\gametypes\_globallogic::endGame( "allies", &"OW_INF_INFECTED_WINS" );
- }
- }
- }
- }
- onBagPickup( ammoBag, ammoBagTrigger )
- {
- while( true )
- {
- ammoBagTrigger waittill( "trigger", player );
- chancePrimary = randomIntRange( 1, 101 );
- if( isAlive( player ) && player.pers["team"] == "axis" )
- {
- if( chancePrimary <= level.scr_inf_percent_primary_ammo_bag ) {
- if( level.scr_inf_rand_ammo_bag == 0 ) {
- if( player hasWeapon( level.scr_inf_last_survivor_weapon ) ) {
- player giveMaxAmmo( level.scr_inf_last_survivor_weapon );
- }
- if( player hasWeapon( level.scr_inf_sur_force_weapon ) ) {
- player giveMaxAmmo( level.scr_inf_sur_force_weapon );
- }
- if( level.scr_inf_ammo_bag_messages == 1 ) player iprintln( "You have ^1MAX ^2Primary Ammo!" );
- } else {
- if( player hasWeapon( level.scr_inf_last_survivor_weapon ) ) {
- player giveRandomAmmoPrimary( level.scr_inf_last_survivor_weapon );
- }
- if( player hasWeapon( level.scr_inf_sur_force_weapon ) ) {
- player giveRandomAmmoPrimary( level.scr_inf_sur_force_weapon );
- }
- }
- } else {
- if( level.scr_inf_rand_ammo_bag == 0 ) {
- if( level.scr_inf_sur_weapon_secondary != "" ) {
- player giveMaxAmmo( level.scr_inf_sur_weapon_secondary );
- if( level.scr_inf_ammo_bag_messages == 1 ) player iprintln( "You have ^1MAX ^3Secondary Ammo!" );
- } else {
- player playLocalSound( "ammo_pickup" );
- if( level.scr_inf_ammo_bag_messages == 1 ) player iprintln( "^1No Ammo^7...Empty Bag!" );
- wait( 0.08 );
- // Delete Trigger and Model
- if( isDefined( ammoBagTrigger ) ) ammoBagTrigger delete();
- if( isDefined( ammoBag ) ) ammoBag delete();
- }
- } else {
- if( level.scr_inf_sur_weapon_secondary != "" ) {
- player giveRandomAmmoSecondary( level.scr_inf_sur_weapon_secondary );
- } else {
- player playLocalSound( "ammo_pickup" );
- if( level.scr_inf_ammo_bag_messages == 1 ) player iprintln( "^1No Ammo^7...Empty Bag!" );
- wait( 0.08 );
- // Delete Trigger and Model
- if( isDefined( ammoBagTrigger ) ) ammoBagTrigger delete();
- if( isDefined( ammoBag ) ) ammoBag delete();
- }
- }
- }
- if( level.scr_inf_scavenger_icon == 1 ) {
- player.inf_scavengerIcon.alpha = 1;
- player.inf_scavengerIcon fadeOverTime( 1.3 );
- player.inf_scavengerIcon.alpha = 0;
- }
- player playLocalSound( "ammo_pickup" );
- wait( 0.08 );
- // Delete Trigger and Model
- if( isDefined( ammoBagTrigger ) ) ammoBagTrigger delete();
- if( isDefined( ammoBag ) ) ammoBag delete();
- }
- wait( 0.08 );
- }
- }
- removeAmmoBagTriggerOnTimeout( ammoBag, ammoBagTrigger )
- {
- wait( level.scr_inf_ammo_bag_removal_time );
- // Delete Trigger and Model
- if( isDefined( ammoBagTrigger ) ) ammoBagTrigger delete();
- if( isDefined( ammoBag ) ) ammoBag delete();
- }
- getInfectedPlayers()
- {
- Infected = 0;
- players = level.players;
- for(i = 0; i < players.size; i++)
- if( isDefined( players[i] ) && players[i].pers["team"] == "allies" )
- {
- Infected++;
- }
- return Infected;
- }
- isHardpointWeapon( sWeapon )
- {
- if ( sWeapon == "artillery_mp" || sWeapon == "cobra_20mm_mp" || sWeapon == "cobra_FFAR_mp" || sWeapon == "hind_FFAR_mp" ) // Add your hardpoints weapons, that kill, here!
- return true;
- return false;
- }
- getSurvivorPlayers()
- {
- Survivors = 0;
- players = level.players;
- for(i = 0; i < players.size; i++)
- if( isDefined( players[i] ) && players[i].pers["team"] == "axis" )
- {
- Survivors++;
- }
- return Survivors;
- }
- detachHead()
- {
- // Get all the attached models from the player
- attachedModels = self getAttachSize();
- // Check which one is the head and detach it
- for ( am=0; am < attachedModels; am++ ) {
- thisModel = self getAttachModelName( am );
- // Check if this one is the head and remove it
- if ( isSubstr( thisModel, "head_mp_" ) ) {
- self detach( thisModel, "" );
- break;
- }
- }
- return;
- }
- givePlayerScore( event, score )
- {
- self maps\mp\gametypes\_rank::giveRankXP( event, score );
- self.pers["score"] += score;
- self maps\mp\gametypes\_persistence::statAdd( "score", ( self.pers["score"] - score ) );
- self.score = self.pers["score"];
- self notify ( "update_playerscore_hud" );
- }
- giveRandomAmmoPrimary( weapon )
- {
- currWeap = weapon;
- currAmmoClip = self getWeaponAmmoClip( currWeap );
- currAmmoStock = self getWeaponAmmoStock( currWeap );
- randAmmo = randomInt( level.scr_inf_rand_ammo_bag );
- maxAmmo = weaponMaxAmmo( currWeap );
- self setWeaponAmmoClip( currWeap, currAmmoClip );
- self setWeaponAmmoStock( currWeap, currAmmoStock + randAmmo ); // Only adds ammo to stockpile, not clip
- curr2AmmoStock = self getWeaponAmmoStock( currWeap );
- if( level.scr_inf_ammo_bag_messages == 1 )
- {
- if( curr2AmmoStock == maxAmmo ) {
- self iprintln( "You have ^1MAX ^2Primary Ammo!" );
- return;
- }
- if( randAmmo == 0 )
- self iprintln( "^1No Ammo^7...Empty Bag!" );
- else
- self iprintln( "You picked up ^1" + randAmmo + " ^2Primary Ammo!" );
- }
- }
- giveRandomAmmoSecondary( weapon )
- {
- currWeap = weapon;
- currAmmoClip = self getWeaponAmmoClip( currWeap );
- clipSize = weaponClipSize( currWeap );
- currAmmoStock = self getWeaponAmmoStock( currWeap );
- randAmmo = randomInt( 3 ); // Rpg's need 3 for max ammo
- maxAmmo = weaponMaxAmmo( currWeap );
- explosiveCount = countActiveExplosives( currWeap, self.pers["team"] );
- claymoreLimit = level.scr_inf_limit_planted_claymores;
- c4Limit = level.scr_inf_limit_planted_c4s;
- // Claymores
- if( currWeap == "claymore_mp" ) {
- if( explosiveCount >= claymoreLimit ) randAmmo = 0; // Don't give anymore if already at limit
- if( currAmmoClip == 0 && randAmmo > 0 ) self giveWeapon( "claymore_mp" );
- self setWeaponAmmoStock( currWeap, randAmmo + currAmmoClip );
- }
- // C4
- if( currWeap == "c4_mp" ) {
- if( explosiveCount >= c4Limit ) randAmmo = 0; // Don't give anymore if already at limit
- self setWeaponAmmoStock( currWeap, randAmmo + currAmmoClip );
- }
- // RPG
- if( currWeap == "rpg_mp" ) {
- self setWeaponAmmoClip( currWeap, currAmmoClip + randAmmo );
- self setWeaponAmmoStock( currWeap, currAmmoStock + ( randAmmo - ( clipSize - currAmmoClip ) ) ); // Old formula works! :)
- }
- curr2AmmoStock = self getWeaponAmmoStock( currWeap );
- if( level.scr_inf_ammo_bag_messages == 1 )
- {
- if( curr2AmmoStock == maxAmmo ) {
- self iprintln( "You have ^1MAX ^3Secondary Ammo!" );
- return;
- }
- if( randAmmo == 0 )
- self iprintln( "^1No Ammo^7...Empty Bag!" );
- else
- self iprintln( "You picked up ^1" + randAmmo + " ^3Secondary Ammo!" );
- }
- }
- infectionNightMode()
- {
- // Wait for match to start
- while ( level.inPrematchPeriod )
- wait( 0.05 );
- setExpFog( level.scr_inf_night_mode_startDist, level.scr_inf_night_mode_halfwayDist, 0, 0, 0, 0 );
- visionSetNaked( "infection_night_mode", 0 );
- }
- countActiveExplosives( currWeap, explosiveTeam )
- {
- // Count placed explosives
- explosiveEntities = getEntArray( currWeap + "_" + explosiveTeam, "targetname");
- return explosiveEntities.size;
- }
- serverCheck()
- {
- level endon("game_ended");
- while ( level.inPrematchPeriod )
- wait ( 0.05 );
- rotatemap = level.scr_rotate_map_time;
- if ( !isDefined( game["readytoplay"] ) )
- game["readytoplay"] = 0;
- if( !isDefined( level.notenough ) ) {
- level.notenough = newHudElem();
- level.notenough.x = 320;
- level.notenough.y = 175;
- level.notenough.alignx = "center";
- level.notenough.aligny = "middle";
- level.notenough.fontScale = 3.4;
- level.notenough.alpha = 0;
- }
- if( !isDefined( level.rotatetime ) ) {
- level.rotatetime = newHudElem();
- level.rotatetime.x = 320;
- level.rotatetime.y = 210;
- level.rotatetime.alignx = "center";
- level.rotatetime.aligny = "middle";
- level.rotatetime.fontScale = 2.4;
- level.rotatetime.alpha = 0;
- }
- for (;;)
- {
- wait( 1.0 );
- // Check if we have enough players
- if ( !enoughPlayers() ) {
- game["readytoplay"]++;
- if( level.scr_inf_nep_message != "" ) {
- level.notenough setText( level.scr_inf_nep_message );
- level.notenough.alpha = 1;
- level.infReady = false;
- }else {
- level.notenough.label = &"OW_INF_NOT_ENOUGH_PLAYERS";
- level.notenough.alpha = 1;
- level.infReady = false;
- }
- players = getentarray( "player", "classname" );
- if ( players.size == 0 ) {
- rotatemap = level.scr_rotate_map_time;
- level.rotatetime.alpha = 0;
- }
- if ( players.size < level.scr_inf_min_players && rotatemap == 1 ) {
- exitLevel( false );
- break;
- }
- if( level.scr_rotate_map_time > 0 ) {
- rotatemap--;
- if( rotatemap > 10 ) {
- level.rotatetime.alpha = 0;
- level.rotatetime setText( "Map rotates in ^3" + rotatemap + " ^7seconds." );
- level.rotatetime.alpha = 1;
- }
- if( rotatemap <= 10 ) {
- level.rotatetime.alpha = 0;
- level.rotatetime setText( "Map rotates in ^1" + rotatemap + " ^7seconds." );
- level.rotatetime.alpha = 1;
- for ( s = 0; s < level.players.size; s++ ) {
- player = level.players[s];
- if ( isDefined( player ) ) {
- player playLocalSound( "ui_mp_suitcasebomb_timer" );
- }
- }
- }
- }
- }else {
- game["readytoplay"] = 0;
- level.notenough.alpha = 0;
- level.rotatetime.alpha = 0;
- level thread timer();
- level.infReady = true;
- break;
- }
- }
- }
- enoughPlayers()
- {
- players[ "allies" ] = 0;
- players[ "axis" ] = 0;
- players[ "spectator" ] = 0;
- enoughPlayers = false;
- for ( index = 0; index < level.players.size; index++ )
- {
- player = level.players[index];
- // Get the players teams
- playerTeam = player.pers[ "team" ];
- players[ playerTeam ]++;
- // Must have the minimum players required to pick Infected
- if ( ( players[ "allies" ] + players[ "axis" ] ) >= level.scr_inf_min_players ) {
- enoughPlayers = true;
- break;
- }
- }
- return ( enoughPlayers );
- }
Add Comment
Please, Sign In to add comment