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

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