1
0

stat_sklattrib.qsrc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. # stat_sklattrib
  2. !!******************** Warning! ********************
  3. !!The code in this location is both complex and very fundamental to most systems!
  4. !!Use EXTREME caution if modifying!
  5. !!Ask if understanding is required
  6. !!****************************************************
  7. !!For Users;
  8. !! For any Attribute or Skill, outside of "stat_sklattrib", the only things that get used are;
  9. !! the variables themselves, pcs_"name", for checks
  10. !! "name"_exp to replace straight adds (i.e. stren_exp +=1 instead of pcs_stren += 1)
  11. !! "name"_deg to replace losses (i.e. stren_deg -= 1 instead of pcs_stren -= 1)
  12. !! "name"_muta if setting higher attribute limits due to "mutations" ("name"_muta replaces the "mutagen" variables)
  13. !! And checking "name"_lvl if and only if it''s being used to check if an NPC/Item can still train the PC. That is also the only time there should be a gate on "name"_exp += x and should be a minimum of += rand(3,5). No other gates should be used.
  14. !! The others are used in the code as controllers and modifying anything except "name"_exp, "name"_deg, and "name"_muta outside of this routine can break things
  15. !! Attributes & Skills
  16. !! $att_name[x] and $skl_name[x]; an array that stores the name of each attribute variable
  17. !! For each attribute and skill variable, there are the following sub-variables
  18. !! _lvl, is the base level of an attribute/skill before adjustment
  19. !! _lvlst, level yesterday, used for error checking
  20. !! _deg is the days to attribute/skill loss and is reset on XP gain
  21. !! _exp is the amount of total XP gained so far for each and will replace all the gains in the rest of the code
  22. !! _mem is the amount of XP yesterday
  23. !! _muta replaces the assorted mutagen variables for attributes, this is to replace the 30 lines of code with 1
  24. !! _flr, this is the floor through which an attribute/skill cannot fall
  25. !! _xpnxt is the XP required to reach the next level
  26. !! Traits
  27. !! $traitattskl[x], this stores a list of all traits that can affect attribute or skill advancement or degradation, if a trait does not, it does not go in this array
  28. !! For each trait that can affect attribute or skill advancement or degradation;
  29. !! "trait"[y1] = 1 if affecting an attribute or = 2 if affecting a skill;
  30. !! "trait"[y2] = the index number in $att_name or $skl_name that corresponds to the skill/attribute to be effected;
  31. !! "trait"[y3] = indicates if it effects XP required to level by adjusting the base rate as a plus to the default of 60
  32. !! "trait"[y4] = indicates if it effects degradation rate by adjusting the base rate as a plus to the default of 60 for attributes or 90 (3/2) for skills
  33. !! the 'y' in the above is for traits that affect more than 1 skill or attribute, note they must be contiguous 0x, 1x, 2x, etc. there can be no gaps
  34. !! Note, the effects of multiple traits on a single skill or attribute stack
  35. !!Attribute variable list
  36. $att_name[0] = 'stren'
  37. $att_name[1] = 'agil'
  38. $att_name[2] = 'vital'
  39. $att_name[3] = 'intel'
  40. $att_name[4] = 'react'
  41. $att_name[5] = 'sprt'
  42. $att_name[6] = 'chrsm'
  43. $att_name[7] = 'prcptn'
  44. $att_name[8] = 'magik'
  45. !!Skill variable list
  46. !!Add new skills to the end; if removing a skill, move the rest up and then edit the Traits so that the index numbers are correct
  47. $skl_name[0] = 'jab'
  48. $skl_name[1] = 'punch'
  49. $skl_name[2] = 'kick'
  50. $skl_name[3] = 'def'
  51. $skl_name[4] = 'shoot'
  52. $skl_name[5] = 'vokal'
  53. $skl_name[6] = 'sewng'
  54. $skl_name[7] = 'instrmusic'
  55. $skl_name[8] = 'photoskl'
  56. $skl_name[9] = 'artskls'
  57. $skl_name[10] = 'danc'
  58. $skl_name[11] = 'dancero'
  59. $skl_name[12] = 'dancpol'
  60. $skl_name[13] = 'chess'
  61. $skl_name[14] = 'gaming'
  62. $skl_name[15] = 'humint'
  63. $skl_name[16] = 'persuas'
  64. $skl_name[17] = 'run'
  65. $skl_name[18] = 'vball'
  66. $skl_name[19] = 'icesktng'
  67. $skl_name[20] = 'wrstlng'
  68. $skl_name[21] = 'ftbll'
  69. $skl_name[22] = 'splcstng'
  70. $skl_name[23] = 'observ'
  71. $skl_name[24] = 'makupskl'
  72. $skl_name[25] = 'compskl'
  73. $skl_name[26] = 'comphckng'
  74. $skl_name[27] = 'hndiwrk'
  75. $skl_name[28] = 'servng'
  76. $skl_name[29] = 'mdlng'
  77. $skl_name[30] = 'medcn'
  78. $skl_name[31] = 'heels'
  79. $skl_name[32] = 'pool'
  80. $skl_name[33] = 'inhib'
  81. $skl_name[34] = 'perform'
  82. $skl_name[35] = 'bushcraft'
  83. $skl_name[36] = 'cleaning'
  84. !!Trait Section
  85. !!This is where Traits that will affect attribute or skill advancement or degradation have those aspects defined.
  86. !!Always put the trait name, variable name, and skill or attribute variable in a comment
  87. !!Natural Dancer; Provides a 10% reduction in xp required to level dance skills
  88. nat_dancer[1] = 2 & nat_dancer[2] = 10 & nat_dancer[3] = -6 & nat_dancer[4] = 0
  89. nat_dancer[11] = 2 & nat_dancer[12] = 11 & nat_dancer[13] = -6 & nat_dancer[14] = 0
  90. nat_dancer[21] = 2 & nat_dancer[22] = 12 & nat_dancer[23] = -6 & nat_dancer[24] = 0
  91. !!Natural Athlete; Provides a 10% reduction in xp required to level sports skills
  92. nat_athlete[1] = 2 & nat_athlete[2] = 17 & nat_athlete[3] = -6 & nat_athlete[4] = 0
  93. nat_athlete[11] = 2 & nat_athlete[12] = 18 & nat_athlete[13] = -6 & nat_athlete[14] = 0
  94. nat_athlete[21] = 2 & nat_athlete[22] = 19 & nat_athlete[23] = -6 & nat_athlete[24] = 0
  95. nat_athlete[31] = 2 & nat_athlete[32] = 20 & nat_athlete[33] = -6 & nat_athlete[34] = 0
  96. nat_athlete[41] = 2 & nat_athlete[42] = 21 & nat_athlete[43] = -6 & nat_athlete[44] = 0
  97. !!Scholarly; Provides a 10% reduction in xp required to level Intelligence, easier to get good notes at school, faster studying in the university
  98. schlrly[1] = 1 & schlrly[2] = 3 & schlrly[3] = -6 & schlrly[4] = 0
  99. !!Trait variable list; only traits that can affect attribute or skill advancement or degradation goes here
  100. $traitattskl[0] = 'nat_dancer'
  101. $traitattskl[1] = 'nat_athlete'
  102. $traitattskl[2] = 'schlrly'
  103. !!This is sets _lvl and _exp based on the value of pcs_"name" the first time so that _lvl and _exp do not need to set on start.
  104. !!Theoretically this can be eventually deleted.
  105. if attsklupdate = 0:
  106. i = 0 & x = 1
  107. :rstloop
  108. expadj = func('_difficulty','getexpadj')
  109. tl = 0
  110. :trtrstloop
  111. tltp = 0
  112. :trtrstinsdlp
  113. !! Note this loop is done with a flag set in the dynamic that is checked outside; this is because testing showed inconsistent results when jumping from inside the dynamic and with the whole loop in the dynamic.
  114. dynamic "
  115. if <<$traitattskl[tl]>> > 0 and <<$traitattskl[tl]>>[tltp + 1] = x and <<$traitattskl[tl]>>[tltp + 2] = i and <<$traitattskl[tl]>>[tltp + 3] ! 0: expadj += <<$traitattskl[tl]>>[tltp + 3]
  116. if <<$traitattskl[tl]>>[tltp + 11] ! 0: insdlpflag = 1
  117. "
  118. if insdlpflag = 1: tltp += 10 & insdlpflag = 0 & jump 'trtrstinsdlp'
  119. tl += 1
  120. if tl < arrsize ('$traitattskl'): jump 'trtrstloop'
  121. killvar 'tl' & killvar 'tltp' & killvar 'insdlpflag'
  122. if x = 1:
  123. $attskltmp = $att_name[i]
  124. else
  125. $attskltmp = $skl_name[i]
  126. end
  127. dynamic "
  128. if pcs_<<$attskltmp>> > 0 and <<$attskltmp>>_lvl = 0:
  129. <<$attskltmp>>_exp = (expadj * (pcs_<<$attskltmp>> - 1) * (pcs_<<$attskltmp>> - 1) / 180) + 1
  130. <<$attskltmp>>_lvl = pcs_<<$attskltmp>>
  131. <<$attskltmp>>_lvlst = <<$attskltmp>>_lvl
  132. end
  133. "
  134. killvar 'expadj' & killvar '$attskltmp'
  135. i += 1
  136. if (x = 1 and i < arrsize ('$att_name')) or (x = 2 and i < arrsize ('$skl_name')): jump 'rstloop'
  137. i = 0 & x += 1
  138. if x < 3: jump 'rstloop'
  139. killvar 'i' & killvar 'x'
  140. attsklupdate = 1
  141. end
  142. !!This is the section that runs when the call is from cikl
  143. if $ARGS[0] = 'daycall':
  144. !! Attribute XP with Skill XP gain
  145. x = 0
  146. :sklxploop
  147. y = 1
  148. :persklloop
  149. dynamic "$attnamtmp = $att_name[<<$skl_name[x]>>[y]]"
  150. dynamic "
  151. if <<$skl_name[x]>>_exp > <<$skl_name[x]>>_mem: <<$attnamtmp>>_exp += (<<$skl_name[x]>>_exp - <<$skl_name[x]>>_mem) / 5
  152. if <<$skl_name[x]>>[y + 1] = -1 or y >= 9: lpstopflg = 1
  153. "
  154. killvar '$attnamtmp'
  155. if lpstopflg = 0: y += 1 & jump 'persklloop'
  156. killvar 'lpstopflg'
  157. x += 1
  158. if x < arrsize ('$skl_name'): jump 'sklxploop'
  159. killvar 'x' & killvar 'y' & killvar '$attnamtmp'
  160. !! Degradation Loop
  161. i = 0 & x = 1
  162. :degloop
  163. degadj = 60
  164. if x = 2: degadj += 30
  165. expadj = func('_difficulty','getexpadj')
  166. tl = 0
  167. :trtdegloop
  168. tltp = 0
  169. :trtdeginsdlp
  170. !! Note this loop is done with a flag set in the dynamic that is checked outside; this is because testing showed inconsistent results when jumping from inside the dynamic and with the whole loop in the dynamic.
  171. dynamic "
  172. if <<$traitattskl[tl]>> > 0 and <<$traitattskl[tl]>>[tltp + 1] = x and <<$traitattskl[tl]>>[tltp + 2] = i and <<$traitattskl[tl]>>[tltp + 3] ! 0: expadj += <<$traitattskl[tl]>>[tltp + 3]
  173. if <<$traitattskl[tl]>> > 0 and <<$traitattskl[tl]>>[tltp + 1] = x and <<$traitattskl[tl]>>[tltp + 2] = i and <<$traitattskl[tl]>>[tltp + 4] ! 0: degadj += <<$traitattskl[tl]>>[tltp + 4]
  174. if <<$traitattskl[tl]>>[tltp + 11] ! 0: insdlpflag = 1
  175. "
  176. if insdlpflag = 1: tltp += 10 & insdlpflag = 0 & jump 'trtdeginsdlp'
  177. tl += 1
  178. if tl < arrsize ('$traitattskl'): jump 'trtdegloop'
  179. killvar 'tl' & killvar 'tltp' & killvar 'insdlpflag'
  180. if x = 1:
  181. $attskltmp = $att_name[i]
  182. else
  183. $attskltmp = $skl_name[i]
  184. end
  185. dynamic "
  186. if <<$attskltmp>>_lvl ! <<$attskltmp>>_lvlst: <<$attskltmp>>_lvl = <<$attskltmp>>_lvlst
  187. if <<$attskltmp>>_lvl < 100:
  188. degtmp = (102 - <<$attskltmp>>_lvl + <<$attskltmp>>_muta)
  189. else
  190. degtmp = 2 + <<$attskltmp>>_muta
  191. end
  192. degtmp = degadj * degtmp / 60
  193. if degtmp < 2: degtmp = 2
  194. if <<$attskltmp>>_exp < <<$attskltmp>>_mem: <<$attskltmp>>_exp = <<$attskltmp>>_mem
  195. if <<$attskltmp>>_exp = <<$attskltmp>>_mem:
  196. <<$attskltmp>>_deg -= 1
  197. else
  198. <<$attskltmp>>_deg = degtmp
  199. end
  200. if <<$attskltmp>>_deg <= 0 and <<$attskltmp>>_lvl > <<$attskltmp>>_flr:
  201. exptmp = <<$attskltmp>>_exp - (expadj * (<<$attskltmp>>_lvl - 1) * (<<$attskltmp>>_lvl - 1) / 180)
  202. if exptmp < 0: exptmp = 0
  203. <<$attskltmp>>_lvl -= 1
  204. <<$attskltmp>>_deg = degtmp
  205. <<$attskltmp>>_exp = (expadj * (<<$attskltmp>>_lvl - 1) * (<<$attskltmp>>_lvl - 1) / 180) + exptmp
  206. !! This will only do anything if the PC builds exp well in excess of what is needed to level
  207. if <<$attskltmp>>_exp > (expadj * (<<$attskltmp>>_lvl) * (<<$attskltmp>>_lvl) / 180): <<$attskltmp>>_exp -= (2 * <<$attskltmp>> - 1) / 10
  208. end
  209. <<$attskltmp>>_lvlst = <<$attskltmp>>_lvl
  210. <<$attskltmp>>_mem = <<$attskltmp>>_exp
  211. "
  212. killvar 'degtmp' & killvar 'exptmp'
  213. killvar 'degadj' & killvar 'expadj' & killvar '$attskltmp'
  214. i += 1
  215. if (x = 1 and i < arrsize ('$att_name')) or (x = 2 and i < arrsize ('$skl_name')): jump 'degloop'
  216. i = 0 & x += 1
  217. if x < 3: jump 'degloop'
  218. killvar 'i' & killvar 'x'
  219. end
  220. !!Advancement Loop
  221. i = 0 & x = 1
  222. :advloop
  223. expadj = func('_difficulty','getexpadj')
  224. tl = 0
  225. :trtadvloop
  226. tltp = 0
  227. :trtadvinsdlp
  228. !!Note this loop is done with a flag set in the dynamic that is checked outside; this is because testing showed inconsistent results when jumping from inside the dynamic and with the whole loop in the dynamic.
  229. dynamic "
  230. if <<$traitattskl[tl]>> > 0 and <<$traitattskl[tl]>>[tltp + 1] = x and <<$traitattskl[tl]>>[tltp + 2] = i and <<$traitattskl[tl]>>[tltp + 3] ! 0: expadj += <<$traitattskl[tl]>>[tltp + 3]
  231. if <<$traitattskl[tl]>>[tltp + 11] ! 0: insdlpflag = 1
  232. "
  233. if insdlpflag = 1: tltp += 10 & insdlpflag = 0 & jump 'trtadvinsdlp'
  234. tl += 1
  235. if tl < arrsize ('$traitattskl'): jump 'trtadvloop'
  236. killvar 'tl' & killvar 'tltp' & killvar 'insdlpflag'
  237. if x = 1:
  238. $attskltmp = $att_name[i]
  239. else
  240. $attskltmp = $skl_name[i]
  241. end
  242. dynamic "
  243. if <<$attskltmp>>_lvl ! <<$attskltmp>>_lvlst: <<$attskltmp>>_lvl = <<$attskltmp>>_lvlst
  244. if <<$attskltmp>>_exp > (expadj * <<$attskltmp>>_lvl * <<$attskltmp>>_lvl / 180): <<$attskltmp>>_lvl += 1
  245. <<$attskltmp>>_lvlst = <<$attskltmp>>_lvl
  246. <<$attskltmp>>_xpnxt = (expadj * <<$attskltmp>>_lvl * <<$attskltmp>>_lvl / 180) + 1
  247. if <<$attskltmp>>_lvl / 5 > <<$attskltmp>>_flr: <<$attskltmp>>_flr = <<$attskltmp>>_lvl / 5
  248. if <<$attskltmp>>_lvl > (100 + (<<$attskltmp>>_muta * 50)): <<$attskltmp>>_lvl = (100 + (<<$attskltmp>>_muta * 50))
  249. "
  250. !! removed by rachels 17/10/23 to correct the "marksman" bug - belongs into preceding dynamic code
  251. !! if <<$attskltmp>>_exp > (expadj * (<<$attskltmp>>_lvl + 1) * (<<$attskltmp>>_lvl + 1) / 180) - 1:
  252. !! <<$attskltmp>>_exp = (expadj * (<<$attskltmp>>_lvl + 1) * (<<$attskltmp>>_lvl + 1) / 180) - 1
  253. !! <<$attskltmp>>_mem = <<$attskltmp>>_exp
  254. !! end
  255. killvar 'expadj' & killvar '$attskltmp'
  256. i += 1
  257. if (x = 1 and i < arrsize ('$att_name')) or (x = 2 and i < arrsize ('$skl_name')): jump 'advloop'
  258. i = 0 & x += 1
  259. if x < 3: jump 'advloop'
  260. killvar 'i' & killvar 'x'
  261. gs 'stat_sklattrib_lvlset'
  262. --- stat_sklattrib ---------------------------------