temnix Posted September 30, 2021 Share Posted September 30, 2021 GET_OFFSET_ARRAY is a handy function, but it doesn't want to consider the randomness I'm building in. Here is how I'm patching regions: COPY_EXISTING ~SW1_#.ARE~ ~override~ GET_OFFSET_ARRAY "region" ARE_V10_REGIONS PHP_EACH "region" AS "ind" => "region_offset" BEGIN READ_SHORT ("%region_offset%" + 32) "type" PATCH_IF type = 1 THEN BEGIN WRITE_ASCII ("%region_offset%") ~Garbled text~ SET garbled = RANDOM (1 12) PATCH_IF garbled = 1 THEN BEGIN SAY ("%region_offset%" + 100) @1 END PATCH_IF garbled = 2 THEN BEGIN SAY ("%region_offset%" + 100) @2 END And so on. This code is supposed to randomize the text on signs in the area. But they all get the first entry. It looks like I need to clear memory here somewhere, with CLEAR_ARRAY, maybe. But where to put it? Quote Link to comment
Ardanis Posted October 1, 2021 Share Posted October 1, 2021 I very vaguely recall that you need RANDOM_SEED (?) put in somewhere to get RANDOM to be actually random. Quote Link to comment
temnix Posted October 1, 2021 Author Share Posted October 1, 2021 Not normally. If I were randomizing some one variable, I would just use RANDOM as written, and the code inserts the right references depending on what is rolled. I finish with an END this bit of patching and start RANDOM again for the next PATCH_IF. I've done this many times. Here is how I'm randomizing doors to accept one of the three key items I made half of the time. I don't see a difference here, unless it's because above I'm putting in @TRA references, and those need to be forgotten in-between somehow? GET_OFFSET_ARRAY "doors" ARE_V10_DOORS PHP_EACH "doors" AS "ind" => "door_offset" BEGIN READ_ASCII ("%door_offset%") "door_name" READ_LONG ("%door_offset%" + 40) "flags" READ_ASCII ("%door_offset%" + 120) "key" PATCH_IF ((~%flags%~ & BIT1) == BIT1) & ((~%flags%~ & BIT6) == BIT6) & (~%key%~ STRING_EQUAL_CASE ~~) & !((~%area%~ STRING_EQUAL_CASE ~AR1100~) & (~%door_name%~ STRING_EQUAL_CASE ~Door1113~)) & !((~%area%~ STRING_EQUAL_CASE ~BG1100~) & (~%door_name%~ STRING_EQUAL_CASE ~Door1113~)) THEN BEGIN SET randomtry = RANDOM (1 6) PATCH_IF randomtry = 1 THEN BEGIN WRITE_ASCII ("%door_offset%" + 120) ~KEYA_#~ END PATCH_IF randomtry = 2 THEN BEGIN WRITE_ASCII ("%door_offset%" + 120) ~KEYB_#~ END PATCH_IF randomtry = 3 THEN BEGIN WRITE_ASCII ("%door_offset%" + 120) ~KEYC_#~ END END Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.