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

  1.  
  2.         float(_declare,ShootDelayCounter,0)
  3.         float(_declare,JumpIdleCounter,0);
  4.         float(_declare,JumpPressCounter,0);
  5.         float(_declare,DownwardPull,0);
  6.         float(_declare,TurnSpeed,0);
  7.         float(_declare,ColAngleCorrectNeeded,0);
  8.         float(_declare,ForceRunFrames,0);
  9.         float(_declare,AirSpeedForward,0);
  10.         float(_declare,AirSpeedSideways,0);
  11.         float(_declare,FallStartAltitude,0);
  12.         float(_declare,SmokeCount,1000);
  13.         float(_declare,FireCount,0);
  14.         float(_declare,ActionOK,1);
  15.         float(_declare,KeyPressCounter,0);
  16.         float(_declare,DropDelay,100);
  17.         float(_declare,ActorDeathType_f,0);
  18.         float(_declare,SteamCounter,0);
  19.  
  20.         vector(_declare,WeaponPickUpPos,0,0,0);
  21.  
  22.         if(VHealth<=0)
  23.         {
  24.             Direction(_clr,_DIRalive);
  25.         }
  26.  
  27.         if(VActiveTime==0)
  28.         {
  29.             call(CheckForPickup,12,_ClassWeapon);
  30.  
  31.             vector(_settoactorpos,TmpVector);
  32.             vector(_copyy,TmpVector,FallStartAltitude);
  33.         }
  34.  
  35.  
  36.         callsub(Sub_SqueezeCheck,Prost1Crush);
  37.  
  38.         if(VActorFlag==_AFLAGnorotation)
  39.         {
  40.             print("Removing direction flags",TurnSpeed);
  41.             Direction(_clr,_DIRleft|_DIRright);
  42.             call(ClrAnalogValues);            //for sub_turncharacter
  43.             float(_set,TurnSpeed,0);
  44.         }
  45.  
  46.         float(_declare,PlayOnce,0);
  47.         if(VAICon==0 && vstate==statedead && PlayOnce==0)
  48.         {
  49.             message("YOU CALL YOURSELF THE MESSIAH ?",400,10);
  50.             callsub(Sub_RandomWalkieKillSFX);
  51.             float(_set,PlayOnce,1);
  52.             call(ChangeSniperMode,0,0);
  53.         }
  54.         elseif(vstate!=statedead)
  55.         {
  56.             float(_set,PlayOnce,0);
  57.         }
  58. /*
  59.         if(VAICon==0 && vstate==statedead && VDifficulty==_DifficultyEasy)
  60.         {
  61.             message("YOU CALL YOURSELF THE MESSIAH ?",400,10);
  62.             callsub(Sub_RandomWalkieKillSFX);
  63.             call(ChangeSniperMode,0,0);
  64.         }
  65. */
  66.         if(VActiveTime==0)
  67.         {
  68.             call(CheckForPickup,12,_ClassWeapon);
  69.  
  70.             vector(_settoactorpos,TmpVector);
  71.             vector(_copyy,TmpVector,FallStartAltitude);
  72.         }
  73.  
  74.         if(VState==StateDead)
  75.         {
  76.             direction(_clr,_DIRcombatmode);
  77.             Direction(_clr,_DIRaiRemoveFlags);
  78.         }
  79.         elseif(vAICon!=0 && aitoggle==0)
  80.         {
  81. // **************************************************************************
  82. // **************************************************************************
  83. // **************************************************************************
  84.  
  85.                 //AIPickDest(100,1);
  86.  
  87.                 Direction(_clr,_DIRaiRemoveFlags)
  88.  
  89.                 if(VTrigger!=_DIRHaveGun)
  90.                 {
  91.                     call(IsPickupClose,_ClassWeapon,115,TmpFloat,TmpVector);
  92.                     if(vtrigger==_DIRTempFlag && TmpFloat!=0)
  93.                     {
  94.                         Direction(_set,_DIRaction);
  95.                         //float(_set,ActionOK,1);
  96.                         //direction(_clr,_DIRactionhold);
  97.                     }
  98.                 }
  99.  
  100. /*                float(_declare,shootcounter,0);
  101.                 if(vlockedondistance>30 && vaistate!=_aistateidle)
  102.                 {
  103.                     if(vlockedonangle<-20)
  104.                     {
  105.                         turn(0,-19,0);
  106.                         //Direction(_set,_DIRleft);
  107.                     }
  108.                     elseif(vlockedonangle>20)
  109.                     {
  110.                         turn(0,19,0);
  111.                         //Direction(_set,_DIRright);
  112.                     }
  113.  
  114.  
  115.                     if(vtargetdistance>600)
  116.                     {
  117.                         //if(vlockedonangle<50 && vlockedonangle>-50)
  118.                         //{
  119.                             if(vlockedonangle<20 && vlockedonangle>-20)
  120.                             {
  121.                                 Direction(_set,_dirrun);
  122.                                 if(vstate==statenormal && vtargetdistance>1000 && vtargetdistance<1500 && vrnd<5)
  123.                                 {
  124.                     //                Direction(_set,_DIRGrenade);
  125.                                 }
  126.                             }
  127.                         //}
  128.                     }
  129.                     else
  130.                     {
  131.                         if(vtargetdistance>100 && vlockedonangle<90 && vlockedonangle>-90)
  132.                         {
  133.                             //if(vlockedondistance<300)
  134.                             if(vtrigger==_DIRhavegun)
  135.                             {
  136.                                 if(vrnd<10 || shootcounter!=0)
  137.                                 {
  138.                                     Direction(_set,_DIRshoot);
  139.                                     float(_add,shootcounter,1);
  140.                                     if(shootcounter>60)
  141.                                     {
  142.                                         Direction(_clr,_DIRshoot);
  143.                                         float(_set,shootcounter,0);
  144.                                     }
  145.                                 }
  146.                             }
  147.                             else
  148.                             {
  149.                                 Direction(_clr,_DIRshoot);
  150.                             }
  151.                     
  152.                             Direction(_set,_DIRforward|_DIRwalking);
  153.                         }
  154.                     }
  155.  
  156.                 }
  157. */
  158.  
  159.                 if(vtrigger==_DIRvercol && vstate!=StateJump)
  160.                 {
  161.                     Collision(0,-20,0, 0,-20,-130);
  162.                     if(vcolflag==_DIRvercol)
  163.                     {
  164.                         Collision(0,60,0, 0,60,-130);
  165.                         if(vcolflag!=_DIRvercol)
  166.                         {
  167.                             Direction(_set,_DIRjump);
  168.                         }
  169.                     }
  170.                 }
  171.                 elseif(vstate==StateJump)
  172.                 {
  173.                     Direction(_set,_DIRjump);
  174.                 }
  175.  
  176.                 if(VTrigger|=_DIRMoveBits)
  177.                 {
  178.                     Direction(_set,_DIRMove)
  179.                 }
  180.  
  181. // **************************************************************************
  182. // **************************************************************************
  183. // **************************************************************************
  184.  
  185.         }
  186.         elseif(VAIcon==0)
  187.         {
  188. //Player control
  189.             call(AIupdateAIvars);            //to update aicounters like TimeNotTarget
  190.             call(AIcheckfortarget,10);        //for LineOfSight reasons etc. this is called for player character also
  191.  
  192.             if(vtrigger==_DIRpossesion)
  193.             {
  194.                 float(_set,PlayerHeadBone,4);
  195.                 callsub(Sub_InitPossesion,prost1Possesed);
  196.                 //Possesion callback effect init here
  197.                 call(MatrixCallback,_SXEXPActorMatrixBulb,0.1,120);
  198.             }
  199.             elseif(vtrigger==_DIRdepossesion)
  200.             {
  201.                 callsub(Sub_InitDepossesion,Prost1Depossesed)
  202.                 //DePossesion callback effect init here
  203.                 call(MatrixCallback,_SXEXPActorMatrixBulb,0.1,120);
  204.             }
  205.  
  206.             if(VAItimenottarget>30)
  207.             {
  208.                 call(AIreinstateactoraiclass);
  209.             }
  210.  
  211.             callsub(Sub_CombatKeyHandler,KeyPressCounter,10);
  212. /*
  213.             callsub(Sub_CombatKeyHandler,KeyPressCounter,10);
  214.             
  215.             if(vtrigger==_DIRpossesion)
  216.             {
  217.                 float(_set,PlayerHeadBone,4);
  218.                 callsub(Sub_InitPossesion,Prost1Possesed);
  219.             }
  220.             elseif(vtrigger==_DIRdepossesion)
  221.             {
  222.                 callsub(Sub_InitDepossesion,Prost1Depossesed)
  223.             }
  224. */
  225.         }
  226.  
  227.  
  228.  
  229.         if(vstate!=StateDead)
  230.         {
  231.             callSub(Sub_ActionKeyHandler,ActionOK);
  232.             if(vstate==StateNormal && vtrigger!=_DIRhavegun)
  233.             {
  234.                 if(VState==StateCrouching)
  235.                 {
  236.                     callSub(Sub_CheckActionPickupCrouch,Prost1PickupCrouch,12,0,0);
  237.                 }
  238.                 else
  239.                 {
  240.                     callSub(Sub_CheckActionPickup,Prost1Pickup,14,0,0);
  241.                 }
  242.  
  243.                 callsub(BackGroundTriggerChecks);
  244.             }
  245.             else
  246.             {
  247.                 callsub(BackGroundTriggerChecks);
  248.                 if(vstate==StateNormal)
  249.                 {
  250.                     if(VState==StateCrouching)
  251.                     {
  252.                         callSub(Sub_CheckActionDropCrouch,Prost1PickupCrouch,12,0,0,DropDelay);
  253.                     }
  254.                     else
  255.                     {
  256.                         callSub(Sub_CheckActionDrop,Prost1Pickup,14,0,0,DropDelay);
  257.                     }
  258.                 }
  259.             }
  260.             if (vtrigger!=_DIRhavegun)
  261.             {
  262.                 callSub(Sub_CheckRemainingActions,Prost1PressGun,22);
  263.             }
  264.             else
  265.             {
  266.                 callSub(Sub_CheckRemainingActions,Prost1PressGun,22);
  267.             }
  268.  
  269.             callsub(Sub_Headtrack);                    //Track head against object
  270.  
  271.             //if in the electric shock animations do not check for fall, it's done for you!!
  272.  
  273.             
  274.             if(VState==StateThrown)
  275.             {
  276.                 CallSub(Sub_CheckThrownFallDamage,FallStartAltitude,Prost1MaxFall);
  277.                 if(VState==StateNormal)
  278.                 {
  279.                     callsub(Sub_TurnCharacter,TurnSpeed,Prost1MaxTurnSpeedWounded,Prost1TurnAccWounded);
  280.                 }
  281.             }
  282.             elseif(VState!=StateElectricShock)
  283.             {
  284.                 CallSub(Sub_CheckFallDamage,Prost1TouchDown,FallStartAltitude,Prost1MaxFall,DamageProst1Fall,Prost1FallDead,0,Prost1FallInplace);
  285.             }
  286.         }
  287.         callsub(Sub_CheckHit,Prost1WoundLight,Prost1WoundLight,Prost1WoundLightNoBreak,FireCount,Prost1PoleDead,Prost1WoundLight,0,0,0,0);
  288.  
  289.         if(vstate==StateOnFire)    //These first if-statements are just for effects
  290.         {
  291.             if(vrnd<20)
  292.             {
  293.                 CheckActorCollision(0,emptyVector,96,0,_COLfire,DamageFlameThrower);
  294.             }
  295.  
  296.             if(FireCount==0)
  297.             {
  298.                 sample(SFXActorOnFire1,-1);
  299.                 samplestop(SFXcough7);
  300.  
  301.                 float(_rnd2,ActorFireType,70);
  302.                 float(_set,ActorDeathType_f,1);
  303.             }
  304.             callsub(Sub_ActorFireEffect,SmokeCount,FireCount,255)
  305.         }
  306.         elseif(vstate==StateBlind)
  307.         {
  308.             if(SmokeCount==0)
  309.             {
  310.                 float(_set,FireCount,0);
  311.                 samplestop(SFXActorOnFire1);
  312.                 sample(SFXcough7,-1);
  313.             }
  314.             callsub(Sub_ActorSmokeEffect,SmokeCount,255)
  315.  
  316.             if(vstate!=StateDead && ActorDeathType_f==1)
  317.             {
  318.                 //actor will die as he's been roasted
  319.                 call(SubtractHealth,0,DamageAfterFire);
  320.             }
  321.         }
  322.  
  323.  
  324.         if(VAction!=Prost1BurningRunInCircle&&VAction!=Prost1BurningRollOnFloor&&VAction!=Prost1SlowGetUpFace)    //It would look bad if he died while in one of these animations
  325.         {
  326. //The last number here is used if they have to fall on their knees when energy is low
  327.             callsub(Sub_CheckDeadOrDying,Prost1PoleDead,Prost1CrawlDead,Prost1StandDead,Prost1CrawlSpread,500,Prost1FallToCrawl,Prost1StandDead,Prost1StandDead);    //0=health when entering crawling-mode
  328.         }
  329.  
  330.         if(vstate==StateExecuteAnim)
  331.         {
  332. /*ttt            if(vaction==Prost1ThrowGrenade)
  333.             {
  334.                 if(vendofanim!=0)
  335.                 {
  336.                     callsub(Sub_SpawnGrenade);
  337.                 }
  338.                 callsub(Sub_TurnCharacter,TurnSpeed,Prost1MaxTurnSpeed,Prost1TurnAcc);
  339.             }
  340. */
  341.             elseif(vaction==Prost1Possesed)
  342.             {
  343.                 callsub(Sub_TurnCharacter,TurnSpeed,Prost1MaxTurnSpeed,Prost1TurnAcc);
  344.             }
  345.             elseif(vaction==Prost1Pickup)
  346.             {
  347.               //callSub(Sub_CheckActionButton,CopPickup,14)
  348.             }
  349. //CopClimbUp, CopDepossesed, CopPickup/Throw weapon,
  350.             callsub(Sub_CheckExecuteAnimEnd)
  351.         }
  352.         elseif(vstate==StateDead||vstate==StateCrawling||vstate==StateBlind||vstate==StateOnFire||vstate==StateSteamed||vstate==StateHarpooned||vstate==StateElectricShock)
  353.         {
  354.             direction(_clr,_DIRcombatmode);
  355.  
  356.             if(VState!=StateDead)
  357.             {
  358.                 if(vstate==StateHarpooned)    //Here are the if-statements that control the actions when you are badly wounded
  359.                 {
  360.                     callsub(Sub_Harpooned,Prost1OnPole,Prost1OnPole,Prost1OnPole,Prost1OnPole,Prost1OnPole,Prost1OnPole,0,0);
  361.                 }
  362.                 else
  363.                 {
  364.                     callsub(Sub_TurnCharacter,TurnSpeed,Prost1MaxTurnSpeedWounded,Prost1TurnAccWounded);
  365.                     if(vstate==StateCrawling)
  366.                     {
  367. //    is this where he has to roll over and hug his knees, and scream if you force him to move?
  368. //
  369.                         callsub(Sub_Crawling,Prost1CrawlSpread,Prost1FallToCrawl)
  370.                     }
  371.                     elseif(vstate==StateOnFire||vstate==StateSteamed||vstate==StateBlind)
  372.                     {
  373.                         callsub(Sub_BurnedSteamedBlind,Prost1BurningRollOnFloor,Prost1BurnedIdle,Prost1GettingBurned,Prost1BlindForward,Prost1BlindBackwards,Prost1BurningRunInCircle,Prost1SlowGetUpFace,SteamCounter,GENIdle)
  374.                     }
  375.                     elseif(vstate==StateElectricShock)
  376.                     {
  377.                         callsub(Sub_ElectricShock,prost1electricshock0,prost1electricshock1);
  378.  
  379.                         if(vaction==prost1electricshock0)
  380.                         {
  381.                             if(vframe==1)
  382.                             {
  383.                                 sample(SFXElectricShock1,-1);
  384.                                 call(SubtractHealth,0,DamageElectric);
  385.                             }
  386.                         }
  387.                         elseif(vaction==prost1electricshock1)
  388.                         {
  389.                             if(vendofanim!=0)
  390.                             {
  391.                                 sample(SFXElectricShock2,-1);
  392.  
  393.                                 call(PlaneTriggerQuadrant,TmpFloat,1);
  394.                                 if(TmpFloat==0)
  395.                                 {
  396.                                     spawnaction(Prost1ThrownForward);
  397.                                     move(0,0,-150);
  398.                                 }
  399.                                 elseif(TmpFloat==1)
  400.                                 {
  401.                                     spawnaction(Prost1ThrownLeft);
  402.                                     move(150,0,0);
  403.                                 }
  404.                                 elseif(TmpFloat==2)
  405.                                 {
  406.                                     spawnaction(Prost1ThrownBack);
  407.                                     move(0,0,150);
  408.                                 }
  409.                                 elseif(TmpFloat==3)
  410.                                 {
  411.                                     spawnaction(Prost1ThrownRight);
  412.                                     move(-150,0,0);
  413.                                 }
  414.                                 state(_change,StateElectricShock,StateThrown);
  415.                             }
  416.                         }
  417.                     }
  418.                 }
  419.             }
  420.         }
  421.         else
  422.         {
  423.             CallSub(Sub_CheckClimbUp,Prost1ClimbUp,60,ColAngleCorrectNeeded,20,-10)
  424.  
  425.             if(vstate==StateNormal)
  426.             {
  427.                 callsub(sub_AlignToWallAndCheckRunUpStairs,Prost1RunUpStairs,Prost1Idle,Prost1IdleHitWall,ColAngleCorrectNeeded,Prost1IdleHitWallFront,Prost1HitWallSpread,-0.95,Prost1Spread,Prost1SpreadGun,ForceRunFrames)
  428.                 callsub(Sub_CheckForIdleLongTime,Prost1Idle,Prost1IdleLongTime);
  429.  
  430.                 if(VTrigger==_DIRGrenade&&VInventoryLeft>0)
  431.                 {
  432.                     state(_or,StateExecuteAnim)
  433.                     if(VState==StateCrouching)
  434.                     {
  435.                         spawnaction(Prost1CrouchGrenade);
  436.                     }
  437.                     else
  438.                     {
  439.                         spawnaction(Prost1ThrowGrenade);
  440.                     }
  441.                 }
  442.  
  443.                 CallSub(Sub_CheckCrouching,Prost1CrouchDown,Prost1CrouchUp);
  444.  
  445.                 CallSub(Sub_CheckJumpFallDown,AIAbility,Prost1RunUpStairs,JumpPressCounter,DownwardPull,Prost1JumpSpeed,Prost1Jump,AirSpeedForward,AirSpeedSideways,Prost1Fall,Prost1AirSpeed)
  446.                 //callSub(Sub_CheckActionButton,CopPickup,14)
  447.                 callsub(Sub_TurnCharacter,TurnSpeed,Prost1MaxTurnSpeed,Prost1TurnAcc);
  448.             }
  449.             elseif(vstate==StateFalling||vstate==StateJump)
  450.             {
  451.                 if(vstate==StateJump)
  452.                 {
  453.                     CallSub(Sub_Jump,JumpPressCounter,DownwardPull,Prost1MinHoldJumpAction,Prost1JumpGravity,2,0)
  454.                 }
  455.                 callsub(Sub_TurnCharacter,TurnSpeed,Prost1MaxTurnSpeedAir,Prost1TurnAccAir);
  456.                 callsub(Sub_MoveInAir,AirSpeedSideways,AirSpeedForward,Prost1AirSpeed,Prost1AirBulb);
  457.             }
  458.         }
  459.  
  460.         callsub(FireWeaponsAndCheckAttached,ShootDelayCounter,1,CopReload,CopReloadCrouch,Prost1HeavyRecoil,Prost1LightRecoil,Prost1CrouchHeavyRecoil,Prost1CrouchLightRecoil);
  461.  
  462.         if(VAction==Prost1HeavyRecoil && VFrame==1)
  463.         {
  464.             call(CheckAttached,_CADropWeapon);
  465.             Direction(_clr,_DIRhavegun);
  466.         }
  467.  
  468.         if(vaicon!=0 && aitoggle==0)
  469.         {
  470.             call(AIupdateAIvars);
  471.             if(VAIleader!=0)            //in charge
  472.             {
  473.                 print("Im the leader....");
  474.                 call(AIcheckfortarget);
  475.  
  476.                 if(VAIgroupstate!=_AIstateidle && VAIgroupstate!=_AIstatesearch)            //search should be widened to account for all attackstates
  477.                 {
  478.                     printi("In attack....",VAInotargettime);
  479.                     if(VAInotargettime<AINOTARGETTHRESHOLD)
  480.                     {
  481.                         print("Persuing enemy...");
  482.                         call(AIasktojoin,_AIstateAttack);            //to make sure newcomers are asked to join for battle
  483.                         if(VAItargetfound!=_AIenemy && VAInotargettime<AINOTARGETSEARCHTHRESHOLD)
  484.                         {
  485.                             call(AIorder,_AIstateSearch);
  486.                             //sample(SFXOrderSearch,-1);
  487.                         }
  488.     /*                    elseif(VAIgrouphealth<50)
  489.                         {
  490.                             call(AIorder,_AIstateretreat);
  491.                         }
  492.                         elseif(VAIpowerrating>80)        //0=no chance 50=neutral 100=superior
  493.                         {
  494.                             call(AIorder,_AIstatesurround);
  495.                         }
  496.                         elseif(VAIpowerrating<30)        //0=no chance 50=neutral 100=superior
  497.                         {
  498.                             call(AIorder,_AIstatespreadout);
  499.                         }
  500.                         elseif(VAIpowerrating<15)
  501.                         {
  502.                             call(AIorder,_AIstatehide);
  503.                         }
  504.                         elseif(VAIgroupleft<70 || VAItimeincurrentorder>AIINORDERREGROUPTHRESHOLD)            //percentage left of original group
  505.                         {
  506.                             call(AIorder,_AIstateregroup);
  507.                         }
  508.                         else
  509.                         {
  510.                             call(AIorder,_AIstateattack);
  511.                         }
  512.     */
  513.                         if(Vaistate==_AIstateattack)
  514.                         {
  515.                             print("Im leading an attack");
  516.                         }
  517.                         call(AIgrouppickdest);
  518.                     }
  519.                 }
  520.                 else
  521.                 {
  522.                     print("No enemy in sight....");
  523.                     if(VAItargetfound==_AIenemy)        //just saw enemy
  524.                     {
  525.             //            print("I saw you. Changing to attack mode");
  526.                         call(AIselecttarget,_AIenemy);
  527.                         call(AIorder,_AIstateAttack);
  528.                         sample(SFXOrderGetHim,-1);
  529.                     }
  530.                     elseif(VAIlasttargetfound|=_AIenemy)            //continue searching
  531.                     {
  532.             //            print("But there used to be....");
  533.                         if(VAInotargettime>AISTOPIFNOTARGETTHRESHOLD)        //check for release group
  534.                         {
  535.                             call(AIorder,_AIstateAtEase);
  536.                             call(AIreleasegroup);
  537.                             sample(SFXSSGirlAhBaNine,-1);
  538.                         }
  539.                         else
  540.                         {
  541.             //                print("So search for him....");
  542.                             if(vaistate!=_AIstatesearch)
  543.                             {
  544.                                 call(AIorder,_AIstateSearch);
  545.                                 //sample(SFXOrderSearch,-1);
  546.                             }
  547.                         }
  548.                     }
  549.                     else                                    //nothing in sight. no present search
  550.                     {
  551.                         //idle formations here
  552.             //            print("Leader in idle formation");
  553.                         call(AIasktojoin,_AIstateIdle);            //join the idle formation
  554.                         if(VAInringroup<5)
  555.                         {
  556.                             //special formation here
  557.                         }
  558.  
  559.                     }
  560.                 }
  561.             }
  562.             elseif(VAIingroup!=0)        //included in group
  563.             {
  564.                 print("Im assigned to a group....");
  565.  
  566.                 if(VAIstatechanged!=0)
  567.                 {
  568.                     sample(SFXOrderYesSir1,-1);
  569.                 }
  570.  
  571.                 if(VAIaskedtojoin!=0)
  572.                 {
  573.                     printi("And im asked to leave",VAIchangetonewgroup);
  574.                     if(VAIchangetonewgroup!=0)
  575.                     {
  576.                         break();
  577.                         call(AIbreakfromgroup);
  578.                         call(AIjoinnewgroup);
  579.                     }
  580.                 }
  581.                 call(AIPickdest);
  582.  
  583.  
  584.             //    if(Vaistate==_AIattack)
  585.             //    {
  586.             //        print("And in the middle of an attack........");
  587.             //    }
  588.  
  589.     /*            if(VAIrebel!=0)            //want out? (friendly fire, health, members dies, ammunition etc)
  590.                 {
  591.                     break();
  592.                     call(AIbreakfromgroup);
  593.                     if(VAItargetfound==_AIenemy)            //in the middle of battle?
  594.                     {
  595.                         if(VAIhealth<10)
  596.                         {
  597.                             call(AIorder,_AIflee);
  598.                             call(AIasktojoin,_AIRetreat);
  599.                         }
  600.                         elseif(VAIhealth>90)
  601.                         {
  602.                             call(AIorder,_AIAttack);
  603.                             call(AIasktojoin,_AIAttack);
  604.                         }
  605.                         else
  606.                         {
  607.                             call(AIorder,_AIHide);
  608.                             call(AIasktojoin,_AIRetreat);
  609.                         }
  610.                     }
  611.                     else
  612.                     {
  613.                         call(AIorder,_AIIdle);
  614.                     }
  615.                 }
  616.                 elseif(VAIaskedtojoin!=0)
  617.                 {
  618.                     if(VAIchangetonewgroup!=0)
  619.                     {
  620.                         break();
  621.                         call(AIbreakfromgroup);
  622.                         call(AIjoinnewgroup);
  623.                     }
  624.                 }
  625.                 else
  626.                 {
  627.                     call(AIpickdest,100,1);        //execute order
  628.                     if(VAIstate==_AISearch)
  629.                     {
  630.                         call(AIcheckfortarget);
  631.                         if(VAItargetfound==_AIenemy)
  632.                         {
  633.                             call(AIorder,_AIattention);
  634.                         }
  635.                     }
  636.                 }
  637.     */
  638.             }
  639.             else
  640.             {
  641.                 call(AIcheckfortarget);
  642.  
  643.                 print("Im by my self");
  644.  
  645.                 if(VAIaskedtojoin!=0)
  646.                 {
  647.                     print("I was asked to join");
  648.                     if(VAIchangetonewgroup!=0)
  649.                     {
  650.                         print("I joined");
  651.                         call(AIjoinnewgroup);
  652.                         sample(SFXOrderYesSir1,-1);
  653.                     }
  654.                     else
  655.                     {
  656.                         printi("LeaderAspiration: ",VAIleaderaspirations);
  657.                         if(VAIleaderaspirations!=0)
  658.                         {
  659.                             printi("Ask to join new group");
  660.                             call(AIasktojoin,_AIstateAttack);
  661.                             call(AIorder,_AIstateattack);
  662.                             sample(SFXOrderGetHim,-1);
  663.                         }
  664.                     }
  665.                 }
  666.                 else
  667.                 {
  668.                     print("And nobody asked me to join");
  669.                 }
  670.  
  671.                 if(vaistate==_aistateattack)
  672.                 {
  673.  
  674.                     if(VAItargetfound!=0 && VAItargetfound==_AIenemy)
  675.                     {
  676.                         print("InAttack by myself...");
  677.                         call(AIselecttarget,_AIenemy);
  678.                         call(AIPickdest);                //in no group. goes after the guy by himself
  679.                     }
  680.                     else
  681.                     {
  682.                         call(AIorder,_AIstateSearch);
  683.                         //sample(SFXOrderSearch,-1);
  684.                     }
  685.                 }
  686.                 elseif(vaistate==_AIstateSearch)
  687.                 {
  688.                     print("Im searching by myself..");
  689.                     turn(0,10,0);
  690.                     if(VAItimeincurrentorder>AINOTARGETTHRESHOLD)
  691.                     {
  692.                         call(AIorder,_AIstateidle);
  693.                     }
  694.                 }
  695.                 elseif(VAItargetfound!=0)
  696.                 {
  697.                     print("Target found");
  698.                     if(VAItargetfound==_AIenemy)
  699.                     {
  700.                         print("Enemy found...............");
  701.  
  702.                         call(AIorder,_AIstateattack);
  703.                         print("Going into attackmode...");
  704.  
  705.     /*                    if(vaistate!=_aiattention)
  706.                         {
  707.                             call(AIorder,_AIattention);
  708.                             sample(SFXOrderOverThere1,-1);
  709.                         }
  710.     */
  711.                         if(VAIleaderaspirations!=0)
  712.                         {
  713.                             call(AIasktojoin,_AIstateAttack);
  714.                             call(AIorder,_AIstateattack);
  715.                             sample(SFXOrderGetHim,-1);
  716.                         }
  717.  
  718.                     }
  719.                     elseif(VAITargetFound==_AIundetermined)
  720.                     {
  721.                         call(AIorder,_AIstateSearch);
  722.                         //sample(SFXOrderSearch,-1);
  723.                     }
  724.                     else        //friend seen
  725.                     {
  726.                         call(AIasktojoin,_AIstateIdle);
  727.                         print("Friend found.Join me.........");
  728.                     }
  729.                 }
  730.                 else
  731.                 {
  732.                     call(AIorder,_AIstateIdle);
  733.                     //patrol
  734.                     //relax
  735.                     //sleep
  736.                 }
  737.             }
  738.  
  739.             print("..........................");
  740.         }
  741.  
  742.  
  743.  
  744.         if(VAICon==0 && vtrigger==_DIRleft||vtrigger==_DIRright||vtrigger==_DIRforward||vtrigger==_DIRbackward||vtrigger==_DIRsideleft||vtrigger==_DIRsideright)
  745.         {
  746.             if(VSpecialFlag==_sFLAGTrodInGoo)
  747.             {
  748.                 if(vrnd<50)
  749.                 {
  750.                     spawnparticle(fx_footbloodspray,18,emptyvector,emptyvector,-1);
  751.                 }
  752.                 else
  753.                 {
  754.                     spawnparticle(fx_footbloodspray,22,emptyvector,emptyvector,-1);
  755.                 }
  756.                 sample(SFXBlood2,-1);
  757.             }
  758.             else
  759.             {
  760.                 callsub(Sub_CheckFootSteps,_sFLAGLeftFoot);
  761.                 callsub(Sub_CheckFootSteps,_sFLAGRightFoot);
  762.             }
  763.         }
  764.  
  765.  
  766.         //weapons
  767.         if(VAICon==0 && VSpecialFlag==_sFLAGPickedUpGun)
  768.         {
  769.             sample(SFXWeaponPickUp,-1);
  770.         }
  771.  
  772.         if(VAICon==0 && VSpecialFlag==_sFLAGPickedUpAmmo)
  773.         {
  774.             if(vrnd<33)
  775.             {
  776.                 sample(SFXWeaponAmmo1,-1);
  777.             }
  778.             elseif(vrnd<66)
  779.             {
  780.                 sample(SFXWeaponAmmo2,-1);
  781.             }
  782.             else
  783.             {
  784.                 sample(SFXWeaponAmmo3,-1);
  785.             }
  786.         }
  787.  
  788.