NPCModule.lua 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. --[[
  2. Script Name : SpawnScripts/Generic/NPCModule.lua
  3. Script Author : LordPazuzu
  4. Script Date : 2023.11.20 08:11:41
  5. Script Purpose : NPC Statistics Control Script- In Development
  6. : Supersedes CombatModule.lua
  7. --]]
  8. require "SpawnScripts/Generic/EquipmentModule"
  9. GlobalDmgMod = 1.0 -- Global Damage Multiplier- make global adjustments to all NPC autoattack damage.
  10. GlobalStatMod = 1.0 -- Global Attribute Multiplier- make global adjustments to NPC attribute scores.
  11. GlobalHPMod = 1.0 -- Global Hit Point Multiplier
  12. GlobalPowerMod = 1.0 -- Global Power Pool Multiplier
  13. function NPCModule(NPC, Spawn)
  14. level = GetLevel(NPC) -- NPC Level
  15. difficulty = GetDifficulty(NPC) -- NPC Difficulty
  16. MeleeDmgMod = GetStr(NPC) / 10 -- Determines strength bonus to auttoattack damage.
  17. --Included functions. Comment out a function to disable.
  18. Attributes(NPC, Spawn) -- Determines basic stats of the NPC(str, agi, sta, int, wis)
  19. AutoAttack(NPC, Spawn) -- Determines the NPC's tier for the purposes of autoattack damage.
  20. Regen(NPC, Spawn) -- Sets NPC's health and/or power regeneration rates or disables regeneration entirely.
  21. HealthPower(NPC, Spawn) -- Calculates NPC's based on level and difficulty.
  22. --Heroic(NPC, Spawn) -- Detects if an NPC should be flagged as heroic and sets the heroic flag accordingly.
  23. AddTimer(NPC, 25, "Heroic")
  24. AddTimer(NPC, 1000, "Heroic") -- Redundant heroic check to compensate for server lag when using developer commands to reload spawns.
  25. end
  26. --Determine damage function based on NPC level.
  27. function AutoAttack(NPC, Spawn)
  28. if level <= 3 then
  29. TierOneA(NPC)
  30. elseif level >= 4 and level <= 5 then
  31. TierOneB(NPC)
  32. elseif level >= 6 and level <= 9 then
  33. TierOneC(NPC)
  34. elseif level >= 10 and level <= 15 then
  35. TierTwoA(NPC)
  36. elseif level >= 16 and level <= 19 then
  37. TierTwoB(NPC)
  38. elseif level >= 20 and level <= 24 then
  39. TierThreeA(NPC)
  40. elseif level >= 25 and level <= 29 then
  41. TierThreeB(NPC)
  42. end
  43. end
  44. -- Set attributes based on NPC level and difficulty
  45. function Attributes(NPC, Spawn)
  46. -- Calculate attributes
  47. if level <= 4 then
  48. baseStat = 19 else
  49. baseStat = level + 15
  50. end
  51. local low = baseStat - 15 -- Difficulty 1-3 vvv
  52. local four = baseStat - 10 -- Difficulty 4 vv
  53. local five = baseStat - 5 -- Difficulty 5 v
  54. local seven = baseStat + 10 -- Difficulty 7 ^
  55. local eight = baseStat + 15 -- Difficulty 8 ^^
  56. local nine = baseStat + 20 -- Difficulty 9 ^^^
  57. lowStat = math.floor(low * GlobalStatMod)
  58. fourStat = math.floor(four * GlobalStatMod)
  59. fiveStat = math.floor(five * GlobalStatMod)
  60. sixStat = math.floor(baseStat * GlobalStatMod)
  61. sevenStat = math.floor(seven * GlobalStatMod)
  62. eightStat = math.floor(eight * GlobalStatMod)
  63. nineStat = math.floor(nine * GlobalStatMod)
  64. -- Determine attribute by difficulty
  65. if difficulty <= 3 then
  66. finalStat = lowStat
  67. elseif difficulty == 4 then
  68. finalStat = fourStat
  69. elseif difficulty == 5 then
  70. finalStat = fiveStat
  71. elseif difficulty == 6 then
  72. finalStat = sixStat
  73. elseif difficulty == 7 then
  74. finalStat = sevenStat
  75. elseif difficulty == 8 then
  76. finalStat = eightStat
  77. elseif difficulty == 9 then
  78. finalStat = nineStat
  79. end
  80. SetInfoStructFloat(NPC, "str", finalStat)
  81. SetStrBase(NPC, finalStat)
  82. SetInfoStructFloat(NPC, "agi", finalStat)
  83. SetAgiBase(NPC, finalStat)
  84. SetInfoStructFloat(NPC, "sta", finalStat)
  85. SetStaBase(NPC, finalStat)
  86. SetInfoStructFloat(NPC, "intel", finalStat)
  87. SetIntBase(NPC, finalStat)
  88. SetInfoStructFloat(NPC, "wis", finalStat)
  89. SetWisBase(NPC, finalStat)
  90. end
  91. --Health and power regeneration rates
  92. function Regen(NPC, Spawn)
  93. -- In-combat health regeneration
  94. SetInfoStructUInt(NPC, "hp_regen_override", 1) -- Set to 0 to disable and allow the server to set the regen rate.
  95. SetInfoStructSInt(NPC, "hp_regen", 0) -- Set Regen Amount. Default 0
  96. -- In-combat power regeneration
  97. SetInfoStructUInt(NPC, "pw_regen_override", 1) -- Set to 0 to disable and allow the server to set the regen rate.
  98. SetInfoStructSInt(NPC, "pw_regen", 0) -- Set Regen Amount. Default 0
  99. end
  100. --Damage functions based on NPC level range.
  101. --Level 1-3
  102. function TierOneA(NPC, Spawn)
  103. lowDmg = math.floor(0 * GlobalDmgMod + MeleeDmgMod)
  104. highDmg = math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  105. damage(NPC)
  106. end
  107. --Level 4-5
  108. function TierOneB(NPC, Spawn)
  109. if difficulty <=4 then --
  110. lowDmg = math.floor(1 * GlobalDmgMod + MeleeDmgMod)
  111. highDmg =math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  112. elseif difficulty == 5 then
  113. lowDmg = math.floor(1 * GlobalDmgMod + MeleeDmgMod)
  114. highDmg = math.floor(3 * GlobalDmgMod + MeleeDmgMod)
  115. elseif difficulty >=6 and difficulty <=9 then
  116. lowDmg = math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  117. highDmg = math.floor(4 * GlobalDmgMod + MeleeDmgMod)
  118. end
  119. damage(NPC)
  120. end
  121. --Level 6-9
  122. function TierOneC(NPC, Spawn)
  123. if difficulty <=4 then -- 1-3 dif 1-4
  124. lowDmg = math.floor(1 * GlobalDmgMod + MeleeDmgMod)
  125. highDmg =math.floor(3 * GlobalDmgMod + MeleeDmgMod)
  126. elseif difficulty == 5 then -- 2-4 dif 5MeleeDmgMod
  127. lowDmg = math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  128. highDmg = math.floor(4 * GlobalDmgMod + MeleeDmgMod)
  129. elseif difficulty ==6 then -- 2-7 damage- Dif 6
  130. lowDmg = math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  131. highDmg = math.floor(7 * GlobalDmgMod + MeleeDmgMod)
  132. elseif difficulty >=7 then -- 2-7 damage- Dif 7+
  133. lowDmg = math.floor(5 * GlobalDmgMod + MeleeDmgMod)
  134. highDmg = math.floor(10 * GlobalDmgMod + MeleeDmgMod)
  135. end
  136. damage(NPC)
  137. end
  138. --Level 10-15
  139. function TierTwoA(NPC, Spawn)
  140. if difficulty <=4 then
  141. lowDmg = math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  142. highDmg =math.floor(4 * GlobalDmgMod + MeleeDmgMod)
  143. elseif difficulty == 5 then
  144. lowDmg = math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  145. highDmg = math.floor(7 * GlobalDmgMod + MeleeDmgMod)
  146. elseif difficulty ==6 then
  147. lowDmg = math.floor(6 * GlobalDmgMod + MeleeDmgMod)
  148. highDmg = math.floor(15 * GlobalDmgMod + MeleeDmgMod)
  149. elseif difficulty == 7 then
  150. lowDmg = math.floor(8 * GlobalDmgMod + MeleeDmgMod)
  151. highDmg = math.floor(17 * GlobalDmgMod + MeleeDmgMod)
  152. elseif difficulty >= 8 then
  153. lowDmg = math.floor(12 * GlobalDmgMod + MeleeDmgMod)
  154. highDmg = math.floor(24 * GlobalDmgMod + MeleeDmgMod)
  155. end
  156. damage(NPC)
  157. end
  158. --Level 16-19
  159. function TierTwoB(NPC, Spawn)
  160. if difficulty <=4 then
  161. lowDmg = math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  162. highDmg =math.floor(7 * GlobalDmgMod + MeleeDmgMod)
  163. elseif difficulty == 5 then
  164. lowDmg = math.floor(6 * GlobalDmgMod + MeleeDmgMod)
  165. highDmg = math.floor(15 * GlobalDmgMod + MeleeDmgMod)
  166. elseif difficulty ==6 then
  167. lowDmg = math.floor(12 * GlobalDmgMod + MeleeDmgMod)
  168. highDmg = math.floor(24 * GlobalDmgMod + MeleeDmgMod)
  169. elseif difficulty == 7 then
  170. lowDmg = math.floor(18 * GlobalDmgMod + MeleeDmgMod)
  171. highDmg = math.floor(32 * GlobalDmgMod + MeleeDmgMod)
  172. elseif difficulty >= 8 then
  173. lowDmg = math.floor(25 * GlobalDmgMod + MeleeDmgMod)
  174. highDmg = math.floor(55 * GlobalDmgMod + MeleeDmgMod)
  175. end
  176. damage(NPC)
  177. end
  178. --Level 20-24
  179. function TierThreeA(NPC, Spawn)
  180. if difficulty <=4 then
  181. lowDmg = math.floor(2 * GlobalDmgMod + MeleeDmgMod)
  182. highDmg =math.floor(7 * GlobalDmgMod + MeleeDmgMod)
  183. elseif difficulty == 5 then
  184. lowDmg = math.floor(6 * GlobalDmgMod + MeleeDmgMod)
  185. highDmg = math.floor(15 * GlobalDmgMod + MeleeDmgMod)
  186. elseif difficulty ==6 then
  187. lowDmg = math.floor(12 * GlobalDmgMod + MeleeDmgMod)
  188. highDmg = math.floor(24 * GlobalDmgMod + MeleeDmgMod)
  189. elseif difficulty == 7 then
  190. lowDmg = math.floor(18 * GlobalDmgMod + MeleeDmgMod)
  191. highDmg = math.floor(32 * GlobalDmgMod + MeleeDmgMod)
  192. elseif difficulty >= 8 then
  193. lowDmg = math.floor(25 * GlobalDmgMod + MeleeDmgMod)
  194. highDmg = math.floor(55 * GlobalDmgMod + MeleeDmgMod)
  195. end
  196. damage(NPC)
  197. end
  198. --Level 25-29
  199. function TierThreeB(NPC, Spawn)
  200. if difficulty <=4 then
  201. lowDmg = math.floor(6 * GlobalDmgMod + MeleeDmgMod)
  202. highDmg =math.floor(15 * GlobalDmgMod + MeleeDmgMod)
  203. elseif difficulty == 5 then
  204. lowDmg = math.floor(12 * GlobalDmgMod + MeleeDmgMod)
  205. highDmg = math.floor(24 * GlobalDmgMod + MeleeDmgMod)
  206. elseif difficulty ==6 then
  207. lowDmg = math.floor(20 * GlobalDmgMod + MeleeDmgMod)
  208. highDmg = math.floor(35 * GlobalDmgMod + MeleeDmgMod)
  209. elseif difficulty == 7 then
  210. lowDmg = math.floor(18 * GlobalDmgMod + MeleeDmgMod)
  211. highDmg = math.floor(32 * GlobalDmgMod + MeleeDmgMod)
  212. elseif difficulty >= 8 then
  213. lowDmg = math.floor(35 * GlobalDmgMod + MeleeDmgMod)
  214. highDmg = math.floor(75 * GlobalDmgMod + MeleeDmgMod)
  215. end
  216. damage(NPC)
  217. end
  218. --Autoattack damage override function.
  219. function damage(NPC, Spawn)
  220. SetInfoStructUInt(NPC, "override_primary_weapon", 1) --Set to 1 enables override for autoattack damage. Set to 0 to allow server to set damage.
  221. SetInfoStructUInt(NPC, "primary_weapon_damage_low", lowDmg)
  222. SetInfoStructUInt(NPC, "primary_weapon_damage_high", highDmg)
  223. end
  224. --Calculate Hitpoints and Power
  225. function HealthPower(NPC, Spawn)
  226. -- Calculate multipliers based on difficulty tier
  227. if difficulty == 1 then
  228. HPMod = 0.20
  229. PWMod = 0.20
  230. elseif difficulty == 2 then
  231. HPMod = 0.25
  232. PWMod = 0.25
  233. elseif difficulty == 3 then
  234. HPMod = 0.35
  235. PWMod = 0.35
  236. elseif difficulty == 4 then
  237. HPMod = 0.45
  238. PWMod = 0.45
  239. elseif difficulty == 5 then
  240. HPMod = 0.66
  241. PWMod = 0.66
  242. elseif difficulty == 6 then
  243. HPMod = 1.0
  244. PWMod = 1.0
  245. elseif difficulty == 7 then
  246. HPMod = 1.45
  247. PWMod = 1.45
  248. elseif difficulty == 8 then
  249. HPMod = 2.2
  250. PWMod = 2.2
  251. elseif difficulty == 9 then
  252. HPMod = 3.25
  253. PWMod = 3.25
  254. end
  255. --Calculate hitpoints and power based on level and difficuty
  256. if level == 1 then
  257. hp = 30 * HPMod * GlobalHPMod
  258. pw = 25 * PWMod * GlobalPowerMod
  259. elseif level == 2 then
  260. hp = 45 * HPMod * GlobalHPMod
  261. pw = 35 * PWMod * GlobalPowerMod
  262. elseif level == 3 then
  263. hp = 75 * HPMod * GlobalHPMod
  264. pw = 45 * PWMod * GlobalPowerMod
  265. elseif level == 4 then
  266. hp = 110 * HPMod * GlobalHPMod
  267. pw = 55 * PWMod * GlobalPowerMod
  268. elseif level == 5 then
  269. hp = 130 * HPMod * GlobalHPMod
  270. pw = 65 * PWMod * GlobalPowerMod
  271. elseif level == 6 then
  272. hp = 150 * HPMod * GlobalHPMod
  273. pw = 80 * PWMod * GlobalPowerMod
  274. elseif level == 7 then
  275. hp = 200 * HPMod * GlobalHPMod
  276. pw = 90 * PWMod * GlobalPowerMod
  277. elseif level == 8 then
  278. hp = 240 * HPMod * GlobalHPMod
  279. pw = 100* PWMod * GlobalPowerMod
  280. elseif level == 9 then
  281. hp = 275 * HPMod * GlobalHPMod
  282. pw = 110 * PWMod * GlobalPowerMod
  283. elseif level == 10 then
  284. hp = 370 * HPMod * GlobalHPMod
  285. pw = 130 * PWMod * GlobalPowerMod
  286. elseif level == 11 then
  287. hp = 430 * HPMod * GlobalHPMod
  288. pw = 160 * PWMod * GlobalPowerMod
  289. elseif level == 12 then
  290. hp = 550 * HPMod * GlobalHPMod
  291. pw = 185 * PWMod * GlobalPowerMod
  292. elseif level == 13 then
  293. hp = 680 * HPMod * GlobalHPMod
  294. pw = 205 * PWMod * GlobalPowerMod
  295. elseif level == 14 then
  296. hp = 795 * HPMod * GlobalHPMod
  297. pw = 240 * PWMod * GlobalPowerMod
  298. elseif level == 15 then
  299. hp = 920 * HPMod * GlobalHPMod
  300. pw = 270 * PWMod * GlobalPowerMod
  301. elseif level == 16 then
  302. hp = 1045 * HPMod * GlobalHPMod
  303. pw = 310 * PWMod * GlobalPowerMod
  304. elseif level == 17 then
  305. hp = 1180 * HPMod * GlobalHPMod
  306. pw = 360 * PWMod * GlobalPowerMod
  307. elseif level == 18 then
  308. hp = 1290 * HPMod * GlobalHPMod
  309. pw = 410 * PWMod * GlobalPowerMod
  310. elseif level == 19 then
  311. hp = 1440 * HPMod * GlobalHPMod
  312. pw = 425 * PWMod * GlobalPowerMod
  313. elseif level == 20 then
  314. hp = 1930 * HPMod * GlobalHPMod
  315. pw = 475 * PWMod * GlobalPowerMod
  316. elseif level == 21 then
  317. hp = 2120 * HPMod * GlobalHPMod
  318. pw = 500 * PWMod * GlobalPowerMod
  319. elseif level == 22 then
  320. hp = 2355 * HPMod * GlobalHPMod
  321. pw = 545 * PWMod * GlobalPowerMod
  322. elseif level == 23 then
  323. hp = 2595 * HPMod * GlobalHPMod
  324. pw = 575 * PWMod * GlobalPowerMod
  325. elseif level == 24 then
  326. hp = 2840 * HPMod * GlobalHPMod
  327. pw = 620 * PWMod * GlobalPowerMod
  328. elseif level == 25 then
  329. hp = 3080 * HPMod * GlobalHPMod
  330. pw = 670 * PWMod * GlobalPowerMod
  331. elseif level == 26 then
  332. hp = 3340 * HPMod * GlobalHPMod
  333. pw = 700 * PWMod * GlobalPowerMod
  334. elseif level == 27 then
  335. hp = 3600 * HPMod * GlobalHPMod
  336. pw = 755 * PWMod * GlobalPowerMod
  337. elseif level == 28 then
  338. hp = 3820 * HPMod * GlobalHPMod
  339. pw = 795 * PWMod * GlobalPowerMod
  340. elseif level == 29 then
  341. hp = 4240 * HPMod * GlobalHPMod
  342. pw = 835 * PWMod * GlobalPowerMod
  343. else
  344. hp = 5000 * HPMod * GlobalHPMod --temp values
  345. pw = 900 * PWMod * GlobalPowerMod -- temp values
  346. end
  347. SetMaxHP(NPC, math.floor(hp))
  348. ModifyHP(NPC, math.floor(hp))
  349. SetMaxPower(NPC, math.floor(pw))
  350. ModifyPower(NPC, math.floor(pw))
  351. end
  352. --Automatically set heroic flags based on specified criteria
  353. function Heroic(NPC, Spawn)
  354. local group = GetGroup(NPC)
  355. if group ~= nil then
  356. local groupsize = #group
  357. if groupsize > 1 then
  358. SpawnSet(NPC, "heroic", 1)
  359. end
  360. end
  361. if difficulty == 8 or difficulty == 9 then
  362. SpawnSet(NPC, "heroic", 1)
  363. end
  364. end
  365. -- OPTIONAL COSMETIC FUNCTIONS--
  366. --Race functions for DoF compatibility. These are called independently in the NPC's spawn function.
  367. function dwarf(NPC, Spawn)
  368. SpawnSet(NPC,"race",2)
  369. if GetGender(NPC)==2 then
  370. SpawnSet(NPC,"model_type",109)
  371. else
  372. SpawnSet(NPC,"model_type",110)
  373. end
  374. hair(NPC)
  375. end
  376. function froglok(NPC, Spawn)
  377. SpawnSet(NPC,"race",4)
  378. if GetGender(NPC)==2 then
  379. SpawnSet(NPC,"model_type",76)
  380. else
  381. SpawnSet(NPC,"model_type",77)
  382. end
  383. hair(NPC)
  384. end
  385. function halfling(NPC, Spawn)
  386. local hair = MakeRandomInt(1,2)
  387. SpawnSet(NPC,"race",7)
  388. if GetGender(NPC)==2 then
  389. SpawnSet(NPC,"model_type",107)
  390. else
  391. SpawnSet(NPC,"model_type",108)
  392. end
  393. if hair == 1 then
  394. SpawnSet(NPC, "hair_type", MakeRandomInt(1125,1128))
  395. else
  396. SpawnSet(NPC, "hair_type", MakeRandomInt(1133,1139))
  397. end
  398. haircolor(NPC)
  399. end
  400. function highelf(NPC, Spawn)
  401. SpawnSet(NPC,"race",8)
  402. if GetGender(NPC)==2 then
  403. SpawnSet(NPC,"model_type",135)
  404. else
  405. SpawnSet(NPC,"model_type",136)
  406. end
  407. hair(NPC)
  408. end
  409. function woodelf(NPC, Spawn)
  410. SpawnSet(NPC,"race",15)
  411. if GetGender(NPC)==2 then
  412. SpawnSet(NPC,"model_type",113)
  413. else
  414. SpawnSet(NPC,"model_type",114)
  415. end
  416. SpawnSet(NPC, "hair_type", MakeRandomInt(1133, 1139))
  417. haircolor(NPC)
  418. end
  419. function barbarian(NPC, Spawn)
  420. local hair = MakeRandomInt(1,2)
  421. SpawnSet(NPC,"race",0)
  422. if GetGender(NPC)==2 then
  423. SpawnSet(NPC,"model_type",111)
  424. else
  425. SpawnSet(NPC,"model_type",112)
  426. end
  427. if hair == 1 then
  428. SpawnSet(NPC, "hair_type", MakeRandomInt(1125,1128))
  429. else
  430. SpawnSet(NPC, "hair_type", MakeRandomInt(1133,1139))
  431. end
  432. haircolor(NPC)
  433. end
  434. function erudite(NPC, Spawn)
  435. SpawnSet(NPC,"race",3)
  436. if GetGender(NPC)==2 then
  437. SpawnSet(NPC,"model_type",120)
  438. else
  439. SpawnSet(NPC,"model_type",119)
  440. end
  441. hair(NPC)
  442. end
  443. function gnome(NPC, Spawn)
  444. SpawnSet(NPC,"race",5)
  445. if GetGender(NPC)==2 then
  446. SpawnSet(NPC,"model_type",122)
  447. else
  448. SpawnSet(NPC,"model_type",121)
  449. end
  450. hair(NPC)
  451. end
  452. function halfelf(NPC, Spawn)
  453. SpawnSet(NPC,"race",6)
  454. if GetGender(NPC)==2 then
  455. SpawnSet(NPC,"model_type",79)
  456. else
  457. SpawnSet(NPC,"model_type",78)
  458. end
  459. hair(NPC)
  460. end
  461. function human(NPC, Spawn)
  462. SpawnSet(NPC,"race",9)
  463. if GetGender(NPC)==2 then
  464. SpawnSet(NPC,"model_type",132)
  465. else
  466. SpawnSet(NPC,"model_type",134)
  467. end
  468. hair(NPC)
  469. end
  470. function kerra(NPC, Spawn)
  471. SpawnSet(NPC,"race",11)
  472. if GetGender(NPC)==2 then
  473. SpawnSet(NPC,"model_type",81)
  474. else
  475. SpawnSet(NPC,"model_type",82)
  476. end
  477. hair(NPC)
  478. end
  479. function darkelf(NPC, Spawn)
  480. SpawnSet(NPC,"race",1)
  481. if GetGender(NPC)==2 then
  482. SpawnSet(NPC,"model_type",116)
  483. else
  484. SpawnSet(NPC,"model_type",115)
  485. end
  486. hair(NPC)
  487. DarkElfHairColor(NPC, Spawn)
  488. end
  489. function iksar(NPC, Spawn)
  490. SpawnSet(NPC,"race",10)
  491. if GetGender(NPC)==2 then
  492. SpawnSet(NPC,"model_type",104)
  493. else
  494. SpawnSet(NPC,"model_type",103)
  495. end
  496. hair(NPC)
  497. end
  498. function ogre(NPC, Spawn)
  499. SpawnSet(NPC,"race",12)
  500. if GetGender(NPC)==2 then
  501. SpawnSet(NPC,"model_type",123)
  502. else
  503. SpawnSet(NPC,"model_type",124)
  504. end
  505. hair(NPC)
  506. end
  507. function ratonga(NPC, Spawn)
  508. SpawnSet(NPC,"race",13)
  509. if GetGender(NPC)==2 then
  510. SpawnSet(NPC,"model_type",54)
  511. else
  512. SpawnSet(NPC,"model_type",53)
  513. end
  514. hair(NPC)
  515. end
  516. function troll(NPC, Spawn)
  517. SpawnSet(NPC,"race",14)
  518. if GetGender(NPC)==2 then
  519. SpawnSet(NPC,"model_type",105)
  520. else
  521. SpawnSet(NPC,"model_type",106)
  522. end
  523. hair(NPC)
  524. end
  525. -- Classic Orcs
  526. function Deathfist(NPC, Spawn)
  527. SpawnSet(NPC,"model_type",137)
  528. SpawnSet(NPC, "race", 20)
  529. SpawnSet(NPC, "faction", 119)
  530. end
  531. function Bloodskull(NPC, Spawn)
  532. SpawnSet(NPC,"model_type",137)
  533. SpawnSet(NPC, "race", 20)
  534. SpawnSet(NPC, "faction", 120)
  535. SpawnSet(NPC, "skin_color", "50 60 50")
  536. SpawnSet(NPC, "eye_color", "98 63 28")
  537. end
  538. function Brokentusk(NPC, Spawn)
  539. SpawnSet(NPC,"model_type",137)
  540. SpawnSet(NPC, "race", 20)
  541. SpawnSet(NPC, "faction", 367)
  542. SpawnSet(NPC, "skin_color", "110 75 75")
  543. SpawnSet(NPC, "eye_color", "98 63 28")
  544. end
  545. function Lonetusk(NPC, Spawn)
  546. SpawnSet(NPC,"model_type",137)
  547. SpawnSet(NPC, "race", 20)
  548. SpawnSet(NPC, "faction", 366)
  549. SpawnSet(NPC, "skin_color", "92 52 52")
  550. SpawnSet(NPC, "eye_color", "98 63 28")
  551. end
  552. function Ree(NPC, Spawn)
  553. SpawnSet(NPC,"model_type",137)
  554. SpawnSet(NPC, "race", 20)
  555. SpawnSet(NPC, "faction", 121)
  556. end
  557. -- DoF compatible hair functions
  558. function hair(NPC, Spawn)
  559. SpawnSet(NPC, "hair_type", MakeRandomInt(1125, 1139))
  560. if GetRace(NPC)==1 then --Darkelf
  561. DarkElfHairColor(NPC, Spawn)
  562. else
  563. haircolor(NPC)
  564. end
  565. end
  566. function haircolor(NPC, Spawn)
  567. local color = MakeRandomInt(1,5)
  568. if color == 1 then
  569. SpawnSet(NPC, "hair_type_color", "102 36 18")
  570. SpawnSet(NPC, "hair_type_highlight_color", "138 129 121")
  571. SpawnSet(NPC, "hair_face_color", "102 36 18")
  572. SpawnSet(NPC, "hair_face_highlight_color", "138 129 121")
  573. elseif color == 2 then
  574. SpawnSet(NPC, "hair_type_color", "218 187 120")
  575. SpawnSet(NPC, "hair_type_highlight_color", "114 65 4")
  576. SpawnSet(NPC, "hair_face_color", "218 187 120")
  577. SpawnSet(NPC, "hair_face_highlight_color", "114 65 4")
  578. elseif color == 3 then
  579. SpawnSet(NPC, "hair_type_color", "51 18 8")
  580. SpawnSet(NPC, "hair_type_highlight_color", "60 59 55")
  581. SpawnSet(NPC, "hair_face_color", "51 18 8")
  582. SpawnSet(NPC, "hair_face_highlight_color", "60 59 55")
  583. elseif color == 4 then
  584. SpawnSet(NPC, "hair_type_color", "5 5 10")
  585. SpawnSet(NPC, "hair_type_highlight_color", "5 5 10")
  586. SpawnSet(NPC, "hair_face_color", "5 5 10")
  587. SpawnSet(NPC, "hair_face_highlight_color", "5 5 10")
  588. elseif color == 5 then
  589. SpawnSet(NPC, "hair_type_color", "230 230 230")
  590. SpawnSet(NPC, "hair_type_highlight_color", "154 147 81")
  591. SpawnSet(NPC, "hair_face_color", "230 230 230")
  592. SpawnSet(NPC, "hair_face_highlight_color", "154 147 81")
  593. end
  594. end
  595. function DarkElfHairColor(NPC, Spawn)
  596. local color = MakeRandomInt(1,5)
  597. if color == 1 then
  598. SpawnSet(NPC, "hair_type_color", "183 177 183")
  599. SpawnSet(NPC, "hair_type_highlight_color", "84 32 14")
  600. SpawnSet(NPC, "hair_face_color", "183 177 183")
  601. SpawnSet(NPC, "hair_face_highlight_color", "84 32 14")
  602. elseif color == 2 then
  603. SpawnSet(NPC, "hair_type_color", "170 191 191")
  604. SpawnSet(NPC, "hair_type_highlight_color", "84 32 4")
  605. SpawnSet(NPC, "hair_face_color", "170 191 191")
  606. SpawnSet(NPC, "hair_face_highlight_color", "84 32 4")
  607. elseif color == 3 then
  608. SpawnSet(NPC, "hair_type_color", "179 173 194")
  609. SpawnSet(NPC, "hair_type_highlight_color", "198 184 78")
  610. SpawnSet(NPC, "hair_face_color", "179 173 194")
  611. SpawnSet(NPC, "hair_face_highlight_color", "198 184 78")
  612. elseif color == 4 then
  613. SpawnSet(NPC, "hair_type_color", "219 244 244")
  614. SpawnSet(NPC, "hair_type_highlight_color", "105 103 97")
  615. SpawnSet(NPC, "hair_face_color", "219 244 244")
  616. SpawnSet(NPC, "hair_face_highlight_color", "105 103 97")
  617. elseif color == 5 then
  618. SpawnSet(NPC, "hair_type_color", "139 122 138")
  619. SpawnSet(NPC, "hair_type_highlight_color", "105 103 97")
  620. SpawnSet(NPC, "hair_face_color", "139 122 138")
  621. SpawnSet(NPC, "hair_face_highlight_color", "105 103 97")
  622. end
  623. end
  624. --Idle Animation Packages: Call the function in the main spawn function of the spawn script.
  625. function IdleAggressive(NPC)
  626. if not IsInCombat(NPC) and GetRunbackDistance(NPC)<2 then
  627. local choice = MakeRandomInt(1,5)
  628. if choice == 1 then
  629. PlayFlavor(NPC,"","","scheme",0,0)
  630. elseif choice == 2 then
  631. PlayFlavor(NPC,"","","brandish",0,0)
  632. elseif choice == 3 then
  633. PlayFlavor(NPC,"","","tapfoot",0,0)
  634. elseif choice == 4 then
  635. PlayFlavor(NPC,"","","swear",0,0)
  636. elseif choice == 5 then
  637. PlayFlavor(NPC,"","","threaten",0,0)
  638. end
  639. end
  640. AddTimer(NPC,MakeRandomInt(6500,12000),"IdleAggressive")
  641. end
  642. function IdleAlert(NPC)
  643. if not IsInCombat(NPC) and GetRunbackDistance(NPC)<2 then
  644. local choice = MakeRandomInt(1,5)
  645. if choice == 1 then
  646. PlayFlavor(NPC,"","","peer",0,0)
  647. elseif choice == 2 then
  648. PlayFlavor(NPC,"","","listen",0,0)
  649. elseif choice == 3 then
  650. PlayFlavor(NPC,"","","tapfoot",0,0)
  651. elseif choice == 4 then
  652. PlayFlavor(NPC,"","","yawn",0,0)
  653. elseif choice == 5 then
  654. PlayFlavor(NPC,"","","ponder",0,0)
  655. end
  656. end
  657. AddTimer(NPC,MakeRandomInt(6500,12000),"IdleAlert")
  658. end
  659. function IdleMischief(NPC)
  660. if not IsInCombat(NPC) and GetRunbackDistance(NPC)<2 then
  661. local choice = MakeRandomInt(1,5)
  662. if choice == 1 then
  663. PlayFlavor(NPC,"","","moon",0,0)
  664. elseif choice == 2 then
  665. PlayFlavor(NPC,"","","neener",0,0)
  666. elseif choice == 3 then
  667. PlayFlavor(NPC,"","","giggle",0,0)
  668. elseif choice == 4 then
  669. PlayFlavor(NPC,"","","dance",0,0)
  670. elseif choice == 5 then
  671. PlayFlavor(NPC,"","","heartattack",0,0)
  672. end
  673. end
  674. AddTimer(NPC,MakeRandomInt(6500,12000),"IdleMischief")
  675. end
  676. function IdleBored(NPC)
  677. if not IsInCombat(NPC) and GetRunbackDistance(NPC)<2 then
  678. local choice = MakeRandomInt(1,5)
  679. if choice == 1 then
  680. PlayFlavor(NPC,"","","tapfoot",0,0)
  681. elseif choice == 2 then
  682. PlayFlavor(NPC,"","","sigh",0,0)
  683. elseif choice == 3 then
  684. PlayFlavor(NPC,"","","stretch",0,0)
  685. elseif choice == 4 then
  686. PlayFlavor(NPC,"","","yawn",0,0)
  687. elseif choice == 5 then
  688. PlayFlavor(NPC,"","","stare",0,0)
  689. end
  690. end
  691. AddTimer(NPC,MakeRandomInt(6500,12000),"IdleBored")
  692. end
  693. function IdlePlayful(NPC)
  694. if not IsInCombat(NPC) and GetRunbackDistance(NPC)<2 then
  695. local choice = MakeRandomInt(1,5)
  696. if choice == 1 then
  697. PlayFlavor(NPC,"","","dance",0,0)
  698. elseif choice == 2 then
  699. PlayFlavor(NPC,"","","flirt",0,0)
  700. elseif choice == 3 then
  701. PlayFlavor(NPC,"","","smile",0,0)
  702. elseif choice == 4 then
  703. PlayFlavor(NPC,"","","thumbsup",0,0)
  704. elseif choice == 5 then
  705. PlayFlavor(NPC,"","","yeah",0,0)
  706. end
  707. end
  708. AddTimer(NPC,MakeRandomInt(6500,12000),"IdlePlayful")
  709. end
  710. function IdleSad(NPC)
  711. if not IsInCombat(NPC) and GetRunbackDistance(NPC)<2 then
  712. local choice = MakeRandomInt(1,5)
  713. if choice == 1 then
  714. PlayFlavor(NPC,"","","sad",0,0)
  715. elseif choice == 2 then
  716. PlayFlavor(NPC,"","","pout",0,0)
  717. elseif choice == 3 then
  718. PlayFlavor(NPC,"","","sigh",0,0)
  719. elseif choice == 4 then
  720. PlayFlavor(NPC,"","","sulk",0,0)
  721. elseif choice == 5 then
  722. PlayFlavor(NPC,"","","cry",0,0)
  723. end
  724. end
  725. AddTimer(NPC,MakeRandomInt(6500,12000),"IdleSad")
  726. end
  727. function IdleSneaky(NPC)
  728. if not IsInCombat(NPC) and GetRunbackDistance(NPC)<2 then
  729. local choice = MakeRandomInt(1,5)
  730. if choice == 1 then
  731. PlayFlavor(NPC,"","","scheme",0,0)
  732. elseif choice == 2 then
  733. PlayFlavor(NPC,"","","smirk",0,0)
  734. elseif choice == 3 then
  735. PlayFlavor(NPC,"","","whome",0,0)
  736. elseif choice == 4 then
  737. PlayFlavor(NPC,"","","beckon",0,0)
  738. elseif choice == 5 then
  739. PlayFlavor(NPC,"","","cutthroat",0,0)
  740. end
  741. end
  742. AddTimer(NPC,MakeRandomInt(6500,12000),"IdleSneaky")
  743. end
  744. function IdlePriest(NPC)
  745. if IsInCombat(NPC) == false then
  746. choice = MakeRandomInt(1,5)
  747. if choice == 1 then
  748. CastSpell(NPC, 110002, 5, NPC)
  749. elseif choice == 2 then
  750. CastSpell(NPC, 110003, 5, NPC)
  751. PlayFlavor(NPC,"","","yawn",0,0)
  752. -- PlayAnimation(NPC, 891)
  753. elseif choice == 4 then
  754. PlayFlavor(NPC,"","","tapfoot",0,0)
  755. -- PlayAnimation(NPC, 713)
  756. elseif choice == 5 then
  757. PlayFlavor(NPC,"","","sniff",0,0)
  758. -- PlayAnimation(NPC, 553)
  759. end
  760. end
  761. AddTimer(NPC,MakeRandomInt(6500,12000),"IdlePriest")
  762. end
  763. function IdleAngry(NPC)
  764. if IsInCombat(NPC) == false then
  765. choice = MakeRandomInt(1,5)
  766. if choice == 1 then
  767. PlayFlavor(NPC,"","","frustrated",0,0)
  768. elseif choice == 2 then
  769. PlayFlavor(NPC,"","","curse",0,0)
  770. elseif choice == 3 then
  771. PlayFlavor(NPC,"","","scold",0,0)
  772. elseif choice == 4 then
  773. PlayFlavor(NPC,"","","shakefist",0,0)
  774. elseif choice == 5 then
  775. PlayFlavor(NPC,"","","swear",0,0)
  776. end
  777. end
  778. AddTimer(NPC,MakeRandomInt(7000,10000),"IdleAngry")
  779. end
  780. function IdleBeggar(NPC)
  781. if IsInCombat(NPC) == false then
  782. choice = MakeRandomInt(1,5)
  783. if choice == 1 then
  784. PlayFlavor(NPC,"","","beg",0,0)
  785. -- PlayAnimation(NPC, 310)
  786. elseif choice == 2 then
  787. PlayFlavor(NPC,"","","peer",0,0)
  788. -- PlayAnimation(NPC, 411)
  789. elseif choice == 3 then
  790. PlayFlavor(NPC,"","","yawn",0,0)
  791. -- PlayAnimation(NPC, 891)
  792. elseif choice == 4 then
  793. PlayFlavor(NPC,"","","tapfoot",0,0)
  794. -- PlayAnimation(NPC, 713)
  795. elseif choice == 5 then
  796. PlayFlavor(NPC,"","","sniff",0,0)
  797. -- PlayAnimation(NPC, 553)
  798. end
  799. end
  800. AddTimer(NPC,MakeRandomInt(10000,15000),"IdleBeggar")
  801. end
  802. function IdleTinker(NPC)
  803. if IsInCombat(NPC) == false then
  804. choice = MakeRandomInt(1,7)
  805. if choice == 1 then
  806. PlayFlavor(NPC,"","","confused",0,0)
  807. -- PlayAnimation(NPC, 310)
  808. elseif choice == 2 then
  809. PlayFlavor(NPC,"","","yes",0,0)
  810. -- PlayAnimation(NPC, 411)
  811. elseif choice == 3 then
  812. PlayFlavor(NPC,"","","boggle",0,0)
  813. -- PlayAnimation(NPC, 891)
  814. elseif choice == 4 then
  815. PlayFlavor(NPC,"","","ponder",0,0)
  816. -- PlayAnimation(NPC, 713)
  817. elseif choice == 5 then
  818. PlayFlavor(NPC,"","","grumble",0,0)
  819. -- PlayAnimation(NPC, 553)
  820. elseif choice == 6 then
  821. PlayFlavor(NPC,"","","doh",0,0)
  822. -- PlayAnimation(NPC, 553)
  823. elseif choice == 7 then
  824. PlayFlavor(NPC,"","","crazy",0,0)
  825. -- PlayAnimation(NPC, 553)
  826. end
  827. end
  828. AddTimer(NPC,MakeRandomInt(8000,13000),"IdleTinker")
  829. end
  830. -- PATHING SCRIPTS --
  831. --[[ Randomized Movement Loops
  832. Call the RandomMovement() function in the NPC's spawn function.
  833. Example format: RandomMovement(NPC, Spawn, -5, 5, 2, 8, 15)
  834. This exampled sets the NPC to randomly move anywhere in a 5 meter radius
  835. from it's spawn point at a speed of 2, moving every 8-15 seconds.
  836. --]]
  837. function RandomMovement(NPC, Spawn, NegDist, PosDist, Speed, MinDly, MaxDly)
  838. local X = GetX(NPC)
  839. local Y = GetY(NPC)
  840. local Z = GetZ(NPC)
  841. MovementLoopAddLocation(NPC, X, Y, Z, Speed, MakeRandomInt(MinDly, MaxDly))
  842. MovementMod(NPC, Spawn, NegDist, PosDist, Speed, MinDly, MaxDly)
  843. MovementLoopAddLocation(NPC, X + LocModX, Y, Z + LocModZ, Speed, MakeRandomInt(MinDly, MaxDly))
  844. MovementMod(NPC, Spawn, NegDist, PosDist, Speed, MinDly, MaxDly)
  845. MovementLoopAddLocation(NPC, X + LocModX, Y, Z + LocModZ, Speed, MakeRandomInt(MinDly, MaxDly))
  846. MovementMod(NPC, Spawn, NegDist, PosDist, Speed, MinDly, MaxDly)
  847. MovementLoopAddLocation(NPC, X + LocModX, Y, Z + LocModZ, Speed, MakeRandomInt(MinDly, MaxDly))
  848. MovementMod(NPC, Spawn, NegDist, PosDist, Speed, MinDly, MaxDly)
  849. MovementLoopAddLocation(NPC, X + LocModX, Y, Z + LocModZ, Speed, MakeRandomInt(MinDly, MaxDly))
  850. MovementMod(NPC, Spawn, NegDist, PosDist, Speed, MinDly, MaxDly)
  851. MovementLoopAddLocation(NPC, X + LocModX, Y, Z + LocModZ, Speed, MakeRandomInt(MinDly, MaxDly))
  852. end
  853. function RandomMovementFlight(NPC, Spawn, NegDist, PosDist, NegHeight, PosHeight, Speed, MinDly, MaxDly)
  854. local X = GetX(NPC)
  855. local Y = GetY(NPC)
  856. local Z = GetZ(NPC)
  857. MovementLoopAddLocation(NPC, X, Y, Z, Speed, MakeRandomInt(MinDly, MaxDly))
  858. MovementLoopAddLocation(NPC, X + MakeRandomInt(NegDist, PosDist), Y + MakeRandomInt(NegHeight, PosHeight), Z + MakeRandomInt(NegDist, PosDist), Speed, MakeRandomInt(MinDly, MaxDly))
  859. MovementLoopAddLocation(NPC, X + MakeRandomInt(NegDist, PosDist), Y + MakeRandomInt(NegHeight, PosHeight), Z + MakeRandomInt(NegDist, PosDist), Speed, MakeRandomInt(MinDly, MaxDly))
  860. MovementLoopAddLocation(NPC, X + MakeRandomInt(NegDist, PosDist), Y + MakeRandomInt(NegHeight, PosHeight), Z + MakeRandomInt(NegDist, PosDist), Speed, MakeRandomInt(MinDly, MaxDly))
  861. MovementLoopAddLocation(NPC, X + MakeRandomInt(NegDist, PosDist), Y + MakeRandomInt(NegHeight, PosHeight), Z + MakeRandomInt(NegDist, PosDist), Speed, MakeRandomInt(MinDly, MaxDly))
  862. MovementLoopAddLocation(NPC, X + MakeRandomInt(NegDist, PosDist), Y + MakeRandomInt(NegHeight, PosHeight), Z + MakeRandomInt(NegDist, PosDist), Speed, MakeRandomInt(MinDly, MaxDly))
  863. end
  864. ---Set an NPC to follow another NPC
  865. function FollowNPC(NPC, Spawn, LocID, Speed, Distance)
  866. local zone = GetZone(NPC)
  867. local leader = GetSpawnByLocationID(zone, LocID)
  868. if GetDistance(NPC, leader) >= Distance then
  869. MovementLoopAddLocation (NPC, GetX(leader), GetY(leader), GetZ(leader), Speed, 0)
  870. end
  871. -- in progress, do not use
  872. end
  873. function MovementMod(NPC, Spawn, NegDist, PosDist, Speed, MinDly, MaxDly)
  874. MinNegDist = math.floor(NegDist/2)
  875. MinPosDist = math.floor(PosDist/2)
  876. MinX = MakeRandomInt(1,2)
  877. MinZ = MakeRandomInt(1,2)
  878. if MinX == 1 then
  879. LocModX = MakeRandomInt(MinNegDist, NegDist)
  880. elseif MinX == 2 then
  881. LocModX = MakeRandomInt(MinPostDist, PosDist)
  882. end
  883. if MinZ == 1 then
  884. LocModZ = MakeRandomInt(MinNegDist, NegDist)
  885. elseif MinZ == 2 then
  886. LocModZ = MakeRandomInt(MinPostDist, PosDist)
  887. end
  888. end
  889. -- Automatically enforce level uniformity in multi-spawn encounters
  890. function Encounters(NPC, Spawn)
  891. local group = GetGroup(NPC)
  892. if group ~= nil then
  893. for k,v in ipairs(group) do
  894. GroupLevel= GetLevel(v)
  895. Level = GroupLevel
  896. SpawnSet(NPC, "level", GroupLevel)
  897. end
  898. end
  899. end