1
0

uniutil.qsrc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. # uniutil
  2. if $ARGS[0] = 'eligible_for_university':
  3. RESULT = func('uniutil', 'student', 'status') = 0 and func('uniutil', 'diploma', 'obtained') = 0 and (age >= 17 or fakepassport = 1)
  4. end
  5. if $ARGS[0] = 'prepclass':
  6. if $ARGS[1] = 'cost':
  7. RESULT = 15000
  8. end
  9. if $ARGS[1] = 'enroll':
  10. money -= func('uniutil', 'prepclass', 'cost')
  11. gs 'uniutil', 'prepclass', 'set_enrolled', 1
  12. gs 'uniutil', 'prepclass', 'set_count', 0
  13. end
  14. if $ARGS[1] = 'unenroll':
  15. killvar 'prepclassstats'
  16. end
  17. if $ARGS[1] = 'offered_this_month':
  18. RESULT = month <= func('uniutil', 'entrance_exam', 'month')
  19. end
  20. if $ARGS[1] = 'offered_today':
  21. RESULT = func('uniutil', 'entrance_exam', 'offered_this_month') and week < 6
  22. end
  23. end
  24. !! The legacy vars are the vars used by the university before the vars were largely consolidated into
  25. !! arrays with string indices. This function exists to avoid breaking old save files with this change,
  26. !! which was made in September 2020. It can be removed whenever it is felt enough time has passed.
  27. if $ARGS[0] = 'transfer_legacy_vars':
  28. if abiturient > 0:
  29. gs 'uniutil', 'prepclass', 'set_enrolled', 1
  30. gs 'uniutil', 'prepclass', 'set_count', abiturient - 1
  31. end
  32. killvar 'abiturient'
  33. if kurs > 0:
  34. if (semestr = 1 and month < func('uniutil', 'entrance_exam', 'month')) or (semestr = 2 and month > func('uniutil', 'exam', 'month', 2)):
  35. !! under the old system, the semestr variable was advanced when the exam was passed, so if the
  36. !! variable is set to a value that does not match the current month, the player skipped the exam
  37. !! and is expelled
  38. gs 'uniutil', 'student', 'set_status', -2
  39. killvar 'unisemestrstats'
  40. elseif semestr = 2 and month = func('uniutil', 'exam', 'month', 1):
  41. !! semestr = 2 in first semester exam month in the old system indicates that its still the first
  42. !! semester (time-wise) but the exam has been passed, so we set the new variables accordingly.
  43. gs 'uniutil', 'semester', 'set', 1
  44. gs 'uniutil', 'attendance', 'reset'
  45. gs 'uniutil', 'assignment_progress', 'reset'
  46. gs 'uniutil', 'assignments_done', 'reset'
  47. gs 'uniutil', 'semester_result', 'set_passed'
  48. gs 'uniutil', 'passed_semesters', 'set', 0
  49. else
  50. gs 'uniutil', 'semester', 'set', semestr
  51. gs 'uniutil', 'attendance', 'set', lektor
  52. gs 'uniutil', 'assignment_progress', 'set', kursovik
  53. gs 'uniutil', 'assignments_done', 'set', kursovikD
  54. gs 'uniutil', 'semester_result', 'reset'
  55. gs 'uniutil', 'passed_semesters', 'set', iif(semestr = 2, 1, 0)
  56. end
  57. gs 'uniutil', 'semester', 'update_year'
  58. gs 'uniutil', 'scholarship', 'set', iif(stipuha = 1, func('uniutil', 'scholarship', 'honors_value'), 0)
  59. end
  60. killvar 'kurs'
  61. killvar 'semestr'
  62. killvar 'stipuha'
  63. killvar 'lektor'
  64. killvar 'kursovik'
  65. killvar 'kursovikD'
  66. killvar 'examen'
  67. end
  68. if $ARGS[0] = 'check_semester_vs_date':
  69. if year > func('uniutil', 'semester', 'get_year') + 1:
  70. !! if year has advanced by more than one since a semester was finished, semesters were skipped.
  71. RESULT = -1
  72. exit
  73. end
  74. unilect_sm = func('uniutil', 'lecture', 'start_month', func('uniutil', 'semester', 'get'))
  75. uniexam_m = func('uniutil', 'exam', 'month', func('uniutil', 'semester', 'get'))
  76. uniexam_mns = func('uniutil', 'exam', 'month', func('uniutil','semester', 'next'))
  77. if year = func('uniutil', 'semester', 'get_year') + 1:
  78. if month > uniexam_m mod 12 and func('uniutil', 'semester_passed') and month <= uniexam_mns:
  79. !! the semester was passed and the next one is not over
  80. RESULT = 1
  81. elseif month <= uniexam_m:
  82. !! the semester is still in progress
  83. RESULT = 0
  84. else
  85. !! expelled
  86. RESULT = -1
  87. end
  88. else
  89. if unilect_sm > uniexam_m or month <= uniexam_m:
  90. !! The semester is still in progress
  91. RESULT = 0
  92. elseif func('uniutil', 'semester_result', 'is_passed') and (uniexam_m > uniexam_mns or month <= uniexam_mns):
  93. !! the semester was passed and the next one is not over
  94. RESULT = 1
  95. else
  96. !! expelled
  97. RESULT = -1
  98. end
  99. end
  100. killvar 'unilect_sm'
  101. killvar 'uniexam_m'
  102. killvar 'uniexam_mns'
  103. end
  104. if $ARGS[0] = 'student':
  105. if $ARGS[1] = 'status':
  106. if student > 0:
  107. uni_semvdateres = func('uniutil', 'check_semester_vs_date')
  108. if uni_semvdateres < 0:
  109. !! date indicates semester exam skipped
  110. gs 'uniutil', 'student', 'expel'
  111. elseif uni_semvdateres > 0:
  112. !! date indicates semester exam passed and next semester started
  113. gs 'uniutil', 'semester', 'update'
  114. gs 'uniutil', 'semester', 'update_year'
  115. gs 'uniutil', 'semester_result', 'reset'
  116. gs 'uniutil', 'passed_semesters', 'update'
  117. else
  118. !! date indicates semester is still in progress
  119. gs 'uniutil', 'semester', 'update_year'
  120. end
  121. killvar 'uni_semvdateres'
  122. end
  123. RESULT = student
  124. end
  125. if $ARGS[1] = 'set_status':
  126. student = ARGS[2]
  127. end
  128. if $ARGS[1] = 'enroll':
  129. gs 'uniutil', 'prepclass', 'unenroll'
  130. gs 'uniutil', 'student', 'set_status', 1
  131. gs 'uniutil', 'semester', 'set', 1
  132. gs 'uniutil', 'semester', 'update_year'
  133. gs 'uniutil', 'scholarship', 'reset'
  134. gs 'uniutil', 'attendance', 'reset'
  135. gs 'uniutil', 'assignment_progress', 'reset'
  136. gs 'uniutil', 'assignments_done', 'reset'
  137. gs 'uniutil', 'semester_result', 'reset'
  138. end
  139. if $ARGS[1] = 'unenroll':
  140. gs 'uniutil', 'prepclass', 'unenroll'
  141. if student > 0:
  142. killvar 'student'
  143. killvar 'unisemestrstats'
  144. end
  145. end
  146. if $ARGS[1] = 'expel':
  147. if func('uniutil', 'semester_result', 'is_failed'):
  148. gs 'uniutil', 'student', 'unenroll'
  149. gs 'uniutil', 'student', 'set_status', -1
  150. elseif func('uniutil', 'check_semester_vs_date') < 0:
  151. gs 'uniutil', 'student', 'unenroll'
  152. gs 'uniutil', 'student', 'set_status', -2
  153. else
  154. gs 'uniutil', 'student', 'unenroll'
  155. gs 'uniutil', 'student', 'set_status', -3
  156. end
  157. end
  158. if $ARGS[1] = 'graduate':
  159. gs 'uniutil', 'student', 'unenroll'
  160. gs 'uniutil', 'diploma', 'set_obtained'
  161. end
  162. if $ARGS[1] = 'expelled_for_failing':
  163. RESULT = func('uniutil', 'student', 'status') = -1
  164. end
  165. if $ARGS[1] = 'expelled_for_skipping':
  166. RESULT = func('uniutil', 'student', 'status') = -2
  167. end
  168. if $ARGS[1] = 'expelled_for_other_reason':
  169. RESULT = func('uniutil', 'student', 'status') = -3
  170. end
  171. if $ARGS[1] = 'enrolled':
  172. RESULT = func('uniutil', 'student', 'status') > 0
  173. end
  174. if $ARGS[1] = 'not_enrolled':
  175. RESULT = func('uniutil', 'student', 'enrolled') = 0
  176. end
  177. if $ARGS[1] = 'semesters_to_graduate':
  178. RESULT = 2
  179. end
  180. end
  181. if $ARGS[0] = 'diploma':
  182. if $ARGS[1] = 'get':
  183. RESULT = diplom
  184. end
  185. if $ARGS[1] = 'set':
  186. diplom = ARGS[2]
  187. end
  188. if $ARGS[1] = 'set_obtained':
  189. gs 'uniutil', 'diploma', 'set', 1
  190. if func('uniutil', 'fake_diploma', 'aware_needed'):
  191. gs 'uniutil', 'fake_diploma', 'reset'
  192. end
  193. end
  194. if $ARGS[1] = 'obtained':
  195. RESULT = func('uniutil', 'diploma', 'get') > 0
  196. end
  197. end
  198. if $ARGS[0] = 'fake_diploma':
  199. if $ARGS[1] = 'get':
  200. RESULT = fakediplom
  201. end
  202. if $ARGS[1] = 'set':
  203. fakediplom = ARGS[2]
  204. end
  205. if $ARGS[1] = 'set_aware_needed':
  206. gs 'uniutil', 'fake_diploma', 'set', 2
  207. end
  208. if $ARGS[1] = 'set_obtained':
  209. gs 'uniutil', 'fake_diploma', 'set', 1
  210. end
  211. if $ARGS[1] = 'reset':
  212. gs 'uniutil', 'fake_diploma', 'set', 0
  213. end
  214. if $ARGS[1] = 'aware_needed':
  215. RESULT = func('uniutil', 'fake_diploma', 'get') = 2
  216. end
  217. if $ARGS[1] = 'obtained':
  218. RESULT = func('uniutil', 'fake_diploma', 'get') = 1
  219. end
  220. end
  221. if $ARGS[0] = 'appear_to_have_graduated':
  222. RESULT = func('uniutil', 'diploma', 'obtained') or func('uniutil', 'fake_diploma', 'obtained')
  223. end
  224. if $ARGS[0] = 'attendance':
  225. if $ARGS[1] = 'get':
  226. RESULT = unisemestrstats['lectures_attendad']
  227. end
  228. if $ARGS[1] = 'set':
  229. unisemestrstats['lectures_attendad'] = ARGS[2]
  230. end
  231. if $ARGS[1] = 'update':
  232. gs 'uniutil', 'attendance', 'set', func('uniutil', 'attendance', 'get') + 1
  233. end
  234. if $ARGS[1] = 'reset':
  235. gs 'uniutil', 'attendance', 'set', 0
  236. end
  237. if $ARGS[1] = 'is_great':
  238. RESULT = func('uniutil', 'attendance', 'get') > 55
  239. end
  240. if $ARGS[1] = 'is_ok':
  241. RESULT = func('uniutil', 'attendance', 'get') > 40
  242. end
  243. if $ARGS[1] = 'is_bad':
  244. RESULT = func('uniutil', 'attendance', 'is_ok') = 0
  245. end
  246. end
  247. if $ARGS[0] = 'assignment_progress':
  248. if $ARGS[1] = 'get':
  249. RESULT = unisemestrstats['assignment_progress']
  250. end
  251. if $ARGS[1] = 'set':
  252. unisemestrstats['assignment_progress'] = iif(ARGS[2] <= 100, ARGS[2], 100)
  253. end
  254. if $ARGS[1] = 'update':
  255. gs 'uniutil', 'assignment_progress', 'set', func('uniutil', 'assignment_progress', 'get') + rand(pcs_intel / 20, pcs_intel / 10)
  256. end
  257. if $ARGS[1] = 'reset':
  258. gs 'uniutil', 'assignment_progress', 'set', 0
  259. end
  260. if $ARGS[1] = 'is_finished':
  261. RESULT = func('uniutil', 'assignment_progress', 'get') >= 100
  262. end
  263. if $ARGS[1] = 'is_not_finished':
  264. RESULT = func('uniutil', 'assignment_progress', 'is_finished') = 0
  265. end
  266. end
  267. if $ARGS[0] = 'assignments_done':
  268. if $ARGS[1] = 'get':
  269. RESULT = unisemestrstats['assignments_done']
  270. end
  271. if $ARGS[1] = 'set':
  272. unisemestrstats['assignments_done'] = ARGS[2]
  273. end
  274. if $ARGS[1] = 'update':
  275. gs 'uniutil', 'assignment_progress', 'reset'
  276. gs 'uniutil', 'assignments_done', 'set', func('uniutil', 'assignments_done', 'get') + 1
  277. end
  278. if $ARGS[1] = 'reset':
  279. gs 'uniutil', 'assignments_done', 'set', 0
  280. end
  281. if $ARGS[1] = 'great_num':
  282. RESULT = 11
  283. end
  284. if $ARGS[1] = 'min_num':
  285. RESULT = 1
  286. end
  287. if $ARGS[1] = 'did_great_num':
  288. RESULT = func('uniutil', 'assignments_done', 'get') >= func('uniutil', 'assignments_done', 'great_num')
  289. end
  290. if $ARGS[1] = 'did_min_num':
  291. RESULT = func('uniutil', 'assignments_done', 'get') >= func('uniutil', 'assignments_done', 'min_num')
  292. end
  293. end
  294. if $ARGS[0] = 'scholarship':
  295. if $ARGS[1] = 'get':
  296. RESULT = unisemestrstats['scholarship']
  297. end
  298. if $ARGS[1] = 'set':
  299. unisemestrstats['scholarship'] = ARGS[2]
  300. end
  301. if $ARGS[1] = 'reset':
  302. gs 'uniutil', 'scholarship', 'set', 0
  303. end
  304. if $ARGS[1] = 'is_active':
  305. RESULT = unisemestrstats['scholarship'] > 0 and func('uniutil', 'semester', 'is_active')
  306. end
  307. if $ARGS[1] = 'honors_value':
  308. RESULT = 1200
  309. end
  310. end
  311. if $ARGS[0] = 'lecture':
  312. if $ARGS[1] = 'start_hour':
  313. RESULT = 8
  314. end
  315. if $ARGS[1] = 'length':
  316. RESULT = 6
  317. end
  318. if $ARGS[1] = 'start_month':
  319. if ARGS[2] = 1:
  320. RESULT = 9
  321. elseif ARGS[2] = 2:
  322. RESULT = 2
  323. else
  324. !! Set to impossible month if it is not semester 1 or 2
  325. RESULT = 13
  326. end
  327. end
  328. if $ARGS[1] = 'end_month':
  329. if ARGS[2] = 1:
  330. RESULT = 11
  331. elseif ARGS[2] = 2:
  332. RESULT = 4
  333. else
  334. !! Set to impossible month if it is not semester 1 or 2
  335. RESULT = 0
  336. end
  337. end
  338. if $ARGS[1] = 'offered_this_month':
  339. unilect_sm = func('uniutil', 'lecture', 'start_month', func('uniutil', 'semester', 'get'))
  340. unilect_em = func('uniutil', 'lecture', 'end_month', func('uniutil', 'semester', 'get'))
  341. if unilect_sm <= unilect_em:
  342. !! if semester is in one calendar year
  343. RESULT = month >= unilect_sm and month <= unilect_em
  344. else
  345. !! if semester continues through New Years
  346. RESULT = month >= unilect_sm or month <= unilect_em
  347. end
  348. killvar 'unilect_sm'
  349. killvar 'unilect_em'
  350. end
  351. if $ARGS[1] = 'offered_today':
  352. RESULT = func('uniutil', 'lecture', 'offered_this_month') and week < 6
  353. end
  354. if $ARGS[1] = 'in_session':
  355. RESULT = func('uniutil', 'lecture', 'offered_today') and hour < func('uniutil', 'lecture', 'start_hour')
  356. end
  357. if $ARGS[1] = 'print_start_month':
  358. $RESULT = $monthName[func('uniutil', 'lecture', 'start_month', ARGS[2])]
  359. end
  360. if $ARGS[1] = 'print_months':
  361. unilect_idx = func('uniutil', 'lecture', 'start_month', ARGS[2])
  362. unilect_end = func('uniutil', 'lecture', 'end_month', ARGS[2])
  363. :lectureprintmonthsloop
  364. $RESULT += $monthname[unilect_idx]
  365. if unilect_idx ! unilect_end:
  366. $RESULT += ', '
  367. unilect_idx = (unilect_idx mod 12) + 1
  368. jump 'lectureprintmonthsloop'
  369. end
  370. killvar 'unilect_idx'
  371. killvar 'unilect_end'
  372. end
  373. end
  374. if $ARGS[0] = 'exam':
  375. if $ARGS[1] = 'month':
  376. if ARGS[2] = 1:
  377. RESULT = 12
  378. elseif ARGS[2] = 2:
  379. RESULT = 5
  380. else
  381. !! Set to impossible month if it is not semester 1 or 2
  382. RESULT = 0
  383. end
  384. end
  385. if $ARGS[1] = 'offered_this_month':
  386. RESULT = month = func('uniutil', 'exam', 'month', func('uniutil', 'semester', 'get'))
  387. end
  388. if $ARGS[1] = 'offered_today':
  389. RESULT = func('uniutil', 'exam', 'offered_this_month') and week < 6
  390. end
  391. if $ARGS[1] = 'print_month':
  392. $RESULT = $monthname[func('uniutil', 'exam', 'month', ARGS[2])]
  393. end
  394. end
  395. if $ARGS[0] = 'semester':
  396. if $ARGS[1] = 'get':
  397. RESULT = unisemestrstats['num']
  398. end
  399. if $ARGS[1] = 'set':
  400. unisemestrstats['num'] = ARGS[2]
  401. end
  402. if $ARGS[1] = 'next':
  403. RESULT = (func('uniutil', 'semester', 'get') mod func('uniutil', 'semester', 'total')) + 1
  404. end
  405. if $ARGS[1] = 'total':
  406. RESULT = 2
  407. end
  408. if $ARGS[1] = 'update':
  409. gs 'uniutil', 'semester', 'set', func('uniutil', 'semester', 'next')
  410. end
  411. if $ARGS[1] = 'get_year':
  412. RESULT = unisemestrstats['year']
  413. end
  414. if $ARGS[1] = 'update_year':
  415. unisemestrstats['year'] = year
  416. end
  417. if $ARGS[1] = 'is_active':
  418. RESULT = func('uniutil', 'lecture', 'offered_this_month') or func('uniutil', 'exam', 'offered_this_month')
  419. end
  420. if $ARGS[1] = 'print_months':
  421. $RESULT = 'Semester ' + ARGS[2] + ' lectures: ' + func('uniutil', 'lecture', 'print_months', ARGS[2]) + '.
  422. '
  423. $RESULT += 'Semester ' + ARGS[2] + ' exams: ' + func('uniutil', 'exam', 'print_month', ARGS[2]) + '.
  424. '
  425. end
  426. if $ARGS[1] = 'print_all_months':
  427. unisemester_idx = 1
  428. :semesterprintmonthsloop
  429. $RESULT += func('uniutil', 'semester', 'print_months', unisemester_idx)
  430. if unisemester_idx < func('uniutil', 'semester', 'total'):
  431. unisemester_idx += 1
  432. jump 'semesterprintmonthsloop'
  433. end
  434. killvar 'unisemester_idx'
  435. end
  436. end
  437. if $ARGS[0] = 'semester_result':
  438. if $ARGS[1] = 'get':
  439. RESULT = unisemestrstats['is_passed']
  440. end
  441. if $ARGS[1] = 'set':
  442. unisemestrstats['is_passed'] = ARGS[2]
  443. end
  444. if $ARGS[1] = 'set_passed':
  445. gs 'uniutil', 'semester_result', 'set', 1
  446. end
  447. if $ARGS[1] = 'set_failed':
  448. gs 'uniutil', 'semester_result', 'set', -1
  449. end
  450. if $ARGS[1] = 'reset':
  451. gs 'uniutil', 'semester_result', 'set', 0
  452. end
  453. if $ARGS[1] = 'is_passed':
  454. RESULT = func('uniutil', 'semester_result', 'get') > 0
  455. end
  456. if $ARGS[1] = 'is_failed':
  457. RESULT = func('uniutil', 'semester_result', 'get') < 0
  458. end
  459. end
  460. if $ARGS[0] = 'exam_outcome':
  461. gs 'uniutil', 'assignment_progress', 'reset'
  462. gs 'uniutil', 'assignments_done', 'reset'
  463. gs 'uniutil', 'attendance', 'reset'
  464. if $ARGS[1] = 'passed_honors':
  465. gs 'uniutil', 'semester_result', 'set_passed'
  466. gs 'uniutil', 'scholarship', 'set', func('uniutil', 'scholarship', 'honors_value')
  467. elseif $ARGS[1] = 'passed':
  468. gs 'uniutil', 'semester_result', 'set_passed'
  469. gs 'uniutil', 'scholarship', 'reset'
  470. else
  471. gs 'uniutil', 'semester_result', 'set_failed'
  472. gs 'uniutil', 'scholarship', 'reset'
  473. end
  474. end
  475. if $ARGS[0] = 'passed_semesters':
  476. if $ARGS[1] = 'get':
  477. RESULT = unisemestrstats['prev_passed_count'] + iif(func('uniutil', 'semester_result', 'is_passed'), 1, 0)
  478. end
  479. if $ARGS[1] = 'set':
  480. unisemestrstats['prev_passed_count'] = ARGS[2]
  481. end
  482. if $ARGS[1] = 'update':
  483. gs 'uniutil', 'passed_semesters', 'set', func('uniutil', 'passed_semesters', 'get')
  484. end
  485. end
  486. --- uniutil ---------------------------------