Advertisement
Guest User

charCreate.lua

a guest
Jul 8th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.68 KB | None | 0 0
  1. CHARACTER_FACING_INCREMENT = 2;
  2. MAX_RACES = 12;
  3. MAX_CLASSES_PER_RACE = 10;
  4. NUM_CHAR_CUSTOMIZATIONS = 5;
  5. MIN_CHAR_NAME_LENGTH = 2;
  6. CHARACTER_CREATE_ROTATION_START_X = nil;
  7. CHARACTER_CREATE_INITIAL_FACING = nil;
  8.  
  9. PAID_CHARACTER_CUSTOMIZATION = 1;
  10. PAID_RACE_CHANGE = 2;
  11. PAID_FACTION_CHANGE = 3;
  12. PAID_SERVICE_CHARACTER_ID = nil;
  13. PAID_SERVICE_TYPE = nil;
  14.  
  15. FACTION_BACKDROP_COLOR_TABLE = {
  16. ["Alliance"] = {0.5, 0.5, 0.5, 0.09, 0.09, 0.19},
  17. ["Horde"] = {0.5, 0.2, 0.2, 0.19, 0.05, 0.05},
  18. };
  19. FRAMES_TO_BACKDROP_COLOR = {
  20. "CharacterCreateCharacterRace",
  21. "CharacterCreateCharacterClass",
  22. -- "CharacterCreateCharacterFaction",
  23. "CharacterCreateNameEdit",
  24. };
  25. RACE_ICON_TCOORDS = {
  26. ["HUMAN_MALE"] = {0, 0.125, 0, 0.25},
  27. ["DWARF_MALE"] = {0.125, 0.25, 0, 0.25},
  28. ["GNOME_MALE"] = {0.25, 0.375, 0, 0.25},
  29. ["NIGHTELF_MALE"] = {0.375, 0.5, 0, 0.25},
  30.  
  31. ["TAUREN_MALE"] = {0, 0.125, 0.25, 0.5},
  32. ["SCOURGE_MALE"] = {0.125, 0.25, 0.25, 0.5},
  33. ["TROLL_MALE"] = {0.25, 0.375, 0.25, 0.5},
  34. ["ORC_MALE"] = {0.375, 0.5, 0.25, 0.5},
  35.  
  36. ["HUMAN_FEMALE"] = {0, 0.125, 0.5, 0.75},
  37. ["DWARF_FEMALE"] = {0.125, 0.25, 0.5, 0.75},
  38. ["GNOME_FEMALE"] = {0.25, 0.375, 0.5, 0.75},
  39. ["NIGHTELF_FEMALE"] = {0.375, 0.5, 0.5, 0.75},
  40.  
  41. ["TAUREN_FEMALE"] = {0, 0.125, 0.75, 1.0},
  42. ["SCOURGE_FEMALE"] = {0.125, 0.25, 0.75, 1.0},
  43. ["TROLL_FEMALE"] = {0.25, 0.375, 0.75, 1.0},
  44. ["ORC_FEMALE"] = {0.375, 0.5, 0.75, 1.0},
  45.  
  46. ["BLOODELF_MALE"] = {0.5, 0.625, 0.25, 0.5},
  47. ["BLOODELF_FEMALE"] = {0.5, 0.625, 0.75, 1.0},
  48.  
  49. ["DRAENEI_MALE"] = {0.5, 0.625, 0, 0.25},
  50. ["DRAENEI_FEMALE"] = {0.5, 0.625, 0.5, 0.75},
  51.  
  52. ["GOBLIN_MALE"] = {0.625, 0.625, 0, 0.25},
  53. ["GOBLIN_FEMALE"] = {0.625, 0.625, 0, 0.25},
  54.  
  55. ["FELORC_MALE"] = {0.5, 0.625, 0, 0.25},
  56. ["FELORC_FEMALE"] = {0.5, 0.625, 0, 0.25},
  57. };
  58. CLASS_ICON_TCOORDS = {
  59. ["WARRIOR"] = {0, 0.25, 0, 0.25},
  60. ["MAGE"] = {0.25, 0.49609375, 0, 0.25},
  61. ["ROGUE"] = {0.49609375, 0.7421875, 0, 0.25},
  62. ["DRUID"] = {0.7421875, 0.98828125, 0, 0.25},
  63. ["HUNTER"] = {0, 0.25, 0.25, 0.5},
  64. ["SHAMAN"] = {0.25, 0.49609375, 0.25, 0.5},
  65. ["PRIEST"] = {0.49609375, 0.7421875, 0.25, 0.5},
  66. ["WARLOCK"] = {0.7421875, 0.98828125, 0.25, 0.5},
  67. ["PALADIN"] = {0, 0.25, 0.5, 0.75},
  68. ["DEATHKNIGHT"] = {0.25, 0.49609375, 0.5, 0.75},
  69. };
  70.  
  71. function CharacterCreate_OnLoad(self)
  72. self:SetSequence(0);
  73. self:SetCamera(0);
  74.  
  75. CharacterCreate.numRaces = 0;
  76. CharacterCreate.selectedRace = 0;
  77. CharacterCreate.numClasses = 0;
  78. CharacterCreate.selectedClass = 0;
  79. CharacterCreate.selectedGender = 0;
  80.  
  81. SetCharCustomizeFrame("CharacterCreate");
  82.  
  83. for i=1, NUM_CHAR_CUSTOMIZATIONS, 1 do
  84. _G["CharacterCustomizationButtonFrame"..i.."Text"]:SetText(_G["CHAR_CUSTOMIZATION"..i.."_DESC"]);
  85. end
  86.  
  87. -- Color edit box backdrop
  88. local backdropColor = FACTION_BACKDROP_COLOR_TABLE["Alliance"];
  89. CharacterCreateNameEdit:SetBackdropBorderColor(backdropColor[1], backdropColor[2], backdropColor[3]);
  90. CharacterCreateNameEdit:SetBackdropColor(backdropColor[4], backdropColor[5], backdropColor[6]);
  91. end
  92.  
  93. function CharacterCreate_OnShow()
  94. for i=1, MAX_CLASSES_PER_RACE, 1 do
  95. local button = _G["CharacterCreateClassButton"..i];
  96. button:Enable();
  97. SetButtonDesaturated(button, false)
  98. end
  99. for i=1, MAX_RACES, 1 do
  100. local button = _G["CharacterCreateRaceButton"..i];
  101. button:Enable();
  102. SetButtonDesaturated(button, false)
  103. end
  104.  
  105. if ( PAID_SERVICE_TYPE ) then
  106. CustomizeExistingCharacter( PAID_SERVICE_CHARACTER_ID );
  107. CharacterCreateNameEdit:SetText( PaidChange_GetName() );
  108. else
  109. --randomly selects a combination
  110. ResetCharCustomize();
  111. CharacterCreateNameEdit:SetText("");
  112. CharCreateRandomizeButton:Show();
  113. end
  114.  
  115. CharacterCreateEnumerateRaces(GetAvailableRaces());
  116. SetCharacterRace(GetSelectedRace());
  117.  
  118. CharacterCreateEnumerateClasses(GetAvailableClasses());
  119. local_,_,index = GetSelectedClass();
  120. SetCharacterClass(index);
  121.  
  122. SetCharacterGender(GetSelectedSex())
  123.  
  124. -- Hair customization stuff
  125. CharacterCreate_UpdateHairCustomization();
  126.  
  127. SetCharacterCreateFacing(-15);
  128.  
  129. if ( ALLOW_RANDOM_NAME_BUTTON ) then
  130. CharacterCreateRandomName:Show();
  131. end
  132.  
  133. -- setup customization
  134. CharacterChangeFixup();
  135. end
  136.  
  137. function CharacterCreate_OnHide()
  138. PAID_SERVICE_CHARACTER_ID = nil;
  139. PAID_SERVICE_TYPE = nil;
  140. end
  141.  
  142. function CharacterCreateFrame_OnMouseDown(button)
  143. if ( button == "LeftButton" ) then
  144. CHARACTER_CREATE_ROTATION_START_X = GetCursorPosition();
  145. CHARACTER_CREATE_INITIAL_FACING = GetCharacterCreateFacing();
  146. end
  147. end
  148.  
  149. function CharacterCreateFrame_OnMouseUp(button)
  150. if ( button == "LeftButton" ) then
  151. CHARACTER_CREATE_ROTATION_START_X = nil
  152. end
  153. end
  154.  
  155. function CharacterCreateFrame_OnUpdate()
  156. if ( CHARACTER_CREATE_ROTATION_START_X ) then
  157. local x = GetCursorPosition();
  158. local diff = (x - CHARACTER_CREATE_ROTATION_START_X) * CHARACTER_ROTATION_CONSTANT;
  159. CHARACTER_CREATE_ROTATION_START_X = GetCursorPosition();
  160. SetCharacterCreateFacing(GetCharacterCreateFacing() + diff);
  161. end
  162. end
  163.  
  164. function CharacterCreateEnumerateRaces(...)
  165. CharacterCreate.numRaces = select("#", ...)/3;
  166. if ( CharacterCreate.numRaces > MAX_RACES ) then
  167. message("Too many races! Update MAX_RACES");
  168. return;
  169. end
  170. local coords;
  171. local index = 1;
  172. local button;
  173. local gender;
  174. local selectedSex = GetSelectedSex();
  175. if ( selectedSex == SEX_MALE ) then
  176. gender = "MALE";
  177. elseif ( selectedSex == SEX_FEMALE ) then
  178. gender = "FEMALE";
  179. end
  180. for i=1, select("#", ...), 3 do
  181. coords = RACE_ICON_TCOORDS[strupper(select(i+1, ...).."_"..gender)];
  182. _G["CharacterCreateRaceButton"..index.."NormalTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  183. _G["CharacterCreateRaceButton"..index.."PushedTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  184. button = _G["CharacterCreateRaceButton"..index];
  185. button:Show();
  186. if ( select(i+2, ...) == 1 ) then
  187. button.enable = true;
  188. SetButtonDesaturated(button);
  189. button.name = select(i, ...)
  190. button.tooltip = select(i, ...);
  191. else
  192. button.enable = false;
  193. SetButtonDesaturated(button, 1);
  194. button.name = select(i, ...)
  195. button.tooltip = _G[strupper(select(i+1, ...).."_".."DISABLED")];
  196. end
  197. index = index + 1;
  198. end
  199. for i=CharacterCreate.numRaces + 1, MAX_RACES, 1 do
  200. _G["CharacterCreateRaceButton"..i]:Hide();
  201. end
  202. end
  203.  
  204. function CharacterCreateEnumerateClasses(...)
  205. CharacterCreate.numClasses = select("#", ...)/3;
  206. if ( CharacterCreate.numClasses > MAX_CLASSES_PER_RACE ) then
  207. message("Too many classes! Update MAX_CLASSES_PER_RACE");
  208. return;
  209. end
  210. local coords;
  211. local index = 1;
  212. local button;
  213. for i=1, select("#", ...), 3 do
  214. coords = CLASS_ICON_TCOORDS[strupper(select(i+1, ...))];
  215. _G["CharacterCreateClassButton"..index.."NormalTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  216. _G["CharacterCreateClassButton"..index.."PushedTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  217. button = _G["CharacterCreateClassButton"..index];
  218. button:Show();
  219. if ( (select(i+2, ...) == 1) and (IsRaceClassValid(CharacterCreate.selectedRace, index)) ) then
  220. button.enable = true;
  221. button:Enable();
  222. SetButtonDesaturated(button);
  223. button.name = select(i, ...)
  224. button.tooltip = select(i, ...);
  225. _G["CharacterCreateClassButton"..index.."DisableTexture"]:Hide();
  226. else
  227. button.enable = false;
  228. button:Disable();
  229. SetButtonDesaturated(button, 1);
  230. button.name = select(i, ...)
  231. button.tooltip = _G[strupper(select(i+1, ...).."_".."DISABLED")];
  232. _G["CharacterCreateClassButton"..index.."DisableTexture"]:Show();
  233. end
  234. index = index + 1;
  235. end
  236. for i=CharacterCreate.numClasses + 1, MAX_CLASSES_PER_RACE, 1 do
  237. _G["CharacterCreateClassButton"..i]:Hide();
  238. end
  239. end
  240.  
  241. function SetCharacterRace(id)
  242. CharacterCreate.selectedRace = id;
  243. local selectedButton;
  244. for i=1, CharacterCreate.numRaces, 1 do
  245. local button = _G["CharacterCreateRaceButton"..i];
  246. if ( i == id ) then
  247. _G["CharacterCreateRaceButton"..i.."Text"]:SetText(button.name);
  248. button:SetChecked(1);
  249. selectedButton = button;
  250. else
  251. _G["CharacterCreateRaceButton"..i.."Text"]:SetText("");
  252. button:SetChecked(0);
  253. end
  254. end
  255.  
  256. -- Set Faction
  257. local name, faction = GetFactionForRace(CharacterCreate.selectedRace);
  258.  
  259. -- Set Race
  260. local race, fileString = GetNameForRace();
  261.  
  262. CharacterCreateRaceLabel:SetText(race);
  263. fileString = strupper(fileString);
  264. if ( GetSelectedSex() == SEX_MALE ) then
  265. gender = "MALE";
  266. else
  267. gender = "FEMALE";
  268. end
  269. local coords = RACE_ICON_TCOORDS[fileString.."_"..gender];
  270. CharacterCreateRaceIcon:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  271. local raceText = _G["RACE_INFO_"..fileString];
  272. local abilityIndex = 1;
  273. local tempText = _G["ABILITY_INFO_"..fileString..abilityIndex];
  274. abilityText = "";
  275. while ( tempText ) do
  276. abilityText = abilityText..tempText.."\n\n";
  277. abilityIndex = abilityIndex + 1;
  278. tempText = _G["ABILITY_INFO_"..fileString..abilityIndex];
  279. end
  280.  
  281. CharacterCreateRaceScrollFrameScrollBar:SetValue(0);
  282. CharacterCreateRaceText:SetText(GetFlavorText("RACE_INFO_"..strupper(fileString), GetSelectedSex()).."|n|n");
  283. if ( abilityText and abilityText ~= "" ) then
  284. CharacterCreateRaceAbilityText:SetText(abilityText);
  285. else
  286. CharacterCreateRaceAbilityText:SetText("");
  287. end
  288.  
  289. -- Set backdrop colors based on faction
  290. local backdropColor = FACTION_BACKDROP_COLOR_TABLE[faction];
  291. local frame;
  292. for index, value in pairs(FRAMES_TO_BACKDROP_COLOR) do
  293. frame = _G[value];
  294. frame:SetBackdropColor(backdropColor[4], backdropColor[5], backdropColor[6]);
  295. end
  296. CharacterCreateConfigurationBackground:SetVertexColor(backdropColor[4], backdropColor[5], backdropColor[6]);
  297.  
  298. local backgroundFilename = GetCreateBackgroundModel();
  299. SetBackgroundModel(CharacterCreate, backgroundFilename);
  300. end
  301.  
  302. function SetCharacterClass(id)
  303. CharacterCreate.selectedClass = id;
  304. for i=1, CharacterCreate.numClasses, 1 do
  305. local button = _G["CharacterCreateClassButton"..i];
  306. if ( i == id ) then
  307. CharacterCreateClassName:SetText(button.name);
  308. button:SetChecked(1);
  309. else
  310. button:SetChecked(0);
  311. end
  312. end
  313.  
  314. local className, classFileName, _, tank, healer, damage = GetSelectedClass();
  315. local abilityIndex = 0;
  316. local tempText = _G["CLASS_INFO_"..classFileName..abilityIndex];
  317. abilityText = "";
  318. while ( tempText ) do
  319. abilityText = abilityText..tempText.."\n\n";
  320. abilityIndex = abilityIndex + 1;
  321. tempText = _G["CLASS_INFO_"..classFileName..abilityIndex];
  322. end
  323. local coords = CLASS_ICON_TCOORDS[classFileName];
  324. CharacterCreateClassIcon:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  325. CharacterCreateClassLabel:SetText(className);
  326. CharacterCreateClassRolesText:SetText(abilityText);
  327. CharacterCreateClassText:SetText(GetFlavorText("CLASS_"..strupper(classFileName), GetSelectedSex()).."|n|n");
  328. CharacterCreateClassScrollFrameScrollBar:SetValue(0);
  329. end
  330.  
  331. function CharacterCreate_OnChar()
  332. end
  333.  
  334. function CharacterCreate_OnKeyDown(key)
  335. if ( key == "ESCAPE" ) then
  336. CharacterCreate_Back();
  337. elseif ( key == "ENTER" ) then
  338. CharacterCreate_Okay();
  339. elseif ( key == "PRINTSCREEN" ) then
  340. Screenshot();
  341. end
  342. end
  343.  
  344. function CharacterCreate_UpdateModel(self)
  345. UpdateCustomizationScene();
  346. self:AdvanceTime();
  347. end
  348.  
  349. function CharacterCreate_Okay()
  350. if ( PAID_SERVICE_TYPE ) then
  351. GlueDialog_Show("CONFIRM_PAID_SERVICE");
  352. else
  353. CreateCharacter(CharacterCreateNameEdit:GetText());
  354. end
  355. PlaySound("gsCharacterCreationCreateChar");
  356. end
  357.  
  358. function CharacterCreate_Back()
  359. PlaySound("gsCharacterCreationCancel");
  360. SetGlueScreen("charselect");
  361. end
  362.  
  363. function CharacterClass_OnClick(id)
  364. PlaySound("gsCharacterCreationClass");
  365. local _,_,currClass = GetSelectedClass();
  366. if ( currClass ~= id and IsRaceClassValid(GetSelectedRace(), id) ) then
  367. SetSelectedClass(id);
  368. SetCharacterClass(id);
  369. SetCharacterRace(GetSelectedRace());
  370. CharacterChangeFixup();
  371. end
  372. end
  373.  
  374. function CharacterRace_OnClick(self, id)
  375. PlaySound("gsCharacterCreationClass");
  376. if ( not self:GetChecked() ) then
  377. self:SetChecked(1);
  378. return;
  379. end
  380. if ( GetSelectedRace() ~= id ) then
  381. SetSelectedRace(id);
  382. SetCharacterRace(id);
  383. SetSelectedSex(GetSelectedSex());
  384. SetCharacterCreateFacing(-15);
  385. CharacterCreateEnumerateClasses(GetAvailableClasses());
  386. local _,_,classIndex = GetSelectedClass();
  387. if ( PAID_SERVICE_TYPE ) then
  388. classIndex = PaidChange_GetCurrentClassIndex();
  389. end
  390. SetCharacterClass(classIndex);
  391.  
  392. -- Hair customization stuff
  393. CharacterCreate_UpdateHairCustomization();
  394.  
  395. CharacterChangeFixup();
  396. end
  397. end
  398.  
  399. function SetCharacterGender(sex)
  400. local gender;
  401. SetSelectedSex(sex);
  402. if ( sex == SEX_MALE ) then
  403. gender = "MALE";
  404. CharacterCreateGender:SetText(MALE);
  405. CharacterCreateGenderButtonMale:SetChecked(1);
  406. CharacterCreateGenderButtonFemale:SetChecked(nil);
  407. elseif ( sex == SEX_FEMALE ) then
  408. gender = "FEMALE";
  409. CharacterCreateGender:SetText(FEMALE);
  410. CharacterCreateGenderButtonMale:SetChecked(nil);
  411. CharacterCreateGenderButtonFemale:SetChecked(1);
  412. end
  413.  
  414. -- Update race images to reflect gender
  415. CharacterCreateEnumerateRaces(GetAvailableRaces());
  416. CharacterCreateEnumerateClasses(GetAvailableClasses());
  417. SetCharacterRace(GetSelectedRace());
  418.  
  419. local _,_,classIndex = GetSelectedClass();
  420. if ( PAID_SERVICE_TYPE ) then
  421. classIndex = PaidChange_GetCurrentClassIndex();
  422. end
  423. SetCharacterClass(classIndex);
  424.  
  425. CharacterCreate_UpdateHairCustomization();
  426.  
  427. -- Update right hand race portrait to reflect gender change
  428. -- Set Race
  429. local race, fileString = GetNameForRace();
  430. CharacterCreateRaceLabel:SetText(race);
  431. fileString = strupper(fileString);
  432. local coords = RACE_ICON_TCOORDS[fileString.."_"..gender];
  433. CharacterCreateRaceIcon:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  434.  
  435. CharacterChangeFixup();
  436. end
  437.  
  438. function CharacterCustomization_Left(id)
  439. PlaySound("gsCharacterCreationLook");
  440. CycleCharCustomization(id, -1);
  441. end
  442.  
  443. function CharacterCustomization_Right(id)
  444. PlaySound("gsCharacterCreationLook");
  445. CycleCharCustomization(id, 1);
  446. end
  447.  
  448. function CharacterCreate_Randomize()
  449. PlaySound("gsCharacterCreationLook");
  450. RandomizeCharCustomization();
  451. end
  452.  
  453. function CharacterCreateRotateRight_OnUpdate(self)
  454. if ( self:GetButtonState() == "PUSHED" ) then
  455. SetCharacterCreateFacing(GetCharacterCreateFacing() + CHARACTER_FACING_INCREMENT);
  456. end
  457. end
  458.  
  459. function CharacterCreateRotateLeft_OnUpdate(self)
  460. if ( self:GetButtonState() == "PUSHED" ) then
  461. SetCharacterCreateFacing(GetCharacterCreateFacing() - CHARACTER_FACING_INCREMENT);
  462. end
  463. end
  464.  
  465. function CharacterCreate_UpdateHairCustomization()
  466. CharacterCustomizationButtonFrame3Text:SetText(_G["HAIR_"..GetHairCustomization().."_STYLE"]);
  467. CharacterCustomizationButtonFrame4Text:SetText(_G["HAIR_"..GetHairCustomization().."_COLOR"]);
  468. CharacterCustomizationButtonFrame5Text:SetText(_G["FACIAL_HAIR_"..GetFacialHairCustomization()]);
  469. end
  470.  
  471. function SetButtonDesaturated(button, desaturated, r, g, b)
  472. if ( not button ) then
  473. return;
  474. end
  475. local icon = button:GetNormalTexture();
  476. if ( not icon ) then
  477. return;
  478. end
  479. local shaderSupported = icon:SetDesaturated(desaturated);
  480.  
  481. if ( not desaturated ) then
  482. r = 1.0;
  483. g = 1.0;
  484. b = 1.0;
  485. elseif ( not r or not shaderSupported ) then
  486. r = 0.5;
  487. g = 0.5;
  488. b = 0.5;
  489. end
  490.  
  491. icon:SetVertexColor(r, g, b);
  492. end
  493.  
  494. function GetFlavorText(tagname, sex)
  495. local primary, secondary;
  496. if ( sex == SEX_MALE ) then
  497. primary = "";
  498. secondary = "_FEMALE";
  499. else
  500. primary = "_FEMALE";
  501. secondary = "";
  502. end
  503. local text = _G[tagname..primary];
  504. if ( (text == nil) or (text == "") ) then
  505. text = _G[tagname..secondary];
  506. end
  507. return text;
  508. end
  509.  
  510. function CharacterCreate_DeathKnightSwap(self)
  511. local _, classFilename = GetSelectedClass();
  512. if ( classFilename == "DEATHKNIGHT" ) then
  513. if (self.currentModel ~= "DEATHKNIGHT") then
  514. self.currentModel = "DEATHKNIGHT";
  515. self:SetNormalTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Up-Blue");
  516. self:SetPushedTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Down-Blue");
  517. self:SetHighlightTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Highlight-Blue");
  518. end
  519. else
  520. if (self.currentModel == "DEATHKNIGHT") then
  521. self.currentModel = nil;
  522. self:SetNormalTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Up");
  523. self:SetPushedTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Down");
  524. self:SetHighlightTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Highlight");
  525. end
  526. end
  527. end
  528.  
  529. function CharacterChangeFixup()
  530. if ( PAID_SERVICE_TYPE ) then
  531. for i=1, MAX_CLASSES_PER_RACE, 1 do
  532. if (CharacterCreate.selectedClass ~= i) then
  533. local button = _G["CharacterCreateClassButton"..i];
  534. button:Disable();
  535. SetButtonDesaturated(button, true)
  536. end
  537. end
  538.  
  539. for i=1, MAX_RACES, 1 do
  540. local allow = false;
  541. if ( PAID_SERVICE_TYPE == PAID_FACTION_CHANGE ) then
  542. local faction = GetFactionForRace(PaidChange_GetCurrentRaceIndex());
  543. if ( (i == PaidChange_GetCurrentRaceIndex()) or ((GetFactionForRace(i) ~= faction) and (IsRaceClassValid(i,CharacterCreate.selectedClass))) ) then
  544. allow = true;
  545. end
  546. elseif ( PAID_SERVICE_TYPE == PAID_RACE_CHANGE ) then
  547. local faction = GetFactionForRace(PaidChange_GetCurrentRaceIndex());
  548. if ( (i == PaidChange_GetCurrentRaceIndex()) or ((GetFactionForRace(i) == faction) and (IsRaceClassValid(i,CharacterCreate.selectedClass))) ) then
  549. allow = true
  550. end
  551. elseif ( PAID_SERVICE_TYPE == PAID_CHARACTER_CUSTOMIZATION ) then
  552. if ( i == CharacterCreate.selectedRace ) then
  553. allow = true
  554. end
  555. end
  556. if (not allow) then
  557. local button = _G["CharacterCreateRaceButton"..i];
  558. button:Disable();
  559. SetButtonDesaturated(button, true)
  560. end
  561. end
  562. end
  563. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement