home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Messiah / data1.cab / Program_Executable_Files / messiahscripts / Enemies / shared.hxx < prev    next >
Text File  |  1999-11-29  |  31KB  |  1,432 lines

  1.  
  2. SubRoutine(Sub_ExplodeObjectHandler)
  3. {
  4.     call(SetParticleSetID);
  5.     if(VDynamicCollision|=_ExplodeGlass)
  6.     {
  7.         sample(SFXGlass,tmpvector);            //attached gets removed!
  8.  
  9.         if(VDynamicCollision|=_ExplodeSmall)
  10.         {
  11.             spawnparticle(fx_smallexplosion,-1,tmpvector,emptyvector,-1);
  12.         }
  13.     }
  14.     elseif(VDynamicCollision|=_ExplodeSmall)
  15.     {
  16.         spawnparticle(fx_smallexplosion,-1,tmpvector,emptyvector,-1);
  17.         sample(SFXSmallExplode,tmpvector);
  18.     }
  19.     elseif(VDynamicCollision|=_ExplodeBig)
  20.     {
  21.         vector(_copyx,TmpVector,TmpFloat2);
  22.         vector(_copyy,TmpVector,TmpFloat3);
  23.         vector(_copyz,TmpVector,TmpFloat4);
  24.  
  25.         if(VDynamicCollision|=_ExplodeAmmo)
  26.         {
  27.             spawnactor(WeaponAmmo,TmpFloat2,TmpFloat3,TmpFloat4,false,true);
  28.         }
  29.         elseif(VDynamicCollision|=_ExplodeAmmoGrenades)
  30.         {
  31.             spawnactor(WeaponAmmoGrenade,TmpFloat2,TmpFloat3,TmpFloat4,false,true);
  32.         }
  33.  
  34.         spawnactor(BulletExplosion,TmpFloat2,TmpFloat3,TmpFloat4,false,true);
  35.         sample(SFXBazookaExplode,tmpvector);
  36.         callsub(sub_fxexplosion);
  37.     }
  38. }
  39.  
  40.  
  41. Subroutine(TurnToPlayer)
  42. {
  43.     call(AIcheckforplayerone,300);
  44.     if(VTrigger==_DIRTempFlag)
  45.     {
  46.         call(AIsetlockedonactortotarget);
  47.         callsub(Sub_AI1WayAlignToTarget);
  48.     }
  49. }
  50. Subroutine(HandBox,float(time),float(toggleon))
  51. {
  52.     call(CheckTriggerObjFlag,TmpFloat,1,_SXObjDynamicObj);
  53.     if(TmpFloat==FALSE)
  54.     {
  55.         if(VTrigger==_DIREnvTrigger && VTrigger==_DIRaction && toggleon==0)
  56.         {
  57.             call(ActivateButton,"Please Step Back",-1,FALSE);
  58.             call(ActivateButtonSample,SFXValidFunction);
  59.             call(SetTriggerObjFlag,2,_clr,_SXObjInvisible);
  60.             sample(SFXCountDown,Gactorpos);
  61.             sample(SFXBoxCountDown,Gactorpos);
  62.             float(_set,toggleon,1);
  63.             direction(_clr,_DIRaction);
  64.         }
  65.         if(toggleon>=1)
  66.         {
  67.             float(_add,toggleon,1);
  68.             if(toggleon>=time)
  69.             {
  70.                 call(SetTriggerObjFlag,2,_or,_SXObjInvisible);
  71.                 call(ExplodeObject,TmpVector,1);
  72.                 samplestop(SFXCountDown,Gactorpos);
  73.                 callsub(Sub_ExplodeObjectHandler);
  74.                 float(_set,toggleon,0);
  75.             }
  76.         }
  77.     }
  78.     else
  79.     {
  80.         if(toggleon!=0)
  81.         {
  82.             samplestop(SFXCountDown,Gactorpos);
  83.             float(_set,toggleon,0);
  84.         }
  85.     }
  86. }
  87.  
  88. SubRoutine(Sub_BoxTrigger,float(radius),float(posx),float(posz),float(solve))
  89. {
  90.     vector(_settotriggerpos,TmpVector);
  91.     vector(_settoactorpos,TmpVector2);
  92.     vector(_sub,TmpVector,TmpVector2);
  93.     vector(_copyx,TmpVector,posx);
  94.     vector(_copyz,TmpVector,posz);
  95.     float(_abs,posx);
  96.     float(_abs,posz);
  97.     if(posx<=radius && posz<=radius)
  98.     {
  99.         float(_set,solve,1);
  100.     }
  101.     else
  102.     {
  103.         float(_set,solve,0);
  104.     }
  105. }
  106.  
  107. SubRoutine(Sub_SpawnGrenade)
  108. {
  109.         call(ChangeInventory,0,-1);
  110.  
  111.         if(VInventoryType==_AmmoGrenadeConcussion)
  112.         {
  113.             spawnactor(BulletGrenadeConcusion,0,100,-100);
  114.         }
  115.         elseif(VInventoryType==_AmmoGrenadeStickEm)
  116.         {
  117.             if(VAICon==0)
  118.             {
  119.                 spawnactor(BulletGrenadeStickEm,0,100,-100);
  120.             }
  121.             else
  122.             {
  123.                 spawnactor(BulletGrenade,0,100,-100);
  124.             }
  125.         }
  126.         elseif(VInventoryType==_AmmoGrenadeBetty)
  127.         {
  128.             spawnactor(BulletGrenadeJumpBetty,0,100,-100);
  129.         }
  130.         elseif(VInventoryType==_AmmoGrenadeRectum)
  131.         {
  132.             spawnactor(BulletGrenadeRectum,0,100,-100)
  133.         }
  134.         elseif(VInventoryType==_AmmoGrenadeNoTimer)
  135.         {
  136.             spawnactor(BulletGrenadeNoTimer,-80,80,-220);
  137.         }
  138.         else    //_AmmoGrenade
  139.         {
  140.             spawnactor(BulletGrenade,0,100,-100);
  141.         }
  142. }
  143.  
  144.  
  145. //    TmpFloat gets the floor number, -1 if nothing should happen
  146. //    TmpFloat1 gets the direction the floor is moving in, 0 if not moving
  147. //
  148. SubRoutine(LiftControl,const(CurFloor),const(NumbFloors))
  149. {
  150.     if(TmpFloat==-1 && VTrigger==_DIREnvTrigger)
  151.     {
  152.         Direction(_clr,_DIRaction);
  153.  
  154.         if(VTrigger==_DIRforward) //if CHARACTER is moving forward
  155.         {
  156.             float(_set,TmpFloat1,1);
  157.             Direction(_clr,_DIRforward); // clears the move
  158.         }
  159.         elseif(VTrigger==_DIRbackward) // if CHARACTER is moving backward
  160.         {
  161.             float(_set,TmpFloat1,-1);
  162.             Direction(_clr,_DIRbackward); // clears the move
  163.         }
  164.         else
  165.         {
  166.             float(_set,TmpFloat1,0);
  167.  
  168.         }
  169.  
  170.         if(TmpFloat1!=0)
  171.         {
  172.             float(_set,TmpFloat,CurFloor);
  173.             float(_add,TmpFloat,TmpFloat1);
  174.  
  175.             if(TmpFloat<0 || TmpFloat>NumbFloors)
  176.             {
  177.                 float(_set,TmpFloat,-1);
  178.             }
  179.         }
  180.     }
  181. }
  182.  
  183. SubRoutine(DispenserSound)
  184. {
  185.     if(timer2==0)
  186.     {
  187.         float(_set,timer2,1);
  188.     }
  189.     if(timer2==5)
  190.     {
  191.         float(_set,timer2,0);
  192.     }
  193.     if(VKeyObjFrame==0 && timer2==1)
  194.     {
  195.         sample(SFXFenetre,Gactorpos)
  196.         float(_set,timer2,2);
  197.     }
  198.     if(VKeyObjFrame==4 && timer2==2)
  199.     {
  200.         sample(SFXPneumatik2,Gactorpos);
  201.         float(_set,timer2,3);
  202.     }
  203.     if(VKeyObjFrame==8 && timer2==3)
  204.     {
  205.         sample(SFXClawSpin,Gactorpos);
  206.         float(_set,timer2,4);
  207.     }
  208.     if(VKeyObjFrame==9 && timer2==4)
  209.     {
  210.         sample(SFXLockedSound,Gactorpos);
  211.         float(_set,timer2,5);
  212.     }
  213. }
  214.  
  215. Subroutine(Fall2Death)
  216. {
  217.     if(VTrigger==_DIREnvTrigger)
  218.     {
  219.         if(VAICon!=0)
  220.         {
  221.             KillActor();
  222.         }
  223.         else
  224.         {
  225.             Camera(500,200);
  226.             Target(-10,10);
  227.             call(LockCamera,1);
  228.             Direction(_clr,_DIRalive);
  229.             State(_or,StateDead);
  230.         }
  231.     }
  232. }
  233.  
  234. //Plays random messages in lift (see exemple in Scene2.hxx, s1r15 & s1r16)
  235. SubRoutine(PickLiftMsg)
  236. {
  237.     float(_add,timer3,1)
  238.     if(timer3>=350)
  239.     {
  240.         float(_rnd2,RandomMsg,6);
  241.         if(RandomMsg<1 && LastLiftSamplePlayed!=1)
  242.         {
  243.             sample(SFXElevatorMsg01,Gactorpos);
  244.             float(_set,LastLiftSamplePlayed,1);
  245.             float(_set,Picked,1);
  246.             float(_set,timer3,0);
  247.         }
  248.         elseif(RandomMsg<2 && LastLiftSamplePlayed!=2)
  249.         {
  250.             sample(SFXElevatorMsg02,Gactorpos);
  251.             float(_set,LastLiftSamplePlayed,2);
  252.             float(_set,Picked,1);
  253.             float(_set,timer3,0);
  254.         }
  255.         elseif(RandomMsg<3 && LastLiftSamplePlayed!=3)
  256.         {
  257.             sample(SFXElevatorMsg03,Gactorpos);
  258.             float(_set,LastLiftSamplePlayed,3);
  259.             float(_set,Picked,1);
  260.             float(_set,timer3,0);
  261.         }
  262.         elseif(RandomMsg<4 && LastLiftSamplePlayed!=4)
  263.         {
  264.             sample(SFXElevatorMsg04,Gactorpos);
  265.             float(_set,LastLiftSamplePlayed,4);
  266.             float(_set,Picked,1);
  267.             float(_set,timer3,0);
  268.         }
  269.         elseif(RandomMsg<5 && LastLiftSamplePlayed!=5)
  270.         {
  271.             sample(SFXElevatorMsg05,Gactorpos);
  272.             float(_set,LastLiftSamplePlayed,5);
  273.             float(_set,Picked,1);
  274.             float(_set,timer3,0);
  275.         }
  276.         elseif(RandomMsg<6 && LastLiftSamplePlayed!=6)
  277.         {
  278.             sample(SFXElevatorMsg06,Gactorpos);
  279.             float(_set,LastLiftSamplePlayed,6);
  280.             float(_set,Picked,1);
  281.             float(_set,timer3,0);
  282.         }
  283.         elseif(RandomMsg<7 && LastLiftSamplePlayed!=7)
  284.         {
  285.             sample(SFXElevatorMsg07,Gactorpos);
  286.             float(_set,LastLiftSamplePlayed,7);
  287.             float(_set,Picked,1);
  288.             float(_set,timer3,0);
  289.         }
  290.     }
  291. }
  292.  
  293. SubRoutine(DoorOpen,const(OpenType),const(WaitType))
  294. {
  295.  
  296. // OpenType : 0  >> light doors sound
  297. //              1     >> medium doors sound
  298. //              2  >> heavy doors sound
  299. //              3  >> rusty door sound
  300. // 
  301. // WaitType : 0  >> WAIT command
  302. //              1  >> KFEVENT command
  303.  
  304.     if(VKeyObjTriggered==0)
  305.     {
  306.          call(KeyObjTrigger,255,1);
  307.         direction(_clr,_DIRaction);
  308.         float(_set,subvar3,0);
  309.         float(_set,SubVar1,WaitType);
  310.         float(_set,SubVar2,OpenType);
  311.         if(SubVar1==1)
  312.         {
  313.             if(SubVar2==0)
  314.             {
  315.                 kfsample(SFXDoOp1,SFXDoMo1,-1,SFXDoCl1);
  316.             }
  317.             elseif(SubVar2==1)
  318.             {
  319.                 kfsample(SFXDoOp2,SFXDoMo2,-1,SFXDoCl2);
  320.             }
  321.             elseif(SubVar2==2)
  322.             {
  323.                 kfsample(SFXVaultOpen,SFXVaultMove,-1,SFXVaultClose);
  324.             }
  325.             elseif(SubVar2==3)
  326.             {
  327.                 kfsample(SFXRustDoorOpen,SFXRustDoorLoop,-1,SFXRustDoorClose);
  328.             }
  329.         }
  330.         elseif(SubVar1==0)
  331.         {
  332.  
  333.             if(SubVar2==0)
  334.             {
  335.                 kfsample(SFXDoOp1,SFXDoMo1,SFXDoCl1,-2);
  336.             }
  337.             elseif(SubVar2==1)
  338.             {
  339.                 kfsample(SFXDoOp2,SFXDoMo2,SFXDoCl2,-2);
  340.             }
  341.             elseif(SubVar2==2)
  342.             {
  343.                 kfsample(SFXVaultOpen,SFXVaultMove,SFXVaultClose,-2);
  344.             }
  345.             elseif(SubVar2==3)
  346.             {
  347.                 kfsample(SFXRustDoorOpen,SFXRustDoorLoop,SFXRustDoorClose,-2);
  348.             }
  349.         }
  350.  
  351.         if(VClass==_ClassCop && VTrigger==_DIRhavegun && VTrigger==_DIRcombatmode)
  352.         {
  353.             if(VAIClass&==_AIclassCop|_AIclassMale)
  354.             {
  355.                 SpawnAction(CopOpenDoorCombat);
  356.             }
  357.         }
  358.     }
  359. }
  360.  
  361. //subroutine root
  362. SubRoutine(Replay)
  363. {
  364.     if(VKeyObjTriggered==0 && VKeyObjFrame!=0)
  365.     {
  366.         call(KeyObjTrigger,255,1);
  367.     }
  368. }
  369.  
  370. // Non RadWorker will lose their health, feel dizzy and...eventually die.
  371. SubRoutine(RadiationArea)
  372. {
  373.     if(VAIClass==_AIClassScientist&&VRank==_RankScum) // If NOT radiation worker
  374.     {
  375.         vector(_set,gactorpos,0,0,0);
  376.     }
  377.     else
  378.     {
  379.         call(SubtractHealth,0,10);
  380.         if(VAIClass!=_AIClassAngel) // Bob must not be dizzy !
  381.         {
  382.             if(Vaction!=CopDizzy)
  383.             {
  384.                 spawnaction(CopDizzy);
  385.             }
  386.         }
  387.         if(VAICon!=0 && VActorFlag!=_AFLAGnoai)
  388.         {
  389.             ActorFlag(_or,_AFLAGnoai);
  390.             Direction(_and,0);
  391.         }
  392.     }
  393. }
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. SubRoutine(Sub_SetCameraNormal)
  401. {
  402.         if(VAICon==0)
  403.         {
  404.             cameragroundclearance(100)
  405.             if(VClass==_CLASSangel)
  406.             {
  407.                 Camera(BobRun_camera_distance,BobRun_camera_angle);
  408.                 Target(BobRun_camera_Tdistance,BobRun_camera_Tangle);
  409.             }
  410.             elseif(VClass==_ClassCop)
  411.             {
  412.                 Camera(CopRun_camera_distance,CopRun_camera_angle);
  413.                 Target(CopRun_camera_Tdistance,CopRun_camera_Tangle);
  414.             }
  415.             elseif(VClass==_ClassBeast)
  416.             {
  417.                 Camera(beast_camera_distance,beast_camera_angle);
  418.                 Target(beast_camera_tdistance,beast_camera_tangle);
  419.             }
  420.             else
  421.             {
  422.                 Camera(CopRun_camera_distance,CopRun_camera_angle);
  423.                 Target(CopRun_camera_Tdistance,CopRun_camera_Tangle);
  424. //                Camera(Run_camera_distance,Run_camera_angle);
  425. //                Target(Run_camera_Tdistance,Run_camera_Tangle);
  426.             }
  427.         }
  428. }
  429.  
  430.  
  431. SubRoutine(Sub_BatteryHandler)
  432. {
  433.         if(VState!=StateCrawling && VTrigger==_DIRcombatmode && VTrigger==_DIRhavegun && VWeaponAmmoType==_AmmoBattery)
  434.         {
  435.             if(VWeaponAmmoLeft==0)
  436.             {
  437.                 //    Check for battery pickup
  438.                 //
  439.                 //if(batterydelay==0)
  440.                 //{
  441.                     call(CheckForPickup,12,_ClassPickup|_ClassBullet);
  442.                 //}
  443.                 //else
  444.                 //{
  445.                     //float(_sub,batterydelay,1);
  446.                 //}
  447.             }
  448.             /*
  449.             elseif(VTrigger==_DIRaction)
  450.             {
  451.                 //    battery drop
  452.                 //
  453.                 call(CheckAttached,_CADropBattery);
  454.                 //direction(_clr,_DIRshoot);
  455.                 //direction(_clr,_DIRcombatmode);
  456.                 //float(_set,batterydelay,30);
  457.             }
  458.             */
  459.         }
  460. }
  461.  
  462.  
  463.  
  464. SubRoutine(Sub_CombatKeyHandler,float(CombatState),const(CombatFireDelay))
  465. {
  466.     //Print("CombatState: ",CombatState);
  467.     if(VTrigger!=_DIRcombatmode)
  468.     {
  469.         //if(VTrigger==_DIRshoot && VTrigger!=_DIRmove)
  470.         if(VTrigger==_DIRshoot)
  471.         {
  472.             Direction(_or,_DIRcombatmode);
  473.             Direction(_clr,_DIRshoot);
  474.             float(_set,CombatState,1);
  475.  
  476.             if(VAICon==0 && VTrigger==_DIRhavegun)
  477.             {
  478.                 if(VWeaponAmmoType==_AmmoUnLimited)
  479.                 {
  480.                     sample(SFXreloadTorch,-1);
  481.                 }
  482.                 else
  483.                 {
  484.                     sample(SFXWeaponIntoCombat,-1);
  485.                 }
  486.             }
  487.         }
  488.  
  489.         if(CombatState!=0 && VTrigger==_DIRaction)
  490.         {
  491.             Direction(_clr,_DIRaction);
  492.         }
  493.         if(DirClr&=_DIRaction)
  494.         {
  495.             float(_set,CombatState,0);
  496.         }
  497.     }
  498.     else
  499.     {
  500.         if(VTrigger==_DIRaction)
  501.         {
  502.             Direction(_clr,_DIRcombatmode);
  503.             Direction(_clr,_DIRaction);
  504.             float(_set,CombatState,1);
  505.  
  506.             if(VAICon==0 && VTrigger==_DIRhavegun)
  507.             {
  508.                 if(VWeaponAmmoType==_AmmoUnLimited)
  509.                 {
  510.                     sample(SFXreloadTorch,-1);
  511.                 }
  512.                 else
  513.                 {
  514.                     sample(SFXWeaponPickUp,-1);
  515.                 }
  516.             }
  517.         }
  518.  
  519.         if(CombatState!=0 && VTrigger==_DIRshoot)
  520.         {
  521.             Direction(_clr,_DIRshoot);
  522.             float(_add,CombatState,1);
  523.         }
  524.         if(DirClr&=_DIRshoot || CombatState>=CombatFireDelay)
  525.         {
  526.             float(_set,CombatState,0);
  527.         }
  528.     }
  529. }
  530.  
  531.  
  532. SubRoutine(Sub_ActionKeyHandler,float(ActionOK))
  533. {
  534.     if(vtrigger==_DIRaction)
  535.     {
  536.         if(ActionOK==1)
  537.         {
  538.             float(_set,ActionOK,0);
  539.         }
  540.         else
  541.         {
  542.             direction(_clr,_DIRaction);
  543.         }
  544.         direction(_or,_DIRactionhold);
  545.     }
  546.     else
  547.     {
  548.         float(_set,ActionOK,1);
  549.         direction(_clr,_DIRactionhold);
  550.     }
  551. }
  552.  
  553. SubRoutine(Sub_CheckActionPickup,const(Pickup),const(PickupFrame),const(PickupChest),const(PickupChestFrame))
  554. {
  555.     if(vtrigger==_DIRaction && Pickup!=0)
  556.     {
  557.         call(IsPickupClose,_ClassWeapon,115,TmpFloat,TmpVector);
  558.         if(VTrigger==_DIRTempFlag && TmpFloat!=0)
  559.         {
  560.             //CallSub(Sub_ChangeStateToNormal);
  561.             state(_or,StateExecuteAnim);
  562.             direction(_clr,_DIRaction);
  563.             if(TmpFloat==1)
  564.             {
  565.                 spawnaction(Pickup);
  566.             }
  567.             else
  568.             {
  569.                 spawnaction(PickupChest);
  570.             }
  571.         }
  572.     }
  573. /*
  574.     PrintI("VFrame: ",VFrame);
  575.     Print("PickupFrame: ",PickupFrame);
  576.     PrintI("VAction: ",VAction);
  577.     Print("Pickup: ",Pickup);
  578. */    
  579.     if(vaction==Pickup&&VFrame==PickupFrame)
  580.     {
  581.         call(CheckForPickup,12,_ClassWeapon);    //Weapons only
  582.     }
  583.     elseif(vaction==PickupChest&&VFrame==PickupChestFrame)
  584.     {
  585.         call(CheckForPickup,12,_ClassWeapon);    //Weapons only
  586.     }
  587. }
  588.  
  589. SubRoutine(Sub_CheckActionPickupCrouch,const(Pickup),const(PickupFrame),const(PickupChest),const(PickupChestFrame))
  590. {
  591.     if(vtrigger==_DIRaction && Pickup!=0)
  592.     {
  593.         call(IsPickupClose,_ClassWeapon,115,TmpFloat,TmpVector);
  594.         if(VTrigger==_DIRTempFlag && TmpFloat!=0)
  595.         {
  596.             state(_or,StateExecuteAnim);
  597.             direction(_clr,_DIRaction);
  598.             spawnaction(Pickup);
  599.         }
  600.     }
  601.     if(vaction==Pickup&&VFrame==PickupFrame)
  602.     {
  603.         call(CheckForPickup,12,_ClassWeapon);    //Weapons only
  604.     }
  605. }
  606.  
  607. SubRoutine(Sub_CheckActionDrop,const(DropAction),const(DropActionFrame),const(DropChest),const(DropChestFrame),float(DropDelay))
  608. {
  609.     if(vtrigger==_DIRaction)
  610.     {
  611.         float(_set,DropDelay,0);
  612.     }
  613.  
  614.     if(VTrigger==_DIRcombatmode)
  615.     {
  616.         float(_set,DropDelay,100);
  617.     }
  618.  
  619.     if(vtrigger==_DIRactionhold)
  620.     {
  621.         float(_add,DropDelay,1);
  622.         if(DropAction!=0 && DropDelay==10)
  623.         {
  624.             call(IsPickupClose,_ClassWeapon,115,TmpFloat,TmpVector);
  625.             if(vtrigger==_DIRTempFlag && TmpFloat!=0)
  626.             {
  627.                 if(TmpFloat==1)
  628.                 {
  629.                     state(_or,StateExecuteAnim);
  630.                     spawnaction(DropAction);            //we're swapping with wep on ground or picking up weapon
  631.                 }
  632.                 else
  633.                 {
  634.                     //if(DropDelay==10)
  635.                     //{
  636.                         state(_or,StateExecuteAnim);
  637.                         spawnaction(DropChest);                //we're swapping with wep in front
  638.                     //}
  639.                 }
  640.             }
  641.             else
  642.             {
  643.                 //if(DropDelay==10)
  644.                 //{
  645.                     state(_or,StateExecuteAnim);
  646.                     spawnaction(DropAction);                //we're dropping our wep
  647.                 //}
  648.             }
  649.         }
  650.     }
  651.     else
  652.     {
  653.         float(_set,DropDelay,100);
  654.     }
  655.  
  656.     Direction(_clr,_DIRTempFlag);
  657.     if(vaction==DropAction && VFrame==DropActionFrame)
  658.     {
  659.         Direction(_or,_DIRTempFlag);
  660.     }
  661.     elseif(vaction==DropChest && VFrame==DropChestFrame)
  662.     {
  663.         Direction(_or,_DIRTempFlag);
  664.     }
  665.  
  666.     if(VTrigger==_DIRTempFlag)
  667.     {
  668.         sample(SFXWeaponDrop1,-1);
  669.  
  670.         call(IsPickupClose,_ClassWeapon,115,TmpFloat,TmpVector);
  671.  
  672.         if(vtrigger==_DIRTempFlag && TmpFloat!=0)
  673.         {
  674.             call(CheckAttached,_CASwapWeapon);
  675.             Direction(_clr,_DIRTempFlag);
  676.         }
  677.         else
  678.         {
  679.             call(CheckAttached,_CADropWeapon);
  680.         }
  681.     }
  682. }
  683.  
  684. SubRoutine(Sub_CheckActionDropCrouch,const(DropAction),const(DropActionFrame),const(DropChest),const(DropChestFrame),float(DropDelay))
  685. {
  686.     if(vtrigger==_DIRaction)
  687.     {
  688.         float(_set,DropDelay,0);
  689.     }
  690.  
  691.     if(VTrigger==_DIRcombatmode)
  692.     {
  693.         float(_set,DropDelay,100);
  694.     }
  695.  
  696.     if(vtrigger==_DIRactionhold)
  697.     {
  698.         float(_add,DropDelay,1);
  699.         if(DropAction!=0 && DropDelay==10)
  700.         {
  701.             state(_or,StateExecuteAnim);
  702.             spawnaction(DropAction); //we're swapping with wep on ground or picking up weapon
  703.         }
  704.     }
  705.     else
  706.     {
  707.         float(_set,DropDelay,100);
  708.     }
  709.  
  710.     Direction(_clr,_DIRTempFlag);
  711.     if(vaction==DropAction && VFrame==DropActionFrame)
  712.     {
  713.         Direction(_or,_DIRTempFlag);
  714.     }
  715.     elseif(vaction==DropChest && VFrame==DropChestFrame)
  716.     {
  717.         Direction(_or,_DIRTempFlag);
  718.     }
  719.  
  720.     if(VTrigger==_DIRTempFlag)
  721.     {
  722.         sample(SFXWeaponDrop1,-1);
  723.  
  724.         call(IsPickupClose,_ClassWeapon,115,TmpFloat,TmpVector);
  725.  
  726.         if(vtrigger==_DIRTempFlag && TmpFloat!=0)
  727.         {
  728.             call(CheckAttached,_CASwapWeapon);
  729.             Direction(_clr,_DIRTempFlag);
  730.         }
  731.         else
  732.         {
  733.             call(CheckAttached,_CADropWeapon);
  734.         }
  735.     }
  736. }
  737.  
  738. SubRoutine(Sub_CheckRemainingActions,const(Action),const(ActionFrame))
  739. {
  740.     if(VActorFlag==_AFLAGactivatebutton && Action!=0)
  741.     {
  742.         state(_or,StateExecuteAnim)
  743.         spawnaction(Action)
  744.     }
  745.  
  746.     if(vaction==Action && VFrame==ActionFrame)
  747.     {
  748.         call(ExecuteActivateCode);        //only action in here so far
  749.     }
  750. }
  751.         
  752.  
  753. SubRoutine(Sub_CheckForIdleLongTime,float(SubParmIdle),float(SubParmIdleLongTime))
  754. {
  755. //Switch to idle long time if inactive for a long time
  756.         if(VAICon==0)
  757.         {
  758.             if(VAction!=SubParmIdle&&VAction!=SubParmIdleLongTime)
  759.             {
  760.                 ClrStateCounter();    //To Random
  761.             }
  762.             elseif(VEndOfAnim!=0)
  763.             {
  764. //                if(VAction==SubParmIdleLongTime)
  765. //                {
  766. //                }
  767.                 if(VInStateCounter>=450)
  768.                 {
  769.                     Direction(_set,_DIRNotEndOfAnim);
  770.                     spawnaction(SubParmIdleLongTime);
  771.                     ClrStateCounter();
  772.                 }
  773.             }
  774.         }
  775. }
  776.  
  777. SubRoutine(Sub_InAirCheckGround,const(SubParm1))    //Check if landing on ground
  778. {
  779. //SubParm1: Action When Landing
  780.         if(Vtrigger==_DIRhorcol && VActorFlag!=_AFLAGcolfromabove)
  781.         {
  782.             CallSub(Sub_ChangeStateToNormal);
  783.             spawnaction(SubParm1);
  784.         }
  785. }
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793. SubRoutine(Sub_InitPossesion,const(PossesedAction),const(PossesedCrouchAction),const(PossesedCrawlAction))    //Called when possion starts
  794. {
  795.         if(vstate==StateNormal && vstate!=StateDead && vstate!=StateBlind && vstate!=StateSteamed && vstate!=StateOnFire && vstate!=StateHarpooned)
  796.         {
  797.             state(_or,StateExecuteAnim);
  798.             if(vstate==StateCrawling)
  799.             {
  800.                 spawnaction(PossesedCrawlAction);
  801.             }
  802.             elseif(VState==StateCrouching)
  803.             {
  804.                 spawnaction(PossesedCrouchAction);
  805.             }
  806.             else
  807.             {
  808.                 spawnaction(PossesedAction);
  809.             }
  810.  
  811.             //TmpPossessFX
  812.             vector(_set,TmpVector,0,0,0);
  813.             //spawnparticle(spikeballfx,0,EmptyVector,TmpVector);
  814.  
  815.             callsub(Sub_SetCameraNormal);
  816.             Direction(_clr,_DIRpossesion);
  817. //            call(CameraFollow,TRUE);
  818. //            call(AICon,FALSE);
  819.         }
  820.  
  821.         spawnparticle(fx_possessflare,0,emptyvector,emptyvector,-1);
  822.         spawnparticle(fx_possessflare,0,emptyvector,emptyvector,-1);
  823.         spawnparticle(fx_possessflare,0,emptyvector,emptyvector,-1);
  824.         spawnparticle(fx_possessflare,0,emptyvector,emptyvector,-1);
  825.  
  826.         vector(_set,tmpvector,64,56,64);
  827.         SpawnLight(PossessLight,0,emptyvector,tmpvector,EmptyVector,800);
  828.  
  829.         sample(SFXPossess,-1);
  830.         sample(SFXPossessHit,-1);
  831.  
  832.         call(AIchangemetoenemy);        //to make sure players notice the change
  833. }
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844. Subroutine(Sub_InitDepossesion,const(SubParm1),const(SubParm2),const(SubParm3))
  845. {
  846.     if(StickEmState==StickEmReady&&VAICon==0)
  847.     {
  848.         //we got here , which means we have thrown a StickEm grenade, and now we are going to explode it!
  849.         float(_set,StickEmState,StickEmExploding);
  850.     }
  851.  
  852. //SubParm1: Depossession action when statenormal
  853.     float(_seti,SubVar1,VColSphereSize);
  854.  
  855.     if(SubVar1<BobSphereSize || VSniperMode==TRUE)
  856.     {
  857. //MISSING: send collisionrays out around bob to see if there is room. If not, set SubVar1==0
  858. //Perhaps this check should always be made.
  859.         float(_set,SubVar1,0);    //Do this if there is not room for Bob (Narrow passages etc.)
  860.     }
  861.  
  862. //    if(SubVar1!=0)
  863. //    {
  864.  
  865.         if(vstate==StateNormal && vstate!=StateDead && vstate!=StateBlind && vstate!=StateSteamed && vstate!=StateOnFire && vstate!=StateHarpooned)
  866.         {
  867.             state(_or,StateExecuteAnim);
  868.             if(vstate==StateCrawling)
  869.             {
  870.                 spawnaction(SubParm3);
  871.             }
  872.             elseif(vstate==StateCrouching)
  873.             {
  874.                 spawnaction(SubParm2);
  875.             }
  876.             else
  877.             {
  878.                 spawnaction(SubParm1);
  879.             }
  880.         }
  881.         //float(_sub,SubVar1,BobSphereSize);    //Trigger bob at top of enemys sphere
  882.         centerbone(PlayerHeadBone,0.0);
  883.         call(CameraFollow,FALSE);
  884.         call(AICon,TRUE);
  885.         if(SubVar1!=0)
  886.         {
  887.             SpawnActor(Bob1,0,0,0,TRUE);
  888.         }
  889.         else
  890.         {
  891.             vector(_settoactorpos,TmpVector);
  892.             vector(_copyx,TmpVector,TmpFloat);
  893.             vector(_copyy,TmpVector,TmpFloat2);
  894.             vector(_copyz,TmpVector,TmpFloat3);
  895.             SpawnActor(Bob1,TmpFloat,TmpFloat2,TmpFloat3);
  896. //            SpawnActor(Bob1,0,100,0);
  897.         }
  898.         call(CheckAttached,_CANormal);
  899.         Direction(_clr,_DIRAIRemoveFlags);
  900.         sample(SFXDePossess,-1);
  901.         call(ChangeSniperMode,-2,0);        //-2 special case from depossession
  902.  
  903. //    }
  904. }
  905.  
  906.  
  907.  
  908. SubRoutine(Sub_Headtrack)        //Track head to objects
  909. {
  910.  
  911. //No parameters
  912.         if(VState==StateHeadTrack)
  913.         {
  914. //            printi("P1 PathDestDist:     ",VPathDestDistance);
  915. //            printi("P1 PathDestAngle:    ",VPathDestAngle);
  916. //            printi("P1 PickDestAngle:    ",VPickDestAngle);
  917. //            printi("P1 TargetDistance:   ",vtargetdistance);
  918. //            printi("P1 TargetAngle:      ",vtargetangle);
  919.             call(CheckForVisual,_CLASSmodel|_CLASSpickup|_CLASSweapon,10000);        //classmask,viewdistance
  920.             if(VAICon==0 || VAItargetfound==2)
  921.             {
  922.                 if(VLockedOnAngle!=0 && VLockedOnAngle<750 && VLockedOnAngle>-750)
  923.                 {
  924.                     vector(_copy,TmpVector,EmptyVector);
  925.                     float(_seti,TmpFloat,VLockedOnAngle);
  926.                     vector(_sety,TmpVector,TmpFloat);
  927.                     call(BonePointTrack,PlayerHeadBone,TmpVector,_SXBoneAttRelative,0.95);        //bonenr,point
  928.                 }
  929.                 else
  930.                 {
  931.                     centerbone(PlayerHeadBone,0.95);
  932.                 }
  933.  
  934.                 if(VTrigger==_DIRcombatmode && VActorFlag==_AFLAGlogon)
  935.                 {
  936.                     vector(_copy,TmpVector,EmptyVector);
  937.                     float(_seti,TmpFloat,VTargetAngleY);
  938.                     if(VTargetAngleY<-750)
  939.                     {
  940.                         float(_set,TmpFloat,-750);
  941.                     }
  942.                     elseif(VTargetAngleY>750)
  943.                     {
  944.                         float(_set,TmpFloat,750);
  945.                     }
  946.                     float(_mul,TmpFloat,-1);
  947.                     vector(_setx,TmpVector,TmpFloat);
  948.                     call(BonePointTrack,2,TmpVector,_SXBoneAttAbsolute,0.80);                    //bonenr,point
  949.                 }
  950.                 else
  951.                 {
  952.                     centerbone(2,0.95);
  953.                 }
  954.             }
  955.             else
  956.             {
  957.                 centerbone(PlayerHeadBone,0.95);
  958.                 centerbone(2,0.95);
  959.             }
  960.         }
  961. }
  962.  
  963. subroutine(Sub_ChangeStateToNormal)    //Switch from flying, falling etc. to normal
  964. {
  965.         state(_clr,StateCrouching);
  966.         state(_clr,StateFlying);
  967.         state(_clr,StateFalling);
  968.         state(_clr,StateJump);
  969.         state(_clr,StateGliding);
  970.         state(_clr,StateThrown);        //ttt
  971.         state(_or,StateNormal);
  972.         if(VAICon==0)
  973.         {
  974.             CallSub(Sub_SetCameraNormal);
  975.         }
  976.         state(_or,StateHeadTrack);
  977. }
  978.  
  979.  
  980. SubRoutine(Sub_CheckExecuteAnimEnd)    //Called if in StateExecuteAnim
  981. {
  982. //No parameters
  983.     if(vendofanim!=0 && VOAction!=VAction)
  984.     {
  985.         state(_clr,StateExecuteAnim);
  986.     }
  987. }
  988. SubRoutine(Sub_TurnCharacter,float(SubParm1),const(SubParm2),const(SubParm3))
  989. {
  990. //SubParm1: CurrentTurnSpeed
  991. //SubParm2: MaxTurnSpeed
  992. //SubParm3: TurnSpeedAcc
  993.         if(VAICon==0)
  994.         {
  995.             if(VTrigger&=_DIRright|_DIRleft)
  996.             {
  997.                 float(_seti,TmpFloat,VAnalog1);
  998.             }
  999.             else
  1000.             {
  1001.                 float(_set,TmpFloat,0);
  1002.                 float(_set,SubParm1,0);
  1003.             }
  1004.             float(_mul,TmpFloat,SubParm2);
  1005.             if(VTrigger==_DIRwalking)
  1006.             {
  1007.                 float(_mul,TmpFloat,0.1)
  1008.                 float(_mul,SubParm1,0.9)        //60% from current speed, 40% from new speed
  1009.             }
  1010.             else
  1011.             {
  1012.                 float(_mul,TmpFloat,0.4)
  1013.                 float(_mul,SubParm1,0.6)        //60% from current speed, 40% from new speed
  1014.             }
  1015.             float(_add,SubParm1,TmpFloat);
  1016.         }
  1017.         else
  1018.         {
  1019.             if(Vtrigger==_DIRleft)
  1020.             {
  1021.                 if(SubParm1>0)
  1022.                 {
  1023.                     float(_set,SubParm1,0);
  1024.                 }
  1025.                 float(_sub,SubParm1,SubParm3);
  1026.  
  1027.                 float(_set,TmpFloat,0);
  1028.                 float(_sub,TmpFloat,SubParm2);
  1029.                 if(SubParm1<Tmpfloat)
  1030.                 {
  1031.                     float(_set,SubParm1,TmpFloat);
  1032.                 }                                                   
  1033.             }
  1034.             elseif(Vtrigger==_DIRright)
  1035.             {
  1036.                 if(SubParm1<0)
  1037.                 {
  1038.                     float(_set,SubParm1,0);
  1039.                 }
  1040.                 float(_add,SubParm1,SubParm3);
  1041.                 if(SubParm1>SubParm2)
  1042.                 {
  1043.                     float(_set,SubParm1,SubParm2);
  1044.                 }
  1045.             }
  1046.             else
  1047.             {
  1048.                 float(_mul,SubParm1,0.2);
  1049.             }
  1050.             //float(_mul,SubParm1,0.8);
  1051.         }
  1052.         Turn(0,SubParm1,0);
  1053. }
  1054.  
  1055.  
  1056.  
  1057.  
  1058. SubRoutine(FireWeaponsAndCheckAttached,float(ShootDelayCounter),const(NumbFrames),const(ReloadStanding),const(ReloadCrouch),const(HeavyRecoil),const(LightRecoil),const(CrouchHeavyRecoil),const(CrouchLightRecoil))
  1059. {
  1060. /*
  1061.         if(vaction==ReloadCrouch || vaction==ReloadStanding)
  1062.         {
  1063.             if(VFrame==24)
  1064.             {
  1065.                 if(VWeaponAmmoType==_AmmoUnLimited)
  1066.                 {
  1067.                     sample(SFXreloadTorch,-1);
  1068.                 }
  1069.                 else
  1070.                 {
  1071.                     sample(SFXreload1,-1);
  1072.                 }
  1073.             }
  1074.             if(VFrame==42)
  1075.             {
  1076.                 if(VWeaponAmmoType==_AmmoUnLimited)
  1077.                 {
  1078.                     sample(SFXreloadTorch,-1);
  1079.                 }
  1080.                 else
  1081.                 {
  1082.                     sample(SFXreload,-1);
  1083.                 }
  1084.             }
  1085.             Direction(_clr,_DIRshoot);
  1086.         }
  1087. */
  1088.  
  1089.         if(vstate!=StateExecuteAnim && vtrigger==_DIRshoot && vtrigger==_DIRHaveGun && VTrigger==_DIRcombatmode)
  1090.         {
  1091.             float(_sub,ShootDelayCounter,1);
  1092.         }
  1093.         else
  1094.         {
  1095.             float(_set,ShootDelayCounter,NumbFrames);
  1096.         }
  1097.  
  1098.         if(VActorFlag==_AFlagAttached)
  1099.         {
  1100.             Direction(_clr,_DIRshoot);
  1101.         }
  1102.  
  1103.         //special hack for prost to drop weapon on heavy recoil
  1104.         if(VAIClass==_AIclassprost && VAction==GENHeavyRecoil && VFrame==1)
  1105.         {
  1106.             call(CheckAttached,_CADropWeapon);
  1107.             Direction(_clr,_DIRhavegun);
  1108.         }
  1109.  
  1110.         if(VTrigger==_DIRshoot)
  1111.         {
  1112.             //we no longer have a need for this delay , because the animation takes care of it!
  1113.             //and it also fucks up previous direction(_set) states !!!  TONY!!!
  1114.             if(ShootDelayCounter<0)
  1115.             {
  1116.                 call(CheckAttached,_CANormal);
  1117.                 if(VTrigger!=_DIRshoot)
  1118.                 {
  1119. /*                    if(VTrigger==_DIRTempFlag && VAICon!=0)
  1120.                     {
  1121.                         if(vstate==StateCrouching)
  1122.                         {
  1123.                             spawnaction(ReloadCrouch);
  1124.                         }
  1125.                         else
  1126.                         {
  1127.                             spawnaction(ReloadStanding);
  1128.                         }
  1129.                     }
  1130.                     elseif(VTrigger!=_DIRMove)
  1131. */
  1132.                     if(VTrigger!=_DIRMove)
  1133.                     {
  1134.                         if(VTrigger==_DIRHeavyRecoil)
  1135.                         {
  1136.                             if(vstate==StateCrouching)
  1137.                             {
  1138.                                 spawnaction(CrouchHeavyRecoil);
  1139.                             }
  1140.                             else
  1141.                             {
  1142.                                 spawnaction(HeavyRecoil);
  1143.                             }
  1144.                         }
  1145.                         else
  1146.                         {
  1147.                             if(VAIClass==_AIclassprost)
  1148.                             {
  1149.                                 if(VWeaponAmmoType==_AmmoMachineGun && VWeaponAmmoLeft>0)
  1150.                                 {
  1151.                                     if(vstate!=StateCrouching && VAction!=Prost1MachineGunFire)
  1152.                                     {
  1153.                                         spawnaction(Prost1MachineGunFire);
  1154.                                     }
  1155.                                 }
  1156.                             }
  1157.                             else
  1158.                             {
  1159.                                 if(vstate==StateCrouching)
  1160.                                 {
  1161.                                     spawnaction(CrouchLightRecoil);
  1162.                                 }
  1163.                                 else
  1164.                                 {
  1165.                                     spawnaction(LightRecoil);
  1166.                                 }
  1167.                             }
  1168.                         }
  1169.                     }
  1170.                 }
  1171.             
  1172.             }
  1173.             else
  1174.             {
  1175.             //    Direction(_clr,_DIRShoot);            //clear so we do the recoil animation
  1176.             //    call(CheckAttached,_CANormal);
  1177.             }
  1178.         }
  1179.         else
  1180.         {
  1181.             call(CheckAttached,_CANormal);
  1182.         }
  1183. //        callsub(Sub_CheckForPickups);
  1184.  
  1185.         if(VSpecialFlag==_sFLAGCloseToWall && VTrigger==_DIRhavegun)
  1186.         {
  1187.             if(VAction!=GENThrowGrenade)
  1188.             {
  1189.                 if(vstate==StateCrouching)
  1190.                 {
  1191.                     spawnaction(ReloadCrouch);
  1192.                 }
  1193.                 else
  1194.                 {
  1195.                     spawnaction(ReloadStanding);
  1196.                 }
  1197.             }
  1198.         }
  1199. }
  1200.  
  1201. //Check for start/end crouching
  1202. SubRoutine(Sub_CheckCrouching,const(CrouchDown),const(CrouchUp))
  1203. {
  1204.         if(vtrigger==_DIRcrouch)
  1205.         {
  1206.             direction(_clr,_DIRcrouch);
  1207.             if(vstate==StateCrouching)
  1208.             {
  1209.                 spawnaction(CrouchUp);
  1210.                 callsub(sub_ChangeStateToNormal)
  1211.                 state(_or,StateExecuteAnim);
  1212.             }
  1213.             elseif(vstate==StateNormal)
  1214.             {
  1215.                 spawnaction(CrouchDown);
  1216.                 callsub(sub_ChangeStateToNormal)
  1217.                 state(_or,StateExecuteAnim|StateCrouching);
  1218.             }
  1219.         }
  1220.  
  1221. }
  1222.  
  1223. SubRoutine(Sub_PrintStates)
  1224. {
  1225.         Print("---------------STATE ",0);
  1226.         if(VState==StateNormal)
  1227.         {
  1228.             Print("Normal ",0);
  1229.         }
  1230.         if(VState==StateFalling)
  1231.         {
  1232.             Print("Falling ",0);
  1233.         }
  1234.         if(VState==StateFlying)
  1235.         {
  1236.             Print("Flying ",0);
  1237.         }
  1238.         if(VState==StateGliding)
  1239.         {
  1240.             Print("Gliding ",0);
  1241.         }
  1242.         if(VState==StateHeadTrack)
  1243.         {
  1244.             Print("HeadTrack ",0);
  1245.         }
  1246.         if(VState==StateJump)
  1247.         {
  1248.             Print("Jump ",0);
  1249.         }
  1250.         if(VState==StateExecuteAnim)
  1251.         {
  1252.             Print("ExecuteAnim ",0);
  1253.         }
  1254.         if(VState==StateDrag)
  1255.         {
  1256.             Print("Drag ",0);
  1257.         }
  1258.         if(VState==StateDead)
  1259.         {
  1260.             Print("Dead ",0);
  1261.         }
  1262.         if(VState==StateCrawling)
  1263.         {
  1264.             Print("Crawling ",0);
  1265.         }
  1266.         if(VState==StateBangedHead)
  1267.         {
  1268.             Print("BangedHead ",0);
  1269.         }
  1270.         if(VState==StateOnFire)
  1271.         {
  1272.             Print("OnFire ",0);
  1273.         }
  1274.         if(VState==StateSteamed)
  1275.         {
  1276.             Print("Steamed ",0);
  1277.         }
  1278.         if(VState==StateBlind)
  1279.         {
  1280.             Print("Blind ",0);
  1281.         }
  1282.         if(VState==StatePatrol)
  1283.         {
  1284.             Print("Patrol ",0);
  1285.         }
  1286.         if(VState==StateAttack)
  1287.         {
  1288.             Print("Attack ",0);
  1289.         }
  1290.         if(VState==StateAttached)
  1291.         {
  1292.             Print("Attached ",0);
  1293.         }
  1294.         if(VState==StateHarpooned)
  1295.         {
  1296.             Print("Harpooned ",0);
  1297.         }
  1298.         if(VState==StateElectricShock)
  1299.         {
  1300.             Print("ElectricShock ",0);
  1301.         }
  1302.         if(VState==StateFollowPath)
  1303.         {
  1304.             Print("FollowPath ",0);
  1305.         }
  1306.         if(VState==StateExecutePathSequence)
  1307.         {
  1308.             Print("ExecutePathSequence ",0);
  1309.         }
  1310.         if(VState==StateCrouching)
  1311.         {
  1312.             Print("Crouching ",0);
  1313.         }
  1314.         if(VState==StateThrown)
  1315.         {
  1316.             Print("Thrown ",0);
  1317.         }
  1318.         if(VState==StateForceField)
  1319.         {
  1320.             Print("ForceField ",0);
  1321.         }
  1322. }
  1323.  
  1324.  
  1325. SubRoutine(Sub_CheckHanging,float(Hanging),const(ClimbUp),const(DropDown),const(ColOffset))
  1326. {
  1327.         if(VTrigger==_DIRhorcol)
  1328.         {
  1329.             //something claims to have touched him from below, verify
  1330.             vector(_set,TmpVector,0,0,0);
  1331.             float(_seti,TmpFloat,VColFeetSphereBottom);
  1332.             float(_sub,TmpFloat,5);
  1333.             vector(_sety,TmpVector,TmpFloat);
  1334.  
  1335.             vector(_copy,TmpVector2,TmpVector);
  1336.             vector(_suby,TmpVector2,175);
  1337.  
  1338.             Collision(TmpVector,TmpVector2);
  1339.             if(vcolflag==_DIRhorcol)
  1340.             {
  1341.                 //yup, something hit bob, so aforce him to climb up...
  1342.                 sample(SFXBobClimb,-1);
  1343.                 spawnaction(ClimbUp);
  1344.                 callsub(sub_ChangeStateToNormal);
  1345.                 state(_or,StateExecuteAnim);
  1346.                 float(_set,Hanging,0);
  1347.             }
  1348.         }
  1349.         elseif(VDirectionHold==_DIRforward)
  1350.         {
  1351.             if(Hanging==1)
  1352.             {
  1353.                 float(_set,Hanging,2);
  1354.             }
  1355.         }
  1356.         else
  1357.         {
  1358.             float(_set,Hanging,1);
  1359.         }
  1360.  
  1361.         if(VTrigger==_DIRforward && Hanging==2)
  1362.         {
  1363.             sample(SFXBobClimb,-1);
  1364.             spawnaction(ClimbUp);
  1365.             callsub(sub_ChangeStateToNormal);
  1366.             state(_or,StateExecuteAnim);
  1367.             float(_set,Hanging,0);
  1368.         }
  1369.         elseif(VTrigger==_DIRbackward)
  1370.         {
  1371.             state(_clr,StateExecuteAnim);
  1372.             state(_clr,StateNormal);
  1373.             SpawnAction(DropDown);
  1374.             state(_or,StateFalling);
  1375.             float(_set,Hanging,0);
  1376.             MoveFeetColOffset(0,0,ColOffset);
  1377.             float(_set,TmpFloat,ColOffset);
  1378.             float(_inv,TmpFloat);
  1379.             move(0,0,TmpFloat);
  1380.         }
  1381. }
  1382.  
  1383. SubRoutine(TurnToFaceSound)//TH, when Bob running behind Cop, Cop turns to face sound
  1384. {
  1385.         call(ClrPath);
  1386.         state(_clr,StateExecutePathSequence);
  1387.         state(_clr,StateFollowPath);
  1388.         call(AIPickdest,10);
  1389.         call(AIupdatetargetpos);
  1390.         VAItargetfound=0;
  1391.         call(ClrAnalogValues); //for sub_turncharacter
  1392. //        float(_clr,TmpFloat);
  1393. //        float(_sub,TmpFloat,vtargetangle);
  1394. printi("vtargetangle:   ",vtargetangle);
  1395.         if(vtargetangle>0)
  1396.         {
  1397.             spawnaction(CopTurnRight);
  1398.             turn(0,45,0);
  1399. //            turn(0,TmpFloat,0);
  1400. //            Direction(_set,_DIRright);
  1401.         }
  1402.         else
  1403.         {
  1404.             spawnaction(CopTurnLeft);
  1405.             turn(0,-45,0);
  1406. //            turn(0,TmpFloat,0);
  1407. //            Direction(_set,_DIRleft);
  1408.         }
  1409. }
  1410.  
  1411. SubRoutine(TurnToFaceSoundSlow)//TH
  1412. {
  1413.         VAItargetfound=0;
  1414.         call(ClrAnalogValues);
  1415.         call(AIPickdest,10);
  1416.         call(AIupdatetargetpos);
  1417. printi("vtargetangle:   ",vtargetangle);
  1418.         if(vtargetangle>0)
  1419.         {
  1420.         //    spawnaction(CopTurnRight);
  1421.             turn(0,45,0);
  1422.         //    Direction(_set,_DIRright);
  1423.         }
  1424.         else
  1425.         {
  1426.         //    spawnaction(CopTurnLeft);
  1427.             turn(0,-45,0);
  1428.         //    Direction(_set,_DIRleft);
  1429.         }
  1430. }
  1431.  
  1432.