389 lines
17 KiB
Plaintext
389 lines
17 KiB
Plaintext
#using scripts\shared\abilities\_ability_util;
|
|
#using scripts\shared\callbacks_shared;
|
|
#using scripts\shared\gameobjects_shared;
|
|
#using scripts\shared\hud_util_shared;
|
|
#using scripts\shared\loadout_shared;
|
|
#using scripts\shared\math_shared;
|
|
#using scripts\shared\util_shared;
|
|
|
|
|
|
|
|
#using scripts\mp\gametypes\_deathicons;
|
|
#using scripts\mp\gametypes\_dogtags;
|
|
#using scripts\mp\gametypes\_globallogic;
|
|
#using scripts\mp\gametypes\_globallogic_audio;
|
|
#using scripts\mp\gametypes\_globallogic_player;
|
|
#using scripts\mp\gametypes\_globallogic_score;
|
|
#using scripts\mp\gametypes\_globallogic_spawn;
|
|
#using scripts\mp\gametypes\_loadout;
|
|
#using scripts\mp\gametypes\_wager;
|
|
#using scripts\mp\gametypes\_weapons;
|
|
#using scripts\mp\gametypes\tdm;
|
|
|
|
#using scripts\mp\_util;
|
|
|
|
#precache( "string", "MP_MAX_KILL_INDICATOR" );
|
|
#precache( "string", "MP_RANGE_KILL_INDICATOR" );
|
|
#precache( "string", "MP_MAX_MATCH_INDICATOR" );
|
|
|
|
function main()
|
|
{
|
|
tdm::main();
|
|
gameobjects::register_allowed_gameobject( "tdm" );
|
|
|
|
level.leaderDialog = undefined;
|
|
|
|
level.CONST_FALLBACK_WEAPON = GetWeapon( "sniper_powerbolt", "extclip", "swayreduc" );
|
|
|
|
level.onStartGameType =&onStartGameType;
|
|
level.onPlayerKilled =&onPlayerKilled;
|
|
level.giveCustomLoadout =&giveCustomLoadout;
|
|
|
|
callback::on_connect( &on_player_connect );
|
|
}
|
|
|
|
function onStartGameType()
|
|
{
|
|
tdm::onStartGameType();
|
|
|
|
level matchBestKillRangeIndicator();
|
|
}
|
|
|
|
function on_player_connect()
|
|
{
|
|
self thread killRangeIndicator();
|
|
}
|
|
|
|
function giveCustomLoadout()
|
|
{
|
|
loadout::giveLoadout_init( true );
|
|
|
|
loadout::setClassNum( self.curClass );
|
|
loadout::givePerks();
|
|
|
|
primaryWeapon = self GetLoadoutWeapon( self.class_num, "primary" );
|
|
weaponClass = util::getWeaponClass( primaryWeapon );
|
|
useCamo = true;
|
|
if ( !isdefined( primaryWeapon ) || primaryWeapon == level.weaponNone || primaryWeapon == level.weaponNull || !isdefined( weaponClass ) || weaponClass != "weapon_sniper" )
|
|
{
|
|
primaryWeapon = level.CONST_FALLBACK_WEAPON;
|
|
useCamo = false;
|
|
}
|
|
|
|
self playerGivePrimaryWeapon( primaryWeapon, useCamo );
|
|
|
|
sidearm = self GetLoadoutWeapon( self.class_num, "secondary" );
|
|
weaponClass = util::getWeaponClass( sidearm );
|
|
if ( isdefined( sidearm ) && sidearm != level.weaponNone && sidearm != level.weaponNull && isdefined( weaponClass ) && weaponClass == "weapon_sniper" )
|
|
{
|
|
self playerGiveSecondaryWeapon( sidearm );
|
|
}
|
|
|
|
primaryOffhand = GetWeapon( "null_offhand_primary" );
|
|
primaryOffhandCount = 0;
|
|
self GiveWeapon( primaryOffhand );
|
|
self SetWeaponAmmoStock( primaryOffhand, primaryOffhandCount );
|
|
self SwitchToOffhand( primaryOffhand );
|
|
self.grenadeTypePrimary = primaryOffhand;
|
|
self.grenadeTypePrimaryCount = primaryOffhandCount;
|
|
|
|
secondaryOffhand = GetWeapon( "null_offhand_secondary" );
|
|
secondaryOffhandCount = 0;
|
|
self GiveWeapon( secondaryOffhand );
|
|
self SetWeaponAmmoClip( secondaryOffhand, secondaryOffhandCount );
|
|
self SwitchToOffhand( secondaryOffhand );
|
|
self.grenadeTypeSecondary = secondaryOffhand;
|
|
self.grenadeTypeSecondaryCount = secondaryOffhandCount;
|
|
|
|
self giveGadget();
|
|
loadout::giveHeroWeapon();
|
|
|
|
self AllowMelee( false );
|
|
|
|
return primaryWeapon;
|
|
}
|
|
|
|
function giveGadget()
|
|
{
|
|
self.grenadeTypeSpecial = undefined;
|
|
|
|
loadout::giveSpecialOffhand();
|
|
|
|
if ( !isdefined( self.grenadeTypeSpecial ) )
|
|
{
|
|
bodyIndex = self GetCharacterBodyType();
|
|
gadgetRef = "none";
|
|
switch( bodyIndex )
|
|
{
|
|
case 0:
|
|
gadgetRef = "gadget_speed_burst";
|
|
break;
|
|
case 1:
|
|
gadgetRef = "gadget_vision_pulse";
|
|
break;
|
|
case 2:
|
|
gadgetRef = "gadget_flashback";
|
|
break;
|
|
case 3:
|
|
gadgetRef = "gadget_armor";
|
|
break;
|
|
case 4:
|
|
gadgetRef = "gadget_combat_efficiency";
|
|
break;
|
|
case 5:
|
|
gadgetRef = "gadget_resurrect";
|
|
break;
|
|
case 6:
|
|
gadgetRef = "gadget_clone";
|
|
break;
|
|
case 7:
|
|
gadgetRef = "gadget_camo";
|
|
break;
|
|
case 8:
|
|
gadgetRef = "gadget_heat_wave";
|
|
break;
|
|
case 9:
|
|
gadgetRef = "gadget_roulette";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if ( gadgetRef != "none" )
|
|
{
|
|
changedClass = self.pers["changed_class"];
|
|
roundBased = !util::isOneRound();
|
|
firstRound = util::isFirstRound();
|
|
|
|
specialOffhand = GetWeapon( gadgetRef );
|
|
specialOffhandCount = specialOffhand.startammo;
|
|
self GiveWeapon( specialOffhand );
|
|
|
|
self SetWeaponAmmoClip( specialOffhand, specialOffhandCount );
|
|
self SwitchToOffhand( specialOffhand );
|
|
self.grenadeTypeSpecial = specialOffhand;
|
|
self.grenadeTypeSpecialCount = specialOffhandCount;
|
|
|
|
self ability_util::gadget_reset( specialOffhand, changedClass, roundBased, firstRound );
|
|
}
|
|
}
|
|
}
|
|
|
|
function playerGivePrimaryWeapon( primaryWeapon, useCamo )
|
|
{
|
|
if ( useCamo )
|
|
{
|
|
primaryWeaponOptions = self CalcWeaponOptions( self.class_num, 0 );
|
|
acvi = self GetAttachmentCosmeticVariantForWeapon( self.class_num, "primary" );
|
|
self GiveWeapon( primaryWeapon, primaryWeaponOptions, acvi );
|
|
}
|
|
else
|
|
{
|
|
self GiveWeapon( primaryWeapon );
|
|
}
|
|
|
|
self.primaryLoadoutWeapon = primaryWeapon;
|
|
self.primaryLoadoutAltWeapon = primaryWeapon.altWeapon;
|
|
|
|
if ( useCamo )
|
|
self.primaryLoadoutGunSmithVariantIndex = self GetLoadoutGunSmithVariantIndex( self.class_num, 0 );
|
|
|
|
if ( self HasPerk( "specialty_extraammo" ) )
|
|
{
|
|
self GiveMaxAmmo( primaryWeapon );
|
|
}
|
|
|
|
self thread loadout::initWeaponAttachments( primaryWeapon );
|
|
|
|
self.pers["changed_class"] = false;
|
|
self.spawnWeapon = primaryWeapon;
|
|
self.pers["spawnWeapon"] = self.spawnWeapon;
|
|
|
|
switchImmediate = isdefined( self.alreadySetSpawnWeaponOnce );
|
|
self SetSpawnWeapon( primaryWeapon, switchImmediate );
|
|
self.alreadySetSpawnWeaponOnce = true;
|
|
}
|
|
|
|
function playerGiveSecondaryWeapon( sidearm )
|
|
{
|
|
secondaryWeaponOptions = self CalcWeaponOptions( self.class_num, 1 );
|
|
|
|
acvi = self GetAttachmentCosmeticVariantForWeapon( self.class_num, "secondary" );
|
|
self GiveWeapon( sidearm, secondaryWeaponOptions, acvi );
|
|
self.secondaryLoadoutWeapon = sidearm;
|
|
self.secondaryLoadoutAltWeapon = sidearm.altWeapon;
|
|
self.secondaryLoadoutGunSmithVariantIndex = self GetLoadoutGunSmithVariantIndex( self.class_num, 1 );
|
|
|
|
if ( self HasPerk( "specialty_extraammo" ) )
|
|
{
|
|
self giveMaxAmmo( sidearm );
|
|
}
|
|
}
|
|
|
|
function onPlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration )
|
|
{
|
|
victim = self;
|
|
|
|
if( ( isdefined( level.droppedTagRespawn ) && level.droppedTagRespawn ) )
|
|
{
|
|
should_spawn_tags = self dogtags::should_spawn_tags(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration);
|
|
|
|
// we should spawn tags if one the previous statements were true and we may not spawn
|
|
should_spawn_tags = should_spawn_tags && !globallogic_spawn::maySpawn();
|
|
|
|
if( should_spawn_tags )
|
|
level thread dogtags::spawn_dog_tag( self, attacker, &dogtags::onUseDogTag, false );
|
|
}
|
|
|
|
if ( !IsDefined( attacker ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
wasSuicide = ( attacker == self ) || !isPlayer( attacker );
|
|
if ( wasSuicide )
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ( isdefined( attacker ) && isdefined( victim ) && isdefined( attacker.origin ) && isdefined( victim.origin ) )
|
|
{
|
|
killDistanceInMeters = Distance( attacker.origin, victim.origin ) * 0.0254;
|
|
killRange = Int( Max( killDistanceInMeters, 1 ) );
|
|
attacker thread updateKillIndicator( killRange );
|
|
}
|
|
|
|
attacker globallogic_score::giveTeamScoreForObjective( attacker.team, level.teamScorePerKill );
|
|
self globallogic_score::giveTeamScoreForObjective( self.team, level.teamScorePerDeath * -1 );
|
|
if ( sMeansOfDeath == "MOD_HEAD_SHOT" )
|
|
{
|
|
attacker globallogic_score::giveTeamScoreForObjective( attacker.team, level.teamScorePerHeadshot );
|
|
}
|
|
}
|
|
|
|
function flashKillIndicator()
|
|
{
|
|
level endon( "game_ended" );
|
|
self endon( "death" );
|
|
self endon( "disconnect" );
|
|
|
|
self notify( "newKillIndicator" );
|
|
self endon( "newKillIndicator" );
|
|
|
|
self.killIndicator.alpha = 1;
|
|
self.killIndicator FadeOverTime( 3 );
|
|
self.killIndicator.alpha = 0;
|
|
}
|
|
|
|
function updateKillIndicator( killRange )
|
|
{
|
|
self endon( "disconnect" );
|
|
level endon( "game_ended" );
|
|
|
|
killRangeColorIntensity = killrange;
|
|
if( killrange >= 150 )
|
|
{
|
|
self.killIndicator.color = ( 0, 1, 0 );
|
|
}
|
|
else
|
|
{
|
|
killRangeColorIntensity = 0.01 * ( 100 - ( 0.67 * killRangeColorIntensity ) );
|
|
self.killIndicator.color = ( killRangeColorIntensity, 1, killRangeColorIntensity );
|
|
}
|
|
self.killIndicator SetValue( killRange );
|
|
|
|
if( !isDefined( self.maxKillRange ) || self.maxKillRange < killRange )
|
|
{
|
|
self.maxKillRange = killRange;
|
|
self.maxKillIndicator.color = ( killRangeColorIntensity, 1, killRangeColorIntensity );
|
|
self.maxKillIndicator SetValue( self.maxKillRange );
|
|
self.maxKillIndicator.alpha = 1;
|
|
|
|
if( killRange >= 150 )
|
|
{
|
|
self.maxKillIndicator.color = ( 0, 1, 0 );
|
|
self.maxKillIndicator.glowAlpha = 0.5;
|
|
}
|
|
|
|
if( !IsDefined( level.maxMatchRange ) || level.maxMatchRange < killRange )
|
|
{
|
|
level.maxMatchRange = killrange;
|
|
level.maxMatchIndicator.color = ( killRangeColorIntensity, 1, killRangeColorIntensity );
|
|
level.maxMatchIndicator setValue( level.maxMatchRange );
|
|
level.maxMatchIndicator.alpha = 1;
|
|
|
|
if( killRange >= 150 )
|
|
{
|
|
level.maxMatchIndicator.color = ( 0, 1, 0 );
|
|
level.maxMatchIndicator.glowAlpha = 0.5;
|
|
}
|
|
}
|
|
}
|
|
|
|
self thread flashKillIndicator();
|
|
}
|
|
|
|
function hideKillIndicator()
|
|
{
|
|
self endon( "disconnect" );
|
|
|
|
while( 1 )
|
|
{
|
|
level waittill( "game_ended" );
|
|
|
|
self.killIndicator.alpha = 0;
|
|
self.maxKillIndicator.alpha = 0;
|
|
}
|
|
}
|
|
|
|
function killRangeIndicator()
|
|
{
|
|
self endon( "disconnect" );
|
|
|
|
self.killIndicator = hud::createFontString( "objective", 1 );
|
|
self.killIndicator.label = &"MP_RANGE_KILL_INDICATOR";
|
|
self.killIndicator SetValue( 0 );
|
|
self.killIndicator.x = 0;
|
|
self.killIndicator.y = 20;
|
|
self.killIndicator.alignX = "center";
|
|
self.killIndicator.alignY = "middle";
|
|
self.killIndicator.horzAlign = "user_center";
|
|
self.killIndicator.vertAlign = "middle";
|
|
self.killIndicator.archived = true;
|
|
self.killIndicator.fontscale = 1;
|
|
self.killIndicator.alpha = 0;
|
|
self.killIndicator.glowAlpha = 0.5;
|
|
self.killIndicator.hidewheninmenu = false;
|
|
|
|
self.maxKillIndicator = hud::createFontString( "objective", 1 );
|
|
self.maxKillIndicator.x = -6;
|
|
self.maxKillIndicator.y = 2;
|
|
self.maxKillIndicator.alignX = "right";
|
|
self.maxKillIndicator.alignY = "top";
|
|
self.maxKillIndicator.horzAlign = "user_right";
|
|
self.maxKillIndicator.vertAlign = "user_top";
|
|
self.maxKillIndicator.label = &"MP_MAX_KILL_INDICATOR";
|
|
self.maxKillIndicator SetValue( 0 );
|
|
self.maxKillIndicator.alpha = 0;
|
|
self.maxKillIndicator.archived = false;
|
|
self.maxKillIndicator.hideWhenInMenu = true;
|
|
|
|
self thread hideKillIndicator();
|
|
}
|
|
|
|
function matchBestKillRangeIndicator()
|
|
{
|
|
level.maxMatchIndicator = hud::createServerFontString( "objective", 1 );
|
|
level.maxMatchIndicator.x = -6;
|
|
level.maxMatchIndicator.y = 14;
|
|
level.maxMatchIndicator.alignX = "right";
|
|
level.maxMatchIndicator.alignY = "top";
|
|
level.maxMatchIndicator.horzAlign = "user_right";
|
|
level.maxMatchIndicator.vertAlign = "user_top";
|
|
level.maxMatchIndicator.label = &"MP_MAX_MATCH_INDICATOR";
|
|
level.maxMatchIndicator SetValue( 0 );
|
|
level.maxMatchIndicator.alpha = 0;
|
|
level.maxMatchIndicator.archived = false;
|
|
level.maxMatchIndicator.hideWhenInMenu = true;
|
|
}
|