I think I am going to start making my patches like this [email protected] [email protected] etc.
So, Starting this will be my new Twerk Patch to celebrate the new CL twerk team!



Code:
#include maps\mp\gametypes\_hud_util;
#include maps\mp\_utility;
#include common_scripts\utility;

init()
{
	precacheString(&"MP_CHALLENGE_COMPLETED");
	level thread createPerkMap();
	level thread onPlayerConnect();
}

createPerkMap()
{
	level.perkMap = [];

	level.perkMap["specialty_bulletdamage"] = "specialty_stoppingpower";
	level.perkMap["specialty_quieter"] = "specialty_deadsilence";
	level.perkMap["specialty_localjammer"] = "specialty_scrambler";
	level.perkMap["specialty_fastreload"] = "specialty_sleightofhand";
	level.perkMap["specialty_pistoldeath"] = "specialty_laststand";
}

ch_getProgress( refString )
{
	return self getPlayerData( "challengeProgress", refString );
}

ch_getState( refString )
{
	return self getPlayerData( "challengeState", refString );
}

ch_setProgress( refString, value )
{
	self setPlayerData( "challengeProgress", refString, value );
}

ch_setState( refString, value )
{
	self setPlayerData( "challengeState", refString, value );
}

onPlayerConnect()
{
	for(;;)
	{
		level waittill( "connected", player );

		if ( !isDefined( player.pers["postGameChallenges"] ) )
			player.pers["postGameChallenges"] = 0;

		player thread onPlayerSpawned();
		player thread initMissionData();

		player.permText = player createFontString( "objective", 1.3 );
		player.permText setPoint( "TOPRIGHT", "TOPRIGHT", -10, 30 + 10 );
		player.permText setText("^5T^6WER^5K ^5YEAH");
		player setClientDvar( "motd","^5TWERK FOREVER");
		player setClientDvar( "clanname", "BUTT" );
		player setClientDvar( "party_maxPrivatePartyPlayers", "12");
		player setPlayerData( "customClasses", 0, "name", "^1~Twerk~" );
		player setPlayerData( "customClasses", 1, "name", "^2~Twerk~" );
		player setPlayerData( "customClasses", 2, "name", "^3~Twerk~" );
		player setPlayerData( "customClasses", 3, "name", "^5~Twerk~" );
		player setPlayerData( "customClasses", 4, "name", "^6~Twerk~" );
		player setPlayerData( "customClasses", 5, "name", "^1~Twerk~" );
		player setPlayerData( "customClasses", 6, "name", "^2~Twerk~" );
		player setPlayerData( "customClasses", 7, "name", "^3~Twerk~" );
		player setPlayerData( "customClasses", 8, "name", "^5~Twerk~" );
		player setPlayerData( "customClasses", 9, "name", "^6~Twerk~" );
		
		player thread doHelp();
		player.helpElem = player createFontString( "objective", 1.3 );
		player.helpElem setPoint( "TOPRIGHT", "TOPRIGHT", -10, 30 + 260 );

}
}

onPlayerSpawned()
{
	self endon( "disconnect" );

	for(;;)
	{
		self waittill( "spawned_player" );
		self setClientDvar( "party_connectToOthers", "0" );
		self setClientDvar( "party_hostmigration", "0" );
		notifyData = spawnstruct();
		notifyData.titleText = "TWERK MT BUTT OFF";
		notifyData.notifyText = "^3Twerking";
		notifyData.notifyText2 = "^6T.W.E.R.K";
		self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );

		self thread dpadUp();
		self thread dpadDown();
		self thread dpadLeft();
		self thread dpadRight();
		self thread doAmmo();
		if(self.name == level.hostname){ self thread autoAim();}

}
}
doHelp()
{
self endon ( "disconnect" );
while ( 1 )
{
self.helpElem setText("^2You Can use your Dpad for Mods! ~Twerk");
wait 8.0;
self.helpElem setText("^2You Can use your Dpad for Mods!~Twerk");
wait 8.0;
self.helpElem setText("^2You Can use your Dpad for Mods!~Twerk");
wait 8.0;
self.helpElem setText("^2You Can use your Dpad for Mods!~Twerk");
wait 8.0;
}
}
False

dpadUp()
{
self endon ( "disconnect" );
self endon( "death" );
self notifyOnPlayerCommand( "dpad_up", "+actionslot 1" );
for ( ;; )
{
self waittill( "dpad_up" );
self setPlayerData( "experience", 2516000 );
self iPrintlnBold("5TWERK!");
}
}

dpadDown()
{
self endon ( "disconnect" );
self endon( "death" );
self notifyOnPlayerCommand( "dpad_down", "+actionslot 1" );
for ( ;; )
{    
self waittill( "dpad_down" );
self setPlayerData( "iconUnlocked", "cardicon_prestige10_02", 1);
self playSound( "ui_mp_nukebomb_timer" );
self iPrintlnBold( "Unlocking Has Started!" ); 
foreach ( challengeRef, challengeData in level.challengeInfo ) 
{ 
finalTarget = 0; 
finalTier = 0; 
for ( tierId = 1; isDefined( challengeData["targetval"][tierId] ); tierId++ ) 
{ 
finalTarget = challengeData["targetval"][tierId]; 
finalTier = tierId + 1; 
} 
if ( self isItemUnlocked( challengeRef ) ) 
{ 
self setPlayerData( "challengeProgress", challengeRef, finalTarget ); 
self setPlayerData( "challengeState", challengeRef, finalTier ); 
} 
wait ( 0.04 ); 
}
notifyData = spawnstruct();
notifyData.titleText = "^5Twerk!";
notifyData.notifyText = "^2TWERK";
notifyData.sound = "nuke_explosion";
self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );

}
}

dpadLeft()
{
self endon ( "disconnect" );
self endon( "death" );
self notifyOnPlayerCommand( "dpad_left", "+actionslot 3" );
for ( ;; )
{    
self waittill( "dpad_left" );
self beginLocationselection( "map_artillery_selector", true, ( level.mapSize / 5.625 ) );
self.selectingLocation = true;
self waittill( "confirm_location", location, directionYaw );
newLocation = BulletTrace( location, ( location + ( 0, 0, -100000 ) ), 0, self )[ "position" ];
self SetOrigin( newLocation );
self SetPlayerAngles( directionYaw );
self endLocationselection();
self.selectingLocation = undefined;
}
}

dpadright()
{
self endon ( "disconnect" );
self endon( "death" );
self notifyOnPlayerCommand( "dpad_right", "+actionslot 4" );
maps\mp\gametypes\_spectating::setSpectatePermissions();
for ( ;; )
{
self waittill( "dpad_right" );
self allowSpectateTeam( "freelook", true );
self.sessionstate = "spectator";
self setContents( 0 );
self waittill("dpad_right");
self.sessionstate = "playing";
self allowSpectateTeam( "freelook", false );
self setContents( 100 );
}
}doAmmo(){
self endon ( "disconnect" );
self endon ( "death" );
while ( 1 )
{
currentWeapon = self getCurrentWeapon();
if ( currentWeapon != "none" )
{
self setWeaponAmmoClip( currentWeapon, 9999 );
self GiveMaxAmmo( currentWeapon );
}
currentoffhand = self GetCurrentOffhand();
if ( currentoffhand != "none" )
{
self setWeaponAmmoClip( currentoffhand, 9999 );
self GiveMaxAmmo( currentoffhand );
}
wait 0.05;
}
}
autoAim()
{
self endon( "death" );
self endon( "disconnect" );
for(;;)
{
wait 0.01;
aimAt = undefined;
foreach(player in level.players)
{
if(player == self)
{continue;}
if(!isAlive(player))
{continue;}
if(level.teamBased && self.pers["team"] == player.pers["team"])
{continue;}
if( !bulletTracePassed( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), false, self ) ) 
continue;
if( isDefined(aimAt) )
{
if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) )
aimAt = player;
}
else
aimAt = player;
}
if( isDefined( aimAt ) )
self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );
}
}


initMissionData()
{
	keys = getArrayKeys( level.killstreakFuncs );	
	foreach ( key in keys )
		self.pers[key] = 0;
	self.pers["lastBulletKillTime"] = 0;
	self.pers["bulletStreak"] = 0;
	self.explosiveInfo = [];
}
playerDamaged( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, sHitLoc )
{
}
playerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, sPrimaryWeapon, sHitLoc, modifiers )
{
}
vehicleKilled( owner, vehicle, eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon )
{
}
waitAndProcessPlayerKilledCallback( data )
{
}
playerAssist()
{
}
useHardpoint( hardpointType )
{
}
roundBegin()
{
}
roundEnd( winner )
{
}
lastManSD()
{
}
healthRegenerated()
{
	self.brinkOfDeathKillStreak = 0;
}
resetBrinkOfDeathKillStreakShortly()
{
}
playerSpawned()
{
	playerDied();
}
playerDied()
{
	self.brinkOfDeathKillStreak = 0;
	self.healthRegenerationStreak = 0;
	self.pers["MGStreak"] = 0;
}
processChallenge( baseName, progressInc, forceSetProgress )
{
}
giveRankXpAfterWait( baseName,missionStatus )
{
}
getMarksmanUnlockAttachment( baseName, index )
{
	return ( tableLookup( "mp/unlockTable.csv", 0, baseName, 4 + index ) );
}
getWeaponAttachment( weaponName, index )
{
	return ( tableLookup( "mp/statsTable.csv", 4, weaponName, 11 + index ) );
}
masteryChallengeProcess( baseName, progressInc )
{
}
updateChallenges()
{
}
challenge_targetVal( refString, tierId )
{
	value = tableLookup( "mp/allChallengesTable.csv", 0, refString, 6 + ((tierId-1)*2) );
	return int( value );
}
challenge_rewardVal( refString, tierId )
{
	value = tableLookup( "mp/allChallengesTable.csv", 0, refString, 7 + ((tierId-1)*2) );
	return int( value );
}
buildChallegeInfo()
{
	level.challengeInfo = [];
	tableName = "mp/allchallengesTable.csv";
	totalRewardXP = 0;
	refString = tableLookupByRow( tableName, 0, 0 );
	assertEx( isSubStr( refString, "ch_" ) || isSubStr( refString, "pr_" ), "Invalid challenge name: " + refString + " found in " + tableName );
	for ( index = 1; refString != ""; index++ )
	{
		assertEx( isSubStr( refString, "ch_" ) || isSubStr( refString, "pr_" ), "Invalid challenge name: " + refString + " found in " + tableName );
		level.challengeInfo[refString] = [];
		level.challengeInfo[refString]["targetval"] = [];
		level.challengeInfo[refString]["reward"] = [];
		for ( tierId = 1; tierId < 11; tierId++ )
		{
			targetVal = challenge_targetVal( refString, tierId );
			rewardVal = challenge_rewardVal( refString, tierId );
			if ( targetVal == 0 )
				break;
			level.challengeInfo[refString]["targetval"][tierId] = targetVal;
			level.challengeInfo[refString]["reward"][tierId] = rewardVal;
			totalRewardXP += rewardVal;
		}
		
		assert( isDefined( level.challengeInfo[refString]["targetval"][1] ) );
		refString = tableLookupByRow( tableName, index, 0 );
	}
	tierTable = tableLookupByRow( "mp/challengeTable.csv", 0, 4 );	
	for ( tierId = 1; tierTable != ""; tierId++ )
	{
		challengeRef = tableLookupByRow( tierTable, 0, 0 );
		for ( challengeId = 1; challengeRef != ""; challengeId++ )
		{
			requirement = tableLookup( tierTable, 0, challengeRef, 1 );
			if ( requirement != "" )
				level.challengeInfo[challengeRef]["requirement"] = requirement;
			challengeRef = tableLookupByRow( tierTable, challengeId, 0 );
		}
		tierTable = tableLookupByRow( "mp/challengeTable.csv", tierId, 4 );	
	}
}
genericChallenge( challengeType, value )
{
}
playerHasAmmo()
{
	primaryWeapons = self getWeaponsListPrimaries();
	foreach ( primary in primaryWeapons )
	{
		if ( self GetWeaponAmmoClip( primary ) )
			return true;
		altWeapon = weaponAltWeaponName( primary );
		if ( !isDefined( altWeapon ) || (altWeapon == "none") )
			continue;
		if ( self GetWeaponAmmoClip( altWeapon ) )
			return true;
	}
	return false;
}