randomint help
Moderator: Moderators
randomint help
How do you use the randomint commands to make sound fit something? 
"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.
This keeps the sound from being repetitive everytime a door is opened.
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"
Wahoo I learned something new!
But I was talking about when you associate a sound with an object the sound doesnt fit quite right. Here is what I mean.
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?
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
Is the example I gave correct?
time
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 .
DoorWoodMove_01
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.
$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
Last edited by tltrude on Thu Jul 26, 2007 11:46 pm, edited 1 time in total.
