home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / anim / saymanager.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  1.5 KB  |  50 lines

  1. //=============================================================
  2. // Init - initializes variables for the SayManager
  3. Init:
  4.     if ( (self.saying == NIL) || (self.saying == NULL) )
  5.     {
  6.         self.saying = 0
  7.         self.sayimportance = 0
  8.         self.silent = 0
  9.     }
  10. end
  11.  
  12. //=============================================================
  13. // SayManager - keeps track of what I'm trying to say and what is more important
  14. // Importance is on a scale of 1 to 10 by convention (ie, it's not enforced)
  15. SayManager local.sayanimation local.sayimportance:
  16.  
  17.     //thread anim/attack.scr::DPrintln "Trying to say " local.sayanimation " (importance " local.sayimportance ")"
  18.     // check if I'm in the waiting state or if the new line is important enough to interrupt
  19.     if ( (self.silent == 0) && ( self.saying == 0 || local.sayimportance > self.sayimportance ) )
  20.     {
  21.         //thread anim/attack.scr::DPrintln "   Say successful"
  22.         // Leave the waiting state
  23.         self.saying = 1
  24.         self.sayimportance = local.sayimportance
  25.         if ( (self.saymanager != NIL) && (self.saymanager != NULL) )
  26.         {
  27.             self.saymanager end
  28.         }
  29.         self.saymanager = local
  30.  
  31.         // Say the line
  32.         self setsay local.sayanimation
  33.  
  34.         // Wait until we finish saying this line
  35.         //self waittill saydone
  36.         wait 1
  37.         thread anim/attack.scr::DPrintln "Say animation " local.sayanimation " finished!"
  38.  
  39.         // Return to the waiting state
  40.         if ( isAlive self )
  41.             self.saying = 0
  42.     }
  43.     else
  44.     {
  45.         thread anim/attack.scr::DPrintln "   Say failed (old animation had importance of " self.sayimportance ")"
  46.         waitframe
  47.     }
  48. end
  49.  
  50.