Advertisement
Guest User

jmt_hdswitch

a guest
Mar 30th, 2015
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.11 KB | None | 0 0
  1. //--------------------------//
  2. // Created By: JediMindTrix //
  3. // Created On: 3/27/2015 //
  4. //--------------------------//
  5.  
  6. //--------------------------------------------------------------------------------//
  7. // Description/Instructions //
  8. // //
  9. // //
  10. //This script is designed to allow a player to switch their head model //
  11. //from their default, chosen one at character creation, to any of the available //
  12. //hooded/masked/hooded+masked head's provided by Bioware and Hakpaks. This is //
  13. //accomplished through a theoretical rest menu option. Another rest menu option //
  14. //would revert the players head back to the original. The default head is stored //
  15. //on the PC the first time they make use of the script, and remains there unless //
  16. //removed by a DM via the in-game console (A special tool would be cumbersome). //
  17. // //
  18. //This command is: "dm_setvarint jmt_OrigHeadChk 0". This will allow a new //
  19. //default head to be set in the event of a a DM-assisted Head Change. //
  20. // //
  21. //Theoretically, this script should be called in the Actions Taken handle of the //
  22. //appropriate conversation node. //
  23. //--------------------------------------------------------------------------------//
  24.  
  25. //--------------------------------------------------------------------------------//
  26. // Constants //
  27. // //
  28. //These defined constants are mainly used for legibility in the Function //
  29. //Execution. Each constant has been named after the appearance of the //
  30. //corresponding model. Further descriptions have been included for //
  31. //some (see below). Each number called by the constants below corresponds to a //
  32. //specific head model number; this model number in turn corresponds to a head //
  33. //number viewable in toolset on any of the dynamic races (except Half-Orcs, as //
  34. //they have no masked/hooded head models). //
  35. // //
  36. //--------------------------------------------------------------------------------//
  37.  
  38. //DWARF MALES
  39. const int MALE_DWARF_HOOD_BEARD = 18; //Stereotypical Beard
  40.  
  41. //DWARF FEMALES
  42. const int FEMALE_DWARF_HOOD_GOATEE = 17;
  43. const int FEMALE_DWARF_HOOD_BGOATEE = 19; //Sporting a bigger goatee
  44. const int FEMALE_DWARF_HOOD_NOGOATEE = 23;
  45.  
  46. //ELF MALES
  47. const int MALE_ELF_HOOD_MASK = 15; //default Bioware
  48. const int MALE_ELF_HOOD_LONGHAIR = 24; //LotR style
  49. const int MALE_ELF_HOOD_MASK_LONGHAIR = 27;
  50.  
  51. //ELF FEMALES
  52. const int FEMALE_ELF_HOOD_MASK = 14; //default Bioware
  53. const int FEMALE_ELF_HOOD_GALADRIEL = 34; //Galadriel Model
  54. const int FEMALE_ELF_HOOD_MASK_EYES = 46; //default Bioware w/colored eyes
  55. const int FEMALE_ELF_HOOD_MEH = 107;
  56.  
  57. //GNOME MALES
  58. const int MALE_GNOME_HOOD = 14; //Default Bioware
  59. const int MALE_GNOME_HOOD_MASK = 17; //Bioware Elf-Style
  60. const int MALE_GNOME_MASK = 18;
  61.  
  62. //GNOME FEMALES
  63. const int FEMALE_GNOME_HOOD = 5; //default Bioware
  64.  
  65. //HALFLING MALES
  66. const int MALE_HALF_HOOD_MASK = 9;
  67. const int MALE_HALF_HOOD = 11;
  68. const int MALE_MASK = 15;
  69. const int MALE_HOOD_MASK_ALT = 17; //alternate take on 9
  70. const int MALE_MASK_ALT = 18;
  71.  
  72. //HALFLING FEMALES
  73. const int FEMALE_HALF_HOOD_MASK = 3;
  74. const int FEMALE_HALF_HOOD = 9;
  75. const int FEMALE_HALF_HOOD_MASK_2 = 10; //Bioware Elf-Style
  76.  
  77. //HALF_ELF MALES
  78. const int MALE_HELF_HOOD = 2;
  79. const int MALE_HELF_MASK = 31;
  80. const int MALE_HELF_HOOD_BEARD = 36;
  81. const int MALE_HELF_MASK_BIG = 47; //Large version of 31
  82. const int MALE_HELF_HELSING = 188; //Hat w/Mask
  83.  
  84. //HALF_ELF FEMALES
  85. const int FEMALE_HELF_HOOD = 12;
  86. const int FEMALE_HELF_HOOD_MASK = 44;
  87. const int FEMALE_HELF_HOOD_MASK_JEWELS = 143; //looks arabian
  88. const int FEMALE_HELF_VISAS = 161; //Visas' head from KOTOR 2
  89. const int FEMALE_HELF_HOOD_HEADDRESS = 162; //Hood and decoration
  90.  
  91. //HUMAN MALES
  92. const int MALE_HUMAN_HOOD = 2;
  93. const int MALE_HUMAN_MASK = 31;
  94. const int MALE_HUMAN_HOOD_BEARD = 36;
  95. const int MALE_HUMAN_ALT_MASK = 47;
  96. const int MALE_HUMAN_HELSING = 188; //Hat and Mask
  97.  
  98. //HUMAN FEMALES
  99. const int FEMALE_HUMAN_HOOD = 12;
  100. const int FEMALE_HUMAN_HOOD_MASK = 44;
  101. const int FEMALE_HUMAN_HOOD_MASK_JEWELS = 143; //Arabian Look
  102. const int FEMALE_HUMAN_VISAS = 161; //Visas from KOTOR 2
  103. const int FEMALE_HUMAN_HOOD_HEADDRESS = 162; //Hood and Decoration
  104.  
  105. //HALF-ORCS HAVE NO HOODS/MASKS :'(
  106.  
  107. //------------------------------------------------------------------------------
  108. // Function Prototypes
  109. //------------------------------------------------------------------------------
  110.  
  111. //This function retrieves the Gender and Racial Type of object oPC and combines
  112. //the value's into a single callable integer for the switch below. NOTE: Race and
  113. //gender are always 1 higher than in the .2da. So a Male Dwarf is "11", rather than
  114. //"00" (which would be invalid).
  115. int GetGenderRaceValue(object oPC);
  116.  
  117. //This function set's oPC's Original Head number to a local variable stored on the
  118. //PC. This is mainly to function as a safety net to prevent the rest of the script
  119. //from turning one of the hood heads into the player's default head model.
  120. //This variable can be erased by a DM in case of permanent headchange.
  121. void SetPCOriginalHead(object oPC);
  122.  
  123. //------------------------------------------------------------------------------
  124. // Function Implementation
  125. //------------------------------------------------------------------------------
  126.  
  127. int GetGenderRaceValue(object oPC)
  128. {
  129. int iPCGender = GetGender(oPC) + 1; //Get's Gender, add's 1 to value
  130. int iPCRace = GetRacialType(oPC) + 1; //Get's Race, and add's 1 to value
  131. string sGenderRace = IntToString(iPCGender) + IntToString(iPCRace); //Converts iPCGender + iPCRace into
  132. //from two seperate integers into a single string
  133. int iGenderRace = StringToInt(sGenderRace); //Converts sGenderRace into an int we can then call from
  134. //a switch.
  135. return iGenderRace;
  136. }
  137.  
  138. void SetPCOriginalHead(object oPC)
  139. {
  140. if (GetLocalInt(oPC, "jmt_OrigHeadChk")==TRUE) return; //Stops the function if it's already been fired
  141. {
  142. SetLocalInt(oPC, "jmt_PCOriginalHead", GetCreatureBodyPart(CREATURE_PART_HEAD, oPC)); //Set's the original head value
  143. SetLocalInt(oPC, "jmt_OrigHeadChk", TRUE); //Set's a "DoOnce" command that will prevent overwriting PC's default head
  144. SendMessageToPC(oPC, "Head has been checked and set to PC"); //Debug Code to Comment Out
  145. }
  146. }
  147. //------------------------------------------------------------------------------
  148. // Function Execution
  149. //------------------------------------------------------------------------------
  150.  
  151. object oPC = GetPCSpeaker(); //Get's Conversation Speaker
  152. int iGenderRace = GetGenderRaceValue(oPC); //Call Custom Function
  153. int iCurrentHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC); //Get's the current head
  154.  
  155. void main()
  156. {
  157. //Begin safety check (prevent default head overwriting)
  158. SetPCOriginalHead(oPC); //Call our default head function
  159. //End safety check
  160.  
  161. switch(iGenderRace) //Race and Gender Check
  162. {
  163. case 11: //Begin Male Dwarf Case Statement
  164. {
  165. switch(iCurrentHead) //Head Check & Switch. Since there's only one suitable Dwarf model,
  166. //There's only a default action.
  167. {
  168. default: SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_DWARF_HOOD_BEARD, oPC);
  169. }
  170. break; //End Male Dwarf Case Statement
  171. }
  172. case 21: //Begin Female Dwarf Case Statement
  173. {
  174. switch(iCurrentHead)//Head Check & Switch
  175. {
  176. case 17: //Case 17 = FEMALE_DWARF_HOOD_GOATEE (The default head number that this
  177. //script switches a Female Dwarven PC's head too.)
  178. {
  179. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_DWARF_HOOD_BGOATEE, oPC);
  180. break;
  181. }
  182. case 19: //Case 19 = FEMALE_DWARF_HOOD_BGOATEE; this is how the cycle is carried through,
  183. //by specifying a case with the same model number as the head that the script
  184. //previously switched too.
  185. {
  186. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_DWARF_HOOD_NOGOATEE, oPC);
  187. break;
  188. }
  189. default: SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_DWARF_HOOD_GOATEE, oPC);
  190. }
  191. break;
  192. }
  193. case 12: //Male Elf
  194. {
  195. switch(iCurrentHead)//Head Check & Switch
  196. {
  197. case 15:
  198. {
  199. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_ELF_HOOD_LONGHAIR, oPC);
  200. break;
  201. }
  202. case 24:
  203. {
  204. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_ELF_HOOD_MASK_LONGHAIR, oPC);
  205. break;
  206. }
  207. default: SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_ELF_HOOD_MASK, oPC);
  208. }
  209. break;
  210. }
  211. case 22: //Female Elf
  212. {
  213. switch(iCurrentHead)//Head Check & Switch
  214. {
  215. case 14:
  216. {
  217.  
  218. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_ELF_HOOD_GALADRIEL, oPC);
  219. break;
  220. }
  221. case 34:
  222. {
  223. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_ELF_HOOD_MASK_EYES, oPC);
  224. break;
  225. }
  226. case 46:
  227. {
  228. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_ELF_HOOD_MEH, oPC);
  229. break;
  230. }
  231. default: SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_ELF_HOOD_MASK, oPC);
  232. }
  233. break;
  234. }
  235. case 13: //Male Gnome
  236. {
  237. switch(iCurrentHead)//Head Check & Switch
  238. {
  239. case 14:
  240. {
  241. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_GNOME_HOOD_MASK, oPC);
  242. break;
  243. }
  244. case 17:
  245. {
  246. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_GNOME_MASK, oPC);
  247. break;
  248. }
  249. default: SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_GNOME_HOOD, oPC);
  250. }
  251. break;
  252. }
  253. case 23: //Female Gnome
  254. {
  255. switch(iCurrentHead)//Head Check & Switchh
  256. {
  257. default: SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_GNOME_HOOD, oPC);
  258. }
  259. break;
  260. }
  261. case 14: //Male Halfling
  262. {
  263. switch(iCurrentHead)//Head Check & Switch
  264. {
  265. case 9:
  266. {
  267. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HALF_HOOD, oPC);
  268. break;
  269. }
  270. case 11:
  271. {
  272. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_MASK, oPC);
  273. break;
  274. }
  275. case 15:
  276. {
  277. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HOOD_MASK_ALT, oPC);
  278. break;
  279. }
  280. case 17:
  281. {
  282. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_MASK_ALT, oPC);
  283. break;
  284. }
  285. default: SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HALF_HOOD_MASK, oPC);
  286. }
  287. break;
  288. }
  289. case 24: //Female Halfling
  290. {
  291. switch(iCurrentHead)//Head Check & Switch
  292. {
  293. case 3:
  294. {
  295. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HALF_HOOD, oPC);
  296. break;
  297. }
  298. case 9:
  299. {
  300. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HALF_HOOD_MASK_2, oPC);
  301. break;
  302. }
  303. default: SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HALF_HOOD_MASK, oPC);
  304. }
  305. break;
  306. }
  307. case 15: //Male Half-Elf
  308. {
  309. switch(iCurrentHead)//Head Check & Switch
  310. {
  311. case 2:
  312. {
  313. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HELF_MASK, oPC);
  314. break;
  315. }
  316. case 31:
  317. {
  318. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HELF_HOOD_BEARD, oPC);
  319. break;
  320. }
  321. case 36:
  322. {
  323. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HELF_MASK_BIG, oPC);
  324. break;
  325. }
  326. case 47:
  327. {
  328. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HELF_HELSING, oPC);
  329. break;
  330. }
  331. default: SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HELF_HOOD, oPC);
  332. }
  333. break;
  334. }
  335. case 25: //Female Half-Elf
  336. {
  337. switch (iCurrentHead)//Head Check & Switch
  338. {
  339. case 12:
  340. {
  341. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HELF_HOOD_MASK, oPC);
  342. break;
  343. }
  344. case 44:
  345. {
  346. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HELF_HOOD_MASK_JEWELS, oPC);
  347. break;
  348. }
  349. case 143:
  350. {
  351. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HELF_VISAS, oPC);
  352. break;
  353. }
  354. case 161:
  355. {
  356. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HELF_HOOD_HEADDRESS, oPC);
  357. break;
  358. }
  359. default: SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HELF_HOOD, oPC);
  360. }
  361. break;
  362. }
  363. case 17: //Male Humans
  364. {
  365. switch(iCurrentHead)//Head Check & Switch
  366. {
  367. case 2:
  368. {
  369. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HUMAN_MASK, oPC);
  370. break;
  371. }
  372. case 31:
  373. {
  374. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HUMAN_HOOD_BEARD, oPC);
  375. break;
  376. }
  377. case 36:
  378. {
  379. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HUMAN_ALT_MASK, oPC);
  380. break;
  381. }
  382. case 47:
  383. {
  384. SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HUMAN_HELSING, oPC);
  385. break;
  386. }
  387. default: SetCreatureBodyPart(CREATURE_PART_HEAD, MALE_HUMAN_HOOD, oPC);
  388. }
  389. break;
  390. }
  391. case 27: //Female Humans
  392. {
  393. switch(iCurrentHead)//Head Check & Switch
  394. {
  395. case 12:
  396. {
  397. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HUMAN_HOOD_MASK, oPC);
  398. break;
  399. }
  400. case 44:
  401. {
  402. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HUMAN_HOOD_MASK_JEWELS, oPC);
  403. break;
  404. }
  405. case 143:
  406. {
  407. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HUMAN_VISAS, oPC);
  408. break;
  409. }
  410. case 161:
  411. {
  412. SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HUMAN_HOOD_HEADDRESS, oPC);
  413. break;
  414. }
  415. default: SetCreatureBodyPart(CREATURE_PART_HEAD, FEMALE_HUMAN_HOOD, oPC);
  416. }
  417. break;
  418. }
  419.  
  420. }
  421. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement