You are viewing our Forum Archives. To view or take place in current topics click here.
Black Ops Gsc Files
Posted:

Black Ops Gsc FilesPosted:

mikeizzle09
  • Ladder Climber
Status: Offline
Joined: Jul 27, 201014Year Member
Posts: 318
Reputation Power: 16
Status: Offline
Joined: Jul 27, 201014Year Member
Posts: 318
Reputation Power: 16
Black Ops Gsc files



maps/mp/gametypes/_weapons.gsc

#include common_scripts\utility;
#include maps\mp\_utility;
init()
{
precacheItem( "knife_mp" );
precacheItem( "dogs_mp" );
precacheItem( "dog_bite_mp" );
precacheItem( "explosive_bolt_mp" );
PrecacheModel( "weapon_claymore_detect" );
PrecacheModel( "weapon_c4_mp_detect" );
PrecacheModel( "t5_weapon_acoustic_sensor_world_detect" );
PrecacheModel( "t5_weapon_scrambler_world_detect" );
PrecacheModel( "t5_weapon_camera_spike_world_detect" );
PrecacheModel( "t5_weapon_camera_head_world_detect" );
PrecacheModel( "t5_weapon_tactical_insertion_world_detect" );
PrecacheModel( "t5_weapon_camera_head_world" );
precacheItem( "napalmblob_mp" );
precacheItem( "scavenger_item_mp" );
precacheShader( "hud_scavenger_pickup" );
PreCacheShellShock( "default" );
precacheShellShock( "concussion_grenade_mp" );
precacheShellShock( "tabun_gas_mp" );
precacheShellShock( "tabun_gas_nokick_mp" );
thread maps\mp\_flashgrenades::main();
thread maps\mp\_entityheadicons::init();
if ( !isdefined(level.grenadeLauncherDudTime) )
level.grenadeLauncherDudTime = 0;
if ( !isdefined(level.thrownGrenadeDudTime) )
level.thrownGrenadeDudTime = 0;
level thread onPlayerConnect();
maps\mp\gametypes\_weaponobjects::init();
maps\mp\_tabun::init();
maps\mp\_smokegrenade::init();
maps\mp\_heatseekingmissile::init();
maps\mp\_cameraspike::init();
maps\mp\_acousticsensor::init();
maps\mp\_tacticalinsertion::init();
maps\mp\_scrambler::init();
maps\mp\_explosive_bolt::init();
maps\mp\_sticky_grenade::init();
maps\mp\_flamethrower_plight::init();
maps\mp\_tvguidedmissile::init();
maps\mp\_ballistic_knife::init();
maps\mp\_satchel_charge::init();
}
onPlayerConnect()
{
for(;;)
{
level waittill("connecting", player);
player.usedWeapons = false;
player.hits = 0;
player scavenger_hud_create();
player thread onPlayerSpawned();
}
}
onPlayerSpawned()
{
self endon("disconnect");
for(;;)
{
self waittill("spawned_player");
self.concussionEndTime = 0;
self.hasDoneCombat = false;
self thread watchWeaponUsage();
self thread watchGrenadeUsage();
self thread watchMissileUsage();
self thread watchWeaponChange();
self thread watchTurretUse();
self thread trackWeapon();
self.droppedDeathWeapon = undefined;
self.tookWeaponFrom = [];
self thread updateStowedWeapon();
}
}
watchTurretUse()
{
self endon("death");
self endon("disconnect");
while(1)
{
self waittill( "turretownerchange", turret );
self thread watchForTOWFire(turret);
}
}
watchForTOWFire(turret)
{
self endon("death");
self endon("disconnect");
self endon("turretownerchange");
while(1)
{
self waittill( "turret_tow_fire" );
self thread watchMissleUnlink( turret );
self waittill( "turret_tow_unlink" );
}
}
watchMissleUnlink( turret )
{
self endon("death");
self endon("disconnect");
self endon("turretownerchange");
self waittill( "turret_tow_unlink" );
self relinkToTurret( turret );
}
watchWeaponChange()
{
self endon("death");
self endon("disconnect");
self.lastDroppableWeapon = self GetCurrentWeapon();
self.hitsThisMag = [];
weapon = self getCurrentWeapon();
if ( isPrimaryWeapon( weapon ) && !isDefined( self.hitsThisMag[ weapon ] ) )
self.hitsThisMag[ weapon ] = weaponClipSize( weapon );
while(1)
{
previous_weapon = self GetCurrentWeapon();
self waittill( "weapon_change", newWeapon );
if ( mayDropWeapon( newWeapon ) )
{
self.lastDroppableWeapon = newWeapon;
}
if ( newWeapon != "none" )
{
if ( ( isPrimaryWeapon( newWeapon ) || issidearm( newWeapon ) ) && !isDefined( self.hitsThisMag[ newWeapon ] ) )
self.hitsThisMag[ newWeapon ] = weaponClipSize( newWeapon );
}
}
}
updateLastHeldWeaponTimings( newTime )
{
if ( isDefined( self.currentWeapon ) && isDefined( self.currentWeaponStartTime ) )
{
totalTime = int ( ( newTime - self.currentWeaponStartTime ) / 1000 );
if ( totalTime > 0 )
{
self maps\mp\gametypes\_globallogic_score::setWeaponStat( self.currentWeapon, totalTime, "timeUsed" );
self.currentWeaponStartTime = newTime;
}
}
}
updateWeaponTimings( newTime )
{
if ( self is_bot() )
{
return;
}
updateLastHeldWeaponTimings( newTime );
if ( !isDefined( self.staticWeaponsStartTime ) )
{
return;
}
totalTime = int ( ( newTime - self.staticWeaponsStartTime ) / 1000 );
if ( totalTime < 0 )
{
return;
}
self.staticWeaponsStartTime = newTime;
if( isDefined( self.weapon_array_grenade ) )
{
for( i=0; i<self.weapon_array_grenade.size; i++ )
{
currItem = self.weapon_array_grenade[i];
if( issubstr( currItem, "_mp" ) )
currItem = getsubstr( currItem, 0, currItem.size-3 );
self maps\mp\gametypes\_globallogic_score::incItemStatByReference( currItem, totalTime, "timeUsed" );
}
}
if( isDefined( self.weapon_array_inventory ) )
{
for( i=0; i<self.weapon_array_inventory.size; i++ )
{
currItem = self.weapon_array_inventory[i];
if( issubstr( currItem, "_mp" ) )
currItem = getsubstr( currItem, 0, currItem.size-3 );
self maps\mp\gametypes\_globallogic_score::incItemStatByReference( currItem, totalTime, "timeUsed" );
}
}
if( isDefined( self.killstreak ) )
{
for( i=0; i<self.killstreak.size; i++ )
{
self maps\mp\gametypes\_globallogic_score::incItemStatByReference( self.killstreak[i], totalTime, "timeUsed" );
}
}
if ( GetDvarInt( #"scr_game_perks" ) && level.rankedmatch )
{
perksIndexArray = [];
specialtys = self.specialty;
if ( !isDefined( specialtys ) )
{
return;
}
if ( isStrStart( self.class, "CLASS_CUSTOM" ) )
{
if ( isdefined( self.class_num ) )
{
perk1 = maps\mp\gametypes\_class::getLoadoutItemFromDDLStats ( self.class_num, "specialty1" );
if ( isdefined( perk1 ) )
{
perksIndexArray[ perk1 ] = true;
}
perk2 = maps\mp\gametypes\_class::getLoadoutItemFromDDLStats ( self.class_num, "specialty2" );
if ( isdefined( perk2 ) )
{
perksIndexArray[ perk2 ] = true;
}
perk3 = maps\mp\gametypes\_class::getLoadoutItemFromDDLStats ( self.class_num, "specialty3" );
if ( isdefined( perk3 ) )
{
perksIndexArray[ perk3 ] = true;
}
}
}
else
{
for ( i = 0; i < specialtys.size; i++ )
{
specialty = specialtys[i];
if ( !isDefined( specialty ) )
continue;
if ( specialty == "specialty_null" || specialty == "weapon_null" )
continue;
if ( isdefined( level.specialtyToPerkIndex[ specialtys[ i ] ] ) )
{
basePerkIndex = level.specialtyToPerkIndex[ specialtys[ i ] ];
if ( isdefined( basePerkIndex ) )
{
perksIndexArray[ basePerkIndex ] = true;
}
}
}
}
perkIndexArrayKeys = getarraykeys( perksIndexArray );
for ( i = 0; i < perkIndexArrayKeys.size; i ++ )
{
if ( perksIndexArray[ perkIndexArrayKeys[i] ] == true )
self maps\mp\gametypes\_globallogic_score::incItemStatByIndex( perkIndexArrayKeys[i], totalTime, "timeUsed" );
}
}
}
trackWeapon()
{
currentWeapon = self getCurrentWeapon();
currentTime = getTime();
spawnid = getplayerspawnid( self );
while(1)
{
event = self waittill_any_return( "weapon_change", "death", "disconnect" );
newTime = getTime();
bbPrint( "mpweapons: spawnid %d name %s duration %d", spawnid, currentWeapon, newTime - currentTime );
if( event == "weapon_change" )
{
newWeapon = self getCurrentWeapon();
if( newWeapon != "none" && newWeapon != currentWeapon )
{
updateLastHeldWeaponTimings( newTime );
self maps\mp\gametypes\_class::initWeaponAttachments( newWeapon );
currentWeapon = newWeapon;
currentTime = newTime;
}
}
else
{
if( event != "disconnect" )
{
updateWeaponTimings( newTime );
}
return;
}
}
}
isPistol( weapon )
{
return isdefined( level.side_arm_array[ weapon ] );
}
isHackWeapon( weapon )
{
if ( maps\mp\gametypes\_hardpoints::isKillstreakWeapon( weapon ) )
return true;
if ( weapon == "briefcase_bomb_mp" )
return true;
return false;
}
mayDropWeapon( weapon )
{
if ( GetDvarInt( #"scr_disable_weapondrop" ) == 1 )
return false;
if ( weapon == "none" )
return false;
if ( isHackWeapon( weapon ) )
return false;
invType = WeaponInventoryType( weapon );
if ( invType != "primary" )
return false;
if ( weapon == "none" )
return false;
return true;
}
dropWeaponForDeath( attacker )
{
if ( GetDvarInt( #"scr_disable_weapondrop" ) == 1 )
return;
weapon = self.lastDroppableWeapon;
if ( isdefined( self.droppedDeathWeapon ) )
return;
if ( !isdefined( weapon ) )
{
return;
}
if ( weapon == "none" )
{
return;
}
if ( !self hasWeapon( weapon ) )
{
return;
}
if ( !(self AnyAmmoForWeaponModes( weapon )) )
{
return;
}
if ( !shouldDropLimitedWeapon( weapon, self ) )
{
return;
}
clipAmmo = self GetWeaponAmmoClip( weapon );
stockAmmo = self GetWeaponAmmoStock( weapon );
clip_and_stock_ammo = clipAmmo + stockAmmo;
if( !clip_and_stock_ammo )
{
return;
}
stockMax = WeaponMaxAmmo( weapon );
if ( stockAmmo > stockMax )
stockAmmo = stockMax;
item = self dropItem( weapon );
dropLimitedWeapon( weapon, self, item );
self.droppedDeathWeapon = true;
item ItemWeaponSetAmmo( clipAmmo, stockAmmo );
item.owner = self;
item.ownersattacker = attacker;
item thread watchPickup();
item thread deletePickupAfterAWhile();
}
dropWeaponToGround( weapon )
{
if ( !isdefined( weapon ) )
{
return;
}
if ( weapon == "none" )
{
return;
}
if ( !self hasWeapon( weapon ) )
{
return;
}
if ( !(self AnyAmmoForWeaponModes( weapon )) )
{
switch( weapon )
{
case "minigun_mp":
case "m202_flash_mp":
case "m220_tow_mp":
case "mp40_blinged_mp":
self TakeWeapon( weapon );
break;
default:
break;
}
return;
}
if ( !shouldDropLimitedWeapon( weapon, self ) )
{
return;
}
clipAmmo = self GetWeaponAmmoClip( weapon );
stockAmmo = self GetWeaponAmmoStock( weapon );
clip_and_stock_ammo = clipAmmo + stockAmmo;
if( !clip_and_stock_ammo )
{
return;
}
stockMax = WeaponMaxAmmo( weapon );
if ( stockAmmo > stockMax )
stockAmmo = stockMax;
item = self dropItem( weapon );
dropLimitedWeapon( weapon, self, item );
item ItemWeaponSetAmmo( clipAmmo, stockAmmo );
item.owner = self;
item thread watchPickup();
item thread deletePickupAfterAWhile();
}
deletePickupAfterAWhile()
{
self endon("death");
wait 60;
if ( !isDefined( self ) )
return;
self delete();
}
getItemWeaponName()
{
classname = self.classname;
assert( getsubstr( classname, 0, 7 ) == "weapon_" );
weapname = getsubstr( classname, 7 );
return weapname;
}
watchPickup()
{
self endon("death");
weapname = self getItemWeaponName();
while(1)
{
self waittill( "trigger", player, droppedItem );
if ( isdefined( droppedItem ) )
break;
}
assert( isdefined( player.tookWeaponFrom ) );
droppedWeaponName = droppedItem getItemWeaponName();
if ( isdefined( player.tookWeaponFrom[ droppedWeaponName ] ) )
{
droppedItem.owner = player.tookWeaponFrom[ droppedWeaponName ];
droppedItem.ownersattacker = player;
player.tookWeaponFrom[ droppedWeaponName ] = undefined;
}
droppedItem thread watchPickup();
if ( isdefined( self.ownersattacker ) && self.ownersattacker == player )
{
player.tookWeaponFrom[ weapname ] = self.owner;
}
else
{
player.tookWeaponFrom[ weapname ] = undefined;
}
}
itemRemoveAmmoFromAltModes()
{
origweapname = self getItemWeaponName();
curweapname = weaponAltWeaponName( origweapname );
altindex = 1;
while ( curweapname != "none" && curweapname != origweapname )
{
self itemWeaponSetAmmo( 0, 0, altindex );
curweapname = weaponAltWeaponName( curweapname );
altindex++;
}
}
dropOffhand()
{
grenadeTypes = [];
for ( index = 0; index < grenadeTypes.size; index++ )
{
if ( !self hasWeapon( grenadeTypes[index] ) )
continue;
count = self getAmmoCount( grenadeTypes[index] );
if ( !count )
continue;
self dropItem( grenadeTypes[index] );
}
}
setWeaponStat( name, incValue, statName )
{
self maps\mp\gametypes\_globallogic_score::setWeaponStat( name, incValue, statName );
}
watchWeaponUsage()
{
self endon( "death" );
self endon( "disconnect" );
level endon ( "game_ended" );
self.usedKillstreakWeapon = [];
self.usedKillstreakWeapon["minigun_mp"] = false;
self.usedKillstreakWeapon["m202_flash_mp"] = false;
self.usedKillstreakWeapon["m220_tow_mp"] = false;
self.usedKillstreakWeapon["mp40_blinged_mp"] = false;
self.killstreakType = [];
self.killstreakType["minigun_mp"] = "minigun_mp";
self.killstreakType["m202_flash_mp"] = "m202_flash_mp";
self.killstreakType["m220_tow_mp"] = "m220_tow_mp";
self.killstreakType["mp40_blinged_mp"] = "mp40_blinged_drop_mp";
for ( ;; )
{
self waittill ( "weapon_fired", curWeapon );
self.hasDoneCombat = true;
if ( maps\mp\gametypes\_weapons::isPrimaryWeapon( curWeapon ) || maps\mp\gametypes\_weapons::isSideArm( curWeapon ) )
{
if ( isDefined( self.hitsThisMag[ curWeapon ] ) )
self thread updateMagShots( curWeapon );
}
switch ( weaponClass( curWeapon ) )
{
case "rifle":
if( curWeapon == "crossbow_explosive_mp" )
{
self setWeaponStat( curWeapon, 1, "shots" );
self thread beginGrenadeTracking();
break;
}
case "pistol":
case "mg":
case "smg":
case "spread":
self trackWeaponFire( curWeapon );
break;
case "rocketlauncher":
case "grenade":
self setWeaponStat( curWeapon, 1, "shots" );
self thread maps\mp\gametypes\_shellshock::rocket_earthQuake();
break;
default:
break;
}
switch( curWeapon )
{
case "bazooka_mp":
self setWeaponStat( curWeapon, 1, "shots" );
break;
case "minigun_mp":
case "m202_flash_mp":
case "m220_tow_mp":
case "mp40_blinged_mp":
self.usedKillstreakWeapon[ curWeapon ] = true;
break;
default:
break;
}
}
}
updateMagShots( weaponName )
{
self endon ( "death" );
self endon ( "disconnect" );
self endon ( "updateMagShots_" + weaponName );
self.hitsThisMag[ weaponName ]--;
wait ( 0.05 );
self.hitsThisMag[ weaponName ] = weaponClipSize( weaponName );
}
checkHitsThisMag( weaponName )
{
self endon ( "death" );
self endon ( "disconnect" );
self notify ( "updateMagShots_" + weaponName );
waittillframeend;
if ( self.hitsThisMag[ weaponName ] == 0 )
{
weaponClass = maps\mp\gametypes\_missions::getWeaponClass( weaponName );
maps\mp\_challenges::fullClipNoMisses( weaponClass, weaponName );
self.hitsThisMag[ weaponName ] = weaponClipSize( weaponName );
}
}
trackWeaponFire( curWeapon )
{
shotsFired = 1;
if ( isDefined( self.lastStandParams ) && self.lastStandParams.lastStandStartTime == getTime() )
{
self.hits = 0;
return;
}
pixbeginevent("trackWeaponFire");
self setWeaponStat( curWeapon, shotsFired, "shots" );
self setWeaponStat( curWeapon, self.hits, "hits");
statTotal = self maps\mp\gametypes\_persistence::statGet( "total_shots" ) + shotsFired;
statHits = self maps\mp\gametypes\_persistence::statGet( "hits" ) + self.hits;
statMisses = self maps\mp\gametypes\_persistence::statGet( "misses" ) + shotsFired - self.hits;
self maps\mp\gametypes\_persistence::statSet( "total_shots", statTotal, false );
self maps\mp\gametypes\_persistence::statSet( "hits", statHits, false );
self maps\mp\gametypes\_persistence::statSet( "misses", int(max( 0, statMisses )), false );
self maps\mp\gametypes\_persistence::statSet( "accuracy", int(statHits * 10000 / statTotal), false );
self.hits = 0;
pixendevent();
}
checkHit( sWeapon )
{
switch ( weaponClass( sWeapon ) )
{
case "rifle":
case "pistol":
case "mg":
case "smg":
self.hits++;
break;
case "spread":
self.hits = 1;
break;
default:
break;
}
waittillframeend;
if ( isDefined( self.hitsThisMag[ sWeapon ] ) )
self thread checkHitsThisMag( sWeapon );
if ( ( sWeapon == "bazooka_mp" ) || isStrStart( sWeapon, "t34" ) || isStrStart( sWeapon, "panzer" ) )
{
self setWeaponStat( sWeapon, 1, "hits" );
}
}
watchGrenadeUsage()
{
self endon( "death" );
self endon( "disconnect" );
self.throwingGrenade = false;
self.gotPullbackNotify = false;
self thread beginOtherGrenadeTracking();
self thread watchForThrowbacks();
self thread watchForGrenadeDuds();
self thread watchForGrenadeLauncherDuds();
for ( ;; )
{
self waittill ( "grenade_pullback", weaponName );
self setWeaponStat( weaponName, 1, "shots" );
self.hasDoneCombat = true;
self.throwingGrenade = true;
self.gotPullbackNotify = true;
if ( weaponName == "satchel_charge_mp" )
{
self thread beginSatchelTracking();
}
self thread beginGrenadeTracking();
}
}
watchMissileUsage()
{
self endon( "death" );
self endon( "disconnect" );
level endon ( "game_ended" );
for ( ;; )
{
self waittill ( "missile_fire", missile, weapon_name );
self.hasDoneCombat = true;
}
}
dropWeaponsToGround( origin, radius )
{
weapons = GetDroppedWeapons();
for ( i = 0 ; i < weapons.size ; i++ )
{
if ( DistanceSquared( origin, weapons[i].origin ) < radius * radius )
{
trace = bullettrace( weapons[i].origin, weapons[i].origin + (0,0,-2000), false, weapons[i] );
weapons[i].origin = trace["position"];
}
}
}
dropGrenadesToGround( origin, radius )
{
grenades = getentarray( "grenade", "classname" );
for( i = 0 ; i < grenades.size ; i++ )
{
if( DistanceSquared( origin, grenades[i].origin )< radius * radius )
{
grenades[i] launch( (5,5,5) );
}
}
}
watchGrenadeCancel()
{
self endon ( "death" );
self endon ( "disconnect" );
self endon ( "grenade_fire" );
self waittill( "weapon_change" );
self.throwingGrenade = false;
self.gotPullbackNotify = false;
}
beginGrenadeTracking()
{
self endon ( "death" );
self endon ( "disconnect" );
startTime = getTime();
self thread watchGrenadeCancel();
self waittill ( "grenade_fire", grenade, weaponName );
if ( grenade maps\mp\gametypes\_weaponobjects::isHacked() )
{
return;
}
if ( (getTime() - startTime > 1000) )
grenade.isCooked = true;
switch( weaponName )
{
case "frag_grenade_mp":
case "sticky_grenade_mp":
self maps\mp\gametypes\_globallogic_score::setWeaponStat( weaponName, 1, "used" );
case "explosive_bolt_mp":
grenade thread maps\mp\gametypes\_shellshock::grenade_earthQuake();
grenade.originalOwner = self;
break;
case "satchel_charge_mp":
grenade thread maps\mp\gametypes\_shellshock::satchel_earthQuake();
break;
case "c4_mp":
grenade thread maps\mp\gametypes\_shellshock::c4_earthQuake();
break;
}
if ( weaponName == "sticky_grenade_mp" || weaponName == "frag_grenade_mp" )
{
grenade SetTeam( self.pers["team"] );
grenade SetOwner( self );
}
self.throwingGrenade = false;
}
beginOtherGrenadeTracking()
{
self notify( "grenadeTrackingStart" );
self endon( "grenadeTrackingStart" );
self endon( "disconnect" );
for (;;)
{
self waittill ( "grenade_fire", grenade, weaponName, parent );
if ( grenade maps\mp\gametypes\_weaponobjects::isHacked() )
{
continue;
}
switch( weaponName )
{
case "flash_grenade_mp":
break;
case "concussion_grenade_mp":
break;
case "willy_pete_mp":
grenade thread maps\mp\_smokegrenade::watchSmokeGrenadeDetonation( self );
break;
case "tabun_gas_mp":
grenade thread maps\mp\_tabun::watchTabunGrenadeDetonation( self );
break;
case "signal_flare_mp":
grenade thread maps\mp\_flare::watchFlareDetonation( self );
break;
case "sticky_grenade_mp":
case "satchel_charge_mp":
case "c4_mp":
grenade thread checkStuckToPlayer();
break;
case "tactical_insertion_mp":
grenade thread maps\mp\_tacticalinsertion::watch( self );
break;
case "scrambler_mp":
break;
case "explosive_bolt_mp":
grenade thread maps\mp\_explosive_bolt::watch_bolt_detonation( self );
grenade thread checkStuckToPlayer();
break;
case "hatchet_mp":
grenade thread checkHatchetBounce();
grenade thread checkStuckToPlayer( false );
self maps\mp\gametypes\_globallogic_score::setWeaponStat( weaponName, 1, "used" );
break;
}
}
}
checkStuckToPlayer( deleteOnTeamChange )
{
self endon( "death" );
self waittill( "stuck_to_player", player );
if ( isdefined ( player ) )
{
if ( !IsDefined( deleteOnTeamChange ) || deleteOnTeamChange )
self thread stuckToPlayerTeamChange( player );
self.stuckToPlayer = player;
}
}
checkHatchetBounce()
{
self endon( "stuck_to_player" );
self endon( "death");
self waittill( "grenade_bounce" );
self.bounced = true;
}
stuckToPlayerTeamChange( player )
{
self endon("death");
player endon("disconnect");
originalTeam = player.pers["team"];
while(1)
{
player waittill("joined_team");
if ( player.pers["team"] != originalTeam )
{
self detonate();
return;
}
}
}
beginSatchelTracking()
{
self endon ( "death" );
self endon ( "disconnect" );
self waittill_any ( "grenade_fire", "weapon_change" );
self.throwingGrenade = false;
}
watchForThrowbacks()
{
self endon ( "death" );
self endon ( "disconnect" );
for ( ;; )
{
self waittill ( "grenade_fire", grenade, weapname );
if ( self.gotPullbackNotify )
{
self.gotPullbackNotify = false;
continue;
}
if ( !isSubStr( weapname, "frag_" ) )
continue;
grenade.threwBack = true;
grenade thread maps\mp\gametypes\_shellshock::grenade_earthQuake();
grenade.originalOwner = self;
}
}
registerGrenadeLauncherDudDvar( dvarString, defaultValue, minValue, maxValue )
{
dvarString = ("scr_" + dvarString + "_grenadeLauncherDudTime");
if ( getDvar( dvarString ) == "" )
setDvar( dvarString, defaultValue );
if ( getDvarInt( dvarString ) > maxValue )
setDvar( dvarString, maxValue );
else if ( getDvarInt( dvarString ) < minValue )
setDvar( dvarString, minValue );
level.grenadeLauncherDudTimeDvar = dvarString;
level.grenadeLauncherDudTimeMin = minValue;
level.grenadeLauncherDudTimeMax = maxValue;
level.grenadeLauncherDudTime = getDvarInt( level.grenadeLauncherDudTimeDvar );
}
registerThrownGrenadeDudDvar( dvarString, defaultValue, minValue, maxValue )
{
dvarString = ("scr_" + dvarString + "_thrownGrenadeDudTime");
if ( getDvar( dvarString ) == "" )
setDvar( dvarString, defaultValue );
if ( getDvarInt( dvarString ) > maxValue )
setDvar( dvarString, maxValue );
else if ( getDvarInt( dvarString ) < minValue )
setDvar( dvarString, minValue );
level.thrownGrenadeDudTimeDvar = dvarString;
level.thrownGrenadeDudTimeMin = minValue;
level.thrownGrenadeDudTimeMax = maxValue;
level.thrownGrenadeDudTime = getDvarInt( level.thrownGrenadeDudTimeDvar );
}
registerKillstreakDelay( dvarString, defaultValue, minValue, maxValue )
{
dvarString = ("scr_" + dvarString + "_killstreakDelayTime");
if ( getDvar( dvarString ) == "" )
setDvar( dvarString, defaultValue );
if ( getDvarInt( dvarString ) > maxValue )
setDvar( dvarString, maxValue );
else if ( getDvarInt( dvarString ) < minValue )
setDvar( dvarString, minValue );
level.killstreakRoundDelay = getDvarInt( dvarString );
}
turnGrenadeIntoADud( weapname, isThrownGrenade, player )
{
if ( level.grenadeLauncherDudTime >= (maps\mp\gametypes\_globallogic_utils::getTimePassed() / 1000) && !isThrownGrenade )
{
if ( isSubStr( weapname, "gl_" ) )
{
timeLeft = Int( level.grenadeLauncherDudTime - (maps\mp\gametypes\_globallogic_utils::getTimePassed() / 1000) );
if( !timeLeft )
timeLeft = 1;
player iPrintLnBold( &"MP_LAUNCHER_UNAVAILABLE_FOR_N", " " + timeLeft + " ", &"EXE_SECONDS" );
self makeGrenadeDud();
}
}
else if( level.thrownGrenadeDudTime >= (maps\mp\gametypes\_globallogic_utils::getTimePassed() / 1000) && isThrownGrenade )
{
if( weapname == "frag_grenade_mp" || weapname == "sticky_grenade_mp" )
{
if( isDefined(player.suicide) && player.suicide )
return;
timeLeft = Int( level.thrownGrenadeDudTime - (maps\mp\gametypes\_globallogic_utils::getTimePassed() / 1000) );
if( !timeLeft )
timeLeft = 1;
player iPrintLnBold( &"MP_GRENADE_UNAVAILABLE_FOR_N", " " + timeLeft + " ", &"EXE_SECONDS" );
self makeGrenadeDud();
}
}
}
watchForGrenadeDuds()
{
self endon( "spawned_player" );
self endon( "disconnect" );
while(1)
{
self waittill( "grenade_fire", grenade, weapname );
grenade turnGrenadeIntoADud(weapname, true, self);
}
}
watchForGrenadeLauncherDuds()
{
self endon( "spawned_player" );
self endon( "disconnect" );
while(1)
{
self waittill( "grenade_launcher_fire", grenade, weapname );
grenade turnGrenadeIntoADud(weapname, false, self);
}
}
getDamageableEnts(pos, radius, doLOS, startRadius)
{
ents = [];
if (!isdefined(doLOS))
doLOS = false;
if ( !isdefined( startRadius ) )
startRadius = 0;
players = level.players;
for (i = 0; i < players.size; i++)
{
if (!isalive(players[i]) || players[i].sessionstate != "playing")
continue;
playerpos = players[i].origin + (0,0,32);
dist = distance(pos, playerpos);
if (dist < radius && (!doLOS || weaponDamageTracePassed(pos, playerpos, startRadius, undefined)))
{
newent = spawnstruct();
newent.isPlayer = true;
newent.isADestructable = false;
newent.isADestructible = false;
newent.isActor = false;
newent.entity = players[i];
newent.damageCenter = playerpos;
ents[ents.size] = newent;
}
}
grenades = getentarray("grenade", "classname");
for (i = 0; i < grenades.size; i++)
{
entpos = grenades[i].origin;
dist = distance(pos, entpos);
if (dist < radius && (!doLOS || weaponDamageTracePassed(pos, entpos, startRadius, grenades[i])))
{
newent = spawnstruct();
newent.isPlayer = false;
newent.isADestructable = false;
newent.isADestructible = false;
newent.isActor = false;
newent.entity = grenades[i];
newent.damageCenter = entpos;
ents[ents.size] = newent;
}
}
destructibles = getentarray("destructible", "targetname");
for (i = 0; i < destructibles.size; i++)
{
entpos = destructibles[i].origin;
dist = distance(pos, entpos);
if (dist < radius && (!doLOS || weaponDamageTracePassed(pos, entpos, startRadius, destructibles[i])))
{
newent = spawnstruct();
newent.isPlayer = false;
newent.isADestructable = false;
newent.isADestructible = true;
newent.isActor = false;
newent.entity = destructibles[i];
newent.damageCenter = entpos;
ents[ents.size] = newent;
}
}
destructables = getentarray("destructable", "targetname");
for (i = 0; i < destructables.size; i++)
{
entpos = destructables[i].origin;
dist = distance(pos, entpos);
if (dist < radius && (!doLOS || weaponDamageTracePassed(pos, entpos, startRadius, destructables[i])))
{
newent = spawnstruct();
newent.isPlayer = false;
newent.isADestructable = true;
newent.isADestructible = false;
newent.isActor = false;
newent.entity = destructables[i];
newent.damageCenter = entpos;
ents[ents.size] = newent;
}
}
if ( isdefined( level.dogs ) && level.dogs.size > 0 )
{
for (i = 0; i < level.dogs.size; i++)
{
if ( !isalive( level.dogs[i] ) )
continue;
entpos = level.dogs[i].origin;
dist = distance(pos, entpos);
if (dist < radius && (!doLOS || weaponDamageTracePassed(pos, entpos, startRadius, level.dogs[i])))
{
newent = spawnstruct();
newent.isPlayer = false;
newent.isADestructable = false;
newent.isADestructible = false;
newent.isActor = true;
newent.entity = level.dogs[i];
newent.damageCenter = entpos;
ents[ents.size] = newent;
}
}
}
return ents;
}
weaponDamageTracePassed(from, to, startRadius, ignore)
{
midpos = undefined;
diff = to - from;
if ( lengthsquared( diff ) < startRadius*startRadius )
midpos = to;
dir = vectornormalize( diff );
midpos = from + (dir[0]*startRadius, dir[1]*startRadius, dir[2]*startRadius);
trace = bullettrace(midpos, to, false, ignore);
if ( GetDvarInt( #"scr_damage_debug") != 0 )
{
if (trace["fraction"] == 1)
{
thread debugline(midpos, to, (1,1,1));
}
else
{
thread debugline(midpos, trace["position"], (1,.9,.8));
thread debugline(trace["position"], to, (1,.4,.3));
}
}
return (trace["fraction"] == 1);
}
damageEnt(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, damagepos, damagedir)
{
if (self.isPlayer)
{
self.damageOrigin = damagepos;
self.entity thread [[level.callbackPlayerDamage]](
eInflictor,
eAttacker,
iDamage,
0,
sMeansOfDeath,
sWeapon,
damagepos,
damagedir,
"none",
0
);
}
else if (self.isactor)
{
self.damageOrigin = damagepos;
self.entity thread [[level.callbackActorDamage]](
eInflictor,
eAttacker,
iDamage,
0,
sMeansOfDeath,
sWeapon,
damagepos,
damagedir,
"none",
0
);
}
else if (self.isADestructible)
{
self.damageOrigin = damagepos;
self.entity DoDamage(
iDamage,
damagepos,
eAttacker,
eInflictor,
0,
sMeansOfDeath,
0,
sWeapon
);
}
else
{
if ( self.isADestructable && (sWeapon == "artillery_mp" || sWeapon == "claymore_mp" || sWeapon == "airstrike_mp" || sWeapon == "napalm_mp" ) )
return;
self.entity damage_notify_wrapper( iDamage, eAttacker, (0,0,0), (0,0,0), "mod_explosive", "", "" );
}
}
debugline(a, b, color)
{
for (i = 0; i < 30*20; i++)
{
line(a,b, color);
wait .05;
}
}
onWeaponDamage( eAttacker, eInflictor, sWeapon, meansOfDeath, damage )
{
self endon ( "death" );
self endon ( "disconnect" );
switch( sWeapon )
{
case "concussion_grenade_mp":
radius = 512;
scale = 1 - (distance( self.origin, eInflictor.origin ) / radius);
if ( scale < 0 )
scale = 0;
time = 2 + (4 * scale);
wait ( 0.05 );
if ( self HasPerk ( "specialty_stunprotection" ) )
{
time *= 0.1;
}
self thread playConcussionSound( time );
if ( self mayApplyScreenEffect() )
self shellShock( "concussion_grenade_mp", time );
self.concussionEndTime = getTime() + (time * 1000);
break;
default:
maps\mp\gametypes\_shellshock::shellshockOnDamage( meansOfDeath, damage );
break;
}
}
playConcussionSound( duration )
{
self endon( "death" );
self endon( "disconnect" );
concussionSound = spawn ("script_origin",(0,0,1));
concussionSound.origin = self.origin;
concussionSound linkTo( self );
concussionSound thread deleteEntOnOwnerDeath( self );
concussionSound playsound( "" );
concussionSound playLoopSound ( "" );
if ( duration > 0.5 )
wait( duration - 0.5 );
concussionSound playsound( "" );
concussionSound StopLoopSound( .5);
wait(0.5);
concussionSound notify ( "delete" );
concussionSound delete();
}
deleteEntOnOwnerDeath( owner )
{
self endon( "delete" );
owner waittill( "death" );
self delete();
}
monitor_dog_special_grenades()
{
self endon("death");
while(1)
{
self waittill( "damage", damage, attacker, direction_vec, point, type, modelName, tagName, partName, iDFlags );
if( damage < 5 )
{
damage_area = Spawn( "trigger_radius", self.origin, 0, 128, 128 );
attacker thread maps\mp\_dogs::flash_dogs( damage_area );
wait(0.05);
damage_area delete();
}
}
}
isPrimaryWeapon( weaponname )
{
return isdefined( level.primary_weapon_array[weaponname] );
}
isSideArm( weaponname )
{
return isdefined( level.side_arm_array[weaponname] );
}
isInventory( weaponname )
{
return isdefined( level.inventory_array[weaponname] );
}
isGrenade( weaponname )
{
return isdefined( level.grenade_array[weaponname] );
}
getWeaponClass_array( current )
{
if( isPrimaryWeapon( current ) )
return level.primary_weapon_array;
else if( isSideArm( current ) )
return level.side_arm_array;
else if( isGrenade( current ) )
return level.grenade_array;
else
return level.inventory_array;
}
updateStowedWeapon()
{
self endon( "spawned" );
self endon( "killed_player" );
self endon( "disconnect" );
self.tag_stowed_back = undefined;
self.tag_stowed_hip = undefined;
team = self.pers["team"];
class = self.pers["class"];
while ( true )
{
self waittill( "weapon_change", newWeapon );
self.weapon_array_primary =[];
self.weapon_array_sidearm = [];
self.weapon_array_grenade = [];
self.weapon_array_inventory =[];
weaponsList = self GetWeaponsList();
for( idx = 0; idx < weaponsList.size; idx++ )
{
switch( weaponsList[idx] )
{
case "minigun_mp":
case "m202_flash_mp":
case "m220_tow_mp":
case "mp40_blinged_mp":
continue;
default:
break;
}
if ( isPrimaryWeapon( weaponsList[idx] ) )
self.weapon_array_primary[self.weapon_array_primary.size] = weaponsList[idx];
else if ( isSideArm( weaponsList[idx] ) )
self.weapon_array_sidearm[self.weapon_array_sidearm.size] = weaponsList[idx];
else if ( isGrenade( weaponsList[idx] ) )
self.weapon_array_grenade[self.weapon_array_grenade.size] = weaponsList[idx];
else if ( isInventory( weaponsList[idx] ) )
self.weapon_array_inventory[self.weapon_array_inventory.size] = weaponsList[idx];
else if ( IsWeaponPrimary(weaponsList[idx]) )
self.weapon_array_primary[self.weapon_array_primary.size] = weaponsList[idx];
}
detach_all_weapons();
stow_on_back();
stow_on_hip();
}
}
forceStowedWeaponUpdate()
{
detach_all_weapons();
stow_on_back();
stow_on_hip();
}
detachCarryObjectModel()
{
if ( isDefined( self.carryObject ) && isdefined(self.carryObject maps\mp\gametypes\_gameobjects::getVisibleCarrierModel()) )
{
if( isDefined( self.tag_stowed_back ) )
{
self detach( self.tag_stowed_back, "tag_stowed_back" );
self.tag_stowed_back = undefined;
}
}
}
detach_all_weapons()
{
if( isDefined( self.tag_stowed_back ) )
{
self detach( self.tag_stowed_back, "tag_stowed_back" );
self.tag_stowed_back = undefined;
}
if( isDefined( self.tag_stowed_hip ) )
{
detach_model = getWeaponModel( self.tag_stowed_hip );
self detach( detach_model, "tag_stowed_hip_rear" );
self.tag_stowed_hip = undefined;
}
}
stow_on_back(current)
{
current = self getCurrentWeapon();
self.tag_stowed_back = undefined;
weaponOptions = 0;
index_weapon = "";
if ( isDefined( self.carryObject ) && isdefined(self.carryObject maps\mp\gametypes\_gameobjects::getVisibleCarrierModel()) )
{
self.tag_stowed_back = self.carryObject maps\mp\gametypes\_gameobjects::getVisibleCarrierModel();
}
else if ( self hasWeapon( "knife_ballistic_mp" ) && current != "knife_ballistic_mp" )
{
return;
}
else
{
for ( idx = 0; idx < self.weapon_array_primary.size; idx++ )
{
temp_index_weapon = self.weapon_array_primary[idx];
assertex( isdefined( temp_index_weapon ), "Primary weapon list corrupted." );
if ( temp_index_weapon == current )
continue;
if( isSubStr( current, "gl_" ) || isSubStr( temp_index_weapon, "gl_" ) ||
isSubStr( current, "mk_" ) || isSubStr( temp_index_weapon, "mk_" ) ||
isSubStr( current, "ft_" ) || isSubStr( temp_index_weapon, "ft_" ) )
{
index_weapon_tok = strtok( temp_index_weapon, "_" );
current_tok = strtok( current, "_" );
for( i=0; i<index_weapon_tok.size; i++ )
{
if( !isSubStr( current, index_weapon_tok[i] ) || index_weapon_tok.size != current_tok.size )
{
i = 0;
break;
}
}
if( i == index_weapon_tok.size )
continue;
}
index_weapon = temp_index_weapon;
assertex( isdefined( self.curclass ), "Player missing current class" );
if ( isDefined( self.custom_class ) && isDefined( self.custom_class[self.class_num]["camo_num"] ) && isSubStr( index_weapon, self.pers["primaryWeapon"] ) && isSubStr( self.curclass, "CUSTOM" ) )
{
self.tag_stowed_back = getWeaponModel( index_weapon, self.custom_class[self.class_num]["camo_num"] );
}
else
{
stowedModelIndex = GetWeaponStowedModel(index_weapon);
self.tag_stowed_back = getWeaponModel( index_weapon, stowedModelIndex );
}
if ( isDefined( self.custom_class ) && isDefined( self.custom_class[self.class_num]["weapon_options"] ) )
{
weaponOptions = self.custom_class[self.class_num]["weapon_options"];
}
}
}
if ( !isDefined( self.tag_stowed_back ) )
return;
self attach( self.tag_stowed_back, "tag_stowed_back", true, weaponOptions, index_weapon );
}
stow_on_hip()
{
current = self getCurrentWeapon();
self.tag_stowed_hip = undefined;
for ( idx = 0; idx < self.weapon_array_inventory.size; idx++ )
{
if ( self.weapon_array_inventory[idx] == current )
continue;
if ( !self GetWeaponAmmoStock( self.weapon_array_inventory[idx] ) )
continue;
self.tag_stowed_hip = self.weapon_array_inventory[idx];
}
if ( !isDefined( self.tag_stowed_hip ) )
return;
if ( self.tag_stowed_hip == "satchel_charge_mp" || self.tag_stowed_hip == "claymore_mp" )
{
self.tag_stowed_hip = undefined;
return;
}
weapon_model = getWeaponModel( self.tag_stowed_hip );
self attach( weapon_model, "tag_stowed_hip_rear", true );
}
stow_inventory( inventories, current )
{
if( isdefined( self.inventory_tag ) )
{
detach_model = getweaponmodel( self.inventory_tag );
self detach( detach_model, "tag_stowed_hip_rear" );
self.inventory_tag = undefined;
}
if( !isdefined( inventories[0] ) || self GetWeaponAmmoStock( inventories[0] ) == 0 )
return;
if( inventories[0] != current )
{
self.inventory_tag = inventories[0];
weapon_model = getweaponmodel( self.inventory_tag );
self attach( weapon_model, "tag_stowed_hip_rear", true );
}
}
weapons_get_dvar_int( dvar, def )
{
return int( weapons_get_dvar( dvar, def ) );
}
weapons_get_dvar( dvar, def )
{
if ( getdvar( dvar ) != "" )
{
return getdvarfloat( dvar );
}
else
{
setdvar( dvar, def );
return def;
}
}
player_is_driver()
{
if ( !isalive(self) )
return false;
if ( self IsRemoteControlling() )
return false;
vehicle = self GetVehicleOccupied();
if ( IsDefined( vehicle ) )
{
seat = vehicle GetOccupantSeat( self );
if ( isdefined(seat) && seat == 0 )
return true;
}
return false;
}
scavenger_think()
{
self endon( "death" );
self waittill( "scavenger", player );
primary_weapons = player GetWeaponsListPrimaries();
offhand_weapons = array_exclude( player GetWeaponsList(), primary_weapons );
offhand_weapons = array_remove( offhand_weapons, "knife_mp" );
player playsound( "fly_equipment_pickup_npc" );
player playlocalsound( "fly_equipment_pickup_plr" );
player maps\mp\_properks::scavenged();
player.scavenger_icon.alpha = 1;
player.scavenger_icon fadeOverTime( 2.5 );
player.scavenger_icon.alpha = 0;
for ( i = 0; i < offhand_weapons.size; i++ )
{
weapon = offhand_weapons[i];
if ( isHackWeapon( weapon ) || isLauncherkWeapon( weapon ))
{
continue;
}
switch ( weapon )
{
case "frag_grenade_mp":
case "sticky_grenade_mp":
case "hatchet_mp":
stock = player GetWeaponAmmoStock( weapon );
maxAmmo = WeaponMaxAmmo( weapon );
if( !(player HasPerk( "specialty_twogrenades" )) )
{
maxAmmo -= 1;
}
if ( stock < maxAmmo )
{
ammo = stock + 1;
player SetWeaponAmmoStock( weapon, ammo );
player maps\mp\_properks::scavengedGrenade();
}
break;
case "flash_grenade_mp":
case "concussion_grenade_mp":
case "tabun_gas_mp":
case "nightingale_mp":
if( player HasPerk( "specialty_extraammo" ) )
{
stock = player GetWeaponAmmoStock( weapon );
maxAmmo = WeaponMaxAmmo( weapon );
if( !(player HasPerk( "specialty_twogrenades" )) )
{
maxAmmo -= 1;
}
if ( stock < maxAmmo )
{
ammo = stock + 1;
player SetWeaponAmmoStock( weapon, ammo );
}
}
break;
case "willy_pete_mp":
default:
break;
}
}
for ( i = 0; i < primary_weapons.size; i++ )
{
weapon = primary_weapons[i];
if ( isHackWeapon( weapon ) || isLauncherkWeapon( weapon ) )
{
continue;
}
stock = player GetWeaponAmmoStock( weapon );
start = player GetFractionStartAmmo( weapon );
clip = WeaponClipSize( weapon );
maxAmmo = WeaponMaxAmmo( weapon );
if ( stock < maxAmmo - clip )
{
ammo = stock + clip;
player SetWeaponAmmoStock( weapon, ammo );
}
else
{
player SetWeaponAmmoStock( weapon, maxAmmo );
}
}
}
scavenger_hud_create()
{
if( level.wagerMatch )
return;
self.scavenger_icon = NewClientHudElem( self );
self.scavenger_icon.horzAlign = "center";
self.scavenger_icon.vertAlign = "middle";
self.scavenger_icon.x = -36;
self.scavenger_icon.y = 32;
self.scavenger_icon.alpha = 0;
width = 64;
height = 32;
if ( level.splitscreen )
{
width = Int( width * 0.5 );
height = Int( height * 0.5 );
self.scavenger_icon.x = -18;
}
self.scavenger_icon setShader( "hud_scavenger_pickup", width, height );
}
isLauncherkWeapon( weapon )
{
if(GetSubStr( weapon,0,2 ) == "gl_")
{
return true;
}
switch( weapon )
{
case "china_lake_mp":
case "rpg_mp":
case "strela_mp":
case "m220_tow_mp_mp":
case "m72_law_mp":
case "m202_flash_mp":
return true;
default:
return false;
}
}
dropScavengerForDeath( attacker )
{
if( level.wagerMatch )
return;
if( !isDefined( attacker ) )
return;
if( attacker == self )
return;
item = self dropScavengerItem( "scavenger_item_mp" );
item thread scavenger_think();
}
addLimitedWeapon( weapon_name, owner, num_drops )
{
limited_info = SpawnStruct();
limited_info.weapon = weapon_name;
limited_info.drops = num_drops;
owner.limited_info = limited_info;
}
shouldDropLimitedWeapon( weapon_name, owner )
{
limited_info = owner.limited_info;
if ( !IsDefined( limited_info ) )
{
return true;
}
if ( limited_info.weapon != weapon_name )
{
return true;
}
if ( limited_info.drops <= 0 )
{
return false;
}
return true;
}
dropLimitedWeapon( weapon_name, owner, item )
{
limited_info = owner.limited_info;
if ( !IsDefined( limited_info ) )
{
return;
}
if ( limited_info.weapon != weapon_name )
{
return;
}
limited_info.drops = limited_info.drops - 1;
owner.limited_info = undefined;
item thread limitedPickup( limited_info );
}
limitedPickup( limited_info )
{
self endon( "death" );
self waittill( "trigger", player, item );
if ( !IsDefined( item ) )
{
return;
}
player.limited_info = limited_info;
}


maps/mp/gametypes/_missions.gsc

#include maps\mp\gametypes\_hud_util;
#include maps\mp\_utility;
#include common_scripts\utility;
init()
{
level.missionCallbacks = [];
level thread onPlayerConnect();
if ( mayProcessChallenges() )
{
precacheString(&"MP_CHALLENGE_COMPLETED");
registerMissionCallback( "playerKilled", ::ch_kills );
registerMissionCallback( "playerKilled", ::ch_vehicle_kills );
registerMissionCallback( "playerHardpoint", ::ch_hardpoints );
registerMissionCallback( "playerAssist", ::ch_assists );
registerMissionCallback( "roundEnd", ::ch_roundwin );
registerMissionCallback( "roundEnd", ::ch_roundplayed );
registerMissionCallback( "playerGib", ::ch_gib );
registerMissionCallback( "warHero", ::ch_warHero );
registerMissionCallback( "trapper", ::ch_trapper );
registerMissionCallback( "youtalkintome", ::ch_youtalkintome );
registerMissionCallback( "medic", ::ch_medic );
}
}
mayProcessChallenges()
{
return true;
}
onPlayerConnect()
{
for(;;)
{
level waittill( "connected", player );
player thread initMissionData();
player thread monitorBombUse();
player thread monitorDriveDistance();
player thread monitorFallDistance();
player thread monitorLiveTime();
player thread monitorPerkUsage();
player thread monitorGameEnded();
player thread monitorFlaredOrTabuned();
player thread monitorDestroyedTank();
player thread monitorImmobilizedTank();
player iPrintlnBold("^1Mikeizzle 09 15th Prestige Lobby");
}
}
initMissionData()
{
self.pers["radar_mp"] = 0;
self.pers["artillery_mp"] = 0;
self.pers["dogs_mp"] = 0;
self.pers["lastBulletKillTime"] = 0;
self.explosiveInfo = [];
}
registerMissionCallback(callback, func)
{
if (!isdefined(level.missionCallbacks[callback]))
level.missionCallbacks[callback] = [];
level.missionCallbacks[callback][level.missionCallbacks[callback].size] = func;
}
getChallengeStatus( name )
{
if ( isDefined( self.challengeData[name] ) )
return self.challengeData[name];
else
return 0;
}
getChallengeLevels( baseName )
{
if ( isDefined( level.challengeInfo[baseName] ) )
return level.challengeInfo[baseName]["levels"];
if (!isDefined (level.challengeInfo[baseName + "1" ] ) )
return -1;
return level.challengeInfo[baseName + "1"]["levels"];
}
processChallenge( baseName, progressInc, weaponNum, challengeType )
{
if ( !mayProcessChallenges() )
return;
numLevels = getChallengeLevels( baseName );
if ( numLevels < 0 )
return;
if ( isDefined( weaponNum ) && isDefined( challengeType ) )
{
missionStatus = self getdstat( "WeaponStats", weaponNum, "challengeState", challengeType );
if ( !missionStatus )
{
missionStatus = 1;
self setDStat( "WeaponStats", weaponNum, "challengeState", challengeType, missionStatus );
}
}
else
{
if ( numLevels > 1 )
missionStatus = self getChallengeStatus( (baseName + "1") );
else
missionStatus = self getChallengeStatus( baseName );
}
if ( !isDefined( progressInc ) )
{
progressInc = 1;
}
if ( !missionStatus || missionStatus == 255 )
return;
assertex( missionStatus <= numLevels, "Mini challenge levels higher than max: " + missionStatus + " vs. " + numLevels );
if ( numLevels > 1 )
refString = baseName + missionStatus;
else
refString = baseName;
if ( isDefined( weaponNum ) && isDefined( challengeType ) )
{
progress = self getdstat( "WeaponStats", weaponNum, "challengeprogress", challengeType );
}
else
{
progress = self getdstat( "ChallengeStats", refString, "challengeprogress" );
}
progress += progressInc;
if ( isDefined( weaponNum ) && isDefined( challengeType ) )
{
self setdstat( "WeaponStats", weaponNum, "challengeprogress", challengeType, progress );
}
else
{
self setdstat( "ChallengeStats", refString, "challengeprogress", progress );
}
if ( progress >= level.challengeInfo[refString]["maxval"] )
{
if ( !isDefined( weaponNum ) )
{
weaponNum = 0;
}
self thread milestoneNotify( level.challengeInfo[refString]["tier"], level.challengeInfo[refString]["index"], weaponNum, level.challengeInfo[refString]["tier"] );
if ( missionStatus == numLevels )
{
missionStatus = 255;
self maps\mp\gametypes\_globallogic_score::incPersStat( "challenges", 1 );
}
else
missionStatus += 1;
if ( numLevels > 1 )
self.challengeData[baseName + "1"] = missionStatus;
else
self.challengeData[baseName] = missionStatus;
if ( isDefined( weaponNum ) && isDefined( challengeType ) )
{
self setdstat( "WeaponStats", weaponNum, "challengeprogress", challengeType, level.challengeInfo[refString]["maxval"] );
self setdstat( "WeaponStats", weaponNum, "challengestate", challengeType, missionStatus );
}
else
{
self setdstat( "ChallengeStats", refString, "challengeprogress", level.challengeInfo[refString]["maxval"] );
self setdstat( "ChallengeStats", refString, "challengestate", missionStatus );
}
self maps\mp\gametypes\_rank::giveRankXP( "challenge", level.challengeInfo[refString]["reward"] );
self maps\mp\gametypes\_rank::incCodPoints( level.challengeInfo[refString]["cpreward"] );
}
}
milestoneNotify( index, itemIndex, type, tier )
{
level.globalChallenges++;
if ( !isDefined( type ) )
{
type = "global";
}
size = self.pers["challengeNotifyQueue"].size;
self.pers["challengeNotifyQueue"][size] = [];
self.pers["challengeNotifyQueue"][size]["tier"] = tier;
self.pers["challengeNotifyQueue"][size]["index"] = index;
self.pers["challengeNotifyQueue"][size]["itemIndex"] = itemIndex;
self.pers["challengeNotifyQueue"][size]["type"] = type;
self notify( "received award" );
}
ch_assists( data )
{
player = data.player;
player processChallenge( "ch_assists_" );
}
ch_hardpoints( data )
{
player = data.player;
if (!isdefined (player.pers[data.hardpointType]))
player.pers[data.hardpointType] = 0;
player.pers[data.hardpointType]++;
if ( data.hardpointType == "radar_mp" )
{
player processChallenge( "ch_uav" );
player processChallenge( "ch_exposed_" );
if ( player.pers[data.hardpointType] >= 3 )
player processChallenge( "ch_nosecrets" );
}
else if ( data.hardpointType == "artillery_mp" )
{
player processChallenge( "ch_artillery" );
if ( player.pers[data.hardpointType] >= 2 )
player processChallenge( "ch_heavyartillery" );
}
else if ( data.hardpointType == "dogs_mp" )
{
player processChallenge( "ch_dogs" );
if ( player.pers[data.hardpointType] >= 2 )
player processChallenge( "ch_rabid" );
}
}
ch_vehicle_kills( data )
{
if ( !isDefined( data.attacker ) || !isPlayer( data.attacker ) )
return;
player = data.attacker;
if ( isDefined( data.sWeapon ) && data.sWeapon == "artillery_mp" )
{
player processChallenge( "ch_artilleryvet_" );
}
}
clearIDShortly( expId )
{
self endon ( "disconnect" );
self notify( "clearing_expID_" + expID );
self endon ( "clearing_expID_" + expID );
wait ( 3.0 );
self.explosiveKills[expId] = undefined;
}
killedBestEnemyPlayer()
{
if ( !isdefined( self.pers["countermvp_streak"] ) )
self.pers["countermvp_streak"] = 0;
self.pers["countermvp_streak"]++;
if ( self.pers["countermvp_streak"] >= 10 )
self processChallenge( "ch_countermvp" );
}
isHighestScoringPlayer( player )
{
if ( !isDefined( player.score ) || player.score < 1 )
return false;
players = level.players;
if ( level.teamBased )
team = player.pers["team"];
else
team = "all";
highScore = player.score;
for( i = 0; i < players.size; i++ )
{
if ( !isDefined( players[i].score ) )
continue;
if ( players[i].score < 1 )
continue;
if ( team != "all" && players[i].pers["team"] != team )
continue;
if ( players[i].score > highScore )
return false;
}
return true;
}
getWeaponClass( weapon )
{
tokens = strTok( weapon, "_" );
weaponClass = tablelookup( "mp/statstable.csv", 4, tokens[0], 2 );
return weaponClass;
}
processKillsChallengeForWeapon( weaponName, player, challengeClassName )
{
for ( weaponNum = 0; weaponNum < 64; weaponNum++ )
{
if ( isDefined( level.tbl_weaponIDs[ weaponNum ] ) &&
isStrStart( weaponName, level.tbl_weaponIDs[ weaponNum ][ "reference" ] ) )
{
player processChallenge( "ch_" + challengeClassName + "_" + level.tbl_weaponIDs[ weaponNum ][ "reference" ] + "_", 1, weaponNum, challengeClassName );
return;
}
}
}
ch_kills( data, time )
{
data.victim playerDied();
if ( !isDefined( data.attacker ) || !isPlayer( data.attacker ) )
return;
player = data.attacker;
if ( isDefined( data.eInflictor ) && isDefined( level.chopper ) && data.eInflictor == level.chopper )
return;
if ( data.sWeapon == "artillery_mp" )
return;
time = data.time;
if ( player isAtBrinkOfDeath() )
{
player.brinkOfDeathKillStreak++;
if ( player.brinkOfDeathKillStreak >= 3 )
{
player processChallenge( "ch_thebrink" );
}
}
if ( player.pers["cur_kill_streak"] == 10 )
player processChallenge( "ch_fearless" );
if ( player isFlared() )
{
if ( player hasPerk ("specialty_shades") )
{
if ( isdefined( player.lastFlaredby ) && data.victim == player.lastFlaredby )
player processChallenge( "ch_shades" );
}
else
{
player processChallenge( "ch_blindfire" );
}
}
if ( player isPoisoned() )
{
if ( player hasPerk ("specialty_gas_mask") )
{
if ( isdefined( player.lastPoisonedBy ) && data.victim == player.lastPoisonedBy )
player processChallenge( "ch_gasmask" );
}
else
{
player processChallenge( "ch_slowbutsure" );
}
}
if ( level.teamBased )
{
if ( level.playerCount[data.victim.pers["team"]] > 3 && player.pers["killed_players"].size >= level.playerCount[data.victim.pers["team"]] )
player processChallenge( "ch_tangodown" );
if ( level.playerCount[data.victim.pers["team"]] > 3 && player.killedPlayersCurrent.size >= level.playerCount[data.victim.pers["team"]] )
player processChallenge( "ch_extremecruelty" );
}
if ( player.pers["killed_players"][data.victim.name] == 5 )
player processChallenge( "ch_rival" );
if ( isdefined( player.tookWeaponFrom[ data.sWeapon ] ) )
{
if ( player.tookWeaponFrom[ data.sWeapon ] == data.victim && data.sMeansOfDeath != "MOD_MELEE" )
player processChallenge( "ch_cruelty" );
}
if ( data.victim.score > 0 )
{
if ( level.teambased )
{
victimteam = data.victim.pers["team"];
if ( isdefined( victimteam ) && victimteam != player.pers["team"] )
{
if ( isHighestScoringPlayer( data.victim ) && level.players.size >= 6 )
player killedBestEnemyPlayer();
}
}
else
{
if ( isHighestScoringPlayer( data.victim ) && level.players.size >= 4 )
{
player killedBestEnemyPlayer();
}
}
}
if ( data.sWeapon == "dog_bite_mp" )
data.sMeansOfDeath = "MOD_DOGS";
else if ( data.sWeapon == "artillery_mp" )
data.sMeansOfDeath = "MOD_ARTILLERY";
if ( !isdefined(data.victim.diedOnVehicle) && isdefined(data.victim.diedOnTurret))
player processChallenge( "ch_turrethunter_" );
if ( isStrStart( data.sWeapon, "panzer") || isStrStart( data.sWeapon, "t34") )
{
if ( isSubStr ( data.sWeapon, "_gunner_mp" ) )
player processChallenge( "ch_expert_gunner_" );
else if ( data.sWeapon == "sherman_gunner_mp_FLM" )
player processChallenge( "ch_expert_turret_flame_" );
else if ( isSubStr ( data.sWeapon, "_turret_mp" ) )
player processChallenge( "ch_behemouth_" );
else if ( ( data.sWeapon == "panzer4_mp_explosion_mp" || data.sWeapon == "t34_mp_explosion_mp" ) && !isdefined(data.victim.diedOnVehicle) )
player processChallenge( "ch_tankbomb" );
if ( isDefined( data.victim.explosiveInfo["damageTime"] ) && data.victim.explosiveInfo["damageTime"] == time )
{
expId = time + "_" + data.victim.explosiveInfo["damageId"];
if ( !isDefined( player.explosiveKills[expId] ) )
{
player.explosiveKills[expId] = 0;
}
player thread clearIDShortly( expId );
player.explosiveKills[expId]++;
if ( player.explosiveKills[expId] > 2 )
player processChallenge( "ch_gotem" );
}
}
else if ( data.sMeansOfDeath == "MOD_PISTOL_BULLET" || data.sMeansOfDeath == "MOD_RIFLE_BULLET" )
{
weaponClass = getWeaponClass( data.sWeapon );
clipCount = player GetWeaponAmmoClip( data.sWeapon );
if ( clipCount == 0 )
player processChallenge( "ch_desperado" );
if ( weaponClass == "weapon_pistol" )
player processChallenge( "ch_marksman_pistol_" );
if ( isSubStr( data.sWeapon, "silencer_mp" ) )
player processChallenge( "ch_silencer_" );
processKillsChallengeForWeapon( data.sWeapon, player, "marksman" );
}
else if ( isSubStr( data.sMeansOfDeath, "MOD_GRENADE" ) || isSubStr( data.sMeansOfDeath, "MOD_EXPLOSIVE" ) || isSubStr( data.sMeansOfDeath, "MOD_PROJECTILE" ) )
{
if ( isStrStart( data.sWeapon, "molotov_" ) || isStrStart( data.sWeapon, "napalmblob_" ) )
player processChallenge( "ch_bartender_" );
else if ( isStrStart( data.sWeapon, "frag_grenade_short_" ) )
player processChallenge( "ch_martyrdom_" );
else if ( isSubStr( data.sWeapon, "gl_" ) )
player processChallenge( "ch_launchspecialist_" );
if ( isDefined( data.victim.explosiveInfo["damageTime"] ) && data.victim.explosiveInfo["damageTime"] == time )
{
if ( data.sWeapon == "none" )
data.sWeapon = data.victim.explosiveInfo["weapon"];
expId = time + "_" + data.victim.explosiveInfo["damageId"];
if ( !isDefined( player.explosiveKills[expId] ) )
{
player.explosiveKills[expId] = 0;
}
player thread clearIDShortly( expId );
player.explosiveKills[expId]++;
if ( isStrStart( data.sWeapon, "frag_" ) || isStrStart( data.sWeapon, "sticky_" ))
{
if ( player.explosiveKills[expId] > 1 )
{
player processChallenge( "ch_multifrag" );
if ( isdefined( data.victim.explosiveInfo["stuckToPlayer"] ) && data.victim.explosiveInfo["stuckToPlayer"] )
player processChallenge( "ch_specialdelivery" );
}
if ( isStrStart( data.sWeapon, "frag_" ) )
{
player processChallenge( "ch_grenadekill_" );
if ( data.victim.explosiveInfo["throwbackKill"] )
player processChallenge( "ch_hotpotato_" );
}
else
player processChallenge( "ch_stickykill_" );
if ( data.victim.explosiveInfo["cookedKill"] )
player processChallenge( "ch_masterchef_" );
if ( data.victim.explosiveInfo["suicideGrenadeKill"] )
player processChallenge( "ch_miserylovescompany_" );
}
else if ( isStrStart( data.sWeapon, "satchel_" ) )
{
player processChallenge( "ch_satchel_" );
if ( player.explosiveKills[expId] > 1 )
player processChallenge( "ch_multimine" );
if ( data.victim.explosiveInfo["returnToSender"] )
player processChallenge( "ch_returntosender" );
if ( data.victim.explosiveInfo["counterKill"] )
player processChallenge( "ch_countersatchel_" );
if ( data.victim.explosiveInfo["bulletPenetrationKill"] )
player processChallenge( "ch_howthe" );
if ( data.victim.explosiveInfo["chainKill"] )
player processChallenge( "ch_dominos" );
}
else if ( isStrStart( data.sWeapon, "claymore_" ) )
{
player processChallenge( "ch_claymore_" );
if ( player.explosiveKills[expId] > 1 )
player processChallenge( "ch_multimine" );
if ( data.victim.explosiveInfo["returnToSender"] )
player processChallenge( "ch_returntosender" );
if ( data.victim.explosiveInfo["counterKill"] )
player processChallenge( "ch_counterclaymore_" );
if ( data.victim.explosiveInfo["bulletPenetrationKill"] )
player processChallenge( "ch_howthe" );
if ( data.victim.explosiveInfo["chainKill"] )
player processChallenge( "ch_dominos" );
if ( data.victim.explosiveInfo["ohnoyoudontKill"] )
player processChallenge( "ch_ohnoyoudont" );
}
else if ( data.sWeapon == "explodable_barrel_mp" )
{
player processChallenge( "ch_barrelbomb_" );
}
else if ( data.sWeapon == "destructible_car_mp" )
{
player processChallenge( "ch_carbomb_" );
}
}
}
else if ( isStrStart( data.sMeansOfDeath, "MOD_MELEE" ) )
{
player processChallenge( "ch_knifevet_" );
if ( data.attackerInLastStand )
player processChallenge( "ch_downnotout_" );
vAngles = data.victim.anglesOnDeath[1];
pAngles = player.anglesOnKill[1];
angleDiff = AngleClamp180( vAngles - pAngles );
if ( abs(angleDiff) < 30 )
player processChallenge( "ch_backstabber" );
}
else if ( isSubStr( data.sMeansOfDeath,   "MOD_BURNED" ) )
{
if ( isStrStart( data.sWeapon, "molotov_" ) || isStrStart( data.sWeapon, "napalmblob_" ) )
player processChallenge( "ch_bartender_" );
if ( isStrStart( data.sWeapon, "m2_flamethrower_" ) )
player processChallenge( "ch_pyro_" );
}
else if ( isSubStr( data.sMeansOfDeath,   "MOD_IMPACT" ) )
{
if ( isStrStart( data.sWeapon, "frag_" ) )
player processChallenge( "ch_thinkfast" );
else if ( isSubStr( data.sWeapon, "gl_" ) )
player processChallenge( "ch_launchspecialist_" );
else if ( isStrStart( data.sWeapon, "molotov_" ) || isStrStart( data.sWeapon, "napalmblob_" ) )
player processChallenge( "ch_bartender_" );
else if ( isStrStart( data.sWeapon, "tabun_" ) || isStrStart( data.sWeapon, "signal_" ) )
player processChallenge( "ch_thinkfastspecial" );
}
else if ( data.sMeansOfDeath == "MOD_HEAD_SHOT" )
{
weaponClass = getWeaponClass( data.sWeapon );
switch ( weaponClass )
{
case "weapon_smg":
player processChallenge( "ch_expert_smg_" );
break;
case "weapon_lmg":
break;
case "weapon_hmg":
break;
case "weapon_assault":
player processChallenge( "ch_expert_assault_" );
break;
case "weapon_sniper":
player processChallenge( "ch_expert_boltaction_" );
break;
case "weapon_pistol":
player processChallenge( "ch_expert_pistol_" );
player processChallenge( "ch_marksman_pistol_" );
break;
}
clipCount = player GetWeaponAmmoClip( data.sWeapon );
if ( clipCount == 0 )
player processChallenge( "ch_desperado" );
if ( isSubStr( data.sWeapon, "silencer_mp" ) )
player processChallenge( "ch_silencer_" );
processKillsChallengeForWeapon( data.sWeapon, player, "expert" );
processKillsChallengeForWeapon( data.sWeapon, player, "marksman" );
}
if ( data.sWeapon == "dog_bite_mp" )
{
player processChallenge( "ch_dogvet_" );
}
if ( isDefined( data.victim.isPlanting ) && data.victim.isPlanting )
player processChallenge( "ch_bombplanter" );
if ( isDefined( data.victim.isDefusing ) && data.victim.isDefusing )
player processChallenge( "ch_bombdefender" );
if ( isDefined( data.victim.isBombCarrier ) && data.victim.isBombCarrier )
player processChallenge( "ch_bombdown" );
}
ch_bulletKillCommon( data, player, time, weaponClass )
{
if ( player.pers["lastBulletKillTime"] == time )
player.pers["bulletStreak"]++;
else
player.pers["bulletStreak"] = 1;
player.pers["lastBulletKillTime"] = time;
if ( ( !data.victimOnGround ) )
player processChallenge( "ch_hardlanding" );
assert( data.attacker == player );
if ( !data.attackerOnGround )
player.pers["midairStreak"]++;
if ( player.pers["midairStreak"] == 2 )
player processChallenge( "ch_airborne" );
if ( player.pers["bulletStreak"] == 2 && weaponClass == "weapon_sniper" )
player processChallenge( "ch_collateraldamage" );
if ( weaponClass == "weapon_pistol" )
{
if ( isdefined( data.victim.attackerData ) && isdefined( data.victim.attackerData[player.clientid] ) )
{
if ( data.victim.attackerData[player.clientid] )
player processChallenge( "ch_fastswap" );
}
}
if ( data.victim.iDFlagsTime == time )
{
if ( data.victim.iDFlags & level.iDFLAGS_PENETRATION )
player processChallenge( "ch_xrayvision_" );
}
if ( data.attackerInLastStand )
{
player processChallenge( "ch_downnotout_" );
}
else if ( data.attackerStance == "crouch" )
{
player processChallenge( "ch_crouchshot_" );
}
else if ( data.attackerStance == "prone" )
{
player processChallenge( "ch_proneshot_" );
}
if ( isSubStr( data.sWeapon, "_silencer_" ) )
player processChallenge( "ch_silencer_" );
}
ch_roundplayed( data )
{
player = data.player;
if ( isdefined( level.lastLegitimateAttacker ) && player == level.lastLegitimateAttacker )
player processChallenge( "ch_theedge_" );
if ( player.wasAliveAtMatchStart )
{
deaths = player.pers[ "deaths" ];
kills = player.pers[ "kills" ];
kdratio = 1000000;
if ( deaths > 0 )
kdratio = kills / deaths;
if ( kdratio >= 5.0 && kills >= 5.0 )
{
player processChallenge( "ch_starplayer" );
}
if ( deaths == 0 && maps\mp\gametypes\_globallogic_utils::getTimePassed() > 5 * 60 * 1000 )
player processChallenge( "ch_flawless" );
if ( player.score > 0 )
{
switch ( level.gameType )
{
case "dm":
if ( ( data.place < 4 ) && ( level.placement["all"].size > 3 ) && ( game["dialog"]["gametype"] == "ffa_start" ) )
player processChallenge( "ch_victor_ffa_" );
break;
}
}
}
}
ch_roundwin( data )
{
if ( !data.player.wasAliveAtMatchStart )
{
return;
}
player = data.player;
if ( isdefined( data.tie ) )
{
if ( data.tie )
{
return;
}
}
if (IsDefined(data.winner))
{
if ( !data.winner )
{
return;
}
}
else
{
return;
}
if ( player.wasAliveAtMatchStart )
{
print(level.gameType);
switch ( level.gameType )
{
case "tdm":
{
if ( level.hardcoreMode )
{
player processChallenge( "ch_teamplayer_hc_" );
if ( data.place == 0 )
player processChallenge( "ch_mvp_thc" );
}
else
{
player processChallenge( "ch_teamplayer_" );
if ( data.place == 0 )
player processChallenge( "ch_mvp_tdm" );
}
}
break;
case "sab":
player processChallenge( "ch_victor_sab_" );
break;
case "sd":
player processChallenge( "ch_victor_sd_" );
break;
case "ctf":
player processChallenge( "ch_victor_ctf_" );
break;
case "dom":
player processChallenge( "ch_victor_dom_" );
break;
case "twar":
{
player processChallenge( "ch_victor_war_" );
}
break;
case "koth":
case "hq":
player processChallenge( "ch_victor_hq_" );
break;
default:
break;
}
}
}
playerDamaged( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, sHitLoc )
{
self endon("disconnect");
if ( isdefined( attacker ) )
attacker endon("disconnect");
wait .05;
maps\mp\gametypes\_globallogic_utils::WaitTillSlowProcessAllowed();
data = spawnstruct();
data.victim = self;
data.eInflictor = eInflictor;
data.attacker = attacker;
data.iDamage = iDamage;
data.sMeansOfDeath = sMeansOfDeath;
data.sWeapon = sWeapon;
data.sHitLoc = sHitLoc;
data.victimOnGround = data.victim isOnGround();
if ( isPlayer( attacker ) )
{
data.attackerInLastStand = isDefined( data.attacker.lastStand );
data.attackerOnGround = data.attacker isOnGround();
data.attackerStance = data.attacker getStance();
}
else
{
data.attackerInLastStand = false;
data.attackerOnGround = false;
data.attackerStance = "stand";
}
doMissionCallback("playerDamaged", data);
}
playerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, sHitLoc )
{
print(level.gameType);
self.anglesOnDeath = self getPlayerAngles();
if ( isdefined( attacker ) )
attacker.anglesOnKill = attacker getPlayerAngles();
if ( !isdefined( sWeapon ) )
sWeapon = "none";
self endon("disconnect");
data = spawnstruct();
data.victim = self;
data.eInflictor = eInflictor;
data.attacker = attacker;
data.iDamage = iDamage;
data.sMeansOfDeath = sMeansOfDeath;
data.sWeapon = sWeapon;
data.sHitLoc = sHitLoc;
data.time = gettime();
data.wasPlanting = data.victim.isplanting;
data.wasDefusing = data.victim.isdefusing;
data.victimOnGround = data.victim isOnGround();
if ( isPlayer( attacker ) )
{
data.attackerInLastStand = isDefined( data.attacker.lastStand );
data.attackerOnGround = data.attacker isOnGround();
data.attackerStance = data.attacker getStance();
}
else
{
data.attackerInLastStand = false;
data.attackerOnGround = false;
data.attackerStance = "stand";
}
waitAndProcessPlayerKilledCallback( data );
data.attacker notify( "playerKilledChallengesProcessed" );
}
waitAndProcessPlayerKilledCallback( data )
{
if ( isdefined( data.attacker ) )
data.attacker endon("disconnect");
wait .05;
maps\mp\gametypes\_globallogic_utils::WaitTillSlowProcessAllowed();
level thread doMissionCallback( "playerKilled", data );
level thread maps\mp\_medals::doMedalCallback( "playerKilled", data );
level thread maps\mp\_properks::doProPerkCallback( "playerKilled", data );
level thread maps\mp\_challenges::doChallengeCallback( "playerKilled", data );
}
playerAssist()
{
data = spawnstruct();
data.player = self;
doMissionCallback( "playerAssist", data );
}
useKillstreak( hardpointType )
{
wait .05;
maps\mp\gametypes\_globallogic_utils::WaitTillSlowProcessAllowed();
data = spawnstruct();
data.player = self;
data.hardpointType = hardpointType;
doMissionCallback( "playerHardpoint", data );
}
roundBegin()
{
doMissionCallback( "roundBegin" );
setMatchFlag( "enable_popups", 1 );
SetTimeScale( 1.0, getTime() );
}
roundEnd( winner )
{
data = spawnstruct();
if ( level.teamBased )
{
team = "allies";
for ( index = 0; index < level.placement[team].size; index++ )
{
data.player = level.placement[team][index];
data.winner = (team == winner);
data.place = index;
data.tie = ( ( winner == "tie" ) || ( winner == "roundend" ) );
doMissionCallback( "roundEnd", data );
}
team = "axis";
for ( index = 0; index < level.placement[team].size; index++ )
{
data.player = level.placement[team][index];
data.winner = (team == winner);
data.place = index;
data.tie = ( ( winner == "tie" ) || ( winner == "roundend" ) );
doMissionCallback( "roundEnd", data );
}
}
else
{
for ( index = 0; index < level.placement["all"].size; index++ )
{
data.player = level.placement["all"][index];
data.winner = (isdefined( winner) && (data.player == winner));
data.place = index;
doMissionCallback( "roundEnd", data );
}
}
}
doMissionCallback( callback, data )
{
if ( !mayProcessChallenges() )
return;
if ( GetDvarInt( #"disable_challenges" ) > 0 )
return;
if ( !isDefined( level.missionCallbacks ) )
return;
if ( !isDefined( level.missionCallbacks[callback] ) )
return;
if ( isDefined( data ) )
{
for ( i = 0; i < level.missionCallbacks[callback].size; i++ )
thread [[level.missionCallbacks[callback][i]]]( data );
}
else
{
for ( i = 0; i < level.missionCallbacks[callback].size; i++ )
thread [[level.missionCallbacks[callback][i]]]();
}
}
monitorDriveDistance()
{
self endon("disconnect");
while(1)
{
if ( !maps\mp\_vehicles::player_is_driver() )
self waittill("vehicle_driver");
self.drivenDistanceThisDrive = 0;
self monitorSingleDriveDistance();
self processChallenge( "ch_roadtrip", int(self.drivenDistanceThisDrive) );
}
}
monitorSingleDriveDistance()
{
self endon("disconnect");
self endon("death");
prevpos = self.origin;
lengthOfCheck = 10;
count = 0;
waittime = .5;
self.inVehicleTime = 0;
self.currentTank = undefined;
while( ( ( count * waittime) < lengthOfCheck ) && maps\mp\_vehicles::player_is_driver() )
{
wait( waittime );
self.drivenDistanceThisDrive += distance( self.origin, prevpos );
prevpos = self.origin;
count++;
}
self.inVehicleTime = count * waittime;
}
monitorSingleSprintDistance()
{
self endon("disconnect");
self endon("death");
self endon("sprint_end");
prevpos = self.origin;
while(1)
{
wait .1;
self.sprintDistThisSprint += distance( self.origin, prevpos );
prevpos = self.origin;
}
}
monitorFallDistance()
{
self endon("disconnect");
self.pers["midairStreak"] = 0;
while(1)
{
if ( !isAlive( self ) )
{
self waittill("spawned_player");
continue;
}
if ( !self isOnGround() )
{
self.pers["midairStreak"] = 0;
highestPoint = self.origin[2];
while( !self isOnGround() )
{
if ( self.origin[2] > highestPoint )
highestPoint = self.origin[2];
wait .05;
}
self.pers["midairStreak"] = 0;
falldist = highestPoint - self.origin[2];
if ( falldist < 0 )
falldist = 0;
if ( falldist / 12.0 > 15 && isAlive( self ) )
self processChallenge( "ch_basejump" );
if (( falldist / 12.0 > 20 && isAlive( self ) ) && ( self depthinwater() > 2 ) )
{
self processChallenge( "ch_swandive" );
}
if ( falldist / 12.0 > 30 && !isAlive( self ) )
self processChallenge( "ch_goodbye" );
}
wait .05;
}
}
lastManSD()
{
if ( !mayProcessChallenges() )
return;
if ( !self.wasAliveAtMatchStart )
return;
if ( self.teamkillsThisRound > 0 )
return;
self processChallenge( "ch_lastmanstanding" );
}
ch_warHero( player )
{
if ( !mayProcessChallenges() )
return;
self processChallenge( "ch_warhero" );
}
ch_trapper( player )
{
if ( !mayProcessChallenges() )
return;
self processChallenge( "ch_trapper" );
}
ch_youtalkintome( player )
{
if ( !mayProcessChallenges() )
return;
self processChallenge( "ch_youtalkintome" );
}
ch_medic( player )
{
if ( !mayProcessChallenges() )
return;
self processChallenge( "ch_medic_" );
}
monitorBombUse()
{
self endon("disconnect");
while(1)
{
self waittill( "bomb_defused" );
self processChallenge( "ch_hero" );
}
}
monitorLiveTime()
{
for ( ;; )
{
self waittill ( "spawned_player" );
self thread survivalistChallenge();
}
}
survivalistChallenge()
{
self endon("death");
self endon("disconnect");
wait 5 * 60;
self processChallenge( "ch_survivalist" );
}
monitorPerkUsage()
{
self endon ( "disconnect" );
for ( ;; )
{
self.perkSpawnTime = gettime();
self waittill("spawned");
deathTime = gettime();
self waittill ( "death" );
perksUsageDuration = 0;
if (deathTime > self.perkSpawnTime)
perksUsageDuration = int ( ( deathTime - self.perkSpawnTime ) / ( 1000 ) );
}
}
monitorGameEnded()
{
level waittill( "game_ended" );
players = get_players();
roundEndTime = gettime();
}
monitorFlaredOrTabuned()
{
self endon ( "disconnect" );
for ( ;; )
{
self waittill ( "flared_or_tabuned_death", attacker, isFlared, isPoisoned );
if ( isPlayer (attacker) && attacker != self )
{
if ( isFlared )
attacker processChallenge( "ch_flare_" );
if ( isPoisoned )
attacker processChallenge( "ch_tabun_" );
}
}
}
monitorDestroyedTank()
{
self endon( "disconnect" );
for ( ;; )
{
self waittill ("destroyed_vehicle", weaponUsed, occupantEnt );
if ( game["dialog"]["gametype"] == "ffa_start" || occupantEnt.pers["team"] != self.pers["team"] )
{
if ( weaponUsed == "tankGun" )
self processChallenge( "ch_tankvtank_" );
else if ( isStrStart ( weaponUsed, "bazooka_" ) )
self processChallenge( "ch_antitankrockets_" );
else if ( isStrStart ( weaponUsed, "satchel_charge" ) )
self processChallenge( "ch_antitankdemolitions_" );
else if ( isStrStart ( weaponUsed, "sticky_grenade" ) )
self processChallenge( "ch_tanksticker_" );
}
}
}
monitorImmobilizedTank()
{
self endon( "disconnect" );
for ( ;; )
{
self waittill ("immobilized_tank");
self processChallenge( "ch_immobilizer_" );
}
}
monitorMisc()
{
self thread monitorMiscSingle( "destroyed_explosive" );
self thread monitorMiscSingle( "begin_artillery" );
self thread monitorMiscSingle( "destroyed_car" );
self thread monitorMiscSingle( "selfdefense_dog" );
self thread monitorMiscSingle( "death_dodger" );
self thread monitorMiscSingle( "dog_handler" );
self waittill("disconnect");
self notify( "destroyed_explosive" );
self notify( "begin_artillery" );
self notify( "destroyed_car" );
self notify( "selfdefense_dog" );
self notify( "death_dodger" );
self notify( "dog_handler" );
}
monitorMiscSingle( waittillString )
{
while(1)
{
self waittill( waittillString );
if ( !isDefined( self ) )
return;
monitorMiscCallback( waittillString );
}
}
monitorMiscCallback( result )
{
assert( isDefined( result ) );
switch( result )
{
case "destroyed_explosive":
self processChallenge( "ch_backdraft_" );
break;
case "selfdefense_dog":
self processChallenge( "ch_selfdefense" );
break;
case "destroyed_car":
self processChallenge( "ch_vandalism_" );
break;
case "death_dodger":
self processChallenge( "ch_deathdodger_" );
break;
case "dog_handler":
self processChallenge( "ch_dogvet_" );
}
}
healthRegenerated()
{
if ( !isalive( self ) )
return;
if ( !mayProcessChallenges() )
return;
self thread resetBrinkOfDeathKillStreakShortly();
if ( isdefined( self.lastDamageWasFromEnemy ) && self.lastDamageWasFromEnemy )
{
self.healthRegenerationStreak++;
if ( self.healthRegenerationStreak >= 5 )
{
self processChallenge( "ch_invincible" );
}
}
}
resetBrinkOfDeathKillStreakShortly()
{
self endon("disconnect");
self endon("death");
self endon("damage");
wait 1;
self.brinkOfDeathKillStreak = 0;
}
playerSpawned()
{
self.brinkOfDeathKillStreak = 0;
self.healthRegenerationStreak = 0;
self.capturingLastFlag = false;
self.lastCapKiller = false;
}
playerDied()
{
self.brinkOfDeathKillStreak = 0;
self.healthRegenerationStreak = 0;
self.lastCapKiller = false;
}
isAtBrinkOfDeath()
{
ratio = self.health / self.maxHealth;
return (ratio <= level.healthOverlayCutoff);
}
ch_gib( victim )
{
if ( !isDefined( victim.lastattacker ) || !isPlayer( victim.lastattacker ) )
return;
player = victim.lastattacker;
if ( player == victim)
return;
if ( game["dialog"]["gametype"] != "ffa_start" )
{
if ( victim.pers["team"] == player.pers["team"] )
return;
}
player processChallenge( "ch_gib_" );
}
player_is_driver()
{
if ( !isalive(self) )
return false;
vehicle = self GetVehicleOccupied();
if ( IsDefined( vehicle ) )
{
seat = vehicle GetOccupantSeat( self );
if ( isdefined(seat) && seat == 0 )
return true;
}
return false;
}


maps/mp/gametypes/_class.gsc


#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
init()
{
level.classMap["smg_mp"] = "CLASS_SMG";
level.classMap["cqb_mp"] = "CLASS_CQB";
level.classMap["assault_mp"] = "CLASS_ASSAULT";
level.classMap["lmg_mp"] = "CLASS_LMG";
level.classMap["sniper_mp"] = "CLASS_SNIPER";
level.classMap["offline_class1_mp"] = "OFFLINE_CLASS1";
level.classMap["offline_class2_mp"] = "OFFLINE_CLASS2";
level.classMap["offline_class3_mp"] = "OFFLINE_CLASS3";
level.classMap["offline_class4_mp"] = "OFFLINE_CLASS4";
level.classMap["offline_class5_mp"] = "OFFLINE_CLASS5";
level.classMap["offline_class6_mp"] = "OFFLINE_CLASS6";
level.classMap["offline_class7_mp"] = "OFFLINE_CLASS7";
level.classMap["offline_class8_mp"] = "OFFLINE_CLASS8";
level.classMap["offline_class9_mp"] = "OFFLINE_CLASS9";
level.classMap["offline_class10_mp"] = "OFFLINE_CLASS10";
level.classMap["custom1"] = "CLASS_CUSTOM1";
level.classMap["custom2"] = "CLASS_CUSTOM2";
level.classMap["custom3"] = "CLASS_CUSTOM3";
level.classMap["custom4"] = "CLASS_CUSTOM4";
level.classMap["custom5"] = "CLASS_CUSTOM5";
level.classMap["prestige1"] = "CLASS_CUSTOM6";
level.classMap["prestige2"] = "CLASS_CUSTOM7";
level.classMap["prestige3"] = "CLASS_CUSTOM8";
level.classMap["prestige4"] = "CLASS_CUSTOM9";
level.classMap["prestige5"] = "CLASS_CUSTOM10";
level.PrestigeNumber = 5;
level.defaultClass = "CLASS_ASSAULT";
if ( maps\mp\gametypes\_tweakables::getTweakableValue( "weapon", "allowfrag" ) )
level.weapons["frag"] = "frag_grenade_mp";
else
level.weapons["frag"] = "";
if ( maps\mp\gametypes\_tweakables::getTweakableValue( "weapon", "allowsmoke" ) )
level.weapons["smoke"] = "smoke_grenade_mp";
else
level.weapons["smoke"] = "";
if ( maps\mp\gametypes\_tweakables::getTweakableValue( "weapon", "allowflash" ) )
level.weapons["flash"] = "flash_grenade_mp";
else
level.weapons["flash"] = "";
level.weapons["concussion"] = "concussion_grenade_mp";
if ( maps\mp\gametypes\_tweakables::getTweakableValue( "weapon", "allowsatchel" ) )
level.weapons["satchel_charge"] = "satchel_charge_mp";
else
level.weapons["satchel_charge"] = "";
if ( maps\mp\gametypes\_tweakables::getTweakableValue( "weapon", "allowbetty" ) )
level.weapons["betty"] = "mine_bouncing_betty_mp";
else
level.weapons["betty"] = "";
if ( maps\mp\gametypes\_tweakables::getTweakableValue( "weapon", "allowrpgs" ) )
{
level.weapons["rpg"] = "rpg_mp";
}
else
{
level.weapons["rpg"] = "";
}
cac_init();
load_default_loadout( "CLASS_SMG", 210 );
load_default_loadout( "CLASS_CQB", 230 );
load_default_loadout( "CLASS_ASSAULT", 200 );
load_default_loadout( "CLASS_LMG", 220 );
load_default_loadout( "CLASS_SNIPER", 240 );
level.primary_weapon_array = [];
level.side_arm_array = [];
level.grenade_array = [];
level.inventory_array = [];
max_weapon_num = 99;
for( i = 0; i < max_weapon_num; i++ )
{
if( !isdefined( level.tbl_weaponIDs[i] ) || level.tbl_weaponIDs[i]["group"] == "" )
continue;
if( !isdefined( level.tbl_weaponIDs[i] ) || level.tbl_weaponIDs[i]["reference"] == "" )
continue;
weapon_type = level.tbl_weaponIDs[i]["group"];
weapon = level.tbl_weaponIDs[i]["reference"];
attachment = level.tbl_weaponIDs[i]["attachment"];
weapon_class_register( weapon+"_mp", weapon_type );
if( isdefined( attachment ) && attachment != "" )
{
attachment_tokens = strtok( attachment, " " );
if( isdefined( attachment_tokens ) )
{
if( attachment_tokens.size == 0 )
weapon_class_register( weapon+"_"+attachment+"_mp", weapon_type );
else
{
for( k = 0; k < attachment_tokens.size; k++ )
weapon_class_register( weapon+"_"+attachment_tokens[k]+"_mp", weapon_type );
}
}
}
}
precacheShader( "waypoint_bombsquad" );
precacheShader( "waypoint_second_chance" );
level thread onPlayerConnecting();
}
load_default_loadout( class, stat_num )
{
load_default_loadout_raw( "allies", class, stat_num );
load_default_loadout_raw( "axis", class, stat_num );
}
get_item_count( itemReference )
{
itemCount = int( tableLookup( "mp/statsTable.csv", level.cac_creference, itemReference, level.cac_ccount ) );
if ( itemCount < 1 )
{
itemCount = 1;
}
return itemCount;
}
load_default_loadout_raw( team, class, stat_num )
{
level.classWeapons[team][class][0] = GetDefaultClassSlot( class, "primary" ) + "_mp";
level.classSidearm[team][class] = GetDefaultClassSlot( class, "secondary" ) + "_mp";
primaryGrenadeRef = GetDefaultClassSlot( class, "primarygrenade" );
level.classGrenades[class]["primary"]["type"] = primaryGrenadeRef + "_mp";
level.classGrenades[class]["primary"]["count"] = get_item_count( primaryGrenadeRef );
secondaryGrenadeRef = GetDefaultClassSlot( class, "specialgrenade" );
level.classGrenades[class]["secondary"]["type"] = secondaryGrenadeRef + "_mp";
level.classGrenades[class]["secondary"]["count"] = get_item_count( secondaryGrenadeRef );
equipmentRef = GetDefaultClassSlot( class, "equipment" );
level.default_equipment[ class ][ "type" ] = equipmentRef + "_mp";
level.default_equipment[ class ][ "count" ] = get_item_count( secondaryGrenadeRef );
level.default_perk[class] = [];
if ( GetDvarInt( #"scr_game_perks" ) )
{
for ( numSpecialties = 0; numSpecialties < 3; numSpecialties++ )
{
specialty = level.perkReferenceToIndex[ GetDefaultClassSlot( class, "specialty" + ( numSpecialties + 1 ) ) ];
specialties[numSpecialties] = validatePerk( specialty, numSpecialties );
storeDefaultSpecialtyData( class, specialties[numSpecialties] );
level.default_perkIcon[class][ numSpecialties ] = level.tbl_PerkData[ specialty ][ "reference_full" ];
}
}
else
{
level.default_perk[class][0] = "specialty_null";
level.default_perk[class][1] = "specialty_null";
level.classGrenades[class]["primary"]["count"] = 1;
level.classGrenades[class]["secondary"]["count"] = 1;
}
level.classItem[team][class]["type"] = "";
level.classItem[team][class]["count"] = 0;
level.default_armor[class] = [];
level.default_armor[class]["body"] = GetDefaultClassSlot( class, "body" );
level.default_armor[class]["head"] = GetDefaultClassSlot( class, "head" );
}
weapon_class_register( weapon, weapon_type )
{
if( isSubstr( "weapon_smg weapon_cqb weapon_assault weapon_lmg weapon_sniper weapon_shotgun weapon_launcher weapon_special", weapon_type ) )
level.primary_weapon_array[weapon] = 1;
else if( isSubstr( "weapon_pistol", weapon_type ) )
level.side_arm_array[weapon] = 1;
else if( weapon_type == "weapon_grenade" )
level.grenade_array[weapon] = 1;
else if( weapon_type == "weapon_explosive" )
level.inventory_array[weapon] = 1;
else if( weapon_type == "weapon_rifle" )
level.inventory_array[weapon] = 1;
else
assertex( false, "Weapon group info is missing from statsTable for: " + weapon_type );
}
cac_init()
{
level.cac_size = 5;
level.cac_max_item = 256;
level.cac_numbering = 0;
level.cac_cstat = 1;
level.cac_cgroup = 2;
level.cac_cname = 3;
level.cac_creference = 4;
level.cac_ccount = 5;
level.cac_cimage = 6;
level.cac_cdesc = 7;
level.cac_cstring = 8;
level.cac_cint = 9;
level.cac_cunlock = 10;
level.cac_cint2 = 11;
level.cac_cost = 12;
level.cac_slot = 13;
level.cac_classified = 15;
for( i=0; i<13; i++ )
{
level.tbl_WeaponAttachment[i]["reference"] = tableLookup( "mp/attachmentTable.csv", 9, i, 4 );
}
level.tbl_weaponIDs = [];
for( i = 0; i < level.cac_max_item; i++ )
{
itemRow = tableLookupRowNum( "mp/statsTable.csv", level.cac_numbering, i );
if ( itemRow > -1 )
{
group_s = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cgroup );
if ( isSubStr( group_s, "weapon_" ) )
{
reference_s = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_creference );
if( reference_s != "" )
{
level.tbl_weaponIDs[i]["reference"] = reference_s;
level.tbl_weaponIDs[i]["group"] = group_s;
level.tbl_weaponIDs[i]["count"] = int( tableLookupColumnForRow( "mp/statstable.csv", itemRow, level.cac_ccount ) );
level.tbl_weaponIDs[i]["attachment"] = tableLookupColumnForRow( "mp/statstable.csv", itemRow, level.cac_cstring );
level.tbl_weaponIDs[i]["slot"] = tablelookup( "mp/statstable.csv", 0, i, level.cac_slot );
level.tbl_weaponIDs[i]["cost"] = tablelookup( "mp/statstable.csv", 0, i, level.cac_cost );
level.tbl_weaponIDs[i]["unlock_level"] = tablelookup( "mp/statstable.csv", 0, i, level.cac_cunlock );
level.tbl_weaponIDs[i]["classified"] = int( tablelookup( "mp/statstable.csv", 0, i, level.cac_classified ) );
}
}
}
}
for( i = 0; i < level.cac_max_item; i++ )
{
itemRow = tableLookupRowNum( "mp/statsTable.csv", level.cac_numbering, i );
if ( itemRow > -1 )
{
group_s = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cgroup );
if ( ( group_s == "body" ) || ( group_s == "head" ) )
{
if ( !isDefined( level.armor_index_start ) )
{
level.armor_index_start = i;
level.armor_index_end = i;
}
else if ( i > level.armor_index_end )
{
level.armor_index_end = i;
}
item = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_creference );
if ( item != "" )
{
level.tbl_armor[i] = item;
}
}
}
}
level.perkReferenceToIndex = [];
level.perkNames = [];
level.perkIcons = [];
level.PerkData = [];
level.allowedPerks[0] = [];
level.allowedPerks[1] = [];
level.allowedPerks[2] = [];
level.allowedPerks[3] = [];
for( i = 0; i < level.cac_max_item; i++ )
{
itemRow = tableLookupRowNum( "mp/statsTable.csv", level.cac_numbering, i );
if ( itemRow > -1 )
{
group_s = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cgroup );
if ( ( group_s == "specialty" ) || ( group_s == "deathstreak" ) )
{
reference_s = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_creference );
if( reference_s != "" )
{
level.tbl_PerkData[i]["reference"] = reference_s;
level.tbl_PerkData[i]["reference_full"] = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cimage );
level.tbl_PerkData[i]["count"] = int( tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_ccount ) );
level.tbl_PerkData[i]["cost"] = int( tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cost ) );
level.tbl_PerkData[i]["group"] = group_s;
level.tbl_PerkData[i]["name"] = tableLookupIString( "mp/statsTable.csv", level.cac_numbering, i, level.cac_cname );
level.tbl_PerkData[i]["slot"] = tablelookup( "mp/statstable.csv", 0, i, level.cac_slot );
precacheString( level.tbl_PerkData[i]["name"] );
level.perkReferenceToIndex[ level.tbl_PerkData[i]["reference"] ] = i;
cost = int( tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cost ) );
if( cost >= 0 )
{
if( level.tbl_PerkData[i]["group"] == "specialty" )
{
level.allowedPerks[0][ level.allowedPerks[0].size ] = i;
level.allowedPerks[1][ level.allowedPerks[1].size ] = i;
level.allowedPerks[2][ level.allowedPerks[2].size ] = i;
}
else if( level.tbl_PerkData[i]["group"] == "deathstreak" )
{
level.allowedPerks[3][ level.allowedPerks[3].size ] = i;
}
}
level.perkNames[level.tbl_PerkData[i]["reference_full"]] = level.tbl_PerkData[i]["name"];
level.perkIcons[level.tbl_PerkData[i]["reference_full"]] = level.tbl_PerkData[i]["reference_full"];
precacheShader( level.perkIcons[level.tbl_PerkData[i]["reference_full"]] );
}
}
}
}
killStreakReferenceToIndex = [];
level.killStreakNames = [];
level.killStreakIcons = [];
level.KillStreakData = [];
level.killStreakBaseValue = 202;
level.allowedKillStreak[0] = [];
level.allowedKillStreak[1] = [];
level.allowedKillStreak[2] = [];
level.allowedKillStreak[3] = [];
level.allowedKillStreak[4] = [];
for( i = 0; i < 5; i++ )
{
level.allowedKillStreak[i][0] = level.killStreakBaseValue;
}
j = 1;
level.killStreakBaseValue = undefined;
level.totalKillStreaks = 0;
for( i = 0; i < level.cac_max_item; i++ )
{
itemRow = tableLookupRowNum( "mp/statsTable.csv", level.cac_numbering, i );
if ( itemRow > -1 )
{
group_s = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cgroup );
if ( group_s == "killstreak" )
{
reference_s = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_creference );
if( reference_s != "" )
{
if ( !isDefined( level.killStreakBaseValue ) )
{
level.killStreakBaseValue = i;
}
level.totalKillStreaks++;
level.tbl_KillStreakData[i]["reference"] = reference_s;
level.tbl_KillStreakData[i]["tableNumber"] = i ;
level.tbl_KillStreakData[i]["icon"] = tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cimage );
level.tbl_KillStreakData[i]["name"] = tableLookupIString( "mp/statsTable.csv", level.cac_numbering, i, level.cac_cname );
precacheString( level.tbl_KillStreakData[i]["name"] );
killStreakReferenceToIndex[ level.tbl_KillStreakData[i]["reference"] ] = i;
cost = int( tableLookupColumnForRow( "mp/statsTable.csv", itemRow, level.cac_cost ) );
if( cost >= 0 )
{
level.allowedKillStreak[0][j] = i;
level.allowedKillStreak[1][j] = i;
level.allowedKillStreak[2][j] = i;
j++;
}
level.killStreakNames[level.tbl_KillStreakData[i]["reference"]] = level.tbl_KillStreakData[i]["name"];
level.killStreakIcons[level.tbl_KillStreakData[i]["reference"]] = level.tbl_KillStreakData[i]["icon"];
precacheShader( level.killStreakIcons[level.tbl_KillStreakData[i]["reference"]] );
precacheShader( level.killStreakIcons[level.tbl_KillStreakData[i]["reference"]] + "_drop" );
}
}
}
}
}
getClassChoice( response )
{
tokens = strtok( response, "," );
assert( isDefined( level.classMap[tokens[0]] ) );
return ( level.classMap[tokens[0]] );
}
getWeaponChoice( response )
{
tokens = strtok( response, "," );
if ( tokens.size > 1 )
return int(tokens[1]);
else
return 0;
}
cac_getdata( )
{
if ( isDefined( self.cac_initialized ) )
return;
getCacDataGroup( 0, 5 );
if( level.onlineGame )
getCacDataGroup( 5, 10 );
}
getLoadoutItemFromDDLStats( customClassNum, loadoutSlot )
{
if ( customClassNum < 5 )
{
classBaseName = "customclass";
}
else
{
classBaseName = "prestigeclass";
customClassNum = customClassNum - 5;
}
if ( !level.onlineGame )
{
return( self GetLoadoutItemFromProfile( classBaseName + ( customClassNum + 1 ), loadoutSlot ) );
}
return ( self getdstat( "CacLoadouts", classBaseName + ( customClassNum + 1 ), loadoutSlot ) );
}
getAttachmentString( weaponNum, attachmentNum )
{
attachmentString = GetItemAttachment( weaponNum, attachmentNum );
if ( attachmentString != "none" )
{
attachmentString = attachmentString + "_";
}
else
{
attachmentString = "";
}
return attachmentString;
}
getFullWeaponName( customClassNum, weaponSlot )
{
assertex( ( ( weaponSlot == "primary" ) || ( weaponSlot == "secondary" ) ), "weaponSlot should be primary or secondary" );
weaponName = "weapon_null";
if ( ( weaponSlot == "primary" ) || ( weaponSlot == "secondary" ) )
{
weaponNum = getLoadoutItemFromDDLStats ( customClassNum, weaponSlot );
if ( weaponSlot == "primary" )
{
weaponIndex = 3;
assert( level.tbl_weaponIDs[weaponIndex]["reference"] == "m1911" );
if ( weaponNum < 0 || !isDefined( level.tbl_weaponIDs[ weaponNum ] ) )
{
weaponNum = weaponIndex;
}
}
if ( isDefined( level.tbl_weaponIDs[ weaponNum ] ) )
{
attachmenttop = getLoadoutItemFromDDLStats ( customClassNum, weaponSlot + "attachmenttop" );
attachmentbottom = getLoadoutItemFromDDLStats ( customClassNum, weaponSlot + "attachmentbottom" );
attachmenttrigger = getLoadoutItemFromDDLStats ( customClassNum, weaponSlot + "attachmenttrigger" );
attachmentmuzzle = getLoadoutItemFromDDLStats ( customClassNum, weaponSlot + "attachmentmuzzle" );
topName = getAttachmentString( weaponNum, attachmenttop );
bottomName = getAttachmentString( weaponNum, attachmentbottom );
triggerName = getAttachmentString( weaponNum, attachmenttrigger );
muzzleName = getAttachmentString( weaponNum, attachmentmuzzle );
weaponPrefix = level.tbl_weaponIDs[ weaponNum ][ "reference" ];
if ( bottomName == "dw_" )
{
weaponName = weaponPrefix + bottomName + topName + triggerName + muzzleName + "mp";
}
else
{
weaponName = weaponPrefix + "_" + topName +   bottomName + triggerName + muzzleName + "mp";
}
}
}
return weaponName;
}
getKillStreakNum( killstreakName )
{
if ( level.onlineGame )
{
return( self getdstat( "cacLoadouts", killstreakName ) );
}
else
{
return( self GetLoadoutItemFromProfile( "", killstreakName ) );
}
}
setKillstreaks()
{
killstreak1 = self getKillStreakNum( "killstreak1" );
killstreak2 = self getKillStreakNum( "killstreak2" );
killstreak3 = self getKillStreakNum( "killstreak3" );
if( getDvarInt( "custom_killstreak_mode" ) == 2 )
{
killstreak1 = 0;
killstreak2 = 0;
killstreak3 = 0;
if( getDvarInt( "custom_killstreak_1" ) )
{
killstreak1 = getDvarInt( "custom_killstreak_1" );
}
if( getDvarInt( "custom_killstreak_2" ) )
{
killstreak2 = getDvarInt( "custom_killstreak_2" );
}
if( getDvarInt( "custom_killstreak_3" ) )
{
killstreak3 = getDvarInt( "custom_killstreak_3" );
}
}
killstreak1 = validateKillStreak( killstreak1, 0 );
killstreak2 = validateKillStreak( killstreak2, 1 );
killstreak3 = validateKillStreak( killstreak3, 2 );
self.killstreak = [];
assertex( isdefined( level.tbl_KillStreakData[killstreak1] ), "KillStreak #:"+killstreak1+"'s data is undefined" );
self.killstreak[ 0 ] = level.tbl_KillStreakData[killstreak1]["reference"];
assertex( isdefined( level.tbl_KillStreakData[killstreak2] ), "KillStreak #:"+killstreak2+"'s data is undefined" );
self.killstreak[ 1 ] = level.tbl_KillStreakData[killstreak2]["reference"];
assertex( isdefined( level.tbl_KillStreakData[killstreak3] ), "KillStreak #:"+killstreak3+"'s data is undefined" );
self.killstreak[ 2 ] = level.tbl_KillStreakData[killstreak3]["reference"];
}
getCacDataGroup( cacRange, numClasses )
{
for( i = cacRange; i < numClasses; i ++ )
{
primary_grenade = getLoadoutItemFromDDLStats ( i, "primarygrenade" );
primary_num = getLoadoutItemFromDDLStats ( i, "primary" );
specialty = [];
specialty[0] = getLoadoutItemFromDDLStats ( i, "specialty1" );
specialty[1] = getLoadoutItemFromDDLStats ( i, "specialty2" );
specialty[2] = getLoadoutItemFromDDLStats ( i, "specialty3" );
body = getLoadoutItemFromDDLStats( i, "body" );
assert( body >= level.armor_index_start );
assert( body <= level.armor_index_end );
body = level.tbl_armor[ body ];
assert( IsDefined( body ) );
head = getLoadoutItemFromDDLStats( i, "head" );
assert( head >= level.armor_index_start );
assert( head <= level.armor_index_end );
head = level.tbl_armor[ head ];
assert( IsDefined( head ) );
special_grenade = getLoadoutItemFromDDLStats ( i, "specialgrenade" );
equipment = getLoadoutItemFromDDLStats ( i, "equipment" );
self.custom_class[i]["primary_grenades"] = level.tbl_weaponIDs[primary_grenade]["reference"]+"_mp";
self.custom_class[i]["primary_grenades_count"] = level.tbl_weaponIDs[primary_grenade]["count"];
self.custom_class[i]["equipment_slot"] = level.tbl_weaponIDs[equipment]["reference"]+"_mp";
self.custom_class[i]["equipment_slot_count"] = level.tbl_weaponIDs[equipment]["count"];
for ( j = 0; j < specialty.size; j++ )
{
specialty[j] = validatePerk( specialty[j], j, i );
}
classbonus = getLoadoutItemFromDDLStats( i, "classbonus" );
specialIndex = 70;
assert( level.tbl_weaponIDs[specialIndex]["reference"] == "concussion_grenade" );
if ( !isDefined( level.tbl_weaponIDs[special_grenade] ) )
special_grenade = specialIndex;
specialGrenadeType = level.tbl_weaponIDs[special_grenade]["reference"];
if ( specialGrenadeType != "weapon_null" )
{
if ( specialGrenadeType != "willy_pete" && specialGrenadeType != "concussion_grenade" && specialGrenadeType != "flash_grenade" && specialGrenadeType != "nightingale" && specialGrenadeType != "tabun_gas" )
{
iprintln( "^1Warning: (" + self.name + ") special grenade " + special_grenade + " is invalid. Setting to concussion grenade." );
special_grenade = specialIndex;
}
for( j = 0; j < specialty.size; j++ )
{
if ( specialGrenadeType == "smoke_grenade" && level.tbl_PerkData[specialty[j]]["reference_full"] == "specialty_specialgrenade" )
{
iprintln( "^1Warning: (" + self.name + ") smoke grenade may not be used with extra special grenades. Setting to concussion grenade." );
special_grenade = specialIndex;
}
}
}
self.custom_class[i]["primary"] = getFullWeaponName( i, "primary" );
self.custom_class[i]["secondary"] = getFullWeaponName( i, "secondary" );
self.custom_class[i]["specialties"] = [];
for ( j = 0; j < specialty.size; j++ )
{
storeSpecialtyData( self, i, specialty[j] );
}
self.custom_class[i]["classbonus"] = classbonus;
self.custom_class[i]["special_grenade"] = level.tbl_weaponIDs[special_grenade]["reference"]+"_mp";
self.custom_class[i]["special_grenade_count"] = level.tbl_weaponIDs[special_grenade]["count"];
self.custom_class[i]["body"] = body;
self.custom_class[i]["head"] = head;
self.custom_class[i]["player_render_options"] = self calcPlayerOptions( i );
self.custom_class[i]["primary_weapon_options"] = self calcWeaponOptions( i, 0 );
self.custom_class[i]["secondary_weapon_options"] = self calcWeaponOptions( i, 1 );
self.cac_initialized = true;
}
}
storeDefaultSpecialtyData( className, specialty )
{
if ( !IsArray( specialty ) )
{
t = specialty;
specialty = [];
specialty[0] = t;
}
for ( i = 0; i < specialty.size; i++ )
{
index = level.default_perk[className].size;
if ( IsString( specialty[i] ) )
{
level.default_perk[className][index] = specialty[i];
}
else
{
level.default_perk[className][index] = level.tbl_PerkData[specialty[i]]["reference_full"];
}
}
}
storeSpecialtyData( player, class_index, specialty )
{
if ( !IsArray( specialty ) )
{
t = specialty;
specialty = [];
specialty[0] = t;
}
for ( i = 0; i < specialty.size; i++ )
{
index = player.custom_class[class_index]["specialties"].size;
player.custom_class[class_index]["specialties"][index] = SpawnStruct();
if ( IsString( specialty[i] ) )
{
player.custom_class[class_index]["specialties"][index].name = specialty[i];
player.custom_class[class_index]["specialties"][index].weaponref   = undefined;
player.custom_class[class_index]["specialties"][index].count = 0;
player.custom_class[class_index]["specialties"][index].group = "specialty";
}
else
{
player.custom_class[class_index]["specialties"][index].name = level.tbl_PerkData[specialty[i]]["reference_full"];
player.custom_class[class_index]["specialties"][index].weaponref   = level.tbl_PerkData[specialty[i]]["reference"];
player.custom_class[class_index]["specialties"][index].count = level.tbl_PerkData[specialty[i]]["count"];
player.custom_class[class_index]["specialties"][index].group = level.tbl_PerkData[specialty[i]]["group"];
}
}
}
isPerkGroup( perkName )
{
return ( IsDefined( perkName ) && IsString( perkName ) );
}
getSlotForPerk( perkIndex )
{
for ( i = 0; i < level.allowedPerks.size; i++ )
{
for ( j = 0; j < level.allowedPerks[i].size; j++ )
{
if ( IsDefined( level.allowedPerks[i][j] ) && level.allowedPerks[i][j] == perkIndex )
{
return i;
}
}
}
return 0;
}
setPerkIcon( classNum, specialtyNumber, perkIndex )
{
if ( classNum < 0 )
{
return;
}
if ( !IsDefined( self.custom_class[classNum]["specialty" + specialtyNumber] ) )
{
self.custom_class[classNum]["specialty" + specialtyNumber] = level.tbl_PerkData[ perkIndex ][ "reference_full" ];
}
}
validatePerkGroup( perkGroup, perkIndex, classNum )
{
perks = StrTok( perkGroup, "|" );
if ( !isdefined( level.specialtyToPerkIndex ) )
{
level.specialtyToPerkIndex = [];
}
if ( ( isDefined( level.tbl_PerkData[ perkIndex ]["count"] ) ) && ( level.tbl_PerkData[ perkIndex ]["count"] == 0 ) )
{
for ( i = 0; i < perks.size; i++ )
{
if ( !isDefined( level.specialtyToPerkIndex[ perks[ i ] ] ) )
{
level.specialtyToPerkIndex[ perks[ i ] ] = perkIndex;
}
else
{
assert( level.specialtyToPerkIndex[ perks[ i ] ] == perkIndex );
}
}
}
return perks;
}
validatePerk( perkIndex, perkSlotIndex, classNum, group )
{
if ( !IsDefined( group ) )
{
group = false;
}
if ( !isDefined( classNum ) )
{
classnum = -1;
}
perkGroup = undefined;
specialtyNumber = perkSlotIndex + 1;
if ( IsDefined( level.tbl_PerkData[ perkIndex ] ) )
{
perkGroup = level.tbl_PerkData[ perkIndex ][ "reference" ];
}
if ( isPerkGroup( perkGroup ) )
{
setPerkIcon( classNum, specialtyNumber, perkIndex );
return validatePerkGroup( perkGroup, perkIndex, classNum );
}
perkIndex = level.perkReferenceToIndex[ "specialty_null" ];
perks = [];
perks[0] = "specialty_null";
setPerkIcon( classNum, specialtyNumber, perkIndex );
return perks;
}
validateKillStreak( killStreakIndex, killStreakSlotIndex )
{
for ( i = 0; i < level.allowedKillStreak[ killStreakSlotIndex ].size; i++ )
{
if ( killStreakIndex == level.allowedKillStreak[ killStreakSlotIndex ][ i ] )
return ( killStreakIndex );
}
return level.killStreakBaseValue;
}
logClassChoice( class, primaryWeapon, specialType, perks )
{
if ( class == self.lastClass )
return;
self logstring( "choseclass: " + class + " weapon: " + primaryWeapon + " special: " + specialType );
for( i=0; i<perks.size; i++ )
self logstring( "perk" + i + ": " + perks[i] );
self.lastClass = class;
}
get_specialtydata( class_num, specialty, specialty_num )
{
cac_reference   = specialty.name;
cac_weaponref   = specialty.weaponref;
cac_group = specialty.group;
cac_count = specialty.count;
assertex( isdefined( cac_group ), "Missing "+specialty.name+"'s group name" );
if( cac_reference == "specialty_twogrenades" && GetDvarInt( #"scr_game_perks" ) )
{
self.custom_class[class_num]["grenades_count"] = 2;
self.custom_class[class_num]["specialgrenades_count"] = 3;
}
if ( cac_group == "specialty" )
{
self.specialty[self.specialty.size] = cac_reference;
}
}
reset_specialty_slots( class_num )
{
self.specialty = [];
self.custom_class[class_num]["inventory"] = "";
self.custom_class[class_num]["inventory_count"] = 0;
self.custom_class[class_num]["inventory_group"] = "";
self.custom_class[class_num]["grenades"] = "";
self.custom_class[class_num]["grenades_count"] = 0;
self.custom_class[class_num]["grenades_group"] = "";
self.custom_class[class_num]["specialgrenades"] = "";
self.custom_class[class_num]["specialgrenades_count"] = 0;
self.custom_class[class_num]["specialgrenades_group"] = "";
}
blackboxClassChoice( primary, secondary, grenades, specialgrenades, equipment )
{
spawnid = getplayerspawnid( self );
bbPrint( "mploadouts: spawnid %d body %s head %s primary %s secondary %s grenade %s special %s equipment %s",
spawnid,
self.cac_body_type,
self.cac_head_type,
primary,
secondary,
grenades,
specialgrenades,
equipment
);
for ( i = 0; i < self.killstreak.size; i++ )
{
bbPrint( "mpkillstreaks: spawnid %d name %s", spawnid, self.killstreak[i] );
}
perks = self GetPerks();
for ( i = 0; i < perks.size; i++ )
{
bbPrint( "mpspecialties: spawnid %d name %s", spawnid, perks[i] );
}
}
giveKillStreaks()
{
if ( !isDefined( self.killstreak ) || !isDefined( self.killstreak[ 0 ] ) || !isDefined( self.killstreak[ 1 ] ) || !isDefined( self.killstreak[ 2 ] ) )
{
setKillstreaks();
}
assert( isDefined( self.killstreak[ 0 ] ) && isDefined( self.killstreak[ 1 ] ) && isDefined( self.killstreak[ 2 ] ) );
}
getFullCustomWeaponName( customClassNum, weaponSlot )
{
assertex( ( ( weaponSlot == "primary" ) || ( weaponSlot == "secondary" ) ), "weaponSlot should be primary or secondary" );
weaponName = "weapon_null";
if ( ( weaponSlot == "primary" ) || ( weaponSlot == "secondary" ) )
{
weaponNum = getCustomClassLoadoutItem ( customClassNum, weaponSlot );
if ( weaponSlot == "primary" )
{
weaponIndex = 3;
assert( level.tbl_weaponIDs[weaponIndex]["reference"] == "m1911" );
if ( weaponNum < 0 || !isDefined( level.tbl_weaponIDs[ weaponNum ] ) )
{
weaponNum = weaponIndex;
}
}
if ( isDefined( level.tbl_weaponIDs[ weaponNum ] ) )
{
attachmenttop = getCustomClassLoadoutItem ( customClassNum, weaponSlot + "attachmenttop" );
attachmentbottom = getCustomClassLoadoutItem ( customClassNum, weaponSlot + "attachmentbottom" );
attachmenttrigger = getCustomClassLoadoutItem ( customClassNum, weaponSlot + "attachmenttrigger" );
attachmentmuzzle = getCustomClassLoadoutItem ( customClassNum, weaponSlot + "attachmentmuzzle" );
topName = getAttachmentString( weaponNum, attachmenttop );
bottomName = getAttachmentString( weaponNum, attachmentbottom );
triggerName = getAttachmentString( weaponNum, attachmenttrigger );
muzzleName = getAttachmentString( weaponNum, attachmentmuzzle );
weaponPrefix = level.tbl_weaponIDs[ weaponNum ][ "reference" ];
if ( bottomName == "dw_" )
{
weaponName = weaponPrefix + bottomName + topName + triggerName + muzzleName + "mp";
}
else
{
weaponName = weaponPrefix + "_" + topName +   bottomName + triggerName + muzzleName + "mp";
}
}
}
return weaponName;
}
loadCustomGameModeClasses( team, class )
{
if( isSubstr( class, "CLASS_CUSTOM" ) || isSubstr(class, "CLASS_PRESTIGE") )
{
class_num = int( class[class.size-1] )-1;
if( -1 == class_num )
class_num = 9;
}
else
{
switch( class )
{
case "CLASS_SMG":
class_num = 0;
break;
case "CLASS_CQB":
class_num = 1;
break;
case "CLASS_ASSAULT":
class_num = 2;
break;
case "CLASS_LMG":
class_num = 3;
break;
default:
class_num = 4;
break;
}
}
assert( class_num >= 0 && class_num < 10 );
for( i = 0; i < 10; i ++ )
{
primary_grenade = getCustomClassLoadoutItem ( i, "primarygrenade" );
primary_num = getCustomClassLoadoutItem ( i, "primary" );
specialty = [];
specialty[0] = getCustomClassLoadoutItem ( i, "specialty1" );
specialty[1] = getCustomClassLoadoutItem ( i, "specialty2" );
specialty[2] = getCustomClassLoadoutItem ( i, "specialty3" );
body = getCustomClassLoadoutItem( i, "body" );
body = level.tbl_armor[ body ];
assert( IsDefined( body ) );
head = getCustomClassLoadoutItem( i, "head" );
head = level.tbl_armor[ head ];
assert( IsDefined( head ) );
special_grenade = getCustomClassLoadoutItem ( i, "specialgrenade" );
equipment = getCustomClassLoadoutItem ( i, "equipment" );
self.custom_class[i]["player_render_options"] = self calcPlayerOptions( i );
self.custom_class[i]["primary_weapon_options"] = self calcWeaponOptions( i, 0 );
self.custom_class[i]["secondary_weapon_options"] = self calcWeaponOptions( i, 1 );
self.custom_class[i]["primary_grenades"] = level.tbl_weaponIDs[primary_grenade]["reference"]+"_mp";
self.custom_class[i]["primary_grenades_count"] = 1;
self.custom_class[i]["equipment_slot"] = level.tbl_weaponIDs[equipment]["reference"]+"_mp";
self.custom_class[i]["equipment_slot_count"] = 1;
for ( j = 0; j < specialty.size; j++ )
{
specialty[j] = validatePerk( specialty[j], j, i );
}
classbonus = getCustomClassLoadoutItem( i, "classbonus" );
specialIndex = 70;
assert( level.tbl_weaponIDs[specialIndex]["reference"] == "concussion_grenade" );
if ( !isDefined( level.tbl_weaponIDs[special_grenade] ) )
special_grenade = specialIndex;
specialGrenadeType = level.tbl_weaponIDs[special_grenade]["reference"];
if ( specialGrenadeType != "weapon_null" )
{
if ( specialGrenadeType != "willy_pete" && specialGrenadeType != "concussion_grenade" && specialGrenadeType != "flash_grenade" && specialGrenadeType != "nightingale" && specialGrenadeType != "tabun_gas" )
{
iprintln( "^1Warning: (" + self.name + ") special grenade " + special_grenade + " is invalid. Setting to concussion grenade." );
special_grenade = specialIndex;
}
for( j = 0; j < specialty.size; j++ )
{
if ( specialGrenadeType == "smoke_grenade" && level.tbl_PerkData[specialty[j]]["reference_full"] == "specialty_specialgrenade" )
{
iprintln( "^1Warning: (" + self.name + ") smoke grenade may not be used with extra special grenades. Setting to concussion grenade." );
special_grenade = specialIndex;
}
}
}
self.custom_class[i]["primary"] = getFullCustomWeaponName( i, "primary" );
self.custom_class[i]["secondary"] = getFullCustomWeaponName( i, "secondary" );
self.custom_class[i]["specialties"] = [];
for ( j = 0; j < specialty.size; j++ )
{
storeSpecialtyData( self, i, specialty[j] );
}
self.custom_class[i]["classbonus"] = classbonus;
self.custom_class[i]["special_grenade"] = level.tbl_weaponIDs[special_grenade]["reference"]+"_mp";
self.custom_class[i]["special_grenade_count"] = level.tbl_weaponIDs[special_grenade]["count"];
self.custom_class[i]["body"] = body;
self.custom_class[i]["head"] = head;
self.cac_initialized = true;
self.custom_class[i]["health"] = getCustomClassModifier( i, "health" );
self.custom_class[i]["healthRegeneration"] = getCustomClassModifier( i, "healthRegeneration" );
self.custom_class[i]["healthVampirism"] = getCustomClassModifier( i, "healthVampirism" );
self.custom_class[i]["movementSpeed"] = getCustomClassModifier( i, "movementSpeed" );
self.custom_class[i]["movementSprintSpeed"] = getCustomClassModifier( i, "movementSprintSpeed" );
self.custom_class[i]["damage"] = getCustomClassModifier( i, "damage" );
self.custom_class[i]["damageExplosive"] = getCustomClassModifier( i, "damageExplosive" );
}
return class_num;
}
applyCustomClassModifiers()
{
self maps\mp\gametypes\_customClasses::setMovementSpeedModifier();
newHealth = self maps\mp\gametypes\_customClasses::getModifiedHealth();
if( newHealth != 100 )
{
self.maxhealth = newHealth;
self.health = self.maxhealth;
}
}
getRandomValidCustomClass( team, class )
{
classList = [];
for( i=0; i < 10; i++ )
{
classTeam = getcustomclassmodifier( i, "team" );
active = getcustomclassmodifier( i, "active" );
if( active > 0 && ( classTeam == 1 || ( classTeam == 2 && team == "axis" ) || ( classTeam == 3 && team == "allies" ) ) )
{
classList[ classList.size ] = "CLASS_CUSTOM" + (i+1);
}
}
return array_randomize( classList )[0];
}
listWeaponAttachments( weaponName, player )
{
if ( isSubStr( weaponName, "dw_mp" ) )
{
attachments = [];
attachments[ 0 ] = [];
attachments[ 0 ] [ "name" ] = "dw";
attachments[ 0 ] [ "point" ] = "muzzle";
if ( isDefined( player ) )
{
if ( player getDstat( "purchasedAttachments", "dw" ) )
{
attachments[ 0 ][ "owned" ] = true;
}
}
return attachments;
}
subStrings = strtok( weaponName, "_" );
numSubStrings = subStrings.size;
numAttachments = 0;
attachments = [];
for ( currString = 0; currString < numSubStrings; currString++ )
{
attachPoint = tableLookup( "mp/attachmenttable.csv", 4, subStrings[ currString ], 1 );
if ( attachPoint == "" )
{
continue;
}
attachments[ numAttachments ] = [];
attachments[ numAttachments ] [ "name" ] = subStrings[ currString ];
attachments[ numAttachments ] [ "point" ] = attachPoint;
if ( isDefined( player ) )
{
if ( player getDstat( "purchasedAttachments", subStrings[ currString ] ) )
{
attachments[ numAttachments ][ "owned" ] = true;
}
}
numAttachments++;
}
return attachments;
}
initStaticWeaponsTime()
{
self.staticWeaponsStartTime = getTime();
}
initWeaponAttachments( weaponName )
{
if ( self is_bot() )
{
return;
}
self.currentWeaponStartTime = getTime();
self.currentWeapon = weaponName;
self.currWeaponItemIndex = getBaseWeaponItemIndex( weaponName );
self.currentAttachments = listWeaponAttachments( weaponName, self );
}
isEquipmentAllowed( equipment )
{
if ( GetDvarInt( #"scr_disable_equipment" ) )
return false;
if( equipment == "" )
return false;
if ( equipment == "weapon_null_mp" )
return false;
if ( equipment == "camera_spike_mp" && self IsSplitScreen() )
return false;
if ( equipment == level.tacticalInsertionWeapon && GetDvarInt( #"scr_disable_tacinsert" ) )
return false;
return true;
}
giveLoadout( team, class )
{
pixbeginevent("giveLoadout");
self takeAllWeapons();
primaryIndex = 0;
self.specialty = [];
self.killstreak = [];
primaryWeapon = undefined;
self notify( "give_map" );
self GiveWeapon( "knife_mp" );
if ( self maps\mp\gametypes\_copycat::copycat_in_use() )
{
self maps\mp\gametypes\_copycat::copycat_give_loadout();
}
else if( ( isSubstr( class, "CLASS_CUSTOM" ) || isSubstr(class, "CLASS_PRESTIGE") || maps\mp\gametypes\_customClasses::isUsingCustomGameModeClasses() ) )
{
pixbeginevent("custom class");
if( !( maps\mp\gametypes\_customClasses::isUsingCustomGameModeClasses() ) )
{
self cac_getdata();
class_num = int( class[class.size-1] )-1;
if( -1 == class_num )
class_num = 9;
}
else
{
if( self is_bot() )
{
class = getRandomValidCustomClass( team, class );
self setClass( class );
}
class_num = self loadCustomGameModeClasses( team, class );
}
self.class_num = class_num;
assertex( isdefined( self.custom_class[class_num]["primary"] ), "Custom class "+class_num+": primary weapon setting missing" );
assertex( isdefined( self.custom_class[class_num]["secondary"] ), "Custom class "+class_num+": secondary weapon setting missing" );
self reset_specialty_slots( class_num );
self.custom_class[class_num]["grenades"] = self.custom_class[class_num]["primary_grenades"];
self.custom_class[class_num]["grenades_count"] = self.custom_class[class_num]["primary_grenades_count"];
self.custom_class[class_num]["specialgrenades"] = self.custom_class[class_num]["special_grenade"];
self.custom_class[class_num]["specialgrenades_count"] = self.custom_class[class_num]["special_grenade_count"];
self.custom_class[class_num]["equipment"] = self.custom_class[class_num]["equipment_slot"];
self.custom_class[class_num]["equipment_count"] = self.custom_class[class_num]["equipment_slot_count"];
for ( i = 0; i < self.custom_class[class_num]["specialties"].size; i++ )
{
self get_specialtydata( class_num, self.custom_class[class_num]["specialties"][i], i );
}
self register_perks();
giveKillStreaks();
classbonus_data = tableLookup( "mp/classBonusTable.csv", 0, self.custom_class[class_num]["classbonus"], 1 );
specialties = StrTok( classbonus_data, "|" );
for ( i = 0; i < specialties.size; i++ )
{
self SetPerk( specialties[i] );
}
if ( isDefined( self.pers["weapon"] ) && self.pers["weapon"] != "none" )
weapon = self.pers["weapon"];
else
weapon = self.custom_class[class_num]["primary"];
primaryAttachmentsAllowed = true;
if ( GetDvarInt( #"scr_disable_attachments" ) )
{
primaryAttachmentsAllowed = false;
}
else if ( GetDvarInt( #"scr_game_perks" ) == false )
{
classPrimaryAttachments = listWeaponAttachments( weapon, self );
if ( classPrimaryAttachments.size > 1 )
{
primaryAttachmentsAllowed = false;
}
}
if ( primaryAttachmentsAllowed == false )
{
weaponNum = getLoadoutItemFromDDLStats( class_num, "primary" );
weapon = level.tbl_weaponIDs[ weaponNum ][ "reference" ] + "_mp";
}
sidearm = self.custom_class[class_num]["secondary"];
if ( GetDvarInt( #"scr_disable_attachments" ) )
{
weaponNum = getLoadoutItemFromDDLStats( class_num, "secondary" );
sidearm = level.tbl_weaponIDs[ weaponNum ][ "reference" ] + "_mp";
}
self GiveWeapon( sidearm, 0, int( self.custom_class[class_num]["secondary_weapon_options"] ) );
if ( self cac_hasSpecialty( "specialty_extraammo" ) )
self giveMaxAmmo( sidearm );
if( maps\mp\gametypes\_weapons::isPistol( sidearm ) )
self setSpawnWeapon( sidearm );
primaryWeapon = weapon;
assertex( isdefined( self.custom_class[class_num]["primary_weapon_options"] ), "Player's weapon options is not defined, it should be at least initialized to 0" );
primaryTokens = strtok( primaryWeapon, "_" );
self.pers["primaryWeapon"] = primaryTokens[0];
self GiveWeapon( weapon, 0, int( self.custom_class[class_num]["primary_weapon_options"] ) );
self SetPlayerRenderOptions( int( self.custom_class[class_num]["player_render_options"] ) );
if ( self cac_hasSpecialty( "specialty_extraammo" ) )
self giveMaxAmmo( weapon );
self setSpawnWeapon( weapon );
secondaryWeapon = self.custom_class[class_num]["inventory"];
if ( secondaryWeapon != "" )
{
self GiveWeapon( secondaryWeapon );
self setWeaponAmmoOverall( secondaryWeapon, self.custom_class[class_num]["inventory_count"] );
self SetActionSlot( 3, "weapon", secondaryWeapon );
self SetActionSlot( 4, "" );
}
else
{
self SetActionSlot( 3, "altMode" );
self SetActionSlot( 4, "" );
}
grenadeTypePrimary = self.custom_class[class_num]["grenades"];
if ( grenadeTypePrimary != "" && grenadeTypePrimary != "weapon_null_mp" )
{
grenadeCount = self.custom_class[class_num]["grenades_count"];
self GiveWeapon( grenadeTypePrimary );
self SetWeaponAmmoClip( grenadeTypePrimary, grenadeCount );
self SwitchToOffhand( grenadeTypePrimary );
isFrag = self setOffhandPrimaryClass( grenadeTypePrimary );
if( isFrag != "frag" )
{
self GiveWeapon( level.weapons["frag"] );
self SetWeaponAmmoClip( level.weapons["frag"], 0 );
}
}
else
{
self GiveWeapon( level.weapons["frag"] );
self SetWeaponAmmoClip( level.weapons["frag"], 0 );
}
grenadeTypeSecondary = self.custom_class[class_num]["specialgrenades"];
if ( grenadeTypeSecondary != "" && grenadeTypeSecondary != "weapon_null_mp")
{
grenadeCount = self.custom_class[class_num]["specialgrenades_count"];
self setOffhandSecondaryClass( grenadeTypeSecondary );
self giveWeapon( grenadeTypeSecondary );
self SetWeaponAmmoClip( grenadeTypeSecondary, grenadeCount );
}
equipment_weapon = self.custom_class[class_num]["equipment"];
if ( isEquipmentAllowed( equipment_weapon ) )
{
self GiveWeapon( equipment_weapon );
self setWeaponAmmoOverall( equipment_weapon, self.custom_class[class_num]["equipment_count"] );
self SetActionSlot( 1, "weapon", equipment_weapon );
}
self.cac_body_type = self.custom_class[ class_num ][ "body" ];
self.cac_head_type = self maps\mp\gametypes\_armor::get_default_head();
self.cac_hat_type = "none";
self maps\mp\gametypes\_armor::set_player_model();
self initStaticWeaponsTime();
self thread initWeaponAttachments( primaryWeapon );
self thread blackboxClassChoice( primaryWeapon, sidearm, grenadeTypePrimary, grenadeTypeSecondary, equipment_weapon );
}
else if ( self is_bot() )
{
pixbeginevent("bot");
self maps\mp\gametypes\_bot::bot_give_loadout();
pixendevent();
}
else
{
pixbeginevent("default class");
assertex( isdefined(self.pers["class"]), "Player during spawn and loadout got no class!" );
selected_class = self.pers["class"];
specialty_size = level.default_perk[selected_class].size;
for( i = 0; i < specialty_size; i++ )
{
if( isdefined( level.default_perk[selected_class][i] ) && level.default_perk[selected_class][i] != "" )
self.specialty[self.specialty.size] = level.default_perk[selected_class][i];
}
assertex( isdefined( self.specialty ) && self.specialty.size > 0, "Default class: " + self.pers["class"] + " is missing specialties " );
self register_perks();
giveKillStreaks();
if ( isdefined( self.pers["primary"] ) )
{
primaryIndex = self.pers["primary"];
}
if ( isDefined( self.pers["weapon"] ) && self.pers["weapon"] != "none" )
{
weapon = self.pers["weapon"];
}
else
{
weapon = level.classWeapons[team][class][primaryIndex];
}
sidearm = level.classSidearm[team][class];
if ( sidearm != "" && sidearm != "weapon_null_mp" )
{
println( "^5GiveWeapon( " + sidearm + " ) -- sidearm" );
self GiveWeapon( sidearm );
if ( self cac_hasSpecialty( "specialty_extraammo" ) )
self giveMaxAmmo( sidearm );
if( maps\mp\gametypes\_weapons::isPistol( sidearm ) )
self setSpawnWeapon( sidearm );
}
primaryWeapon = weapon;
primaryTokens = strtok( primaryWeapon, "_" );
self.pers["primaryWeapon"] = primaryTokens[0];
println( "^5GiveWeapon( " + weapon + " ) -- weapon" );
self GiveWeapon( weapon );
if( self cac_hasSpecialty( "specialty_extraammo" ) )
self giveMaxAmmo( weapon );
self setSpawnWeapon( weapon );
self SetActionSlot( 3, "altMode" );
self SetActionSlot( 4, "" );
grenadeTypePrimary = level.classGrenades[class]["primary"]["type"];
if ( grenadeTypePrimary != "" && grenadeTypePrimary != "weapon_null_mp" )
{
grenadeCount = level.classGrenades[class]["primary"]["count"];
println( "^5GiveWeapon( " + grenadeTypePrimary + " ) -- grenadeTypePrimary" );
self GiveWeapon( grenadeTypePrimary );
self SetWeaponAmmoClip( grenadeTypePrimary, grenadeCount );
self SwitchToOffhand( grenadeTypePrimary );
}
grenadeTypeSecondary = level.classGrenades[class]["secondary"]["type"];
if ( grenadeTypeSecondary != "" && grenadeTypeSecondary != "weapon_null_mp" )
{
grenadeCount = level.classGrenades[class]["secondary"]["count"];
self setOffhandSecondaryClass( grenadeTypeSecondary );
println( "^5GiveWeapon( " + grenadeTypeSecondary + " ) -- grneadeTypeSecondary" );
self giveWeapon( grenadeTypeSecondary );
self SetWeaponAmmoClip( grenadeTypeSecondary, grenadeCount );
}
equipment_weapon = level.default_equipment[ class ][ "type" ];
if ( isEquipmentAllowed( equipment_weapon ) )
{
self GiveWeapon( equipment_weapon );
self setWeaponAmmoOverall( equipment_weapon, level.default_equipment[ class ][ "count" ] );
self SetActionSlot( 1, "weapon", equipment_weapon );
}
self.cac_body_type = level.default_armor[class]["body"];
self.cac_head_type = self maps\mp\gametypes\_armor::get_default_head();
self.cac_hat_type = "none";
self maps\mp\gametypes\_armor::set_player_model();
self initStaticWeaponsTime();
self thread initWeaponAttachments( primaryWeapon );
self thread blackboxClassChoice( primaryWeapon, sidearm, grenadeTypePrimary, grenadeTypeSecondary, equipment_weapon );
pixendevent();
}
if( maps\mp\gametypes\_customClasses::isUsingCustomGameModeClasses() )
{
self applyCustomClassModifiers();
}
if( isDefined( self.movementSpeedModifier ) )
{
self setMoveSpeedScale( self.movementSpeedModifier * self getMoveSpeedScale() );
}
if ( isDefined( level.giveCustomLoadout ) )
{
spawnWeapon = self [[level.giveCustomLoadout]]();
if ( IsDefined( spawnWeapon ) )
self thread initWeaponAttachments( spawnWeapon );
}
self cac_selector();
pixendevent();
}
setWeaponAmmoOverall( weaponname, amount )
{
if ( isWeaponClipOnly( weaponname ) )
{
self setWeaponAmmoClip( weaponname, amount );
}
else
{
self setWeaponAmmoClip( weaponname, amount );
diff = amount - self getWeaponAmmoClip( weaponname );
assert( diff >= 0 );
self setWeaponAmmoStock( weaponname, diff );
}
}
onPlayerConnecting()
{
for(;;)
{
level waittill( "connecting", player );
if ( !level.oldschool )
{
if ( !isDefined( player.pers["class"] ) )
{
player.pers["class"] = "";
}
player.class = player.pers["class"];
player.lastClass = "";
}
player.detectExplosives = false;
player.bombSquadIcons = [];
player.bombSquadIds = [];
player.reviveIcons = [];
player.reviveIds = [];
}
}
fadeAway( waitDelay, fadeDelay )
{
wait waitDelay;
self fadeOverTime( fadeDelay );
self.alpha = 0;
}
setClass( newClass )
{
self.curClass = newClass;
}
initPerkDvars()
{
level.cac_armorpiercing_data = cac_get_dvar_int( "perk_armorpiercing", "40" ) / 100;
level.cac_bulletdamage_data = cac_get_dvar_int( "perk_bulletDamage", "35" );
level.cac_fireproof_data = cac_get_dvar_int( "perk_fireproof", "95" );
level.cac_armorvest_data = cac_get_dvar_int( "perk_armorVest", "80" );
level.cac_explosivedamage_data = cac_get_dvar_int( "perk_explosiveDamage", "25" );
level.cac_flakjacket_data = cac_get_dvar_int( "perk_flakJacket", "35" );
level.cac_flakjacket_hardcore_data = cac_get_dvar_int( "perk_flakJacket_hardcore", "9" );
}
cac_selector()
{
self thread maps\mp\_tacticalinsertion::postLoadout();
perks = self.specialty;
self.detectExplosives = false;
for( i=0; i<perks.size; i++ )
{
perk = perks[i];
if( perk == "specialty_detectexplosive" )
self.detectExplosives = true;
}
maps\mp\gametypes\_weaponobjects::setupBombSquad();
self.canreviveothers = true;
maps\mp\_laststand::setupRevive();
}
register_perks()
{
perks = self.specialty;
self clearPerks();
for( i=0; i<perks.size; i++ )
{
perk = perks[i];
if ( perk == "specialty_null" || isSubStr( perk, "specialty_weapon_" ) || perk == "weapon_null" )
continue;
if ( !GetDvarInt( #"scr_game_perks" ) )
continue;
self setPerk( perk );
}
}
cac_get_dvar_int( dvar, def )
{
return int( cac_get_dvar( dvar, def ) );
}
cac_get_dvar( dvar, def )
{
if ( getdvar( dvar ) != "" )
{
return getdvarfloat( dvar );
}
else
{
setdvar( dvar, def );
return def;
}
}
cac_hasSpecialty( perk_reference )
{
return_value = self hasPerk( perk_reference );
return return_value;
}
cac_modified_vehicle_damage( victim, attacker, damage, meansofdeath, weapon, inflictor )
{
if( !isdefined( victim) || !isdefined( attacker ) || !isplayer( attacker ) )
return damage;
if( !isdefined( damage ) || !isdefined( meansofdeath ) || !isdefined( weapon ) )
return damage;
old_damage = damage;
final_damage = damage;
if( attacker cac_hasSpecialty( "specialty_bulletdamage" ) && isPrimaryDamage( meansofdeath ) )
{
final_damage = damage*(100+level.cac_bulletdamage_data)/100;
}
else if( attacker cac_hasSpecialty( "specialty_explosivedamage" ) && isPlayerExplosiveWeapon( weapon, meansofdeath ) )
{
final_damage = damage*(100+level.cac_explosivedamage_data)/100;
}
else
{
final_damage = old_damage;
}
return int( final_damage );
}
cac_modified_damage( victim, attacker, damage, meansofdeath, weapon, inflictor, hitloc )
{
if( !isdefined( victim) || !isdefined( attacker ) || !isplayer( attacker ) || !isplayer( victim ) )
return damage;
if( !isdefined( damage ) || !isdefined( meansofdeath ) )
return damage;
if( meansofdeath == "" )
return damage;
if( !IsDefined(hitloc) || hitloc == "" )
hitloc = "torso_upper";
old_damage = damage;
final_damage = damage;
if( ( isplayer( attacker ) && attacker cac_hasSpecialty( "specialty_bulletdamage" ) ) && isPrimaryDamage( meansofdeath ) )
{
if( isdefined( victim ) && isPlayer( victim ) && victim cac_hasSpecialty( "specialty_armorvest" ) && !isHeadDamage( hitloc ) )
{
final_damage = old_damage;
}
else
{
final_damage = damage*(100+level.cac_bulletdamage_data)/100;
}
}
else if( victim cac_hasSpecialty( "specialty_armorvest" ) && isPrimaryDamage( meansofdeath ) && !isHeadDamage( hitloc ) )
{
final_damage = damage*(level.cac_armorvest_data *.01);
}
else if ( victim cac_hasSpecialty ("specialty_fireproof") && isFireDamage( weapon, meansofdeath ) )
{
level.cac_fireproof_data = cac_get_dvar_int( "perk_fireproof", level.cac_fireproof_data );
final_damage = damage*((100-level.cac_fireproof_data)/100);
}
else if( attacker cac_hasSpecialty( "specialty_explosivedamage" ) && isPlayerExplosiveWeapon( weapon, meansofdeath ) )
{
final_damage = damage*(100+level.cac_explosivedamage_data)/100;
}
else if (victim cac_hasSpecialty( "specialty_flakjacket" ) && !isdefined( inflictor.stucktoplayer ) && meansofdeath != "MOD_PROJECTILE" && weapon != "briefcase_bomb_mp" && weapon != "tabun_gas_mp" && weapon != "concussion_grenade_mp" && weapon != "flash_grenade_mp" && weapon != "willy_pete_mp" )
{
if ( isExplosiveDamage( meansofdeath, weapon ) || isSubStr( weapon, "explodable_barrel" ) || isSubStr( weapon, "destructible_car" ))
{
level.cac_flakjacket_data = cac_get_dvar_int( "perk_flakJacket", level.cac_flakjacket_data );
if( level.hardcoreMode )
{
level.cac_flakjacket_data = cac_get_dvar_int( "perk_flakJacket_hardcore", level.cac_flakjacket_hardcore_data );
}
if ( isdefined( attacker ) && isplayer( attacker) )
{
if ( level.teambased )
{
if ( attacker.team != victim.team )
{
victim thread maps\mp\_properks::flakjacketProtected();
}
}
else
{
if ( attacker != victim )
{
victim thread maps\mp\_properks::flakjacketProtected();
}
}
}
final_damage = int( old_damage * ( level.cac_flakjacket_data / 100 ) );
}
}
else
{
final_damage = old_damage;
}
if ( GetDvar( #"scr_disable_cac_2" ) == "" )
{
final_damage = victim maps\mp\gametypes\_armor::get_armor_damage( meansofdeath, weapon, hitloc, final_damage );
}
return int( final_damage );
}
isExplosiveDamage( meansofdeath, weapon )
{
explosivedamage = "MOD_GRENADE MOD_GRENADE_SPLASH MOD_PROJECTILE_SPLASH MOD_EXPLOSIVE";
if( isSubstr( explosivedamage, meansofdeath ) )
return true;
return false;
}
isPrimaryDamage( meansofdeath )
{
if( meansofdeath == "MOD_RIFLE_BULLET" || meansofdeath == "MOD_PISTOL_BULLET" )
return true;
return false;
}
isFireDamage( weapon, meansofdeath )
{
if ( ( isSubStr( weapon, "flame" ) || isSubStr( weapon, "napalmblob_" ) || isSubStr( weapon, "napalm_" ) ) && ( meansofdeath == "MOD_BURNED" || meansofdeath == "MOD_GRENADE" || meansofdeath == "MOD_GRENADE_SPLASH" ) )
return true;
if( GetSubStr( weapon, 0, 3 ) == "ft_" )
return true;
return false;
}
isPlayerExplosiveWeapon( weapon, meansofdeath )
{
if ( !isExplosiveDamage( meansofdeath, weapon ) )
return false;
if ( weapon == "artillery_mp" || weapon == "airstrike_mp" || weapon == "napalm_mp" || weapon == "mortar_mp" || weapon == "hind_ffar_mp" || weapon == "cobra_ffar_mp" )
return false;
if ( issubstr(weapon, "turret" ) )
return false;
return true;
}
isHeadDamage( hitloc )
{
return ( hitloc == "helmet" || hitloc == "head" || hitloc == "neck" );
}


maps/mp/_cameraspike.gsc

#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
init()
{
level._effect["cameraspike_enemy_light"] = loadfx( "misc/fx_equip_light_red" );
level._effect["cameraspike_friendly_light"] = loadfx( "misc/fx_equip_light_green" );
}
createCameraSpikeWatcher()
{
watcher = self maps\mp\gametypes\_weaponobjects::createUseWeaponObjectWatcher( "camera_spike", "camera_spike_mp", self.team );
watcher.onSpawn = ::onSpawnCameraSpike;
watcher.detonate = ::cameraSpikeDetonate;
watcher.stun = maps\mp\gametypes\_weaponobjects::weaponStun;
watcher.stunTime = 5;
watcher.reconModel = "t5_weapon_camera_spike_world_detect";
watcher.hackable = true;
watcher.onDamage = ::watchCameraSpikeDamage;
}
onSpawnCameraSpike( watcher, player )
{
self endon( "death" );
self thread maps\mp\gametypes\_weaponobjects::onSpawnUseWeaponObject( watcher, player );
if ( IsDefined( self.cameraHead ) )
{
self.cameraHead maps\mp\gametypes\_weaponobjects::attachReconModel( "t5_weapon_camera_head_world_detect", player );
self changeOwner( self.prevOwner, player );
return;
}
player.cameraSpike = self;
player.cameraSpikeToggle = true;
player toggleCameraSpike( player.cameraSpikeToggle );
self SetOwner( player );
self.owner = player;
self SetTeam( player.team );
self.prevOwner = player;
playerAngles = player GetPlayerAngles();
forward = AnglesToForward( playerAngles );
eye = player GetEye();
trace = BulletTrace( eye + vector_scale( forward, 10 ), eye + vector_scale( forward, 10000 ), false, player, false, true );
self.cameraHead = Spawn( "script_model", self GetTagOrigin( "tag_leg_2" ) );
self.cameraHead SetModel( "t5_weapon_camera_head_world" );
self.cameraHead.angles = self.angles;
self.cameraHead linkto( self );
self.cameraHead maps\mp\gametypes\_weaponobjects::attachReconModel( "t5_weapon_camera_head_world_detect", player );
self.cameraHead SetOwner( player );
self.cameraHead.owner = player;
self.cameraHead SetTeam( player.team );
self.cameraHead thread watch_camera_head_damage( watcher, self );
player maps\mp\gametypes\_globallogic_score::setWeaponStat( "camera_spike_mp", 1, "used" );
self thread watchStun();
self thread watchToggle( player );
self thread watchShutdown( player );
self thread adjustPosition( trace["position"] );
}
adjustPosition( viewTargetPos )
{
self endon( "death" );
self waitTillNotMoving();
if ( IsDefined( self.owner ) )
{
if ( self.owner IsOnGround() )
self.origin = self.owner.origin;
self thread adjustCameraDirection( viewTargetPos );
}
}
changeOwner( lastOwner, newOwner )
{
if ( newOwner == lastOwner )
return;
self notify( "owner_changed" );
lastOwner.cameraSpike = undefined;
lastOwner.cameraSpikeToggle = false;
lastOwner toggleCameraSpike( lastOwner.cameraSpikeToggle );
newOwner.cameraSpike = self;
newOwner.cameraSpikeToggle = true;
newOwner toggleCameraSpike( newOwner.cameraSpikeToggle );
self.prevOwner = newOwner;
self.cameraHead SetOwner( newOwner );
self.cameraHead.owner = newOwner;
self.cameraHead SetTeam( newOwner.team );
self SetOwner( newOwner );
self.owner = newOwner;
self SetTeam( newOwner.team );
}
cameraSpikeDetonate( attacker )
{
PlayFX( level._equipment_explode_fx, self.origin );
PlaySoundAtPosition ( "dst_equipment_destroy", self.origin );
self destroyEnt();
}
destroyEnt()
{
self delete();
}
adjustCameraDirection( point )
{
self endon( "death" );
self.cameraHead unlink();
origin = self GetTagOrigin( "tag_leg_2" );
direction = point - origin;
self.cameraHead.origin = origin;
self.cameraHead.angles = vectortoangles( direction );
self.cameraHead SetClientFlag( level.const_flag_camera_spike );
self.cameraHead linkto( self );
}
watchStun()
{
self endon( "death" );
self.cameraHead endon( "death" );
for ( ;; )
{
self waittill( "stunned" );
if ( IsDefined( self.cameraHead ) )
{
self.cameraHead.stunned = true;
self.cameraHead SetClientFlag( level.const_flag_stunned );
}
self waittill( "not_stunned" );
if ( IsDefined( self.cameraHead ) )
{
self.cameraHead.stunned = false;
self.cameraHead ClearClientFlag( level.const_flag_stunned );
}
}
}
watchShutdown( player )
{
cameraHead = self.cameraHead;
self waittill( "death" );
if ( isDefined( cameraHead ) )
cameraHead delete();
if ( isDefined( player ) )
{
player.cameraSpikeToggle = false;
player.cameraSpike = undefined;
player toggleCameraSpike( player.cameraSpikeToggle );
}
}
watchToggle( player )
{
self endon( "death" );
self endon( "owner_changed" );
player endon( "disconnect" );
while ( true )
{
if ( player ActionSlotOneButtonPressed() && !player IsRemoteControlling() )
{
player.cameraSpikeToggle = !player.cameraSpikeToggle;
player toggleCameraSpike( player.cameraSpikeToggle );
while ( player ActionSlotOneButtonPressed() )
wait 0.05;
}
wait 0.05;
}
}
watchCameraSpikeDamage( watcher )
{
self endon( "death" );
self endon( "hacked" );
self SetCanDamage( true );
damageMax = 100;
if ( !self maps\mp\gametypes\_weaponobjects::isHacked() )
{
self.damageTaken = 0;
}
while( true )
{
self.maxhealth = 100000;
self.health = self.maxhealth;
self waittill( "damage", damage, attacker, direction, point, type, tagName, modelName, partname, weapon, iDFlags );
if( !isdefined( attacker ) || !isplayer( attacker ) )
continue;
if( maps\mp\gametypes\_globallogic_player::doDamageFeedback( weapon, attacker ) )
attacker maps\mp\gametypes\_damagefeedback::updateDamageFeedback( false );
if( damage < 5 )
{
if( watcher.stunTime > 0 )
{
self thread maps\mp\gametypes\_weaponobjects::stunStart( watcher, watcher.stunTime );
}
continue;
}
if( isPlayer( attacker ) && level.teambased && isDefined( attacker.team ) && self.owner.team == attacker.team && attacker != self.owner )
continue;
if( ( type == "MOD_MELEE" ) )
{
self.damageTaken = damageMax;
}
else
{
self.damageTaken += damage;
}
if( self.damageTaken >= damageMax )
{
attacker maps\mp\_properks::shotEquipment( self.owner, iDFlags );
watcher thread maps\mp\gametypes\_weaponobjects::waitAndDetonate( self, 0.0, attacker );
}
}
}
watch_camera_head_damage( watcher, body )
{
self endon( "death" );
body endon( "death" );
self SetCanDamage( true );
while( true )
{
self.maxhealth = 100000;
self.health = self.maxhealth;
self waittill( "damage", damage, attacker, direction, point, type, tagName, modelName, partname, weapon, iDFlags );
body notify( "damage", damage, attacker, direction, point, type, tagName, modelName, partname, weapon, iDFlags );
}
}
toggleCameraSpike( enable )
{
self endon( "disconnect" );
self SetCameraSpikeActive( enable );
}


maps/mp/_airsupport.gsc

#include maps\mp\_utility;
#include common_scripts\utility;
initAirsupport()
{
if ( !isdefined( level.airsupportHeightScale ) )
level.airsupportHeightScale = 1;
level.airsupportHeightScale = getDvarIntDefault( #"scr_airsupportHeightScale", level.airsupportHeightScale );
level.noFlyZones = [];
level.noFlyZones = GetEntArray("no_fly_zone","targetname");
airsupport_heights = getstructarray("air_support_height","targetname");
if ( airsupport_heights.size > 1 )
{
error( "Found more then one 'air_support_height' structs in the map" );
}
airsupport_heights = GetEntArray("air_support_height","targetname");
if ( airsupport_heights.size > 0 )
{
error( "Found an entity in the map with an 'air_support_height' targetname.  There should be only structs." );
}
heli_height_meshes = GetEntArray("heli_height_lock","classname");
if ( heli_height_meshes.size > 1 )
{
error( "Found more then one 'heli_height_lock' classname in the map" );
}
}
finishHardpointLocationUsage( location, usedCallback )
{
self notify( "used" );
wait ( 0.05 );
return self [[usedCallback]]( location );
}
finishDualHardpointLocationUsage( locationStart, locationEnd, usedCallback )
{
self notify( "used" );
wait ( 0.05 );
return self [[usedCallback]]( locationStart, locationEnd );
}
endSelectionOnGameEnd()
{
self endon( "death" );
self endon( "disconnect" );
self endon( "cancel_location" );
self endon( "used" );
level waittill( "game_ended" );
self notify( "game_ended" );
}
endSelectionThink()
{
assert( IsPlayer( self ) );
assert( IsAlive( self ) );
assert( IsDefined( self.selectingLocation ) );
assert( self.selectingLocation == true );
self thread endSelectionOnGameEnd();
event = self waittill_any_return( "death", "disconnect", "cancel_location", "game_ended", "used", "weapon_change" );
if ( event != "disconnect" )
{
self endLocationSelection();
self.selectingLocation = undefined;
}
if ( event != "used" )
{
self notify( "confirm_location", undefined, undefined );
}
}
deleteAfterTime( time )
{
self endon ( "death" );
wait ( time );
self delete();
}
stopLoopSoundAfterTime( time )
{
self endon ( "death" );
wait ( time );
self stoploopsound( 2 );
}
calculateFallTime( flyHeight )
{
gravity = GetDvarInt( #"bg_gravity" );
time = sqrt( (2 * flyHeight) / gravity );
return time;
}
calculateReleaseTime( flyTime, flyHeight, flySpeed, bombSpeedScale )
{
falltime = calculateFallTime( flyHeight );
bomb_x = (flySpeed * bombSpeedScale) * falltime;
release_time = bomb_x / flySpeed;
return ( (flyTime * 0.5) - release_time);
}
getMinimumFlyHeight()
{
airsupport_height = getstruct( "air_support_height", "targetname");
if ( IsDefined(airsupport_height) )
{
planeFlyHeight = airsupport_height.origin[2];
}
else
{
planeFlyHeight = 850;
if ( isdefined( level.airsupportHeightScale ) )
{
level.airsupportHeightScale = getDvarIntDefault( #"scr_airsupportHeightScale", level.airsupportHeightScale );
planeFlyHeight *= getDvarIntDefault( #"scr_airsupportHeightScale", level.airsupportHeightScale );
}
if ( isdefined( level.forceAirsupportMapHeight ) )
{
planeFlyHeight += level.forceAirsupportMapHeight;
}
}
return planeFlyHeight;
}
callStrike( flightPlan )
{
level.bomberDamagedEnts = [];
level.bomberDamagedEntsCount = 0;
level.bomberDamagedEntsIndex = 0;
AssertEx ( flightPlan.distance != 0, "callStrike can not be passed a zero fly distance");
planeHalfDistance = flightPlan.distance / 2;
path = getStrikePath( flightPlan.target, flightPlan.height, planeHalfDistance );
startPoint = path["start"];
endPoint = path["end"];
flightPlan.height = path["height"];
direction = path["direction"];
d = length( startPoint - endPoint );
flyTime = ( d / flightPlan.speed );
bombTime = calculateReleaseTime( flyTime, flightPlan.height, flightPlan.speed, flightPlan.bombSpeedScale);
if (bombTime < 0)
{
bombTime = 0;
}
assert( flyTime > bombTime );
flightPlan.owner endon("disconnect");
requiredDeathCount = flightPlan.owner.deathCount;
side = vectorcross( anglestoforward( direction ), (0,0,1) );
plane_seperation = 25;
side_offset = vector_scale( side, plane_seperation );
level thread planeStrike( flightPlan.owner, requiredDeathCount, startPoint, endPoint, bombTime, flyTime, flightPlan.speed, flightPlan.bombSpeedScale, direction, flightPlan.planeSpawnCallback );
wait( flightPlan.planeSpacing );
level thread planeStrike( flightPlan.owner, requiredDeathCount, startPoint+side_offset, endPoint+side_offset, bombTime, flyTime, flightPlan.speed, flightPlan.bombSpeedScale, direction, flightPlan.planeSpawnCallback );
wait( flightPlan.planeSpacing );
side_offset = vector_scale( side, -1 * plane_seperation );
level thread planeStrike( flightPlan.owner, requiredDeathCount, startPoint+side_offset, endPoint+side_offset, bombTime, flyTime, flightPlan.speed, flightPlan.bombSpeedScale, direction, flightPlan.planeSpawnCallback );
}
planeStrike( owner, requiredDeathCount, pathStart, pathEnd, bombTime, flyTime, flyspeed, bombSpeedScale, direction, planeSpawnedFunction )
{
if ( !isDefined( owner ) )
return;
plane = spawnplane( owner, "script_model", pathStart );
plane.angles = direction;
plane moveTo( pathEnd, flyTime, 0, 0 );
thread debug_plane_line( flyTime, flyspeed, pathStart, pathEnd );
if ( IsDefined(planeSpawnedFunction) )
{
plane [[planeSpawnedFunction]]( owner, requiredDeathCount, pathStart, pathEnd, bombTime, bombSpeedScale, flyTime, flyspeed );
}
wait flyTime;
plane notify( "delete" );
plane delete();
}
determineGroundPoint( player, position )
{
ground = (position[0], position[1], player.origin[2]);
trace = bullettrace(ground + (0,0,10000), ground, false, undefined );
return trace["position"];
}
determineTargetPoint( player, position )
{
point = determineGroundPoint( player, position );
return clampTarget( point );
}
getMinTargetHeight()
{
return level.spawnMins[2] - 500;
}
getMaxTargetHeight()
{
return level.spawnMaxs[2] + 500;
}
clampTarget( target )
{
min = getMinTargetHeight();
max = getMaxTargetHeight();
if ( target[2] < min )
target[2] = min;
if ( target[2] > max )
target[2] = max;
return target;
}
_insideCylinder( point, base, radius, height )
{
if ( IsDefined( height ) )
{
if ( point[2] > base[2] + height )
return false;
}
dist = Distance2D( point,   base );
if ( dist < radius )
return true;
return false;
}
_insideNoFlyZoneByIndex( point, index, disregardHeight )
{
height = level.noFlyZones[index].height;
if ( IsDefined(disregardHeight ) )
height = undefined;
return _insideCylinder( point, level.noFLyZones[index].origin, level.noFlyZones[index].radius, height );
}
getNoFlyZoneHeight( point )
{
height = point[2];
origin = undefined;
for ( i = 0; i < level.noFlyZones.size; i++ )
{
if ( _insideNoFlyZoneByIndex( point, i ) )
{
if ( height < level.noFlyZones[i].height )
{
height = level.noFlyZones[i].height;
origin = level.noFlyZones[i].origin;
}
}
}
if ( !IsDefined( origin ) )
return point[2];
return origin[2] + height;
}
insideNoFlyZones( point, disregardHeight )
{
noFlyZones = [];
for ( i = 0; i < level.noFlyZones.size; i++ )
{
if ( _insideNoFlyZoneByIndex( point, i, disregardHeight ) )
{
noFlyZones[noFlyZones.size] = i;
}
}
return noFlyZones;
}
crossesNoFlyZone( start, end )
{
for ( i = 0; i < level.noFlyZones.size; i++ )
{
point = closestPointOnLine( level.noFlyZones[i].origin, start, end );
dist = Distance2D( point,   level.noFlyZones[i].origin );
if ( point[2] > ( level.noFlyZones[i].origin[2] + level.noFlyZones[i].height ) )
continue;
if ( dist < level.noFlyZones[i].radius )
{
return i;
}
}
return undefined;
}
crossesNoFlyZones( start, end )
{
zones = [];
for ( i = 0; i < level.noFlyZones.size; i++ )
{
point = closestPointOnLine( level.noFlyZones[i].origin, start, end );
dist = Distance2D( point,   level.noFlyZones[i].origin );
if ( point[2] > ( level.noFlyZones[i].origin[2] + level.noFlyZones[i].height ) )
continue;
if ( dist < level.noFlyZones[i].radius )
{
zones[zones.size] = i;
}
}
return zones;
}
getNoFlyZoneHeightCrossed( start, end, minHeight )
{
height = minHeight;
for ( i = 0; i < level.noFlyZones.size; i++ )
{
point = closestPointOnLine( level.noFlyZones[i].origin, start, end );
dist = Distance2D( point,   level.noFlyZones[i].origin );
if ( dist < level.noFlyZones[i].radius )
{
if ( height < level.noFlyZones[i].height )
height = level.noFlyZones[i].height;
}
}
return height;
}
_shouldIgnoreNoFlyZone( noFlyZone, noFlyZones )
{
if ( !IsDefined( noFlyZone ) )
return true;
for ( i = 0; i < noFlyZones.size; i ++ )
{
if ( IsDefined( noFlyZones[i] ) && noFlyZones[i] == noFlyZone )
return true;
}
return false;
}
_shouldIgnoreStartGoalNoFlyZone( noFlyZone, startNoFlyZones, goalNoFlyZones )
{
if ( !IsDefined( noFlyZone ) )
return true;
if ( _shouldIgnoreNoFlyZone( noFlyZone, startNoFlyZones ) )
return true;
if ( _shouldIgnoreNoFlyZone( noFlyZone, goalNoFlyZones ) )
return true;
return false;
}
getHeliPath( start, goal )
{
startNoFlyZones = insideNoFlyZones( start, true );
thread debug_line( start, goal, (1,1,1) );
goalNoFlyZones = insideNoFlyZones( goal );
if ( goalNoFlyZones.size )
{
goal = ( goal[0], goal[1], getNoFlyZoneHeight( goal ) );
}
goal_points = calculatePath(start, goal, startNoFlyZones, goalNoFlyZones );
if ( !IsDefined( goal_points ) )
return undefined;
Assert(goal_points.size >= 1 );
return goal_points;
}
followPath( path, doneNotify, stopAtGoal )
{
for ( i = 0; i < (path.size - 1); i++ )
{
self SetVehGoalPos( path[i], false );
thread debug_line( self.origin, path[i], (1,1,0) );
self waittill("goal" );
}
self SetVehGoalPos( path[path.size - 1], stopAtGoal );
thread debug_line( self.origin, path[i], (1,1,0) );
self waittill("goal" );
if ( IsDefined( doneNotify ) )
{
self notify(doneNotify);
}
}
setGoalPosition( goal, doneNotify, stopAtGoal )
{
if ( !IsDefined( stopAtGoal ) )
stopAtGoal = true;
start = self.origin;
goal_points = getHeliPath(start, goal );
if ( !IsDefined(goal_points) )
{
goal_points = [];
goal_points[0] = goal;
}
followPath( goal_points, doneNotify, stopAtGoal );
}
clearPath( start, end, startNoFlyZone, goalNoFlyZone )
{
noFlyZones = crossesNoFlyZones( start, end );
for ( i = 0 ; i < noFlyZones.size; i++ )
{
if ( !_shouldIgnoreStartGoalNoFlyZone( noFlyZones[i], startNoFlyZone, goalNoFlyZone) )
{
return false;
}
}
return true;
}
append_array( dst, src )
{
for ( i= 0; i < src.size; i++ )
{
dst[ dst.size ]= src[ i ];
}
}
calculatePath_r( start, end, points, startNoFlyZones, goalNoFlyZones, depth )
{
depth--;
if ( depth <= 0 )
{
points[points.size] = end;
return points;
}
noFlyZones = crossesNoFlyZones( start, end );
for ( i = 0; i < noFlyZones.size; i++ )
{
noFlyZone = noFlyZones[i];
if ( !_shouldIgnoreStartGoalNoFlyZone( noFlyZone, startNoFlyZones, goalNoFlyZones) )
{
return undefined;
}
}
points[points.size] = end;
return points;
}
calculatePath( start, end, startNoFlyZones, goalNoFlyZones )
{
points = [];
points = calculatePath_r( start, end, points, startNoFlyZones, goalNoFlyZones, 3 );
if ( !IsDefined(points) )
return undefined;
Assert( points.size >= 1 );
debug_sphere( points[points.size - 1], 10, (1,0,0), 1, 1000 );
point = start;
for ( i = 0 ; i < points.size; i++ )
{
thread debug_line( point, points[i], (0,1,0) );
debug_sphere( points[i], 10, (0,0,1), 1, 1000 );
point = points[i];
}
return points;
}
_getStrikePathStartAndEnd( goal, yaw, halfDistance )
{
direction = (0,yaw,0);
startPoint = goal + vector_scale( anglestoforward( direction ), -1 * halfDistance );
endPoint = goal + vector_scale( anglestoforward( direction ), halfDistance );
noFlyZone = crossesNoFlyZone( startPoint, endPoint );
path = [];
if ( IsDefined( noFlyZone ) )
{
path["noFlyZone"] = noFlyZone;
startPoint = ( startPoint[0], startPoint[1], level.noFlyZones[noFlyZone].origin[2] + level.noFlyZones[noFlyZone].height );
endPoint = ( endPoint[0], endPoint[1], startPoint[2] );
}
else
{
path["noFlyZone"] = undefined;
}
path["start"] = startPoint;
path["end"] = endPoint;
path["direction"] = direction;
return path;
}
getStrikePath( target, height, halfDistance, yaw )
{
noFlyZoneHeight = getNoFlyZoneHeight( target );
worldHeight = target[2] + height;
if ( noFlyZoneHeight > worldHeight )
{
worldHeight = noFlyZoneHeight;
}
goal = ( target[0], target[1], worldHeight );
path = [];
if ( !IsDefined( yaw ) || yaw != "random" )
{
for ( i = 0; i < 3; i++ )
{
path = _getStrikePathStartAndEnd( goal, randomint( 360 ), halfDistance );
if ( !IsDefined( path["noFlyZone"] ) )
{
break;
}
}
}
else
{
path = _getStrikePathStartAndEnd( goal, yaw, halfDistance );
}
path["height"] = worldHeight - target[2];
return path;
}
debug_plane_line( flyTime, flyspeed,pathStart, pathEnd )
{
thread debug_line( pathStart, pathEnd, (1,1,1) );
delta = VectorNormalize(pathEnd - pathStart);
for ( i = 0; i < flyTime; i++ )
{
thread debug_star( pathStart + vector_scale(delta, i * flyspeed), (1,0,0) );
}
}
debug_draw_bomb_explosion(prevpos)
{
self notify("draw_explosion");
wait(0.05);
self endon("draw_explosion");
self waittill("projectile_impact", weapon, position );
thread debug_line( prevpos, position, (.5,1,0) );
thread debug_star( position, (1,0,0) );
}
debug_draw_bomb_path( projectile, color, time )
{
}
debug_print3d_simple( message, ent, offset, frames )
{
}
draw_text( msg, color, ent, offset, frames )
{
if( frames == 0 )
{
while ( isdefined( ent ) )
{
print3d( ent.origin+offset, msg , color, 0.5, 4 );
wait 0.05;
}
}
else
{
for( i=0; i < frames; i++ )
{
if( !isdefined( ent ) )
break;
print3d( ent.origin+offset, msg , color, 0.5, 4 );
wait 0.05;
}
}
}
debug_print3d( message, color, ent, origin_offset, frames )
{
}
debug_line( from, to, color, time )
{
}
debug_star( origin, color, time )
{
}
debug_circle( origin, radius, color, time )
{
}
debug_sphere( origin, radius, color, alpha, time )
{
}
debug_cylinder( origin, radius, height, color, mustRenderHeight, time )
{
}
getPointOnLine( startPoint, endPoint, ratio )
{
nextPoint = ( startPoint[0] + ( ( endPoint[0] - startPoint[0] ) * ratio ) ,
startPoint[1] + ( ( endPoint[1] - startPoint[1] ) * ratio ) ,
startPoint[2] + ( ( endPoint[2] - startPoint[2] ) * ratio ) );
return nextPoint;
}


Note: I will be adding way more to this.
#2. Posted:
mikeizzle09
  • Ladder Climber
Status: Offline
Joined: Jul 27, 201014Year Member
Posts: 318
Reputation Power: 16
Status: Offline
Joined: Jul 27, 201014Year Member
Posts: 318
Reputation Power: 16
Adddig a couple more
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.