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

  1. //-----
  2. // Aim
  3. //-----
  4. // Aim script - causes the character to aim its current weapon.  Right now it requires 
  5. // that the character stop moving first.  Once we get this working we can think about 
  6. // allowing the characters to fire while moving.
  7.  
  8. //println "aim.scr called"
  9.  
  10. // Initialise say manager
  11. self waitthread anim/SayManager.scr::Init
  12.  
  13. waitexec "anim/default_inithandler.scr"
  14. waitexec anim/smoking.scr::SmokeRemoveCigarette
  15. self weaponcommand mainhand attachtohand mainhand
  16.  
  17. start:
  18.  
  19. self.blendtime = 0.20
  20.  
  21. switch (self.position)
  22. {
  23.     walk:
  24.     run:
  25.     stand:
  26.         switch (self.weapongroup)
  27.         {
  28.             rifle:
  29.                 self setmotionanim (self.weapongroup + "_stand_alert_legs")
  30.                 waitexec anim/aim.scr::PlayAimActionAnim
  31.                 break
  32.             pistol:
  33.             mp40:
  34.             mp44:
  35.             bar:
  36.             thompson:
  37.             bazooka:
  38.                 self setsay face_aiming
  39.                 self setmotionanim (self.weapongroup + "_stand_alert_legs")
  40.                 self setactionanim (self.weapongroup + "_aim") -60 60
  41.                 break
  42.                             
  43.             grenade:
  44.                 self setmotionanim idle_grenade        // Do we need this or should ai just 
  45.                                         // begin the throw after finding a 
  46.                                         // target?
  47.                 break
  48.             
  49.             unarmed:
  50.                 self setmotionanim unarmed_stand_alert_legs
  51.                 break
  52.  
  53.             default:
  54.                 println ("^~^~^ Stand Aim Default case for "+self.weapongroup+" weapon group - fix aim.scr")
  55.                 self setmotionanim unarmed_stand_alert_legs
  56.                 break
  57.         }
  58.         break
  59.  
  60.     crouchwalk:
  61.     crouchrun:
  62.         // For now at least, we need to stop in order to fire
  63.         waitexec anim/crouch.scr::transition
  64.         goto start
  65.         
  66.     crouch:
  67.         switch (self.weapongroup)
  68.         {
  69.             pistol:
  70.             rifle:
  71.             mp40:
  72.             mp44:
  73.             bar:
  74.             thompson:
  75.             bazooka:
  76.                 self setsay face_aiming
  77.                 self.blendtime = 0.5
  78.                 self setmotionanim (self.weapongroup + "_crouch_alert")
  79.                 self setactionanim (self.weapongroup + "_aim") -60 60
  80.                 break
  81.             
  82.             grenade:
  83.                 self setmotionanim grenade_aim_action    // Kinda works... better than I thought 
  84.                                         // it would, this is a standing action 
  85.                                         // blended with a crouch
  86.                 self setmotionanim (self.weapongroup + "_crouch_alert")
  87.                 break
  88.             
  89.             default:
  90.                 println ("^~^~^ Crouch Aim Default case for "+self.weapongroup+" weapon group - fix aim.scr")
  91.                 self setmotionanim rifle_crouch_alert
  92.                 break
  93.         }
  94.         
  95.         break
  96.  
  97.     pronewalk:
  98.         // Can't crawl and fire at the same time
  99.         waitexec anim/prone.scr
  100.         goto start
  101.  
  102.     prone:
  103.         //self.emotion = emotion_aiming
  104.         switch (self.weapongroup)
  105.         {
  106.             pistol:
  107.             rifle:
  108.             mp40:
  109.             mp44:
  110.             bar:
  111.             thompson:
  112.                 self setsay face_aiming
  113.                 self.blendtime = 0.2
  114.                 self setactionanim (self.weapongroup + "_prone_aim") -60 60
  115.                 self setmotionanim (self.weapongroup + "_prone_legs")
  116.                 break
  117.             
  118.             bazooka:
  119.                 // Can't fire the bazooka while lying down
  120.                 waitexec anim/crouch.scr::transition
  121.                 goto start
  122.  
  123.             default:
  124.                 println ("^~^~^ Prone Aim Default case for "+self.weapongroup+" weapon group - fix aim.scr")
  125.                 break
  126.         }
  127.         
  128.         break
  129.  
  130.     knees:
  131.     crawl:
  132.     floor:
  133.         // Incapacitated, can't aim.  Just go on being in pain.
  134.         waitexec anim/continue_pain.scr
  135.         goto start
  136.  
  137.     default:
  138.         // Should never happen
  139.         println ("^~^~^ Aim Default case for "+self.position+" position - fix aim.scr")
  140.         self thread anim/SayManager.scr::SayManager face_aiming 3
  141.         self setmotionanim rifle_crouch_alert
  142.         self setactionanim rifle_aim -60 60
  143.         break
  144. }
  145. wait self.blendtime
  146. end
  147.  
  148.  
  149. //=============================================================
  150. //=============================================================
  151. PlayAimActionAnim:
  152.     
  153.     self.playedhipshootanim = 0
  154.     
  155.     switch (self.weapon)
  156.     {
  157.         case "springfield '03 sniper":
  158.         case "mauser kar 98k":
  159.         case "mauser kar 98d sniper":
  160.             //NOTE: self.hipshootdistance set in default_inithandler.scr
  161.             if (self.distancetoenemy < self.hipshootdistance)
  162.             {
  163.                 self setactionanim kar98_hipaim -60 60
  164.                 self.playedhipshootanim = 1
  165.                 break
  166.             }
  167.             //fall through and play regular anim
  168.         default:
  169.             self setactionanim (self.weapongroup + "_aim") -60 60
  170.             break
  171.     }
  172. end
  173.