You are not logged in.
Pages: 1
How to make the Random Number.. i only need 1 2 3 4 ...
Like this:
func gmsly104
{
if (sj eq 0)
{
ai2_spawn npc_1
...
}
if (sj eq 1)
{
ai2_spawn npc_2
...
}
if (sj eq 2)
{
ai2_spawn npc_3
...
}
if (sj eq 3)
{
ai2_spawn npc_4
...
}
}
Offline
Take a look at Oni Team Arena: http://wiki.oni2.net/OTA
One part of the script is called random. Perhaps that can help you to generate a random number.
Offline
Thanks ....now i will review my English and look at that
Offline
IIRC, it uses the number of frames since OTA was started. However, that has some flaws, such as multiple characters dieing at once given identical items.
If I ever were to improve OTA like I keep saying I will (not that OTA is mine in the beginning, it is geyser's, but I have permission to improve it ) I will improve that system.
Iritscen:
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours
Offline
Gumby: Can you write a function that will produce random numbers within a certain range, that we can use?
Congrats on your graduation!
Offline
Thanks. Let me double check the OTA script to check that that is indeed how it works.
It will be up tomorrow, I have to leave now.
EDIT: Oh yuck. The current fuction is ugly. But it works. Basically it is a loop. I don't like it, but I can't do anything about it right now. It works well though.
func void RandGen(void) {
rand_cell= rand_cell + 1; if(rand_cell > rand_cell_max) rand_cell= 0;
}
basically, rand_cell is your random number, rand_cell_max is the highest rand_cell can go.
It doesn't work too well if you need to call a whole bunch of the same type of random thing at once.
If I were to make a random function, it would work a bit differently, but I have to go now!
Last edited by Gumby (06/13/08 19:06)
Iritscen:
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours
Offline
func void RandGen(void) {
rand_cell= rand_cell + 1; if(rand_cell > rand_cell_max) rand_cell= 0;
}
maybe we should add a "fork"? like
func void RandGen(void) {
rand_cell= rand_cell + 1; if(rand_cell > rand_cell_max) rand_cell= 0; sleep 1; fork RandGen
}
Offline
func void RandGen(void) {
rand_cell= rand_cell + 1; if(rand_cell > rand_cell_max) rand_cell= 0;
rand_ammo= rand_ammo + 1; if(rand_ammo > rand_ammo_max) rand_ammo= 0;
rand_invis= rand_invis + 1; if(rand_invis > rand_invis_max) rand_invis= 0;
rand_shield= rand_shield + 1; if(rand_shield > rand_shield_max) rand_shield= 0;
rand_dead= rand_dead + 1; if(rand_dead > rand_dead_max) rand_dead= 0;
rand_weapon= rand_weapon + 1; if(rand_weapon > rand_weapon_max) rand_weapon= 0
rand_flag= rand_flag + 1; if(rand_flag > rand_flag_max) rand_flag= 0;
rand_music= rand_music + 1; if(rand_music > rand_music_max) rand_music= 0;
sleep 1; fork RandGen();
}
the full function
And no matter what I try, I can't think of an all purpose random function that can be used multiple times in the same frame and get different answers.
Last edited by Gumby (06/14/08 01:06)
Iritscen:
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours
Offline
Pages: 1