View Single Post
  #2  
Old 06-13-2007, 04:34 AM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

assuming rand/srand dont work, you can do something like create "global variables" in the perl script of the
quest, something like:

Code:
$SEED = int( $npc->GetX() );
$NUMBER_OF_PHRASES = 7;
and then have a method like:

Code:
sub
generateRandom
{
    $SEED += int( $npc->GetX() );
    $SEED %= $NUMBER_OF_PHRASES;
    return $SEED;
}
and then you can do:

Code:
sub
EVENT_AGGRO
{
    quest::say( $PHRASE[ &generateRandom ] );
}
its not a perfect random number generator, but it should offer you a bootstrap until you can wire up a better random generator. you can try using srand/rand, but i do not know if they are exposed to the quest engine. you will have to redefine the phrases as an array for this (in either case) to work:

Code:
@PHRASE = 
(
    "phrase 1",
    "phrase 2", 
   # etc.
);
== sfisque

Last edited by sfisque; 06-13-2007 at 12:39 PM..
Reply With Quote