NachosEater

_class

Nov 19th, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 75.22 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. KILLSTREAK_GIMME_SLOT = 0;
  7. KILLSTREAK_SLOT_1 = 1;
  8. KILLSTREAK_SLOT_2 = 2;
  9. KILLSTREAK_SLOT_3 = 3;
  10. KILLSTREAK_ALL_PERKS_SLOT = 4;
  11. KILLSTREAK_STACKING_START_SLOT = 5;
  12.  
  13. init()
  14. {
  15. level.classMap["class0"] = 0;
  16. level.classMap["class1"] = 1;
  17. level.classMap["class2"] = 2;
  18. level.classMap["class3"] = 3;
  19. level.classMap["class4"] = 4;
  20. level.classMap["class5"] = 5;
  21. level.classMap["class6"] = 6;
  22. level.classMap["class7"] = 7;
  23. level.classMap["class8"] = 8;
  24. level.classMap["class9"] = 9;
  25. level.classMap["class10"] = 10;
  26. level.classMap["class11"] = 11;
  27. level.classMap["class12"] = 12;
  28. level.classMap["class13"] = 13;
  29. level.classMap["class14"] = 14;
  30.  
  31. level.classMap["custom1"] = 0;
  32. level.classMap["custom2"] = 1;
  33. level.classMap["custom3"] = 2;
  34. level.classMap["custom4"] = 3;
  35. level.classMap["custom5"] = 4;
  36. level.classMap["custom6"] = 5;
  37. level.classMap["custom7"] = 6;
  38. level.classMap["custom8"] = 7;
  39. level.classMap["custom9"] = 8;
  40. level.classMap["custom10"] = 9;
  41. level.classMap["custom11"] = 10;
  42. level.classMap["custom12"] = 11;
  43. level.classMap["custom13"] = 12;
  44. level.classMap["custom14"] = 13;
  45. level.classMap["custom15"] = 14;
  46.  
  47. level.classMap["axis_recipe1"] = 0;
  48. level.classMap["axis_recipe2"] = 1;
  49. level.classMap["axis_recipe3"] = 2;
  50. level.classMap["axis_recipe4"] = 3;
  51. level.classMap["axis_recipe5"] = 4;
  52.  
  53. level.classMap["allies_recipe1"] = 0;
  54. level.classMap["allies_recipe2"] = 1;
  55. level.classMap["allies_recipe3"] = 2;
  56. level.classMap["allies_recipe4"] = 3;
  57. level.classMap["allies_recipe5"] = 4;
  58.  
  59. level.classMap["copycat"] = -1;
  60.  
  61. /#
  62. // classes testclients may choose from.
  63. level.botClasses = [];
  64. level.botClasses[0] = "class0";
  65. level.botClasses[1] = "class0";
  66. level.botClasses[2] = "class0";
  67. level.botClasses[3] = "class0";
  68. level.botClasses[4] = "class0";
  69. #/
  70.  
  71. level.defaultClass = "CLASS_ASSAULT";
  72.  
  73. level.classTableName = "mp/classTable.csv";
  74.  
  75. level thread onPlayerConnecting();
  76. }
  77.  
  78.  
  79. getClassChoice( response )
  80. {
  81. assert( isDefined( level.classMap[response] ) );
  82.  
  83. return response;
  84. }
  85.  
  86. getWeaponChoice( response )
  87. {
  88. tokens = strtok( response, "," );
  89. if ( tokens.size > 1 )
  90. return int(tokens[1]);
  91. else
  92. return 0;
  93. }
  94.  
  95.  
  96. logClassChoice( class, primaryWeapon, specialType, perks )
  97. {
  98. if ( class == self.lastClass )
  99. return;
  100.  
  101. self logstring( "choseclass: " + class + " weapon: " + primaryWeapon + " special: " + specialType );
  102. for( i=0; i<perks.size; i++ )
  103. self logstring( "perk" + i + ": " + perks[i] );
  104.  
  105. self.lastClass = class;
  106. }
  107.  
  108. cac_getCustomClassLoc()
  109. {
  110. if( getDvarInt( "xblive_privatematch" ) )
  111. {
  112. return "privateMatchCustomClasses";
  113. }
  114. else
  115. {
  116. return "customClasses";
  117. }
  118. }
  119.  
  120. cac_getWeapon( classIndex, weaponIndex )
  121. {
  122. customClassLoc = cac_getCustomClassLoc();
  123. return self getPlayerData( customClassLoc, classIndex, "weaponSetups", weaponIndex, "weapon" );
  124. }
  125.  
  126. cac_getWeaponAttachment( classIndex, weaponIndex )
  127. {
  128. customClassLoc = cac_getCustomClassLoc();
  129. return self getPlayerData( customClassLoc, classIndex, "weaponSetups", weaponIndex, "attachment", 0 );
  130. }
  131.  
  132. cac_getWeaponAttachmentTwo( classIndex, weaponIndex )
  133. {
  134. customClassLoc = cac_getCustomClassLoc();
  135. return self getPlayerData( customClassLoc, classIndex, "weaponSetups", weaponIndex, "attachment", 1 );
  136. }
  137.  
  138. cac_getWeaponBuff( classIndex, weaponIndex )
  139. {
  140. customClassLoc = cac_getCustomClassLoc();
  141. return self getPlayerData( customClassLoc, classIndex, "weaponSetups", weaponIndex, "buff" );
  142. }
  143.  
  144. cac_getWeaponCamo( classIndex, weaponIndex )
  145. {
  146. customClassLoc = cac_getCustomClassLoc();
  147. return self getPlayerData( customClassLoc, classIndex, "weaponSetups", weaponIndex, "camo" );
  148. }
  149.  
  150. cac_getWeaponReticle( classIndex, weaponIndex )
  151. {
  152. customClassLoc = cac_getCustomClassLoc();
  153. return self getPlayerData( customClassLoc, classIndex, "weaponSetups", weaponIndex, "reticle" );
  154. }
  155.  
  156. cac_getPerk( classIndex, perkIndex )
  157. {
  158. customClassLoc = cac_getCustomClassLoc();
  159. return self getPlayerData( customClassLoc, classIndex, "perks", perkIndex );
  160. }
  161.  
  162. cac_getKillstreak( class_num, streakType, streakIndex )
  163. {
  164. playerData = undefined;
  165. switch( streakType )
  166. {
  167. case "streaktype_support":
  168. playerData = "defenseStreaks";
  169. break;
  170. case "streaktype_specialist":
  171. playerData = "specialistStreaks";
  172. break;
  173. default: // assault
  174. playerData = "assaultStreaks";
  175. break;
  176. }
  177. customClassLoc = cac_getCustomClassLoc();
  178. return self getPlayerData( customClassLoc, class_num, playerData, streakIndex );
  179. }
  180.  
  181. cac_getDeathstreak( classIndex )
  182. {
  183. customClassLoc = cac_getCustomClassLoc();
  184. return self getPlayerData( customClassLoc, classIndex, "deathstreak" );
  185. }
  186.  
  187. /*
  188. cac_getAmmoType( classIndex )
  189. {
  190. customClassLoc = cac_getCustomClassLoc();
  191. return self getPlayerData( customClassLoc, classIndex, "perks", 6 );
  192. }
  193. */
  194.  
  195. cac_getOffhand( classIndex )
  196. {
  197. customClassLoc = cac_getCustomClassLoc();
  198. return self getPlayerData( customClassLoc, classIndex, "perks", 6 );
  199. }
  200.  
  201. recipe_getKillstreak( teamName, classIndex, streakType, streakIndex )
  202. {
  203. playerData = undefined;
  204. switch( streakType )
  205. {
  206. case "streaktype_support":
  207. playerData = "defenseStreaks";
  208. break;
  209. case "streaktype_specialist":
  210. playerData = "specialistStreaks";
  211. break;
  212. default: // assault
  213. playerData = "assaultStreaks";
  214. break;
  215. }
  216. return getMatchRulesData( "defaultClasses", teamName, classIndex, "class", playerData, streakIndex );
  217. }
  218.  
  219. table_getWeapon( tableName, classIndex, weaponIndex )
  220. {
  221. if ( weaponIndex == 0 )
  222. return tableLookup( tableName, 0, "loadoutPrimary", classIndex + 1 );
  223. else
  224. return tableLookup( tableName, 0, "loadoutSecondary", classIndex + 1 );
  225. }
  226.  
  227. table_getWeaponAttachment( tableName, classIndex, weaponIndex, attachmentIndex )
  228. {
  229. tempName = "none";
  230.  
  231. if ( weaponIndex == 0 )
  232. {
  233. if ( !isDefined( attachmentIndex ) || attachmentIndex == 0 )
  234. tempName = tableLookup( tableName, 0, "loadoutPrimaryAttachment", classIndex + 1 );
  235. else
  236. tempName = tableLookup( tableName, 0, "loadoutPrimaryAttachment2", classIndex + 1 );
  237. }
  238. else
  239. {
  240. if ( !isDefined( attachmentIndex ) || attachmentIndex == 0 )
  241. tempName = tableLookup( tableName, 0, "loadoutSecondaryAttachment", classIndex + 1 );
  242. else
  243. tempName = tableLookup( tableName, 0, "loadoutSecondaryAttachment2", classIndex + 1 );
  244. }
  245.  
  246. if ( tempName == "" || tempName == "none" )
  247. return "none";
  248. else
  249. return tempName;
  250.  
  251.  
  252. }
  253.  
  254. table_getWeaponBuff( tableName, classIndex, weaponIndex )
  255. {
  256. if ( weaponIndex == 0 )
  257. return tableLookup( tableName, 0, "loadoutPrimaryBuff", classIndex + 1 );
  258. else
  259. return tableLookup( tableName, 0, "loadoutSecondaryBuff", classIndex + 1 );
  260. }
  261.  
  262. table_getWeaponCamo( tableName, classIndex, weaponIndex )
  263. {
  264. if ( weaponIndex == 0 )
  265. return tableLookup( tableName, 0, "loadoutPrimaryCamo", classIndex + 1 );
  266. else
  267. return tableLookup( tableName, 0, "loadoutSecondaryCamo", classIndex + 1 );
  268. }
  269.  
  270. table_getWeaponReticle( tableName, classIndex, weaponIndex )
  271. {
  272. return "none";
  273. }
  274.  
  275. table_getEquipment( tableName, classIndex, perkIndex )
  276. {
  277. assert( perkIndex < 5 );
  278. return tableLookup( tableName, 0, "loadoutEquipment", classIndex + 1 );
  279. }
  280.  
  281. table_getPerk( tableName, classIndex, perkIndex )
  282. {
  283. assert( perkIndex <= 6 );
  284. return tableLookup( tableName, 0, "loadoutPerk" + perkIndex, classIndex + 1 );
  285. }
  286.  
  287. table_getTeamPerk( tableName, classIndex )
  288. {
  289. return tableLookup( tableName, 0, "loadoutTeamPerk", classIndex + 1 );
  290. }
  291.  
  292. table_getOffhand( tableName, classIndex )
  293. {
  294. return tableLookup( tableName, 0, "loadoutOffhand", classIndex + 1 );
  295. }
  296.  
  297. table_getKillstreak( tableName, classIndex, streakIndex )
  298. {
  299. return tableLookup( tableName, 0, "loadoutStreak" + streakIndex, classIndex + 1 );
  300. }
  301.  
  302. table_getDeathstreak( tableName, classIndex )
  303. {
  304. return tableLookup( tableName, 0, "loadoutDeathstreak", classIndex + 1 );
  305. }
  306.  
  307. /*
  308. table_getAmmoType( tableName, classIndex )
  309. {
  310. return tableLookup( tableName, 0, "loadoutAmmoType", classIndex + 1 );
  311. }
  312. */
  313.  
  314. getClassIndex( className )
  315. {
  316. assert( isDefined( level.classMap[className] ) );
  317.  
  318. return level.classMap[className];
  319. }
  320.  
  321.  
  322. cloneLoadout()
  323. {
  324. teamName = "none";
  325.  
  326. clonedLoadout = [];
  327.  
  328. class = self.curClass;
  329.  
  330. if ( class == "copycat" )
  331. return ( undefined );
  332.  
  333. if( isSubstr( class, "axis" ) )
  334. {
  335. teamName = "axis";
  336. }
  337. else if( isSubstr( class, "allies" ) )
  338. {
  339. teamName = "allies";
  340. }
  341.  
  342. if (teamName != "none")
  343. {
  344. classIndex = getClassIndex( class );
  345.  
  346. loadoutPrimaryAttachment2 = "none";
  347. loadoutSecondaryAttachment2 = "none";
  348.  
  349. loadoutPrimary = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "weapon" );
  350. loadoutPrimaryAttachment = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "attachment", 0 );
  351. loadoutPrimaryAttachment2 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "attachment", 1 );
  352. loadoutPrimaryBuff = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "buff" );
  353. loadoutPrimaryCamo = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "camo" );
  354. loadoutPrimaryReticle = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "reticle" );
  355.  
  356. loadoutSecondary = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "weapon" );
  357. loadoutSecondaryAttachment = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "attachment", 0 );
  358. loadoutSecondaryAttachment2 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "attachment", 1 );
  359. loadoutSecondaryBuff = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "buff" );
  360. loadoutSecondaryCamo = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "camo" );
  361. loadoutSecondaryReticle = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "reticle" );
  362.  
  363. loadoutEquipment = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 0 );
  364. loadoutPerk1 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 1 );
  365. loadoutPerk2 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 2 );
  366. loadoutPerk3 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 3 );
  367. loadoutStreakType = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 5 );
  368. loadoutKillstreak1 = recipe_getKillstreak( teamName, classIndex, loadoutStreakType, 0 );
  369. loadoutKillstreak2 = recipe_getKillstreak( teamName, classIndex, loadoutStreakType, 1 );
  370. loadoutKillstreak3 = recipe_getKillstreak( teamName, classIndex, loadoutStreakType, 2 );
  371. loadoutOffhand = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 6 );
  372. loadoutDeathStreak = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "deathstreak" );
  373. }
  374. else if( isSubstr( class, "custom" ) )
  375. {
  376. class_num = getClassIndex( class );
  377.  
  378. loadoutPrimaryAttachment2 = "none";
  379. loadoutSecondaryAttachment2 = "none";
  380.  
  381. loadoutPrimary = cac_getWeapon( class_num, 0 );
  382. loadoutPrimaryAttachment = cac_getWeaponAttachment( class_num, 0 );
  383. loadoutPrimaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 0 );
  384. loadoutPrimaryBuff = cac_getWeaponBuff( class_num, 0 );
  385. loadoutPrimaryCamo = cac_getWeaponCamo( class_num, 0 );
  386. loadoutPrimaryReticle = cac_getWeaponReticle( class_num, 0 );
  387. loadoutSecondary = cac_getWeapon( class_num, 1 );
  388. loadoutSecondaryAttachment = cac_getWeaponAttachment( class_num, 1 );
  389. loadoutSecondaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 1 );
  390. loadoutSecondaryBuff = cac_getWeaponBuff( class_num, 1 );
  391. loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
  392. loadoutSecondaryReticle = cac_getWeaponReticle( class_num, 1 );
  393. loadoutEquipment = cac_getPerk( class_num, 0 );
  394. loadoutPerk1 = cac_getPerk( class_num, 1 );
  395. loadoutPerk2 = cac_getPerk( class_num, 2 );
  396. loadoutPerk3 = cac_getPerk( class_num, 3 );
  397. loadoutStreakType = cac_getPerk( class_num, 5 );
  398. loadoutKillstreak1 = cac_getKillstreak( class_num, loadoutStreakType, 0 );
  399. loadoutKillstreak2 = cac_getKillstreak( class_num, loadoutStreakType, 1 );
  400. loadoutKillstreak3 = cac_getKillstreak( class_num, loadoutStreakType, 2 );
  401. loadoutOffhand = cac_getOffhand( class_num );
  402. loadoutDeathStreak = cac_getDeathstreak( class_num );
  403. //loadoutAmmoType = cac_getAmmoType( class_num );
  404. }
  405. else
  406. {
  407. class_num = getClassIndex( class );
  408.  
  409. loadoutPrimary = table_getWeapon( level.classTableName, class_num, 0 );
  410. loadoutPrimaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 0 , 0);
  411. loadoutPrimaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 0, 1 );
  412. loadoutPrimaryBuff = table_getWeaponBuff( level.classTableName, class_num, 0 );
  413. loadoutPrimaryCamo = table_getWeaponCamo( level.classTableName, class_num, 0 );
  414. loadoutPrimaryReticle = table_getWeaponReticle( level.classTableName, class_num, 0 );
  415. loadoutSecondary = table_getWeapon( level.classTableName, class_num, 1 );
  416. loadoutSecondaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 1, 0);
  417. loadoutSecondaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 1, 1 );
  418. loadoutSecondaryBuff = table_getWeaponBuff( level.classTableName, class_num, 1 );
  419. loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
  420. loadoutSecondaryReticle = table_getWeaponReticle( level.classTableName, class_num, 1 );
  421. loadoutEquipment = table_getEquipment( level.classTableName, class_num, 0 );
  422. loadoutPerk1 = table_getPerk( level.classTableName, class_num, 1 );
  423. loadoutPerk2 = table_getPerk( level.classTableName, class_num, 2 );
  424. loadoutPerk3 = table_getPerk( level.classTableName, class_num, 3 );
  425. loadoutStreakType = table_getPerk( level.classTableName, class_num, 5 );
  426. loadoutOffhand = table_getOffhand( level.classTableName, class_num );
  427. loadoutDeathStreak = table_getDeathstreak( level.classTableName, class_num );
  428. //loadoutAmmoType = table_getAmmoType( level.classTableName, class_num );
  429.  
  430. switch( loadoutStreakType )
  431. {
  432. case "streaktype_support":
  433. defaultKillstreak1 = table_getKillstreak( level.classTableName, 3, 1 );
  434. defaultKillstreak2 = table_getKillstreak( level.classTableName, 3, 2 );
  435. defaultKillstreak3 = table_getKillstreak( level.classTableName, 3, 3 );
  436. break;
  437. case "streaktype_specialist":
  438. defaultKillstreak1 = table_getKillstreak( level.classTableName, 1, 1 );
  439. defaultKillstreak2 = table_getKillstreak( level.classTableName, 1, 2 );
  440. defaultKillstreak3 = table_getKillstreak( level.classTableName, 1, 3 );
  441. break;
  442. default: // assault
  443. defaultKillstreak1 = table_getKillstreak( level.classTableName, 0, 1 );
  444. defaultKillstreak2 = table_getKillstreak( level.classTableName, 0, 2 );
  445. defaultKillstreak3 = table_getKillstreak( level.classTableName, 0, 3 );
  446. break;
  447. }
  448.  
  449. loadoutKillstreak1 = defaultKillstreak1;
  450. loadoutKillstreak2 = defaultKillstreak2;
  451. loadoutKillstreak3 = defaultKillstreak3;
  452. }
  453.  
  454. clonedLoadout["inUse"] = false;
  455. clonedLoadout["loadoutPrimary"] = loadoutPrimary;
  456. clonedLoadout["loadoutPrimaryAttachment"] = loadoutPrimaryAttachment;
  457. clonedLoadout["loadoutPrimaryAttachment2"] = loadoutPrimaryAttachment2;
  458. clonedLoadout["loadoutPrimaryBuff"] = loadoutPrimaryBuff;
  459. clonedLoadout["loadoutPrimaryCamo"] = loadoutPrimaryCamo;
  460. clonedLoadout["loadoutPrimaryReticle"] = loadoutPrimaryReticle;
  461. clonedLoadout["loadoutSecondary"] = loadoutSecondary;
  462. clonedLoadout["loadoutSecondaryAttachment"] = loadoutSecondaryAttachment;
  463. clonedLoadout["loadoutSecondaryAttachment2"] = loadoutSecondaryAttachment2;
  464. clonedLoadout["loadoutSecondaryBuff"] = loadoutSecondaryBuff;
  465. clonedLoadout["loadoutSecondaryCamo"] = loadoutSecondaryCamo;
  466. clonedLoadout["loadoutSecondaryReticle"] = loadoutSecondaryReticle;
  467. clonedLoadout["loadoutEquipment"] = loadoutEquipment;
  468. clonedLoadout["loadoutPerk1"] = loadoutPerk1;
  469. clonedLoadout["loadoutPerk2"] = loadoutPerk2;
  470. clonedLoadout["loadoutPerk3"] = loadoutPerk3;
  471. clonedLoadout["loadoutStreakType"] = loadoutStreakType;
  472. clonedLoadout["loadoutKillstreak1"] = loadoutKillstreak1;
  473. clonedLoadout["loadoutKillstreak2"] = loadoutKillstreak2;
  474. clonedLoadout["loadoutKillstreak3"] = loadoutKillstreak3;
  475. clonedLoadout["loadoutDeathstreak"] = loadoutDeathstreak;
  476. //clonedLoadout["loadoutAmmoType"] = loadoutAmmoType;
  477. clonedLoadout["loadoutOffhand"] = loadoutOffhand;
  478.  
  479. return ( clonedLoadout );
  480. }
  481.  
  482. //avoiding going through code for extra perk types
  483. loadoutFakePerks( loadoutStreakType, loadoutAmmoType )
  484. {
  485. switch ( loadoutStreakType )
  486. {
  487. case "streaktype_support":
  488. self.streakType = "support";
  489. break;
  490. case "streaktype_specialist":
  491. self.streakType = "specialist";
  492. break;
  493. default: // assault/null:
  494. self.streakType = "assault";
  495. }
  496.  
  497. //self.ammoType = loadoutAmmoType;
  498. }
  499.  
  500. getLoadoutStreakTypeFromStreakType( streakType )
  501. {
  502. if ( !isDefined( streakType ) )
  503. {
  504. assertEx( false, "getLoadoutStreakTypeFromStreakType() called with undefined streaktype" );
  505. return "streaktype_assault";
  506. }
  507.  
  508. switch ( streakType )
  509. {
  510. case "support":
  511. return "streaktype_support";
  512. case "specialist":
  513. return "streaktype_specialist";
  514. case "assault":
  515. return "streaktype_assault";
  516. default:
  517. assertEx( false, "getLoadoutStreakTypeFromStreakType() called with unknown streaktype" );
  518. return "streaktype_assault";
  519. }
  520. }
  521.  
  522. giveLoadout( team, class, allowCopycat, setPrimarySpawnWeapon ) // setPrimarySpawnWeapon only when called during spawn
  523. {
  524. self takeAllWeapons();
  525.  
  526. self.changingWeapon = undefined;
  527.  
  528. teamName = "none";
  529. if ( !isDefined( setPrimarySpawnWeapon ) )
  530. setPrimarySpawnWeapon = true;
  531.  
  532. primaryIndex = 0;
  533.  
  534. // initialize specialty array
  535. self.specialty = [];
  536.  
  537. if ( !isDefined( allowCopycat ) )
  538. allowCopycat = true;
  539.  
  540. primaryWeapon = undefined;
  541.  
  542. // set in game mode custom class
  543. loadoutKillstreak1 = undefined;
  544. loadoutKillstreak2 = undefined;
  545. loadoutKillstreak3 = undefined;
  546.  
  547. if( isSubstr( class, "axis" ) )
  548. {
  549. teamName = "axis";
  550. }
  551. else if( isSubstr( class, "allies" ) )
  552. {
  553. teamName = "allies";
  554. }
  555.  
  556. clonedLoadout = [];
  557. if ( isDefined( self.pers["copyCatLoadout"] ) && self.pers["copyCatLoadout"]["inUse"] && allowCopycat )
  558. {
  559. self maps\mp\gametypes\_class::setClass( "copycat" );
  560. self.class_num = getClassIndex( "copycat" );
  561.  
  562. clonedLoadout = self.pers["copyCatLoadout"];
  563.  
  564. loadoutPrimary = clonedLoadout["loadoutPrimary"];
  565. loadoutPrimaryAttachment = clonedLoadout["loadoutPrimaryAttachment"];
  566. loadoutPrimaryAttachment2 = clonedLoadout["loadoutPrimaryAttachment2"] ;
  567. loadoutPrimaryBuff = clonedLoadout["loadoutPrimaryBuff"];
  568. loadoutPrimaryCamo = clonedLoadout["loadoutPrimaryCamo"];
  569. loadoutPrimaryReticle = clonedLoadout["loadoutPrimaryReticle"];
  570. loadoutSecondary = clonedLoadout["loadoutSecondary"];
  571. loadoutSecondaryAttachment = clonedLoadout["loadoutSecondaryAttachment"];
  572. loadoutSecondaryAttachment2 = clonedLoadout["loadoutSecondaryAttachment2"];
  573. loadoutSecondaryBuff = clonedLoadout["loadoutSecondaryBuff"];
  574. loadoutSecondaryCamo = clonedLoadout["loadoutSecondaryCamo"];
  575. loadoutSecondaryReticle = clonedLoadout["loadoutSecondaryReticle"];
  576. loadoutEquipment = clonedLoadout["loadoutEquipment"];
  577. loadoutPerk1 = clonedLoadout["loadoutPerk1"];
  578. loadoutPerk2 = clonedLoadout["loadoutPerk2"];
  579. loadoutPerk3 = clonedLoadout["loadoutPerk3"];
  580. loadoutStreakType = clonedLoadout["loadoutStreakType"];
  581. loadoutOffhand = clonedLoadout["loadoutOffhand"];
  582. loadoutDeathStreak = clonedLoadout["loadoutDeathstreak"];
  583. loadoutAmmoType = clonedLoadout["loadoutAmmoType"];
  584. }
  585. else if (teamName != "none")
  586. {
  587. classIndex = getClassIndex( class );
  588.  
  589. loadoutPrimaryAttachment2 = "none";
  590. loadoutSecondaryAttachment2 = "none";
  591.  
  592. loadoutPrimary = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "weapon" );
  593. loadoutPrimaryAttachment = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "attachment", 0 );
  594. loadoutPrimaryAttachment2 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "attachment", 1 );
  595. loadoutPrimaryBuff = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "buff" );
  596. loadoutPrimaryCamo = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "camo" );
  597. loadoutPrimaryReticle = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 0, "reticle" );
  598.  
  599. loadoutSecondary = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "weapon" );
  600. loadoutSecondaryAttachment = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "attachment", 0 );
  601. loadoutSecondaryAttachment2 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "attachment", 1 );
  602. loadoutSecondaryBuff = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "buff" );
  603. loadoutSecondaryCamo = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "camo" );
  604. loadoutSecondaryReticle = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "weaponSetups", 1, "reticle" );
  605.  
  606. // replace the placeholder throwing knife with the valid secondary if there is one
  607. if ( loadoutPrimary == "throwingknife" && loadoutSecondary != "none" )
  608. {
  609. loadoutPrimary = loadoutSecondary;
  610. loadoutPrimaryAttachment = loadoutSecondaryAttachment;
  611. loadoutPrimaryAttachment2 = loadoutSecondaryAttachment2;
  612. loadoutPrimaryBuff = loadoutSecondaryBuff;
  613. loadoutPrimaryCamo = loadoutSecondaryCamo;
  614. loadoutPrimaryReticle = loadoutSecondaryReticle;
  615.  
  616. loadoutSecondary = "none";
  617. loadoutSecondaryAttachment = "none";
  618. loadoutSecondaryAttachment2 = "none";
  619. loadoutSecondaryBuff = "specialty_null";
  620. loadoutSecondaryCamo = "none";
  621. loadoutSecondaryReticle = "none";
  622. }
  623. // otherwise replace with normal default for invalid class
  624. else if ( loadoutPrimary == "throwingknife" && loadoutSecondary == "none" )
  625. {
  626. loadoutPrimary = table_getWeapon( level.classTableName, 10, 1 );
  627. }
  628.  
  629. loadoutEquipment = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 0 );
  630. loadoutPerk1 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 1 );
  631. loadoutPerk2 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 2 );
  632. loadoutPerk3 = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 3 );
  633.  
  634. // replace secondary with default in case overkill perk was used to give 2 primaries and perks are disabled
  635. if ( loadoutSecondary != "none" && !isValidSecondary( loadoutSecondary, loadoutPerk2, loadoutPerk3, false ) )
  636. loadoutSecondary = table_getWeapon( level.classTableName, 10, 1 );
  637.  
  638. loadoutStreakType = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 5 );
  639. loadoutKillstreak1 = recipe_getKillstreak( teamName, classIndex, loadoutStreakType, 0 );
  640. loadoutKillstreak2 = recipe_getKillstreak( teamName, classIndex, loadoutStreakType, 1 );
  641. loadoutKillstreak3 = recipe_getKillstreak( teamName, classIndex, loadoutStreakType, 2 );
  642. loadoutOffhand = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "perks", 6 );
  643. // hack, until game mode default class data can be reset
  644. if ( loadoutOffhand == "specialty_null" )
  645. loadoutOffhand = "none";
  646. loadoutDeathStreak = getMatchRulesData( "defaultClasses", teamName, classIndex, "class", "deathstreak" );
  647. if ( getMatchRulesData( "defaultClasses", teamName, classIndex, "juggernaut" ) )
  648. {
  649. self.isJuggernaut = true;
  650. self thread recipeClassApplyJuggernaut();
  651. }
  652. }
  653. else if ( isSubstr( class, "custom" ) )
  654. {
  655. class_num = getClassIndex( class );
  656. self.class_num = class_num;
  657.  
  658. loadoutPrimary = cac_getWeapon( class_num, 0 );
  659. loadoutPrimaryAttachment = cac_getWeaponAttachment( class_num, 0 );
  660. loadoutPrimaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 0 );
  661. loadoutPrimaryBuff = cac_getWeaponBuff( class_num, 0 );
  662. loadoutPrimaryCamo = cac_getWeaponCamo( class_num, 0 );
  663. loadoutPrimaryReticle = cac_getWeaponReticle( class_num, 0 );
  664. loadoutSecondary = cac_getWeapon( class_num, 1 );
  665. loadoutSecondaryAttachment = cac_getWeaponAttachment( class_num, 1 );
  666. loadoutSecondaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 1 );
  667. loadoutSecondaryBuff = cac_getWeaponBuff( class_num, 1 );
  668. loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
  669. loadoutSecondaryReticle = cac_getWeaponReticle( class_num, 1 );
  670. loadoutEquipment = cac_getPerk( class_num, 0 );
  671. loadoutPerk1 = cac_getPerk( class_num, 1 );
  672. loadoutPerk2 = cac_getPerk( class_num, 2 );
  673. loadoutPerk3 = cac_getPerk( class_num, 3 );
  674. loadoutStreakType = cac_getPerk( class_num, 5 );
  675. loadoutOffhand = cac_getOffhand( class_num );
  676. loadoutDeathStreak = cac_getDeathstreak( class_num );
  677. }
  678. else if ( class == "gamemode" )
  679. {
  680. gamemodeLoadout = self.pers["gamemodeLoadout"];
  681.  
  682. loadoutPrimary = gamemodeLoadout["loadoutPrimary"];
  683. loadoutPrimaryAttachment = gamemodeLoadout["loadoutPrimaryAttachment"];
  684. loadoutPrimaryAttachment2 = gamemodeLoadout["loadoutPrimaryAttachment2"] ;
  685. loadoutPrimaryBuff = gamemodeLoadout["loadoutPrimaryBuff"];
  686. loadoutPrimaryCamo = gamemodeLoadout["loadoutPrimaryCamo"];
  687. loadoutPrimaryReticle = gamemodeLoadout["loadoutPrimaryReticle"];
  688. loadoutSecondary = gamemodeLoadout["loadoutSecondary"];
  689. loadoutSecondaryAttachment = gamemodeLoadout["loadoutSecondaryAttachment"];
  690. loadoutSecondaryAttachment2 = gamemodeLoadout["loadoutSecondaryAttachment2"];
  691. loadoutSecondaryBuff = gamemodeLoadout["loadoutSecondaryBuff"];
  692. loadoutSecondaryCamo = gamemodeLoadout["loadoutSecondaryCamo"];
  693. loadoutSecondaryReticle = gamemodeLoadout["loadoutSecondaryReticle"];
  694.  
  695. // replace the placeholder throwing knife with the valid secondary if there is one
  696. if ( loadoutPrimary == "throwingknife" && loadoutSecondary != "none" )
  697. {
  698. loadoutPrimary = loadoutSecondary;
  699. loadoutPrimaryAttachment = loadoutSecondaryAttachment;
  700. loadoutPrimaryAttachment2 = loadoutSecondaryAttachment2;
  701. loadoutPrimaryBuff = loadoutSecondaryBuff;
  702. loadoutPrimaryCamo = loadoutSecondaryCamo;
  703. loadoutPrimaryReticle = loadoutSecondaryReticle;
  704.  
  705. loadoutSecondary = "none";
  706. loadoutSecondaryAttachment = "none";
  707. loadoutSecondaryAttachment2 = "none";
  708. loadoutSecondaryBuff = "specialty_null";
  709. loadoutSecondaryCamo = "none";
  710. loadoutSecondaryReticle = "none";
  711. }
  712. // otherwise replace with normal default for invalid class
  713. else if ( loadoutPrimary == "throwingknife" && loadoutSecondary == "none" )
  714. {
  715. loadoutPrimary = table_getWeapon( level.classTableName, 10, 1 );
  716. }
  717.  
  718. loadoutEquipment = gamemodeLoadout["loadoutEquipment"];
  719. loadoutOffhand = gamemodeLoadout["loadoutOffhand"];
  720. // hack, until game mode default class data can be reset
  721. if ( loadoutOffhand == "specialty_null" )
  722. loadoutOffhand = "none";
  723. loadoutPerk1 = gamemodeLoadout["loadoutPerk1"];
  724. loadoutPerk2 = gamemodeLoadout["loadoutPerk2"];
  725. loadoutPerk3 = gamemodeLoadout["loadoutPerk3"];
  726. // replace secondary with default in case overkill perk was used to give 2 primaries and perks are disabled
  727. if ( loadoutSecondary != "none" && !isValidSecondary( loadoutSecondary, loadoutPerk2, loadoutPerk3, false ) )
  728. loadoutSecondary = table_getWeapon( level.classTableName, 10, 1 );
  729. if ( level.killstreakRewards && isDefined( gamemodeLoadout["loadoutStreakType"] ) && gamemodeLoadout["loadoutStreakType"] != "specialty_null" )
  730. {
  731. loadoutStreakType = gamemodeLoadout["loadoutStreakType"];
  732. loadoutKillstreak1 = gamemodeLoadout["loadoutKillstreak1"];
  733. loadoutKillstreak2 = gamemodeLoadout["loadoutKillstreak2"];
  734. loadoutKillstreak3 = gamemodeLoadout["loadoutKillstreak3"];
  735. }
  736. else if ( level.killstreakRewards && isDefined( self.streakType ) )
  737. loadoutStreakType = getLoadoutStreakTypeFromStreakType( self.streakType );
  738. else
  739. {
  740. loadoutStreakType = "streaktype_assault";
  741. loadoutKillstreak1 = "none";
  742. loadoutKillstreak2 = "none";
  743. loadoutKillstreak3 = "none";
  744. }
  745. loadoutDeathStreak = gamemodeLoadout["loadoutDeathstreak"];
  746. if ( !self isJuggernaut() && gamemodeLoadout["loadoutJuggernaut"] )
  747. {
  748. self.isJuggernaut = true;
  749. self thread recipeClassApplyJuggernaut();
  750. }
  751. }
  752. else if( class == "juggernaut" )
  753. {
  754. loadoutPrimary = "iw5_m60jugg";
  755. loadoutPrimaryAttachment = "none";
  756. loadoutPrimaryAttachment2 = "none";
  757. loadoutPrimaryBuff = "specialty_null";
  758. loadoutPrimaryCamo = "none";
  759. loadoutPrimaryReticle = "none";
  760. loadoutSecondary = "iw5_mp412jugg";
  761. loadoutSecondaryAttachment = "none";
  762. loadoutSecondaryAttachment2 = "none";
  763. loadoutSecondaryBuff = "specialty_null";
  764. loadoutSecondaryCamo = "none";
  765. loadoutSecondaryReticle = "none";
  766. loadoutEquipment = "frag_grenade_mp";
  767. loadoutPerk1 = "specialty_scavenger";
  768. loadoutPerk2 = "specialty_quickdraw";
  769. loadoutPerk3 = "specialty_detectexplosive";
  770. loadoutStreakType = getLoadoutStreakTypeFromStreakType( self.streakType );
  771. loadoutOffhand = "smoke_grenade_mp";
  772. loadoutDeathStreak = "specialty_null";
  773. }
  774. else if( class == "juggernaut_recon" )
  775. {
  776. loadoutPrimary = "iw5_riotshieldjugg";
  777. loadoutPrimaryAttachment = "none";
  778. loadoutPrimaryAttachment2 = "none";
  779. loadoutPrimaryBuff = "specialty_null";
  780. loadoutPrimaryCamo = "none";
  781. loadoutPrimaryReticle = "none";
  782. loadoutSecondary = "iw5_usp45jugg";
  783. loadoutSecondaryAttachment = "none";
  784. loadoutSecondaryAttachment2 = "none";
  785. loadoutSecondaryBuff = "specialty_null";
  786. loadoutSecondaryCamo = "none";
  787. loadoutSecondaryReticle = "none";
  788. loadoutEquipment = "specialty_portable_radar";
  789. loadoutPerk1 = "specialty_scavenger";
  790. loadoutPerk2 = "specialty_coldblooded";
  791. loadoutPerk3 = "specialty_detectexplosive";
  792. loadoutStreakType = getLoadoutStreakTypeFromStreakType( self.streakType );
  793. loadoutOffhand = "smoke_grenade_mp";
  794. loadoutDeathStreak = "specialty_null";
  795. }
  796. else
  797. {
  798. class_num = getClassIndex( class );
  799. self.class_num = class_num;
  800.  
  801. loadoutPrimary = table_getWeapon( level.classTableName, class_num, 0 );
  802. loadoutPrimaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 0 , 0);
  803. loadoutPrimaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 0, 1 );
  804. loadoutPrimaryBuff = table_getWeaponBuff( level.classTableName, class_num, 0 );
  805. loadoutPrimaryCamo = table_getWeaponCamo( level.classTableName, class_num, 0 );
  806. loadoutPrimaryReticle = table_getWeaponReticle( level.classTableName, class_num, 0 );
  807. loadoutSecondary = table_getWeapon( level.classTableName, class_num, 1 );
  808. loadoutSecondaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 1 , 0);
  809. loadoutSecondaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 1, 1 );;
  810. loadoutSecondaryBuff = table_getWeaponBuff( level.classTableName, class_num, 1 );
  811. loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
  812. loadoutSecondaryReticle = table_getWeaponReticle( level.classTableName, class_num, 1 );
  813. loadoutEquipment = table_getEquipment( level.classTableName, class_num, 0 );
  814. loadoutPerk1 = table_getPerk( level.classTableName, class_num, 1 );
  815. loadoutPerk2 = table_getPerk( level.classTableName, class_num, 2 );
  816. loadoutPerk3 = table_getPerk( level.classTableName, class_num, 3 );
  817. loadoutStreakType = table_getPerk( level.classTableName, class_num, 5 );
  818. loadoutOffhand = table_getOffhand( level.classTableName, class_num );
  819. loadoutDeathstreak = table_getDeathstreak( level.classTableName, class_num );
  820. }
  821.  
  822. self loadoutFakePerks( loadoutStreakType );
  823.  
  824. isCustomClass = isSubstr( class, "custom" );
  825. isRecipeClass = isSubstr( class, "recipe" );
  826. isGameModeClass = ( class == "gamemode" );
  827.  
  828. if ( !isGameModeClass && !isRecipeClass && !(isDefined( self.pers["copyCatLoadout"] ) && self.pers["copyCatLoadout"]["inUse"] && allowCopycat) )
  829. {
  830. if ( !isValidPrimary( loadoutPrimary ) || ( level.rankedMatch && isCustomClass && !self isItemUnlocked( loadoutPrimary )) )
  831. loadoutPrimary = table_getWeapon( level.classTableName, 10, 0 );
  832.  
  833. if ( !isValidAttachment( loadoutPrimaryAttachment ) || ( level.rankedMatch && isCustomClass && !self isAttachmentUnlocked( loadoutPrimary, loadoutPrimaryAttachment ) ) )
  834. loadoutPrimaryAttachment = table_getWeaponAttachment( level.classTableName, 10, 0 , 0);
  835.  
  836. if ( !isValidAttachment( loadoutPrimaryAttachment2 ) || ( level.rankedMatch && isCustomClass && !self isAttachmentUnlocked( loadoutPrimary, loadoutPrimaryAttachment2 ) ) )
  837. loadoutPrimaryAttachment2 = table_getWeaponAttachment( level.classTableName, 10, 0, 1 );
  838.  
  839. if ( !isValidWeaponBuff( loadoutPrimaryBuff ) || ( level.rankedMatch && isCustomClass && !self isWeaponBuffUnlocked( loadoutPrimary, loadoutPrimaryBuff )) )
  840. loadoutPrimaryBuff = table_getWeaponBuff( level.classTableName, 10, 0 );
  841.  
  842. if ( !isValidCamo( loadoutPrimaryCamo ) || ( level.rankedMatch && isCustomClass && !self isCamoUnlocked( loadoutPrimary, loadoutPrimaryCamo )) )
  843. loadoutPrimaryCamo = table_getWeaponCamo( level.classTableName, 10, 0 );
  844.  
  845. if ( !isValidReticle( loadoutPrimaryReticle ) )
  846. loadoutPrimaryReticle = table_getWeaponReticle( level.classTableNum, 10, 0 );
  847.  
  848. if ( !isValidSecondary( loadoutSecondary, loadoutPerk2, loadoutPerk3 ) || ( level.rankedMatch && level.rankedMatch && isCustomClass && !self isItemUnlocked( loadoutSecondary )) )
  849. loadoutSecondary = table_getWeapon( level.classTableName, 10, 1 );
  850.  
  851. if ( !isValidAttachment( loadoutSecondaryAttachment ) || ( level.rankedMatch && isCustomClass && !self isAttachmentUnlocked( loadoutSecondary, loadoutSecondaryAttachment )) )
  852. loadoutSecondaryAttachment = table_getWeaponAttachment( level.classTableName, 10, 1 , 0);
  853.  
  854. if ( !isValidAttachment( loadoutSecondaryAttachment2 ) || ( level.rankedMatch && isCustomClass && !self isAttachmentUnlocked( loadoutSecondary, loadoutSecondaryAttachment2 )) )
  855. loadoutSecondaryAttachment2 = table_getWeaponAttachment( level.classTableName, 10, 1, 1 );;
  856.  
  857. if ( loadoutPerk2 == "specialty_twoprimaries" && !isValidWeaponBuff( loadoutSecondaryBuff ) || ( level.rankedMatch && isCustomClass && !self isItemUnlocked( loadoutSecondary + " " + loadoutSecondaryBuff )) )
  858. loadoutSecondaryBuff = table_getWeaponBuff( level.classTableName, 10, 1 );
  859.  
  860. if ( !isValidCamo( loadoutSecondaryCamo ) || ( level.rankedMatch && isCustomClass && !self isCamoUnlocked( loadoutSecondary, loadoutSecondaryCamo )) )
  861. loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, 10, 1 );
  862.  
  863. if ( !isValidReticle( loadoutSecondaryReticle ) )
  864. loadoutSecondaryReticle = table_getWeaponReticle( level.classTableName, 10, 1 );
  865.  
  866. if ( !isValidEquipment( loadoutEquipment ) || ( level.rankedMatch && isCustomClass && !self isItemUnlocked( loadoutEquipment )) )
  867. loadoutEquipment = table_getEquipment( level.classTableName, 10, 0 );
  868.  
  869. if ( !isValidPerk1( loadoutPerk1 ) || ( level.rankedMatch && isCustomClass && !self isItemUnlocked( loadoutPerk1 )) )
  870. loadoutPerk1 = table_getPerk( level.classTableName, 10, 1 );
  871.  
  872. if ( !isValidPerk2( loadoutPerk2, loadoutPerk1 ) || ( level.rankedMatch && isCustomClass && !self isItemUnlocked( loadoutPerk2 )) )
  873. loadoutPerk2 = table_getPerk( level.classTableName, 10, 2 );
  874.  
  875. if ( !isValidPerk3( loadoutPerk3, loadoutPerk1 ) || ( level.rankedMatch && isCustomClass && !self isItemUnlocked( loadoutPerk3 )) )
  876. loadoutPerk3 = table_getPerk( level.classTableName, 10, 3 );
  877.  
  878. if ( !isValidDeathStreak( loadoutDeathStreak ) || ( level.rankedMatch && isCustomClass && !self isItemUnlocked( loadoutDeathStreak ) ) )
  879. loadoutDeathStreak = table_getDeathstreak( level.classTableName, 10 );
  880.  
  881. if ( !isValidOffhand( loadoutOffhand ) )
  882. loadoutOffhand = table_getOffhand( level.classTableName, 10 );
  883. }
  884.  
  885. // TODO: give bling if the weapon is properly ranked up
  886. //if ( loadoutPerk1 != "specialty_bling" )
  887. //{
  888. // loadoutPrimaryAttachment2 = "none";
  889. // loadoutSecondaryAttachment2 = "none";
  890. //}
  891.  
  892. /*
  893. if ( loadoutPerk1 != "specialty_onemanarmy" && loadoutSecondary == "onemanarmy" )
  894. loadoutSecondary = table_getWeapon( level.classTableName, 10, 1 );
  895. */
  896.  
  897. //loadoutSecondaryCamo = "none";
  898.  
  899. self.loadoutPrimary = loadoutPrimary;
  900. self.loadoutPrimaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutPrimaryCamo, 0 ));
  901. self.loadoutSecondary = loadoutSecondary;
  902. self.loadoutSecondaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ));
  903.  
  904. // sorry, not supporting camo variants on old weapons.
  905. if ( !IsSubstr( loadoutPrimary, "iw5" ) )
  906. self.loadoutPrimaryCamo = 0;
  907. if ( !IsSubstr( loadoutSecondary, "iw5" ) )
  908. self.loadoutSecondaryCamo = 0;
  909.  
  910. self.loadoutPrimaryReticle = int(tableLookup( "mp/reticleTable.csv", 1, loadoutPrimaryReticle, 0 ));
  911. self.loadoutSecondaryReticle = int(tableLookup( "mp/reticleTable.csv", 1, loadoutSecondaryReticle, 0));
  912.  
  913. // sorry, not supporting reticle variants on old weapons.
  914. if ( !IsSubstr( loadoutPrimary, "iw5" ) )
  915. self.loadoutPrimaryReticle = 0;
  916. if ( !IsSubstr( loadoutSecondary, "iw5" ) )
  917. self.loadoutSecondaryReticle = 0;
  918.  
  919. if ( loadoutSecondary == "none" )
  920. secondaryName = "none";
  921. else
  922. {
  923. secondaryName = buildWeaponName( loadoutSecondary, loadoutSecondaryAttachment, loadoutSecondaryAttachment2, self.loadoutSecondaryCamo, self.loadoutSecondaryReticle );
  924. self _giveWeapon( secondaryName );
  925. // do a quick check to make sure the weapon xp and rank jive with each other
  926. weaponTokens = StrTok( secondaryName, "_" );
  927.  
  928. if ( weaponTokens[0] == "iw5" )
  929. weaponTokens[0] = weaponTokens[0] + "_" + weaponTokens[1];
  930. else if ( weaponTokens[0] == "alt" )
  931. weaponTokens[0] = weaponTokens[1] + "_" + weaponTokens[2];
  932.  
  933. weaponName = weaponTokens[0];
  934.  
  935. curWeaponRank = self maps\mp\gametypes\_rank::getWeaponRank( weaponName );
  936. curWeaponStatRank = self GetPlayerData( "weaponRank", weaponName );
  937. if( curWeaponRank != curWeaponStatRank )
  938. self SetPlayerData( "weaponRank", weaponName, curWeaponRank );
  939. }
  940.  
  941. self SetOffhandPrimaryClass( "other" );
  942.  
  943. // Action Slots
  944. self _SetActionSlot( 1, "" );
  945. //self _SetActionSlot( 1, "nightvision" );
  946. self _SetActionSlot( 3, "altMode" );
  947. self _SetActionSlot( 4, "" );
  948.  
  949. // Perks
  950. self _clearPerks();
  951. self _detachAll();
  952.  
  953. // these special case giving pistol death have to come before
  954. // perk loadout to ensure player perk icons arent overwritten
  955. if ( level.dieHardMode )
  956. self givePerk( "specialty_pistoldeath", false );
  957.  
  958. self loadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3, loadoutPrimaryBuff, loadoutSecondaryBuff );
  959.  
  960. if ( self _hasPerk( "specialty_extraammo" ) && secondaryName != "none" && getWeaponClass( secondaryName ) != "weapon_projectile" )
  961. self giveMaxAmmo( secondaryName );
  962.  
  963. // trying to stop killstreaks from targeting the newly spawned
  964. self.spawnPerk = false;
  965. if( !self _hasPerk( "specialty_blindeye" ) && self.avoidKillstreakOnSpawnTimer > 0 )
  966. self thread maps\mp\perks\_perks::giveBlindEyeAfterSpawn();
  967.  
  968. // need to give deathstreaks after perks because some deathstreaks need to supercede perks, like juiced needs to happen after lightweight because of the speed change
  969. // only give the deathstreak for the initial spawn for this life.
  970. if( self.pers["cur_death_streak"] > 0 )
  971. {
  972. deathStreaks = [];
  973. if( loadoutDeathStreak != "specialty_null" )
  974. deathStreaks[ loadoutDeathStreak ] = int( tableLookup( "mp/perkTable.csv", 1, loadoutDeathStreak, 6 ) );
  975.  
  976. if ( self getPerkUpgrade( loadoutPerk1 ) == "specialty_rollover" || self getPerkUpgrade( loadoutPerk2 ) == "specialty_rollover" || self getPerkUpgrade( loadoutPerk3 ) == "specialty_rollover" )
  977. {
  978. foreach( key, value in deathStreaks )
  979. deathStreaks[ key ] -= 1;
  980. }
  981.  
  982. foreach( key, value in deathStreaks )
  983. {
  984. if ( self.pers["cur_death_streak"] >= value )
  985. {
  986. // the care package death streak should only be given once per death streak, not every time after the value is hit
  987. if( key == "specialty_carepackage" && self.pers[ "cur_death_streak" ] > value )
  988. continue;
  989. // the uav death streak should only be given once per death streak, not every time after the value is hit
  990. if( key == "specialty_uav" && self.pers[ "cur_death_streak" ] > value )
  991. continue;
  992.  
  993. self thread givePerk( key, true );
  994. self thread maps\mp\gametypes\_hud_message::splashNotify( key );
  995. }
  996. }
  997. }
  998.  
  999. // killstreaks need to be given after perks because of things like hardline
  1000. if ( level.killstreakRewards && !isDefined( loadoutKillstreak1 ) && !isDefined( loadoutKillstreak2 ) && !isDefined( loadoutKillstreak3 ) )
  1001. {
  1002. if ( isDefined( self.pers["copyCatLoadout"] ) && self.pers["copyCatLoadout"]["inUse"] && allowCopycat )
  1003. {
  1004. loadoutKillstreak1 = clonedLoadout["loadoutKillstreak1"];
  1005. loadoutKillstreak2 = clonedLoadout["loadoutKillstreak2"];
  1006. loadoutKillstreak3 = clonedLoadout["loadoutKillstreak3"];
  1007. }
  1008. else
  1009. {
  1010. defaultKillstreak1 = undefined;
  1011. defaultKillstreak2 = undefined;
  1012. defaultKillstreak3 = undefined;
  1013. playerData = undefined;
  1014.  
  1015. // IW5 Defcon Killstreak loadout
  1016. switch( self.streakType )
  1017. {
  1018. case "support":
  1019. defaultKillstreak1 = table_getKillstreak( level.classTableName, 2, 1 );
  1020. defaultKillstreak2 = table_getKillstreak( level.classTableName, 2, 2 );
  1021. defaultKillstreak3 = table_getKillstreak( level.classTableName, 2, 3 );
  1022. playerData = "defenseStreaks";
  1023. break;
  1024. case "specialist":
  1025. defaultKillstreak1 = table_getKillstreak( level.classTableName, 1, 1 );
  1026. defaultKillstreak2 = table_getKillstreak( level.classTableName, 1, 2 );
  1027. defaultKillstreak3 = table_getKillstreak( level.classTableName, 1, 3 );
  1028. playerData = "specialistStreaks";
  1029. break;
  1030. default: // assault
  1031. defaultKillstreak1 = table_getKillstreak( level.classTableName, 0, 1 );
  1032. defaultKillstreak2 = table_getKillstreak( level.classTableName, 0, 2 );
  1033. defaultKillstreak3 = table_getKillstreak( level.classTableName, 0, 3 );
  1034. playerData = "assaultStreaks";
  1035. break;
  1036. }
  1037.  
  1038. loadoutKillstreak1 = undefined;
  1039. loadoutKillstreak2 = undefined;
  1040. loadoutKillstreak3 = undefined;
  1041.  
  1042. // this is a custom class so pull from the player data
  1043. if( IsSubStr( class, "custom" ) )
  1044. {
  1045. assert( IsDefined( self.class_num ) );
  1046. customClassLoc = cac_getCustomClassLoc();
  1047. loadoutKillstreak1 = self getPlayerData( customClassLoc, self.class_num, playerData, 0 );
  1048. loadoutKillstreak2 = self getPlayerData( customClassLoc, self.class_num, playerData, 1 );
  1049. loadoutKillstreak3 = self getPlayerData( customClassLoc, self.class_num, playerData, 2 );
  1050. }
  1051.  
  1052. // give juggernauts and special gamemode classes the current killstreaks the player has
  1053. if( IsSubStr( class, "juggernaut" ) || isGameModeClass )
  1054. {
  1055. foreach( killstreak in self.killstreaks )
  1056. {
  1057. if( !IsDefined( loadoutKillstreak1 ) )
  1058. loadoutKillstreak1 = killstreak;
  1059. else if( !IsDefined( loadoutKillstreak2 ) )
  1060. loadoutKillstreak2 = killstreak;
  1061. else if( !IsDefined( loadoutKillstreak3 ) )
  1062. loadoutKillstreak3 = killstreak;
  1063. }
  1064. }
  1065.  
  1066. // give defaults if this isn't a custom class, or juggernauts, or special gamemode classes
  1067. if( !isSubstr( class, "custom" ) && !isSubstr( class, "juggernaut" ) && !isGameModeClass )
  1068. {
  1069. loadoutKillstreak1 = defaultKillstreak1;
  1070. loadoutKillstreak2 = defaultKillstreak2;
  1071. loadoutKillstreak3 = defaultKillstreak3;
  1072. }
  1073.  
  1074. // if the killstreak variables are undefined by the time they get here then we should set them to "none" because they may not have selected a killstreak
  1075. if( !IsDefined( loadoutKillstreak1 ) )
  1076. loadoutKillstreak1 = "none";
  1077. if( !IsDefined( loadoutKillstreak2 ) )
  1078. loadoutKillstreak2 = "none";
  1079. if( !IsDefined( loadoutKillstreak3 ) )
  1080. loadoutKillstreak3 = "none";
  1081.  
  1082. // validate to stop cheaters
  1083. if( !isValidKillstreak( loadoutKillstreak1 ) || ( isCustomClass && !self isItemUnlocked( loadoutKillstreak1 ) ) )
  1084. loadoutKillstreak1 = table_getKillstreak( level.classTableName, 0, 1 );
  1085. if( !isValidKillstreak( loadoutKillstreak2 ) || ( isCustomClass && !self isItemUnlocked( loadoutKillstreak2 ) ) )
  1086. loadoutKillstreak2 = table_getKillstreak( level.classTableName, 0, 2 );
  1087. if( !isValidKillstreak( loadoutKillstreak3 ) || ( isCustomClass && !self isItemUnlocked( loadoutKillstreak3 ) ) )
  1088. loadoutKillstreak3 = table_getKillstreak( level.classTableName, 0, 3 );
  1089. }
  1090. }
  1091. else if ( !level.killstreakRewards )
  1092. {
  1093. loadoutKillstreak1 = "none";
  1094. loadoutKillstreak2 = "none";
  1095. loadoutKillstreak3 = "none";
  1096. }
  1097.  
  1098. self setKillstreaks( loadoutKillstreak1, loadoutKillstreak2, loadoutKillstreak3 );
  1099. // reset the killstreaks when there is a new class chosen, unless it's juggernaut or special gamemode class, this fixes the bug where killstreaks don't reset if you change classes during pre-match timer
  1100. if ( IsDefined( self.lastClass ) && self.lastClass != self.class && !IsSubStr( self.class, "juggernaut" ) && !IsSubStr( self.lastClass, "juggernaut" ) && !IsSubStr( class, "juggernaut" ) )
  1101. {
  1102. if( wasOnlyRound() || self.lastClass != "" )
  1103. {
  1104. // put all of their killstreaks into the gimme slot now that it stacks
  1105. streakNames = [];
  1106. inc = 0;
  1107. // first go through the gimme slot killstreaks, this way they will be in the bottom of the pile
  1108. if( self.pers["killstreaks"].size > KILLSTREAK_STACKING_START_SLOT )
  1109. {
  1110. for( i = KILLSTREAK_STACKING_START_SLOT; i < self.pers["killstreaks"].size; i++ )
  1111. {
  1112. streakNames[inc] = self.pers["killstreaks"][i].streakName;
  1113. inc++;
  1114. }
  1115. }
  1116. // now go through the earned killstreaks, so these will be on the top of the pile
  1117. if( self.pers["killstreaks"].size )
  1118. {
  1119. for( i = KILLSTREAK_SLOT_1; i < KILLSTREAK_SLOT_3 + 1; i++ )
  1120. {
  1121. if( IsDefined( self.pers["killstreaks"][i] ) &&
  1122. IsDefined( self.pers["killstreaks"][i].streakName ) &&
  1123. self.pers["killstreaks"][i].available &&
  1124. !self.pers["killstreaks"][i].isSpecialist )
  1125. {
  1126. streakNames[inc] = self.pers["killstreaks"][i].streakName;
  1127. inc++;
  1128. }
  1129. }
  1130. }
  1131.  
  1132. maps\mp\killstreaks\_killstreaks::clearKillstreaks();
  1133.  
  1134. for( i = 0; i < streakNames.size; i++ )
  1135. {
  1136. self maps\mp\killstreaks\_killstreaks::giveKillstreak( streakNames[i] );
  1137. }
  1138. }
  1139. }
  1140.  
  1141. // don't change these if we're becoming a juggernaut
  1142. if( !IsSubStr( class, "juggernaut" ) )
  1143. {
  1144. if( isDefined( self.lastClass ) && self.lastClass != "" && self.lastClass != self.class )
  1145. {
  1146. self incPlayerStat( "mostclasseschanged", 1 );
  1147. }
  1148.  
  1149. self.pers["lastClass"] = self.class;
  1150. self.lastClass = self.class;
  1151. }
  1152.  
  1153. // Primary Weapon
  1154. primaryName = buildWeaponName( loadoutPrimary, loadoutPrimaryAttachment, loadoutPrimaryAttachment2, self.loadoutPrimaryCamo, self.loadoutPrimaryReticle );
  1155. self _giveWeapon( primaryName );
  1156.  
  1157.  
  1158. self SwitchToWeapon( primaryName );
  1159. // do a quick check to make sure the weapon xp and rank jive with each other
  1160. weaponTokens = StrTok( primaryName, "_" );
  1161.  
  1162. if ( weaponTokens[0] == "iw5" )
  1163. weaponName = weaponTokens[0] + "_" + weaponTokens[1];
  1164. else if ( weaponTokens[0] == "alt" )
  1165. weaponName = weaponTokens[1] + "_" + weaponTokens[2];
  1166. else
  1167. weaponName = weaponTokens[0];
  1168.  
  1169. curWeaponRank = self maps\mp\gametypes\_rank::getWeaponRank( weaponName );
  1170. curWeaponStatRank = self GetPlayerData( "weaponRank", weaponName );
  1171. if( curWeaponRank != curWeaponStatRank )
  1172. self SetPlayerData( "weaponRank", weaponName, curWeaponRank );
  1173.  
  1174. // fix changing from a riotshield class to a riotshield class during grace period not giving a shield
  1175. if ( primaryName == "riotshield_mp" && level.inGracePeriod )
  1176. self notify ( "weapon_change", "riotshield_mp" );
  1177.  
  1178. if ( self _hasPerk( "specialty_extraammo" ) )
  1179. self giveMaxAmmo( primaryName );
  1180.  
  1181. // only when called during spawn flow
  1182. if ( setPrimarySpawnWeapon )
  1183. self setSpawnWeapon( primaryName );
  1184.  
  1185. self.pers["primaryWeapon"] = weaponName;
  1186.  
  1187. primaryTokens = strtok( primaryName, "_" );
  1188.  
  1189. // Primary Offhand was given by givePerk (it's your perk1)
  1190.  
  1191. // Secondary Offhand
  1192. offhandSecondaryWeapon = loadoutOffhand;
  1193.  
  1194. if ( loadoutOffhand == "none" )
  1195. self SetOffhandSecondaryClass( "none" );
  1196. else if ( loadoutOffhand == "flash_grenade_mp" )
  1197. self SetOffhandSecondaryClass( "flash" );
  1198. else if ( loadoutOffhand == "smoke_grenade_mp" || loadoutOffhand == "concussion_grenade_mp" )
  1199. self SetOffhandSecondaryClass( "smoke" );
  1200. else
  1201. self SetOffhandSecondaryClass( "flash" );
  1202.  
  1203. switch( offhandSecondaryWeapon )
  1204. {
  1205. case "none":
  1206. break;
  1207. case "specialty_portable_radar":
  1208. case "specialty_scrambler":
  1209. case "specialty_tacticalinsertion":
  1210. case "trophy_mp":
  1211. self givePerk( offhandSecondaryWeapon, false );
  1212. break;
  1213.  
  1214. default:
  1215. self giveWeapon( offhandSecondaryWeapon );
  1216.  
  1217. if( loadOutOffhand == "flash_grenade_mp" )
  1218. self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
  1219. else if( loadOutOffhand == "concussion_grenade_mp" )
  1220. self setWeaponAmmoClip( offhandSecondaryWeapon, 2 );
  1221. else
  1222. self setWeaponAmmoClip( offhandSecondaryWeapon, 1 );
  1223. break;
  1224. }
  1225.  
  1226. primaryWeapon = primaryName;
  1227. self.primaryWeapon = primaryWeapon;
  1228. self.secondaryWeapon = secondaryName;
  1229.  
  1230. self maps\mp\gametypes\_teams::playerModelForWeapon( self.pers["primaryWeapon"], getBaseWeaponName( secondaryName ) );
  1231.  
  1232. self.isSniper = (weaponClass( self.primaryWeapon ) == "sniper");
  1233.  
  1234. self maps\mp\gametypes\_weapons::updateMoveSpeedScale();
  1235.  
  1236. // cac specialties that require loop threads
  1237. self maps\mp\perks\_perks::cac_selector();
  1238.  
  1239. self notify ( "changed_kit" );
  1240. self notify ( "giveLoadout" );
  1241. }
  1242.  
  1243. _detachAll()
  1244. {
  1245. if ( isDefined( self.hasRiotShield ) && self.hasRiotShield )
  1246. {
  1247. if ( self.hasRiotShieldEquipped )
  1248. {
  1249. self DetachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  1250. self.hasRiotShieldEquipped = false;
  1251. }
  1252. else
  1253. {
  1254. self DetachShieldModel( "weapon_riot_shield_mp", "tag_shield_back" );
  1255. }
  1256.  
  1257. self.hasRiotShield = false;
  1258. }
  1259.  
  1260. self detachAll();
  1261. }
  1262.  
  1263. isPerkUpgraded( perkName )
  1264. {
  1265. perkUpgrade = tablelookup( "mp/perktable.csv", 1, perkName, 8 );
  1266.  
  1267. if ( perkUpgrade == "" || perkUpgrade == "specialty_null" )
  1268. return false;
  1269.  
  1270. if ( !self isItemUnlocked( perkUpgrade ) )
  1271. return false;
  1272.  
  1273. return true;
  1274. }
  1275.  
  1276. getPerkUpgrade( perkName )
  1277. {
  1278. perkUpgrade = tablelookup( "mp/perktable.csv", 1, perkName, 8 );
  1279.  
  1280. if ( perkUpgrade == "" || perkUpgrade == "specialty_null" )
  1281. return "specialty_null";
  1282.  
  1283. if ( !self isItemUnlocked( perkUpgrade ) )
  1284. return "specialty_null";
  1285.  
  1286. return ( perkUpgrade );
  1287. }
  1288.  
  1289. loadoutAllPerks( loadoutEquipment, loadoutPerk1, loadoutPerk2, loadoutPerk3, loadoutPrimaryBuff, loadoutSecondaryBuff )
  1290. {
  1291. loadoutEquipment = maps\mp\perks\_perks::validatePerk( 1, loadoutEquipment );
  1292. loadoutPerk1 = maps\mp\perks\_perks::validatePerk( 1, loadoutPerk1 );
  1293. loadoutPerk2 = maps\mp\perks\_perks::validatePerk( 2, loadoutPerk2 );
  1294. loadoutPerk3 = maps\mp\perks\_perks::validatePerk( 3, loadoutPerk3 );
  1295.  
  1296. loadoutPrimaryBuff = maps\mp\perks\_perks::validatePerk( undefined, loadoutPrimaryBuff );
  1297. if( loadoutPerk2 == "specialty_twoprimaries" )
  1298. loadoutSecondaryBuff = maps\mp\perks\_perks::validatePerk( undefined, loadoutSecondaryBuff );
  1299.  
  1300. self.loadoutPerk1 = loadoutPerk1;
  1301. self.loadoutPerk2 = loadoutPerk2;
  1302. self.loadoutPerk3 = loadoutPerk3;
  1303. self.loadoutPerkEquipment = loadoutEquipment;
  1304. self.loadoutPrimaryBuff = loadoutPrimaryBuff;
  1305. if( loadoutPerk2 == "specialty_twoprimaries" )
  1306. self.loadoutSecondaryBuff = loadoutSecondaryBuff;
  1307.  
  1308. if( loadoutEquipment != "specialty_null" )
  1309. self givePerk( loadoutEquipment, true );
  1310. if( loadoutPerk1 != "specialty_null" )
  1311. self givePerk( loadoutPerk1, true );
  1312. if( loadoutPerk2 != "specialty_null" )
  1313. self givePerk( loadoutPerk2, true );
  1314. if( loadoutPerk3 != "specialty_null" )
  1315. self givePerk( loadoutPerk3, true );
  1316.  
  1317. //self givePerk( loadoutTeamPerk ); //not currently validated
  1318.  
  1319. //self givePerk( loadoutAmmoType );
  1320.  
  1321. if( loadoutPrimaryBuff != "specialty_null" )
  1322. self givePerk( loadoutPrimaryBuff, true );
  1323. // NOTE: don't give the secondary buff here because it should be weapon specific and only if you're currently holding the weapon, see watchWeaponChange()
  1324.  
  1325. perkUpgrd[0] = tablelookup( "mp/perktable.csv", 1, loadoutPerk1, 8 );
  1326. perkUpgrd[1] = tablelookup( "mp/perktable.csv", 1, loadoutPerk2, 8 );
  1327. perkUpgrd[2] = tablelookup( "mp/perktable.csv", 1, loadoutPerk3, 8 );
  1328.  
  1329. foreach( upgrade in perkUpgrd )
  1330. {
  1331. if ( upgrade == "" || upgrade == "specialty_null" )
  1332. continue;
  1333.  
  1334. if ( self isItemUnlocked( upgrade ) || !self rankingEnabled() )
  1335. {
  1336. // we want to put the upgrade perk in the slot in code
  1337. self givePerk( upgrade, true );
  1338. }
  1339. }
  1340.  
  1341. // now if we don't have specialty_assists then reset the persistent data
  1342. if( !self _hasPerk( "specialty_assists" ) )
  1343. self.pers["assistsToKill"] = 0;
  1344. }
  1345.  
  1346. trackRiotShield()
  1347. {
  1348. self endon ( "death" );
  1349. self endon ( "disconnect" );
  1350.  
  1351. self.hasRiotShield = self hasWeapon( "riotshield_mp" );
  1352. self.hasRiotShieldEquipped = (self.currentWeaponAtSpawn == "riotshield_mp");
  1353.  
  1354. // note this function must play nice with _detachAll().
  1355.  
  1356. if ( self.hasRiotShield )
  1357. {
  1358. if ( self.primaryWeapon == "riotshield_mp" && self.secondaryWeapon == "riotshield_mp" )
  1359. {
  1360. self AttachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  1361. self AttachShieldModel( "weapon_riot_shield_mp", "tag_shield_back" );
  1362. }
  1363. else if ( self.hasRiotShieldEquipped )
  1364. {
  1365. self AttachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  1366. }
  1367. else
  1368. {
  1369. self AttachShieldModel( "weapon_riot_shield_mp", "tag_shield_back" );
  1370. }
  1371. }
  1372.  
  1373. for ( ;; )
  1374. {
  1375. self waittill ( "weapon_change", newWeapon );
  1376.  
  1377. // need to check both, player can be 'juggernaut' by game setup default class specification now, not only killstreak
  1378. if ( newWeapon == "riotshield_mp" || newWeapon == "iw5_riotshieldjugg_mp" )
  1379. {
  1380. // defensive check in case we somehow get an extra "weapon_change"
  1381. if ( self.hasRiotShieldEquipped )
  1382. continue;
  1383.  
  1384. if ( self.primaryWeapon == newWeapon && self.secondaryWeapon == newWeapon )
  1385. continue;
  1386. else if ( self.hasRiotShield )
  1387. self MoveShieldModel( "weapon_riot_shield_mp", "tag_shield_back", "tag_weapon_left" );
  1388. else
  1389. self AttachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  1390.  
  1391. self.hasRiotShield = true;
  1392. self.hasRiotShieldEquipped = true;
  1393. }
  1394. else if ( (self IsMantling()) && (newWeapon == "none") )
  1395. {
  1396. // Do nothing, we want to keep that weapon on their arm.
  1397. }
  1398. else if ( self.hasRiotShieldEquipped )
  1399. {
  1400. assert( self.hasRiotShield );
  1401. self.hasRiotShield = ( self hasWeapon( "riotshield_mp" ) || self hasWeapon( "iw5_riotshieldjugg_mp" ) );
  1402.  
  1403. if ( self.hasRiotShield )
  1404. self MoveShieldModel( "weapon_riot_shield_mp", "tag_weapon_left", "tag_shield_back" );
  1405. else
  1406. self DetachShieldModel( "weapon_riot_shield_mp", "tag_weapon_left" );
  1407.  
  1408. self.hasRiotShieldEquipped = false;
  1409. }
  1410. else if ( self.hasRiotShield )
  1411. {
  1412. if ( !self hasWeapon( "riotshield_mp" ) && !self hasWeapon( "iw5_riotshieldjugg_mp" ) )
  1413. {
  1414. // we probably just lost all of our weapons (maybe switched classes)
  1415. self DetachShieldModel( "weapon_riot_shield_mp", "tag_shield_back" );
  1416. self.hasRiotShield = false;
  1417. }
  1418. }
  1419. }
  1420. }
  1421.  
  1422.  
  1423. tryAttach( placement ) // deprecated; hopefully we won't need to bring this defensive function back
  1424. {
  1425. if ( !isDefined( placement ) || placement != "back" )
  1426. tag = "tag_weapon_left";
  1427. else
  1428. tag = "tag_shield_back";
  1429.  
  1430. attachSize = self getAttachSize();
  1431.  
  1432. for ( i = 0; i < attachSize; i++ )
  1433. {
  1434. attachedTag = self getAttachTagName( i );
  1435. if ( attachedTag == tag && self getAttachModelName( i ) == "weapon_riot_shield_mp" )
  1436. {
  1437. return;
  1438. }
  1439. }
  1440.  
  1441. self AttachShieldModel( "weapon_riot_shield_mp", tag );
  1442. }
  1443.  
  1444. tryDetach( placement ) // deprecated; hopefully we won't need to bring this defensive function back
  1445. {
  1446. if ( !isDefined( placement ) || placement != "back" )
  1447. tag = "tag_weapon_left";
  1448. else
  1449. tag = "tag_shield_back";
  1450.  
  1451.  
  1452. attachSize = self getAttachSize();
  1453.  
  1454. for ( i = 0; i < attachSize; i++ )
  1455. {
  1456. attachedModel = self getAttachModelName( i );
  1457. if ( attachedModel == "weapon_riot_shield_mp" )
  1458. {
  1459. self DetachShieldModel( attachedModel, tag);
  1460. return;
  1461. }
  1462. }
  1463. return;
  1464. }
  1465.  
  1466.  
  1467. buildWeaponName( baseName, attachment1, attachment2, camo, reticle )
  1468. {
  1469. if ( !isDefined( level.letterToNumber ) )
  1470. level.letterToNumber = makeLettersToNumbers();
  1471.  
  1472. // disable bling when perks are disabled
  1473. if ( getDvarInt ( "scr_game_perks" ) == 0 )
  1474. {
  1475. attachment2 = "none";
  1476. }
  1477.  
  1478. //hack for current menu bug - remove before ship
  1479. if ( isDefined( reticle ) && reticle != 0 && getAttachmentType( attachment1 ) != "rail" && getAttachmentType( attachment2 ) != "rail" )
  1480. {
  1481. reticle = undefined;
  1482. }
  1483.  
  1484. if( getAttachmentType( attachment1 ) == "rail" )
  1485. {
  1486. attachment1 = attachmentMap( attachment1, baseName );
  1487. }
  1488. else if ( getAttachmentType( attachment2 ) == "rail" )
  1489. {
  1490. attachment2 = attachmentMap( attachment2, baseName );
  1491. }
  1492.  
  1493. bareWeaponName = "";
  1494.  
  1495. if ( isSubstr(baseName, "iw5_") )
  1496. {
  1497. weaponName = baseName + "_mp";
  1498. endIndex = baseName.size;
  1499. bareWeaponName = GetSubStr( baseName, 4, endIndex );
  1500. }
  1501. else
  1502. {
  1503. weaponName = baseName;
  1504. }
  1505.  
  1506. attachments = [];
  1507.  
  1508. if ( attachment1 != "none" && attachment2 != "none" )
  1509. {
  1510. if ( level.letterToNumber[attachment1[0]] < level.letterToNumber[attachment2[0]] )
  1511. {
  1512.  
  1513. attachments[0] = attachment1;
  1514. attachments[1] = attachment2;
  1515.  
  1516. }
  1517. else if ( level.letterToNumber[attachment1[0]] == level.letterToNumber[attachment2[0]] )
  1518. {
  1519. if ( level.letterToNumber[attachment1[1]] < level.letterToNumber[attachment2[1]] )
  1520. {
  1521. attachments[0] = attachment1;
  1522. attachments[1] = attachment2;
  1523. }
  1524. else
  1525. {
  1526. attachments[0] = attachment2;
  1527. attachments[1] = attachment1;
  1528. }
  1529. }
  1530. else
  1531. {
  1532. attachments[0] = attachment2;
  1533. attachments[1] = attachment1;
  1534. }
  1535.  
  1536. if ( getWeaponClass( baseName ) == "weapon_sniper" && getAttachmentType( attachment1 ) != "rail" && getAttachmentType( attachment2 ) != "rail" )
  1537. {
  1538. if ( attachment1 != "zoomscope" && attachment2 != "zoomscope" )
  1539. attachments[2] = bareWeaponName + "scope";
  1540. }
  1541. }
  1542. else if ( attachment1 != "none" )
  1543. {
  1544. attachments[0] = attachment1;
  1545.  
  1546. if ( getWeaponClass( baseName ) == "weapon_sniper" && getAttachmentType( attachment1 ) != "rail" && attachment1 != "zoomscope" )
  1547. attachments[1] = bareWeaponName + "scope";
  1548.  
  1549. }
  1550. else if ( attachment2 != "none" )
  1551. {
  1552. attachments[0] = attachment2;
  1553.  
  1554. if ( getWeaponClass( baseName ) == "weapon_sniper" && getAttachmentType( attachment2 ) != "rail" && attachment2 != "zoomscope" )
  1555. attachments[1] = bareWeaponName + "scope";
  1556. }
  1557. else if ( getWeaponClass( baseName ) == "weapon_sniper" )
  1558. {
  1559. attachments[0] = bareWeaponName + "scope";
  1560. }
  1561.  
  1562.  
  1563. //Handle VZ Scopes
  1564. if( isDefined( attachments[0] ) && attachments[0] == "vzscope" )
  1565. attachments[0] = bareWeaponName + "scopevz";
  1566. else if( isDefined( attachments[1] ) && attachments[1] == "vzscope" )
  1567. attachments[1] = bareWeaponName + "scopevz";
  1568. else if( isDefined( attachments[2] ) && attachments[2] == "vzscope" )
  1569. attachments[2] = bareWeaponName + "scopevz";
  1570.  
  1571. //orders attachments alphabetically.
  1572. if ( isDefined( attachments.size ) && attachments.size )
  1573. {
  1574. i = 0;
  1575. while( i < attachments.size )
  1576. {
  1577. if ( isDefined( attachments[i+1] ) && is_later_in_alphabet( attachments[i], attachments[i+1] ) )
  1578. {
  1579. tmpAtch = attachments[i];
  1580. attachments[i] = attachments[i+1];
  1581. attachments[i+1] = tmpAtch;
  1582. i = 0;
  1583. continue;
  1584. }
  1585. i++;
  1586. }
  1587. }
  1588.  
  1589. foreach ( attachment in attachments )
  1590. {
  1591. weaponName += "_" + attachment;
  1592. }
  1593.  
  1594. if ( isSubstr(weaponName, "iw5_") )
  1595. {
  1596. weaponName = buildWeaponNameCamo( weaponName, camo );
  1597. weaponName = buildWeaponNameReticle( weaponName, reticle );
  1598. return ( weaponName );
  1599. }
  1600. else if ( !isValidWeapon( weaponName + "_mp" ) )
  1601. {
  1602. return ( baseName + "_mp" );
  1603. }
  1604. else
  1605. {
  1606. weaponName = buildWeaponNameCamo( weaponName, camo );
  1607. weaponName = buildWeaponNameReticle( weaponName, reticle );
  1608. return ( weaponName + "_mp" );
  1609. }
  1610. }
  1611.  
  1612. buildWeaponNameCamo( weaponName, camo )
  1613. {
  1614. if ( !isdefined( camo ) )
  1615. return weaponName;
  1616. if ( camo <= 0 )
  1617. return weaponName;
  1618.  
  1619. if ( camo < 10 )
  1620. weaponName += "_camo0";
  1621. else
  1622. weaponName += "_camo";
  1623. weaponName += camo;
  1624.  
  1625. return weaponName;
  1626. }
  1627.  
  1628. buildWeaponNameReticle( weaponName, reticle )
  1629. {
  1630. if ( !isdefined( reticle ) )
  1631. return weaponName;
  1632. if ( reticle <= 0 )
  1633. return weaponName;
  1634.  
  1635. weaponName += "_scope";
  1636. weaponName += reticle;
  1637.  
  1638. return weaponName;
  1639. }
  1640.  
  1641. makeLettersToNumbers()
  1642. {
  1643. array = [];
  1644.  
  1645. array["a"] = 0;
  1646. array["b"] = 1;
  1647. array["c"] = 2;
  1648. array["d"] = 3;
  1649. array["e"] = 4;
  1650. array["f"] = 5;
  1651. array["g"] = 6;
  1652. array["h"] = 7;
  1653. array["i"] = 8;
  1654. array["j"] = 9;
  1655. array["k"] = 10;
  1656. array["l"] = 11;
  1657. array["m"] = 12;
  1658. array["n"] = 13;
  1659. array["o"] = 14;
  1660. array["p"] = 15;
  1661. array["q"] = 16;
  1662. array["r"] = 17;
  1663. array["s"] = 18;
  1664. array["t"] = 19;
  1665. array["u"] = 20;
  1666. array["v"] = 21;
  1667. array["w"] = 22;
  1668. array["x"] = 23;
  1669. array["y"] = 24;
  1670. array["z"] = 25;
  1671.  
  1672. return array;
  1673. }
  1674.  
  1675. setKillstreaks( streak1, streak2, streak3 )
  1676. {
  1677. self.killStreaks = [];
  1678.  
  1679. killStreaks = [];
  1680.  
  1681. if ( IsDefined( streak1 ) && streak1 != "none" )
  1682. {
  1683. streakVal = self maps\mp\killstreaks\_killstreaks::getStreakCost( streak1 );
  1684. killStreaks[streakVal] = streak1;
  1685. }
  1686. if ( IsDefined( streak2 ) && streak2 != "none" )
  1687. {
  1688. streakVal = self maps\mp\killstreaks\_killstreaks::getStreakCost( streak2 );
  1689. killStreaks[streakVal] = streak2;
  1690. }
  1691. if ( IsDefined( streak3 ) && streak3 != "none" )
  1692. {
  1693. streakVal = self maps\mp\killstreaks\_killstreaks::getStreakCost( streak3 );
  1694. killStreaks[streakVal] = streak3;
  1695. }
  1696.  
  1697. // foreach doesn't loop through numbers arrays in number order; it loops through the elements in the order
  1698. // they were added. We'll use this to fix it for now.
  1699. maxVal = 0;
  1700. foreach ( streakVal, streakName in killStreaks )
  1701. {
  1702. if ( streakVal > maxVal )
  1703. maxVal = streakVal;
  1704. }
  1705.  
  1706. for ( streakIndex = 0; streakIndex <= maxVal; streakIndex++ )
  1707. {
  1708. if ( !isDefined( killStreaks[streakIndex] ) )
  1709. continue;
  1710.  
  1711. streakName = killStreaks[streakIndex];
  1712.  
  1713. self.killStreaks[ streakIndex ] = killStreaks[ streakIndex ];
  1714. }
  1715. // end lameness
  1716. }
  1717.  
  1718.  
  1719. replenishLoadout() // used by ammo hardpoint.
  1720. {
  1721. team = self.pers["team"];
  1722. class = self.pers["class"];
  1723.  
  1724. weaponsList = self GetWeaponsListAll();
  1725. for( idx = 0; idx < weaponsList.size; idx++ )
  1726. {
  1727. weapon = weaponsList[idx];
  1728.  
  1729. self giveMaxAmmo( weapon );
  1730. self SetWeaponAmmoClip( weapon, 9999 );
  1731.  
  1732. if ( weapon == "claymore_mp" || weapon == "claymore_detonator_mp" )
  1733. self setWeaponAmmoStock( weapon, 2 );
  1734. }
  1735.  
  1736. if ( self getAmmoCount( level.classGrenades[class]["primary"]["type"] ) < level.classGrenades[class]["primary"]["count"] )
  1737. self SetWeaponAmmoClip( level.classGrenades[class]["primary"]["type"], level.classGrenades[class]["primary"]["count"] );
  1738.  
  1739. if ( self getAmmoCount( level.classGrenades[class]["secondary"]["type"] ) < level.classGrenades[class]["secondary"]["count"] )
  1740. self SetWeaponAmmoClip( level.classGrenades[class]["secondary"]["type"], level.classGrenades[class]["secondary"]["count"] );
  1741. }
  1742.  
  1743.  
  1744. onPlayerConnecting()
  1745. {
  1746. for(;;)
  1747. {
  1748. level waittill( "connected", player );
  1749.  
  1750. if ( !isDefined( player.pers["class"] ) )
  1751. {
  1752. player.pers["class"] = "";
  1753. }
  1754. if ( !isDefined( player.pers["lastClass"] ) )
  1755. {
  1756. player.pers["lastClass"] = "";
  1757. }
  1758. player.class = player.pers["class"];
  1759. player.lastClass = player.pers["lastClass"];
  1760. player.detectExplosives = false;
  1761. player.bombSquadIcons = [];
  1762. player.bombSquadIds = [];
  1763. }
  1764. }
  1765.  
  1766.  
  1767. fadeAway( waitDelay, fadeDelay )
  1768. {
  1769. wait waitDelay;
  1770.  
  1771. self fadeOverTime( fadeDelay );
  1772. self.alpha = 0;
  1773. }
  1774.  
  1775.  
  1776. setClass( newClass )
  1777. {
  1778. self.curClass = newClass;
  1779. }
  1780.  
  1781. getPerkForClass( perkSlot, className )
  1782. {
  1783. class_num = getClassIndex( className );
  1784.  
  1785. if( isSubstr( className, "custom" ) )
  1786. return cac_getPerk( class_num, perkSlot );
  1787. else
  1788. return table_getPerk( level.classTableName, class_num, perkSlot );
  1789. }
  1790.  
  1791.  
  1792. classHasPerk( className, perkName )
  1793. {
  1794. return( getPerkForClass( 0, className ) == perkName || getPerkForClass( 1, className ) == perkName || getPerkForClass( 2, className ) == perkName );
  1795. }
  1796.  
  1797. isValidPrimary( refString, showAssert )
  1798. {
  1799. if( !IsDefined( showAssert ) )
  1800. showAssert = true;
  1801.  
  1802. switch ( refString )
  1803. {
  1804. case "iw5_m4":
  1805. case "riotshield":
  1806. case "iw5_ak47":
  1807. case "iw5_m16":
  1808. case "iw5_fad":
  1809. case "iw5_acr":
  1810. case "iw5_type95":
  1811. case "iw5_mk14":
  1812. case "iw5_scar":
  1813. case "iw5_g36c":
  1814. case "iw5_cm901":
  1815. case "iw5_mp5":
  1816. case "iw5_mp7":
  1817. case "iw5_m9":
  1818. case "iw5_p90":
  1819. case "iw5_pp90m1":
  1820. case "iw5_ump45":
  1821. case "iw5_barrett":
  1822. case "iw5_rsass":
  1823. case "iw5_dragunov":
  1824. case "iw5_msr":
  1825. case "iw5_as50":
  1826. case "iw5_ksg":
  1827. case "iw5_1887":
  1828. case "iw5_striker":
  1829. case "iw5_aa12":
  1830. case "iw5_usas12":
  1831. case "iw5_spas12":
  1832. case "xm25":
  1833. case "iw5_m60":
  1834. case "iw5_mk46":
  1835. case "iw5_pecheneg":
  1836. case "iw5_sa80":
  1837. case "iw5_mg36":
  1838. case "iw5_l96a1":
  1839. case "iw5_m60jugg":
  1840. case "iw5_riotshieldjugg":
  1841. return true;
  1842. default:
  1843. if( showAssert )
  1844. assertMsg( "Replacing invalid primary weapon: " + refString );
  1845. return false;
  1846. }
  1847. }
  1848.  
  1849. isValidSecondary( refString, perk2, perk3, showAssert )
  1850. {
  1851. if( !IsDefined( showAssert ) )
  1852. showAssert = true;
  1853.  
  1854. switch ( refString )
  1855. {
  1856. case "iw5_44magnum":
  1857. case "iw5_usp45":
  1858. case "iw5_deserteagle":
  1859. case "iw5_mp412":
  1860. case "iw5_g18":
  1861. case "iw5_fmg9":
  1862. case "iw5_mp9":
  1863. case "iw5_skorpion":
  1864. case "iw5_p99":
  1865. case "iw5_fnfiveseven":
  1866. case "m320":
  1867. case "rpg":
  1868. case "iw5_smaw":
  1869. case "stinger":
  1870. case "javelin":
  1871. case "xm25":
  1872.  
  1873. case "iw5_usp45jugg":
  1874. case "iw5_mp412jugg":
  1875. return true;
  1876.  
  1877. case "iw5_m4":
  1878. case "riotshield":
  1879. case "iw5_ak47":
  1880. case "iw5_m16":
  1881. case "iw5_fad":
  1882. case "iw5_acr":
  1883. case "iw5_type95":
  1884. case "iw5_mk14":
  1885. case "iw5_scar":
  1886. case "iw5_g36c":
  1887. case "iw5_cm901":
  1888. case "iw5_mp5":
  1889. case "iw5_mp7":
  1890. case "iw5_m9":
  1891. case "iw5_p90":
  1892. case "iw5_pp90m1":
  1893. case "iw5_ump45":
  1894. case "iw5_barrett":
  1895. case "iw5_rsass":
  1896. case "iw5_dragunov":
  1897. case "iw5_msr":
  1898. case "iw5_as50":
  1899. case "iw5_ksg":
  1900. case "iw5_1887":
  1901. case "iw5_striker":
  1902. case "iw5_aa12":
  1903. case "iw5_usas12":
  1904. case "iw5_spas12":
  1905. case "iw5_m60":
  1906. case "iw5_mk46":
  1907. case "iw5_pecheneg":
  1908. case "iw5_sa80":
  1909. case "iw5_mg36":
  1910. case "iw5_l96a1":
  1911. if ( getDvarInt ( "scr_game_perks" ) == 1 && ( perk2 == "specialty_twoprimaries" || perk3 == "specialty_twoprimaries" ) )
  1912. {
  1913. return true;
  1914. }
  1915. else
  1916. {
  1917. return false;
  1918. }
  1919. default:
  1920. if( showAssert )
  1921. assertMsg( "Replacing invalid secondary weapon: " + refString );
  1922. return false;
  1923. }
  1924. }
  1925.  
  1926. isValidAttachment( refString, shouldAssert )
  1927. {
  1928. if( !IsDefined( shouldAssert ) )
  1929. shouldAssert = true;
  1930.  
  1931. switch ( refString )
  1932. {
  1933. case "none":
  1934. case "acog":
  1935. case "acogsmg":
  1936. case "reflex":
  1937. case "reflexsmg":
  1938. case "reflexlmg":
  1939. case "silencer":
  1940. case "silencer02":
  1941. case "silencer03":
  1942. case "grip":
  1943. case "gl":
  1944. case "gp25":
  1945. case "m320":
  1946. case "akimbo":
  1947. case "thermal":
  1948. case "thermalsmg":
  1949. case "shotgun":
  1950. case "heartbeat":
  1951. case "fmj":
  1952. case "rof":
  1953. case "xmags":
  1954. case "eotech":
  1955. case "eotechsmg":
  1956. case "eotechlmg":
  1957. case "tactical":
  1958. case "vzscope":
  1959. case "hamrhybrid":
  1960. case "hybrid":
  1961. case "zoomscope":
  1962. return true;
  1963. default:
  1964. if( shouldAssert )
  1965. assertMsg( "Replacing invalid equipment weapon: " + refString );
  1966. return false;
  1967. }
  1968. }
  1969.  
  1970. isAttachmentUnlocked( weaponRef, attachmentRef )
  1971. {
  1972. /#
  1973. if( GetDvarInt( "unlockAllItems" ) )
  1974. return true;
  1975. #/
  1976. tableWeaponClassCol = 0;
  1977. tableWeaponClassAttachmentCol = 2;
  1978. tableWeaponRankCol = 4;
  1979. weaponRank = self GetPlayerData( "weaponRank", weaponRef );
  1980. colNum = int( tableLookup( "mp/weaponRankTable.csv", tableWeaponClassCol, getWeaponClass( weaponRef ), tableWeaponClassAttachmentCol ) );
  1981. attachmentRank = int( tableLookup( "mp/weaponRankTable.csv", colNum, attachmentRef, tableWeaponRankCol ) );
  1982. if( weaponRank >= attachmentRank )
  1983. return true;
  1984.  
  1985. return false;
  1986. }
  1987.  
  1988. isValidWeaponBuff( refString )
  1989. {
  1990. switch ( refString )
  1991. {
  1992. case "specialty_bulletpenetration":
  1993. case "specialty_marksman":
  1994. case "specialty_bling":
  1995. case "specialty_sharp_focus":
  1996. case "specialty_armorpiercing":
  1997. case "specialty_holdbreathwhileads":
  1998. case "specialty_longerrange":
  1999. case "specialty_fastermelee":
  2000. case "specialty_reducedsway":
  2001. case "specialty_lightweight":
  2002. case "specialty_moredamage":
  2003. return true;
  2004. default:
  2005. //assertMsg( "Replacing invalid weapon buff: " + refString );
  2006. return false;
  2007. }
  2008. }
  2009.  
  2010. isWeaponBuffUnlocked( weaponRef, buffRef )
  2011. {
  2012. /#
  2013. if( GetDvarInt( "unlockAllItems" ) )
  2014. return true;
  2015. #/
  2016. tableWeaponClassCol = 0;
  2017. tableWeaponClassBuffCol = 4;
  2018. tableWeaponRankCol = 4;
  2019. weaponRank = self GetPlayerData( "weaponRank", weaponRef );
  2020. colNum = int( tableLookup( "mp/weaponRankTable.csv", tableWeaponClassCol, getWeaponClass( weaponRef ), tableWeaponClassBuffCol ) );
  2021. buffRank = int( tableLookup( "mp/weaponRankTable.csv", colNum, buffRef, tableWeaponRankCol ) );
  2022. if( weaponRank >= buffRank )
  2023. return true;
  2024.  
  2025. return false;
  2026. }
  2027.  
  2028. isValidCamo( refString )
  2029. {
  2030. switch ( refString )
  2031. {
  2032. case "none":
  2033. case "classic":
  2034. case "snow":
  2035. case "multi":
  2036. case "d_urban":
  2037. case "hex":
  2038. case "choco":
  2039. case "marine":
  2040. case "snake":
  2041. case "winter":
  2042. case "blue":
  2043. case "red":
  2044. case "autumn":
  2045. case "gold":
  2046. return true;
  2047. default:
  2048. assertMsg( "Replacing invalid camo: " + refString );
  2049. return false;
  2050. }
  2051. }
  2052.  
  2053. isValidReticle( refString )
  2054. {
  2055. switch ( refString )
  2056. {
  2057. case "none":
  2058. case "ret1":
  2059. case "ret2":
  2060. case "ret3":
  2061. case "ret4":
  2062. case "ret5":
  2063. case "ret6":
  2064. return true;
  2065. default:
  2066. assertMsg( "Replacing invalid reticle " + refString );
  2067. return false;
  2068. }
  2069. }
  2070.  
  2071. isCamoUnlocked( weaponRef, camoRef )
  2072. {
  2073. /#
  2074. if( GetDvarInt( "unlockAllItems" ) )
  2075. return true;
  2076. #/
  2077. tableWeaponClassCol = 0;
  2078. tableWeaponClassCamoCol = 3;
  2079. tableWeaponRankCol = 4;
  2080. weaponRank = self GetPlayerData( "weaponRank", weaponRef );
  2081. colNum = int( tableLookup( "mp/weaponRankTable.csv", tableWeaponClassCol, getWeaponClass( weaponRef ), tableWeaponClassCamoCol ) );
  2082. camoRank = int( tableLookup( "mp/weaponRankTable.csv", colNum, camoRef, tableWeaponRankCol ) );
  2083. if( weaponRank >= camoRank )
  2084. return true;
  2085.  
  2086. return false;
  2087. }
  2088.  
  2089. isValidEquipment( refString )
  2090. {
  2091. switch ( refString )
  2092. {
  2093. case "frag_grenade_mp":
  2094. case "semtex_mp":
  2095. case "throwingknife_mp":
  2096. case "claymore_mp":
  2097. case "c4_mp":
  2098. case "bouncingbetty_mp":
  2099. case "specialty_portable_radar":
  2100. return true;
  2101. default:
  2102. assertMsg( "Replacing invalid equipment: " + refString );
  2103. return false;
  2104. }
  2105. }
  2106.  
  2107.  
  2108. isValidOffhand( refString )
  2109. {
  2110. switch ( refString )
  2111. {
  2112. case "flash_grenade_mp":
  2113. case "concussion_grenade_mp":
  2114. case "smoke_grenade_mp":
  2115. case "emp_grenade_mp":
  2116. case "trophy_mp":
  2117. case "specialty_tacticalinsertion":
  2118. case "specialty_scrambler":
  2119. case "specialty_portable_radar":
  2120. return true;
  2121. default:
  2122. assertMsg( "Replacing invalid offhand: " + refString );
  2123. return false;
  2124. }
  2125. }
  2126.  
  2127. isValidPerk1( refString )
  2128. {
  2129. switch ( refString )
  2130. {
  2131. case "specialty_longersprint":
  2132. case "specialty_fastreload":
  2133. case "specialty_scavenger":
  2134. case "specialty_blindeye":
  2135. case "specialty_paint":
  2136. return true;
  2137. default:
  2138. assertMsg( "Replacing invalid perk1: " + refString );
  2139. return false;
  2140. }
  2141. }
  2142.  
  2143. isValidPerk2( refString, perk1 )
  2144. {
  2145. if( !IsDefined( perk1 ) || perk1 != "specialty_anytwo" )
  2146. {
  2147. switch ( refString )
  2148. {
  2149. case "specialty_hardline":
  2150. case "specialty_coldblooded":
  2151. case "specialty_quickdraw":
  2152. case "specialty_twoprimaries":
  2153. case "specialty_assists":
  2154. case "_specialty_blastshield":
  2155. return true;
  2156. default:
  2157. assertMsg( "Replacing invalid perk2: " + refString );
  2158. return false;
  2159. }
  2160. }
  2161. return true;
  2162. }
  2163.  
  2164. isValidPerk3( refString, perk1 )
  2165. {
  2166. if( !IsDefined( perk1 ) || perk1 != "specialty_anytwo" )
  2167. {
  2168. switch ( refString )
  2169. {
  2170. case "specialty_detectexplosive":
  2171. case "specialty_autospot":
  2172. case "specialty_bulletaccuracy":
  2173. case "specialty_quieter":
  2174. case "specialty_stalker":
  2175. return true;
  2176. default:
  2177. assertMsg( "Replacing invalid perk3: " + refString );
  2178. return false;
  2179. }
  2180. }
  2181. return true;
  2182. }
  2183.  
  2184. isValidDeathStreak( refString )
  2185. {
  2186. switch ( refString )
  2187. {
  2188. //case "specialty_copycat":
  2189. //case "specialty_light_armor":
  2190. //case "specialty_carepackage":
  2191. case "specialty_juiced":
  2192. case "specialty_grenadepulldeath":
  2193. case "specialty_finalstand":
  2194. case "specialty_revenge":
  2195. case "specialty_stopping_power":
  2196. case "specialty_c4death":
  2197. case "specialty_uav":
  2198. case "specialty_null":
  2199. return true;
  2200. default:
  2201. assertMsg( "Replacing invalid death streak: " + refString );
  2202. return false;
  2203. }
  2204. }
  2205.  
  2206. isValidWeapon( refString )
  2207. {
  2208. if ( !isDefined( level.weaponRefs ) )
  2209. {
  2210. level.weaponRefs = [];
  2211.  
  2212. foreach ( weaponRef in level.weaponList )
  2213. level.weaponRefs[ weaponRef ] = true;
  2214. }
  2215.  
  2216. if ( isDefined( level.weaponRefs[ refString ] ) )
  2217. return true;
  2218.  
  2219. assertMsg( "Replacing invalid weapon/attachment combo: " + refString );
  2220.  
  2221. return false;
  2222. }
  2223.  
  2224. isValidKillstreak( refString )
  2225. {
  2226. switch ( refString )
  2227. {
  2228. case "uav":
  2229. case "double_uav":
  2230. case "triple_uav":
  2231. case "ac130":
  2232. case "precision_airstrike":
  2233. case "predator_missile":
  2234. case "counter_uav":
  2235. case "sentry":
  2236. case "airdrop_assault":
  2237. case "airdrop_sentry_minigun":
  2238. case "airdrop_juggernaut":
  2239. case "helicopter_flares":
  2240. case "emp":
  2241. case "littlebird_flock":
  2242. case "stealth_airstrike":
  2243. case "airdrop_trap":
  2244. case "minigun_turret":
  2245. case "escort_airdrop":
  2246. case "osprey_gunner":
  2247. case "deployable_vest":
  2248. case "directional_uav":
  2249. case "heli_sniper":
  2250. case "ims":
  2251. case "aastrike":
  2252. case "remote_mortar":
  2253. case "remote_mg_turret":
  2254. case "airdrop_juggernaut_recon":
  2255. case "uav_support":
  2256. case "remote_uav":
  2257. case "remote_tank":
  2258. case "airdrop_remote_tank":
  2259. case "sam_turret":
  2260. case "helicopter":
  2261. case "littlebird_support":
  2262.  
  2263. case "specialty_longersprint_ks":
  2264. case "specialty_fastreload_ks":
  2265. case "specialty_scavenger_ks":
  2266. case "specialty_blindeye_ks":
  2267. case "specialty_paint_ks":
  2268. case "specialty_hardline_ks":
  2269. case "specialty_coldblooded_ks":
  2270. case "specialty_quickdraw_ks":
  2271. case "specialty_assists_ks":
  2272. case "_specialty_blastshield_ks":
  2273. case "specialty_detectexplosive_ks":
  2274. case "specialty_autospot_ks":
  2275. case "specialty_bulletaccuracy_ks":
  2276. case "specialty_quieter_ks":
  2277. case "specialty_stalker_ks":
  2278.  
  2279. case "none":
  2280. return true;
  2281. default:
  2282. assertMsg( "Replacing invalid killstreak: " + refString );
  2283. return false;
  2284. }
  2285. }
  2286.  
  2287.  
Add Comment
Please, Sign In to add comment