shortgs.qsrc 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. # shortgs
  2. !! make an autosave unless it is disabled
  3. if $ARGS[0] = 'autosave':
  4. if disable_autosave = 0:
  5. if mid($start_type, 1, 4) = 'city':
  6. savegame 'autosave_city_<<$week[week]>>.sav'
  7. elseif mid($start_type, 1, 3) = 'uni':
  8. savegame 'autosave_uni_<<$week[week]>>.sav'
  9. else
  10. savegame 'autosave_sg_<<$week[week]>>.sav'
  11. end
  12. end
  13. end
  14. !! following function counts the number of guys which PC slept with.
  15. !! use func('shortgs','guy') or func('shortgs','guy',X) for subset (X can be 'A','B','C','AB','AC','BC')
  16. if $ARGS[0] = 'guy':
  17. r_sht=0
  18. if $ARGS[1] = '': $temptask = 'ABC' else $temptask = $ARGS[1]
  19. :loop_shtty
  20. $temptaskchar = mid($temptask,1,1)
  21. $temptask = mid($temptask,2,len($temptask)-1)
  22. s_sht=0
  23. :loop_shya
  24. if s_sht<=dyneval("result = <<$temptaskchar>>arraynumber"):
  25. s_sht += 1
  26. if npc_sex['<<$temptaskchar>><<s_sht>>'] > 0: r_sht = r_sht + iif(npc_gender['<<$temptaskchar>><<s_sht>>'] = 0,1,0)
  27. jump 'loop_shya'
  28. end
  29. if len($temptask) > 0:jump 'loop_shtty'
  30. result = r_sht
  31. killvar 'r_sht'
  32. killvar '$temptask'
  33. killvar '$temptaskchar'
  34. killvar 's_sht'
  35. end &! --- guy ---
  36. !! following function counts the number of girls which PC slept with.
  37. !! use func('shortgs','girl') or func('shortgs','girl',X) for subset (X can be 'A','B','C','AB','AC','BC')
  38. if $ARGS[0] = 'girl':
  39. r_sht=0
  40. if $ARGS[1] = '': $temptask = 'ABC' else $temptask = $ARGS[1]
  41. :loop_shttl
  42. $temptaskchar = mid($temptask,1,1)
  43. $temptask = mid($temptask,2,len($temptask)-1)
  44. s_sht=0
  45. :loop_shl
  46. if s_sht<=dyneval("result = <<$temptaskchar>>arraynumber"):
  47. s_sht += 1
  48. if npc_sex['<<$temptaskchar>><<s_sht>>'] > 0: r_sht = r_sht + iif(npc_gender['<<$temptaskchar>><<s_sht>>'] = 1,1,0)
  49. jump 'loop_shl'
  50. end
  51. if len($temptask) > 0: jump 'loop_shttl'
  52. result = r_sht
  53. killvar 'r_sht'
  54. killvar '$temptask'
  55. killvar '$temptaskchar'
  56. killvar 's_sht'
  57. end &! --- girl ---
  58. !! following procedure should be used when PC gets naked, but it should be paired with the reverse procedure
  59. !! use gs 'shortgs','undress'
  60. if $ARGS[0] = 'undress':
  61. gs 'underwear', 'remove'
  62. gs 'clothing','strip'
  63. end &! --- undress ---
  64. !! reverse procedure, it can be modified for lose or stolen panties later.
  65. !! use gs 'shortgs','dress'
  66. if $ARGS[0] = 'dress':
  67. gs 'clothing','wear_last_worn'
  68. gs 'underwear', 'wear'
  69. end &! --- dress ---
  70. !! procedure, which prevents PC to leave a room naked.
  71. !! use gs 'shortgs','checkdress',' <<$loc>>,<<$loc_arg>> ' or equivalent
  72. if $ARGS[0] = 'checkdress':
  73. if $clothingworntype = 'nude':
  74. msg '<b><font color="red">You need to get dressed before going out.</font></b>'
  75. dynamic 'gt <<$ARGS[1]>>'
  76. end
  77. end &! --- checkdress ---
  78. !! this is an integer sqrt function
  79. !! call func('shortgs','sqrt', n)
  80. if $ARGS[0] = 'sqrt':
  81. sqrtnum = ARGS[1]
  82. if sqrtnum = 0: result = 0 & exit
  83. sqrtn = sqrtnum/2 + 1
  84. sqrtn1 = (sqrtn + sqrtnum / sqrtn) / 2
  85. :sqrtloop
  86. if sqrtn1 < sqrtn:
  87. sqrtn = sqrtn1
  88. sqrtn1 = (sqrtn + sqrtnum / sqrtn) / 2
  89. jump 'sqrtloop'
  90. end
  91. result = sqrtn
  92. end
  93. !! this function calculates modul of given arguments as it was coordinates in cartezian systeme
  94. !! use func('shortgs','modul',n1,n2,..n8)
  95. if $ARGS[0] = 'modul':
  96. modul_sum = ARGS[1]*ARGS[1]+ARGS[2]*ARGS[2]+ARGS[3]*ARGS[3]+ARGS[4]*ARGS[4]+ARGS[5]*ARGS[5]+ARGS[6]*ARGS[6]+ARGS[7]*ARGS[7]+ARGS[8]*ARGS[8]
  97. result = func('shortgs','sqrt',modul_sum)
  98. killvar 'modul_sum'
  99. end
  100. !! day of week 1 - Monday .. 7 - Sunday
  101. if $ARGS[0] = 'dow':
  102. if ARGS[1]=0:
  103. D_dow = day
  104. M_dow = month
  105. Y_dow = year
  106. else
  107. D_dow = ARGS[3]
  108. M_dow = ARGS[2]
  109. Y_dow = ARGS[1]
  110. end
  111. dow_a = (14 - M_dow) / 12
  112. dow_Y = Y_dow - dow_a
  113. dow_M = M_dow + 12*dow_a - 2
  114. dummy = (D_dow + dow_y + dow_y/4 - dow_y/100 + dow_y/400 + (31*dow_m)/12) mod 7
  115. if dummy = 0: dummy = 7
  116. result = dummy
  117. end
  118. !! day of year
  119. !! use xdoy = func('shortgs','doy',year,month,day)
  120. !! https://astronomy.stackexchange.com/questions/2407/calculate-day-of-the-year-for-a-given-date
  121. if $ARGS[0] = 'doy':
  122. doy_N1 = 275 * ARGS[2] / 9
  123. doy_N2 = (ARGS[2] + 9) / 12
  124. doy_N3 = 1 + (ARGS[1] - 4 * (ARGS[1] / 4) + 2) / 3
  125. result = doy_N1 - (doy_N2 * doy_N3) + ARGS[3] - 30
  126. end
  127. if $ARGS[0] = 'mk1':
  128. gs 'saveposition'
  129. *clr & cla
  130. $mk_subst['0'] = 'M' & $mk_subst['1'] = 'F' & $mk_subst['2'] = 'O' & $mk_subst['3'] = 'L' & $mk_subst['4'] = 'R' & $mk_subst['5'] = 'P'
  131. '<center><font face="courier" size=1>'
  132. '<table border = 1>'
  133. '<tr><th>Mon</th><th>Tue</th><th>Wen</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th><th>Mon</th><th>Tue</th><th>Wen</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th>
  134. <th>Mon</th><th>Tue</th><th>Wen</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th><th>Mon</th><th>Tue</th><th>Wen</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th></tr>'
  135. i = ArrSize('$MenCal')
  136. empty0 = week + 29 - i - 1
  137. empty1 = min(28,empty0)
  138. full1 = max(0,28 - empty0)
  139. empty2 = max(0,empty0-28)
  140. full2 = i - full1
  141. empty3 = 28 - empty2 - full2
  142. count=0
  143. $tabmc = '<tr>'
  144. :tabmcl1
  145. if empty1 > 0: empty1 -=1 & $tabmc +='<td>&nbsp</td>' & jump 'tabmcl1'
  146. :tabmcl2
  147. if full1 > 0:
  148. full1 -=1
  149. if $MenCal[count]='0': $tabmc +='<td bgcolor="red"><<$mk_subst[$MenCal[count]]>></td>' else $tabmc +='<td><<$mk_subst[$MenCal[count]]>></td>'
  150. count +=1
  151. jump 'tabmcl1'
  152. end
  153. $tabmc += '</tr><tr>'
  154. :tabmcl3
  155. if empty2 > 0: empty2 -=1 & $tabmc +='<td>&nbsp</td>' & jump 'tabmcl3'
  156. :tabmcl4
  157. if full2 > 0:
  158. full2 -=1
  159. if $MenCal[count]='0': $tabmc +='<td bgcolor="red"><<$mk_subst[$MenCal[count]]>></td>' else $tabmc +='<td><<$mk_subst[$MenCal[count]]>></td>'
  160. count +=1
  161. jump 'tabmcl4'
  162. end
  163. :tabmcl5
  164. if empty3 > 0: empty3 -=1 & $tabmc +='<td></td>' & jump 'tabmcl5'
  165. $tabmc += '</tr><table></font></center>'
  166. $tabmc
  167. act 'Back': gt 'restoreposition'
  168. end
  169. !! use gs 'shortgs','mk'
  170. if $ARGS[0] = 'mk':
  171. gs 'saveposition'
  172. *clr & cla
  173. copyarr '$MenCalCopy','$MenCal'
  174. length_of_month_field = arrsize('$MenCalCopy')
  175. if daystart - firstmens > 40:
  176. mensnotfound = 1
  177. i = 0
  178. :tabmcfm
  179. if $MenCalCopy[length_of_month_field-i] = '0' and $MenCalCopy[length_of_month_field-i-1] = '3': mensnotfound = 0
  180. i += 1
  181. if i < length_of_month_field and mensnotfound = 1: jump 'tabmcfm'
  182. if mensnotfound = 0:
  183. firstmens = daystart - i + 1
  184. end
  185. end
  186. i=1
  187. :tabmcc1
  188. if daystart - firstmens < 40:
  189. if (daystart - firstmens + i) = 28:
  190. $MenCalCopy[] = ' bgcolor="#df2020"'
  191. elseif (daystart - firstmens + i) = 29:
  192. $MenCalCopy[] = ' bgcolor="#df3030"'
  193. elseif (daystart - firstmens + i) = 30:
  194. $MenCalCopy[] = ' bgcolor="#df4040"'
  195. elseif (daystart - firstmens + i) = 12:
  196. $MenCalCopy[] = ' bgcolor="#d8ff00"'
  197. elseif (daystart - firstmens + i) = 13:
  198. $MenCalCopy[] = ' bgcolor="#d0ff00"'
  199. elseif (daystart - firstmens + i) = 14:
  200. $MenCalCopy[] = ' bgcolor="#c8ff00"'
  201. elseif (daystart - firstmens + i) = 15:
  202. $MenCalCopy[] = ' bgcolor="#c0ff00"'
  203. elseif (daystart - firstmens + i) = 16:
  204. $MenCalCopy[] = ' bgcolor="#d0ff00"'
  205. elseif (daystart - firstmens + i) = 12+28:
  206. $MenCalCopy[] = ' bgcolor="#d8ff00"'
  207. elseif (daystart - firstmens + i) = 13+28:
  208. $MenCalCopy[] = ' bgcolor="#d0ff00"'
  209. elseif (daystart - firstmens + i) = 14+28:
  210. $MenCalCopy[] = ' bgcolor="#c8ff00"'
  211. elseif (daystart - firstmens + i) = 15+28:
  212. $MenCalCopy[] = ' bgcolor="#c0ff00"'
  213. elseif (daystart - firstmens + i) = 16+28:
  214. $MenCalCopy[] = ' bgcolor="#d0ff00"'
  215. else
  216. $MenCalCopy[] = ''
  217. end
  218. i += 1
  219. if i < 40: jump 'tabmcc1'
  220. end
  221. i = length_of_month_field
  222. :tabmcc2
  223. if i > 0:
  224. if $MenCalCopy[i-1] = '2' and i = 1 : $MenCalCopy[i-1] = ' bgcolor="#c0ff00"'
  225. if $MenCalCopy[i-1] = '2' and $MenCalCopy[i-2] = '2': $MenCalCopy[i-1] = ' bgcolor="#c0ff00"'
  226. if $MenCalCopy[i-1] = '2' and $MenCalCopy[i-2] = '1': $MenCalCopy[i-1] = ' bgcolor="#80ff00"' & $MenCalCopy[i-2] = ' bgcolor="#90ff00"' & $MenCalCopy[i-3] = ' bgcolor="#a0ff00"' & $MenCalCopy[i-4] = ' bgcolor="#b0ff00"' & $MenCalCopy[i-5] = ' bgcolor="#c0ff00"'
  227. if $MenCalCopy[i-1] = '1' and (daystart - firstmens - length_of_month_field + i) < 12: $MenCalCopy[i-1] =''
  228. if $MenCalCopy[i-1] = '1' and (daystart - firstmens - length_of_month_field + i) = 12: $MenCalCopy[i-1] =' bgcolor="#b0ff00"'
  229. if $MenCalCopy[i-1] = '1' and (daystart - firstmens - length_of_month_field + i) = 13: $MenCalCopy[i-1] =' bgcolor="#a0ff00"'
  230. if $MenCalCopy[i-1] = '1' and (daystart - firstmens - length_of_month_field + i) = 14: $MenCalCopy[i-1] =' bgcolor="#90ff00"'
  231. if $MenCalCopy[i-1] = '1' and (daystart - firstmens - length_of_month_field + i) = 15: $MenCalCopy[i-1] =' bgcolor="#80ff00"'
  232. if $MenCalCopy[i-1] = '1' and (daystart - firstmens - length_of_month_field + i) > 15: $MenCalCopy[i-1] =''
  233. if $MenCalCopy[i-1] = '0': $MenCalCopy[i-1] =' bgcolor="#df2020"'
  234. if $MenCalCopy[i-1] = '3': $MenCalCopy[i-1] =''
  235. if $MenCalCopy[i-1] = '4': $MenCalCopy[i-1] =''
  236. if $MenCalCopy[i-1] = '5': $MenCalCopy[i-1] =''
  237. if $MenCalCopy[i-1] = '6': $MenCalCopy[i-1] =''
  238. i -= 1
  239. jump 'tabmcc2'
  240. end
  241. cur_day_doy = func('shortgs','doy',year,month,day)
  242. if month = 1:
  243. dif_days = cur_day_doy + 30
  244. prev_month = 12
  245. prev_month_length = 31
  246. else
  247. prev_month = month - 1
  248. dif_days = cur_day_doy - func('shortgs','doy',year,prev_month,1)
  249. prev_month_length = func('shortgs','doy',year,month,1) - func('shortgs','doy',year,prev_month,1)
  250. end
  251. first_month_first_day_week = week - (dif_days mod 7)
  252. first_month_first_day_index = length_of_month_field -1 - dif_days
  253. r = first_month_first_day_index
  254. if first_month_first_day_week < 1: first_month_first_day_week += 7
  255. i = 42
  256. :tabmc21
  257. $mk1_mdays[] = '&nbsp' & i -= 1 & if i > 0: jump 'tabmc21'
  258. i = 0
  259. :tabmc21a
  260. $mk1_mdays[i+first_month_first_day_week-1] = $str(i+1)
  261. i += 1
  262. if i < prev_month_length: jump 'tabmc21a'
  263. $prev_month_name = $mid($monthName[prev_month],1,1) + '<br>' + $mid($monthName[prev_month],2,1) + '<br>' + $mid($monthName[prev_month],3,1)
  264. k = 0
  265. $tabmc ='<center><font face="courier" size=5>'
  266. $tabmc +='<table border = 1 cellspacing="0" cellpadding="5">'
  267. $tabmc +='<tr><th>Month</th><th>Mon</th><th>Tue</th><th>Wen</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th></tr>'
  268. month_weeks = (first_month_first_day_week + prev_month_length + 5)/7 - 1
  269. i = month_weeks
  270. :tabmc22
  271. $tabmc +='<tr>'
  272. j = 7
  273. if i = month_weeks:$tabmc +='<td rowspan="<<month_weeks+1>>" align = "center"><<$prev_month_name>></td>'
  274. :tabmc23
  275. if j > 0:
  276. j -=1
  277. if $mk1_mdays[k]='&nbsp':
  278. $tabmc +='<td><<$mk1_mdays[k]>></td>'
  279. else
  280. $tabmc +='<td<<$MenCalCopy[r]>> ><<$mk1_mdays[k]>></td>'
  281. r +=1
  282. end
  283. k +=1
  284. jump 'tabmc23' & !<<$MenCalCopy[r]>>
  285. end
  286. if i > 0: i -=1 & $tabmc +='</tr>' & jump 'tabmc22'
  287. killvar '$mk1_mdays'
  288. killvar '$mk1_mdays_color'
  289. !! current month
  290. if month = 12:
  291. dif_days = day - 1
  292. cur_month = month
  293. cur_month_length = 31
  294. else
  295. dif_days = day - 1
  296. cur_month_length = func('shortgs','doy',year,month+1,1) - func('shortgs','doy',year,month,1)
  297. end
  298. second_month_first_day_week = week - (dif_days mod 7)
  299. second_month_first_day_index = length_of_month_field -1 - dif_days
  300. if second_month_first_day_week < 1: second_month_first_day_week += 7
  301. i = 42
  302. :tabmc31
  303. $mk1_mdays[] = '&nbsp' & i -= 1 & if i > 0: jump 'tabmc31'
  304. i = 0
  305. :tabmc31a
  306. $mk1_mdays[i+second_month_first_day_week-1] = $str(i+1)
  307. i += 1
  308. if i < cur_month_length: jump 'tabmc31a'
  309. $cur_month_name = $mid($monthName[month],1,1) + '<br>' + $mid($monthName[month],2,1) + '<br>' + $mid($monthName[month],3,1)
  310. k = 0
  311. month_weeks = (second_month_first_day_week + cur_month_length + 5)/7 - 1
  312. i = month_weeks
  313. :tabmc32
  314. $tabmc +='<tr>'
  315. j = 7
  316. if i = month_weeks:$tabmc +='<td rowspan="<<month_weeks+1>>" align = "center"><<$cur_month_name>></td>'
  317. :tabmc33
  318. if j > 0:
  319. j -=1
  320. if $mk1_mdays[k]='&nbsp':
  321. $tabmc +='<td><<$mk1_mdays[k]>></td>'
  322. else
  323. if day + second_month_first_day_week - 2 = k: $tabmc +='<td<<$MenCalCopy[r]>> ><u><b><<$mk1_mdays[k]>></b></u></td>' else $tabmc +='<td<<$MenCalCopy[r]>> ><<$mk1_mdays[k]>></td>'
  324. r +=1
  325. end
  326. k +=1
  327. jump 'tabmc33'
  328. end
  329. if i > 0: i -=1 & $tabmc +='</tr>' & jump 'tabmc32'
  330. killvar '$mk1_mdays'
  331. killvar '$mk1_mdays_color'
  332. !! next month
  333. if month = 12:
  334. dif_days = 31 - day + 1
  335. next_month = 1
  336. next_month_length = 31
  337. elseif month = 11:
  338. dif_days = 30 - day + 1
  339. next_month = 12
  340. next_month_length = 31
  341. else
  342. next_month = month + 1
  343. dif_days = cur_month_length - day + 1
  344. next_month_length = func('shortgs','doy',year,month+2,1) - func('shortgs','doy',year,month+1,1)
  345. end
  346. next_month_first_day_week = week + (dif_days mod 7)
  347. next_month_first_day_index = length_of_month_field -1 - dif_days
  348. if next_month_first_day_week < 1: next_month_first_day_week += 7
  349. i = 35
  350. :tabmc41
  351. $mk1_mdays[] = '&nbsp' & i -= 1 & if i > 0: jump 'tabmc41'
  352. i = 0
  353. :tabmc41a
  354. $mk1_mdays[i+next_month_first_day_week-1] = $str(i+1)
  355. !! if next_month_first_day_index + i >= 0: $mk1_mdays[i+next_month_first_day_week-1] += $mk_subst[$MenCal[second_month_first_day_index + i]]
  356. i += 1
  357. if i < next_month_length: jump 'tabmc41a'
  358. $next_month_name = $mid($monthName[next_month],1,1) + '<br>' + $mid($monthName[next_month],2,1) + '<br>' + $mid($monthName[next_month],3,1)
  359. k = 0
  360. month_weeks = (next_month_first_day_week + next_month_length + 5)/7 - 1
  361. i = month_weeks
  362. :tabmc42
  363. $tabmc +='<tr>'
  364. j = 7
  365. if i = month_weeks:$tabmc +='<td rowspan="<<month_weeks+1>>" align = "center"><<$next_month_name>></td>'
  366. :tabmc43
  367. if j > 0:
  368. j -=1
  369. if $mk1_mdays[k]='&nbsp':
  370. $tabmc +='<td><<$mk1_mdays[k]>></td>'
  371. else
  372. $tabmc +='<td<<$MenCalCopy[r]>> ><<$mk1_mdays[k]>></td>'
  373. r +=1
  374. end
  375. k +=1
  376. jump 'tabmc43'
  377. end
  378. if i > 0: i -=1 & $tabmc +='</tr>' & jump 'tabmc42'
  379. killvar '$mk1_mdays'
  380. $tabmc += '</tr><table></font></center>'
  381. $tabmc
  382. act 'Back': gt 'restoreposition'
  383. end
  384. !! gs 'shortgs','fonts'
  385. if $ARGS[0] = 'fonts':
  386. if $ARGS[1] = 'refresh':
  387. jump 'fontsloop'
  388. else
  389. $dynamicreturn = $ARGS[1]
  390. $OpenPhraseSave = $ARGS[2]
  391. $ClosePhraseSave = $ARGS[3]
  392. end
  393. gs 'saveposition'
  394. $fontlist[] = 'Lucida' & $fontlist[] = 'Ariel' & $fontlist[] = 'Tahoma' & $fontlist[] = 'Verdana' & $fontlist[] = 'Courier New' & $fontlist[] = 'Courier' & $fontlist[] = 'Georgia' & $fontlist[] = 'Times New Roman' & $fontlist[] = 'Garamond' & $fontlist[] = 'Bookman' & $fontlist[] = 'Times New Roman' & $fontlist[] = 'Times' & $fontlist[] = 'Comic Sans MS' & $fontlist[] = 'Trebuchet MS' & $fontlist[] = 'Impact' & $fontlist[] = 'BankGothic'
  395. $fontcolor[] = 'aqua' & $fontcolor[] = 'black' & $fontcolor[] = 'blue' & $fontcolor[] = 'magenta' & $fontcolor[] = 'green' & $fontcolor[] = 'gray' & $fontcolor[] = 'lime' & $fontcolor[] = 'maroon' & $fontcolor[] = 'navy' & $fontcolor[] = 'olive' & $fontcolor[] = 'purple' & $fontcolor[] = 'red' & $fontcolor[] = 'silver' & $fontcolor[] = 'teal' & $fontcolor[] = 'white' & $fontcolor[] = 'yellow'
  396. i = 15
  397. :fontsloop0
  398. if $CurFont = $fontlist[i]: curfont = i
  399. if $CurColor = $fontcolor[i]: curcolor = i
  400. i -= 1
  401. if i > 0: jump 'fontsloop0'
  402. jump 'fontsloop1'
  403. :fontsloop
  404. $OpenPhrase = '<font size="<<CurFontSize>>" color="<<$CurColor>>" face="<<$CurFont>>" >'+$CurBold+$CurItalic
  405. $ClosePhrase = $CurItalicBack+$CurBoldBack+'</font>'
  406. :fontsloop1
  407. *clr & cla
  408. $OpenPhrase+'Current font is <<$CurFont>> Size <<CurFontSize>>, the color is <<$CurColor>>, the Bold is <<iif($CurBold = ''<b>'',''On'',''Off'')>> and Italic is <<iif($CurItalic = ''<i>'',''On'',''Off'')>>'+$ClosePhrase
  409. '<a href="exec: curfont = (curfont + 1) mod 16 & $CurFont = $fontlist[curfont] & gs ''shortgs'',''fonts'',''refresh'' ">Change the Font</a>'
  410. '<a href="exec: curcolor = (curcolor + 1) mod 16 & $CurColor = $fontcolor[curcolor] & gs ''shortgs'',''fonts'',''refresh'' ">Change the Color</a>'
  411. '<a href="exec:$CurBold = iif($CurBold ! ''<b>'',''<b>'','' '') & $CurBoldBack = iif($CurBold = ''<b>'',''</b>'','' '') & gs ''shortgs'',''fonts'',''refresh'' ">Change the BoldState</a>'
  412. '<a href="exec:$CurItalic = iif($CurItalic ! ''<i>'',''<i>'','' '') & $CurItalicBack = iif($CurItalic = ''<i>'',''</i>'','' '') & gs ''shortgs'',''fonts'',''refresh'' ">Change the ItalicState</a>'
  413. '<a href="exec:CurfontSize -= 1 & gs ''shortgs'',''fonts'',''refresh'' ">Decrease the Font</a>&nbsp&nbsp&nbsp<a href="exec:CurfontSize += 1 & gs ''shortgs'',''fonts'',''refresh'' ">Increase the font</a>'
  414. act 'Back':
  415. killvar '$fontlist'
  416. killvar '$fontcolor'
  417. dynamic '<<$OpenPhraseSave>> = $OpenPhrase'
  418. dynamic '<<$ClosePhraseSave>> = $ClosePhrase'
  419. if $dynamicreturn ! '': dynamic 'dynamic <<$dynamicreturn>>'
  420. gt 'restoreposition'
  421. end
  422. end
  423. !! use gs 'shortgs','ncp_update'
  424. if $ARGS[0] = 'ncp_update':
  425. copyarr 'copy_npc_QW','npc_QW'
  426. copyarr 'copy_npc_rel','npc_rel'
  427. copyarr 'copy_npc_love','npc_love'
  428. copyarr '$copy_npc_usedname','$npc_usedname'
  429. gs 'npcstatic1'
  430. gs 'npcstatic2'
  431. gs 'npcstatic3'
  432. gs 'npcstatic4'
  433. gs 'npcstatic5'
  434. gs 'npcstatic6'
  435. i = arrsize('copy_npc_QW')
  436. j = 1
  437. :loopnpcupdate
  438. $boy = 'A<<j>>'
  439. npc_QW[$boy] = copy_npc_QW[$boy]
  440. npc_rel[$boy] = copy_npc_rel[$boy]
  441. npc_love[$boy] = copy_npc_love[$boy]
  442. $npc_usedname[$boy] = $copy_npc_usedname[$boy]
  443. j += 1
  444. if j <= i: jump 'loopnpcupdate'
  445. killvar 'copy_npc_QW'
  446. killvar 'copy_npc_rel'
  447. killvar 'copy_npc_love'
  448. killvar '$copy_npc_usedname'
  449. end
  450. !! this function returns the numeric index of the array element which is indexed by string value.
  451. !! call func('shortgs', 'get_me_index', 'name of array','string index')
  452. !! the array can be both numeric or string: Be aware, for the search is used the value 'SearchTag' for string arrays and -2147483648 for numeric arrays.
  453. !! if the array consists such value, the fuction can mess the array content and return wrong value
  454. !! changed the value for detecting numeric element from -999 to -2147483648 (November 2020)
  455. if $ARGS[0] = 'get_me_index':
  456. $test = '<<$ARGS[1]>>[''<<$ARGS[2]>>'']'
  457. testas0 = arrsize('<<$ARGS[1]>>')
  458. if $mid($test,1,1)='$':
  459. $temp=dyneval('$result=<<$test>>')
  460. dynamic '<<$test>> = ''SearchTag'' '
  461. testas1 = arrsize('<<$ARGS[1]>>')
  462. if testas0 = testas1:
  463. res = dyneval('result = arrpos(''<<$ARGS[1]>>'',''SearchTag'')')
  464. dynamic '<<$test>> = $temp'
  465. else
  466. res = -1
  467. killvar '<<$ARGS[1]>>',testas0
  468. end
  469. else
  470. temp=dyneval('result=<<$test>>')
  471. dynamic '<<$test>> = -2147483648'
  472. testas1 = arrsize('<<$ARGS[1]>>')
  473. if testas0 = testas1:
  474. res = dyneval('result = arrpos(''<<$ARGS[1]>>'',-2147483648)')
  475. dynamic '<<$test>> = <<temp>>'
  476. else
  477. res = -1
  478. killvar '<<$ARGS[1]>>',testas0
  479. end
  480. end
  481. result = res
  482. end
  483. !! call gs 'shortgs', 'remove_array_element', 'name of array','string index'
  484. if $ARGS[0] = 'remove_array_element':
  485. killvar '<<$ARGS[1]>>',func('shortgs', 'get_me_index', $ARGS[1],$ARGS[2])
  486. end
  487. if $ARGS[0] = 'testsize':
  488. '$npc_dna = ' + arrsize('$npc_dna')
  489. '$npc_firstname = ' + arrsize('$npc_firstname')
  490. '$npc_lastname = ' + arrsize('$npc_lastname')
  491. '$npc_nickname = ' + arrsize('$npc_nickname')
  492. '$npc_notes = ' + arrsize('$npc_notes')
  493. '$npc_occupation = ' + arrsize('$npc_occupation')
  494. '$npc_perstype = ' + arrsize('$npc_perstype')
  495. '$npc_pic = ' + arrsize('$npc_pic')
  496. '$npc_thdick = ' + arrsize('$npc_thdick')
  497. '$npc_usedname = ' + arrsize('$npc_usedname')
  498. 'npc_apprnc = ' + arrsize('npc_apprnc')
  499. 'npc_bust = ' + arrsize('npc_bust')
  500. 'npc_outfit = ' + arrsize('npc_outfit')
  501. 'npc_style = ' + arrsize('npc_style')
  502. 'npc_dick = ' + arrsize('npc_dick')
  503. 'npc_dob = ' + arrsize('npc_dob')
  504. 'npc_drunk = ' + arrsize('npc_drunk')
  505. 'npc_gender = ' + arrsize('npc_gender')
  506. 'npc_haircol = ' + arrsize('npc_haircol')
  507. 'npc_height = ' + arrsize('npc_height')
  508. 'npc_horny = ' + arrsize('npc_horny')
  509. 'npc_intel = ' + arrsize('npc_intel')
  510. 'npc_love = ' + arrsize('npc_love')
  511. 'npc_QW = ' + arrsize('npc_QW')
  512. 'npc_rel = ' + arrsize('npc_rel')
  513. 'npc_sex = ' + arrsize('npc_sex')
  514. 'npc_sexskill = ' + arrsize('npc_sexskill')
  515. 'npc_spermpot = ' + arrsize('npc_spermpot')
  516. 'npc_herpes = ' + arrsize('npc_herpes')
  517. 'npc_syth = ' + arrsize('npc_syth')
  518. 'npc_gon = ' + arrsize('npc_gon')
  519. 'npc_thrush = ' + arrsize('npc_thrush')
  520. 'npc_apt_type = ' + arrsize('npc_apt_type')
  521. 'npc_apt_number = ' + arrsize('npc_apt_number')
  522. '$npc_apt_bedroom = ' + arrsize('$npc_apt_bedroom')
  523. '$npc_apt_kitchen = ' + arrsize('$npc_apt_kitchen')
  524. '$npc_apt_livingroom = ' + arrsize('$npc_apt_livingroom')
  525. '$npc_apt_bathroom = ' + arrsize('$npc_apt_bathroom')
  526. 'npc_perv = ' + arrsize('npc_perv')
  527. 'npc_finance = ' + arrsize('npc_finance')
  528. 'npc_humor = ' + arrsize('npc_humor')
  529. 'npc_fav_pos = ' + arrsize('npc_fav_pos')
  530. 'npc_tit_pref = ' + arrsize('npc_tit_pref')
  531. 'npc_addit = ' + arrsize('npc_addit')
  532. 'npc_doors = ' + arrsize('npc_doors')
  533. 'npc_goal = ' + arrsize('npc_goal')
  534. 'npc_fidelity = ' + arrsize('npc_fidelity')
  535. 'npc_lover_days = ' + arrsize('npc_lover_days')
  536. 'npc_lover_keys = ' + arrsize('npc_lover_keys')
  537. '$npc_index = ' + arrsize('$npc_index')
  538. end
  539. if $ARGS[0] = 'npctest':
  540. ' --- init --- '
  541. gs 'shortgs', 'testsize'
  542. gs 'npcgeneratec', 0, 'stranger', rand(18,45),1
  543. $npc_notes[$npclastgenerated]
  544. $npclastgenerated
  545. ' --- gen npc C --- '
  546. gs 'shortgs', 'testsize'
  547. gs 'npcpreservec', $npclastgenerated
  548. $npc_notes[$npclastsaved]
  549. $npclastsaved
  550. ' --- sav npc C to npc B --- '
  551. gs 'shortgs', 'testsize'
  552. gs 'npccleanc',$npclastsaved
  553. ' --- delete npc B --- '
  554. gs 'shortgs', 'testsize'
  555. end
  556. if $ARGS[0] = 'replace header':
  557. wait(ARGS[1])
  558. RH_Count = ARGS[2]
  559. $RH_temp = $MAINTXT
  560. :RH_label
  561. RH_temp_lenght = LEN($RH_temp)
  562. RH_temp_LFpos = STRPOS($RH_temp,'\n')
  563. $RH_temp = $MID($RH_temp, RH_temp_LFpos+1, RH_temp_lenght - RH_temp_LFpos)
  564. RH_Count -=1
  565. if RH_Count > 0: jump 'RH_label'
  566. *clr
  567. $ARGS[3] & $ARGS[4] & $ARGS[5] & $ARGS[6] & $ARGS[7]
  568. $RH_temp
  569. killvar '$RH_temp'
  570. killvar 'RH_Count'
  571. killvar 'RH_temp_lenght'
  572. killvar 'RH_temp_LFpos'
  573. end
  574. if $ARGS[0]='img msg':
  575. $shortgstemp = '<center><img height=280 src="<<$ARGS[1]>>"></center>'
  576. msg $shortgstemp
  577. killvar '$shortgstemp'
  578. end
  579. !! Used for dividing with accurate rounding up/down
  580. if $ARGS[0] = 'round_divide':
  581. !! ARGS[1] = value you want divided
  582. !! ARGS[2] = divider
  583. !! func('shortgs','round_divide', number, divider)
  584. !! func('shortgs','round_divide', 12345, 7)
  585. if ARGS[2] ! 0:
  586. temp_number = ARGS[1]/ARGS[2]
  587. if (ARGS[2] mod 2 ! 0 and ARGS[1] mod ARGS[2] > ARGS[2]/2) or (ARGS[2] mod 2 = 0 and ARGS[1] mod ARGS[2] >= ARGS[2]/2): temp_number += 1
  588. result = temp_number
  589. killvar 'temp_number'
  590. else
  591. msg '<b>Error: No dividing by 0! You trying to make the universe disappear?</b>'
  592. end
  593. end
  594. !! Used for rounding numbers to the nearest multiple of ARGS[2]
  595. if $ARGS[0] = 'round_tool':
  596. !! ARGS[1] = value you want rounded
  597. !! ARGS[2] = nearest multiple to round to
  598. !! func('shortgs','round_tool', number, multiple)
  599. !! func('shortgs','round_tool', 12345, 10)
  600. if ARGS[2] ! 0:
  601. temp_multiple = ARGS[2]
  602. result = func('shortgs','round_divide', ARGS[1], ARGS[2]) * temp_multiple
  603. killvar 'temp_multiple'
  604. else
  605. msg '<b>Error: Can''t round to 0!</b>'
  606. end
  607. end
  608. !! Randomly picks one of the items plugged in
  609. !!
  610. !! Option 1: (has 6 input limit)
  611. !! $ARGS[1] = 'string' or 'number' to specify what youre plugging in (can also be blank for numbers)
  612. !! $ARGS[2-7] = strings or numbers to pick from, limited to 6
  613. !! Example 1: func('shortgs', 'rand_pick', 'string', 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta')
  614. !! Example 2: func('shortgs', 'rand_pick', '', 2, 3, 5, 7, 11, 13)
  615. !!
  616. !! Option 2: (no limitations, has to be delimited)
  617. !! $ARGS[1] = 'delimit' - used for larger numbers of items to pick from
  618. !! $ARGS[2] = 'string' or 'number' to specify what youre plugging in (can also be blank for numbers)
  619. !! $ARGS[3] = Delimited string to parse
  620. !! $ARGS[4] = Delimiter used (Default = '|' pipe)
  621. !! Example 1: func('shortgs', 'rand_pick', 'delimit', 'string', 'alpha|beta|gamma|delta|epsilon|zeta')
  622. !! Example 2: func('shortgs', 'rand_pick', 'delimit', 'number', '1-12-123-1234-12345-123456', '-')
  623. !! Example 3: func('shortgs', 'rand_pick', 'delimit', '', '0.1.2.3.5.7.11', '.')
  624. if $ARGS[0] = 'rand_pick':
  625. if $ARGS[1] = 'delimit':
  626. if $ARGS[2] = 'string':
  627. gs 'shortgs', 'parse_string', '$rand_pick_temp', $ARGS[3], $ARGS[4]
  628. $result = $rand_pick_temp[rand(0, arrsize('$rand_pick_temp')-1)]
  629. killvar '$rand_pick_temp'
  630. else
  631. gs 'shortgs', 'parse_string', 'rand_pick_temp', $ARGS[3], $ARGS[4]
  632. result = rand_pick_temp[rand(0, arrsize('rand_pick_temp')-1)]
  633. killvar 'rand_pick_temp'
  634. end
  635. else
  636. if arrsize('ARGS') > 2:
  637. if $ARGS[1] = 'string':
  638. $result = $ARGS[rand(2, arrsize('$ARGS')-1)]
  639. else
  640. result = ARGS[rand(2, arrsize('ARGS')-1)]
  641. end
  642. else
  643. msg '<b>Error: ''rand_pick'' is missing ARGS</b>'
  644. end
  645. end
  646. end
  647. !! Parse delimited string into an array
  648. !! $ARGS[1] = ArrayName (has to include $ for string values)
  649. !! $ARGS[2] = Delimited string to parse
  650. !! $ARGS[3] = Delimiter used (Default = '|' pipe)
  651. !! Example 1: gs 'shortgs', 'parse_string', '$my_array', 'alpha|beta|gamma|delta|epsilon|zeta'
  652. !! Example 2: gs 'shortgs', 'parse_string', 'my_array', '1-12-123-1234-12345-123456', '-'
  653. if $ARGS[0] = 'parse_string':
  654. !! Some failsafes (blank array name, blank string or no delimiters in string)
  655. if $ARGS[1] ! '':
  656. if $ARGS[2] ! '' and instr($ARGS[2],iif($ARGS[3] = '', '|', $ARGS[3])) > 0:
  657. !! Set delimiter with default if needed
  658. if $ARGS[3] = '':
  659. $ParserTmpDelim = '|'
  660. else
  661. $ParserTmpDelim = $ARGS[3]
  662. end
  663. !! Clear temp array if needed
  664. killvar 'ParserTmpArr' & killvar '$ParserTmpArr'
  665. $ParserTmpStr = $ARGS[2]
  666. !! Loop through string until no more delimiters found
  667. :StringParser01
  668. ParserTmpIdx = instr($ParserTmpStr, $ParserTmpDelim)
  669. if ParserTmpIdx > 0:
  670. if mid($ARGS[1],1,1) = '$':
  671. $ParserTmpArr[] = mid($ParserTmpStr, 1, ParserTmpIdx-1)
  672. $ParserTmpStr = mid($ParserTmpStr, ParserTmpIdx+1)
  673. else
  674. ParserTmpArr[] = val(mid($ParserTmpStr, 1, ParserTmpIdx-1))
  675. $ParserTmpStr = mid($ParserTmpStr, ParserTmpIdx+1)
  676. end
  677. jump 'StringParser01'
  678. !! Get last part since no more delimiters were found and copy to the final array
  679. elseif mid($ARGS[1],1,1) = '$':
  680. $ParserTmpArr[] = $ParserTmpStr
  681. copyarr $ARGS[1], '$ParserTmpArr'
  682. else
  683. ParserTmpArr[] = val($ParserTmpStr)
  684. copyarr $ARGS[1], 'ParserTmpArr'
  685. end
  686. killvar '$ParserTmpDelim'
  687. killvar '$ParserTmpStr'
  688. killvar 'ParserTmpIdx'
  689. killvar 'ParserTmpArr'
  690. else
  691. msg '<b>Error: No delimited string found!</b>'
  692. end
  693. else
  694. msg '<b>Error: No array name found!</b>'
  695. end
  696. end
  697. if $ARGS[0] = 'clothing_state':
  698. if PCloswimwear = 1:
  699. 'You are wearing swimwear.'
  700. elseif $clothingworntype = 'danilovich_outfits' and $shoeworntype = 'danilovich':
  701. 'You are wearing gym clothing and shoes.'
  702. elseif $clothingworntype = 'nude' and $braworntype = 'none' and $pantyworntype = 'none':
  703. 'You are naked.'
  704. elseif $clothingworntype = 'nude' and $braworntype = 'none':
  705. 'You are just wearing panties.'
  706. elseif $clothingworntype = 'nude' and $pantyworntype = 'none':
  707. 'You are just wearing a bra.'
  708. elseif $clothingworntype = 'nude':
  709. 'You are in your underwear.'
  710. elseif $braworntype = 'none' and $pantyworntype = 'none' and PCloPanties = 0 and PCloBra = 0:
  711. 'You are not wearing any underwear.'
  712. elseif $pantyworntype = 'none' and PCloPanties = 0:
  713. 'You are not wearing panties'
  714. elseif PCloBra = 0:
  715. 'You are not wearing a bra'
  716. end
  717. end
  718. !! Author - Hooded Silence
  719. !! Date created - 26 Aug 22
  720. !! Payment system - Used to pay for items in various game locations
  721. !! v. 02 - Refactoring to make usage simpler using the epayments array
  722. !! command syntax: gs 'shortgs','payments'
  723. !! All variabls are initiated at point of origin
  724. !!
  725. !! epayments[value] = cost of goods. Required
  726. !! $epayments[method] = how it''s to be paid cash or card. leave blank for both. Optional
  727. !! $epayments[description] = Item Description - What's been bought. Required
  728. !! $epayments[item_variable] = item variable to be purchased to be added to players inventory. Optional.
  729. !! epayments[quantity] = How many items to be added. Defaults to one - Optional.
  730. !! $epayments[loc] = Where do you want the character to go to, optional falls back to starting location if set. Optional
  731. !! $epayments[act] = If there's a specific act to return to. Optional
  732. !! $epayments[banner] = banner image for the sale. Optional
  733. !! Optional with no content are ignored.
  734. !! Use stock image for the purchase screen?
  735. if $ARGS[0] = 'payments':
  736. *clr & cla
  737. if epayments['value'] = 0:
  738. msg '<b>Error, Cash Value not set.</b>'
  739. end
  740. if $epayments['description'] = '':
  741. msg '<b>Error, Item Description not set.</b>'
  742. end
  743. !! Construct payment call
  744. if $epayments['item_variable'] ! '':
  745. $construct_cash = '<a href="exec: money -= <<epayments[''value'']>> & <<$epayments[''item_variable'']>> += <<epayments[''quantity'']>> & gs ''shortgs'', ''paymentcomplete'' ">Cash</a>'
  746. $construct_card = '<a href="exec: karta -= <<epayments[''value'']>> & <<$epayments[''item_variable'']>> += <<epayments[''quantity'']>> & gs ''shortgs'', ''paymentcomplete'' ">Card</a>'
  747. else
  748. $construct_cash = '<a href="exec: $epayments[''method''] = ''cash'' & money -= <<epayments[''value'']>> & gs ''shortgs'', ''paymentcomplete'' ">Cash</a>'
  749. $construct_card = '<a href="exec: $epayments[''method''] = ''card'' & karta -= <<epayments[''value'']>> & gs ''shortgs'', ''paymentcomplete'' ">Card</a>'
  750. end
  751. !Use stock image for the purchase screen?
  752. if $epayments['banner'] ! '':
  753. '<center><img <<$set_imgh>> src="images/' + $epayments['banner'] + '"></center>'
  754. end
  755. if ($epayments['method'] ! 'cash' and $epayments['method'] ! 'card') and (epayments['value'] <= money and epayments['value'] <= karta + bankDebtLimit):
  756. 'How do you want to pay for the <<$epayments[''description'']>>? <<$construct_cash>> or <<$construct_card>>'
  757. elseif ($epayments['method'] = 'cash' or $epayments['method'] = '') and epayments['value'] <= money:
  758. 'Pay for the <<$epayments[''description'']>> with <<$construct_cash>>?'
  759. elseif ($epayments['method'] = 'card' or $epayments['method'] = '') and epayments['value'] <= karta + bankDebtLimit:
  760. 'Pay for the <<$epayments[''description'']>> with your <<$construct_card>>?'
  761. else
  762. 'You don''t have enough money in your purse or bank account for this item.'
  763. end
  764. act 'Cancel Payment': gt $loc, $loc_arg
  765. end
  766. !! Payment complete
  767. if $ARGS[0] = 'paymentcomplete':
  768. *clr & cla
  769. 'Thank you for your custom. Please come again!'
  770. *nl
  771. 'You paid ' + epayments['value'] + '<b>₽</b>' + iif ($epayments['method'] = 'cash',' in cash', ' with your bank card') + ' for your ' + $epayments['description']
  772. gs 'stat'
  773. !! clean up all the variables
  774. killvar 'construct_cash'
  775. killvar 'construct_card'
  776. if $epayments['loc'] ! '':
  777. act 'Finish payment': gt $epayments['loc'], $epayments['loc_arg']
  778. else
  779. act 'Finish Payment': gt $loc, $loc_arg
  780. end
  781. end
  782. if $ARGS[0] = 'calendar_display':
  783. '<b><<$month>> <<day>></b>'
  784. '<b><<$week>></b>'
  785. '<b><<$mid(100 + hour, 2, 2)>>:<<$mid(100 + minut, 2, 2)>></b>'
  786. end
  787. if $ARGS[0] = 'day_display':
  788. '<b><<$week>></b>'
  789. '<b><<$mid(100 + hour, 2, 2)>>:<<$mid(100 + minut, 2, 2)>></b>'
  790. end
  791. if $ARGS[0] = 'time_display':
  792. '<b><<$mid(100 + hour, 2, 2)>>:<<$mid(100 + minut, 2, 2)>></b>'
  793. end
  794. if $ARGS[0] = 'setloc':
  795. !! Sets the location variables based on $ARGS[1] = loc, $ARGS[2] = loc arg
  796. !! Primary key
  797. $loc = $ARGS[1]
  798. $menu_loc = $ARGS[1]
  799. $locM = $ARGS[1]
  800. !! Secondary key
  801. $loc_arg = $ARGS[2]
  802. $menu_arg = $ARGS[2]
  803. $locM_arg = $ARGS[2]
  804. !! create loop from location array to determine region
  805. !!TBC
  806. end
  807. !! generates n rand numbers and selects min or max (max for lucky or min for unlucky)
  808. !! use: func('shortgs' 'roll', 'lucky' x, y, n)
  809. !! where x and y set range and n sets amount of rolls
  810. !! example: func('shortgs' 'roll', 'lucky' 0, 5)
  811. !! example: func('shortgs' 'roll', 'unlucky' 0, 100, 5)
  812. if $ARGS[0] = 'roll':
  813. temp_roll = rand(ARGS[2], ARGS[3])
  814. shortgs_i = 1
  815. :roll
  816. temp_rand = rand(ARGS[2], ARGS[3])
  817. if $ARGS[1] = 'lucky' and temp_rand > temp_roll:
  818. temp_roll = temp_rand
  819. elseif $ARGS[1] = 'unlucky' and temp_rand < temp_roll:
  820. temp_roll = temp_rand
  821. end
  822. shortgs_i += 1
  823. if shortgs_i < ARGS[4]: jump 'roll'
  824. result = temp_roll
  825. killvar 'temp_roll'
  826. killvar 'temp_rand'
  827. end
  828. !! limits a number to a range
  829. !! use: func('shortgs', 'clamp', var, min, max)
  830. !! returns min if var < min, returns max if var > max
  831. !! otherwise returns var
  832. !! example: func('shortgs', 'clamp', var, 0, 100)
  833. if $ARGS[0] = 'clamp':
  834. result = min(max(ARGS[1], ARGS[2]), ARGS[3])
  835. end
  836. !! sets a stat or attribute level to a number
  837. !! use: gs 'shortgs', 'setStat', 'stat', number
  838. !! example: gs 'shortgs', 'setStat', 'stren', 70
  839. !! example: gs 'shortgs', 'setStat', 'inhib', 10
  840. if $ARGS[0] = 'setStat':
  841. temp_input = func('shortgs', 'clamp', ARGS[2], 0, 100)
  842. if temp_input > 1:
  843. temp_xpnxt = (func('_difficulty','getexpadj') * (temp_input - 1) * (temp_input - 1) / 180) + 1
  844. end
  845. !! magik is based on `orgasm` variable thus the need for `_adj`
  846. if $ARGS[1] = 'magik':
  847. dynamic "<<$ARGS[1]>>_lvl = temp_input
  848. <<$ARGS[1]>>_adj = temp_xpnxt - orgasm
  849. <<$ARGS[1]>>_exp = orgasm + <<$ARGS[1]>>_adj
  850. <<$ARGS[1]>>_mem = <<$ARGS[1]>>_exp
  851. <<$ARGS[1]>>_lvlst = <<$ARGS[1]>>_lvl
  852. <<$ARGS[1]>>_flr = <<$ARGS[1]>>_lvl / 5"
  853. !! inhib needs its `_flr` set at `_lvl` and not `_lvl / 5`
  854. elseif $ARGS[1] = 'inhib':
  855. dynamic "<<$ARGS[1]>>_lvl = temp_input
  856. <<$ARGS[1]>>_exp = temp_xpnxt
  857. <<$ARGS[1]>>_mem = temp_xpnxt
  858. <<$ARGS[1]>>_lvlst = <<$ARGS[1]>>_lvl
  859. <<$ARGS[1]>>_flr = <<$ARGS[1]>>_lvl"
  860. !! `stren` and `stren_plus` changes should also update strenbuf
  861. elseif $ARGS[1] = 'stren' or $ARGS[1] = 'stren_plus':
  862. dynamic "<<$ARGS[1]>>_lvl = temp_input
  863. <<$ARGS[1]>>_exp = temp_xpnxt
  864. <<$ARGS[1]>>_mem = temp_xpnxt
  865. <<$ARGS[1]>>_lvlst = <<$ARGS[1]>>_lvl
  866. <<$ARGS[1]>>_flr = <<$ARGS[1]>>_lvl"
  867. strenbuf = stren_lvl + stren_plus_lvl
  868. gs 'body', 'DailyUpdate'
  869. else
  870. dynamic "<<$ARGS[1]>>_lvl = temp_input
  871. <<$ARGS[1]>>_exp = temp_xpnxt
  872. <<$ARGS[1]>>_mem = temp_xpnxt
  873. <<$ARGS[1]>>_lvlst = <<$ARGS[1]>>_lvl
  874. <<$ARGS[1]>>_flr = <<$ARGS[1]>>_lvl / 5"
  875. end
  876. killvar 'temp_input' & killvar 'temp_xpnxt'
  877. end
  878. !! Recursively computes a simple exponent - https://en.wikipedia.org/wiki/Exponentiation_by_squaring
  879. !! use: func('shortgs', 's_pow', var, exp)
  880. !! returns var ^ exp
  881. !! exp must be an integer >= 0
  882. !! example: func('shortgs', 's_pow', 2, 3)
  883. if $ARGS[0] = 's_pow':
  884. if(ARGS[2] > 10) : msg('Warning: s_pow operations with large exponents may cause integer overflows. <<ARGS[1]>> ^ <<ARGS[2]>>')
  885. if(ARGS[2]) < 0:
  886. !! n ^(-m) = 0
  887. msg('Error: s_pow cannot accept negative exponents! <<ARGS[1]>> ^ <<ARGS[2]>>')
  888. elseif ARGS[2] = 0:
  889. result = 1
  890. elseif ARGS[2] = 1:
  891. result = ARGS[1]
  892. elseif (ARGS[2] mod 2) = 0:
  893. result = func('shortgs', 's_pow', ARGS[1] * ARGS[1], ARGS[2] / 2)
  894. elseif (ARGS[2] mod 2) ! 0:
  895. result = ARGS[1] * func('shortgs', 's_pow', ARGS[1] * ARGS[1], (ARGS[2] - 1) / 2)
  896. end
  897. end
  898. !! Improved exponent calculation based on - https://en.wikipedia.org/wiki/Exponentiation_by_squaring
  899. !! use: func('shortgs', 's_pow2', var, exp)
  900. !! returns var ^exp
  901. !! if exp < 0, returns 0
  902. !! example: func('shortgs', 's_pow2', 2, 3) -> 8
  903. if $ARGS[0] = 's_pow2':
  904. if ARGS[2] = 0:
  905. result = 1
  906. elseif ARGS[2] < 0:
  907. result = 0
  908. elseif ARGS[2] = 1:
  909. result = ARGS[1]
  910. elseif ARGS[2] = 2:
  911. result = ARGS[1] * ARGS[1]
  912. elseif ARGS[2] = 3:
  913. result = ARGS[1] * ARGS[1] * ARGS[1]
  914. elseif (ARGS[2] mod 2) = 0:
  915. result = func('shortgs', 's_pow2', ARGS[1] * ARGS[1], ARGS[2] / 2)
  916. else
  917. result = ARGS[1] * func('shortgs', 's_pow2', ARGS[1] * ARGS[1], ARGS[2] / 4)
  918. end
  919. end
  920. !! Takes multiple arrays and sorts them based on the first one.
  921. !! Sorts the key_array (which must only have value entries) in ascending order.
  922. !! gs 'shortgs', 'coupled_array_sort'. 'key_array', 'array1', 'array2', 'array3', ...
  923. !!
  924. !! String arrays must start with a $ otherwise the numeric values will be copied instead.
  925. !!
  926. !! examples:
  927. !! example 1: we want to sort a single array with values called values_array
  928. !! gs 'shortgs', 'coupled_array_sort', 'values_array'
  929. !! example 2: we have an array filled with days (called trigger_days), and a coupled array filled with npc_codes (called $trigger_npc_codes)
  930. !! gs 'shortgs', 'coupled_array_sort', 'trigger_days', '$trigger_npc_codes'
  931. if $ARGS[0] = 'coupled_array_sort':
  932. :shortgs_coupled_array_sort_loop_start
  933. if arrsize($ARGS[1]) > 0:
  934. shortgs_temp_pos = arrpos($ARGS[1], min($ARGS[1]))
  935. shortgs_args_index = 1
  936. :shortgs_casl_inner_start
  937. if $ARGS[shortgs_args_index] ! '':
  938. if arrsize($ARGS[shortgs_args_index]) > 0:
  939. if mid($ARGS[shortgs_args_index], 1, 1) = '$':
  940. dynamic '$shortgs_temp_array<<shortgs_args_index>>[] = <<$ARGS[shortgs_args_index]>>[shortgs_temp_pos]'
  941. else
  942. dynamic 'shortgs_temp_array<<shortgs_args_index>>[] = <<$ARGS[shortgs_args_index]>>[shortgs_temp_pos]'
  943. end
  944. killvar $ARGS[shortgs_args_index], shortgs_temp_pos
  945. shortgs_args_index += 1
  946. jump 'shortgs_casl_inner_start'
  947. end
  948. end
  949. jump 'shortgs_coupled_array_sort_loop_start'
  950. end
  951. shortgs_max_args_index = shortgs_args_index
  952. shortgs_args_index = 1
  953. :shortgs_casl_outer_start
  954. if shortgs_args_index < shortgs_max_args_index:
  955. dynamic 'copyarr(''<<$ARGS[shortgs_args_index]>>'', ''shortgs_temp_array<<shortgs_args_index>>'')'
  956. dynamic 'killvar ''shortgs_temp_array<<shortgs_args_index>>'' '
  957. shortgs_args_index += 1
  958. jump 'shortgs_casl_outer_start'
  959. end
  960. killvar 'shortgs_casl_inner_start'
  961. killvar 'shortgs_args_index'
  962. killvar 'shortgs_coupled_array_sort_loop_start'
  963. killvar 'shortgs_casl_outer_start'
  964. killvar 'shortgs_max_args_index'
  965. killvar 'shortgs_temp_pos'
  966. end
  967. !! converts decimal integer to hexadecimal string
  968. !! main use - convert rgb color to hex color (to use with HTML)
  969. ! use: func('shortgs', 'int_to_hex_str', number)
  970. ! example: func('shortgs', 'int_to_hex_str', 192)
  971. ! example: func('shortgs', 'int_to_hex_str', BColorBase)
  972. if $ARGS[0] = 'int_to_hex_str':
  973. :int_to_hex_loop
  974. $result = mid('0123456789ABCDEF', 1 + (ARGS[1] mod 16), 1) + $result
  975. ARGS[1] /= 16
  976. if ARGS[1] > 0: jump 'int_to_hex_loop'
  977. end
  978. !! converts hexadecimal string to decimal integer
  979. !! main use - convert hex color to rgb color (to use with HTML)
  980. ! use: func('shortgs', 'hex_str_to_int', $hex_string)
  981. ! example: func('shortgs', 'hex_str_to_int', 'A1C')
  982. ! example: func('shortgs', 'hex_str_to_int', $bcolor)
  983. if $ARGS[0] = 'hex_str_to_int':
  984. $ARGS[1] = $ucase($ARGS[1])
  985. shortgs_i = 1
  986. :hex_to_int_loop
  987. result = result * 16 + instr(1, '123456789ABCDEF', mid($ARGS[1], shortgs_i, 1))
  988. shortgs_i += 1
  989. if shortgs_i <= len($ARGS[1]): jump 'hex_to_int_loop'
  990. killvar 'shortgs_i'
  991. end
  992. !! converts ABGR integer (generated by rgb() func) to hex string
  993. !! OMITS ALPHA CHANNEL
  994. ! use: func('shortgs', 'rgb_to_hex', number)
  995. ! example: func('shortgs', 'rgb_to_hex', bcolor)
  996. ! example: func('shortgs', 'rgb_to_hex', lcolor)
  997. if $ARGS[0] = 'rgb_to_hex':
  998. $result = func('shortgs', 'int_to_hex_str', (ARGS[1] and 16711680) / 65536)
  999. $result = mid('00', 1, 2 - len($result)) + $result
  1000. $result = func('shortgs', 'int_to_hex_str', (ARGS[1] and 65280) / 256) + $result
  1001. $result = mid('0000', 1, 4 - len($result)) + $result
  1002. $result = func('shortgs', 'int_to_hex_str', (ARGS[1] and 255)) + $result
  1003. $result = '#' + mid('000000', 1, 6 - len($result)) + $result
  1004. end
  1005. !! Inverts a hexidecimal color (f.e. #31A4E2)
  1006. !! func('shortgs', 'invert_color', $color)
  1007. !! if you want to get either white or black, furthest away from the given color. Use:
  1008. !! func('shortgs', 'invert_color', $color, 'bw')
  1009. !! https://stackoverflow.com/questions/35969656/how-can-i-generate-the-opposite-color-according-to-current-color
  1010. if $ARGS[0] = 'invert_color':
  1011. if $ARGS[2] = 'bw':
  1012. if func('shortgs', 'color_is_dark', $ARGS[1]) = 1:
  1013. $result = '#FFFFFF'
  1014. else
  1015. $result = '#000000'
  1016. end
  1017. else
  1018. $ARGS[1] = ucase(replace(trim($ARGS[1]), '#'))
  1019. shortgs_r = 255 - func('shortgs', 'hex_str_to_int', mid($ARGS[1], 1, 2))
  1020. shortgs_g = 255 - func('shortgs', 'hex_str_to_int', mid($ARGS[1], 3, 2))
  1021. shortgs_b = 255 - func('shortgs', 'hex_str_to_int', mid($ARGS[1], 5, 2))
  1022. $shortgs_r = func('shortgs', 'int_to_hex_str', shortgs_r)
  1023. $shortgs_g = func('shortgs', 'int_to_hex_str', shortgs_g)
  1024. $shortgs_b = func('shortgs', 'int_to_hex_str', shortgs_b)
  1025. $shortgs_r = mid('0' + $shortgs_r, len($shortgs_r), 2)
  1026. $shortgs_g = mid('0' + $shortgs_g, len($shortgs_g), 2)
  1027. $shortgs_b = mid('0' + $shortgs_b, len($shortgs_b), 2)
  1028. $result = '#' + $shortgs_r + $shortgs_g + $shortgs_b
  1029. killvar 'shortgs_r'
  1030. killvar 'shortgs_g'
  1031. killvar 'shortgs_b'
  1032. end
  1033. end
  1034. if $ARGS[0] = 'color_is_dark':
  1035. $ARGS[1] = ucase(replace(trim($ARGS[1]), '#'))
  1036. shortgs_cid_r = func('shortgs', 'hex_str_to_int', mid($ARGS[1], 1, 2))
  1037. shortgs_cid_g = func('shortgs', 'hex_str_to_int', mid($ARGS[1], 3, 2))
  1038. shortgs_cid_b = func('shortgs', 'hex_str_to_int', mid($ARGS[1], 5, 2))
  1039. result = 2126 * shortgs_r * shortgs_r + 7152 * shortgs_g * shortgs_g + 722 * shortgs_b * shortgs_b
  1040. result = iif(result > 136315346, 0, 1)
  1041. killvar 'shortgs_cid_r'
  1042. killvar 'shortgs_cid_g'
  1043. killvar 'shortgs_cid_b'
  1044. end
  1045. --- shortgs ---------------------------------