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

  1.  
  2.  
  3.                 print("Movement done by hide code:   ",AIHideControl);
  4.                 //printi("CornerAngle:   ",VAICornerAngle);
  5.  
  6.                 if(vtrigger!=_DIRcombatmode)                        //put character in combatmode
  7.                 {
  8.                     direction(_set,_DIRcombatmode);
  9.                 }
  10.  
  11.  
  12.                 //*********        HIDE ATTACK      ****************************************
  13.                 if(AIHideControl>=_AIHCAttack)
  14.                 {
  15.                     print("In Hideattack",Counter);
  16.  
  17.                     //Initialize HideAttack
  18.                     if(AIHideControl==_AIHCAttack)
  19.                     {
  20.                         print("HideAttack ordered. Initialize values");
  21.                         float(_set,Counter,0);
  22. /*                        if(vstate==StateCrouching && vrnd<10)
  23.                         {
  24.                             //decide if he should stand up or turn corner
  25.                             if(VAIhideheight<160)                //go into crouch if appropriate
  26.                             {
  27.                                 float(_set,AIHideControl,_AIHCAttackOEdge);
  28.                                 //spawnaction(standup...);
  29.                             }
  30.                         }
  31. */
  32.                         if(AIHideControl!=_AIHCAttack)
  33.                         {
  34.                         }
  35.                         elseif(VAICornerAngle<0)                        //Left Corner
  36.                         {
  37.                             float(_set,AIHideControl,_AIHCAttackLCorner);
  38.                             if(vstate==StateCrouching)
  39.                             {
  40.                                 if(VAIcornerdistance<170)
  41.                                 {
  42.                                     spawnaction(CopHideCrouchLeanLeftS);
  43.                                 }
  44.                                 else
  45.                                 {
  46.                                     spawnaction(CopHideCrouchRoll);
  47.                                     sample(SFXGrunt,-1);
  48.                                 }
  49.                             }
  50.                             else
  51.                             {
  52.                                 if(VAIcornerdistance<170)
  53.                                 {
  54.                                     spawnaction(CopHideLeanLeftS);
  55.                                 }
  56.                                 else
  57.                                 {
  58.                                     spawnaction(CopHideRoll);
  59.                                     sample(SFXGrunt,-1);
  60.                                 }
  61.                             }
  62.                         }
  63.                         else                                            //Right Corner
  64.                         {
  65.                             float(_set,AIHideControl,_AIHCAttackRCorner);
  66.                             if(vstate==StateCrouching)
  67.                             {
  68.                                 if(VAIcornerdistance<170)
  69.                                 {
  70.                                     spawnaction(CopHideCrouchLeanRightS);
  71.                                 }
  72.                                 else
  73.                                 {
  74.                                     spawnaction(CopHideCrouchRoll);
  75.                                     sample(SFXGrunt,-1);
  76.                                 }
  77.                             }
  78.                             else
  79.                             {
  80.                                 if(VAIcornerdistance<170)
  81.                                 {
  82.                                     spawnaction(CopHideLeanRightS);
  83.                                 }
  84.                                 else
  85.                                 {
  86.                                     spawnaction(CopHideRoll);
  87.                                     sample(SFXGrunt,-1);
  88.                                 }
  89.                             }
  90.                         }
  91.                     }
  92.                     //End of Initialize HideAttack
  93.  
  94.                     /*
  95.                     if(AIHideControl==_AIHCAttackLCorner)
  96.                     {
  97.                         print("Left corner");
  98.                     }
  99.                     elseif(AIHideControl==_AIHCAttackRCorner)
  100.                     {
  101.                         print("Right corner");
  102.                     }
  103.                     */
  104.  
  105.                     if(AIHideControl==_AIHCAttackOEdge)
  106.                     {
  107.                         print("In Attack over edge");
  108.                         if(Counter<100)
  109.                         {
  110.                             if(vstate==StateCrouching)
  111.                             {
  112.                                 direction(_set,_DIRcrouch);
  113.                             }
  114.                         }
  115.                         else
  116.                         {
  117.                             if(vstate!=StateCrouching)
  118.                             {
  119.                                 direction(_set,_DIRcrouch);
  120.                             }
  121.                         }
  122.                     }
  123.  
  124.                     float(_add,Counter,1);        //dummy timer
  125.                     //print("Counter:   ",counter);
  126.  
  127.                     //check to end hideattack
  128.                     if(voaction==CopHideLeanLeftE || voaction==CopHideCrouchLeanLeftE || voaction==CopHideLeanRightE || voaction==CopHideCrouchLeanRightE && vendofanim!=0)
  129.                     {
  130.                         float(_set,AIHideControl,_AIHCFollowPath);
  131.                     }
  132.  
  133.                     if(Counter>100)                //compare with resistance, logon etc instead
  134.                     {
  135.                         if(vaction==CopHideLeanLeftE || vaction==CopHideCrouchLeanLeftE || vaction==CopHideLeanRightE || vaction==CopHideCrouchLeanRightE)
  136.                         {
  137.                             if(VPathDestAngle<-20)
  138.                             {
  139.                                 turn(0,-19,0);
  140.                                 //Direction(_DIRleft);
  141.                             }
  142.                             elseif(VPathDestAngle>20)
  143.                             {
  144.                                 turn(0,19,0);
  145.                                 //Direction(_DIRright);
  146.                             }
  147.                         }
  148.  
  149.                         if(VEndOfAnim!=0)
  150.                         {
  151.                             if(VAIcornerdistance>100 && vstate==StateCrouching)
  152.                             {
  153.                                 float(_set,AIHideControl,_AIHCFollowPath);
  154.                                 spawnaction(CopCrouchIdle);
  155.                             }
  156.                             elseif(VAIcornerdistance>100 && vstate!=StateCrouching)
  157.                             {
  158.                                 float(_set,AIHideControl,_AIHCFollowPath);
  159.                                 spawnaction(CopIdle);
  160.                             }
  161.                             else
  162.                             {
  163.                                 if(AIHideControl==_AIHCAttackLCorner)
  164.                                 {
  165.                                     if(vstate!=StateCrouching)
  166.                                     {
  167.                                         spawnaction(CopHideLeanLeftE);
  168.                                     }
  169.                                     else
  170.                                     {
  171.                                         spawnaction(CopHideCrouchLeanLeftE);
  172.                                     }
  173.                                 }
  174.                                 else
  175.                                 {
  176.                                     if(vstate!=StateCrouching)
  177.                                     {
  178.                                         spawnaction(CopHideLeanRightE);
  179.                                     }
  180.                                     else
  181.                                     {
  182.                                         spawnaction(CopHideCrouchLeanRightE);
  183.                                     }
  184.                                 }
  185.                             }
  186.                         }
  187.                     }
  188.                     //normal hide attack. Align, log, fire etc
  189.                     else
  190.                     {
  191.                         if(VTargetAngle<-40)
  192.                         {
  193.                             if(Counter>12)
  194.                             {
  195.                                 if(VTargetAngle<-140)
  196.                                 {
  197.                                     turn(0,-79,0);
  198.                                 }
  199.                                 else
  200.                                 {
  201.                                     turn(0,-39,0);
  202.                                 }
  203.                                 //turn(0,-39,0);
  204.                                 //Direction(_DIRleft);
  205.                             }
  206.                         }
  207.                         elseif(VTargetAngle>40)
  208.                         {
  209.                             if(Counter>12)
  210.                             {
  211.                                 if(VTargetAngle>140)
  212.                                 {
  213.                                     turn(0,79,0);
  214.                                 }
  215.                                 else
  216.                                 {
  217.                                     turn(0,39,0);
  218.                                 }
  219.                                 //Direction(_DIRright);
  220.                             }
  221.                         }
  222.                         //align to targetangle
  223.                         else
  224.                         {
  225.                             if(Counter>45)
  226.                             {
  227.                                 //decide if we want to move forward
  228.                                 if(vstate!=StateCrouching)
  229.                                 {
  230.                                     spawnaction(CopIdle);
  231.                                 }
  232.                                 else
  233.                                 {
  234.                                     spawnaction(CopCrouchIdle);
  235.                                 }
  236.  
  237.                                 if(VAInotargettime>AINOTARGETTHRESHOLD)
  238.                                 {
  239.                                     //print("Didn't see enemy. All well. Lets get out of state");
  240.                                     //leave hide since no enemy seen
  241.                                     call(AIclrhidenode);
  242.                                     call(AIorder,_set,_AIstateIdle);
  243.                                     call(ClrPath);
  244.                                     //call(PickNewNode);
  245.                                     CallSub(Sub_AIGetBackToIdle);
  246.                                     if(vstate==StateCrouching)                        //To get rid of crouching when he is running to new Hide
  247.                                     {
  248.                                         direction(_set,_DIRcrouch);
  249.                                     }
  250.                                 }
  251.                                 else
  252.                                 {
  253.                                     // pick new way point............
  254.                                     if(AICOntrol&=_AICRetreat)
  255.                                     {
  256.                                         if(VAITargetfound!=_AIenemy && AIUsage&=_AIUHideRetreatDefensive)
  257.                                         {
  258.                                             //pick new hidenode further away
  259.                                             call(AIpicknewhidenode,1,0,_AICRetreat);
  260.                                         }
  261.                                     }
  262.                                     else
  263.                                     {
  264.                                         if(VAITargetfound!=_AIenemy || AIUsage&=_AIUHideAttackOffensive)
  265.                                         {
  266.                                             //pick new hidenode closer to enemy
  267.                                             call(AIpicknewhidenode,1,0,_AICAttack);
  268.                                         }
  269.                                     }
  270.  
  271.                                     if(vtrigger==_DIRTempFlag)
  272.                                     {
  273.                                         float(_set,AIHideControl,_AIHCReset);
  274.                                     }
  275.                                     else
  276.                                     {
  277.                                         float(_set,AIHideControl,_AIHCFollowPath);
  278.                                     }
  279.                                 }
  280.                             }
  281.  
  282.                             CallSub(Sub_AIShootCheck,Counter,AIGrenadeCounter);
  283.                             if(vtrigger==_DIRshoot)
  284.                             {
  285.                         //        float(_add,Counter,50);
  286.                             }
  287.                         }
  288.                     }
  289.                 }
  290.                 //*********        HIDE IN-ROUTE      ****************************************
  291.                 elseif(AIHideControl==_AIHCInRoute)                    //has not reached dest yet
  292.                 {
  293.                     print("In route to Hide Position    ");
  294.                     if(vstate==StateCrouching)                        //To get rid of crouching when he is running to new Hide
  295.                     {
  296.                         direction(_set,_DIRcrouch);
  297.                     }
  298.  
  299.                     if(VPathDestDistance>10)
  300.                     {
  301.                         CallSub(Sub_AIShootCheck,Counter,AIGrenadeCounter);
  302.  
  303.                         //CallSub(Sub_AI1WayAlignToTarget);
  304.                         CallSub(Sub_AI1WayAlignToPickDestAngle);
  305.                         if(VPathDestDistance<50)
  306.                         {
  307.                             CallSub(Sub_AI8WayMoveWalk,CurrentDirection);
  308.                         }
  309.                         else
  310.                         {
  311.                             CallSub(Sub_AI8WayMoveRun,CurrentDirection);
  312.                         }
  313.                     }
  314.                     else
  315.                     {
  316.                         float(_set,AIHideControl,_AIHCFollowPath);
  317.                     }
  318.                 }
  319.                 //*********        HIDE FOLLOW PATH    ****************************************
  320.                 else                                                //reached first hide node. Now use hide maneuvering
  321.                 {
  322.                     printi("In hide specific movement: ",VPathDestAngle);
  323.  
  324.                     if(VAIhideheight<180)                                //go into crouch if appropriate
  325.                     {
  326.                         if(vstate!=StateCrouching)
  327.                         {
  328.                             direction(_set,_DIRcrouch);
  329.                         }
  330.                         float(_set,TmpFloat,20)
  331.                     }
  332.                     else
  333.                     {
  334.                         float(_set,TmpFloat,30)
  335.                     }
  336.  
  337.                     if(VPathDestDistance<TmpFloat)                            //Reached destination?
  338.                     {
  339.                         printi("reached hide destination:  ",VPathDestAngle);
  340.                         if(VAItargetfound==_AIenemy)        //make sure we still check for enemy in sight
  341.                         {
  342.                             CallSub(Sub_AIShootCheck,Counter,AIGrenadeCounter);
  343.                             CallSub(Sub_AI1WayAlignToTarget);
  344.                             //CallSub(Sub_AI8WayMoveRun,CurrentDirection);
  345.                         }
  346.                         elseif(VPathDestAngle<-20)
  347.                         {
  348.                             //turn(0,-19,0);
  349.                             Direction(_set,_DIRleft);
  350.                         }
  351.                         elseif(VPathDestAngle>20)
  352.                         {
  353.                             //turn(0,19,0);
  354.                             Direction(_set,_DIRright);
  355.                         }
  356.                         elseif(VTrigger==_DIRhavegun)
  357.                         {
  358.                             //Make decision if actor should lean out and take a shot
  359.                             if(AIControl&==_AICRetreat && AIUsage&=_AIUHideLeanOutRetreat)
  360.                             {
  361.                                 float(_set,AIHideControl,_AIHCAttack);
  362.                             }
  363.                             elseif(AIControl&==_AICAttack && AIUsage&=_AIUHideLeanOutAttack)
  364.                             {
  365.                                 float(_set,AIHideControl,_AIHCAttack);
  366.                             }
  367.                         }
  368.                     }
  369.                     else                                                            //Move to HideDest
  370.                     {
  371.                         float(_set,AIHideControl,_AIHCFollowPath);
  372.                         printi("Correcting Hide Position   ",VAItargetfound);
  373.                         if(VAItargetfound==_AIenemy)
  374.                         {
  375.                             CallSub(Sub_AIShootCheck,Counter,AIGrenadeCounter);
  376.                             CallSub(Sub_AI1WayAlignToTarget);
  377.                             CallSub(Sub_AI8WayMoveRun,CurrentDirection);
  378.                         }
  379.                         else
  380.                         {
  381.                             CallSub(Sub_AI2WayAlignToPickDestAngle);
  382.  
  383.                             if(vpickdestanglecorr>=-1024 && vpickdestanglecorr<=1024)        //forward
  384.                             {
  385.                                 //printi("forward code   ",VPathDestDistance);
  386.                                 if(VPathDestDistance<150 && vpickdestanglecorr>-120 && vpickdestanglecorr<120)
  387.                                 {
  388.                                     float(_set,CurrentDirection,_DIRforward|_DIRwalking);
  389.                                 }
  390.                                 elseif(VPathDestDistance>150 && vpickdestanglecorr>-60 && vpickdestanglecorr<60)
  391.                                 {
  392.                                     float(_set,CurrentDirection,_DIRforward);
  393.                                 }
  394.                             }
  395.                             else                                                            //backward
  396.                             {
  397.                                 //printi("backward code   ",VPathDestDistance);
  398.                                 if(vpickdestanglecorr<-1980 || vpickdestanglecorr>1980)
  399.                                 {
  400.                                     if(VPathDestDistance<150)
  401.                                     {
  402.                                         float(_set,CurrentDirection,_DIRbackward|_DIRwalking);
  403.                                     }
  404.                                     elseif(VPathDestDistance>150)
  405.                                     {
  406.                                         //float(_clr,CurrentDirection,_DIRwalking);
  407.                                         float(_set,CurrentDirection,_DIRbackward);
  408.                                     }
  409.                                 }
  410.                             }
  411.                         }
  412.                     }
  413. //XYXYXY redo
  414.                     if(VAIpowerrating>60)
  415.                     {
  416.                         //printlog("Leaving hidemode");
  417.                         state(_clr,StateFollowPath);
  418.                         call(AIclrhidenode);
  419.                         call(ClrPath);
  420.                         call(AIorder,_set,_AIStateidle);
  421.                         CallSub(Sub_AISetAttack);
  422.                         if(vstate==StateCrouching)                        //To get rid of crouching when he is running to new Hide
  423.                         {
  424.                             direction(_set,_DIRcrouch);
  425.                         }
  426.                         //play sample (he's weak. go for him");
  427.                     }
  428.                 }
  429.  
  430.