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

  1. //-----
  2. // Attack
  3. //-----
  4.  
  5. //=============================================================
  6. //=============================================================
  7. AttackMain:
  8.  
  9. //    if ( self.lastattacktime == NIL )
  10. //        self.lastattacktime = level.time
  11. //    println "~~~~~~~~~~~~~ " self.targetname " in AttackMain, last is " (level.time - self.lastattacktime) " ~~~~~~~~~~~~~~~~~~~~~~"
  12. //    self.lastattacktime = level.time
  13.     // boonDebug sets whether or not to print debug messages from this script.
  14.     //level.boonDebug = 1
  15.  
  16.     //thread DPrintln "Attack main called"
  17.     waitexec anim/smoking.scr::SmokeRemoveCigarette
  18.     waitexec anim/reload.scr::ReloadInit
  19.     self weaponcommand mainhand attachtohand mainhand
  20.  
  21.     //defines
  22.     if ( level.aiattackshortrange != NIL )
  23.         self.shortrange = level.aiattackshortrange
  24.     else
  25.         self.shortrange = 150
  26.  
  27.     if ( level.aiattackmediumrange != NIL )
  28.         self.mediumrange = level.aiattackmediumrange
  29.     else
  30.         self.mediumrange = 650
  31.  
  32.     if ( level.aipronedistance != NIL )
  33.         self.pronedistance = level.aipronedistance
  34.     else
  35.         self.pronedistance = 850
  36.  
  37.     if ( self.aipronechance == NIL )
  38.     {
  39.         if ( level.aipronechance != NIL )
  40.             self.aipronechance = level.aipronechance
  41.         else
  42.             self.aipronechance = 25
  43.     }
  44.  
  45.     if ( self.aicrouchchance == NIL )
  46.     {
  47.         if ( level.aicrouchchance != NIL )
  48.             self.aicrouchchance = level.aicrouchchance
  49.         else
  50.             self.aicrouchchance = 60
  51.     }
  52.  
  53.     if ( self.aicrouchpronechance == NIL )
  54.         waitexec anim/attack.scr::AttackRandomizeCrouchProne
  55.  
  56.     if ( self.ainocrouch == NIL )
  57.         self.ainocrouch = 0
  58.     if ( self.ainoprone == NIL )
  59.         self.ainoprone = 0
  60.     if ( self.ainododge == NIL )
  61.         self.ainododge = 0
  62.     if ( self.ainostrafe == NIL )
  63.         self.ainostrafe = 0
  64.     if ( self.ainocrouchdodge == NIL )
  65.         self.ainocrouchdodge = 0
  66.     if ( self.ainopronedodge == NIL )
  67.         self.ainopronedodge = 0
  68.     if ( self.ainointerval == NIL )
  69.         self.ainointerval = 0
  70.     if ( self.ainohopforward == NIL )
  71.         self.ainohopforward = 0
  72.     if ( self.ainohopbackward == NIL )
  73.         self.ainohopbackward = 0
  74.  
  75.     self.dist_walkforward = 110
  76.     self.dist_walkbackward = 90
  77.     self.dist_walkleft = 80
  78.     self.dist_walkright = 80
  79.     self.dist_dodgeleft = 70
  80.     self.dist_dodgeright = 70
  81.     self.dist_crouchleft = 15
  82.     self.dist_crouchright = 15
  83.     self.dist_prone_roll_left = 30
  84.     self.dist_prone_roll_right = 30
  85.  
  86.     //attack parameters default value - set based on distance below
  87.  
  88.     //percent chance of dodging (while player is not aiming at me)
  89.     self.dodgepct = 50
  90.     //percent chance of moving forward
  91.     self.aggresiveness = 10
  92.     //percent chance of backing away
  93.     self.backawaypct = 90
  94.     //percent chance of doing a strafe during dodge - should really be name self.strafedodgepct
  95.     self.strafepct = 20
  96.     //percent chance of shooting while dodging - should really be named self.dodgeshootpct
  97.     self.shootpct = 100
  98.     //boolean whether to dodege when player is aiming at me
  99.     self.aimdodge = 1
  100.     //amount of time to spend aiming before shooting
  101.     self.aimtime = 1
  102.  
  103.     self.enemyaimingme = 0
  104.     self.collideresult = 0
  105.     self.movedtointervaldir = 0
  106.     self.movingtointervaldir = 0
  107.     self.needreload = 0
  108.     self.lastmovement = "none"
  109.     group.subthread = NULL
  110.  
  111.     // Initialise say manager
  112.     self waitthread anim/SayManager.scr::Init
  113.  
  114.     // Now say something aggressive
  115.     if ( (self.nextsayattack == NULL) || (self.nextsayattack == NIL) || (level.time > self.nextsayattack) )
  116.     {
  117.         self.nextsayattack = level.time + randomint 3 + 4
  118.         //thread DPrintln "=================Saying attack line====================="
  119.         if (self.team == "german")
  120.         {
  121.             //self setsay ("den_head_attack_" + self.voicetype)
  122.             self thread anim/SayManager.scr::SayManager ("den_head_attack_" + self.voicetype) 7
  123.         }
  124.         else
  125.         {
  126.             // Friendlies shouldn't say attack sounds as often as enemies, since they're speaking a language most of
  127.             // our market can understand.
  128.             if ( (randomint 100) > 50 )
  129.             {
  130.                 self thread anim/SayManager.scr::SayManager ("dfr_head_attack_" + self.voicetype) 7
  131.             }
  132.         }
  133.     }
  134.  
  135.     while (1)
  136.     {
  137.         waitexec anim/default_inithandler.scr
  138.  
  139.         //get distance
  140.         local.distance = self.distancetoenemy
  141.         if (local.distance > self.mediumrange)
  142.         {
  143.             //long range attack
  144.             waitexec anim/attack.scr::AttackLongRangeStart
  145.         }
  146.         else if (local.distance > self.shortrange)
  147.         {
  148.             //medium range attack
  149.             waitexec anim/attack.scr::AttackMediumRangeStart
  150.         }
  151.         else
  152.         {
  153.             //we must be in short range
  154.             waitexec anim/attack.scr::AttackShortRangeStart
  155.         }
  156.  
  157.         waitexec anim/attack.scr::AttackDeleteSubThread
  158.     }
  159.  
  160. end
  161.  
  162. //=============================================================
  163. //=============================================================
  164. AttackDeleteSubThread:
  165.     if (group.subthread != NIL)
  166.     {
  167.         if (group.subthread != NULL)
  168.         {
  169.             group.subthread delete
  170.         }
  171.     }
  172. end
  173.  
  174. //=============================================================
  175. //=============================================================
  176. AttackShortRangeStart:
  177.     switch (self.weapongroup)
  178.     {
  179.         case rifle:
  180.         case pistol:
  181.             self.dodgepct = 10
  182.             self.aggresiveness = 0
  183.             self.backawaypct = 90
  184.             self.strafepct = 50
  185.             self.shootpct = 100
  186.             self.aimdodge = 1
  187.             self.aimtime = 0.20
  188.             break
  189.         case bazooka:
  190.             //bazooka guys should never get here but just in case
  191.             self.dodgepct = 10
  192.             self.aggresiveness = 0
  193.             self.backawaypct = 100
  194.             self.strafepct = 100
  195.             self.shootpct = 0
  196.             self.aimdodge = 1
  197.             self.aimtime = 1
  198.             break
  199.         default:
  200.             self.dodgepct = 80
  201.             self.aggresiveness = 0
  202.             self.backawaypct = 20
  203.             self.strafepct = 75
  204.             self.shootpct = 100
  205.             self.aimdodge = 1
  206.             self.aimtime = 0.20
  207.             break
  208.     }
  209.  
  210.     self.instandshoot = 0
  211.     self.movedtointervaldir = 0
  212.     self.movingtointervaldir = 0
  213.     self.inreload = 0
  214.  
  215.     thread AttackMediumRange
  216.     local.mythread = parm.previousthread
  217.  
  218.     while(1)
  219.     {
  220.         // this wait moved from bottom of loop to avoid running the same thread twice in a frame.
  221.         waitframe
  222.  
  223.         local.distance = self.distancetoenemy
  224.         if ( (local.distance > self.shortrange) && (self.inreload == 0) && (self.movingtointervaldir == 0) )
  225.         {
  226.             break
  227.         }
  228.  
  229.         if ( (local.distance < self.reallyshortrange) && (self.weapongroup != bazooka) && (self.inreload == 0) && (self.movingtointervaldir == 0) )
  230.         {
  231.             self.instandshoot = 0
  232.             
  233.             local.mythread delete
  234.             waitexec anim/attack.scr::AttackDeleteSubThread
  235.  
  236.             waitexec anim/attack.scr::AttackReallyShortRange
  237.             thread AttackMediumRange
  238.             local.mythread = parm.previousthread
  239.         }
  240.     }
  241.  
  242.     local.mythread delete
  243.     waitexec anim/attack.scr::AttackDeleteSubThread
  244. end
  245.  
  246. //=============================================================
  247. //=============================================================
  248. AttackMediumRangeStart:
  249.     //thread DPrintln "Calling medium range start"
  250.     switch (self.weapongroup)
  251.     {
  252.         case rifle:
  253.             self.dodgepct = 30
  254.             self.aggresiveness = 5
  255.             self.backawaypct = 50
  256.             self.strafepct = 50
  257.             self.shootpct = 100
  258.             self.aimdodge = 1
  259.             self.aimtime = 0.30
  260.             break
  261.         case pistol:
  262.             self.dodgepct = 35
  263.             self.aggresiveness = 5
  264.             self.backawaypct = 50
  265.             self.strafepct = 8
  266.             self.shootpct = 100
  267.             self.aimdodge = 1
  268.             self.aimtime = 0.30
  269.             break
  270.         case bazooka:
  271.             //bazooka guys should never get here but just in case
  272.             self.dodgepct = 30
  273.             self.aggresiveness = 0
  274.             self.backawaypct = 85
  275.             self.strafepct = 100
  276.             self.shootpct = 0
  277.             self.aimdodge = 1
  278.             self.aimtime = 1.5
  279.             break
  280.         default:
  281.             self.dodgepct = 50
  282.             self.aggresiveness = 50
  283.             self.backawaypct = 25
  284.             self.strafepct = 65
  285.             self.shootpct = 100
  286.             self.aimdodge = 1
  287.             self.aimtime = 0.30
  288.             break
  289.     }
  290.  
  291.     thread AttackMediumRange
  292.     local.mythread = parm.previousthread
  293.  
  294.     self.instandshoot = 0
  295.     self.movedtointervaldir = 0
  296.     self.movingtointervaldir = 0
  297.     self.inreload = 0
  298.  
  299.     while(1)
  300.     {
  301.         local.distance = self.distancetoenemy
  302.         if ( (local.distance > self.mediumrange || local.distance < self.shortrange) && (self.inreload == 0) && (self.movingtointervaldir == 0) )
  303.         {
  304.             break
  305.         }
  306.  
  307.         if ( (self.instandshoot == 1) && (self.inreload == 0) && (self.movingtointervaldir == 0) )
  308.         {
  309.             waitexec anim/attack.scr::AttackIsEnemyAimingAtMe
  310.  
  311.             if (self.enemyaimingme > 0)
  312.             {
  313. // TODO (Boon) Perhaps play panic face here?
  314.                 waitexec anim/attack.scr::AttackCheckLeft self.dist_walkleft
  315.                 if (self.collideresult == 0)
  316.                 {
  317.                     waitexec anim/attack.scr::AttackCheckRight self.dist_walkright
  318.                 }
  319.  
  320.                 if (self.collideresult > 0)
  321.                 {
  322.                     //thread DPrintln "calling dodge"
  323.                     self.instandshoot = 0
  324.  
  325.                     local.mythread delete
  326.                     waitexec anim/attack.scr::AttackDeleteSubThread
  327.  
  328.                     waitexec anim/attack.scr::AttackStandDodge
  329.                     thread AttackMediumRange
  330.                     local.mythread = parm.previousthread
  331.                 }
  332.             }
  333.         }
  334.  
  335.         waitframe
  336.     }
  337.  
  338.     local.mythread delete
  339.     waitexec anim/attack.scr::AttackDeleteSubThread
  340.     //group delete
  341. end
  342.  
  343. //=============================================================
  344. //=============================================================
  345. AttackLongRangeStart:
  346.     //thread DPrintln "long range"
  347.     if (self.weapongroup == bazooka)
  348.     {
  349.         self.dodgepct = 10
  350.         self.aggresiveness = 0
  351.         self.backawaypct = 5
  352.         self.strafepct = 100
  353.         self.shootpct = 0
  354.         self.aimdodge = 1
  355.         self.aimtime = 1.5
  356.     }
  357.     else
  358.     {
  359.         self.dodgepct = 20
  360.         self.aggresiveness = 10
  361.         self.backawaypct = 5
  362.         self.strafepct = 50
  363.         self.shootpct = 100
  364.         self.aimdodge = 1
  365.         self.aimtime = 0.50
  366.     }
  367.  
  368.     self.instandshoot = 0
  369.     self.movedtointervaldir = 0
  370.     self.movingtointervaldir = 0
  371.     self.inreload = 0
  372.  
  373.     thread AttackLongRange
  374.     local.mythread = parm.previousthread
  375.  
  376.     while(1)
  377.     {
  378.         local.distance = self.distancetoenemy
  379.         if ( (local.distance < self.mediumrange) && (self.inreload == 0) && (self.movingtointervaldir == 0) )
  380.         {
  381.             break
  382.         }
  383.  
  384.         waitframe
  385.     }
  386.  
  387.     if (local.mythread != NULL)
  388.     {
  389.         local.mythread delete
  390.     }
  391.     waitexec anim/attack.scr::AttackDeleteSubThread
  392. end
  393.  
  394. //=============================================================
  395. //=============================================================
  396. AttackReallyShortRange:
  397.     local.distance = self.distancetoenemy
  398.  
  399.     self weaponcommand mainhand attachtohand mainhand
  400.     self setmotionanim (self.weapongroup + "_stand_alert_legs")
  401.     // Note: local.distance returns 0 if I don't have an enemy
  402.     while ( (local.distance > 0) && (local.distance < self.reallyshortrange) )
  403.     {
  404.         waitexec anim/attack.scr::AttackDoMelee
  405.         local.distance = self.distancetoenemy
  406.         self.lastmovement = "stand"
  407.         self interrupt_point
  408.     }
  409. end
  410.  
  411. //=============================================================
  412. //=============================================================
  413. AttackDoMelee:
  414.     self.blendtime = 0.25
  415.     self thread anim/SayManager.scr::SayManager face_hit 5
  416.     self playsound rifle_whip
  417.     self setupperanim (self.weapongroup + "_butt")
  418.     wait 0.38
  419. // can't make AI unkillable this way        self.enemy normal_damage 25
  420.     if ( self.enemy != $player )
  421.         self.enemy damage self 75 self (0 0 0) (0 0 0) (0 0 0) 1 9 0 0
  422.     else
  423.     {
  424.         local.dir = $player.origin - self.origin;
  425.         self.enemy damage self 75 self (0 0 0) local.dir (0 0 0) 1 9 0 0
  426.     }
  427.     self playsound rifle_hit
  428.     self waittill upperanimdone
  429. end
  430.  
  431. //=============================================================
  432. //=============================================================
  433. AttackMediumRange:
  434.     //thread DPrintln "calling attack medium range"
  435.     switch (self.weapongroup)
  436.     {
  437.         rifle:
  438.         mp40:
  439.         mp44:
  440.         bar:
  441.         thompson:
  442.         pistol:
  443.         bazooka:
  444.             waitexec anim/attack.scr::AttackStandUp
  445.             while (1)
  446.             {
  447.                 waitexec anim/attack.scr::AttackStandMoveToIntervalDir
  448.                 waitexec anim/attack.scr::AttackStandDodge
  449.                 //waitexec anim/attack.scr::AttackStand
  450.             }
  451.             break
  452.  
  453.         grenade:
  454.         mg42:
  455.         generic:
  456.         unarmed:
  457.         handler:
  458.         dog:
  459.         default:
  460.             println ("^~^~^ Attack medium range default case for "+self.weapongroup+" weapon group - fix attack.scr")
  461.             break
  462.     }
  463. end
  464.  
  465. //=============================================================
  466. //=============================================================
  467. AttackStand:
  468.     if (self.needreload == 1)
  469.     {
  470.         waitexec anim/reload.scr::Reload 0
  471.     }
  472.     else
  473.     {
  474.         self.playedreloadanim = 0
  475.         self.playedrechamberanim = 0
  476.     }
  477.  
  478.     self.instandshoot = 1
  479.     self weaponcommand mainhand attachtohand mainhand
  480.  
  481.     waitexec anim/shoot.scr::CanShoot
  482.  
  483.     if (self.canshoot == 1)
  484.     {
  485.         if (self.lastmovement != stand)
  486.         {
  487.             self.blendtime = 0.20
  488.             self thread anim/SayManager.scr::SayManager face_aiming 3
  489.             self setmotionanim (self.weapongroup + "_stand_alert_legs")
  490.             //self setactionanim (self.weapongroup + "_aim") -60 60
  491.             waitexec anim/aim.scr::PlayAimActionAnim
  492.             wait self.aimtime
  493.         }
  494.  
  495.         waitexec anim/shoot.scr::CanShoot
  496.  
  497.         if (self.canshoot == 1)
  498.         {
  499.             //self.blendtime = 0.05
  500.             self thread anim/SayManager.scr::SayManager face_attack 5
  501.  
  502.             self setmotionanim (self.weapongroup + "_stand_alert_legs")
  503.             //self setactionanim (self.weapongroup + "_shoot") -60 60
  504.             waitexec anim/shoot.scr::PlayShootActionAnim
  505.             self waittill upperanimdone
  506.             self.needreload = 1
  507.             //so that we don't get interrupted
  508.             self.instandshoot = 0
  509.             waitexec anim/reload.scr::Reload 1 0
  510.         }
  511.         else
  512.         {
  513.             //println "~^~^~^AttackStand can't shoot after aim!"
  514.             if (self.lastmovement == stand)
  515.             {
  516.                 //just aim if we can't shoot
  517.                 self.blendtime = 0.20
  518.                 self thread anim/SayManager.scr::SayManager face_aiming 3
  519.                 self setmotionanim (self.weapongroup + "_stand_alert_legs")
  520.                 //self setactionanim (self.weapongroup + "_aim") -60 60
  521.                 waitexec anim/aim.scr::PlayAimActionAnim
  522.                 wait self.aimtime
  523.             }
  524.             else
  525.             {
  526.                 //wait a frame here so that we don't do multiple sight trace
  527.                 //in one frame
  528.                 waitexec anim/aim.scr::PlayAimActionAnim
  529.                 waitframe
  530.             }
  531.         }
  532.         
  533.         self.lastmovement = "stand"
  534.     }
  535.     else
  536.     {
  537. //        println "~^~^~^AttackStand can't shoot!"
  538.         self.needreload = 0
  539.         self.instandshoot = 0
  540.         self.blendtime = 0.30
  541.         self endactionanim
  542.         self setupperanim (self.weapongroup + "_stand_alert")
  543.         self setmotionanim (self.weapongroup + "_stand_alert_legs")
  544.         self.lastmovement = "stand_alert"
  545.         wait self.blendtime
  546.     }
  547.  
  548.     self.instandshoot = 0
  549.     self interrupt_point
  550. end
  551.  
  552. //=============================================================
  553. //=============================================================
  554. AttackStandAndAim:
  555.     if (self.needreload == 1)
  556.     {
  557.         waitexec anim/reload.scr::Reload 0
  558.     }
  559.     else
  560.     {
  561.         self.playedreloadanim = 0
  562.         self.playedrechamberanim = 0
  563.     }
  564.  
  565.     self weaponcommand mainhand attachtohand mainhand
  566.     self.blendtime = 0.30
  567.     self setmotionanim (self.weapongroup + "_stand_alert_legs")
  568.  
  569.     waitexec anim/shoot.scr::CanShoot
  570.     if (self.canshoot)
  571.     {
  572.         //self setactionanim (self.weapongroup + "_aim") -60 60
  573.         waitexec anim/aim.scr::PlayAimActionAnim
  574.         self.lastmovement = "stand"
  575.     }
  576.     else
  577.     {
  578.         //println "~^~^~^AttackStandAndAim can't shoot!"
  579.         self.lastmovement = "stand_alert"
  580.         self setupperanim (self.weapongroup + "_stand_alert")
  581.     }
  582.  
  583.     wait self.blendtime
  584.     self interrupt_point
  585. end
  586.  
  587. //=============================================================
  588. //=============================================================
  589. AttackStandDodge:
  590.     self.instandshoot = 0
  591.  
  592.     local.randnum = randomint 100
  593.     waitexec anim/attack.scr::AttackIsEnemyAimingAtMe
  594.  
  595.     if ( (local.randnum < self.dodgepct) || (self.enemyaimingme > 0) )
  596.     {
  597. // TODO (Boon) Perhaps play panic face here?
  598.         //dodge left or right
  599.         local.randnum = randomint 100
  600.  
  601.         if (local.randnum < 50)
  602.         {
  603.             //strafe left or hop left
  604.             local.randnum = randomint 100
  605.  
  606.             if ( ((local.randnum < self.strafepct) || (self.ainododge != 0) ) && (self.ainostrafe == 0) )
  607.             {
  608.                 waitexec anim/attack.scr::AttackDodgeStrafeLeft 1
  609.             }
  610.             else if ( self.ainododge == 0 )
  611.             {
  612.                 waitexec anim/attack.scr::AttackDodgeLeft 1
  613.             }
  614.             else
  615.             {
  616.                 waitexec anim/attack.scr::AttackStand
  617.             }
  618.         }
  619.         else
  620.         {
  621.             //strafe right or dodge right
  622.             local.randnum = randomint 100
  623.  
  624.             if ( ((local.randnum < self.strafepct) || (self.ainododge != 0) ) && (self.ainostrafe == 0) )
  625.             {
  626.                 waitexec anim/attack.scr::AttackDodgeStrafeRight 1
  627.             }
  628.             else if ( self.ainododge == 0 )
  629.             {
  630.                 waitexec anim/attack.scr::AttackDodgeRight 1
  631.             }
  632.             else
  633.             {
  634.                 waitexec anim/attack.scr::AttackStand
  635.             }
  636.         }
  637.     }
  638.     else
  639.     {
  640.         local.randnum = randomint 100
  641.         if ( (local.randnum < self.aggresiveness) && (self.ainohopforward == 0) )
  642.         {
  643.             waitexec anim/attack.scr::AttackCheckFront self.dist_walkforward
  644.             if (self.collideresult > 0)
  645.             {
  646.                 self.blendtime = 0.25
  647.  
  648.                 self.lastmovement = "walk_forward"
  649.                 waitexec anim/attack.scr::AttackShootInMotion (self.weapongroup + "_walk_alert_forward") 1
  650.  
  651.                 self interrupt_point
  652.             }
  653.             else
  654.             {
  655.                 waitexec anim/attack.scr::AttackStand
  656.             }
  657.         }
  658.         else
  659.         {
  660.             local.randnum = randomint 100
  661.             if ( (local.randnum < self.backawaypct) && (self.ainohopbackward == 0) )
  662.             {
  663.                 waitexec anim/attack.scr::AttackCheckBack self.dist_walkbackward
  664.                 if (self.collideresult > 0)
  665.                 {
  666.                     self.blendtime = 0.25
  667.  
  668.                     self.lastmovement = "walk_backward"
  669.                     waitexec anim/attack.scr::AttackShootInMotion (self.weapongroup + "_walk_alert_back") 2
  670.  
  671.                     self interrupt_point
  672.                 }
  673.                 else
  674.                 {
  675.                     waitexec anim/attack.scr::AttackStand
  676.                 }
  677.             }
  678.             else
  679.             {
  680.                 waitexec anim/attack.scr::AttackStand
  681.             }
  682.         }
  683.     }
  684. end
  685.  
  686. //=============================================================
  687. //=============================================================
  688. AttackDodgeLeft local.oppositedodge:
  689.     waitexec anim/attack.scr::AttackCheckLeft self.dist_dodgeleft
  690.     if (self.collideresult > 0)
  691.     {
  692.         self.blendtime = 0.25
  693.  
  694.         self.lastmovement = "dodge_left"
  695.         
  696.         waitexec anim/attack.scr::AttackShootInMotion (self.weapongroup + "_stand_dodge_left") 3
  697.  
  698.         if (self.needreload == 1)
  699.         {
  700.             waitexec anim/reload.scr::Reload 0
  701.         }
  702.  
  703.         self interrupt_point
  704.  
  705.         //if (self.weapongroup == bazooka && self.playedreloadanim == 0)
  706.         if (self.weapongroup == bazooka)
  707.         {
  708.             waitexec anim/attack.scr::AttackStand
  709.         }
  710.     }
  711.     else
  712.     {
  713.         if (local.oppositedodge > 0)
  714.         {
  715.             //wait a frame so that we don't do multiple trace checks
  716.             waitframe
  717.             waitexec anim/attack.scr::AttackDodgeRight 0
  718.         }
  719.         else
  720.         {
  721.             waitexec anim/attack.scr::AttackStand
  722.         }
  723.     }
  724. end
  725.  
  726. //=============================================================
  727. //=============================================================
  728. AttackDodgeRight local.oppositedodge:
  729.     waitexec anim/attack.scr::AttackCheckRight self.dist_dodgeright
  730.     if (self.collideresult > 0)
  731.     {
  732.         self.blendtime = 0.25
  733.  
  734.         self.lastmovement = "dodge_right"
  735.  
  736.         waitexec anim/attack.scr::AttackShootInMotion (self.weapongroup + "_stand_dodge_right") 4
  737.  
  738.         if (self.needreload == 1)
  739.         {
  740.             waitexec anim/reload.scr::Reload 0
  741.         }
  742.  
  743.         self interrupt_point
  744.  
  745.         //if (self.weapongroup == bazooka && self.playedreloadanim == 0)
  746.         if (self.weapongroup == bazooka)
  747.         {
  748.             waitexec anim/attack.scr::AttackStand
  749.         }
  750.     }
  751.     else
  752.     {
  753.         if (local.oppositedodge)
  754.         {
  755.             //wait a frame so that we don't do multiple trace checks
  756.             waitframe
  757.             waitexec anim/attack.scr::AttackDodgeLeft 0
  758.         }
  759.         else
  760.         {
  761.             waitexec anim/attack.scr::AttackStand
  762.         }
  763.     }
  764. end
  765.  
  766. //=============================================================
  767. //=============================================================
  768. AttackDodgeStrafeRight local.oppositestrafe:
  769.     if ( (self.weapongroup == pistol) || (self.weapongroup == rifle) )
  770.     {
  771.         //local.i = randomint(1) + 1
  772.         local.i = 1
  773.     }
  774.     else
  775.     {
  776.         local.i = randomint(4) + 1
  777.     }
  778.  
  779.     local.j = local.i
  780.  
  781.     while (local.i > 0)
  782.     {
  783.         waitexec anim/attack.scr::AttackCheckRight self.dist_walkright
  784.         if (self.collideresult > 0)
  785.         {
  786.             if ( (self.lastmovement == strafe_left) && (self.playedreloadanim == 0) )
  787.             {
  788.                 //stop first if we strafe right last time around so that the feet won't look funny
  789.                 //thread DPrintln "Standing first before strafing right"
  790.                 waitexec anim/attack.scr::AttackStandAndAim
  791.             }
  792.  
  793.             self.blendtime = 0.25
  794.  
  795.             self.lastmovement = "strafe_right"
  796.  
  797.             waitexec anim/attack.scr::AttackShootInMotion (self.weapongroup + "_walk_alert_right") 5
  798.  
  799.             self interrupt_point
  800.  
  801.             //if (self.weapongroup == bazooka && self.playedreloadanim == 0)
  802.             if (self.weapongroup == bazooka)
  803.             {
  804.                 waitexec anim/attack.scr::AttackStand
  805.             }
  806.         }
  807.         else
  808.         {
  809.             //only strafe the other way if it's the first time
  810.             if ( (local.i == local.j) && (local.oppositestrafe == 1) )
  811.             {
  812.                 //thread DPrintln "Strafing the other way to left"
  813.                 //wait a frame so that we don't do multiple trace checks
  814.                 waitframe
  815.                 waitexec anim/attack.scr::AttackDodgeStrafeLeft 0
  816.             }
  817.             else
  818.             {
  819.                 waitexec anim/attack.scr::AttackStand
  820.             }
  821.  
  822.             break
  823.         }
  824.  
  825.         local.i = local.i - 1
  826.     }
  827. end
  828.  
  829. //=============================================================
  830. //=============================================================
  831. AttackDodgeStrafeLeft local.oppositestrafe:
  832.     if ( (self.weapongroup == pistol) || (self.weapongroup == rifle) )
  833.     {
  834.         //local.i = randomint(1) + 1
  835.         local.i = 1
  836.     }
  837.     else
  838.     {
  839.         local.i = randomint(4) + 1
  840.     }
  841.  
  842.     local.j = local.i
  843.  
  844.     while (local.i > 0)
  845.     {
  846.         waitexec anim/attack.scr::AttackCheckLeft self.dist_walkleft
  847.         if (self.collideresult > 0)
  848.         {
  849.             if ( (self.lastmovement == strafe_right) && (self.playedreloadanim == 0) )
  850.             {
  851.                 //stop first if we strafe right last time around so that the feet won't look funny
  852.                 //thread DPrintln "Standing first before strafing left"
  853.                 waitexec anim/attack.scr::AttackStandAndAim
  854.             }
  855.  
  856.             self.blendtime = 0.25
  857.  
  858.             self.lastmovement = "strafe_left"
  859.  
  860.             waitexec anim/attack.scr::AttackShootInMotion (self.weapongroup + "_walk_alert_left") 6
  861.  
  862.             self interrupt_point
  863.  
  864.             //if (self.weapongroup == bazooka && self.playedreloadanim == 0)
  865.             if (self.weapongroup == bazooka)
  866.             {
  867.                 waitexec anim/attack.scr::AttackStand
  868.             }
  869.  
  870.         }
  871.         else
  872.         {
  873.             //only strafe the other way if it's the first time
  874.             if ( (local.i == local.j) && (local.oppositestrafe == 1) )
  875.             {
  876.                 //thread DPrintln "Strafing the other way to Right"
  877.                 //wait a frame so that we don't do multiple trace checks
  878.                 waitframe
  879.                 waitexec anim/attack.scr::AttackDodgeStrafeRight 0
  880.             }
  881.             else
  882.             {
  883.                 waitexec anim/attack.scr::AttackStand
  884.             }
  885.             break
  886.         }
  887.  
  888.         local.i = local.i - 1
  889.     }
  890. end
  891.  
  892. //=============================================================
  893. //=============================================================
  894. AttackShootInMotion local.animname local.id:
  895.     self weaponcommand mainhand attachtohand mainhand
  896.  
  897.     if (self.needreload == 1)
  898.     {
  899.         waitexec anim/reload.scr::Reload 2
  900.     }
  901.     else
  902.     {
  903.         self.playedreloadanim = 0
  904.         self.playedrechamberanim = 0
  905.     }
  906.  
  907.     self weaponcommand mainhand attachtohand mainhand
  908.  
  909.     local.randnum = randomint 100
  910.     if ( self && self.enemy && (local.randnum < self.shootpct) && (self cansee self.enemy) )
  911.     {
  912.         thread DPrintln "(Boon) Fired without aiming " local.id " - did anything weird happen?"
  913.         self thread anim/SayManager.scr::SayManager face_attack 5
  914.  
  915.         //waitexec anim/shoot.scr::PlayShootActionAnim
  916.         //self setmotionanim local.animname
  917.         //self waittill flaggedanimdone
  918.         //self waittill upperanimdone
  919.         //self.needreload = 1
  920.  
  921.         switch (self.weapon)
  922.         {
  923.             case "springfield '03 sniper":
  924.             case "mauser kar 98k":
  925.             case "mauser kar 98d sniper":
  926.                 //waitexec anim/shoot.scr::PlayShootActionAnim
  927.                 //self setmotionanim local.animname
  928.                 //self waittill flaggedanimdone
  929.                 //self waittill upperanimdone
  930.                 //self.needreload = 1
  931.                 
  932.                 thread AttackShootInMotionThread
  933.                 self setmotionanim local.animname
  934.                 self waittill flaggedanimdone
  935.                 self.needreload = 1
  936.  
  937.                 while (self.shootinmotionanimdone == 0)
  938.                 {
  939.                     waitframe
  940.                 }
  941.                 waitexec anim/attack.scr::AttackDeleteSubThread
  942.                 break
  943.             
  944.             default:
  945.                 //waitexec anim/shoot.scr::PlayShootActionAnim
  946.                 //self setmotionanim local.animname
  947.                 //self waittill flaggedanimdone
  948.                 //self.needreload = 1
  949.                 
  950.                 thread AttackShootInMotionThread
  951.                 self setmotionanim local.animname
  952.                 self waittill flaggedanimdone
  953.                 self.needreload = 1
  954.                 waitexec anim/attack.scr::AttackDeleteSubThread
  955.                 //waitexec anim/aim.scr::PlayAimActionAnim
  956.                 break
  957.         }
  958.  
  959.     }
  960.     else
  961.     {
  962.         self thread anim/SayManager.scr::SayManager face_aiming 3
  963.         self.needreload = 0
  964.         //self setactionanim (self.weapongroup + "_aim") -60 60
  965.         waitexec anim/aim.scr::PlayAimActionAnim
  966.         self setmotionanim local.animname
  967.         self waittill flaggedanimdone
  968.     }
  969. end
  970.  
  971. //=============================================================
  972. //=============================================================
  973. AttackShootInMotionThread:
  974.     group.subthread = local
  975.     self.shootinmotionanimdone = 0
  976.     waitexec anim/shoot.scr::PlayShootActionAnim
  977.     self waittill upperanimdone
  978.     self.shootinmotionanimdone = 1
  979.     waitexec anim/aim.scr::PlayAimActionAnim
  980.     self waittill upperanimdone
  981. end
  982.  
  983. //=============================================================
  984. //=============================================================
  985. AttackLongRange:
  986.     switch (self.weapongroup)
  987.     {
  988.         rifle:
  989.         mp40:
  990.         mp44:
  991.         bar:
  992.         thompson:
  993.         pistol:
  994.         bazooka:
  995.             while (1)
  996.             {
  997.                 waitexec anim/attack.scr::AttackStandMoveToIntervalDir
  998.  
  999.                 local.noprone = 0
  1000.                 local.distance = self.distancetoenemy
  1001.                 if ( (local.distance >= self.pronedistance) && (self.weapongroup != bazooka) && (self.team == german) && (self.aicrouchpronechance < self.aipronechance) )
  1002.                 {
  1003.                     self.collideresult = 0
  1004.                     if (self.position != prone)
  1005.                     {
  1006.                         waitexec anim/attack.scr::AttackCheckProne
  1007.                     }
  1008.  
  1009.                     if ( (self.collideresult > 0) || (self.position == prone) )
  1010.                     {
  1011.                         waitexec anim/attack.scr::AttackProneDown
  1012.                         //if ((self cansee self.enemy) > 0)
  1013.                         //{
  1014.                             waitexec anim/attack.scr::AttackLongRangeProne
  1015.                         //}
  1016.                         //else
  1017.                         //{
  1018.                         //    local.noprone = 1
  1019.                         //}
  1020.                     }
  1021.                     else
  1022.                     {
  1023.                         local.noprone = 1
  1024.                     }
  1025.                 }
  1026.                 else
  1027.                 {
  1028.                     local.noprone = 1
  1029.                 }
  1030.  
  1031.                 local.nocrouch = 0
  1032.  
  1033.                 if ( ((local.distance < self.pronedistance) || (local.noprone == 1)) && (self.aicrouchpronechance < self.aicrouchchance) && (self.aicrouchpronechance > self.aipronechance) )
  1034.                 {
  1035.                     self.collideresult = 0
  1036.                     if (self.position != crouch)
  1037.                     {
  1038.                         waitexec anim/attack.scr::AttackCheckCrouch
  1039.                     }
  1040.  
  1041.                     if ( (self.collideresult > 0) || (self.position == crouch) )
  1042.                     {
  1043.                         waitexec anim/attack.scr::AttackCrouchDown
  1044.                         //if ((self cansee self.enemy) > 0)
  1045.                         //{
  1046.                             waitexec anim/attack.scr::AttackLongRangeCrouch
  1047.                         //}
  1048.                         //else
  1049.                         //{
  1050.                         //    local.nocrouch = 1
  1051.                         //}
  1052.                     }
  1053.                     else
  1054.                     {
  1055.                         local.nocrouch = 1
  1056.                     }
  1057.                 }
  1058.                 else
  1059.                 {
  1060.                     local.nocrouch = 1
  1061.                 }
  1062.  
  1063.  
  1064.                 if ( (local.noprone == 1) && (local.nocrouch == 1) )
  1065.                 {
  1066.                     //can't crouch or prone.. so let's just stand
  1067.                     waitexec anim/attack.scr::AttackStandUp
  1068.                     waitexec anim/attack.scr::AttackLongRangeStand
  1069.                 }
  1070.             }
  1071.             break
  1072.  
  1073.         grenade:
  1074.         mg42:
  1075.         generic:
  1076.         unarmed:
  1077.         handler:
  1078.         dog:
  1079.         default:
  1080.             println ("^~^~^ Attack medium range default case for "+self.weapongroup+" weapon group - fix attack.scr")
  1081.             break
  1082.     }
  1083. end
  1084.  
  1085.  
  1086. //=============================================================
  1087. //=============================================================
  1088. AttackLongRangeStand:
  1089.     waitexec anim/attack.scr::AttackStandMoveToIntervalDir
  1090.     waitexec anim/attack.scr::AttackStandDodge
  1091.     //waitexec anim/attack.scr::AttackStand
  1092. end
  1093.  
  1094. //=============================================================
  1095. //=============================================================
  1096. AttackLongRangeCrouch:
  1097.     waitexec anim/attack.scr::AttackCrouchDodge
  1098.     waitexec anim/attack.scr::AttackCrouch
  1099. end
  1100.  
  1101. //=============================================================
  1102. //=============================================================
  1103. AttackLongRangeProne:
  1104.     waitexec anim/attack.scr::AttackProneDodge
  1105.     waitexec anim/attack.scr::AttackProne
  1106. end
  1107.  
  1108. //=============================================================
  1109. //=============================================================
  1110. AttackCrouch:
  1111.     if (self.weapongroup == bazooka)
  1112.     {
  1113.         waitexec anim/attack.scr::AttackCrouchBazooka
  1114.     }
  1115.     else
  1116.     {
  1117.         self setmotionanim (self.weapongroup + "_crouch_alert")
  1118.  
  1119.         if (self.needreload == 1)
  1120.         {
  1121.             waitexec anim/reload.scr::Reload 1
  1122.         }
  1123.         else
  1124.         {
  1125.             self.playedreloadanim = 0
  1126.             self.playedrechamberanim = 0
  1127.         }
  1128.  
  1129.         self weaponcommand mainhand attachtohand mainhand
  1130.  
  1131.         if (self.lastmovement != crouch)
  1132.         {
  1133.             //aim till we're ready to fire
  1134.             self.blendtime = 0.20
  1135.             self thread anim/SayManager.scr::SayManager face_aiming 3
  1136.             //self setmotionanim (idle_crouch_rifle)
  1137.             self setactionanim (self.weapongroup + "_aim") -60 60
  1138.             //self waittill flaggedanimdone
  1139.             wait self.aimtime
  1140.         }
  1141.  
  1142.         if ( isAlive self )
  1143.         {
  1144.             if ((self cansee self.enemy) > 0)
  1145.             {
  1146.                 self.blendtime = 0.05
  1147.                 self thread anim/SayManager.scr::SayManager face_attack 5
  1148.                 switch (self.weapon)
  1149.                 {
  1150.                     case "springfield '03 sniper":
  1151.                     case "mauser kar 98k":
  1152.                     case "mauser kar 98d sniper":
  1153.                         self setactionanim kar98_shoot -60 60
  1154.                         self waittill upperanimdone
  1155.                         self.needreload = 1
  1156.                         //so that we don't get interrupted
  1157.                         self.instandshoot = 0
  1158.                         waitexec anim/reload.scr::Reload 1 1
  1159.                         break
  1160.                     default:
  1161.                         self setactionanim (self.weapongroup + "_shoot") -60 60
  1162.                         self waittill upperanimdone
  1163.                         self.needreload = 1
  1164.                         //so that we don't get interrupted
  1165.                         self.instandshoot = 0
  1166.                         waitexec anim/reload.scr::Reload 1 0
  1167.                         break
  1168.                 }
  1169.             }
  1170.             else if (self.lastmovement == crouch)
  1171.             {
  1172.                 //Just aim if we can't shoot and did not aim from above
  1173.                 self.blendtime = 0.20
  1174.                 self thread anim/SayManager.scr::SayManager face_aiming 3
  1175.                 //self setmotionanim (idle_crouch_rifle)
  1176.                 self setactionanim (self.weapongroup + "_aim") -60 60
  1177.     //            self waittill upperanimdone
  1178.                 wait self.aimtime
  1179.             }
  1180.         }
  1181.  
  1182.         if ( isAlive self )
  1183.         {
  1184.             self.lastmovement = "crouch"
  1185.             self interrupt_point
  1186.         }
  1187.     }
  1188. end
  1189.  
  1190. //=============================================================
  1191. //=============================================================
  1192. AttackCrouchBazooka:
  1193.     self setmotionanim (self.weapongroup + "_crouch_alert")
  1194.  
  1195.     if (self.needreload == 1)
  1196.     {
  1197.         waitexec anim/reload.scr::Reload 1
  1198.     }
  1199.     else
  1200.     {
  1201.         self.playedreloadanim = 0
  1202.         self.playedrechamberanim = 0
  1203.     }
  1204.  
  1205.     self weaponcommand mainhand attachtohand mainhand
  1206.  
  1207.     //aim till we're ready to fire
  1208.     local.i = 1
  1209.     while (!(self ReadyToFire) || (local.i > 0) )
  1210.     {
  1211.         self.blendtime = 0.30
  1212.         self thread anim/SayManager.scr::SayManager face_aiming 3
  1213.         self setactionanim (self.weapongroup + "_aim") -60 60
  1214. //        self waittill upperanimdone
  1215.         wait self.aimtime
  1216.  
  1217.         local.i = local.i - 1
  1218.     }
  1219.  
  1220.     self.lastmovement = "crouch"
  1221.  
  1222.     if ((self cansee self.enemy) > 0)
  1223.     {
  1224.         self.blendtime = 0.1
  1225.         self thread anim/SayManager.scr::SayManager face_attack 5
  1226.         self setactionanim (self.weapongroup + "_shoot") -60 60
  1227.         self waittill upperanimdone
  1228.         //so that we don't get interrupted
  1229.         self.instandshoot = 0
  1230.         waitexec anim/reload.scr::Reload 1
  1231.     }
  1232.  
  1233.     self interrupt_point
  1234. end
  1235.  
  1236. //=============================================================
  1237. //=============================================================
  1238. AttackProne:
  1239.  
  1240.     self.position = prone
  1241.     if (self.needreload == 1)
  1242.     {
  1243.         waitexec anim/reload.scr::Reload 0
  1244.     }
  1245.     else
  1246.     {
  1247.         self.playedreloadanim = 0
  1248.         self.playedrechamberanim = 0
  1249.     }
  1250.  
  1251.     self weaponcommand mainhand attachtohand mainhand
  1252.  
  1253.     //aim till we're ready to fire
  1254.     local.i = 1
  1255.     //while (!(self ReadyToFire) || local.i > 0)
  1256.     while (local.i > 0)
  1257.     {
  1258.         self.blendtime = 0.20
  1259.         self thread anim/SayManager.scr::SayManager face_aiming 3
  1260.         self setmotionanim (self.weapongroup + "_prone_legs")
  1261.         self setactionanim (self.weapongroup + "_prone_aim") -60 60
  1262. //        self waittill flaggedanimdone
  1263.         wait self.aimtime
  1264.  
  1265.         local.i = local.i - 1
  1266.     }
  1267.  
  1268.     self.lastmovement = "prone"
  1269.  
  1270.     if ((self cansee self.enemy) > 0)
  1271.     {
  1272.         self.blendtime = 0.1
  1273.         self thread anim/SayManager.scr::SayManager face_attack 5
  1274.         self setmotionanim (self.weapongroup + "_prone_legs")
  1275.         self setactionanim (self.weapongroup + "_prone_shoot") -60 60
  1276.         self waittill upperanimdone
  1277.  
  1278.         // Simulate rechamber since we don't have an animation for it
  1279.         if ( (self.weapon == "springfield '03 sniper") || (self.weapon == "mauser kar 98k") || (self.weapon == "mauser kar 98d sniper") )
  1280.         {
  1281.             self setactionanim (self.weapongroup + "_prone_aim") -60 60
  1282.             wait 0.4
  1283.         }
  1284.  
  1285.         self.needreload = 0
  1286.         //so that we don't get interrupted
  1287.         self.instandshoot = 0
  1288.         //per Boon--no reload during prone
  1289.         //waitexec anim/reload.scr::Reload 0
  1290.     }
  1291.  
  1292.     self interrupt_point
  1293. end
  1294.  
  1295. //=============================================================
  1296. //=============================================================
  1297. AttackCrouchDodge:
  1298.  
  1299.     if ( self.ainocrouchdodge != 0 )
  1300.         end
  1301.  
  1302.     local.randnum = randomint 100
  1303.     waitexec anim/attack.scr::AttackIsEnemyAimingAtMe
  1304.  
  1305.     if ( (local.randnum < self.dodgepct) || (self.enemyaimingme > 0) )
  1306.     {
  1307. // TODO (Boon) Perhaps play panic face here?
  1308.         self weaponcommand mainhand attachtohand mainhand
  1309.  
  1310.         local.randnum = randomint 100
  1311.  
  1312.         if (local.randnum < 50)
  1313.         {
  1314.             waitexec anim/attack.scr::AttackCheckLeft self.dist_crouchleft
  1315.             if (self.collideresult > 0)
  1316.             {
  1317.                 self.blendtime = 0.5
  1318.                 self thread anim/SayManager.scr::SayManager face_aiming 3
  1319.                 self setmotionanim (walk_crouch_left)
  1320.                 self setactionanim (self.weapongroup + "_aim") -60 60
  1321.                 self waittill flaggedanimdone
  1322.                 self.lastmovement = "crouch_left"
  1323.             }
  1324.         }
  1325.         else
  1326.         {
  1327.             waitexec anim/attack.scr::AttackCheckRight self.dist_crouchright
  1328.             if (self.collideresult > 0)
  1329.             {
  1330.                 self.blendtime = 0.5
  1331.                 self thread anim/SayManager.scr::SayManager face_aiming 3
  1332.                 self setmotionanim (walk_crouch_right)
  1333.                 self setactionanim (self.weapongroup + "_aim") -60 60
  1334.                 self waittill flaggedanimdone
  1335.                 self.lastmovement = "crouch_right"
  1336.             }
  1337.         }
  1338.     }
  1339. end
  1340.  
  1341. //=============================================================
  1342. //=============================================================
  1343. AttackProneDodge:
  1344.     if ( self.ainopronedodge != 0 )
  1345.         end
  1346.  
  1347.     local.randnum = randomint 100
  1348. //    waitexec anim/attack.scr::AttackIsEnemyAimingAtMe
  1349.  
  1350. //    if (local.randnum < self.dodgepct || self.enemyaimingme > 0)
  1351.     if (local.randnum < self.dodgepct)
  1352.     {
  1353.         self weaponcommand mainhand attachtohand mainhand
  1354.  
  1355.         local.randnum = randomint 100
  1356.  
  1357.         if (local.randnum < 50)
  1358.         {
  1359.             waitexec anim/attack.scr::AttackCheckLeft self.dist_prone_roll_left
  1360.             if (self.collideresult > 0)
  1361.             {
  1362.                 self.blendtime = 0.3
  1363.                 self setmotionanim (self.weapongroup + "_prone_roll_left")
  1364.                 self waittill flaggedanimdone
  1365.                 self.lastmovement = "prone_roll_left"
  1366.             }
  1367.         }
  1368.         else
  1369.         {
  1370.             waitexec anim/attack.scr::AttackCheckRight self.dist_prone_roll_right
  1371.             if (self.collideresult > 0)
  1372.             {
  1373.                 self.blendtime = 0.3
  1374.                 self setmotionanim (self.weapongroup + "_prone_roll_right")
  1375.                 self waittill flaggedanimdone
  1376.                 self.lastmovement = "prone_roll_right"
  1377.             }
  1378.         }
  1379.     }
  1380. end
  1381.  
  1382.  
  1383. //=============================================================
  1384. //=============================================================
  1385. AttackStandMoveToIntervalDir:
  1386.     self.movedtointervaldir = 0
  1387.     self.movingtointervaldir = 0
  1388.  
  1389.     if ( self.ainointerval != 0 )
  1390.         end
  1391.  
  1392.     if (self.intervaldir != (0 0 0))
  1393.     {
  1394.         //thread DPrintln "Moving to interval dir: " self.intervaldir
  1395.  
  1396.         local.stoodup = 0
  1397.         local.spawnedshootthread = 0
  1398.         self weaponcommand mainhand attachtohand mainhand
  1399.  
  1400.         while (self.intervaldir != (0 0 0))
  1401.         {
  1402.             //check to see if we can move
  1403.             local.movepos = (self.intervaldir * 93) + self.origin
  1404.             self.collideresult = 0
  1405.             local.movetoresult = self canmoveto local.movepos
  1406.             if (local.movetoresult == 1)
  1407.             {
  1408.                 self.collideresult = self sighttrace self.origin local.movepos 1 ( -16 -16 16) ( 16 16 96)
  1409.             }
  1410.  
  1411.             if (self.collideresult > 0)
  1412.             {
  1413.                 // We're spreading out, so tell each other (trying to sound smarter...)
  1414.                 if ( (level.nextsayspread == NULL) || (level.nextsayspread == NIL) || (level.time > level.nextsayspread) )
  1415.                 {
  1416.                     level.nextsayspread = level.time + ( (randomint 200 + 50) / 100 )
  1417.                     if (self.team == "german")
  1418.                     {
  1419.                         self thread anim/SayManager.scr::SayManager ("den_head_spread_" + self.voicetype) 3
  1420.                     }
  1421.                     else
  1422.                     {
  1423.                         self thread anim/SayManager.scr::SayManager ("dfr_head_spread_" + self.voicetype) 3
  1424.                     }
  1425.                 }
  1426.  
  1427.                 self.movingtointervaldir = 1
  1428.  
  1429.                 if (local.stoodup == 0)
  1430.                 {
  1431.                     waitexec anim/attack.scr::AttackStandUp
  1432.                     local.stoodup = 1
  1433.                 }
  1434.  
  1435.                 if (local.spawnedshootthread == 0)
  1436.                 {
  1437.                     thread AttackStandMoveToIntervalDirShoot
  1438.                     self.shootthread = parm.previousthread
  1439.                     local.spawnedshootthread = 1
  1440.                 }
  1441.  
  1442.                 self.blendtime = 0.20
  1443.  
  1444.                 local.dotvec = self.forwardvector * self.intervaldir
  1445.                 local.sidevec = self.leftvector * self.intervaldir
  1446.                 local.forwardbackblend = abs(local.dotvec)
  1447.                 local.sideblend = 1.0 - local.forwardbackblend
  1448.  
  1449.                 //sanity checks
  1450.                 if (local.sideblend < 0.00)
  1451.                 {
  1452.                     local.sideblend = 0.00
  1453.                 }
  1454.  
  1455.                 if (local.sideblend > 1.0)
  1456.                 {
  1457.                     local.sideblend = 1.0
  1458.                 }
  1459.  
  1460.                 //thread DPrintln "Forward: " local.forwardbackblend " Side: " local.sideblend
  1461.  
  1462.                 if (local.dotvec >= 0.00)
  1463.                 {
  1464.                     //move forward
  1465.                     self setanim (self.weapongroup + "_walk_alert_forward") 0 local.forwardbackblend
  1466.  
  1467.                     if (local.dotvec >= 0.70)
  1468.                     {
  1469.                         self.lastmovement = "walk_forward"
  1470.                     }
  1471.                 }
  1472.                 else
  1473.                 {
  1474.                     self setanim (self.weapongroup + "_walk_alert_back") 0 local.forwardbackblend
  1475.  
  1476.                     if (local.dotvec <= -0.70)
  1477.                     {
  1478.                         self.lastmovement = "walk_backward"
  1479.                     }
  1480.                 }
  1481.  
  1482.                 if (local.sidevec >= 0.00)
  1483.                 {
  1484.                     //move left
  1485.                     self setanim (self.weapongroup + "_walk_alert_left") 1 local.sideblend
  1486.                     if (local.dotvec < 0.70 && local.dotvec > -0.70)
  1487.                     {
  1488.                         self.lastmovement = "strafe_left"
  1489.                     }
  1490.                 }
  1491.                 else
  1492.                 {
  1493.                     //move right
  1494.                     self setanim (self.weapongroup + "_walk_alert_right") 1 local.sideblend
  1495.                     if (local.dotvec < 0.70 && local.dotvec > -0.70)
  1496.                     {
  1497.                         self.lastmovement = "strafe_right"
  1498.                     }
  1499.                 }
  1500.  
  1501.                 self.movedtointervaldir = 1
  1502.                 wait 0.2
  1503.             }
  1504.             else
  1505.             {
  1506.                 //thread DPrintln "Could not move to interval dir!"
  1507.                 break
  1508.             }
  1509.         }
  1510.  
  1511.         if (local.spawnedshootthread == 1)
  1512.         {
  1513.             self.shootthread delete
  1514.         }
  1515.  
  1516.         self.movingtointervaldir = 0
  1517.         //thread DPrintln "Done!"
  1518.     }
  1519. end
  1520.  
  1521. //=============================================================
  1522. //=============================================================
  1523. AttackStandMoveToIntervalDirShoot:
  1524.     while (1)
  1525.     {
  1526.         if (self.needreload == 1)
  1527.         {
  1528.             waitexec anim/reload.scr::Reload 1
  1529.         }
  1530.         else
  1531.         {
  1532.             self.playedreloadanim = 0
  1533.             self.playedrechamberanim = 0
  1534.         }
  1535.  
  1536.         local.randnum = randomint 100
  1537.         if ( (local.randnum < self.shootpct) && (self cansee self.enemy))
  1538.         {
  1539. //            thread DPrintln "(Boon) Fired without aiming 7 - did anything weird happen?"
  1540.             self thread anim/SayManager.scr::SayManager face_attack 5
  1541.             //self setactionanim (self.weapongroup + "_shoot") -60 60
  1542.             waitexec anim/shoot.scr::PlayShootActionAnim
  1543.             self.needreload = 1
  1544.             self waittill upperanimdone
  1545.         }
  1546.         else
  1547.         {
  1548.             self thread anim/SayManager.scr::SayManager face_aiming 3
  1549.             waitexec anim/aim.scr::PlayAimActionAnim
  1550.             self.needreload = 0
  1551.             self waittill upperanimdone
  1552.         }
  1553.  
  1554.         if (self.movingtointervaldir == 0)
  1555.         {
  1556.             thread DPrintln "IntervalDirShoot thread is still running for " self
  1557.         }
  1558.  
  1559.         self interrupt_point
  1560.     }
  1561. end
  1562.  
  1563. //=============================================================
  1564. //=============================================================
  1565. //this is temporary until someone makes this a function call for the script
  1566. AttackIsEnemyAimingAtMe:
  1567.     if ( (self.aimdodge == 1) && self.enemy && (isAlive self.enemy) )
  1568.     {
  1569.         local.vec = (self.origin - self.enemy.origin)
  1570.         local.vec = vector_normalize (local.vec)
  1571.         local.dotvec = local.vec * self.enemy.forwardvector
  1572.         if (local.dotvec > 0.980)
  1573.         {
  1574.             self.enemyaimingme = 1
  1575.         }
  1576.         else
  1577.         {
  1578.             self.enemyaimingme = 0
  1579.         }
  1580.     }
  1581.     else
  1582.     {
  1583.         self.enemyaimingme = 0
  1584.     }
  1585. end
  1586.  
  1587. //=============================================================
  1588. //=============================================================
  1589. //Checks ahead to see if it's possible to crouch
  1590. AttackCheckCrouch:
  1591.     if ( self.ainocrouch != 0 )
  1592.     {
  1593.         self.collideresult = 0
  1594.         end
  1595.     }
  1596.     local.start = self.origin
  1597. //    local.end = self.enemy.controid    //origin
  1598.     local.start[2] = local.start[2] + 45
  1599. //    local.end[2] = local.end[2] + 45
  1600. //    self.collideresult = self sighttrace local.start local.end 1
  1601.     self.collideresult = self canshootenemyfrom local.start
  1602. end
  1603.  
  1604. //=============================================================
  1605. //=============================================================
  1606. //Checks ahead to see if it's possible to go prone
  1607. AttackCheckProne:
  1608.     //check height
  1609.     if ( self.ainoprone != 0 )
  1610.     {
  1611.         self.collideresult = 0
  1612.         end
  1613.     }
  1614.     local.height = self.enemy.origin[2] - self.origin[2]
  1615.     if (local.height < 160)
  1616.     {
  1617.         local.start = self.origin
  1618.         local.end = self.enemy.origin
  1619.         local.start[2] = local.start[2] + 22
  1620.         local.end[2] = local.end[2] + 22
  1621.         self.collideresult = self sighttrace local.start local.end 1
  1622.     }
  1623.     else
  1624.     {
  1625.         self.collideresult = 0
  1626.         //println "~^~^ Can't prone - target is higher"
  1627.     }
  1628. end
  1629.  
  1630. //=============================================================
  1631. //=============================================================
  1632. //Checks ahead to see if it's possible to move right without colliding
  1633. AttackCheckRight local.checkdist:
  1634.     local.movepos = (self.rightvector * local.checkdist) + self.origin
  1635.     self.collideresult = 0
  1636.     local.movetoresult = self canmoveto local.movepos
  1637.     if (local.movetoresult == 1)
  1638.     {
  1639.         self.collideresult = self sighttrace self.origin local.movepos 0 ( -16 -16 16) ( 16 16 128)
  1640.     }
  1641.     //thread DPrintln "CheckRight got :" self.collideresult "Dist :" local.checkdist
  1642. end
  1643.  
  1644. //=============================================================
  1645. //=============================================================
  1646. //Checks ahead to see if it's possible to move left without colliding
  1647. AttackCheckLeft local.checkdist:
  1648.     local.movepos = (self.leftvector * local.checkdist) + self.origin
  1649.     self.collideresult = 0
  1650.     local.movetoresult = self canmoveto local.movepos
  1651.     if (local.movetoresult == 1)
  1652.     {
  1653.         self.collideresult = self sighttrace self.origin local.movepos 0 ( -16 -16 16) ( 16 16 128)
  1654.     }
  1655.     //thread DPrintln "CheckLeft got :" self.collideresult "Dist :" local.checkdist
  1656. end
  1657.  
  1658. //=============================================================
  1659. //=============================================================
  1660. //Checks ahead to see if it's possible to move forward without colliding
  1661. AttackCheckFront local.checkdist:
  1662.     local.movepos = (self.forwardvector * local.checkdist) + self.origin
  1663.     self.collideresult = 0
  1664.     local.movetoresult = self canmoveto local.movepos
  1665.     if (local.movetoresult == 1)
  1666.     {
  1667.         self.collideresult = self sighttrace self.origin local.movepos 0 ( -16 -16 16) ( 16 16 128)
  1668.     }
  1669.     //thread DPrintln "CheckFront got :" self.collideresult "Dist :" local.checkdist
  1670. end
  1671.  
  1672. //=============================================================
  1673. //=============================================================
  1674. //Checks ahead to see if it's possible to move backward without colliding
  1675. AttackCheckBack local.checkdist:
  1676.     local.tempvec = ( -self.forwardvector[0] -self.forwardvector[1] -self.forwardvector[2] )
  1677.     local.movepos = (local.tempvec * local.checkdist) + self.origin
  1678.     self.collideresult = 0
  1679.     local.movetoresult = self canmoveto local.movepos
  1680.     if (local.movetoresult == 1)
  1681.     {
  1682.         self.collideresult = self sighttrace self.origin local.movepos 0 ( -16 -16 16) ( 16 16 128)
  1683.     }
  1684.     //thread DPrintln "CheckBack got :" self.collideresult "Dist :" local.checkdist
  1685.     //thread DPrintln "Start: " self.origin "End : " local.movepos
  1686. end
  1687.  
  1688.  
  1689. //=============================================================
  1690. //called whenever the actor needs to stand
  1691. AttackStandUp:
  1692.     switch (self.position)
  1693.     {
  1694.         stand:
  1695.             break
  1696.         pronewalk:
  1697.         prone:
  1698.             self.blendtime = 0.25
  1699.             self setmotionanim (self.weapongroup + "_pronetocrouch")
  1700.             self waittill flaggedanimdone
  1701.  
  1702.             self.position = crouch
  1703.  
  1704.         // *Deliberately drop through to the crouch case so we can stand from crouching*
  1705.  
  1706.         walk:
  1707.         run:
  1708. //        stand:
  1709.         crouchwalk:
  1710.         crouchrun:
  1711.         crouch:
  1712.             waitexec anim/attack.scr::AttackRandomizeCrouchProne
  1713. //            println "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ METHINKS " self.targetname " JUST STOOD UP. RESET PRONE/CROUCH HERE? ~~~~~~~~~~~~~~~~"
  1714.             self.blendtime = 0.50
  1715.             //self setactionanim (self.weapongroup + "_aim") -60 60
  1716.             waitexec anim/aim.scr::PlayAimActionAnim
  1717.             self setmotionanim (self.weapongroup + "_stand_alert_legs")
  1718. //            self waittill flaggedanimdone
  1719.             wait self.blendtime    // Time enough to stand up - not dependent on the length of the looping
  1720.                                 // animation stand_alert_legs, which could be any length.
  1721.             self.weaponpos = up
  1722.             self.position = stand
  1723.             break
  1724.         knees:
  1725.         crawl:
  1726.         floor:
  1727.         default:
  1728.             println ("^~^~^ Default case for position " + self.position + "in Attack.scr::AttackStandUp script")
  1729.             break
  1730.     }
  1731. end
  1732.  
  1733. //=============================================================
  1734. // called to reset the random crouch/prone factor
  1735. AttackRandomizeCrouchProne:
  1736.     self.aicrouchpronechance = randomint 100
  1737. end
  1738.  
  1739. //=============================================================
  1740. //called whenever the actor needs to crouch
  1741. AttackCrouchDown:
  1742.     switch (self.position)
  1743.     {
  1744.         walk:
  1745.         run:
  1746.         stand:
  1747.             self.blendtime = 0.50
  1748.             self setactionanim (self.weapongroup + "_aim") -60 60
  1749.             self setmotionanim (self.weapongroup + "_crouch_alert")
  1750.             // Let's set our state variables when we're halfway through blending, since we can.
  1751.             wait 0.25
  1752.             self.weaponpos = up
  1753.             self.position = crouch
  1754.             wait 0.25
  1755.             break
  1756.         crouchwalk:
  1757.         crouchrun:
  1758.         crouch:
  1759.             //already crouched
  1760.             self.position = crouch
  1761.             self.weaponpos = up
  1762.             break
  1763.         pronewalk:
  1764.         prone:
  1765.             self.blendtime = 0.25
  1766.             self setmotionanim (self.weapongroup + "_pronetocrouch")
  1767.             self waittill flaggedanimdone
  1768.             self.position = crouch
  1769.             self.weaponpos = up
  1770.             break
  1771.         knees:
  1772.         crawl:
  1773.         floor:
  1774.         default:
  1775.             println ("^~^~^ Default case for position " + self.position + "in Attack.scr::AttackCrouchDown script")
  1776.             break
  1777.     }
  1778. end
  1779.  
  1780. //=============================================================
  1781. //called whenever the actor needs to go to prone
  1782. AttackProneDown:
  1783.     switch (self.position)
  1784.     {
  1785.         walk:
  1786.         run:
  1787.         stand:
  1788.             self.blendtime = 0.50
  1789.             self setactionanim (self.weapongroup + "_aim") -60 60
  1790.             self setmotionanim (self.weapongroup + "_crouch_alert")
  1791. //            self waittill flaggedanimdone
  1792.             wait 0.5    // Time enough to crouch - not dependent on the length of the looping
  1793.                         // animation <weapon>_crouch, which could be any length.
  1794.  
  1795.             self.position = crouch
  1796.             self.weaponpos = up
  1797.  
  1798.             self endactionanim
  1799.             self.blendtime = 0.30
  1800.             self setmotionanim (self.weapongroup + "_crouchtoprone")
  1801.             self waittill flaggedanimdone
  1802.  
  1803.             self.position = prone
  1804.             break
  1805.  
  1806.         crouchwalk:
  1807.         crouchrun:
  1808.         crouch:
  1809.             self endactionanim
  1810.             self.blendtime = 0.30
  1811.             self setmotionanim (self.weapongroup + "_crouchtoprone")
  1812.             self waittill flaggedanimdone
  1813.             self.position = prone
  1814.             self.weaponpos = up
  1815.             break
  1816.         pronewalk:
  1817.         prone:
  1818.             //already in prone
  1819.             self.position = prone
  1820.             break
  1821.         knees:
  1822.         crawl:
  1823.         floor:
  1824.         default:
  1825.             println ("^~^~^ Default case for position " + self.position + "in Attack.scr::AttackProneDown script")
  1826.             break
  1827.     }
  1828. end
  1829.  
  1830. //==================================================================
  1831. // thread DPrintln - for debug prints
  1832. DPrintln local.text1 local.text2 local.text3 local.text4 local.text5:
  1833.     if (level.boonDebug == 1)
  1834.     {
  1835.         if (local.text1 != NIL)
  1836.         {
  1837.             print local.text1
  1838.             if (local.text2 != NIL)
  1839.             {
  1840.                 print local.text2
  1841.                 if (local.text3 != NIL)
  1842.                 {
  1843.                     print local.text3
  1844.                     if (local.text4 != NIL)
  1845.                     {
  1846.                         print local.text4
  1847.                         if (local.text5 != NIL)
  1848.                         {
  1849.                             print local.text5
  1850.                         }
  1851.                     }
  1852.                 }
  1853.             }
  1854.         }
  1855.         println
  1856.     }
  1857. end
  1858.