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

  1.  
  2.         if(VActorFlag==_AFLAGattached && VAICon==0)//for 2-man animation, changes guy who punches him in the face into an enemy
  3.         {
  4.             print("IM DOING ATTACHED ACTION. STILL HERE 777777777777777");
  5.         }
  6.  
  7.  
  8.         float(_declare,RandomGnkNoisem,0);
  9.         float(_declare,RandomGnkNoisea,200);
  10.         float(_declare,ShootDelayCounter,0)
  11.         float(_declare,JumpIdleCounter,0);
  12.         float(_declare,JumpPressCounter,0);
  13.         float(_declare,DownwardPull,0);
  14.         float(_declare,TurnSpeed,0);
  15.         float(_declare,ColAngleCorrectNeeded,0);
  16.         float(_declare,ForceRunFrames,0);
  17.         float(_declare,AirSpeedForward,0);
  18.         float(_declare,AirSpeedSideways,0);
  19.         float(_declare,FallStartAltitude,0);
  20.         float(_declare,SmokeCount,1000);
  21.         float(_declare,FireCount,0);
  22.         float(_declare,ActionOK,1);
  23.         float(_declare,KeyPressCounter,0);
  24.         float(_declare,ActorDeathType,0);
  25.         float(_declare,DropDelay,100);
  26.         float(_declare,DieCounter,0);
  27.  
  28.         float(_declare,stickumDelay,0);
  29.         //float(_declare,batterydelay,0);
  30.  
  31.         float(_declare,riotshieldhitcount,0);
  32.         float(_declare,riotshieldoncount,18);
  33.         float(_declare,riotshieldoffcount,0);
  34.  
  35.         float(_declare,CurrentDirection,_DIRforward|_DIRwalking);
  36.         float(_declare,SeenFlag,0);
  37.  
  38.         //used in aicode
  39.         float(_declare,Counter,0);                    //Not Used?
  40.         float(_declare,AIChoiceVar,0);
  41.         float(_declare,AIEncounterVar,0);
  42.         float(_declare,AIGrenadeCounter,200);
  43.         float(_declare,AILastPathTurn,0);
  44.  
  45.         float(_declare,limbblownoff,0);
  46.         float(_declare,SteamCounter,0);
  47.  
  48.         float(_declare,GeigerCounter,0);
  49.  
  50.         vector(_declare,WeaponPickUpPos,0,0,0);
  51.  
  52.         if(VAICon==0)
  53.         {
  54.             callsub(Sub_PrintStates);
  55.         }
  56.  
  57.         call(CheckColSphereOffset,GENClimbUp);
  58.  
  59.  
  60.         if(VActorFlag==_AFLAGinitialize)            //re-initialize after a loadgame
  61.         {
  62.             if(GeigerCounter==1)
  63.             {
  64.                 sample(SFXGeigerCounter,-1);
  65.             }
  66.         }
  67.  
  68.  
  69.         if(VActiveTime==0)
  70.         {
  71.             call(CheckForPickup,12,_ClassWeapon);
  72.             callsub(Sub_ChangeStateToNormal);
  73.  
  74.             vector(_settoactorpos,TmpVector);
  75.             vector(_copyy,TmpVector,FallStartAltitude);
  76.         }
  77.  
  78.         callsub(Sub_SqueezeCheck,CopCrush);
  79.  
  80.         if(VActorFlag==_AFLAGnorotation)
  81.         {
  82.             print("Removing direction flags",TurnSpeed);
  83.             Direction(_clr,_DIRleft|_DIRright);
  84.             if(VAICon==0)
  85.             {
  86.                 call(ClrAnalogValues);            //for sub_turncharacter
  87.                 float(_set,TurnSpeed,0);
  88.             }
  89.         }
  90.  
  91.         float(_declare,PlayOnce,0);
  92.         if(VAICon==0 && vstate==statedead && PlayOnce==0)
  93.         {
  94.             message("YOU CALL YOURSELF THE MESSIAH?",400,10);
  95.             callsub(Sub_RandomWalkieKillSFX);
  96.             float(_set,PlayOnce,1);
  97.             call(ChangeSniperMode,0,0);
  98.         }
  99.         elseif(vstate!=statedead)
  100.         {
  101.             float(_set,PlayOnce,0);
  102.         }
  103.  
  104.         if(VTrigger!=_DIRhavegun)
  105.         {
  106.             ActorFlag(_clr,_AFLAGlogon);
  107.         }
  108.  
  109. /*
  110.         if(VAICon==0 && vstate==StateDead && VDifficulty==_DifficultyEasy)
  111.         {
  112.             message("YOU CALL YOURSELF THE MESSIAH ?",400,10);
  113.             callsub(Sub_RandomWalkieKillSFX);
  114.             call(ChangeSniperMode,0,0);
  115.         }
  116. */
  117.         if(AIAbility&=_AIAFakeWeapon)
  118.         {
  119.             Direction(_or,_DIRhavegun);        //to fool the enemies into believing she is packing
  120.         }
  121.  
  122.         if(AIAbility&=_AIAHideWeapon && VTrigger==_DIRhavegun && VTrigger!=_DIRmove)
  123.         {
  124.             print("check for holster/unholster");
  125.  
  126.             if(VTrigger==_DIRcombatmode)
  127.             {
  128.                 print("Weapon visible");
  129.                 if(VActorFlag==_AFlagweaponinvisible)
  130.                 {
  131.                     if(VAction==GENUnHolsterGun && VFrame==11)
  132.                     {
  133.                         ActorFlag(_clr,_AFLAGweaponinvisible);
  134.                     }
  135.                     else
  136.                     {
  137.                         spawnaction(GENUnHolsterGun);
  138.                     }
  139.                 }
  140.             }
  141.             else
  142.             {
  143.                 print("Weapon invisible");
  144.                 if(VActorFlag!=_AFlagweaponinvisible)
  145.                 {
  146.                     if(VAction==GENHolsterGun && VFrame==20)
  147.                     {
  148.                         ActorFlag(_or,_AFLAGweaponinvisible);
  149.                     }
  150.                     else
  151.                     {
  152.                         spawnaction(GENHolsterGun);
  153.                     }
  154.                 }
  155.             }
  156.         }
  157.  
  158.         if(AIAbility&=_AIAAlwaysInCombatMode)
  159.         {
  160.             Direction(_or,_DIRcombatmode);
  161.         }
  162.  
  163.         if(VActorFlag==_AFLAGconfused && AIAbility&!=_AIAFlashVisors)
  164.         {
  165.             call(AIorder,_set,_AIstateConfused);
  166.             call(AIorder,_set,_AIinspecialmode);
  167.         }
  168.  
  169.         if(VActorFlag==_AFLAGradiated)
  170.         {
  171.             ActorFlag(_clr,_AFLAGradiated);
  172.             if(VAIClass==_AIClassScientist&&VRank==_RankScum)            // If radiation worker
  173.             {
  174.                 if(GeigerCounter==0)
  175.                 {
  176.                     sample(SFXGeigerCounter,-1);
  177.                     float(_set,GeigerCounter,1);
  178.                 }
  179.             }
  180.             else
  181.             {
  182.                 call(AIorder,_set,_AIstateRadioactive);
  183.                 call(AIorder,_set,_AIinspecialmode|_AIdontdopickdest);
  184.             }
  185.         }
  186.         else
  187.         {
  188.             if(GeigerCounter==1)
  189.             {
  190.                 samplestop(SFXGeigerCounter);
  191.                 float(_set,GeigerCounter,0);
  192.             }
  193.         }
  194.  
  195.  
  196.         if(AIAbility&=_AIAShield && VActorFlag==_AFLAGshieldon)
  197.         {
  198.             print("Shield On:   ",AIAbility);
  199.  
  200.             if(riotshieldhitcount>0)
  201.             {
  202.                 //we've been hit ..aarrggghhhh!!!!
  203.                 callsub(Sub_riotshield,fx_riotshlda1hit,fx_riotshlda2hit,fx_riotshlda3hit,fx_riotshlda4hit,fx_riotshlda5hit,fx_riotshlda6hit,emptyfloat);
  204.                 float(_sub,riotshieldhitcount,1);
  205.             }
  206.             else
  207.             {
  208.                 if(riotshieldoncount==18)
  209.                 {
  210.                     sample(SFXRiotShieldOn,-1);
  211.                 }
  212.  
  213.                 if(riotshieldoncount>0)
  214.                 {
  215.                     //shield forming on
  216.                     callsub(Sub_riotshield,fx_riotshlda1on,fx_riotshlda2on,fx_riotshlda3on,fx_riotshlda4on,fx_riotshlda5on,fx_riotshlda6on,riotshieldoncount);
  217.                     float(_sub,riotshieldoncount,1);
  218.                 }
  219.                 else
  220.                 {
  221.                     //normal sheild active!!!
  222.                     callsub(Sub_riotshield,fx_riotshlda1,fx_riotshlda2,fx_riotshlda3,fx_riotshlda4,fx_riotshlda5,fx_riotshlda6,emptyfloat);
  223.                 }
  224.             }
  225.  
  226.             float(_set,riotshieldoffcount,18);
  227.  
  228.             if(VTrigger==_DIRactorbulletcol)
  229.             {
  230.                 if(VColAngle>3072 || VColAngle<1024)
  231.                 {
  232.                     sample(SFXRiotShield,-1);
  233.  
  234.                     float(_set,riotshieldoncount,0);
  235.                     float(_set,riotshieldhitcount,18);
  236.  
  237.                     call(RestoreOldHealth);
  238.                     //printilog("ColAngle:   ",VColAngle);
  239.                     Direction(_clr,_DIRactorbulletcol);
  240.                     SpecialFlag(_clr,_sFLAGLostALimb);
  241.                     SpecialFlag(_clr,_sFLAGTargetAimKillShot);
  242.                     SpecialFlag(_clr,_sFLAGTargetAimCloseRange);
  243.                     ActorFlag(_clr,_AFLAGSniped);
  244.                 }
  245.             }
  246.         }
  247.         else
  248.         {
  249.             float(_set,riotshieldhitcount,0);
  250.             float(_set,riotshieldoncount,18);
  251.  
  252.             if(riotshieldoffcount==18)
  253.             {
  254.                 sample(SFXRiotShieldOff,-1);
  255.             }
  256.  
  257.             if(riotshieldoffcount>0)
  258.             {
  259.                 float(_set,tmpfloat,18);
  260.                 float(_sub,tmpfloat,riotshieldoffcount);
  261.                 callsub(Sub_riotshield,fx_riotshlda1off,fx_riotshlda2off,fx_riotshlda3off,fx_riotshlda4off,fx_riotshlda5off,fx_riotshlda6off,tmpfloat);
  262.                 float(_sub,riotshieldoffcount,1);
  263.             }
  264.         }
  265.  
  266.         //don't move up higher than this to prevent sequencing problems
  267.         if(VHealth<=0 && VTrigger==_DIRalive)
  268.         {
  269.             Direction(_clr,_DIRalive);
  270.             //sample(SFXJustDiedReact,-1);    consistently repeating and crashing game!!!
  271.         }
  272.  
  273.         if(VColMaterialProperties==_MATDrown || VAction==CopDrown)
  274.         {
  275.             if(VAction!=CopDrown || Vaction!=CopDrownDead || Vaction!=CopDrownDeadLoop)
  276.             {
  277.                 state(_or,StateExecuteAnim);
  278.                 SpawnAction(CopDrown);
  279.             }
  280.             if(DieCounter==0)
  281.             {
  282.                 state(_or,StateDead);
  283.                 direction(_clr,_DIRalive);
  284.                 callsub(Sub_Deposses);
  285.                 if(VAICon==0)
  286.                 {
  287.                     call(LockCamera,true);
  288.                 }
  289.                 float(_add,DieCounter,1);
  290.                 move(0,-75,0);
  291.             }
  292.             else
  293.             {
  294.                 if(vrnd<15&&DieCounter<60)
  295.                 {
  296.                     callsub(Sub_RandomWaterSFX);
  297.                 }
  298.  
  299.                 if(DieCounter>=125 && VAICon==0)
  300.                 {
  301.                     killactor();
  302.                 }
  303.                 /* Add some bubble from mouth here
  304.                 if(vrnd<20)
  305.                 {
  306.                 }
  307.                 */
  308.                 float(_add,DieCounter,1);
  309.             }
  310.             move(0,-1,0);
  311.         }
  312.  
  313.         //XXXdoesn't belong in CopGen
  314.         if(VAction==CopEatenSlowLink || VAction==CopEatenLink)
  315.         {
  316.             State(_or,StateDead);
  317.             Direction(_clr,_DIRalive);
  318.  
  319.             if(VFrame>=130 && VFrame<=175 && VRnd<20)
  320.             {
  321.                 spawnparticle(fx_bloodspurt,1,emptyvector,emptyvector,-1);        //1 is lower torso
  322.                 spawnparticle(fx_bloodspray,1,emptyvector,emptyvector,-1);
  323.                 spawnparticle(fx_blood,1,emptyvector,emptyvector,-1);
  324.                 spawnparticle(fx_blood,1,emptyvector,emptyvector,-1);
  325.             }
  326.         }
  327.         //XXXdoesn't belong in CopGen
  328.         if(VAction==MedicWorking)
  329.         {
  330.             if(VFrame>=90 && VFrame<=100 && VRnd<10)
  331.             {
  332.                 spawnparticle(fx_bloodspurt,8,emptyvector,emptyvector,-1);        //12 is right hand
  333.                 spawnparticle(fx_bloodspray,8,emptyvector,emptyvector,-1);
  334.                 spawnparticle(fx_blood,8,emptyvector,emptyvector,-1);
  335.                 spawnparticle(fx_blood,8,emptyvector,emptyvector,-1);
  336.             }
  337.         }
  338.  
  339.  
  340.         //    ActorDeathType - 1 is die from fire after walking around blinded
  341.         if(VState==StateDead)
  342.         {
  343.             direction(_clr,_DIRcombatmode);
  344.             Direction(_clr,_DIRaiRemoveFlags);
  345.             if(VAIState==_AIStateHide)
  346.             {
  347.                 //to free up corner occupied by dead actor
  348.                 call(AIclrhidenode);
  349.                 call(AIorder,_set,_AIStateidle);
  350.             }
  351.         }
  352.         //elseif(VAICon!=0 && aitoggle==0 && VState!=StateThrown && VState!=StateHarpooned && VState!=StateCrawling && VActorFlag!=_AFLAGattached && VActorFlag!=_AFLAGnoai)
  353.         elseif(VAICon!=0 && aitoggle==0 && VState!=StateThrown && VState!=StateHarpooned && VState!=StateCrawling && VActorFlag!=_AFLAGnoai && VState!=StateExecuteAnim && VState!=StateExecuteAnim && VActorFlag!=_AFLAGattached)
  354.         {
  355.  
  356.             // **************************************************************************
  357.             // ************ Start of AI Control Code ************************************
  358.             // **************************************************************************
  359. /*
  360.             printi("PathDestDist:     ",VPathDestDistance);
  361.             printi("PathDestAngle:    ",VPathDestAngle);
  362.             printi("PickDestAngle:    ",VPickDestAngle);
  363.             printi("TargetDistance:   ",vtargetdistance);
  364.             printi("TargetAngle:      ",vtargetangle);
  365. */
  366.             float(_declare,pRndAngle,0);
  367.             vector(_declare,pHaloOuterPos,0,0,0);
  368.             vector(_declare,pHaloPos,0,0,-50);
  369.  
  370.             Direction(_clr,_DIRaiRemoveFlags)
  371.  
  372.             if(VTrigger!=_DIRHaveGun && VState!=StateCrawling)
  373.             {
  374.                 call(IsPickupClose,_ClassWeapon,115,TmpFloat,TmpVector);
  375.                 if(vtrigger==_DIRTempFlag && TmpFloat!=0)
  376.                 {
  377.                     print("Trying to pick up weapon");
  378.                     Direction(_set,_DIRaction);
  379.                     float(_set,ActionOK,1);
  380.                 }
  381.             }
  382.  
  383.             call(AIcorrectforobstacles,5);
  384.             float(_set,CurrentDirection,0);
  385.  
  386.             //************************************************************************
  387.             //*********        HIDE CONTROL      ****************************************
  388.             //************************************************************************
  389.             if(vaistate==_AIstateHide)
  390.             {
  391.                 #include    "messiahscripts\enemies\cophide.hxx"
  392.             }
  393.             //************************************************************************
  394.             //*********        END OF HIDE CONTROL      *********************************
  395.             //************************************************************************
  396.             elseif(VAIstatehigh==_AInomove)
  397.             {
  398.                 printi("Moving routine no move:    ",VAIhastarget);
  399.                 if(VAIstatehigh!=_AInoturn)
  400.                 {
  401.                     if(VAIhastarget==_AIenemy)
  402.                     {
  403.                         callsub(Sub_AI1WayAlignToTarget);
  404.                     }
  405.                     else
  406.                     {
  407.                         CallSub(Sub_AI1WayAlignToPickDestAngle)
  408.                     }
  409.                 }
  410.             }
  411.             elseif(vstate==StateFollowPath || vstate==StateExecutePathSequence)
  412.             {
  413.                 //moving pattern for normal patroling
  414.                 print("Moving routine for normal patrolling   ");
  415.  
  416.                 if(VTrigger==_DIRcombatmode && VAIstatehigh!=_AIinspecialmode)
  417.                 {
  418.                     direction(_clr,_DIRcombatmode);        //not in attack
  419.                 }
  420.  
  421.                 if(VAIhastarget==0)
  422.                 {
  423.                     print("Has target");
  424.                     CallSub(Sub_AI1WayAlignToPickDestAngle)
  425.                     if(VPathDestDistance>20)
  426.                     {
  427.                         if(vaistate==_AIstateRun)
  428.                         {
  429.                             printi("In state run:   ",vpickdestanglecorr);
  430.                             print("In state run:   ",CurrentDirection);
  431.                             if(vpickdestanglecorr<128 && vpickdestanglecorr>-128)    //aligned with target but standing still
  432.                             {
  433.                                 float(_set,CurrentDirection,_DIRforward);
  434.                             }
  435.                         }
  436.                         else
  437.                         {
  438.                             if(vpickdestanglecorr<256 && vpickdestanglecorr>-256)    //aligned with target but standing still
  439.                             {
  440.                                 float(_set,CurrentDirection,_DIRforward|_DIRwalking);
  441.                             }    
  442.                         }
  443.                     }
  444.                 }
  445.                 else
  446.                 {
  447.                     CallSub(Sub_AI1WayAlignToTarget);
  448.                     if(vtargetdistance>800 || AIUsage&=_AIUAlwaysRun)
  449.                     {
  450.                         if(vtargetdistance>80)
  451.                         {
  452.                             CallSub(Sub_AI8WayMoveRun,CurrentDirection);
  453.                         }
  454.                     }
  455.                     elseif(vtargetdistance>80)
  456.                     {
  457.                         CallSub(Sub_AI8WayMoveWalk,CurrentDirection);
  458.                     }
  459.                 }
  460.             }
  461.             elseif(vtargetdistance>200)
  462.             {
  463.                 //moving pattern for any anything but patrolling
  464.                 print("Moving routine for anything but patrolling");
  465.  
  466.                 //float(_set,AIFlags,_AIHideReset);        //clr hide control so ready for next hide session
  467.  
  468.                 //if(vaistate==_AIstateAttack && VAItargetfound==_AIenemy && vtargetdistance<1000)        //if in attack and close
  469.                 //if(vaistate==_AIstateAttack || vaistate==_AIstatesearch || vaistate==_AIstateGetWeapon)
  470.                 //{
  471.                     print("In special control routine");
  472.                     CallSub(Sub_AI1WayAlignToTarget);
  473.                     if(VTrigger==_DIRhavegun)
  474.                     {
  475.                         if(vtargetdistance>800)
  476.                         {
  477.                             CallSub(Sub_AI8WayMoveRun,CurrentDirection);
  478.                         }
  479.                         else
  480.                         {
  481.                             CallSub(Sub_AI8WayMoveWalk,CurrentDirection);
  482.                         }
  483.                     }
  484.                     else
  485.                     {
  486.                         CallSub(Sub_AI8WayMoveRun,CurrentDirection);
  487.                     }
  488.                     if(vtrigger!=_DIRcombatmode)                        //put character in combatmode
  489.                     {
  490.                         direction(_set,_DIRcombatmode);
  491.                     }
  492.  
  493.                     CallSub(Sub_AIShootCheck,Counter,AIGrenadeCounter);
  494.                 //}
  495.                 //else
  496.                 //{
  497. /*
  498.                     if(vaistate!=_AIstateAttack && vaistate!=_AIstatesearch)
  499.                     {
  500.                         if(VAIstatehigh!=_AIinspecialmode)
  501.                         {
  502.                             direction(_clr,_DIRcombatmode);                            //not close enough for combatmode or not in attack
  503.                         }
  504.                     }
  505.                     else
  506.                     {
  507.                         direction(_set,_DIRcombatmode);
  508.                     }
  509.  
  510.                     if(vpickdestanglecorr<-20)
  511.                     {
  512.                         if(vpickdestanglecorr<-2000 && AILastPathTurn>0)
  513.                         {
  514.                             turn(0,19,0);
  515.                         }
  516.                         else
  517.                         {
  518.                             turn(0,-19,0);
  519.                         }
  520.                         //Direction(_set,_DIRleft);
  521.                     }
  522.                     elseif(vpickdestanglecorr>20)
  523.                     {
  524.                         if(vpickdestanglecorr>2000 && AILastPathTurn<0)
  525.                         {
  526.                             turn(0,-19,0);
  527.                         }
  528.                         else
  529.                         {
  530.                             turn(0,19,0);
  531.                         }
  532.                         //Direction(_set,_DIRright);
  533.                     }
  534.                     float(_seti,AILastPathTurn,vpickdestanglecorr);
  535.  
  536.  
  537.                     if(CurrentDirection!=_DIRwalking && CurrentDirection==_DIRforward)
  538.                     {
  539.                         if(vpickdestanglecorr>256 || vpickdestanglecorr<-256)    //if not aligned with target stop running
  540.                         {
  541.                             float(_set,CurrentDirection,_DIRforward|_DIRwalking);
  542.                         }
  543.  
  544.                         if(vpathdestdistance<500)                                //if closer than 500 units to target stop running
  545.                         {
  546.                             float(_set,CurrentDirection,_DIRforward|_DIRwalking);
  547.                         }
  548.                     }
  549.                     elseif(CurrentDirection==_DIRwalking && CurrentDirection==_DIRforward)
  550.                     {
  551.                         if(vaistate==_AIstateAttack && vpathdestdistance>600 && vpickdestanglecorr<256 && vpickdestanglecorr>-256)    //if aligned and far from target start running
  552.                         {
  553.                             float(_set,CurrentDirection,_DIRforward);
  554.                         }
  555.                         if(vpickdestanglecorr>256 || vpickdestanglecorr<-256)    //if not aligned with target stop walking until aligned
  556.                         {
  557.                             float(_set,CurrentDirection,0);
  558.                         }
  559.                     }
  560.                     elseif(CurrentDirection==0)
  561.                     {
  562.                         if(vpickdestanglecorr<256 && vpickdestanglecorr>-256)    //aligned with target but standing still
  563.                         {
  564.                             float(_set,CurrentDirection,_DIRforward|_DIRwalking);
  565.                         }
  566.                     }
  567. */
  568.  
  569.                 //}
  570.             }
  571.             else    //condition true if character is closer to subject than 200 units
  572.             {
  573.                 print("Close up attack move");
  574.                 if(vaistate==_AIstateAttack || vaistate==_AIstatesearch)
  575.                 {
  576.                     print("Close up attack move");
  577.                     CallSub(Sub_AI1WayAlignToTarget)
  578.                     CallSub(Sub_AIShootCheck,Counter,AIGrenadeCounter);
  579.                     if(VTrigger!=_DIRhavegun || VAItargetfound!=_AIenemy)
  580.                     {
  581.                         if(vtargetdistance>90)
  582.                         {
  583.                             CallSub(Sub_AI8WayMoveWalk,CurrentDirection);
  584.                         }
  585.                         if(VTrigger!=_DIRhavegun)
  586.                         {
  587.                             if(AIAbility&=_AIAPossesion && AIUsage&=_AIUFindHost)
  588.                             {
  589.                                 if(VTargetAngle<100 && VTargetAngle>-100)
  590.                                 {
  591.                                     Direction(_set,_DIRjump);
  592.                                 }
  593.                             }
  594.                             else
  595.                             {
  596.                                 Direction(_set,_DIRshoot);
  597.                             }
  598.                         }
  599.                     }
  600.                 }
  601.                 else
  602.                 {
  603.                     //printi("aligning to pickdestcorr  ",vtargetangle);
  604.                     print("In close up mode");
  605.                     CallSub(Sub_AI1WayAlignToPickDestAngle)
  606.                 }
  607.  
  608.                 if(VState!=StateCrawling)
  609.                 {
  610.                     direction(_set,_DIRaction);
  611.                     float(_set,ActionOK,1);
  612.                 }
  613.             }
  614.  
  615.             if(AIUsage&=_AIUAlwaysRun)
  616.             {
  617.                 float(_clr,CurrentDirection,_DIRwalking);
  618.             }
  619.  
  620. /*            //testing if illegal Directions were entered
  621.             if(vstate==StateCrouching)
  622.             {
  623.                 if(CurrentDirection&=_DIRrun)                //walk is not possible in crouch mode
  624.                 {
  625.                     float(_set,CurrentDirection,_DIRwalk);
  626.                 }
  627.                 if(CurrentDirection&=_DIRrunbackward)        //walk is not possible in crouch mode
  628.                 {
  629.                     float(_set,CurrentDirection,_DIRbackward);
  630.                 }
  631.                 if(CurrentDirection&=_DIRrunsideleft)        //walk is not possible in crouch mode
  632.                 {
  633.                     float(_set,CurrentDirection,_DIRsideleft);
  634.                 }
  635.                 if(CurrentDirection&=_DIRrunsideright)        //walk is not possible in crouch mode
  636.                 {
  637.                     float(_set,CurrentDirection,_DIRsideright);
  638.                 }
  639.             }
  640. */
  641.             //printlog("CurrentDirection:  ",CurrentDirection);
  642.             //printilog("Pickdestangle:      ",vpickdestanglecorr);
  643.  
  644. //            if(vaistate!=_AIstateRun)                    //not the best implementation but will do for now
  645. //            {
  646.                 Direction(_set,CurrentDirection);
  647. //            }
  648. //            else
  649. //            {
  650. //                Direction(_clr,_DIRwalking);
  651. //                Direction(_set,_DIRforward);
  652. //            }
  653.  
  654.             //*****************************
  655.             //******** jump code **********
  656.             //*****************************
  657.             if(vtrigger==_DIRvercol && vstate!=StateJump && vaistate!=_AIstateHide)
  658.             {
  659.                 Collision(0,-20,0, 0,-20,-130);
  660.                 if(vcolflag==_DIRvercol)
  661.                 {
  662.                     Collision(0,80,0, 0,80,-130);
  663.                     if(vcolflag!=_DIRvercol)
  664.                     {
  665.                         if(JumpPressCounter>30)
  666.                         {
  667.                             Direction(_set,_DIRjump);
  668.                         }
  669.                         else
  670.                         {
  671.                             float(_add,JumpPressCounter,1);
  672.                         }
  673.                     }
  674.                 }
  675.             }
  676.             elseif(vstate==StateJump)
  677.             {
  678.                 Direction(_set,_DIRjump);
  679.             }
  680.             else
  681.             {
  682.                 float(_set,JumpPressCounter,0);
  683.             }
  684.             //*****************************
  685.             //***** end of jump code ******
  686.             //*****************************
  687.  
  688.             if(VTrigger|=_DIRMoveBits)
  689.             {
  690.                 Direction(_set,_DIRMove);
  691.             }
  692.             else
  693.             {
  694.                 Direction(_set,_noDIR);
  695.             }
  696.  
  697.             //print("CurrentDirection:   ",CurrentDirection);
  698.  
  699.             if(VTrigger==_DIRactoractorcol && VTrigger!=_DIRmove)
  700.             {
  701.                 if(VAIStatehigh!=_AIcombatmodereact && VAIStatehigh!=_AIcloseupaction)
  702.                 {
  703.                     sample(SFXBumpIntoReact,-1);
  704.                 }
  705.                 Direction(_clr,_DIRactoractorcol);
  706.             }
  707.  
  708.             #include    "messiahscripts\enemies\copai.hxx"
  709.  
  710. // **************************************************************************
  711. // ************ End of AI Control Code **************************************
  712. // **************************************************************************
  713.         }
  714.         elseif(VAIcon==0)
  715.         {
  716. //Player control
  717.             call(AIupdateAIvars);            //to update aicounters like TimeNotTarget
  718.             call(AIcheckfortarget,10);        //for LineOfSight reasons etc. this is called for player character also
  719.         //    call(AIsetlockedonactortotarget);
  720.  
  721.             if(VAItimenottarget>30)
  722.             {
  723.                 call(AIreinstateactoraiclass);
  724.             }
  725.         }
  726.  
  727.         if(vtrigger==_DIRpossesion)
  728.         {
  729.             float(_set,PlayerHeadBone,4);
  730.             callsub(Sub_InitPossesion,GENPossesed,GENCrouchPossession,GENCrawlPossession);
  731.             //Possesion callback effect init here
  732.             call(MatrixCallback,_SXEXPActorMatrixBulb,0.1,120);
  733.             resetbone(PlayerHeadBone);
  734.             resetbone(2);
  735.             ActorFlag(_or,_AFLAGpossesed);
  736.             
  737.             ActorFlag(_clr,_AFLAGnorotation);    //(Torg) make sure this is cleared out so the player can turn
  738.         }
  739.         elseif(vtrigger==_DIRdepossesion)
  740.         {
  741.             if(DepossesionAbilityActive!=0)
  742.             {
  743.                 spawnactor(BulletAntiSatan,0,0,-100);        //Satan depossesion weapon
  744.             }
  745.  
  746.             callsub(Sub_InitDepossesion,GENDepossesed,GENCrouchDepossession,GENCrawlDepossession)
  747.             //DePossesion callback effect init here
  748.             call(MatrixCallback,_SXEXPActorMatrixBulb,0.1,120);
  749.             ActorFlag(_clr,_AFLAGpossesed);
  750.         }
  751.  
  752.  
  753.         if(VState!=StateDead && VActorFlag!=_AFLAGattached)
  754.         {
  755.             callSub(Sub_ActionKeyHandler,ActionOK);
  756.  
  757.             if(vstate|=StateAllNormalStates && vtrigger!=_DIRhavegun)
  758.             {
  759.                 if(AIAbility&=_AIAPickUpWeapon && VAIStateHigh!=_AIinspecialmode && VState!=StateCrawling)
  760.                 {
  761.                     if(VState==StateCrouching)
  762.                     {
  763.                         callSub(Sub_CheckActionPickupCrouch,GENPickupCrouch,14,0,0);
  764.                     }
  765.                     else
  766.                     {
  767.                         callSub(Sub_CheckActionPickup,GENPickup,14,GENPickupChest,36);
  768.                     }
  769.                 }
  770.                 call(DeadClassRank,true,175);
  771.                 callsub(BackGroundTriggerChecks);
  772.                 call(DeadClassRank,false);
  773.                 callsub(Sub_BatteryHandler);
  774.  
  775.                 if(VAICon==0)
  776.                 {
  777.                     callsub(Sub_CombatKeyHandler,KeyPressCounter,20);
  778.                 }
  779.             }
  780.             else
  781.             {
  782.                 call(DeadClassRank,true,175);
  783.                 callsub(BackGroundTriggerChecks);
  784.                 call(DeadClassRank,false);
  785.                 callsub(Sub_BatteryHandler);
  786.                 if(VAICon==0)
  787.                 {
  788.                     callsub(Sub_CombatKeyHandler,KeyPressCounter,20);
  789.                 }
  790.                 if(vstate==StateNormal)
  791.                 {
  792.                     if(VState==StateCrouching)
  793.                     {
  794.                         callSub(Sub_CheckActionDropCrouch,GENPickupCrouch,14,0,0,DropDelay);
  795.                     }
  796.                     else
  797.                     {
  798.                         callSub(Sub_CheckActionDrop,GENPickup,14,GENPickupChest,36,DropDelay);
  799.                     }
  800.                 }
  801.             }
  802.  
  803.             if(VActorFlag==_AFLAGresetfallalt)                //need to be after bacgroundtriggerchecks prevent death
  804.             {
  805.                 ActorFlag(_clr,_AFLAGresetfallalt);
  806.                 vector(_settoactorpos,TmpVector);
  807.                 vector(_copyy,TmpVector,FallStartAltitude);
  808.             }
  809.  
  810.  
  811.  
  812.             callSub(Sub_CheckRemainingActions,GENPressGun,11);
  813.  
  814.             callsub(Sub_Headtrack);                    //Track head against object
  815.  
  816.             //if in the electric shock animations do not check for fall, it's done for you!!
  817.             if(VState==StateThrown)
  818.             {
  819.                 CallSub(Sub_CheckThrownFallDamage,FallStartAltitude,CopMaxFall);
  820.                 if(VState==StateNormal)
  821.                 {
  822.                     callsub(Sub_TurnCharacter,TurnSpeed,CopMaxTurnSpeedWounded,CopTurnAccWounded);
  823.                 }
  824.             }
  825.             elseif(VState!=StateElectricShock)
  826.             {
  827.                 CallSub(Sub_CheckFallDamage,AIAbility,GENTouchDown,FallStartAltitude,CopMaxFall,DamageCopFall,GENFallDead,0,GENFallInPlace);
  828.             }
  829.  
  830.             if(AIAbility&=_AIAPossesion)
  831.             {
  832.                 if(Vstate==StateFlying||vstate==StateFalling||vstate==StateJump||vstate==StateGliding)
  833.                 {
  834.                     call(CheckForPossesion);    //DiameterSqr
  835.                 }
  836.             }
  837.  
  838.         }
  839.  
  840.         //If character was sniped do bonespecific damage else call Sub_CheckHit() as usual
  841.         if(AIAbility&!=_AIANoBoneCollision && VActorFlag==_AFLAGSniped && VState==StateNormal && VState!=StateThrown)
  842.         {
  843.             ActorFlag(_clr,_AFLAGSniped);
  844.  
  845.             if(VState!=StateCrawling)
  846.             {
  847.                 //if distance greater than 70 feet with pumpgun, then no killshot or specific bone shots!
  848.                 if(VSpecialFlag==_sFLAGTargetAimCloseRange)
  849.                 {
  850.                     if(VColBone>=15 && VColBone<=18)                //left leg
  851.                     {
  852.                         SpawnAction(GENShotInLLeg);
  853.                         state(_or,StateCrawling);
  854.                         state(_or,StateExecuteAnim);
  855.                         sample(SFXShotInLegReact,-1);
  856.                         call(CheckAttached,_CADropWeaponAndShells);
  857.                         CallSub(Sub_ChangeStateToNormal);
  858.                     }
  859.                     elseif(VColBone>=19 && VColBone<=22)            //right leg
  860.                     {
  861.                         SpawnAction(GENShotInRLeg);
  862.                         state(_or,StateCrawling);
  863.                         state(_or,StateExecuteAnim);
  864.                         sample(SFXShotInLegReact,-1);
  865.                         call(CheckAttached,_CADropWeaponAndShells);
  866.                         CallSub(Sub_ChangeStateToNormal);
  867.                     }
  868.                     else
  869.                     {
  870.                         if(VColAngle>=3072 || VColAngle<=1024)        //hit in front
  871.                         {
  872.                             if(VSpecialFlag==_sFLAGLostALimb)
  873.                             {
  874.                                 State(_or,StateDead);
  875.                                 call(CheckAttached,_CADropWeaponAndShells);
  876.                                 spawnaction(CopHeadBlownOffDead);
  877.                             }
  878.                             elseif(VColBone==11 || VColBone==12 && VHealth<500)    //right hand and weak
  879.                             {
  880.                                 call(CheckAttached,_CADropWeaponAndShells);
  881.                             }
  882.                             elseif(VColBone==3 || VColBone==4)            //face, neck
  883.                             {
  884.                                 //SpawnAction(GENShotFrHead);
  885.                                 SpawnAction(CopThrownSpin);
  886.                                 State(_or,StateDead);
  887.                                 call(CheckAttached,_CADropWeaponAndShells);
  888.                             }
  889.                             elseif(VColBone==1)                        //lower torso (balls really)
  890.                             {
  891.                                 SpawnAction(GENShotFrTorso);
  892.                                 State(_or,StateDead);
  893.                                 call(CheckAttached,_CADropWeaponAndShells);
  894.                             }
  895.                             elseif(VColBone==2 || VColBone==9 || VColBone==10)    // upper torso, right collar and upper right shoulder
  896.                             {
  897.                                 SpawnAction(GENShotFrRShoulder);    //right shoulder
  898.                             }
  899.                             elseif(VColBone>=5 && VColBone<=8)        //left collar -> left hand
  900.                             {
  901.                                 SpawnAction(GENShotFrLShoulder);    //left shoulder
  902.                             }
  903.                             else
  904.                             {
  905.                                 SpawnAction(GENShotGeneric);        //generic shot anim
  906.                             }
  907.                         }
  908.                         elseif(VColAngle>1024 && VColAngle<3072)    //hit in back
  909.                         {
  910.                             if(VSpecialFlag==_sFLAGLostALimb)
  911.                             {
  912.                                 State(_or,StateDead);
  913.                                 call(CheckAttached,_CADropWeaponAndShells);
  914.                                 spawnaction(CopHeadBlownOffDead);
  915.                             }
  916.                             elseif(VColBone==11 || VColBone==12 && VHealth<500)        //right hand and weak
  917.                             {
  918.                                 call(CheckAttached,_CADropWeaponAndShells);
  919.                             }
  920.                             elseif(VColBone==3 || VColBone==4)            //face, neck
  921.                             {
  922.                                 SpawnAction(CopThrownSpin);
  923.                                 //SpawnAction(GENShotBkHead);
  924.                                 State(_or,StateDead);
  925.                                 call(CheckAttached,_CADropWeaponAndShells);
  926.                             }
  927.                             elseif(VColBone==1 || VColBone==2 || VColBone==5 || VColBone==9) //ltorso,rtorso,lcollar,rcollar
  928.                             {
  929.                                 SpawnAction(GENShotBkBack);
  930.                             }
  931.                             else
  932.                             {
  933.                                 spawnaction(GENShotGeneric);
  934.                             }
  935.                         }
  936.                     }
  937.                 }
  938.                 else
  939.                 {
  940.                     spawnaction(GENShotGeneric);
  941.                 }
  942.             }
  943.             else
  944.             {
  945.                 spawnaction(CopShotCrawl);
  946.             }
  947.         }
  948.         else
  949.         {
  950.             //if(VState!=StateThrown && VState!=StateAttached)
  951.             if(VState!=StateThrown && VActorFlag!=_AFLAGattached)
  952.             {
  953.                 callsub(Sub_CheckHit,AIAbility,GENWoundLight,GENWoundLightRun,GENWoundLightNoBreak,FireCount,GENPoleDead,GENCrouchWoundLight,GENThrownForward,GENThrownBack,GENThrownLeft,GENThrownRight);
  954.             }
  955.         }
  956.  
  957.         if(vstate==StateOnFire)    //These first if-statements are just for effects
  958.         {
  959.             if(vrnd<20)
  960.             {
  961.                 CheckActorCollision(0,emptyVector,96,0,_COLfire,DamageFlameThrower);
  962.             }
  963.  
  964.             if(FireCount==0)
  965.             {
  966.                 sample(SFXOnFire,-1);
  967.                 sample(SFXGenericBurn,-1);
  968.  
  969. /*                if(vrnd<50)
  970.                 {
  971.                     sample(SFXActorPainInFire1,-1);
  972.                 }
  973.                 else
  974.                 {
  975.                     sample(SFXActorPainInFire2,-1);
  976.                 }
  977.  
  978.                 samplestop(SFXcough);
  979. */
  980.                 float(_rnd2,ActorFireType,70);
  981.                 float(_set,ActorDeathType,1);
  982.             }
  983.             callsub(Sub_ActorFireEffect,SmokeCount,FireCount,255)
  984.         }
  985.         elseif(vstate==StateBlind)
  986.         {
  987.             if(SmokeCount==0)
  988.             {
  989.                 float(_set,FireCount,0);
  990.                 samplestop(SFXGenericBurn);
  991.                 sample(SFXcough,-1);
  992.             }
  993.             callsub(Sub_ActorSmokeEffect,SmokeCount,255)
  994.  
  995.             if(vstate!=StateDead && ActorDeathType==1)
  996.             {
  997.                 //actor will die as he's been roasted
  998.                 call(SubtractHealth,0,DamageAfterFire);
  999.             }
  1000.         }
  1001.  
  1002.         //The last number here is used if they have to fall on their knees when energy is low
  1003.         callsub(Sub_CheckDeadOrDying,AIAbility,GENPoleDead,GENCrawlDead,GENStandDead,GENCrawlSpreadOut,0,GENFallToCrawl,GENCrouchDead,0);    //0=health when entering crawling-mode
  1004.  
  1005.         if(VState==StateDead)
  1006.         {
  1007.             callsub(Sub_LostAnyLimbsLately,limbblownoff);
  1008.             if(VTrigger==_DIRdepossesion)
  1009.             {
  1010.                 callsub(Sub_InitDepossesion,GENDepossesed,GENCrouchDepossession,GENCrawlDepossession)
  1011.                 //DePossesion callback effect init here
  1012.                 call(MatrixCallback,_SXEXPActorMatrixBulb,0.1,120);
  1013.                 direction(_clr,_DIRdepossesion);
  1014.             }
  1015.             if(VCurSet=="s2r9")
  1016.             {
  1017.                 callsub(BackGroundTriggerChecks);
  1018.             }
  1019.         }
  1020.  
  1021.         if(vstate==StateExecuteAnim)
  1022.         {
  1023.             callsub(Sub_CheckExecuteAnimEnd);
  1024.  
  1025.             if(AIAbility&!=_AIASpecialSecondaryWeapon)
  1026.             {
  1027.                 if(VOAction==GENThrowGrenade)
  1028.                 {
  1029.                     if(VFrame==0)
  1030.                     {
  1031.                         callsub(Sub_SpawnGrenade);
  1032.  
  1033.                         if(vrnd<50)
  1034.                         {
  1035.                             sample(SFXThrow1,-1);
  1036.                         }
  1037.                         else
  1038.                         {
  1039.                             sample(SFXThrow2,-1);
  1040.                         }
  1041.                     }
  1042.                     callsub(Sub_TurnCharacter,TurnSpeed,CopMaxTurnSpeed,CopTurnAcc);
  1043.                 }
  1044.                 elseif(VAction==GENCrouchGrenade)
  1045.                 {
  1046.                     if(VFrame==26)
  1047.                     {
  1048.                         callsub(Sub_SpawnGrenade);
  1049.  
  1050.                         if(vrnd<50)
  1051.                         {
  1052.                             sample(SFXThrow1,-1);
  1053.                         }
  1054.                         else
  1055.                         {
  1056.                             sample(SFXThrow2,-1);
  1057.                         }
  1058.                     }
  1059.                     callsub(Sub_TurnCharacter,TurnSpeed,CopMaxTurnSpeed,CopTurnAcc);
  1060.                 }
  1061.             }
  1062.             if(vaction==GENPossesed)
  1063.             {
  1064.                 callsub(Sub_TurnCharacter,TurnSpeed,CopMaxTurnSpeed,CopTurnAcc);
  1065.             }
  1066.             elseif(VOAction==GENClimbUp && VState!=StateExecuteAnim)
  1067.             {
  1068.                 Move(0,0,CopHangMoveIn);
  1069. //                MoveFeetColOffset(0,0,CopHangMoveIn);
  1070.                 //callsub(Sub_CheckHanging,KeyPressCounter,CopClimbUp,CopFall,CopHangMoveIn);
  1071.             }
  1072.         }
  1073.         elseif(vstate==StateCrawling||vstate==StateBlind||vstate==StateOnFire||vstate==StateSteamed||vstate==StateHarpooned||vstate==StateElectricShock)
  1074.         {
  1075.             direction(_clr,_DIRcombatmode);
  1076.  
  1077.             if(VState!=StateDead)
  1078.             {
  1079.                 if(vstate==StateHarpooned)    //Here are the if-statements that control the actions when you are badly wounded
  1080.                 {
  1081.                     if(RandomGnkNoisem<0)
  1082.                     {
  1083.                         float(_rnd2,RandomGnkNoisem,100);
  1084.                         float(_add,RandomGnkNoisem,RandomGnkNoisea);
  1085.                         float(_add,RandomGnkNoisea,30);
  1086.  
  1087.                         callsub(Sub_RandomHarpoonedSFX,100);
  1088.                     }
  1089.                     else
  1090.                     {
  1091.                         float(_sub,RandomGnkNoisem,1);
  1092.                     }
  1093.  
  1094.                     callsub(Sub_Harpooned,GENHarpoonFrontHold,GENHarpoonFrontHitWall,GENHarpoonFrontIdle,GENHarpoonFrontBurn,GENHarpoonBackHold,GENHarpoonBackHitWall,GENHarpoonBackIdle,GENHarpoonBackBurn);
  1095.                     callsub(Sub_Deposses);
  1096.                 }
  1097.                 else
  1098.                 {
  1099.                     callsub(Sub_TurnCharacter,TurnSpeed,CopMaxTurnSpeedWounded,CopTurnAccWounded);
  1100.                     if(vstate==StateCrawling)
  1101.                     {
  1102.                         sample(SFXCrawlingReact,-1);
  1103.                 //        if(RandomGnkNoisem<0)
  1104.                 //        {
  1105.                 //            float(_rnd2,RandomGnkNoisem,100);
  1106.                 //            float(_add,RandomGnkNoisem,RandomGnkNoisea);
  1107.                 //            float(_add,RandomGnkNoisea,30);
  1108.                 //            callsub(Sub_RandomHarpoonedSFX,85);
  1109.                 //        }
  1110.                 //        else
  1111.                 //        {
  1112.                 //            float(_sub,RandomGnkNoisem,1);
  1113.                 //        }
  1114.  
  1115.                         //is this where he has to roll over and hug his knees, and scream if you force him to move?
  1116.                         callsub(Sub_Crawling,GENCrawlSpreadOut,GENFallToCrawl)
  1117.                     }
  1118.                     elseif(vstate==StateOnFire || vstate==StateSteamed || vstate==StateBlind)
  1119.                     {
  1120.                         callsub(Sub_BurnedSteamedBlind,GENBurningRollOnFloor,GENBurnedIdle,GENGettingBurned,GENBlindForward,GENBlindBackwards,GENBurningRunInCircle,GENSlowGetUpFace,SteamCounter,GENIdle)
  1121.                     }
  1122.                     elseif(vstate==StateElectricShock)
  1123.                     {
  1124.  
  1125.                         callsub(Sub_ElectricShock,GENelectricshock0,GENelectricshock1);
  1126.  
  1127.                         if(vaction==GENelectricshock0)
  1128.                         {
  1129.                             if(vframe==1)
  1130.                             {
  1131.                                 sample(SFXElectricShock1,-1);
  1132.                                 sample(SFXElectrocuteReact,-1);
  1133.                                 call(SubtractHealth,0,DamageElectric);
  1134.                             }
  1135.                         }
  1136.                         elseif(vaction==GENelectricshock1)
  1137.                         {
  1138.                             if(vendofanim!=0)
  1139.                             {
  1140.                                 sample(SFXElectricShock2,-1);
  1141.  
  1142.                                 call(PlaneTriggerQuadrant,TmpFloat,1);
  1143.                                 if(TmpFloat==0)
  1144.                                 {
  1145.                                     spawnaction(GENThrownForward);
  1146.                                     move(0,0,-150);
  1147.                                 }
  1148.                                 elseif(TmpFloat==1)
  1149.                                 {
  1150.                                     spawnaction(GENThrownLeft);
  1151.                                     move(150,0,0);
  1152.                                 }
  1153.                                 elseif(TmpFloat==2)
  1154.                                 {
  1155.                                     spawnaction(GENThrownBack);
  1156.                                     move(0,0,150);
  1157.                                 }
  1158.                                 elseif(TmpFloat==3)
  1159.                                 {
  1160.                                     spawnaction(GENThrownRight);
  1161.                                     move(-150,0,0);
  1162.                                 }
  1163. //                                state(_change,StateElectricShock,StateThrown);
  1164.                                 state(_clr,StateElectricShock);
  1165.                             }
  1166.                         }
  1167.  
  1168.                     }
  1169.                 }
  1170.             }
  1171.         }
  1172. /*        DO NOT UNCOMMENT WITHOUT ASKING SAXS
  1173.         elseif(VState==StateThrown)
  1174.         {
  1175.             print("In thrown sequence");
  1176.             if (VOAction==CopGetUpFromFrontFaceDown || VOAction==CopGetUpFromBack || VOAction==CopGetUpFromLeftFaceDown || VOAction==CopGetUpFromRightFaceDown)
  1177.             {
  1178.                 CallSub(sub_ChangeStateToNormal);
  1179.             }
  1180.     //        elseif(VAction!=CopThrownSpin && VAction!=CopThrownForward && VAction!=CopThrownForwardLand && VAction!=CopThrownRight && VAction!=CopThrownRightLand && VAction!=CopThrownLeft && VAction!=CopThrownLeftLand && VAction!=CopThrownBack && VAction!=CopThrownBackLand)
  1181.     //        {
  1182.     //            //PrintLog("Resetting StateThrown! risky...");
  1183.     //            //CallSub(sub_ChangeStateToNormal);
  1184.     //            state(_clr,StateThrown);
  1185.     //        }
  1186.         }
  1187. */
  1188.         elseif(VTrigger==_DIRalive && VState!=StateThrown && VActorFlag!=_AFLAGattached)
  1189.         {
  1190.             CallSub(Sub_CheckClimbUp,GENClimbUp,60,ColAngleCorrectNeeded,20,CopHangMoveIn);
  1191.             if(vstate==StateNormal && VTrigger!=_DIRTempFlag)    //TempFlag comes from checkclimbup, if set, character is gonna climb up
  1192.             {
  1193.                 if(VState!=StateCrouching)
  1194.                 {
  1195.                     //callsub(Sub_AlignToWallAndCheckRunUpStairs,GENRunUpStairs,GENIdle,GENIdleHitWall,ColAngleCorrectNeeded,GENIdleHitWallFront,GENHitWallSpreadOut,-0.95,CopSpreadOut,GENSpreadOutGun,ForceRunFrames)
  1196.                     //callsub(Sub_AlignToWallAndCheckRunUpStairs,GENRunUpStairs,GENIdle,GENIdleHitWall,ColAngleCorrectNeeded,GENIdleHitWallFront,GENHitWallSpreadOut,-0.95,GENSpreadOut,GENSpreadOutGun,ForceRunFrames)
  1197.                     if(VAIClass==_AIclassmale && VAICon==0)
  1198.                     {
  1199.                         callsub(Sub_AlignToWallAndCheckRunUpStairs,GENRunUpStairs,GENIdle,GENIdleHitWall,ColAngleCorrectNeeded,GENIdleHitWall,GENHitWallSpreadOut,-0.95,GENSpreadOut,GENSpreadOutGun,ForceRunFrames)
  1200.                     }
  1201.                 }
  1202.                 callsub(Sub_CheckForIdleLongTime,GENIdle,GENIdleLongTime);
  1203.  
  1204.                 //control for Sub_SpawnGrenade: stickum control, so it doesn't look stupid!
  1205.                 if(VAICon==0)
  1206.                 {
  1207.                     //only PlayerOne controls stickem
  1208.                     if(StickEmState==StickEmReady&&VTrigger==_DIRGrenade)
  1209.                     {
  1210.                         //we got here , which means we have thrown a StickEm grenade, and now we are going to explode it!
  1211.                         float(_set,StickEmState,StickEmExploding);
  1212.                         direction(_clr,_DIRGrenade);
  1213.                         float(_set,stickumDelay,60);
  1214.                     }
  1215.  
  1216.                     if(VInventoryType==_AmmoGrenadeStickEm)
  1217.                     {
  1218.                         float(_sub,stickumDelay,1);
  1219.                         if(stickumDelay>0)
  1220.                         {
  1221.                             direction(_clr,_DIRGrenade);
  1222.                         }
  1223.                     }
  1224.                 }
  1225.  
  1226.                 if(VTrigger==_DIRGrenade && VInventoryLeft>0)
  1227.                 {
  1228.                     state(_or,StateExecuteAnim);
  1229.                     if(VState==StateCrouching)
  1230.                     {
  1231.                         spawnaction(GENCrouchGrenade);
  1232.                     }
  1233.                     else
  1234.                     {
  1235.                         spawnaction(GENThrowGrenade);
  1236.                     }
  1237.                 }
  1238.  
  1239.                 CallSub(Sub_CheckCrouching,GENCrouchDown,GENCrouchUp);
  1240.  
  1241.                 CallSub(Sub_CheckJumpFallDown,AIAbility,GENRunUpStairs,JumpPressCounter,DownwardPull,CopJumpSpeed,GENJump,AirSpeedForward,AirSpeedSideways,GENFall,CopAirSpeed)
  1242.                 CallSub(Sub_CheckSliding,GENRunUpStairs,GENSlide);
  1243.  
  1244.                 if(vtrigger==_DIRaction)
  1245.                 {
  1246.                     call(CheckForGrab,200,TmpFloat);    //Deletes diraction flag if there is no grap possible  !??!
  1247.                     if(TmpFloat!=0)
  1248.                     {
  1249.                         if(TmpFloat&=16)                            //on stomach
  1250.                         {
  1251.                             if(TmpFloat&=1)
  1252.                             {
  1253.                                 spawnaction(GENKickHeadFD);
  1254.                             }
  1255.                             elseif(TmpFloat&=2)
  1256.                             {
  1257.                                 spawnaction(GENKickRightFD);
  1258.                             }
  1259.                             elseif(TmpFloat&=4)
  1260.                             {
  1261.                                 spawnaction(GENKickCrotchFD);
  1262.                             }
  1263.                             elseif(TmpFloat&=8)
  1264.                             {
  1265.                                 spawnaction(GENKickLeftFD);
  1266.                             }
  1267.                         }
  1268.                         else                                        //on back
  1269.                         {
  1270.                             if(TmpFloat&=1)
  1271.                             {
  1272.                                 spawnaction(GENKickHeadFU);
  1273.                             }
  1274.                             elseif(TmpFloat&=2)
  1275.                             {
  1276.                                 spawnaction(GENKickRightFU);
  1277.                             }
  1278.                             elseif(TmpFloat&=4)
  1279.                             {
  1280.                                 spawnaction(GENKickCrotchFU);
  1281.                             }
  1282.                             elseif(TmpFloat&=8)
  1283.                             {
  1284.                                 spawnaction(GENKickLeftFU);
  1285.                             }
  1286.                         }
  1287.                     }
  1288.                 }
  1289.  
  1290.                 if(VActorFlag!=_AFLAGnorotation)
  1291.                 {
  1292.                     callsub(Sub_TurnCharacter,TurnSpeed,CopMaxTurnSpeed,CopTurnAcc);
  1293.                 }
  1294.             }
  1295.             elseif(vstate==StateFalling||vstate==StateJump)
  1296.             {
  1297.                 if(vstate==StateJump)
  1298.                 {
  1299.                     CallSub(Sub_Jump,JumpPressCounter,DownwardPull,CopMinHoldJumpAction,CopJumpGravity,2,0);
  1300.                 }
  1301.                 callsub(Sub_TurnCharacter,TurnSpeed,CopMaxTurnSpeedAir,CopTurnAccAir);
  1302.                 callsub(Sub_MoveInAir,AirSpeedSideways,AirSpeedForward,CopAirSpeed,CopAirBulb);
  1303.                 CallSub(Sub_CheckSliding,GENRunUpStairs,GENSlide);
  1304.             }
  1305.         }
  1306.  
  1307.         if(VState!=StateThrown && VAction!=GenClimbup && VActorFlag!=_AFLAGattached)
  1308.         {
  1309.             if(VTrigger==_DIRcombatmode && VTrigger!=_DIRhavegun && VTrigger==_DIRshoot)
  1310.             {
  1311.                 print("Fire pressed and you have no gun");
  1312.                 //if(VState!=StateDead && Vaction!=CopBoxing)
  1313.                 //{
  1314.                     //SpawnAction(CopBoxing);
  1315.                     //if(vrnd<50)
  1316.                     //{
  1317.                     //    sample(SFXThrow1,-1);
  1318.                     //}
  1319.                     //else
  1320.                     //{
  1321.                     //    sample(SFXThrow2,-1);
  1322.                     //}
  1323.                 //}7
  1324.             }
  1325.             else
  1326.             {
  1327.                 callsub(FireWeaponsAndCheckAttached,ShootDelayCounter,1,GENReload,GENReloadCrouch,GENHeavyRecoil,GENLightRecoil,GENCrouchHeavyRecoil,GENCrouchLightRecoil);
  1328.             }
  1329.         }
  1330.  
  1331.         //footsteps
  1332.         if(VAICon==0 && vtrigger==_DIRleft||vtrigger==_DIRright||vtrigger==_DIRforward||vtrigger==_DIRbackward||vtrigger==_DIRsideleft||vtrigger==_DIRsideright)
  1333.         {
  1334.             if(VSpecialFlag==_sFLAGTrodInGoo)
  1335.             {
  1336.                 if(vrnd<50)
  1337.                 {
  1338.                     spawnparticle(fx_footbloodspray,18,emptyvector,emptyvector,-1);
  1339.                 }
  1340.                 else
  1341.                 {
  1342.                     spawnparticle(fx_footbloodspray,22,emptyvector,emptyvector,-1);
  1343.                 }
  1344.                 sample(SFXBlood2,-1);
  1345.             }
  1346.             else
  1347.             {
  1348.                 callsub(Sub_CheckFootSteps,_sFLAGLeftFoot);
  1349.                 callsub(Sub_CheckFootSteps,_sFLAGRightFoot);
  1350.             }
  1351.         }
  1352.  
  1353.  
  1354.         //weapons
  1355.         if(VAICon==0 && VSpecialFlag==_sFLAGPickedUpGun)
  1356.         {
  1357.             sample(SFXWeaponPickUp,-1);
  1358.         }
  1359.  
  1360.         if(VAICon==0 && VSpecialFlag==_sFLAGPickedUpAmmo)
  1361.         {
  1362.             if(vrnd<33)
  1363.             {
  1364.                 sample(SFXWeaponAmmo1,-1);
  1365.             }
  1366.             elseif(vrnd<66)
  1367.             {
  1368.                 sample(SFXWeaponAmmo2,-1);
  1369.             }
  1370.             else
  1371.             {
  1372.                 sample(SFXWeaponAmmo3,-1);
  1373.             }
  1374.         }
  1375.  
  1376.  
  1377.         if(VState==StateForceField)
  1378.         {
  1379.             State(_clr,StateForceField);
  1380.             float(_add,DownWardPull,CopJumpGravity);
  1381.  
  1382.  
  1383.  
  1384.         }
  1385.  
  1386.