homes_properties.qsrc 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  1. # homes_properties
  2. if ARRSIZE('homes') < 16 or ARRSIZE('home_name') < 7:
  3. gs 'homes_properties_attr'
  4. end
  5. !!-----------------------------------------------------------------------------------------------------
  6. !!
  7. !! General calls
  8. !!
  9. !!-----------------------------------------------------------------------------------------------------
  10. !! Call: `gs 'homes_properties', 'calculate_available_for_rent_property_count'`
  11. !! This calculate the value of accessible_property['available_for_rent_home_count'] and accessible_property['available_for_rent_business_count']
  12. !! Right now it is called once when the first call to this location finds that the value for these are 0.
  13. !! However, I added it as a named thing in case a mod adds new properties, especially business type properties, in which the mod should call this
  14. !! to recalculate the values to include the newly added properties.
  15. !!
  16. !! NOTE: The code will set the value to -1 if now property of correct type is found.
  17. !! The reason for this is to make sure that it will not run more than once because there are no properties of that type - like business properties right now -,
  18. !! but to also make it sure that if we add one or more, either in the main game, or via some mod, we will not have to worry about this, as it will calculate correctly.
  19. !!
  20. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  21. if $ARGS[0] = 'calculate_rentable_property_count':
  22. count = ARRSIZE('homes')
  23. if count > 0:
  24. hp_i = 0
  25. :get_rentable_property_count_loop
  26. gs 'homes_properties_attr', 'get_property_attr', $homes[hp_i]
  27. if $ARGS[1] ! 'home' and INSTR($property['type'], 'residence') = 0 and property['rental']:
  28. accessible_property['rentable_business_count'] += 1
  29. elseif $ARGS[1] ! 'business' and INSTR($property['type'], 'business') = 0 and property['rental']:
  30. accessible_property['rentable_home_count'] += 1
  31. end
  32. hp_i += 1
  33. if hp_i < count: jump 'get_rentable_property_count_loop'
  34. killvar 'hp_i'
  35. end
  36. if accessible_property['rentable_business_count'] = 0: accessible_property['rentable_business_count'] = -1
  37. if accessible_property['rentable_home_count'] = 0: accessible_property['rentable_home_count'] = -1
  38. accessible_property['available_for_rent_home_count'] = accessible_property['rentable_home_count']
  39. accessible_property['available_for_rent_business_count'] = accessible_property['rentable_business_count']
  40. end
  41. !! Set the current home for Sveta based on either the property code or the id - for backward compatibility or some mods
  42. !! $ARGS[1] - a string to identify the property.
  43. !! Possible values:
  44. !! A property code - 'city_apartment', 'village_cottage', etc.
  45. !! A location name - $loc passed
  46. !! An empty string - in this case ARGS[2] is mandatory
  47. !! A number as str - really should remove this
  48. !!
  49. if $ARGS[0] = 'set_home':
  50. $homepropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  51. if $homepropcode ! '':
  52. killvar 'home'
  53. gs 'homes_properties_attr', 'get_property_attr', $homepropcode
  54. if INSTR($property['type'], 'residence') > 0:
  55. COPYARR 'home','property'
  56. $home['current'] = $property['code']
  57. if accessible_property[$home['current']] = 0: gs 'homes_properties', 'set_access', $home['current'], 1
  58. killvar 'property'
  59. end
  60. end
  61. end
  62. !! Call: `gs 'homes_properties', 'set_access', $ARGS[1], ARGS[2], ARGS[3]. ARGS[4]`
  63. !!
  64. !! $ARGS[1]: the location for which the access is set
  65. !! Accepted values
  66. !! - property code -> 'city_apartment', 'parents_home'
  67. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  68. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  69. !! - A number as str -> '1', '2' - this should be the id of the property
  70. !! NOTE: only added in case someone really want to use the old ids
  71. !! ARGS[2]: ownership type
  72. !! 0: no acces -> 'no access'
  73. !! 1: not owned but can live her - a rented property or living at some else''s place
  74. !! 2: owned -> 'owned'
  75. !! 3: owned and rented out -> 'tenants'
  76. !! ARGS[3]: construction status - optional
  77. !! 0: land only
  78. !! 1: foundation, frames built, utilities are connected
  79. !! 2: fully built
  80. !! ARGS[4]:renovation status - optional
  81. !! 0: not renovated
  82. !! 1: fully renovated
  83. if $ARGS[0] = 'set_access':
  84. $propcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  85. orig_status_code = accessible_property[$propcode]
  86. new_status_code = ARGS[2]
  87. if orig_status_code ! new_status_code:
  88. if $accessible_property[$propcode] = '' or $accessible_property['<<$propcode>>-display'] = '' or $accessible_property['<<$propcode>>-name'] = '':
  89. if $property['code'] ! $propcode:
  90. gs 'homes_properties_attr', 'get_property_attr', $propcode
  91. else
  92. nokill = 1
  93. end
  94. if ARGS[2] = 1 and property['rental'] = 0: new_status_code = 4
  95. accessible_property[$propcode] = new_status_code
  96. $accessible_property[$propcode] = $propcode
  97. $accessible_property['<<$propcode>>-name'] = $property['name']
  98. $accessible_property['<<$propcode>>-type'] = $property['type']
  99. if property['construction_needed'] = 1:
  100. accessible_property['<<$propcode>>-construction-status'] = ARGS[3]
  101. $accessible_property['<<$propcode>>-display'] = $property['display_<<ARGS[3]>>']
  102. else
  103. accessible_property['<<$propcode>>-construction-status'] = 2
  104. $accessible_property['<<$propcode>>-display'] = $property['display']
  105. end
  106. if INSTR($property['type'], 'residence') > 0: accessible_property['<<$propcode>>-is-home'] = 1
  107. accessible_property['<<$propcode>>-rental'] = property['rental']
  108. accessible_property['<<$propcode>>-renovated'] = ARGS[4]
  109. accessible_property['<<$propcode>>-sales-price'] = property['price']
  110. accessible_property['<<$propcode>>-rent'] = property['rent']
  111. end
  112. if accessible_property[$propcode] = 0:
  113. !! If this was the current home then killing it
  114. if $home['current'] = $propcode: killvar '$home'
  115. !! Updating home counts
  116. !! NOTE: Valid transitions: 1 -> 0, 2 -> 0, 4 -> 0
  117. if accessible_property['<<$propcode>>-is-home'] = 1:
  118. if orig_status_code = 1:
  119. accessible_property['rental_home_count'] -= 1
  120. accessible_property['available_for_rent_home_count'] += 1
  121. end
  122. if orig_status_code = 2: accessible_property['owned_home_count'] -= 1
  123. if accessible_property['<<$propcode>>-construction-status'] = 2: accessible_property['furnishable_home_count'] -= 1
  124. accessible_property['accessible_home_count'] -= 1
  125. end
  126. if accessible_property['accessible_home_count'] = 1:
  127. gs 'homes_properties', 'get_accessible_properties', 'home'
  128. if accessible_property['<<$ARGS[1]>>-is-home'] = 1: gs 'homes_properties', 'set_home', $property_code
  129. gs 'homes_properties', 'clean_up_property_data'
  130. end
  131. !! Property is rented
  132. elseif accessible_property[$propcode] = 1:
  133. !! Updating home counts
  134. !! NOTE: Only valid transition is 0 -> 1
  135. if accessible_property['<<$propcode>>-is-home'] = 1:
  136. accessible_property['rental_home_count'] += 1
  137. accessible_property['accessible_home_count'] += 1
  138. accessible_property['available_for_rent_home_count'] -= 1
  139. if accessible_property['<<$propcode>>-construction-status'] = 2: accessible_property['furnishable_home_count'] +=1
  140. end
  141. !! Property is owned
  142. elseif accessible_property[$propcode] = 2:
  143. !! Updating home counts
  144. !! NOTE: Valid transitions: 0 -> 2, 1 -> 2, 3-> 2
  145. if accessible_property['<<$propcode>>-is-home'] = 1:
  146. if orig_status_code = 0:
  147. accessible_property['accessible_home_count'] += 1
  148. elseif orig_status_code = 1:
  149. accessible_property['rental_home_count'] -= 1
  150. accessible_property['available_for_rent_home_count'] += 1
  151. elseif orig_status_code = 3:
  152. accessible_property['tenant_home_count'] -= 1
  153. accessible_property['<<$propcode>>-tenant-day'] = -1
  154. accessible_property['<<$propcode>>-tenant-month'] = -1
  155. if accessible_property['<<$propcode>>-construction-status'] = 2: accessible_property['furnishable_home_count'] += 1
  156. end
  157. if accessible_property['<<$propcode>>-construction-status'] = 2 and orig_status_code ! 1: accessible_property['furnishable_home_count'] += 1
  158. accessible_property['owned_home_count'] += 1
  159. end
  160. !! Property has tenants
  161. elseif accessible_property[$propcode] = 3:
  162. !! Updating home counts
  163. !! NOTE: Valid transitions: 2 -> 3
  164. if accessible_property['<<$propcode>>-is-home'] = 1:
  165. if $home['current'] = $propcode: killvar '$home'
  166. accessible_property['tenant_home_count'] += 1
  167. accessible_property['owned_home_count'] -= 1
  168. accessible_property['accessible_home_count'] -= 1
  169. if accessible_property['<<$propcode>>-construction-status'] = 2: accessible_property['furnishable_home_count'] -= 1
  170. end
  171. !! Property is just accessible
  172. elseif accessible_property[$propcode] = 4:
  173. !! Updating home counts
  174. !! NOTE: Valid transitions: 0 -> 4
  175. if accessible_property['<<$propcode>>-is-home'] = 1:
  176. accessible_property['accessible_home_count'] += 1
  177. end
  178. end
  179. if nokill = 0 : killvar 'property'
  180. end
  181. killvar 'propcode' & killvar 'orig_status_code' & killvar 'new_status_code' & killvar 'nokill'
  182. end
  183. !! Call: dyneval($is_homeless)
  184. $is_homeless = {
  185. result = ($home['current'] = 'homeless')
  186. }
  187. !! Call: `func('homes_properties', 'can_live_here', $ARGS[1])`
  188. !! Return -1 if the location/property is a place where Sveta can live, whether he owns or rents the place,
  189. !! she is just allowed to live there: university dorm, parents home, the Meynold Household, etc.
  190. !!
  191. !! $ARGS[1]: the location for which the access is set
  192. !! Accepted values
  193. !! - property code -> 'city_apartment', 'parents_home'
  194. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  195. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  196. !! - A number as str -> '1', '2' - this should be the id of the property
  197. !! NOTE: only added in case someone really want to use the old ids
  198. if $ARGS[0] = 'can_live_here':
  199. $canlivecode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  200. result = accessible_property[$canlivecode] > 0 and accessible_property[$canlivecode] ! 3 and func('homes_properties', 'get_property_construction_status', $canlivecode) = 2
  201. killvar 'canlivecode'
  202. end
  203. !! Call: `func('homes_properties', 'is_current_home', $ARGS[1])`
  204. !! Returns 0 if the location/property is not the current home, otherwise -1.
  205. !!
  206. !! $ARGS[1]: the location for which the access is set
  207. !! Accepted values
  208. !! - property code -> 'city_apartment', 'parents_home'
  209. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  210. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  211. !! - A number as str -> '1', '2' - this should be the id of the property
  212. !! NOTE: only added in case someone really want to use the old ids
  213. if $ARGS[0] = 'is_current_home':
  214. $currenthomecode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  215. result = $home['current'] = $currenthomecode
  216. killvar 'currenthomecode'
  217. end
  218. !! Call: `func('homes_properties', 'is_at_a_home', $ARGS[1])`
  219. !! Tells if the location passed in $ARGS[1] or if empty the $loc is a home or not.
  220. !! If true then returns -1, if false 0.
  221. !!
  222. !! $ARGS[1]: the location for which the access is set
  223. !! Accepted values
  224. !! - property code -> 'city_apartment', 'parents_home'
  225. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  226. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  227. !! - A number as str -> '1', '2' - this should be the id of the property
  228. !! NOTE: only added in case someone really want to use the old ids
  229. if $ARGS[0] = 'is_at_a_home':
  230. $isathomecode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  231. result = accessible_property['<<$isathomecode>>-is-home'] = 1
  232. killvar 'isathomecode'
  233. end
  234. !! Call: `func('homes_properties', 'is_property_of_status', $ARGS[1])`
  235. !! Tells if the location passed in $ARGS[1] or if empty the $loc is of the queried status.
  236. !! If true then returns -1, if false 0.
  237. !!
  238. !! $ARGS[1]: the status that is checked
  239. !! Accepted values
  240. !! 'rented' -> is the property rented?
  241. !! 'owned' -> is the property is owned (bought by Sveta) ?
  242. !! 'tenants' -> are there tenants in the property?
  243. !! 'purchased' -> both 'owned' and 'tenants'
  244. !! 'blocked' -> is the property blocked?
  245. !! 'hasaccess' -> can Sveta use the property (without owning or renting it)?
  246. !!
  247. !! $ARGS[2]: the location for which the access is set
  248. !! Accepted values
  249. !! - property code -> 'city_apartment', 'parents_home'
  250. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  251. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  252. !! - A number as str -> '1', '2' - this should be the id of the property
  253. !! NOTE: only added in case someone really want to use the old ids
  254. if $ARGS[0] = 'is_property_of_status':
  255. $propstatcode = iif($ARGS[2] = '', $home_name[$loc], $home_name[$ARGS[2]])
  256. if $ARGS[1] = 'rented':
  257. result = accessible_property[$propstatcode] = 1
  258. elseif $ARGS[1] = 'owned':
  259. result = accessible_property[$propstatcode] = 2
  260. elseif $ARGS[1] = 'tenants':
  261. result = accessible_property[$propstatcode] = 3
  262. elseif $ARGS[1] = 'blocked':
  263. result = accessible_property[$propstatcode] = 0
  264. elseif $ARGS[1] = 'hasacces':
  265. result = accessible_property[$propstatcode] = 4
  266. elseif $ARGS[1] = 'purchased':
  267. result = accessible_property[$propstatcode] = 2 or accessible_property[$propstatcode] = 3
  268. else
  269. result = 0
  270. end
  271. killvar 'propstatcode'
  272. end
  273. !! Call `func('homes_properties', 'get_property_code', $ARGS[1])`
  274. !! Returns
  275. !!
  276. !! $ARGS[1]: the location for which the access is set
  277. !! Accepted values
  278. !! - property code -> 'city_apartment', 'parents_home'
  279. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  280. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  281. !! - A number as str -> '1', '2' - this should be the id of the property
  282. !! NOTE: only added in case someone really want to use the old ids
  283. if $ARGS[0] = 'get_property_code':
  284. $result = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  285. end
  286. !!---------------------------------------------------------
  287. !! Home and Property Counts - FUNC()
  288. !!---------------------------------------------------------
  289. !! Call: `func('homes_properties', 'get_rented_property_count', $ARGS[1])`
  290. !! Returns the count of rented properties
  291. !!
  292. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  293. if $ARGS[0] = 'get_rented_property_count':
  294. if $ARGS[1] = 'home':
  295. result = accessible_property['rental_home_count']
  296. elseif $ARGS[1] = 'business':
  297. result = accessible_property['rental_business_count']
  298. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  299. result = accessible_property['rental_home_count'] + accessible_property['rental_business_count']
  300. end
  301. end
  302. !! Call: `func('homes_properties', 'get_accessible_property_count', $ARGS[1])`
  303. !! Returns the count of accessible properties
  304. !!
  305. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  306. if $ARGS[0] = 'get_accessible_property_count':
  307. if $ARGS[1] = 'home':
  308. result = accessible_property['accessible_home_count']
  309. elseif $ARGS[1] = 'business':
  310. result = accessible_property['accessible_business_count']
  311. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  312. result = accessible_property['accessible_home_count'] + accessible_property['accessible_business_count']
  313. end
  314. end
  315. !! Call: `func('homes_properties', 'get_rentable_property_count', $ARGS[1])`
  316. !! Returns the count of properties that can be rented (all properties with where property['rental'] = 1)
  317. !!
  318. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  319. if $ARGS[0] = 'get_rentable_property_count':
  320. if $ARGS[1] = 'home':
  321. result = accessible_property['rentable_home_count']
  322. elseif $ARGS[1] = 'business':
  323. result = accessible_property['rentable_business_count']
  324. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  325. result = accessible_property['rentable_home_count'] + accessible_property['rentable_business_count']
  326. end
  327. end
  328. !! Call: `func('homes_properties', 'get_available_for_rent_property_count', $ARGS[1])`
  329. !! Returns the number of properties that are avaiable for rent - rentable properties that are not rented.
  330. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  331. if $ARGS[0] = 'get_available_for_rent_property_count':
  332. if $ARGS[1] = 'home':
  333. result = accessible_property['available_for_rent_home_count']
  334. elseif $ARGS[1] = 'business':
  335. result = accessible_property['available_for_rent_business_count']
  336. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  337. result = accessible_property['available_for_rent_home_count'] + accessible_property['available_for_rent_business_count']
  338. end
  339. end
  340. !! Call: `func('homes_properties', 'furnishable_home_count', $ARGS[1])`
  341. !! Returns the count of furnishable properties (for shops)
  342. !!
  343. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  344. if $ARGS[0] = 'get_furnishable_property_count':
  345. if $ARGS[1] = 'home':
  346. result = accessible_property['furnishable_home_count']
  347. elseif $ARGS[1] = 'business':
  348. result = accessible_property['furnishable_business_count']
  349. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  350. result = accessible_property['furnishable_home_count'] + accessible_property['furnishable_business_count']
  351. end
  352. end
  353. !!---------------------------------------------------------
  354. !! Get Properties and their values
  355. !!---------------------------------------------------------
  356. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  357. !! rented properties
  358. !!
  359. !! Returns: property_rent, property_days, $property_name, $property_display, $property_code
  360. !! $ARGS[1] - the property_type: 'home' - homes, 'business' - business properties, 'all' or '' - both types
  361. !! ARGS[2] - optional, if value is 1 then only $property_code[] is created.
  362. if $ARGS[0] = 'get_rented_properties':
  363. hp_i = 0
  364. hp_j = 0
  365. gs 'homes_properties', 'clean_up_property_data'
  366. count = ARRSIZE('accessible_property')
  367. if count > 0:
  368. :get_rented_properties_loop
  369. $getrentedpropcode = $accessible_property[hp_i]
  370. if $home_name[$getrentedpropcode] ! '' and accessible_property[hp_i] = 1:
  371. if ($ARGS[1] ! 'home' and accessible_property['<<$getrentedpropcode>>-is-home'] = 0) or ($ARGS[1] ! 'business' and accessible_property['<<$getrentedpropcode>>-is-home'] = 1):
  372. $property_code[hp_j] = $getrentedpropcode
  373. if ARGS[2] = 0:
  374. $property_name[hp_j] = $accessible_property['<<$getrentedpropcode>>-name']
  375. $property_display[hp_j] = $accessible_property['<<$getrentedpropcode>>-display']
  376. property_days[hp_j] = accessible_property['<<$getrentedpropcode>>-days-left']
  377. property_rent[hp_j] = accessible_property['<<$getrentedpropcode>>-rent']
  378. end
  379. j += 1
  380. end
  381. end
  382. hp_i += 1
  383. if hp_i < count: jump 'get_rented_properties_loop'
  384. end
  385. killvar 'count'
  386. killvar 'hp_i'
  387. killvar 'hp_j'
  388. killvar '$getrentedpropcode'
  389. end
  390. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  391. !! all owned (bought) properties.
  392. !!
  393. !! "Returns":
  394. !! $property_code[], $property_name[], $property_display[], $property_status_display[], $property_type[]
  395. !! property_status[], property_construction_status, property_is_renovated[], property_sales_price[],
  396. !! property_renovation_value[]
  397. !!
  398. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties;
  399. !! 'all' or '' (or $ARGS[1] not passed) - returns both types
  400. !! IMPORTANT: If $ARGS[2] is passed, the $ARGS[1] will be ignored and will be treated as if it was 'all'/''.
  401. !! $ARGS[2] - optional, a property code or a location. If $ARGS[2] passed, only one property will be checked and returned.
  402. !!
  403. if $ARGS[0] = 'get_owned_properties':
  404. hp_i = 0
  405. hp_j = 0
  406. gs 'homes_properties', 'clean_up_property_data'
  407. $type = iif($ARGS[2] = '', $ARGS[1], 'all')
  408. count = iif($ARGS[2] = '', ARRSIZE('accessible_property'), 1)
  409. if count > 0:
  410. !!'<h3>Building Owned Properties List</h3>'
  411. !!'Count: <b><<count>></b>'
  412. :get_owned_properties_loop
  413. $getownedpropcode = iif( $ARGS[2] = '', $accessible_property[hp_i], $ARGS[2] )
  414. !!' Index: <b><<hp_i>></b> Code: <b><<$getownedpropcode>></b> Status: <b><<accessible_property[hp_i]>></b>'
  415. if $home_name[$getownedpropcode] ! '' and (accessible_property[$getownedpropcode] = 2 or accessible_property[$getownedpropcode] = 3):
  416. !!' $ARGS[1]: <b><<$ARGS[hp_i]>></b> Is home: <b><<accessible_property[''<<$getownedpropcode>>-is-home'']>></b>'
  417. if ($type ! 'home' and accessible_property['<<$getownedpropcode>>-is-home'] = 0) or ($type ! 'business' and accessible_property['<<$getownedpropcode>>-is-home'] = 1):
  418. $property_code[hp_j] = $getownedpropcode
  419. $property_name[hp_j] = $accessible_property['<<$getownedpropcode>>-name']
  420. if property['construction_needed'] = 1:
  421. $property_display[hp_j] = iif($accessible_property[$getownedpropcode] = '', $property['display_0'], $accessible_property['<<$getownedpropcode>>-display'])
  422. else
  423. $property_display[hp_j] = iif($accessible_property[$getownedpropcode] = '', $property['display'], $accessible_property['<<$getownedpropcode>>-display'])
  424. end
  425. $property_type[hp_j] = $accessible_property['<<$getownedpropcode>>-type']
  426. if accessible_property[$getownedpropcode] = 3:
  427. $property_status_display[hp_j] = 'A(n) <<$property_display[hp_j]>> which is currently occupied by your tenants'
  428. else
  429. $property_status_display[hp_j] = 'A(n) <<$property_display[hp_j]>> ' + iif($accessible_property[$getownedpropcode] = $home['current'], 'where you currently live.', 'which is currently empty.')
  430. end
  431. property_status[hp_j] = accessible_property[$getownedpropcode]
  432. property_construction_status[hp_j] = accessible_property['<<$getownedpropcode>>-construction-status']
  433. property_is_renovated[hp_j] = accessible_property['<<$getownedpropcode>>-renovated']
  434. property_sales_price[hp_j] = accessible_property['<<$getownedpropcode>>-sales-price']
  435. property_renovation_value[hp_j] = accessible_property['<<$getownedpropcode>>-renovation-value']
  436. hp_j += 1
  437. end
  438. end
  439. hp_i += 1
  440. if hp_i < count: jump 'get_owned_properties_loop'
  441. end
  442. killvar 'count'
  443. killvar 'hp_i'
  444. killvar 'hp_j'
  445. killvar 'getownedpropcode'
  446. end
  447. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  448. !! all accessible (rented, bought or just allowed to stay) properties.
  449. !!
  450. !! "Returns":
  451. !! $property_code[], $property_name[], $property_display[], $property_status_display[], $property_type[]
  452. !! property_status[], property_construction_status[], property_is_renovated[], property_renovation_value[]
  453. !!
  454. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties; '' - returns both types
  455. if $ARGS[0] = 'get_accessible_properties':
  456. hp_i = 0
  457. hp_j = 0
  458. gs 'homes_properties', 'clean_up_property_data'
  459. count = ARRSIZE('accessible_property')
  460. if count > 0:
  461. :get_accessible_properties_loop
  462. $getaccessiblepropcode = $accessible_property[hp_i]
  463. if $home_name[$getaccessiblepropcode] ! '' and accessible_property[$getaccessiblepropcode] > 0:
  464. if ($ARGS[1] ! 'home' and accessible_property['<<$getaccessiblepropcode>>-is-home'] = 0) or ($ARGS[1] ! 'business' and accessible_property['<<$getaccessiblepropcode>>-is-home'] = 1):
  465. $property_code[hp_j] = $getaccessiblepropcode
  466. $property_name[hp_j] = $accessible_property['<<$getaccessiblepropcode>>-name']
  467. if property['construction_needed'] = 1:
  468. $property_display[hp_j] = iif($accessible_property[$getaccessiblepropcode] = '', $property['display_0'], $accessible_property['<<$getaccessiblepropcode>>-display'])
  469. else
  470. $property_display[hp_j] = iif($accessible_property[$getaccessiblepropcode] = '', $property['display'], $accessible_property['<<$getaccessiblepropcode>>-display'])
  471. end
  472. if accessible_property[$getaccessiblepropcode] = 1:
  473. $property_status_display[hp_j] = 'You rent the <<$property_display[hp_j]>> '+iif($accessible_property[$getaccessiblepropcode] = $home['current'], 'where you currently live.', 'which is currently empty.')
  474. elseif accessible_property[$getaccessiblepropcode] = 2:
  475. $property_status_display[hp_j] = 'You own the <<$property_display[hp_j]>> ' + iif($accessible_property[$getaccessiblepropcode] = $home['current'], 'where you currently live.', 'which is currently empty.')
  476. elseif accessible_property[$getaccessiblepropcode] = 3:
  477. $property_status_display[hp_j] = 'You own the <<$property_display[hp_j]>> which is currently occupied by your tenants'
  478. else
  479. $property_status_display[hp_j] = 'You can stay at the <<$property_display[hp_j]>> which is currently occupied by your tenants'
  480. end
  481. property_status[hp_j] = accessible_property[$getaccessiblepropcode]
  482. property_construction_status[hp_j] = accessible_property['<<$getaccessiblepropcode>>-construction-status']
  483. property_is_renovated[hp_j] = accessible_property['<<$getaccessiblepropcode>>-renovated']
  484. property_type[hp_j] = accessible_property['<<$getaccessiblepropcode>>-type']
  485. hp_j += 1
  486. end
  487. end
  488. hp_i += 1
  489. if hp_i < count: jump 'get_accessible_properties_loop'
  490. end
  491. killvar 'count'
  492. killvar 'hp_i'
  493. killvar 'hp_j'
  494. killvar 'getaccessiblepropcode'
  495. end
  496. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  497. !! all properties that are for sale.
  498. !!
  499. !! "Returns":
  500. !! $property_code[], $property_name[], $property_display[], $property_type[]
  501. !! property_construction_status,property_is_renovated[], property_sales_price[], property_renovation_value[]
  502. !!
  503. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties; '' - returns both types
  504. if $ARGS[0] = 'get_properties_for_sale':
  505. hp_i = 0
  506. hp_j = 0
  507. gs 'homes_properties', 'clean_up_property_data'
  508. count = ARRSIZE('homes')
  509. if count > 0:
  510. :get_properties_for_sale_loop
  511. $getforsalespropcode = $homes[hp_i]
  512. if $getforsalespropcode ! '' and checked_homes[$getforsalespropcode] = 0 and accessible_property[$getforsalespropcode] < 2:
  513. checked_homes[$getforsalespropcode] = 1
  514. if $accessible_property[$getforsalespropcode] = '': gs 'homes_properties_attr', 'get_property_attr', $getforsalespropcode
  515. ishome = iif($accessible_property[$getforsalespropcode] = '', INSTR($property['type'], 'residence') > 0, INSTR($accessible_property['<<$getforsalespropcode>>-type'], 'residence') > 0 )
  516. hasprice = iif($accessible_property[$getforsalespropcode] = '', property['price'] > 0, accessible_property['<<$getforsalespropcode>>-sales-price'] > 0)
  517. if (($ARGS[1] ! 'home' and ishome = 0) or ($ARGS[1] ! 'business' and ishome)) and hasprice:
  518. $property_code[hp_j] = $getforsalespropcode
  519. $property_name[hp_j] = iif($accessible_property[$getforsalespropcode] = '', $property['name'], $accessible_property['<<$getforsalespropcode>>-name'])
  520. $property_type[hp_j] = iif($accessible_property[$getforsalespropcode] = '', $property['type'], $accessible_property['<<$getforsalespropcode>>-type'])
  521. if property['construction_needed'] = 1:
  522. $property_display[hp_j] = iif($accessible_property[$getforsalespropcode] = '', $property['display_0'], $accessible_property['<<$getforsalespropcode>>-display'])
  523. else
  524. $property_display[hp_j] = iif($accessible_property[$getforsalespropcode] = '', $property['display'], $accessible_property['<<$getforsalespropcode>>-display'])
  525. end
  526. property_is_rented[hp_j] = accessible_property[$getforsalespropcode] = 1
  527. property_construction_status[hp_j] = iif($accessible_property[$getforsalespropcode] = '', 0, accessible_property['<<$getforsalespropcode>>-construction-status'])
  528. property_is_renovated[hp_j] = iif($accessible_property[$getforsalespropcode] = '', 0, accessible_property['<<$getforsalespropcode>>-renovated'])
  529. property_sales_price[hp_j] = iif($accessible_property[$getforsalespropcode] = '', property['price'], accessible_property['<<$getforsalespropcode>>-sales-price'])
  530. hp_j += 1
  531. end
  532. killvar 'property'
  533. end
  534. hp_i += 1
  535. if hp_i < count: jump 'get_properties_for_sale_loop'
  536. end
  537. killvar 'count'
  538. killvar 'hp_i'
  539. killvar 'j'
  540. killvar 'propcode'
  541. killvar 'checked_homes'
  542. killvar 'ishome'
  543. killvar 'hasprice'
  544. killvar '$getforsalespropcode'
  545. end
  546. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  547. !! all properties that the player can rent.
  548. !!
  549. !! "Returns":
  550. !! $property_code[], $property_name[], $property_display[]
  551. !! property_days[], property_rent[]
  552. !!
  553. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties; '' - returns both types
  554. if $ARGS[0] = 'get_properties_for_rent':
  555. hp_i = 0
  556. hp_j = 0
  557. gs 'homes_properties', 'clean_up_property_data'
  558. count = ARRSIZE('homes')
  559. if count > 0:
  560. :get_properties_for_rent_loop
  561. $getpropforrentcode = $homes[hp_i]
  562. if $getpropforrentcode ! '' and checked_homes[$getpropforrentcode] = 0 and accessible_property[$getpropforrentcode] = 0:
  563. checked_homes[$getpropforrentcode] = 1
  564. if $accessible_property[$getpropforrentcode] = '': gs 'homes_properties_attr', 'get_property_attr', $getpropforrentcode
  565. ishome = iif($accessible_property[$getpropforrentcode] = '', INSTR($property['type'], 'residence') > 1, INSTR($accessible_property['<<$getpropforrentcode>>-type'], 'residence') > 1 )
  566. isrental = iif($accessible_property[$getpropforrentcode] = '', property['rental'] = 1, accessible_property['<<$getpropforrentcode>>-rental'] = 1 )
  567. if (($ARGS[1] ! 'home' and ishome = 0) or ($ARGS[1] ! 'business' and ishome)) and isrental:
  568. $property_code[hp_j] = $getpropforrentcode
  569. $property_name[hp_j] = iif($accessible_property[$getpropforrentcode] = '', $property['name'], $accessible_property['<<$getpropforrentcode>>-name'])
  570. if property['construction_needed'] = 1:
  571. $property_display[hp_j] = iif($accessible_property[$getpropforrentcode] = '', $property['display_0'], $accessible_property['<<$getpropforrentcode>>-display'])
  572. else
  573. $property_display[hp_j] = iif($accessible_property[$getpropforrentcode] = '', $property['display'], $accessible_property['<<$getpropforrentcode>>-display'])
  574. end
  575. property_days[hp_j] = iif($accessible_property[$getpropforrentcode] = '', 0, accessible_property['<<$getpropforrentcode>>-days-left'])
  576. property_rent[hp_j] = iif($accessible_property[$getpropforrentcode] = '', property['rent'], accessible_property['<<$getpropforrentcode>>-rent'])
  577. hp_j += 1
  578. end
  579. killvar 'property'
  580. end
  581. hp_i += 1
  582. if hp_i < count: jump 'get_properties_for_rent_loop'
  583. end
  584. killvar 'checked_homes'
  585. killvar 'count'
  586. killvar 'hp_i'
  587. killvar 'hp_j'
  588. killvar '$getpropforrentcode'
  589. killvar 'ishome'
  590. killvar 'isrental'
  591. end
  592. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  593. !! all properties for which the player can buy an internet subscription
  594. !!
  595. !! "Returns":
  596. !! $property_code[], $property_name[], $property_status[], property__is_current_home[]
  597. !! $property_stat values: 'rented', 'owned', 'tenants', 'no access'
  598. !!
  599. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties; '' - returns both types
  600. !! $ARGS[2] - '' or 'hasaccess'. 'hasaccess' returns only those internet enabled properties that are purchased or rented by Sveta
  601. !! including ones with tenants.
  602. if $ARGS[0] = 'get_internet_enabled_properties':
  603. hp_i = 0
  604. hp_j = 0
  605. gs 'homes_properties', 'clean_up_property_data'
  606. count = ARRSIZE('homes')
  607. if count > 0:
  608. :get_internet_enabled_properties_loop
  609. $getnetenabledprocode = $homes[hp_i]
  610. if checked_homes[$getnetenabledprocode] = 0:
  611. checked_homes[$getnetenabledprocode] = 1
  612. gs 'homes_properties_attr', 'get_property_attr', $getnetenabledprocode
  613. accesscheck = ($ARGS[2] = 'hasaccess' and accessible_property[$getnetenabledprocode] ! 0 and accessible_property[$getnetenabledprocode] ! 4) or $ARGS[2] = ''
  614. typecheck = (($ARGS[1] ! 'home' and INSTR($property['type'], 'residence') = 0) or ($ARGS[1] ! 'business' and INSTR($property['type'], 'residence') > 0))
  615. if accesscheck and typecheck and property['internet_enabled']:
  616. $property_name[hp_j] = $property['name']
  617. $property_code[hp_j] = $getnetenabledprocode
  618. if accessible_property[$getnetenabledprocode] = 0:
  619. $property_status[hp_j] = 'no access'
  620. elseif accessible_property[$getnetenabledprocode] = 1:
  621. $property_status[hp_j] = 'rented'
  622. elseif accessible_property[$getnetenabledprocode] = 2:
  623. $property_status[hp_j] = 'owned'
  624. elseif accessible_property[$getnetenabledprocode] = 3:
  625. $property_status[hp_j] = 'tenants'
  626. end
  627. property__is_current_home[hp_j] = $home['current'] = $getnetenabledprocode
  628. hp_j += 1
  629. killvar 'accesscheck'
  630. killvar 'typecheck'
  631. end
  632. killvar 'property'
  633. end
  634. hp_i += 1
  635. if hp_i < count: jump 'get_internet_enabled_properties_loop'
  636. end
  637. killvar 'count'
  638. killvar 'hp_i'
  639. killvar 'hp_j'
  640. killvar 'propcode'
  641. killvar 'checked_homes'
  642. end
  643. !! Call after using any of the above calls to run killvar on all the temporary variables
  644. if $ARGS[0] = 'clean_up_property_data':
  645. killvar 'property_rent'
  646. killvar 'property_days'
  647. killvar 'property_code'
  648. killvar 'property_status'
  649. killvar 'property_name'
  650. killvar 'property_display'
  651. killvar 'property_type'
  652. killvar 'property_status_display'
  653. killvar 'property_is_rented'
  654. killvar 'property_construction_status'
  655. killvar 'property_is_renovated'
  656. killvar 'property_sales_price'
  657. killvar 'property_renovation_value'
  658. killvar 'property__is_current_home'
  659. end
  660. !! If there are no properties that can be used as home, Sveta is homeless.
  661. if $ARGS[0] = 'set_homeless':
  662. $home['current'] = 'homeless'
  663. end
  664. !!---------------------------------------------------------
  665. !! Give and block access to properties - use these if the
  666. !! property is not bought or rented.
  667. !! Parents home[], Meynold household, Grandparents house, etc.
  668. !!---------------------------------------------------------
  669. !! $ARGS[1]: the location for which the access is set
  670. !! Accepted values
  671. !! - property code -> 'city_apartment', 'parents_home'
  672. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  673. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  674. !! - A number as str -> '1', '2' - this should be the id of the property
  675. !! NOTE: only added in case someone really want to use the old ids
  676. if $ARGS[0] = 'give_access':
  677. $accesscode = iif($ARGS[1] = '', $home_name[$loc], $ARGS[1])
  678. gs 'homes_properties', 'set_access', $accesscode, 1
  679. if accessible_property['accessible_home_count'] = 1 and accessible_property['<<$accesscode>>-is-home'] = 1 and $home['current'] = '': gs 'homes_properties', 'set_home', $accesscode
  680. killvar '$accesscode'
  681. end
  682. !! $ARGS[1]: the location for which the access is set
  683. !! Accepted values
  684. !! - property code -> 'city_apartment', 'parents_home'
  685. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  686. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  687. !! - A number as str -> '1', '2' - this should be the id of the property
  688. !! NOTE: only added in case someone really want to use the old ids
  689. if $ARGS[0] = 'block_access':
  690. $blockcode = iif($ARGS[1] = '', $home_name[$loc], $ARGS[1])
  691. gs 'homes_properties', 'set_access', $blockcode, 0
  692. if accessible_property['accessible_home_count'] = 1 and ($home['current'] = '' or dyneval($is_homeless)):
  693. gs 'homes_properties', 'get_accessible_properties', 'home'
  694. if accessible_property['<<$property_code>>-is-home'] = 1: gs 'homes_properties', 'set_home', $property_code
  695. gs 'homes_properties', 'clean_up_property_data'
  696. elseif accessible_property['accessible_home_count'] < 1:
  697. gs 'homes_properties', 'set_homeless'
  698. end
  699. killvar 'blockcode'
  700. end
  701. !! Call: `func('homes_properties', 'has_access', $ARGS[1])`
  702. !! Returns 0 if Sveta has no access to the property and 1 or -1 if she has access, irrelecant of the type of access
  703. !! - owns the property, rents the property or allowed to stay at the property
  704. !!
  705. !! $ARGS[1]: the location for which the access is set
  706. !! Accepted values
  707. !! - property code -> 'city_apartment', 'parents_home'
  708. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  709. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  710. !! - A number as str -> '1', '2' - this should be the id of the property
  711. !! NOTE: only added in case someone really want to use the old ids
  712. if $ARGS[0] = 'has_access':
  713. $hasaccesscode = iif($ARGS[1] = '', $home_name[$loc], $ARGS[1])
  714. result = accessible_property[$hasaccesscode] > 0 and accessible_property[$hasaccesscode] ! 3
  715. killvar 'hasaccesscode'
  716. end
  717. !!---------------------------------------------------------
  718. !! Buy, rent out and sell properties
  719. !!---------------------------------------------------------
  720. !! Call: `gs 'homes_properties', 'get_property_sales_info', $ARGS[1]`
  721. !! Creates $property_display and property_sales_price for a specific property.
  722. !!
  723. !! $ARGS[1] = the code of the property, e.g. 'city_apartment'
  724. if $ARGS[0] = 'get_property_sales_info':
  725. if $accessible_property[$ARGS[1]] = '' : gs 'homes_properties_attr', 'get_property_attr', $ARGS[1]
  726. if property['construction_needed'] = 1:
  727. $property_display = iif($accessible_property[$ARGS[1]] = '', $property['display_0'], $accessible_property['<<$ARGS[1]>>-display'])
  728. else
  729. $property_display = iif($accessible_property[$ARGS[1]] = '', $property['display'], $accessible_property['<<$ARGS[1]>>-display'])
  730. end
  731. property_sales_price = iif($accessible_property[$ARGS[1]] = '', property['price'], accessible_property['<<$ARGS[1]>>-sales-price'])
  732. killvar 'property'
  733. end
  734. !! Call: `gs 'homes_properties', 'buy_property', $ARGS[1], ARGS[2]`
  735. !! Makes all the necessary changes to the property status, access, etc.
  736. !! and stores the new sales value for future reference in case Sveta sells the property.
  737. !!
  738. !! $ARGS[1] = the code of the property, e.g. 'city_apartment'
  739. !! ARGS[2] = the final sales price in the transaction
  740. if $ARGS[0] = 'buy_property':
  741. gs 'homes_properties', 'set_access', $ARGS[1], 2
  742. accessible_property['<<$ARGS[1]>>-sales-price'] = ARGS[2]
  743. end
  744. !! Call: `gs 'homes_properties', 'sell_property', $ARGS[1], ARGS[2]`
  745. !! Makes all the necessary changes to the property status, access, etc.
  746. !! and stores the new sales value for future reference in case Sveta buys the property back.
  747. !!
  748. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  749. !! ARGS[2] = the final sales price in the transaction
  750. if $ARGS[0] = 'sell_property':
  751. gs 'homes_properties', 'set_access',$ARGS[1], 0
  752. accessible_property['<<$ARGS[1]>>-sales-price'] = ARGS[2]
  753. end
  754. !! Call: gs 'homes_properties', 'tenants_move_in', $ARGS[1], ARGS[2], ARGS[3]
  755. !! Makes the necessary changes to the property to track the tenants.
  756. !!
  757. !! $ARGS[1] - the property code of the home that is rented to tenants
  758. !! ARGS[2] - the tenancy end day
  759. !! ARGS[3] - the tenancy end month
  760. if $ARGS[0] = 'tenants_move_in':
  761. gs 'homes_properties', 'set_access', $ARGS[1], 3
  762. accessible_property['<<$ARGS[1]>>-tenant-day'] = ARGS[2]
  763. accessible_property['<<$ARGS[1]>>-tenant-month'] = ARGS[3]
  764. if $home['current'] = '' and accessible_property['accessible_home_count'] = 1:
  765. gs 'homes_properties', 'get_accessible_properties', 'home'
  766. if accessible_property['<<$property_code>>-is-home']: gs 'homes_properties', 'set_home', $property_code
  767. gs 'homes_properties', 'clean_up_property_data'
  768. end
  769. end
  770. !! Call: gs 'homes_properties', 'tenants_move_out', $ARGS[1]
  771. !! Makes the necessary changes to the property to track the tenants.
  772. !!
  773. !! $ARGS[1] - the property code of the home that was rented to tenants
  774. if $ARGS[0] = 'tenants_move_out':
  775. if $ARGS[1] ! '':
  776. gs 'homes_properties', 'set_access', $ARGS[1], 2
  777. if $home['current'] = '' and accessible_property['<<$ARGS[1]>>-is-home'] = 1 and accessible_property['accessible_home_count'] = 1: gs 'homes_properties', 'set_home', $ARGS[1]
  778. end
  779. end
  780. !! Call: `func('homes_properties', 'tenant_move_out_check')`
  781. !! Returns an array of messages for the tenants that have moved out.
  782. !! Runs every night and sees if any tenants are moving out
  783. !! If the tenants are moving out, the property becomes accessible again
  784. !!
  785. if $ARGS[0] = 'tenant_move_out_check':
  786. count = ARRSIZE('accessible_property')
  787. hp_i = 0
  788. hp_j = 0
  789. if count > 0:
  790. :tenantloop
  791. $tenantcode = $accessible_property[hp_i]
  792. if $home_name[$tenantcode] ! '' and accessible_property[$tenantcode] = 3:
  793. if accessible_property['<<$tenantcode>>-tenant-day'] = day and accessible_property['<<$tenantcode>>-tenant-month'] = month:
  794. gs 'homes_properties', 'set_access', $tenantcode, 2
  795. $result[hp_j] = '<b><font color="red">Your tenants have moved out from your <<$accessible_property[''<<$tenantcode>>-display'']>> and your apartment is now vacant.</font></b>'
  796. hp_j += 1
  797. end
  798. end
  799. hp_i += 1
  800. killvar 'property'
  801. if hp_i < count: jump 'tenantloop'
  802. end
  803. if accessible_property['accessible_home_count'] = 1 and $home['current'] = '':
  804. gs 'homes_properties', 'get_accessible_properties', 'home'
  805. if accessible_property['<<$property_code>>-is-home'] = 1: gs 'homes_properties', 'set_home', $property_code
  806. gs 'homes_properties', 'clean_up_property_data'
  807. end
  808. killvar 'hp_i'
  809. killvar 'hp_j'
  810. killvar 'count'
  811. end
  812. !! Call: `func('homes_properties', 'get_property_sales_price', $ARGS[1])`
  813. !! Returns the actual sales price of the property
  814. !!
  815. !! $ARGS[1] - property code
  816. if $ARGS[0] = 'get_property_sales_price':
  817. if $accessible_property[$ARGS[1]] ! '':
  818. result = accessible_property['<<$ARGS[1]>>-sales-price']
  819. else
  820. gs 'homes_properties_attr', 'get_property_attr', $ARGS[1]
  821. result = property['price']
  822. killvar 'property'
  823. end
  824. end
  825. !!---------------------------------------------------------
  826. !! Create, Update and Cancel Rents and related values
  827. !!---------------------------------------------------------
  828. !! Call: `gs 'homes_properties', 'rent_property', $ARGS[1], ARGS[2]`
  829. !! Rents a property. For now with immediate effect.
  830. !!
  831. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  832. !! ARGS[2] = the number of days the rent is paid for, optional
  833. if $ARGS[0] = 'rent_property':
  834. gs 'homes_properties', 'set_access', $ARGS[1], 1
  835. gs 'homes_properties', 'set_rent_days', $ARGS[1], ARGS[2]
  836. end
  837. !! Call: `gs 'homes_properties', 'cancel_rent', $ARGS[1]`
  838. !! Cancels the rent. For now with immediate effect.
  839. !!
  840. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  841. if $ARGS[0] = 'cancel_rent':
  842. gs 'homes_properties', 'set_access', $ARGS[1], 0
  843. gs 'homes_properties', 'set_rent_days', $ARGS[1], -1
  844. if accessible_property['accessible_home_count'] > 0 and $home['current'] = '':
  845. gs 'homes_properties', 'get_accessible_properties', 'home'
  846. if accessible_property['<<$ARGS[1]>>-is-home'] = 1: gs 'homes_properties', 'set_home', $property_code
  847. gs 'homes_properties', 'clean_up_property_data'
  848. end
  849. end
  850. !! Call: `gs 'homes_properties', 'cancel_rent', $ARGS[1], $ARGS[2]`
  851. !!
  852. !! $ARGS[1] - property code of the rental
  853. !! $ARGS[2] - payment method: 'card' or 'cash'
  854. if $ARGS[0] = 'pay_rent':
  855. if $ARGS[2] = 'card':
  856. karta -= accessible_property['<<$ARGS[1]>>-rent']
  857. elseif $ARGS[2] = 'cash':
  858. money -= accessible_property['<<$ARGS[1]>>-rent']
  859. end
  860. gs 'homes_properties', 'add_rent_days', $ARGS[1]
  861. end
  862. !! Call: `gs 'homes_properties', 'add_rent_days', $ARGS[1], ARGS[2]`
  863. !! Add the number of days passed to the remaining rental days.
  864. !!
  865. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  866. !! ARGS[2] - the number of days to add (can be negative).
  867. !! if the value is 0 then the code will add the number of days equal to the length of the month
  868. if $ARGS[0] = 'add_rent_days':
  869. if ARGS[2] = 0:
  870. accessible_property['<<$ARGS[1]>>-days-left'] += func( 'homes_properties', 'days_in_month')
  871. else
  872. accessible_property['<<$ARGS[1]>>-days-left'] += ARGS[2]
  873. end
  874. end
  875. !! Call: `gs 'homes_properties', 'set_rent_days', $ARGS[1], ARGS[2]`
  876. !! Sets the remaining rental days to a specific amount.
  877. !!
  878. !! $ARGS[1] - the code name of the property, e.g. 'city_apartment'
  879. !! ARGS[2] - the number of days to set to - it is an absolute value
  880. !! If the value is zero, it will be set to the length of the month (ie. 28,29,30 or 31 days)
  881. if $ARGS[0] = 'set_rent_days':
  882. if ARGS[2] = 0:
  883. accessible_property['<<$ARGS[1]>>-days-left'] = func( 'homes_properties', 'days_in_month')
  884. else
  885. accessible_property['<<$ARGS[1]>>-days-left'] = ARGS[2]
  886. end
  887. end
  888. !! Call: `gs 'homes_properties', 'set_rent_amount', $ARGS[1], ARGS[2]`
  889. !! Sets the monthly rent of the property
  890. !!
  891. !! $ARGS[1] - property code
  892. !! ARGS[2] - the new rent amount
  893. if $ARGS[0] = 'set_rent_amount':
  894. if accessible_property['<<$ARGS[1]>>-rental'] and ARGS[2] >= 0 : accessible_property['<<$ARGS[1]>>-rent'] = ARGS[2]
  895. end
  896. !! Call: `func('homes_properties', 'get_rent_days', $ARGS[1])`
  897. !! Returns the remaining rent days for the property
  898. !!
  899. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  900. if $ARGS[0] = 'get_rent_days':
  901. result = accessible_property['<<$ARGS[1]>>-days-left']
  902. end
  903. !! Call: `func('homes_properties', 'get_rent_amount', $ARGS[1])`
  904. !! Returns the monthly rent of the property
  905. !!
  906. !! $ARGS[1] - property code
  907. if $ARGS[0] = 'get_rent_amount':
  908. if $accessible_property[$ARGS[1]] ! '':
  909. result = accessible_property['<<$ARGS[1]>>-rent']
  910. else
  911. gs 'homes_properties_attr', 'get_property_attr', $ARGS[1]
  912. result = property['rent']
  913. killvar 'property'
  914. end
  915. end
  916. !! Call: `gs 'homes_properties', 'progress_property_rent_time'`
  917. !! Decreases the number of days left on the lease.
  918. !!
  919. if $ARGS[0] = 'progress_property_rent_time':
  920. gs 'homes_properties', 'get_rented_properties', 1
  921. count = ARRSIZE('property_code')
  922. hp_i = 0
  923. if count > 0:
  924. :progress_property_rent_time_loop
  925. gs 'homes_properties', 'add_rent_days', $property_code[hp_i], -1
  926. hp_i += 1
  927. if hp_i < count: jump 'progress_property_rent_time_loop'
  928. end
  929. killvar 'property_code'
  930. killvar 'count'
  931. killvar 'hp_i'
  932. end
  933. !! Call: `func('homes_properties', 'days_in_month')`
  934. !! Returns the rent the number of days in a give month.
  935. !!
  936. if $ARGS[0] = 'days_in_month':
  937. if monthsend[1] = 0: gs 'time', 'init_monthends'
  938. result = monthsend[month]
  939. end
  940. !!---------------------------------------------------------
  941. !! Construction and Renovation of Properties
  942. !!---------------------------------------------------------
  943. !! Call: `func('homes_properties', 'get_property_construction_status', $ARGS[1])`
  944. !! $ARGS[1] - the property code or location, if empty it will use $loc
  945. if $ARGS[0] = 'get_property_construction_status':
  946. $constrstatcheckpropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  947. result = accessible_property['<<$constrstatcheckpropcode>>-construction-status']
  948. killvar 'constrstatcheckpropcode'
  949. end
  950. !! Call: `func('homes_properties', 'progress_construction_status', $ARGS[1])`
  951. !! $ARGS[1] - the property code or location, if empty it will use $loc
  952. if $ARGS[0] = 'progress_construction_status':
  953. $constrstatpropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  954. if accessible_property['<<$constrstatpropcode>>-construction-status'] < 2: accessible_property['<<$constrstatpropcode>>-construction-status'] += 1
  955. killvar 'constrstatpropcode'
  956. end
  957. !! Call: `func('homes_properties', 'is_property_renovated', $ARGS[1])`
  958. !! $ARGS[1] - the property code or location, if empty it will use $loc
  959. if $ARGS[0] = 'is_property_renovated':
  960. $checkrenpropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  961. result = accessible_property['<<$checkrenpropcode>>-renovated']
  962. killvar 'checkrenpropcode'
  963. end
  964. !! Call: `gs 'homes_properties', 'renovate_property', $ARGS[1], ARGS[2], $ARGS[3]`
  965. !!
  966. !! $ARGS[1] - the property code or location, if empty it will use $loc
  967. !! ARGS[2] - the value of the renovation
  968. !! $ARGS[3] - the part of the property that was renovated - 'bedroom', 'living room', etc. Optional
  969. if $ARGS[0] = 'renovate_property':
  970. $renovatepropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  971. accessible_property['<<$renovatepropcode>>-renovated'] = 1
  972. accessible_property['<<$renovatepropcode>>-renovation-value'] += ARGS[2]
  973. if $ARGS[3] ! '' : $accessible_property['<<$renovatepropcode>>-renovations'] += ';<<$ARGS[3]>>'
  974. killvar '$renovatepropcode'
  975. end
  976. !!---------------------------------------------------------
  977. !! Go to properties, home, free internet checksm etc.
  978. !!---------------------------------------------------------
  979. !! Call: `gs 'homes_properties', 'go_home'`
  980. !! Takes Sveta to the location where her home can be found
  981. if $ARGS[0] = 'go_home':
  982. if dyneval($is_homeless) or $home['region'] ! $region:
  983. dynamic($train_station[$region])
  984. else
  985. gt $home['location'], $home['location_arg']
  986. end
  987. end
  988. !! Call: `gs 'homes_properties', 'go_straight_home'`
  989. !! Takes Sveta to the entrance of her home
  990. if $ARGS[0] = 'go_straight_home':
  991. if dyneval($is_homeless) or $home['region'] ! $region:
  992. dynamic($train_station[$region])
  993. else
  994. gt $home['entrance'], $home['entrance_arg']
  995. end
  996. end
  997. !! Call: `gs 'homes_properties', 'go_bathroom'`
  998. !! Takes Sveta to the bathroom of the property they are at, or the property passed in $ARGS[1]
  999. !! $ARGS[1] - the property code or location, if empty it will use $loc
  1000. if $ARGS[0] = 'go_bathroom':
  1001. $name = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  1002. gs 'homes_properties_attr', 'get_property_attr', $name
  1003. gt $property['bathroom'], $property['bathroom_arg']
  1004. killvar '$property'
  1005. killvar '$name'
  1006. end
  1007. !! Call: `gs 'homes_properties', 'go_bedroom'`
  1008. !! Takes Sveta to the bedroom of the property they are at, or the property passed in $ARGS[1]
  1009. !! $ARGS[1] - the property code or location, if empty it will use $loc
  1010. if $ARGS[0] = 'go_bedroom':
  1011. $name = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  1012. gs 'homes_properties_attr', 'get_property_attr', $name
  1013. gt $property['bedroom'], $property['bedroom_arg']
  1014. killvar '$property'
  1015. killvar '$name'
  1016. end
  1017. !! Returns 0 if the property doesn''t give free internet access, and 1 or -1 if it does
  1018. !!
  1019. !! Call: func('homes_properties', 'free_internet_available')
  1020. !! $ARGS[1] The location to be checked
  1021. !! Accepted values:
  1022. !! - a property code - 'city_apartment', etc.
  1023. !! - a location - a value that could show up in $loc, like 'bedr' or 'mey_home'
  1024. !! - empty string - in this case the actual $loc value will be used
  1025. if $ARGS[0] = 'free_internet_available':
  1026. gs 'homes_properties_attr', 'get_property_attr', iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  1027. result = property['free_internet'] = 1
  1028. killvar 'property'
  1029. end
  1030. --- homes_properties ---------------------------------