Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.77 KB | None | 0 0
  1. #include common_scripts\utility;
  2. // check if below includes are removable
  3. #include maps\mp\_utility;
  4. #include maps\mp\gametypes\_hud_util;
  5.  
  6. init()
  7. {
  8. level.classMap["class0"] = 0;
  9. level.classMap["class1"] = 1;
  10. level.classMap["class2"] = 2;
  11. level.classMap["class3"] = 3;
  12. level.classMap["class4"] = 4;
  13. level.classMap["class5"] = 5;
  14. level.classMap["class6"] = 6;
  15. level.classMap["class7"] = 7;
  16. level.classMap["class8"] = 8;
  17. level.classMap["class9"] = 9;
  18. level.classMap["class10"] = 10;
  19. level.classMap["class11"] = 11;
  20. level.classMap["class12"] = 12;
  21. level.classMap["class13"] = 13;
  22. level.classMap["class14"] = 14;
  23.  
  24. level.classMap["custom1"] = 0;
  25. level.classMap["custom2"] = 1;
  26. level.classMap["custom3"] = 2;
  27. level.classMap["custom4"] = 3;
  28. level.classMap["custom5"] = 4;
  29. level.classMap["custom6"] = 5;
  30. level.classMap["custom7"] = 6;
  31. level.classMap["custom8"] = 7;
  32. level.classMap["custom9"] = 8;
  33. level.classMap["custom10"] = 9;
  34.  
  35. level.classMap["copycat"] = -1;
  36.  
  37. /#
  38. // classes testclients may choose from.
  39. level.botClasses = [];
  40. level.botClasses[0] = "class0";
  41. level.botClasses[1] = "class0";
  42. level.botClasses[2] = "class0";
  43. level.botClasses[3] = "class0";
  44. level.botClasses[4] = "class0";
  45. #/
  46.  
  47. level.defaultClass = "CLASS_ASSAULT";
  48.  
  49. level.classTableName = "mp/classTable.csv";
  50.  
  51. //precacheShader( "waypoint_bombsquad" );
  52. precacheShader( "specialty_pistoldeath" );
  53. precacheShader( "specialty_finalstand" );
  54.  
  55. level thread onPlayerConnecting();
  56. }
  57.  
  58.  
  59. getClassChoice( response )
  60. {
  61. assert( isDefined( level.classMap[response] ) );
  62.  
  63. return response;
  64. }
  65.  
  66. getWeaponChoice( response )
  67. {
  68. tokens = strtok( response, "," );
  69. if ( tokens.size > 1 )
  70. return int(tokens[1]);
  71. else
  72. return 0;
  73. }
  74.  
  75.  
  76. logClassChoice( class, primaryWeapon, specialType, perks )
  77. {
  78. if ( class == self.lastClass )
  79. return;
  80.  
  81. self logstring( "choseclass: " + class + " weapon: " + primaryWeapon + " special: " + specialType );
  82. for( i=0; i<perks.size; i++ )
  83. self logstring( "perk" + i + ": " + perks[i] );
  84.  
  85. self.lastClass = class;
  86. }
  87.  
  88.  
  89. cac_getWeapon( classIndex, weaponIndex )
  90. {
  91. return self getPlayerData( "customClasses", classIndex, "weaponSetups", weaponIndex, "weapon" );
  92. }
  93.  
  94. cac_getWeaponAttachment( classIndex, weaponIndex )
  95. {
  96. return self getPlayerData( "customClasses", classIndex, "weaponSetups", weaponIndex, "attachment", 0 );
  97. }
  98.  
  99. cac_getWeaponAttachmentTwo( classIndex, weaponIndex )
  100. {
  101. return self getPlayerData( "customClasses", classIndex, "weaponSetups", weaponIndex, "attachment", 1 );
  102. }
  103.  
  104. cac_getWeaponCamo( classIndex, weaponIndex )
  105. {
  106. return self getPlayerData( "customClasses", classIndex, "weaponSetups", weaponIndex, "camo" );
  107. }
  108.  
  109. cac_getPerk( classIndex, perkIndex )
  110. {
  111. return self getPlayerData( "customClasses", classIndex, "perks", perkIndex );
  112. }
  113.  
  114. cac_getKillstreak( classIndex, streakIndex )
  115. {
  116. return self getPlayerData( "killstreaks", streakIndex );
  117. }
  118.  
  119. cac_getDeathstreak( classIndex )
  120. {
  121. return self getPlayerData( "customClasses", classIndex, "perks", 4 );
  122. }
  123.  
  124. cac_getOffhand( classIndex )
  125. {
  126. return self getPlayerData( "customClasses", classIndex, "specialGrenade" );
  127. }
  128.  
  129.  
  130.  
  131. table_getWeapon( tableName, classIndex, weaponIndex )
  132. {
  133. if ( weaponIndex == 0 )
  134. return tableLookup( tableName, 0, "loadoutPrimary", classIndex + 1 );
  135. else
  136. return tableLookup( tableName, 0, "loadoutSecondary", classIndex + 1 );
  137. }
  138.  
  139. table_getWeaponAttachment( tableName, classIndex, weaponIndex, attachmentIndex )
  140. {
  141. tempName = "none";
  142.  
  143. if ( weaponIndex == 0 )
  144. {
  145. if ( !isDefined( attachmentIndex ) || attachmentIndex == 0 )
  146. tempName = tableLookup( tableName, 0, "loadoutPrimaryAttachment", classIndex + 1 );
  147. else
  148. tempName = tableLookup( tableName, 0, "loadoutPrimaryAttachment2", classIndex + 1 );
  149. }
  150. else
  151. {
  152. if ( !isDefined( attachmentIndex ) || attachmentIndex == 0 )
  153. tempName = tableLookup( tableName, 0, "loadoutSecondaryAttachment", classIndex + 1 );
  154. else
  155. tempName = tableLookup( tableName, 0, "loadoutSecondaryAttachment2", classIndex + 1 );
  156. }
  157.  
  158. if ( tempName == "" || tempName == "none" )
  159. return "none";
  160. else
  161. return tempName;
  162.  
  163.  
  164. }
  165.  
  166. table_getWeaponCamo( tableName, classIndex, weaponIndex )
  167. {
  168. if ( weaponIndex == 0 )
  169. return tableLookup( tableName, 0, "loadoutPrimaryCamo", classIndex + 1 );
  170. else
  171. return tableLookup( tableName, 0, "loadoutSecondaryCamo", classIndex + 1 );
  172. }
  173.  
  174. table_getEquipment( tableName, classIndex, perkIndex )
  175. {
  176. assert( perkIndex < 5 );
  177. return tableLookup( tableName, 0, "loadoutEquipment", classIndex + 1 );
  178. }
  179.  
  180. table_getPerk( tableName, classIndex, perkIndex )
  181. {
  182. assert( perkIndex < 5 );
  183. return tableLookup( tableName, 0, "loadoutPerk" + perkIndex, classIndex + 1 );
  184. }
  185.  
  186. table_getOffhand( tableName, classIndex )
  187. {
  188. return tableLookup( tableName, 0, "loadoutOffhand", classIndex + 1 );
  189. }
  190.  
  191. table_getKillstreak( tableName, classIndex, streakIndex )
  192. {
  193. // return tableLookup( tableName, 0, "loadoutStreak" + streakIndex, classIndex + 1 );
  194. return ( "none" );
  195. }
  196.  
  197. table_getDeathstreak( tableName, classIndex )
  198. {
  199. return tableLookup( tableName, 0, "loadoutDeathstreak", classIndex + 1 );
  200. }
  201.  
  202. getClassIndex( className )
  203. {
  204. assert( isDefined( level.classMap[className] ) );
  205.  
  206. return level.classMap[className];
  207. }
  208.  
  209. /*
  210. getPerk( perkIndex )
  211. {
  212. if( isSubstr( self.pers["class"], "CLASS_CUSTOM" ) )
  213. return cac_getPerk( self.class_num, perkIndex );
  214. else
  215. return table_getPerk( level.classTableName, self.class_num, perkIndex );
  216. }
  217.  
  218. getWeaponCamo( weaponIndex )
  219. {
  220. if( isSubstr( self.pers["class"], "CLASS_CUSTOM" ) )
  221. return cac_getWeaponCamo( self.class_num, weaponIndex );
  222. else
  223. return table_getWeaponCamo( level.classTableName, self.class_num, weaponIndex );
  224. }
  225. */
  226.  
  227. cloneLoadout()
  228. {
  229. clonedLoadout = [];
  230.  
  231. class = self.curClass;
  232.  
  233. if ( class == "copycat" )
  234. return ( undefined );
  235.  
  236. if( isSubstr( class, "custom" ) )
  237. {
  238. class_num = getClassIndex( class );
  239.  
  240. loadoutPrimaryAttachment2 = "none";
  241. loadoutSecondaryAttachment2 = "none";
  242.  
  243. loadoutPrimary = cac_getWeapon( class_num, 0 );
  244. loadoutPrimaryAttachment = cac_getWeaponAttachment( class_num, 0 );
  245. loadoutPrimaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 0 );
  246. loadoutPrimaryCamo = cac_getWeaponCamo( class_num, 0 );
  247. loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
  248. loadoutSecondary = cac_getWeapon( class_num, 1 );
  249. loadoutSecondaryAttachment = cac_getWeaponAttachment( class_num, 1 );
  250. loadoutSecondaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 1 );
  251. loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
  252. loadoutEquipment = cac_getPerk( class_num, 0 );
  253. loadoutPerk1 = cac_getPerk( class_num, 1 );
  254. loadoutPerk2 = cac_getPerk( class_num, 2 );
  255. loadoutPerk3 = cac_getPerk( class_num, 3 );
  256. loadoutOffhand = cac_getOffhand( class_num );
  257. loadoutDeathStreak = cac_getDeathstreak( class_num );
  258. }
  259. else
  260. {
  261. class_num = getClassIndex( class );
  262.  
  263. loadoutPrimary = table_getWeapon( level.classTableName, class_num, 0 );
  264. loadoutPrimaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 0 , 0);
  265. loadoutPrimaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 0, 1 );
  266. loadoutPrimaryCamo = table_getWeaponCamo( level.classTableName, class_num, 0 );
  267. loadoutSecondary = table_getWeapon( level.classTableName, class_num, 1 );
  268. loadoutSecondaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 1 , 0);
  269. loadoutSecondaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 1, 1 );;
  270. loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
  271. loadoutEquipment = table_getEquipment( level.classTableName, class_num, 0 );
  272. loadoutPerk1 = table_getPerk( level.classTableName, class_num, 1 );
  273. loadoutPerk2 = table_getPerk( level.classTableName, class_num, 2 );
  274. loadoutPerk3 = table_getPerk( level.classTableName, class_num, 3 );
  275. loadoutOffhand = table_getOffhand( level.classTableName, class_num );
  276. loadoutDeathstreak = table_getDeathstreak( level.classTableName, class_num );
  277. }
  278.  
  279. clonedLoadout["inUse"] = false;
  280. clonedLoadout["loadoutPrimary"] = loadoutPrimary;
  281. clonedLoadout["loadoutPrimaryAttachment"] = loadoutPrimaryAttachment;
  282. clonedLoadout["loadoutPrimaryAttachment2"] = loadoutPrimaryAttachment2;
  283. clonedLoadout["loadoutPrimaryCamo"] = loadoutPrimaryCamo;
  284. clonedLoadout["loadoutSecondary"] = loadoutSecondary;
  285. clonedLoadout["loadoutSecondaryAttachment"] = loadoutSecondaryAttachment;
  286. clonedLoadout["loadoutSecondaryAttachment2"] = loadoutSecondaryAttachment2;
  287. clonedLoadout["loadoutSecondaryCamo"] = loadoutSecondaryCamo;
  288. clonedLoadout["loadoutEquipment"] = loadoutEquipment;
  289. clonedLoadout["loadoutPerk1"] = loadoutPerk1;
  290. clonedLoadout["loadoutPerk2"] = loadoutPerk2;
  291. clonedLoadout["loadoutPerk3"] = loadoutPerk3;
  292. clonedLoadout["loadoutOffhand"] = loadoutOffhand;
  293.  
  294. return ( clonedLoadout );
  295. }
  296.  
  297. giveLoadout( team, class, allowCopycat )
  298. {
  299. self takeAllWeapons();
  300.  
  301. primaryIndex = 0;
  302.  
  303. // initialize specialty array
  304. self.specialty = [];
  305.  
  306. if ( !isDefined( allowCopycat ) )
  307. allowCopycat = true;
  308.  
  309. primaryWeapon = undefined;
  310.  
  311. if ( isDefined( self.pers["copyCatLoadout"] ) && self.pers["copyCatLoadout"]["inUse"] && allowCopycat )
  312. {
  313. self maps\mp\gametypes\_class::setClass( "copycat" );
  314. self.class_num = getClassIndex( "copycat" );
  315.  
  316. clonedLoadout = self.pers["copyCatLoadout"];
  317.  
  318. loadoutPrimary = clonedLoadout["loadoutPrimary"];
  319. loadoutPrimaryAttachment = clonedLoadout["loadoutPrimaryAttachment"];
  320. loadoutPrimaryAttachment2 = clonedLoadout["loadoutPrimaryAttachment2"] ;
  321. loadoutPrimaryCamo = clonedLoadout["loadoutPrimaryCamo"];
  322. loadoutSecondary = clonedLoadout["loadoutSecondary"];
  323. loadoutSecondaryAttachment = clonedLoadout["loadoutSecondaryAttachment"];
  324. loadoutSecondaryAttachment2 = clonedLoadout["loadoutSecondaryAttachment2"];
  325. loadoutSecondaryCamo = clonedLoadout["loadoutSecondaryCamo"];
  326. loadoutEquipment = clonedLoadout["loadoutEquipment"];
  327. loadoutPerk1 = clonedLoadout["loadoutPerk1"];
  328. loadoutPerk2 = clonedLoadout["loadoutPerk2"];
  329. loadoutPerk3 = clonedLoadout["loadoutPerk3"];
  330. loadoutOffhand = clonedLoadout["loadoutOffhand"];
  331. loadoutDeathStreak = "specialty_copycat";
  332. }
  333. else if ( isSubstr( class, "custom" ) )
  334. {
  335. class_num = getClassIndex( class );
  336. self.class_num = class_num;
  337.  
  338. loadoutPrimary = cac_getWeapon( class_num, 0 );
  339. loadoutPrimaryAttachment = cac_getWeaponAttachment( class_num, 0 );
  340. loadoutPrimaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 0 );
  341. loadoutPrimaryCamo = cac_getWeaponCamo( class_num, 0 );
  342. loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
  343. loadoutSecondary = cac_getWeapon( class_num, 1 );
  344. loadoutSecondaryAttachment = cac_getWeaponAttachment( class_num, 1 );
  345. loadoutSecondaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 1 );
  346. loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
  347. loadoutEquipment = cac_getPerk( class_num, 0 );
  348. loadoutPerk1 = cac_getPerk( class_num, 1 );
  349. loadoutPerk2 = cac_getPerk( class_num, 2 );
  350. loadoutPerk3 = cac_getPerk( class_num, 3 );
  351. loadoutOffhand = cac_getOffhand( class_num );
  352. loadoutDeathStreak = cac_getDeathstreak( class_num );
  353. }
  354. else
  355. {
  356. class_num = getClassIndex( class );
  357. self.class_num = class_num;
  358.  
  359. loadoutPrimary = table_getWeapon( level.classTableName, class_num, 0 );
  360. loadoutPrimaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 0 , 0);
  361. loadoutPrimaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 0, 1 );
  362. loadoutPrimaryCamo = table_getWeaponCamo( level.classTableName, class_num, 0 );
  363. loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
  364. loadoutSecondary = table_getWeapon( level.classTableName, class_num, 1 );
  365. loadoutSecondaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 1 , 0);
  366. loadoutSecondaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 1, 1 );;
  367. loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
  368. loadoutEquipment = table_getEquipment( level.classTableName, class_num, 0 );
  369. loadoutPerk1 = table_getPerk( level.classTableName, class_num, 1 );
  370. loadoutPerk2 = table_getPerk( level.classTableName, class_num, 2 );
  371. loadoutPerk3 = table_getPerk( level.classTableName, class_num, 3 );
  372. loadoutOffhand = table_getOffhand( level.classTableName, class_num );
  373. loadoutDeathstreak = table_getDeathstreak( level.classTableName, class_num );
  374. }
  375.  
  376. if ( level.killstreakRewards )
  377. {
  378. loadoutKillstreak1 = self getPlayerData( "killstreaks", 0 );
  379. loadoutKillstreak2 = self getPlayerData( "killstreaks", 1 );
  380. loadoutKillstreak3 = self getPlayerData( "killstreaks", 2 );
  381. }
  382. else
  383. {
  384. loadoutKillstreak1 = "none";
  385. loadoutKillstreak2 = "none";
  386. loadoutKillstreak3 = "none";
  387. }
  388.  
  389. secondaryName = buildWeaponName( loadoutSecondary, loadoutSecondaryAttachment, loadoutSecondaryAttachment2 );
  390. self _giveWeapon( secondaryName, int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ) ) );
  391.  
  392. self.loadoutPrimaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutPrimaryCamo, 0 ));
  393. self.loadoutPrimary = loadoutPrimary;
  394. self.loadoutSecondary = loadoutSecondary;
  395. self.loadoutSecondaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ));
  396.  
  397. self SetOffhandPrimaryClass( "other" );
  398.  
  399. // Action Slots
  400. self _SetActionSlot( 1, "" );
  401. //self _SetActionSlot( 1, "nightvision" );
  402. self _SetActionSlot( 3, "altMode" );
  403. self _SetActionSlot( 4, "" );
  404.  
  405. // Perks
  406. self _clearPerks();
  407. self _detachAll();
  408.  
  409. // these special case giving pistol death have to come before
  410. // perk loadout to ensure player perk icons arent overwritten
  411. if ( level.dieHardMode )
  412. self maps\mp\perks\_perks::givePerk( "specialty_pistoldeath" );
  413.  
  414. // only give the deathstreak for the initial spawn for this life.
  415. if ( loadoutDeathStreak != "specialty_null" && getTime() == self.spawnTime )
  416. {
  417. deathVal = int( tableLookup( "mp/perkTable.csv", 1, loadoutDeathStreak, 6 ) );
  418.  
  419. if ( self _hasPerk( "specialty_rollover" ) )
  420. deathVal -= 1;
  421.  
  422. if ( self.pers["cur_death_streak"] == deathVal )
  423. {
  424. self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
  425. self thread maps\mp\gametypes\_hud_message::splashNotify( loadoutDeathStreak );
  426. }
  427. else if ( self.pers["cur_death_streak"] > deathVal )
  428. {
  429. self thread maps\mp\perks\_perks::givePerk( loadoutDeathStreak );
  430. }
  431. }
  432.  
  433. self loadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3 );
  434.  
  435. self setKillstreaks( loadoutKillstreak1, loadoutKillstreak2, loadoutKillstreak3 );
  436.  
  437. if ( self hasPerk( "specialty_extraammo", true ) && getWeaponClass( secondaryName ) != "weapon_projectile" )
  438. self giveMaxAmmo( secondaryName );
  439.  
  440. // Primary Weapon
  441. primaryName = buildWeaponName( loadoutPrimary, loadoutPrimaryAttachment, loadoutPrimaryAttachment2 );
  442. self _giveWeapon( primaryName, self.loadoutPrimaryCamo );
  443.  
  444. // fix changing from a riotshield class to a riotshield class during grace period not giving a shield
  445. if ( primaryName == "riotshield_mp" && level.inGracePeriod )
  446. self notify ( "weapon_change", "riotshield_mp" );
  447.  
  448. if ( self hasPerk( "specialty_extraammo", true ) )
  449. self giveMaxAmmo( primaryName );
  450.  
  451. self setSpawnWeapon( primaryName );
  452.  
  453. primaryTokens = strtok( primaryName, "_" );
  454. self.pers["primaryWeapon"] = primaryTokens[0];
  455.  
  456. // Primary Offhand was given by givePerk (it's your perk1)
  457.  
  458. // Secondary Offhand
  459. offhandSecondaryWeapon = loadoutOffhand + "_mp";
  460. if ( loadoutOffhand == "flash_grenade" )
  461. self SetOffhandSecondaryClass( "flash" );
  462. else
  463. self SetOffhandSecondaryClass( "smoke" );
  464.  
  465. self giveWeapon( offhandSecondaryWeapon );
  466. if( loadOutOffhand == "smoke_grenade" )
  467. self setWeaponAmmoClip( offhandSecondaryWeapon, 1 );
  468. else if( loadOutOffhand == "flash_grenade" )
  469. self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
  470. else if( loadOutOffhand == "concussion_grenade" )
  471. self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
  472. else
  473. self setWeaponAmmoClip( offhandSecondaryWeapon, 1 );
  474.  
  475. primaryWeapon = primaryName;
  476. self.primaryWeapon = primaryWeapon;
  477. self.secondaryWeapon = secondaryName;
  478.  
  479. self maps\mp\gametypes\_teams::playerModelForWeapon( self.pers["primaryWeapon"], getBaseWeaponName( secondaryName ) );
  480.  
  481. self.isSniper = (weaponClass( self.primaryWeapon ) == "sniper");
  482.  
  483. self maps\mp\gametypes\_weapons::updateMoveSpeedScale( "primary" );
  484.  
  485. // cac specialties that require loop threads
  486. self maps\mp\perks\_perks::cac_selector();
  487.  
  488. self notify ( "changed_kit" );
  489. self notify ( "giveLoadout" );
  490. }
  491.  
  492. _detachAll()
  493. {
  494. if ( isDefined( self.hasRiotShield ) && self.hasRiotShield )
  495. {
  496. if ( self.hasRiotShieldEquipped )
  497. {
  498. self DetachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  499. self.hasRiotShieldEquipped = false;
  500. }
  501. else
  502. {
  503. self DetachShieldModel( "weapon_riot_shield_mp", "tag_shield_back" );
  504. }
  505.  
  506. self.hasRiotShield = false;
  507. }
  508.  
  509. self detachAll();
  510. }
  511.  
  512. loadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3 )
  513. {
  514. loadoutEquipment = maps\mp\perks\_perks::validatePerk( 1, loadoutEquipment );
  515. loadoutPerk1 = maps\mp\perks\_perks::validatePerk( 1, loadoutPerk1 );
  516. loadoutPerk2 = maps\mp\perks\_perks::validatePerk( 2, loadoutPerk2 );
  517. loadoutPerk3 = maps\mp\perks\_perks::validatePerk( 3, loadoutPerk3 );
  518.  
  519. self maps\mp\perks\_perks::givePerk( loadoutEquipment );
  520. self maps\mp\perks\_perks::givePerk( loadoutPerk1 );
  521. self maps\mp\perks\_perks::givePerk( loadoutPerk2 );
  522. self maps\mp\perks\_perks::givePerk( loadoutPerk3 );
  523.  
  524. perkUpgrd[0] = tablelookup( "mp/perktable.csv", 1, loadoutPerk1, 8 );
  525. perkUpgrd[1] = tablelookup( "mp/perktable.csv", 1, loadoutPerk2, 8 );
  526. perkUpgrd[2] = tablelookup( "mp/perktable.csv", 1, loadoutPerk3, 8 );
  527.  
  528. foreach( upgrade in perkUpgrd )
  529. {
  530. if ( upgrade == "" || upgrade == "specialty_null" )
  531. continue;
  532.  
  533. if ( self isItemUnlocked( upgrade ) )
  534. self maps\mp\perks\_perks::givePerk( upgrade );
  535. }
  536.  
  537. }
  538.  
  539. trackRiotShield()
  540. {
  541. self endon ( "death" );
  542. self endon ( "disconnect" );
  543.  
  544. self.hasRiotShield = self hasWeapon( "riotshield_mp" );
  545. self.hasRiotShieldEquipped = (self.currentWeaponAtSpawn == "riotshield_mp");
  546.  
  547. // note this function must play nice with _detachAll().
  548.  
  549. if ( self.hasRiotShield )
  550. {
  551. if ( self.hasRiotShieldEquipped )
  552. {
  553. self AttachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  554. }
  555. else
  556. {
  557. self AttachShieldModel( "weapon_riot_shield_mp", "tag_shield_back" );
  558. }
  559. }
  560.  
  561. for ( ;; )
  562. {
  563. self waittill ( "weapon_change", newWeapon );
  564.  
  565. if ( newWeapon == "riotshield_mp" )
  566. {
  567. // defensive check in case we somehow get an extra "weapon_change"
  568. if ( self.hasRiotShieldEquipped )
  569. continue;
  570.  
  571. if ( self.hasRiotShield )
  572. self MoveShieldModel( "weapon_riot_shield_mp", "tag_shield_back", "tag_weapon_left" );
  573. else
  574. self AttachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  575.  
  576. self.hasRiotShield = true;
  577. self.hasRiotShieldEquipped = true;
  578. }
  579. else if ( (self IsMantling()) && (newWeapon == "none") )
  580. {
  581. // Do nothing, we want to keep that weapon on their arm.
  582. }
  583. else if ( self.hasRiotShieldEquipped )
  584. {
  585. assert( self.hasRiotShield );
  586. self.hasRiotShield = self hasWeapon( "riotshield_mp" );
  587.  
  588. if ( self.hasRiotShield )
  589. self MoveShieldModel( "weapon_riot_shield_mp", "tag_weapon_left", "tag_shield_back" );
  590. else
  591. self DetachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  592.  
  593. self.hasRiotShieldEquipped = false;
  594. }
  595. else if ( self.hasRiotShield )
  596. {
  597. if ( !self hasWeapon( "riotshield_mp" ) )
  598. {
  599. // we probably just lost all of our weapons (maybe switched classes)
  600. self DetachShieldModel( "weapon_riot_shield_mp", "tag_shield_back" );
  601. self.hasRiotShield = false;
  602. }
  603. }
  604. }
  605. }
  606.  
  607.  
  608. tryAttach( placement ) // deprecated; hopefully we won't need to bring this defensive function back
  609. {
  610. if ( !isDefined( placement ) || placement != "back" )
  611. tag = "tag_weapon_left";
  612. else
  613. tag = "tag_shield_back";
  614.  
  615. attachSize = self getAttachSize();
  616.  
  617. for ( i = 0; i < attachSize; i++ )
  618. {
  619. attachedTag = self getAttachTagName( i );
  620. if ( attachedTag == tag && self getAttachModelName( i ) == "weapon_riot_shield_mp" )
  621. {
  622. return;
  623. }
  624. }
  625.  
  626. self AttachShieldModel( "weapon_riot_shield_mp", tag );
  627. }
  628.  
  629. tryDetach( placement ) // deprecated; hopefully we won't need to bring this defensive function back
  630. {
  631. if ( !isDefined( placement ) || placement != "back" )
  632. tag = "tag_weapon_left";
  633. else
  634. tag = "tag_shield_back";
  635.  
  636.  
  637. attachSize = self getAttachSize();
  638.  
  639. for ( i = 0; i < attachSize; i++ )
  640. {
  641. attachedModel = self getAttachModelName( i );
  642. if ( attachedModel == "weapon_riot_shield_mp" )
  643. {
  644. self DetachShieldModel( attachedModel, tag);
  645. return;
  646. }
  647. }
  648. return;
  649. }
  650.  
  651.  
  652.  
  653. buildWeaponName( baseName, attachment1, attachment2 )
  654. {
  655. if ( !isDefined( level.letterToNumber ) )
  656. level.letterToNumber = makeLettersToNumbers();
  657.  
  658. // disable bling when perks are disabled
  659. if ( getDvarInt ( "scr_game_perks" ) == 0 )
  660. {
  661. attachment2 = "none";
  662.  
  663. if ( baseName == "onemanarmy" )
  664. return ( "beretta_mp" );
  665. }
  666.  
  667. weaponName = baseName;
  668. attachments = [];
  669.  
  670. if ( attachment1 != "none" && attachment2 != "none" )
  671. {
  672. if ( level.letterToNumber[attachment1[0]] < level.letterToNumber[attachment2[0]] )
  673. {
  674.  
  675. attachments[0] = attachment1;
  676. attachments[1] = attachment2;
  677.  
  678. }
  679. else if ( level.letterToNumber[attachment1[0]] == level.letterToNumber[attachment2[0]] )
  680. {
  681. if ( level.letterToNumber[attachment1[1]] < level.letterToNumber[attachment2[1]] )
  682. {
  683. attachments[0] = attachment1;
  684. attachments[1] = attachment2;
  685. }
  686. else
  687. {
  688. attachments[0] = attachment2;
  689. attachments[1] = attachment1;
  690. }
  691. }
  692. else
  693. {
  694. attachments[0] = attachment2;
  695. attachments[1] = attachment1;
  696. }
  697. }
  698. else if ( attachment1 != "none" )
  699. {
  700. attachments[0] = attachment1;
  701. }
  702. else if ( attachment2 != "none" )
  703. {
  704. attachments[0] = attachment2;
  705. }
  706.  
  707. foreach ( attachment in attachments )
  708. {
  709. weaponName += "_" + attachment;
  710. }
  711.  
  712. return ( weaponName + "_mp" );
  713. }
  714.  
  715.  
  716. makeLettersToNumbers()
  717. {
  718. array = [];
  719.  
  720. array["a"] = 0;
  721. array["b"] = 1;
  722. array["c"] = 2;
  723. array["d"] = 3;
  724. array["e"] = 4;
  725. array["f"] = 5;
  726. array["g"] = 6;
  727. array["h"] = 7;
  728. array["i"] = 8;
  729. array["j"] = 9;
  730. array["k"] = 10;
  731. array["l"] = 11;
  732. array["m"] = 12;
  733. array["n"] = 13;
  734. array["o"] = 14;
  735. array["p"] = 15;
  736. array["q"] = 16;
  737. array["r"] = 17;
  738. array["s"] = 18;
  739. array["t"] = 19;
  740. array["u"] = 20;
  741. array["v"] = 21;
  742. array["w"] = 22;
  743. array["x"] = 23;
  744. array["y"] = 24;
  745. array["z"] = 25;
  746.  
  747. return array;
  748. }
  749.  
  750. setKillstreaks( streak1, streak2, streak3 )
  751. {
  752. self.killStreaks = [];
  753.  
  754. if ( self _hasPerk( "specialty_hardline" ) )
  755. modifier = -1;
  756. else
  757. modifier = 0;
  758.  
  759. /*if ( streak1 == "none" && streak2 == "none" && streak3 == "none" )
  760. {
  761. streak1 = "uav";
  762. streak2 = "precision_airstrike";
  763. streak3 = "helicopter";
  764. }*/
  765.  
  766. killStreaks = [];
  767.  
  768. if ( streak1 != "none" )
  769. {
  770. //if ( !level.splitScreen )
  771. streakVal = int( tableLookup( "mp/killstreakTable.csv", 1, streak1, 4 ) );
  772. //else
  773. // streakVal = int( tableLookup( "mp/killstreakTable.csv", 1, streak1, 5 ) );
  774. killStreaks[streakVal + modifier] = streak1;
  775. }
  776.  
  777. if ( streak2 != "none" )
  778. {
  779. //if ( !level.splitScreen )
  780. streakVal = int( tableLookup( "mp/killstreakTable.csv", 1, streak2, 4 ) );
  781. //else
  782. // streakVal = int( tableLookup( "mp/killstreakTable.csv", 1, streak2, 5 ) );
  783. killStreaks[streakVal + modifier] = streak2;
  784. }
  785.  
  786. if ( streak3 != "none" )
  787. {
  788. //if ( !level.splitScreen )
  789. streakVal = int( tableLookup( "mp/killstreakTable.csv", 1, streak3, 4 ) );
  790. //else
  791. // streakVal = int( tableLookup( "mp/killstreakTable.csv", 1, streak3, 5 ) );
  792. killStreaks[streakVal + modifier] = streak3;
  793. }
  794.  
  795. // foreach doesn't loop through numbers arrays in number order; it loops through the elements in the order
  796. // they were added. We'll use this to fix it for now.
  797. maxVal = 0;
  798. foreach ( streakVal, streakName in killStreaks )
  799. {
  800. if ( streakVal > maxVal )
  801. maxVal = streakVal;
  802. }
  803.  
  804. for ( streakIndex = 0; streakIndex <= maxVal; streakIndex++ )
  805. {
  806. if ( !isDefined( killStreaks[streakIndex] ) )
  807. continue;
  808.  
  809. streakName = killStreaks[streakIndex];
  810.  
  811. self.killStreaks[ streakIndex ] = killStreaks[ streakIndex ];
  812. }
  813. // end lameness
  814.  
  815. // defcon rollover
  816. maxRollOvers = 10;
  817. newKillstreaks = self.killstreaks;
  818. for ( rollOver = 1; rollOver <= maxRollOvers; rollOver++ )
  819. {
  820. foreach ( streakVal, streakName in self.killstreaks )
  821. {
  822. newKillstreaks[ streakVal + (maxVal*rollOver) ] = streakName + "-rollover" + rollOver;
  823. }
  824. }
  825.  
  826. self.killstreaks = newKillstreaks;
  827. }
  828.  
  829.  
  830. replenishLoadout() // used by ammo hardpoint.
  831. {
  832. team = self.pers["team"];
  833. class = self.pers["class"];
  834.  
  835. weaponsList = self GetWeaponsListAll();
  836. for( idx = 0; idx < weaponsList.size; idx++ )
  837. {
  838. weapon = weaponsList[idx];
  839.  
  840. self giveMaxAmmo( weapon );
  841. self SetWeaponAmmoClip( weapon, 9999 );
  842.  
  843. if ( weapon == "claymore_mp" || weapon == "claymore_detonator_mp" )
  844. self setWeaponAmmoStock( weapon, 2 );
  845. }
  846.  
  847. if ( self getAmmoCount( level.classGrenades[class]["primary"]["type"] ) < level.classGrenades[class]["primary"]["count"] )
  848. self SetWeaponAmmoClip( level.classGrenades[class]["primary"]["type"], level.classGrenades[class]["primary"]["count"] );
  849.  
  850. if ( self getAmmoCount( level.classGrenades[class]["secondary"]["type"] ) < level.classGrenades[class]["secondary"]["count"] )
  851. self SetWeaponAmmoClip( level.classGrenades[class]["secondary"]["type"], level.classGrenades[class]["secondary"]["count"] );
  852. }
  853.  
  854.  
  855. onPlayerConnecting()
  856. {
  857. for(;;)
  858. {
  859. level waittill( "connected", player );
  860.  
  861. if ( !isDefined( player.pers["class"] ) )
  862. {
  863. player.pers["class"] = "";
  864. }
  865. player.class = player.pers["class"];
  866. player.lastClass = "";
  867. player.detectExplosives = false;
  868. player.bombSquadIcons = [];
  869. player.bombSquadIds = [];
  870. }
  871. }
  872.  
  873.  
  874. fadeAway( waitDelay, fadeDelay )
  875. {
  876. wait waitDelay;
  877.  
  878. self fadeOverTime( fadeDelay );
  879. self.alpha = 0;
  880. }
  881.  
  882.  
  883. setClass( newClass )
  884. {
  885. self.curClass = newClass;
  886. }
  887.  
  888. getPerkForClass( perkSlot, className )
  889. {
  890. class_num = getClassIndex( className );
  891.  
  892. if( isSubstr( className, "custom" ) )
  893. return cac_getPerk( class_num, perkSlot );
  894. else
  895. return table_getPerk( level.classTableName, class_num, perkSlot );
  896. }
  897.  
  898.  
  899. classHasPerk( className, perkName )
  900. {
  901. return( getPerkForClass( 0, className ) == perkName || getPerkForClass( 1, className ) == perkName || getPerkForClass( 2, className ) == perkName );
  902. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement