Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.44 KB | None | 0 0
  1. *Adaptive Metaroom Placement Search by Amaikokonut (naturingnurturing.blogspot.com)
  2. *You are free to modify/build upon this script but please leave the attribution
  3. *intact and allow others to modify/build upon your derivative too!
  4.  
  5. *!* For this test script we are going to inject a clone of the DS hub
  6. *(room structure only, no doors/agents)
  7. *I've tried to mark comments about hub-specific code with the symbol '*!*'
  8. *so if you are adapting this to your own metaroom you can hopefully find the
  9. *room-specific pieces of code and change them without looking too hard.
  10.  
  11. *First we're going to make sure this room hasn't already been injected
  12. *!*We're going to do this by checking to see if the GAME variable "AMP_DS_Hub"
  13. *!*(or whatever name you want to give your metaroom) exists and contains a number
  14. *After sucessful injection this variable will be created and assigned the room number
  15. *so it can easily be referenced later by agents looking for that specific room
  16. *(This also means that AMP rooms can't have an ID of 0 but we'll address that issue later)
  17.  
  18. *checks if the type is an integer (It really always should be but if for some reason
  19. *it's not and we try to run the second check anyway we get errors, so better safe)
  20. doif type game "AMP_DS_Hub" eq 0
  21. doif game "AMP_DS_Hub" > 0
  22. *a number is here, so the room has already been injected
  23. *so we'll just point the camera at the existing room to show the player it's there
  24. *and then stop the script
  25. meta game "AMP_DS_Hub" 0 0 0
  26. stop
  27. endi
  28. endi
  29.  
  30. *otherwise, proceed
  31.  
  32. *!* The DS Hub is 1124px width and 832px tall, those numbers are reflected below:
  33. *VA50, the width of the room you are trying to inject
  34. setv va50 1124
  35. *VA51, the height of the room
  36. setv va51 832
  37.  
  38.  
  39. *VA52, the density of room checks
  40. *(Setting this higher will result in faster checking but runs the risk of missing
  41. *any metarooms smaller than its check and throwing errors)
  42. setv va52 300
  43.  
  44. *va00 and va01 define the x/y point that is currently being checked
  45. setv va00 0
  46. setv va01 0
  47. *va99 is the search status flag:
  48. * 0 = Empty spot not yet found (search in progress)
  49. * 1 = Empty spot found
  50. * 2 = Entire map searched but no empty spot was found (hopefully this won't happen)
  51. setv va99 0
  52. *va98 is another search status flag specified in the roomcheck subroutine
  53.  
  54. *GMAP returns the ID of the metaroom at point x y.
  55. *if there is no metaroom, reports -1
  56. *so basically it needs to report -1 for all checks to be considered
  57. *a viable free space to inject the room.
  58.  
  59. *starting the search loop:
  60. loop
  61. *first see if this va00 (x) and va01 (y) are valid to start from.
  62. doif gmap va00 va01 eq -1
  63. *It's valid, so go on.
  64. gsub roomcheck
  65. *when roomcheck returns it will hold flag va98 containing either 1 or 2
  66. *if va98 is 1, you have found a good spot
  67. doif va98 eq 1
  68. setv va99 1
  69. *if va98 is 2 (or anything else for some reason) it means those startcoords
  70. *didnt work, so run the startcoords routine to find new ones
  71. else
  72. gsub startcoords
  73. endi
  74. else
  75. gsub startcoords
  76. endi
  77.  
  78. untl va99 gt 0
  79.  
  80. *this loop ends when va99 (the search flag) is no longer marked as 'in progress'
  81. *if va99 is 2, there was no empty space found in the entire metaroom system, injection not
  82. *possible (should probably change this later to increase the size of the map
  83. *and try again)
  84. doif va99 eq 2
  85. outs "could not find space"
  86. stop
  87. endi
  88.  
  89. *otherwise, va99 is 1 and we can proceed safely
  90.  
  91. *!*TIME FOR ROOM CREATION! The lot of this is hub-specific.
  92.  
  93. *!* The ORIGINAL code to inject the hub metaroom (found in !map.cos) is:
  94. **************************************************************
  95. * outv addm 2071 8732 1124 832 "SPRITE_CorridorBackdrop004" *
  96. **************************************************************
  97.  
  98. *But this is our NEW, ADAPTIVE way:
  99.  
  100. * a refresher: va00 and va01 are the x/y start coordinates we found with all the
  101. * previous scripts.
  102. * va50/va51 are the width and height (established early on in this file)
  103. *!* We're using the hub-room name for the last argument
  104.  
  105. setv va60 addm va00 va01 va50 va51 "SPRITE_CorridorBackdrop004"
  106.  
  107. *va60 now holds the room number for the new metaroom! We did it!
  108.  
  109. *point your camera at it:
  110. cmra va00 va01 0
  111.  
  112. *Set some gamevars for easy access/reference by agents later on:
  113. *!* Again, these use the hub-name
  114. setv game "AMP_DS_Hub" va60
  115.  
  116. *Not sure if we strictly need these but it sure is easier than parsing MLOC every time.
  117. setv game "AMP_DS_Hub_x" va00
  118. setv game "AMP_DS_Hub_y" va01
  119. setv game "AMP_DS_Hub_w" va50
  120. setv game "AMP_DS_Hub_h" va51
  121.  
  122. *I think having a string with the names of AMP-enabled rooms would be nice to be able to
  123. *call up, and parse as needed, like a named EMID"
  124. *this checks if the string already exists first (type is 2) and adds to it if it is.
  125. *Don't forget the space after the name!
  126. doif type game "AMP_listing" eq 2
  127. adds game "AMP_listing" "AMP_DS_Hub "
  128. *if it's not there, it starts the string itself
  129. else
  130. sets game "AMP_listing" "AMP_DS_Hub "
  131. endi
  132.  
  133. *Okay this is possibly the hard/annoying part for converting: adding rooms
  134. *!*Also pretty much everything from here to the subroutines is hub-specific
  135. *With the 'static' hub it begins adding rooms from the number 600
  136. *We're obviously using adaptively-numbered rooms here so we can't rely on that
  137. *but to make things easier we're going use some temp game variables named
  138. *after the old room names so we know what's what when we are making doors later.
  139.  
  140. *So the ORIGINAL code for the first room in the DS hub (found in !map.cos) is:
  141. ****************************************************
  142. * setv va00 addr 10 2195 2287 8999 8999 9161 9185 *
  143. ****************************************************
  144. * in which the numbers represent the following:
  145. *METAROOM_ID: 10
  146. *X_LEFT: 2195
  147. *X_RIGHT: 2287
  148. *Y_LEFT_CEILING: 8999
  149. *Y_RIGHT_CEILING: 8999
  150. *Y_LEFT_FLOOR: 9161
  151. *Y_RIGHT_FLOOR: 9185
  152.  
  153. *But these assume that the room is starting at the original x/y coords which are:
  154. * 2071, 8732 *
  155.  
  156. *meanwhile we are starting at va00/va01, so we have to do some math.
  157. *First by finding the difference between the coordinates of the original rooms
  158. *Like this:
  159.  
  160. *diff X_LEFT: OLD X_LEFT (2195) - OLD X-coord (2071) = 124
  161. *diff X_RIGHT: OLD X_RIGHT (2287) - OLD X-coord (2071) = 216
  162. *diff Y_LEFT_CEILING: OLD Y_LEFT_CEILING (8999) - OLD Y-coord (8732) = 267
  163. *diff Y_RIGHT_CEILING: OLD Y_RIGHT_CEILING (8999) - OLD Y-coord (8732) = 267
  164. *diff Y_LEFT_FLOOR: OLD Y_LEFT_FLOOR (9161) - OLD Y-coord (8732) = 429
  165. *diff Y_RIGHT_FLOOR: OLD Y_RIGHT_FLOOR (9185) - OLD Y-coord (8732) = 453
  166.  
  167. *Now that we've subtracted the old coord, we're going to re-add our now coords
  168. *(still va00 and va01)
  169.  
  170. *We're going to use va70 (X_LEFT), va71 (X_RIGHT), va72 (Y_LEFT_CEILING),
  171. *va73 (Y_RIGHT_CEILING), va74 (Y_LEFT_FLOOR), and va75 (Y_RIGHT_FLOOR)
  172.  
  173. setv va70 124
  174. addv va70 va00
  175. setv va71 216
  176. addv va71 va00
  177. setv va72 267
  178. addv va72 va01
  179. setv va73 267
  180. addv va73 va01
  181. setv va74 429
  182. addv va74 va01
  183. setv va75 453
  184. addv va75 va01
  185.  
  186. *And now that the calculations are complete, we're finally adding the room
  187. *Remember va60 holds the current metaroom ID
  188. *And again, this is originally room 600, so we're going to make a temp game var
  189. *so we can easily reference later:
  190.  
  191. setv game "AMP_temp_room_600" addr va60 va70 va71 va72 va73 va74 va75
  192.  
  193. *and set the room type same as it's set in the original cosfile (0 - air )
  194. rtyp game "AMP_temp_room_600" 0
  195.  
  196. *Wow, that was a pain. Now we have to repeat this process for the SEVENTEEN OTHER ROOMS
  197. *THAT ARE IN THE DS HUB. Screw this, I'm going to write a python script to do this.
  198.  
  199. **Here are the rest of the rooms after having python do the worst of the work
  200. **Also included, MMSC and RMSC (metaroom music and room music) conversions:
  201.  
  202. *additional room 600 music
  203. setv va70 562
  204. addv va70 va00
  205. setv va71 416
  206. addv va71 va01
  207. mmsc va70 va71 "ds_music.mng\\MetallicChords"
  208. setv va70 170
  209. addv va70 va00
  210. setv va71 360
  211. addv va71 va01
  212. rmsc va70 va71 ""
  213. *room 601
  214. setv va70 216
  215. addv va70 va00
  216. setv va71 313
  217. addv va71 va00
  218. setv va72 267
  219. addv va72 va01
  220. setv va73 267
  221. addv va73 va01
  222. setv va74 453
  223. addv va74 va01
  224. setv va75 460
  225. addv va75 va01
  226. setv game "AMP_temp_room_601" addr va60 va70 va71 va72 va73 va74 va75
  227. rtyp game "AMP_temp_room_601" 0
  228. setv va70 264
  229. addv va70 va00
  230. setv va71 363
  231. addv va71 va01
  232. rmsc va70 va71 ""
  233.  
  234. *room 602
  235. setv va70 313
  236. addv va70 va00
  237. setv va71 410
  238. addv va71 va00
  239. setv va72 267
  240. addv va72 va01
  241. setv va73 267
  242. addv va73 va01
  243. setv va74 460
  244. addv va74 va01
  245. setv va75 464
  246. addv va75 va01
  247. setv game "AMP_temp_room_602" addr va60 va70 va71 va72 va73 va74 va75
  248. rtyp game "AMP_temp_room_602" 0
  249. setv va70 361
  250. addv va70 va00
  251. setv va71 365
  252. addv va71 va01
  253. rmsc va70 va71 ""
  254.  
  255. *room 603
  256. setv va70 410
  257. addv va70 va00
  258. setv va71 503
  259. addv va71 va00
  260. setv va72 267
  261. addv va72 va01
  262. setv va73 267
  263. addv va73 va01
  264. setv va74 464
  265. addv va74 va01
  266. setv va75 453
  267. addv va75 va01
  268. setv game "AMP_temp_room_603" addr va60 va70 va71 va72 va73 va74 va75
  269. rtyp game "AMP_temp_room_603" 0
  270. setv va70 456
  271. addv va70 va00
  272. setv va71 360
  273. addv va71 va01
  274. rmsc va70 va71 ""
  275.  
  276. *room 604
  277. setv va70 503
  278. addv va70 va00
  279. setv va71 613
  280. addv va71 va00
  281. setv va72 267
  282. addv va72 va01
  283. setv va73 267
  284. addv va73 va01
  285. setv va74 453
  286. addv va74 va01
  287. setv va75 453
  288. addv va75 va01
  289. setv game "AMP_temp_room_604" addr va60 va70 va71 va72 va73 va74 va75
  290. rtyp game "AMP_temp_room_604" 0
  291. setv va70 558
  292. addv va70 va00
  293. setv va71 360
  294. addv va71 va01
  295. rmsc va70 va71 "ds_music.mng\\Tremelo"
  296.  
  297. *room 605
  298. setv va70 613
  299. addv va70 va00
  300. setv va71 709
  301. addv va71 va00
  302. setv va72 267
  303. addv va72 va01
  304. setv va73 267
  305. addv va73 va01
  306. setv va74 453
  307. addv va74 va01
  308. setv va75 462
  309. addv va75 va01
  310. setv game "AMP_temp_room_605" addr va60 va70 va71 va72 va73 va74 va75
  311. rtyp game "AMP_temp_room_605" 0
  312. setv va70 661
  313. addv va70 va00
  314. setv va71 364
  315. addv va71 va01
  316. rmsc va70 va71 ""
  317.  
  318. *room 606
  319. setv va70 709
  320. addv va70 va00
  321. setv va71 816
  322. addv va71 va00
  323. setv va72 267
  324. addv va72 va01
  325. setv va73 267
  326. addv va73 va01
  327. setv va74 462
  328. addv va74 va01
  329. setv va75 461
  330. addv va75 va01
  331. setv game "AMP_temp_room_606" addr va60 va70 va71 va72 va73 va74 va75
  332. rtyp game "AMP_temp_room_606" 0
  333. setv va70 762
  334. addv va70 va00
  335. setv va71 364
  336. addv va71 va01
  337. rmsc va70 va71 ""
  338.  
  339. *room 607
  340. setv va70 816
  341. addv va70 va00
  342. setv va71 909
  343. addv va71 va00
  344. setv va72 267
  345. addv va72 va01
  346. setv va73 267
  347. addv va73 va01
  348. setv va74 461
  349. addv va74 va01
  350. setv va75 452
  351. addv va75 va01
  352. setv game "AMP_temp_room_607" addr va60 va70 va71 va72 va73 va74 va75
  353. rtyp game "AMP_temp_room_607" 0
  354. setv va70 862
  355. addv va70 va00
  356. setv va71 359
  357. addv va71 va01
  358. rmsc va70 va71 ""
  359.  
  360. *room 608
  361. setv va70 909
  362. addv va70 va00
  363. setv va71 1006
  364. addv va71 va00
  365. setv va72 267
  366. addv va72 va01
  367. setv va73 267
  368. addv va73 va01
  369. setv va74 452
  370. addv va74 va01
  371. setv va75 430
  372. addv va75 va01
  373. setv game "AMP_temp_room_608" addr va60 va70 va71 va72 va73 va74 va75
  374. rtyp game "AMP_temp_room_608" 0
  375. setv va70 957
  376. addv va70 va00
  377. setv va71 348
  378. addv va71 va01
  379. rmsc va70 va71 "ds_music.mng\\TremeloBleep"
  380.  
  381. *room 609
  382. setv va70 909
  383. addv va70 va00
  384. setv va71 991
  385. addv va71 va00
  386. setv va72 176
  387. addv va72 va01
  388. setv va73 247
  389. addv va73 va01
  390. setv va74 267
  391. addv va74 va01
  392. setv va75 267
  393. addv va75 va01
  394. setv game "AMP_temp_room_609" addr va60 va70 va71 va72 va73 va74 va75
  395. rtyp game "AMP_temp_room_609" 0
  396. setv va70 950
  397. addv va70 va00
  398. setv va71 221
  399. addv va71 va01
  400. rmsc va70 va71 ""
  401.  
  402. *room 610
  403. setv va70 816
  404. addv va70 va00
  405. setv va71 909
  406. addv va71 va00
  407. setv va72 150
  408. addv va72 va01
  409. setv va73 176
  410. addv va73 va01
  411. setv va74 267
  412. addv va74 va01
  413. setv va75 267
  414. addv va75 va01
  415. setv game "AMP_temp_room_610" addr va60 va70 va71 va72 va73 va74 va75
  416. rtyp game "AMP_temp_room_610" 0
  417. setv va70 862
  418. addv va70 va00
  419. setv va71 208
  420. addv va71 va01
  421. rmsc va70 va71 ""
  422.  
  423. *room 611
  424. setv va70 709
  425. addv va70 va00
  426. setv va71 816
  427. addv va71 va00
  428. setv va72 150
  429. addv va72 va01
  430. setv va73 150
  431. addv va73 va01
  432. setv va74 267
  433. addv va74 va01
  434. setv va75 267
  435. addv va75 va01
  436. setv game "AMP_temp_room_611" addr va60 va70 va71 va72 va73 va74 va75
  437. rtyp game "AMP_temp_room_611" 0
  438. setv va70 762
  439. addv va70 va00
  440. setv va71 208
  441. addv va71 va01
  442. rmsc va70 va71 ""
  443.  
  444. *room 612
  445. setv va70 613
  446. addv va70 va00
  447. setv va71 709
  448. addv va71 va00
  449. setv va72 150
  450. addv va72 va01
  451. setv va73 150
  452. addv va73 va01
  453. setv va74 267
  454. addv va74 va01
  455. setv va75 267
  456. addv va75 va01
  457. setv game "AMP_temp_room_612" addr va60 va70 va71 va72 va73 va74 va75
  458. rtyp game "AMP_temp_room_612" 0
  459. setv va70 661
  460. addv va70 va00
  461. setv va71 208
  462. addv va71 va01
  463. rmsc va70 va71 ""
  464.  
  465. *room 613
  466. setv va70 503
  467. addv va70 va00
  468. setv va71 613
  469. addv va71 va00
  470. setv va72 148
  471. addv va72 va01
  472. setv va73 150
  473. addv va73 va01
  474. setv va74 267
  475. addv va74 va01
  476. setv va75 267
  477. addv va75 va01
  478. setv game "AMP_temp_room_613" addr va60 va70 va71 va72 va73 va74 va75
  479. rtyp game "AMP_temp_room_613" 0
  480. setv va70 558
  481. addv va70 va00
  482. setv va71 207
  483. addv va71 va01
  484. rmsc va70 va71 ""
  485.  
  486. *room 614
  487. setv va70 410
  488. addv va70 va00
  489. setv va71 503
  490. addv va71 va00
  491. setv va72 146
  492. addv va72 va01
  493. setv va73 148
  494. addv va73 va01
  495. setv va74 267
  496. addv va74 va01
  497. setv va75 267
  498. addv va75 va01
  499. setv game "AMP_temp_room_614" addr va60 va70 va71 va72 va73 va74 va75
  500. rtyp game "AMP_temp_room_614" 0
  501. setv va70 456
  502. addv va70 va00
  503. setv va71 206
  504. addv va71 va01
  505. rmsc va70 va71 ""
  506.  
  507. *room 615
  508. setv va70 313
  509. addv va70 va00
  510. setv va71 410
  511. addv va71 va00
  512. setv va72 146
  513. addv va72 va01
  514. setv va73 146
  515. addv va73 va01
  516. setv va74 267
  517. addv va74 va01
  518. setv va75 267
  519. addv va75 va01
  520. setv game "AMP_temp_room_615" addr va60 va70 va71 va72 va73 va74 va75
  521. rtyp game "AMP_temp_room_615" 0
  522. setv va70 361
  523. addv va70 va00
  524. setv va71 206
  525. addv va71 va01
  526. rmsc va70 va71 ""
  527.  
  528. *room 616
  529. setv va70 216
  530. addv va70 va00
  531. setv va71 313
  532. addv va71 va00
  533. setv va72 181
  534. addv va72 va01
  535. setv va73 146
  536. addv va73 va01
  537. setv va74 267
  538. addv va74 va01
  539. setv va75 267
  540. addv va75 va01
  541. setv game "AMP_temp_room_616" addr va60 va70 va71 va72 va73 va74 va75
  542. rtyp game "AMP_temp_room_616" 0
  543. setv va70 264
  544. addv va70 va00
  545. setv va71 224
  546. addv va71 va01
  547. rmsc va70 va71 ""
  548.  
  549. *room 617
  550. setv va70 124
  551. addv va70 va00
  552. setv va71 216
  553. addv va71 va00
  554. setv va72 243
  555. addv va72 va01
  556. setv va73 181
  557. addv va73 va01
  558. setv va74 267
  559. addv va74 va01
  560. setv va75 267
  561. addv va75 va01
  562. setv game "AMP_temp_room_617" addr va60 va70 va71 va72 va73 va74 va75
  563. rtyp game "AMP_temp_room_617" 0
  564. setv va70 170
  565. addv va70 va00
  566. setv va71 255
  567. addv va71 va01
  568. rmsc va70 va71 ""
  569. ****************************************************************************
  570. *good lord that was annoying. Note to self: find a way to rewrite this more
  571. *efficiently
  572.  
  573. **And now DOORS
  574. **We stored all the NEW room numbers in variables named after their old room numbers
  575. *just so this part would be easier. The original script sets doors according to their
  576. *room numbers IE:
  577. *door 600 601 100
  578. *door 600 617 100
  579. * So to convert them we just have to call the the variables we set:
  580.  
  581. door game "AMP_temp_room_600" game "AMP_temp_room_601" 100
  582. door game "AMP_temp_room_600" game "AMP_temp_room_617" 100
  583. door game "AMP_temp_room_601" game "AMP_temp_room_602" 100
  584. door game "AMP_temp_room_601" game "AMP_temp_room_616" 100
  585. door game "AMP_temp_room_602" game "AMP_temp_room_603" 100
  586. door game "AMP_temp_room_602" game "AMP_temp_room_615" 100
  587. door game "AMP_temp_room_603" game "AMP_temp_room_604" 100
  588. door game "AMP_temp_room_603" game "AMP_temp_room_614" 100
  589. door game "AMP_temp_room_604" game "AMP_temp_room_605" 100
  590. door game "AMP_temp_room_604" game "AMP_temp_room_613" 100
  591. door game "AMP_temp_room_605" game "AMP_temp_room_606" 100
  592. door game "AMP_temp_room_605" game "AMP_temp_room_612" 100
  593. door game "AMP_temp_room_606" game "AMP_temp_room_607" 100
  594. door game "AMP_temp_room_606" game "AMP_temp_room_611" 100
  595. door game "AMP_temp_room_607" game "AMP_temp_room_608" 100
  596. door game "AMP_temp_room_607" game "AMP_temp_room_610" 100
  597. door game "AMP_temp_room_608" game "AMP_temp_room_609" 100
  598. door game "AMP_temp_room_609" game "AMP_temp_room_610" 100
  599. door game "AMP_temp_room_610" game "AMP_temp_room_611" 100
  600. door game "AMP_temp_room_611" game "AMP_temp_room_612" 100
  601. door game "AMP_temp_room_612" game "AMP_temp_room_613" 100
  602. door game "AMP_temp_room_613" game "AMP_temp_room_614" 100
  603. door game "AMP_temp_room_614" game "AMP_temp_room_615" 100
  604. door game "AMP_temp_room_615" game "AMP_temp_room_616" 100
  605. door game "AMP_temp_room_616" game "AMP_temp_room_617" 100
  606.  
  607.  
  608. *Almost there: Now we just have to make a standard favico!
  609. *I think using "metaroom number + 100" is probably an okay standard for AMP-icons species
  610. *classifier numbers.
  611. *It's high enough not to clash with static C3/DS favicos (afaik) and low enough not to
  612. *interfere in most 3rd party classifiers:
  613.  
  614. setv va61 va60
  615. addv va61 100
  616. new: simp 1 3 va61 "fav_place_corridor" 1 0 1
  617. attr 272
  618. mvto va00 va01
  619. tick 10
  620.  
  621. *One last thing: we're gonna cleanup all the temp gamevars:
  622. delg "AMP_temp_room_600"
  623. delg "AMP_temp_room_601"
  624. delg "AMP_temp_room_602"
  625. delg "AMP_temp_room_603"
  626. delg "AMP_temp_room_604"
  627. delg "AMP_temp_room_605"
  628. delg "AMP_temp_room_606"
  629. delg "AMP_temp_room_607"
  630. delg "AMP_temp_room_608"
  631. delg "AMP_temp_room_609"
  632. delg "AMP_temp_room_610"
  633. delg "AMP_temp_room_611"
  634. delg "AMP_temp_room_612"
  635. delg "AMP_temp_room_613"
  636. delg "AMP_temp_room_614"
  637. delg "AMP_temp_room_615"
  638. delg "AMP_temp_room_616"
  639. delg "AMP_temp_room_617"
  640.  
  641.  
  642. **THE END**
  643.  
  644.  
  645.  
  646. **SUBRS** (You shouldn't have to modify these)
  647. **Finds some empty coords to start with
  648. **va00/va01 are the current candidates for startcoords
  649. **va52 is the room check density (checks for an empty space every va52px)
  650. subr startcoords
  651. *if you're not at the max world x, add va52
  652. doif va00 le mapw
  653. addv va00 va52
  654. *if you are at the max world x, set it to 0 and add va52 to Y
  655. elif va01 le maph
  656. setv va00 0
  657. addv va01 va52
  658. *if you've maxed out both you have a problem, stop and set status flag to 2
  659. elif va00 ge mapw and va01 ge maph
  660. setv va99 2
  661. endi
  662. retn
  663.  
  664. *roomcheck executes after proper startcoords hace been found (va00/va01)
  665. **va52 is the room check density (checks for an empty space every va52px)
  666. **va98 comes up in here too, it's another status flag
  667. ** 0 - So far so good
  668. ** 1 - Everything checks out
  669. ** 2 - Something is in the way (this will return to the main script where it will
  670. ** attempt to find new startcoords and try again)
  671. subr roomcheck
  672. *so in this you have to check 0 0, 0 va52, 0 va52 + va52, then va52 0, va52 va52,
  673. *va52 va52 + va52, etc etc...
  674. setv va02 va00
  675. setv va03 va01
  676. *va02 and 03 are going to be your little "tester" x/y
  677. setv va04 va02
  678. setv va05 va03
  679. addv va04 va50
  680. addv va05 va51
  681. *va04 and va05 are your bottom-right coords, the endpoints.
  682. *found by adding your start coords to the height/width of the room
  683. *go ahead and make sure those are valid too before starting...
  684. doif gmap va04 va05 eq -1 and va04 lt mapw and va05 lt maph
  685. setv va98 0
  686. *If your start and end points are both valid, start the loop to check
  687. *everything in between.
  688. loop
  689. *check validity
  690.  
  691. doif gmap va02 va03 eq -1
  692. *now, how are the x's?
  693. doif va02 lt va04
  694. *add va52 to the x
  695.  
  696. addv va02 va52
  697. *now, have you checked all the x's but not all the y's?
  698. elif va02 ge va04 and va03 lt va05
  699.  
  700. *add va52 to the y, and reset the x
  701. setv va02 va00
  702. addv va03 va52
  703. *have you checked them all?
  704. elif va02 ge va04 and va03 ge va05
  705.  
  706. *Success!
  707. setv va98 1
  708.  
  709. endi
  710. else
  711. *if it didn't check out, you'll have to start again.
  712. setv va98 2
  713.  
  714. endi
  715. untl va98 gt 0
  716.  
  717. else
  718. setv va98 2
  719. endi
  720. retn
  721.  
  722. **REMOVE SCRIPT TO BE ADDED (I'm tired right now and want to get this posted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement