Posted by JM on October 20, 1998 at 21:17:45:
In Reply to: Crashing Cog posted by Nightmare on October 20, 1998 at 19:33:08:
: OK, so I link up this cog in my level. You start out, after a few seconds, you see the "starting" message. Then, as soon as you see the "timer"message, the game crashes and sends you back to the desktop. CogWriter didn't find any errors. Does anyone see anything here that is wrong?
: Nightmare
:
: # Jedi Knight Cog Script
: # dnli_rand_amb.cog
: #
: # Plays a random sound at a random ghost popsition at a random interval
: #
: # 10/20/98 Nightmare
: # This COG is not made or supported by LEC: symbols
: message startup
: message timer: sound sound00
: sound sound01
: sound sound02
: sound sound03
: sound sound04
: sound sound05
: sound sound06
: sound sound07
: sound sound08
: sound sound09: thing ghost00
: thing ghost01
: thing ghost02
: thing ghost03
: thing ghost04
: thing ghost05
: thing ghost06
: thing ghost07
: thing ghost08
: thing ghost09: int numsounds
: int numghosts: flex interval
: flex interval_rand: int soundnum local
: int locationnum local
: end: code
: #==================================================================================================
: startup:
: sleep(5);
: print("starting");
: settimer(interval+(rand()*interval_rand));
: return;: #==================================================================================================
: timer:
: print("timer");
: soundnum = rand()*numsounds;
: locationnum = rand()*numghosts;
: PlaySoundThing(sound[soundnum], ghost[locationnum], 2.0, -1, -1, 0);
: settimer(interval+(rand()*interval_rand));
: return;
: end:
rand gives a rand flex value between 0 and 1... so, say it was 0.5234... * 10.. (num sounds) 5.234... no sound number 5.234. Use ints, and just shuffle it with, say, five sounds and six locations. Each shuffles, +1 each timer, with the say, seven diff intervals, also shuffling. Quite random, patern only repeats ever 210 sounds played.