Kirby recently helped me develop a randomised script using either random_range or begin_random. The script was supposed to be for a UI script that randomises the main menu screen every time it loads up by utilising any one of the two script examples he gave me. It seems to be working, but the problem seems to be that it's not being random enough. it keeps returning 2 for random_range at the start and always returns the second script first using begin_random.
I just tested typing random_range 0 5 in halo, EVERY single time I type random_range 0 5 a couple of times then restart halo then type random_range 0 5 a couple of times again it return the exact same pattern that goes:
2
4
2
3
1
4
0
2
2
3
4
0
2
0
1
3
0
4
3
2
1
3
Bungie, I am dissapoint...
UI script that uses random_range:
(global real rnd 0)
(script static unit p0
(unit (list_get (players) 0))
)
(script startup random_ui
(begin
(set rnd (random_range 0 5))
(if
(= rnd 0)
(begin
(fade_in 1 1 1 90)
(camera_set acut1 0)
(sleep 100)
(camera_set acut2 60)
(sleep 30)
(camera_set acut3 90)
)
)
(if
(= rnd 1)
(begin
(fade_in 1 1 1 90)
(camera_set bcut1 0)
(sleep 100)
(camera_set bcut2 60)
(sleep 60)
(camera_set bcut3 90)
)
)
(if
(= rnd 2)
(begin
(fade_in 0 0 0 90)
(camera_set ccut1 0)
(sleep 120)
(camera_set ccut2 60)
(sleep 55)
(camera_set ccut3 90)
(sleep 85)
(camera_set ccut4 90)
)
)
(if
(= rnd 3)
(begin
(fade_in 0 0 0 90)
(camera_set ccut1 0)
(sleep 120)
(camera_set ccut2 60)
(sleep 55)
(camera_set ccut3 90)
(sleep 85)
(camera_set ccut4 90)
)
)
(if
(= rnd 4)
(begin
(fade_in 0 0.5 0.2 90)
(camera_set dcut1 0)
(sleep 120)
(camera_set dcut2 60)
(sleep 60)
(camera_set dcut3 90)
)
)
)
)
UI script that uses begin_random:
(global boolean cnt true)
(script startup random_ui
(set cnt true)
(begin_random
(if cnt
(begin
(set cnt false)
(fade_in 1 1 1 90)
(camera_set acut1 0)
(sleep 100)
(camera_set acut2 60)
(sleep 30)
(camera_set acut3 90)
)
)
(if cnt
(begin
(set cnt false)
(fade_in 1 1 1 90)
(camera_set bcut1 0)
(sleep 100)
(camera_set bcut2 60)
(sleep 60)
(camera_set bcut3 90)
)
)
(if cnt
(begin
(set cnt false)
(fade_in 0 0 0 90)
(camera_set ccut1 0)
(sleep 120)
(camera_set ccut2 60)
(sleep 55)
(camera_set ccut3 90)
(sleep 85)
(camera_set ccut4 90)
)
)
(if cnt
(begin
(set cnt false)
(fade_in 0 0.5 0.2 90)
(camera_set dcut1 0)
(sleep 120)
(camera_set dcut2 60)
(sleep 60)
(camera_set dcut3 90)
)
)
)
)
Kirby's examples:
(global real rnd 0)
(global boolean cnt true)
(script static unit p0
(unit (list_get (players) 0))
)
(script continuous random_stuff_1
(sleep_until (unit_get_current_flashlight_state (p0)) 5)
(unit_set_desired_flashlight_state (p0) 0)
(set rnd (random_range 0 5))
(if (= rnd 0) (sv_say "0")
(if (= rnd 1) (sv_say "1")
(if (= rnd 2) (sv_say "2")
(if (= rnd 3) (sv_say "3")
(if (= rnd 4) (sv_say "4")
(sv_say "Laz0rz")
)))))
)
(script continuous random_stuff_2
(set cnt true)
(begin_random
(if cnt (begin (set cnt false) (sv_say "0")))
(if cnt (begin (set cnt false) (sv_say "1")))
(if cnt (begin (set cnt false) (sv_say "2")))
(if cnt (begin (set cnt false) (sv_say "3")))
(if cnt (begin (set cnt false) (sv_say "4")))
)
)
Any suggestions on how I should randomise my start menu now?
Edited by nihao123456ftw on Jun 10, 2012 at 04:40 AMEdited by nihao123456ftw on Jun 10, 2012 at 05:27 AM