I've started to work on my random number code. Basically it will do three different things. Give each treasure a random description name, then place it in a random location. And also place all the monsters at random too. So far, my initial attempt kind of works, (my first go had them moving about every time you moved!) Except it only seems to move them in blocks of 4 or 5 items to a different room. Once I get this part working, I'll do the names and monsters next using the same code.
900 NAME random_object_locs
910 LOAD_VAR 0,0:LOAD_VAR 1,2:BITTST_LOC 0,1,0:IF_NE 0:RETurn:Remark this part only checks if the initial startup game message has displayed as it only needs to run once per game.
920 LOAD_VAR 2,10:LOAD_VAR 3,10:REMark 10 item loop, 10 into var 2. Parameter 10 for each object holds the location value, 10 into var3
930 IF_EQ 2:RETurn:REMark check if the loop has reached 0 if so, return.
940 RANDOM 1:DIVIDE 1,3855:ADD 1,8:UPDATE_OBJ 2,3,1:SUBTRACT 2,1:GO TO 930
The random number is from -32768 to 32767. Divided by 3855 (65535 / 17 for range of 17 locations) Add 8 (middle of range) (As per Tobias' examples) By default I think ACT always rounds up, no matter the value.
Oops, needed a space to my makeshift debugger, My last run had 10 values, 9 were 14 and 1 was 8. Ran it again, and they scattered all over. I kept running it and started to get 10 sets of 7, then ten sets of 3, then qemulator crashed!