Page 1 of 1

randomint help

Posted: Wed Jul 25, 2007 9:39 pm
by erick
How do you use the randomint commands to make sound fit something? :D

Posted: Thu Jul 26, 2007 2:40 am
by tltrude
"randomint" is short for "Random Integer". An Integer is, of course, a number. So it really means "random number".

In the ubersound script, you will see sounds that have the same alias name, but with different numbers. If the sound name is called for, without a number, the game will automattally picks one of the numbered sounds at random. Here is an example.

When a wooden door is opened, the door calls for "door_wood_open_move" and the game randomly picks from these four numbered sounds.

Code: Select all

aliascache door_wood_open_move1 sound/mechanics/DoorWoodOpen_01.wav soundparms 1.2 0.2 0.8 0.2 160 1600 item loaded maps "m1 m2 m3l2 m3l3 m4 m5 m6 dm moh obj train"
aliascache door_wood_open_move2 sound/mechanics/DoorWoodOpen_02.wav soundparms 1.2 0.2 0.8 0.2 160 1600 item loaded maps "m1 m2 m3l2 m3l3 m4 m5 m6 dm moh obj train"
aliascache door_wood_open_move3 sound/mechanics/DoorWoodOpen_03.wav soundparms 1.2 0.2 0.8 0.2 160 1600 item loaded maps "m1 m2 m3l2 m3l3 m4 m5 m6 dm moh obj train"
aliascache door_wood_open_move4 sound/mechanics/DoorWoodOpen_04.wav soundparms 1.2 0.2 0.8 0.2 160 1600 item loaded maps "m1 m2 m3l2 m3l3 m4 m5 m6 dm moh obj train"
This keeps the sound from being repetitive everytime a door is opened.

Posted: Thu Jul 26, 2007 3:01 am
by erick
Wahoo I learned something new! :D
But I was talking about when you associate a sound with an object the sound doesnt fit quite right. Here is what I mean.

Code: Select all

$door time 3
$door rotateXup 90
$door playsound ("DoorWoodMove_01" + (randomint(2) + 1))
$door waitmove
I mean how do you get the randomint correct to the right time (of 3 seconds in this case).
Is the example I gave correct?

time

Posted: Thu Jul 26, 2007 3:09 am
by tltrude
The "time" is how long it takes for the door to move. You can't change how long a sound takes to play. So your only option is to change the time -- you can use fractions like 2.5 .

Posted: Thu Jul 26, 2007 2:38 pm
by erick
Why do you put the randomint into the sound then if it doesnt do anything.

DoorWoodMove_01

Posted: Thu Jul 26, 2007 10:53 pm
by tltrude
It is an attempt to manually set which of the numbered sounds are randomly picked. It looks like a mistake to me because the alias name should be "door_wood_open_move". The random stuff is not really needed because the game does it automatically -- if you leave the number off the end of the alias name.

$door playsound door_wood_open_move

Here is how I did my first trap door, but it was before I knew the sound was automatically random. Also, notice that the travel time is set for two seconds.

Code: Select all

//------------------------------------------
// trap_door
//------------------------------------------

trap_door_mover:

$trap_door_trigger waittill trigger
$trap_door time 2
$trap_door playsound ("door_wood_open_move" + (randomint(3) + 1)) 
$trap_door rotateXup 90
$trap_door waitmove
$trap_door playsound door_wood_open_stop
wait 20
$trap_door playsound ("door_wood_close_move" + (randomint(1) + 1))
$trap_door rotateXdown 90
$trap_door waitmove
$trap_door playsound ("door_wood_close_stop" + (randomint(2) + 1))

goto trap_door_mover

end

Posted: Thu Jul 26, 2007 11:46 pm
by erick
Okay! Now I understand. The randomint is to randomly select a sound not to make it longer.