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

  1.  
  2.         float(_declare,CloseUpCounter,1400);
  3.         float(_add,CloseUpCounter,1);
  4.  
  5.         call(AIupdateAIvars);
  6.  
  7.         if(VAIpowerrating>AIPowerRatingThreshold)
  8.         {
  9.             if(VAImanpowerindex>AIManPowerThreshold || VAIpowerrating==0)
  10.             {
  11.                 //frontal attack (against unarmed enemies or Bob for example)
  12.                 float(_set,AIControl,_AICAttack);
  13.             }
  14.             else
  15.             {
  16.                 //attack using hide if appropriate (normal attack)
  17.                 if(AIUsage&=_AIUhideforattack)
  18.                 {
  19.                     float(_set,AIControl,_AICAttackUsingHide);
  20.                     //initialize hide code
  21.                 }
  22.                 else
  23.                 {
  24.                     //use frontal attack
  25.                     float(_set,AIControl,_AICAttack);
  26.                 }
  27.             }
  28.         }
  29.         else
  30.         {
  31.             if(VTrigger!=_DIRhavegun && VAItargettrigger!=_DIRhavegun)
  32.             {
  33.                 float(_set,AIControl,_AICAttack);        //if both unarmed
  34.             }
  35.             elseif(VAImanpowerindex>AIManPowerThreshold)
  36.             {
  37.                 //attack using hide if appropriate (normal attack)
  38.                 if(AIUsage&=_AIUhideforattack)
  39.                 {
  40.                     float(_set,AIControl,_AICAttackUsingHide);
  41.                 }
  42.                 else
  43.                 {
  44.                     float(_set,AIControl,_AICAttack);
  45.                 }
  46.             }
  47.             else
  48.             {
  49.                 //retreat (act less offensive. Let them seek out you)
  50.                 if(AIUsage&=_AIUhideforretreat)
  51.                 {
  52.                     float(_set,AIControl,_AICRetreatUsingHide);
  53.                 }
  54.                 else
  55.                 {
  56.                     float(_set,AIControl,_AICRetreat);
  57.                 }
  58.             }
  59.         }
  60.         printi("PowerRating:       ",VAIpowerrating);
  61.         printi("VAImanpowerindex:  ",VAImanpowerindex);
  62.         print("AIControl:         ",AIControl);
  63.  
  64. /*
  65.  
  66. /////////////////////////////////////////////////////////////////////////////////////
  67. //Tim's CopStateBits stuff:
  68.  
  69.         //includes possessed character
  70.     call(GetNumbActorsInCurrentSet,_AIClassCop|_AIClassWorker|_AIclassprost|_AIclasspimp|_AIclasspriest|_AIclassdweller|_AIclassscientist|_AIclassbarpeople|_AIclassmale|_AIclassfemale|_AIclassmedic|_AIclasssubgirl,TmpFloat);
  71. //    print("Num Actors = ",TmpFloat);
  72.  
  73. //cop (only the Cops NOT possessed)
  74.     if(VRank>=_RankSergeantL)
  75.     {
  76.         float(_set,PreCopActionBits,CopActionBits); //save previous action bits
  77.         float(_set,PreCopStateBits,CopStateBits); //save previous state bits
  78.         float(_set,CopStateBits,0); //clear state bits
  79.         if(vaistate==_aistateattack)//in attack mode
  80.         //if(CopActionBits==2)//combat flag
  81.         {
  82. //dmessage("in COMBAT mode",10,30);
  83.             float(_set,CopActionBits,0);//clear initial combat bit
  84.             float(_or,CopStateBits,1); //in COMBAT mode bit
  85.         }
  86.         if(VAItargetfound!=0 && VAItargetfound==_AIundetermined && vaistate!=_AIstateTurnToSound)
  87.         {
  88. //dmessage("Can HEAR character behind",20,30);
  89.             callsub(Sub_RandomCopHearsBobSFX);
  90.             float(_or,CopStateBits,2); //Can HEAR character behind bit
  91.             callsub(TurnToFaceSound);
  92.             call(AIorder,_set,_AIstateTurnToSound);
  93.         }
  94.         if(PreCopActionBits!=0 && PreCopActionBits<4)//attack: CopActionBits=1, combat: CopActionBits=2
  95.         {
  96.             if(VAItargetclass==_AIclassAngel)
  97.             {
  98. //dmessage("Cop saw Bob!",30,30);
  99.                 float(_set,CopActionBits,0);//clear initial attack bit
  100.                 float(_or,CopStateBits,4); //Just saw Bob as cherub (before going into attack mode) bit
  101.                 //spawnaction(CopGesture1);
  102.                 call(AIorder,_clr,_AIstateTurnToSound);
  103.             //    call(AIorder,_set,_AIstateTurnToSoundSlow);
  104.                 call(AIorder,_set,_AIstateGestureAtBob);
  105.             }
  106.         }
  107.         if(TmpFloat>1)//more than 1 character in room?
  108.         {
  109. //dmessage("more than 1 character in room",40,30);
  110.             float(_or,CopStateBits,8); //more than one character in room
  111.         }
  112.         if(vtrigger==_DIRhavegun)//when NOT possessed by Bob
  113.         {
  114. //dmessage("cop carrying a weapon",50,30);
  115.             float(_or,CopStateBits,16); //carrying a weapon bit
  116.         }
  117.         //if(VAItargetfound==_AIenemy && vaistate!=_aistateattack)//just saw enemy (not yet in attack mode)
  118.         //if(CopActionBits!=0 && CopActionBits<4)
  119.         if(PreCopActionBits!=0 && PreCopActionBits<4)
  120.         {
  121. //dmessage("Cop saw enemy possessed character",60,30);
  122.             float(_set,CopActionBits,0);
  123.             float(_or,CopStateBits,32); //just saw enemy (not yet in attack mode)
  124.         }
  125.         if(VHealth<=2500)
  126.         {
  127. //dmessage("energy low!",70,30);
  128.             float(_or,CopStateBits,64); //energy low bit
  129.         }
  130.     }
  131. //end
  132. /////////////////////////////////////////////////////////////////////////////////////
  133. //printi("VHealth: ",VHealth);//starts at 5000, then 4000, 3000 each time I kick another
  134.  
  135. */
  136.         if(VState!=StateExecutePathSequence)
  137.         {
  138.             if(aivisiontoggle==0)
  139.             {
  140.                 call(AIcheckfortarget,10);
  141.             }
  142.  
  143. //            if(VAItargetfound!=0 && VAItargetfound==_AIundetermined && vaistate!=_AIstateTurnToSound)
  144. //            {
  145. //                callsub(Sub_RandomCopHearsBobSFX);
  146. //            }
  147.  
  148.             if(VAItargetfound==_AIgrenade)
  149.             {
  150.                 //select grenade paret as target
  151.                 if(VAIState!=_AIstateAttack && VAIState!=_AIstateHide)
  152.                 {
  153.                     call(AIselecttarget,_AIgrenade);
  154.                     call(AIchangefriendtoenemy);
  155.                     call(AIalert,Sub_AISetAttack);
  156.                     sample(SFXGrenadeReact,-1);
  157.                     if(VAIhidenodenear!=0)
  158.                     {
  159.                         call(AIorder,_set,_AIstatehide);
  160.                         state(_clr,StateFollowPath);
  161.                         call(ClrPath);
  162.                     }
  163.                     else
  164.                     {
  165.                         //pick pos out of way
  166.                     }
  167.                 }
  168.                 else
  169.                 {
  170.  
  171.                 }
  172.             }
  173.  
  174.             call(AIcheckactoractions,10,GENPossesed); //only when possessing cop?
  175.             if(VTrigger==_DIRTempFlag) //did character see cop being possessed
  176.             {
  177.     //dmessage("AIcheckactoractions CopPossesed",50,100);
  178.                 if(VRank>=_RankSergeantL)
  179.                 {
  180.                     sample(SFXPossesionReact,-1);
  181.                     call(AIsetlockedonactortotarget);
  182.                     if(VAIStateHigh!=_AIstayonpath && VAIStateHigh!=_AIstayonpath)
  183.                     {
  184.                         call(AIorder,_set,_AIstatePossesionReact);
  185.                         call(AIorder,_set,_AIinspecialmode);
  186.                         float(_set,AIChoiceVar,0);
  187.                     }
  188.                 }
  189.                 else
  190.                 {
  191.                     sample(SFXPossesionReact,-1);
  192.                     callsub(Sub_CivilianReactionToThreat);
  193.                 }
  194.             }
  195.  
  196.  
  197.             if(VAIState!=_AIstateAttack && VAIState!=_AIstateHide && VAIState!=_AIstateGuard)
  198.             {
  199.                 if(vtrigger==_DIRactorbulletcol)
  200.                 {
  201.                     if(VRank>=_RankSergeantL)
  202.                     {
  203.                         //if shot came from playerone, turn him into enemy
  204.                         call(AIcheckbulletorigin);
  205.                         if(vtrigger==_DIRTempFlag)
  206.                         {
  207.                             //turn player one into enemy
  208.                             call(AIchangefriendtoenemy);
  209.                             call(AIalert,Sub_AISetAttack);
  210.                             CallSub(Sub_AISetAttack);
  211.                         }
  212.                     }
  213.                     else
  214.                     {
  215.                         callsub(Sub_CivilianReactionToThreat);
  216.                     }
  217.                 }
  218.  
  219.                 if(VActorFlag==_AFLAGattached)//for 2-man animation, changes guy who punches him in the face into an enemy
  220.                 {
  221.                     call(AIcheckattachactionorigin);
  222.                     call(AIchangefriendtoenemy);
  223.                 }
  224.             }
  225.         }
  226.  
  227.         printih("State:       ",vstate);
  228.         printi("AIState:     ",vaistate);
  229.         printih("AIStateHigh: ",vaistatehigh);
  230.  
  231.         if(VActorFlag==_AFLAGattached)
  232.         {
  233.             //dummy to prevent ai from running
  234.         }
  235.         elseif(vstate==StateFollowPath)
  236.         {
  237.             print("Im in follow path mode:  ",vstate);
  238.  
  239.             if(VAIstatehigh!=_AIdontdopickdest)
  240.             {
  241.                 call(AIPickdest,10);
  242.             }
  243.             if(VAIstatehigh!=_AIinspecialmode)
  244.             {
  245.                 if(vtrigger==_DIRtempflag && VAIstatehigh!=_AIdontdopickdest)
  246.                 {
  247.                     call(PickNewNode);
  248.                 }
  249.             }
  250.             else
  251.             {
  252.                 //print("AAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
  253.                 print("AAHH! vstate=StateFollowPath & VAIstatehigh=_AIinspecialmode");
  254.             }
  255.  
  256.             if(aivisiontoggle==0)
  257.             {
  258.                 if(VAItargetfound!=0 && VAItargetfound==_AIenemy && VAIStateHigh!=_AIstayonpath)
  259.                 {
  260. //dmessage("VAItargetfound==_AIenemy",50,5);
  261.                     if(VRank>=_RankSergeantL)
  262.                     {
  263.                         call(ClrPath);
  264.                         call(AIselecttarget,_AIenemy);
  265.                         CallSub(Sub_AISetAttack);
  266.                         if(VAITargetClass==_AIclassAngel)
  267.                         {
  268.                             sample(SFXReactToBob,-1);
  269.                         }
  270.                         call(AIalert,Sub_AISetAttack);
  271.                     }
  272.                     else
  273.                     {
  274.                         call(AIselecttarget,_AIenemy);
  275.                         if(VAItargetclass==_AIclassAngel)
  276.                         {
  277.                             //worker, civilian reactions to Bob or enemy
  278.                             call(AIfindpathwithspecificstate,_AIstatePressAlarmButton);
  279.                             if(VTrigger==_DIRTempFlag)
  280.                             {
  281.                                 //call(AIorder,_set,_AIstateRun);
  282.                                 //State(_or,StateFollowPath);
  283.                                 call(AIclrtarget);
  284.                                 call(AIorder,_set,_AIstateRun);
  285.                                 call(AIorder,_clr,_AInomove|_AInoturn);
  286.                                 State(_clr,StateFollowPath);
  287.                                 State(_or,StateExecutePathSequence);
  288.                             }
  289.                             elseif(VTargetDistance<400)
  290.                             {
  291.                                 call(AIorder,_set,_AIstateReactToBob);
  292.                                 call(AIorder,_set,_AIinspecialmode|_AInomove);
  293.                                 if(vstate==StateCrouching)
  294.                                 {
  295.                                     direction(_set,_DIRcrouch);
  296.                                 }
  297.                             }
  298.                             else
  299.                             {
  300.                                 call(AIclrtarget);
  301.                             }
  302.                         }
  303.                         else
  304.                         {
  305.                             callsub(Sub_CivilianReactionToThreat);
  306.                         }
  307.                     }
  308.                 }
  309.                 elseif(VRank>=_RankSergeantL)
  310.                 {
  311. /*                    //check for worker off path
  312.                     if(VAIClass==_AIClassCop && VAIStateHigh!=_AIstayonpath)
  313.                     {
  314.                         call(AIcheckactorstates,10,_AIclassworker,0,_AInotonpath);
  315.                         if(vtrigger==_DIRTempFlag && VAIstatehigh!=_AIlockedtoactor)
  316.                         {
  317.                             call(AIsetlockedonactortotarget);
  318.                             call(AIlockedtoactorflag,_set);
  319.                             call(AIorder,_set,_AIstateGetToWork);
  320.                             call(AIorder,_set,_AIinspecialmode);
  321.                             float(_set,AIChoiceVar,0);
  322.                             sample(SFXCopGetBackToWork1,-1);
  323.                         }
  324.                     }
  325. */
  326.                     //check for Combatmode Set
  327.                     if(VAIStateHigh!=_AIcombatmodereact && VAIState!=_AIstateCombatModeReact)
  328.                     {
  329.                         call(AIcheckactordirections,10,_DIRcombatmode);
  330.                         if(VTrigger==_DIRTempFlag)
  331.                         {
  332.                             call(AIsetlockedonactortotarget);
  333.                             if(VAItargetstrenght!=0)
  334.                             {
  335.                                 if(VAItargettrigger!=_DIRhavegun && VTargetDistance>700)
  336.                                 {
  337.                                 }
  338.                                 else
  339.                                 {
  340.                                     if(VAIState!=_AIstateGuard)
  341.                                     {
  342.                                         call(AIorder,_or,_AIcombatmodereact);
  343.                                         float(_set,CloseUpCounter,0);
  344.                                         spawnaction(GENidle);
  345.                                     }
  346.                                     else
  347.                                     {
  348.                                         call(AIchangetargettoenemy);
  349.                                         if(VAIStateHigh!=_AIstayonpath)
  350.                                         {
  351.                                             call(AIorder,_set,_AIstateCombatModeReact);
  352.                                             call(AIorder,_set,_AIinspecialmode);
  353.                                             float(_set,AIChoiceVar,0);
  354.                                         }
  355.                                     }
  356.                                 }
  357.                             }
  358.                             else
  359.                             {
  360.                                 call(AIclrtarget);
  361.                             }
  362.                         }
  363.                     }
  364.                 }
  365.                 elseif(VAIClass==_AIClassChot)
  366.                 {
  367.                     if(VAIstatehigh!=_AIinspecialmode)
  368.                     {
  369.                         call(GetNumbActorsInCurrentSet,TmpFloat,_AIClassChot,_GreaterEqual,_RankSergeantM);
  370.                         //print("NrChots: ",TmpFloat);
  371.                         if(TmpFloat!=0)
  372.                         {
  373.                             call(AIselecttarget,_AIfriend,_AIClassChot,_GreaterEqual,_RankSergeantM);
  374.                             if(VAIhastarget!=0)
  375.                             {
  376.                                 call(AIOrder,_set,_AIstateFollowTheLeader);
  377.                                 call(AIOrder,_set,_AIinspecialmode);
  378.                                 call(AIorder,_clr,_AInomove|_AInoturn);
  379.                             }
  380.                         }
  381.                     }
  382.                 }
  383.                 else
  384.                 {
  385.                     //reactions from civilians
  386.                 //    if(VTrigger!=_DIRcombatmode)
  387.                 //    {
  388.                         call(AIcheckactordirections,10,_DIRcombatmode|_DIRhavegun);
  389.                         if(VTrigger==_DIRTempFlag)
  390.                         {
  391.                             call(AIsetlockedonactortotarget);
  392.                             if(VTargetDistance<600 && VAItargetseenme!=0)
  393.                             {
  394.                                 call(AIorder,_set,_AIstateSurrender);
  395.                                 call(AIorder,_set,_AIinspecialmode);
  396.                             }
  397.                             else
  398.                             {
  399.                                 call(AIclrtarget);
  400.                             }
  401.                         }
  402.                 //    }
  403.  
  404.                     if(VAIState!=_AIstateSurrender && VTrigger!=_DIRhavegun && AIUsage&=_AIUAttackIfUnseen)
  405.                     {
  406.                         if(VAItargetfound!=0)
  407.                         {
  408.                             printi("attack from behind:   ",VAItargetfound);
  409.                             call(GetNumbActorsInCurrentSet,TmpFloat,_AIClassCop|_AIClassChot);
  410.                             if(TmpFloat==1)        //make sure only 1 is in the scene
  411.                             {
  412.                                 print("1 character in scene");
  413.                                 call(AIselecttarget,0,_AIClassCop|_AIClassChot);
  414.                                 if(VTrigger==_DIRTempFlag)
  415.                                 {
  416.                                     print("I can see you");
  417.                                     if(VAItargettrigger==_DIRhavegun)    // does target carry gun
  418.                                     {
  419.                                         print("you have a gun");
  420.                                         if(VAItargetseenme==0)
  421.                                         {
  422.                                             print("you cant see me");
  423.                                             if(VTargetDistance<500)        //if he is close
  424.                                             {
  425.                                                 print("You are close enough");
  426.                                                 //sneak after him and steal his weapon
  427.                                                 call(AIOrder,_set,_AIstateSneakUp);
  428.                                                 //call(ClrPath);
  429.                                                  call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  430.                                                 //call(AIorder,_set,_AIstateAttack);
  431.                                                 //state(_change,StateFollowPath,StateNormal);
  432.                                             }
  433.                                         }
  434.                                     }
  435.                                 }
  436.                                 else
  437.                                 {
  438.                                     call(AIclrtarget);
  439.                                 }
  440.                             }
  441.  
  442.  
  443.                         }
  444.                     }
  445.  
  446.                 }
  447.  
  448. /*                if(VAItargetfound!=0 && VAItargetfound==_AIundetermined && VAIState!=_AIStateGuard)
  449.                 {
  450. //dmessage("_AIundetermined",90,30);
  451.                     if(VRank>=_RankSergeantL)
  452.                     {
  453.                         //cop reaction to sound etc.
  454. //dmessage("cop reaction to sound",50,10);
  455.                     }
  456.                     else
  457.                     {
  458.                         //civilian reaction to sound etc.
  459. //dmessage("civilian reaction to sound",50,10);
  460.                     }
  461.                 }
  462. */
  463.             }
  464.         }
  465.         elseif(vstate==StateExecutePathSequence)
  466.         {
  467.             if(VAIstatehigh!=_AIdontdopickdest)
  468.             {
  469.                 call(AIPickdest,10);        //follow path
  470.                 if(vtrigger==_DIRtempflag)
  471.                 {
  472.                     state(_clr,StateExecutePathSequence);
  473.                     state(_or,StateFollowPath);
  474.                     call(ClrPath);
  475.                     call(PickNewNode);
  476.                 }
  477.             }
  478.         }
  479.         //*****************
  480.         //Group Leader Code
  481.         //*****************
  482.         elseif(VAIleader!=0)            //in charge
  483.         {
  484.     break();
  485.             print("Im the Leader");
  486.             call(AIPickdest,10);
  487.             if(VAIgroupstate!=_AIstateidle && VAIgroupstate!=_AIstatesearch)//search should be widened to account for all attackstates
  488.             {
  489.                 if(VAInotargettime<AINOTARGETTHRESHOLD)
  490.                 {
  491.                     call(AIasktojoin,_AIstateAttack);    //to make sure newcomers are asked to join for battle
  492.                     if(VAItargetfound!=_AIenemy && VAInotargettime<AINOTARGETSEARCHTHRESHOLD)
  493.                     {
  494.                         call(AIorder,_set,_AIstateSearch);
  495.                     }
  496.                     call(AIgrouppickdest);
  497.                 }
  498.             }
  499.             else
  500.             {
  501.                 if(VAItargetfound==_AIenemy)    //just saw enemy
  502.                 {
  503.                     call(AIselecttarget,_AIenemy);
  504.                     call(AIorder,_set,_AIstateAttack);
  505.                 }
  506.                 elseif(VAIlasttargetfound|=_AIenemy)            //continue searching
  507.                 {
  508.                     if(VAInotargettime>AISTOPIFNOTARGETTHRESHOLD)        //check for release group
  509.                     {
  510.                         call(AIorder,_set,_AIstateAtEase);
  511.                         call(AIreleasegroup);
  512.                     }
  513.                     else
  514.                     {
  515.                         if(vaistate!=_AIstatesearch)
  516.                         {
  517.                             call(AIorder,_set,_AIstateSearch);
  518.                         }
  519.                     }
  520.                 }
  521.                 else                                    //nothing in sight. no present search
  522.                 {
  523.                     call(AIasktojoin,_AIstateIdle);            //join the idle formation
  524.                 }
  525.             }
  526.         }
  527.         //*****************
  528.         //Group member Code
  529.         //*****************
  530.         elseif(VAIingroup!=0)        //included in group
  531.         {
  532.     break();
  533.             print("Im in a Group");
  534.             if(VAIstatechanged!=0)
  535.             {
  536.                 sample(SFXOrderYesSir1,-1);
  537.             }
  538.  
  539.             if(VAIaskedtojoin!=0)
  540.             {
  541.                 if(VAIchangetonewgroup!=0)
  542.                 {
  543.                     call(AIbreakfromgroup);
  544.                     call(AIjoinnewgroup);
  545.                 }
  546.             }
  547.             call(AIPickdest,10);
  548.         }
  549.         //****************
  550.         //In No Group Code
  551.         //****************
  552.         elseif(vactivetime>10)
  553.         {
  554.             print("Decide what to do");
  555.             if(VAIaskedtojoin!=0)
  556.             {
  557.                 if(VAIchangetonewgroup!=0)
  558.                 {
  559.                     call(AIjoinnewgroup);
  560.                     sample(SFXOrderYesSir1,-1);
  561.  
  562.                     state(_or,StateExecuteAnim);
  563.                     spawnaction(CopAttention);
  564.                 }
  565.                 else
  566.                 {
  567.                     if(VAIleaderaspirations!=0)
  568.                     {
  569.                         call(AIasktojoin,_AIstateAttack);
  570.                         call(AIorder,_set,_AIstateattack);
  571.                     }
  572.                 }
  573.             }
  574.             if(vaistate==_AIstateGetWeapon)
  575.             {
  576.                 call(AIPickdest,10);
  577.                 if(VTrigger!=_DIRhavegun)
  578.                 {
  579.                     call(IsPickupClose,_ClassWeapon,1000,TmpFloat,WeaponPickUpPos);
  580.                     if(vtrigger!=_DIRTempFlag)
  581.                     {
  582.                         call(AIorder,_set,_AIstateAttack);
  583.                     }
  584.                     else
  585.                     {
  586.                         vector(_setpathdest,WeaponPickUpPos);        //just in case position changed
  587.                     }
  588.                 }
  589.                 else
  590.                 {
  591.                     call(AIorder,_set,_AIstateAttack);
  592.                 }
  593.                 print("In Get Weapon State");
  594.             }
  595.             elseif(vaistate==_AIstateAttack)
  596.             {
  597.                 printi("Im in attack:   ",VAItargetfound);
  598.                 call(AIPickdest,10);
  599.  
  600.                 if(VAItargetfound!=0 && VAItargetfound==_AIenemy)
  601.                 {
  602.                     //printi(Powerrating:    ",VAIpowerrating);
  603.                     
  604.                     if(VAIhastarget==0)
  605.                     {
  606.                         call(AIselecttarget,_AIenemy);    //in no group. goes after the guy by himself
  607.                     }
  608.                     call(AIupdatetargetpos);
  609.  
  610.                     if(AIControl&=_AICHide)
  611.                     {
  612.                         if(VAIhidenodenear!=0)
  613.                         {
  614.                             call(AIorder,_set,_AIstateHide);
  615.                             state(_clr,StateFollowPath);
  616.                             call(ClrPath);
  617.                         }
  618.                     }
  619.  
  620.                     if(VAItargethealth<=0)    // && VAInotargettime>150)
  621.                     {
  622.                         callsub(Sub_AIGetBackToIdle);
  623.                     }
  624.                 }
  625.                 else
  626.                 {
  627.                     if(VAIhastarget!=0 && VAItargetvisible!=0)        //if actor can see his targetactor but he changed from enemy to friend
  628.                     {
  629.                         call(AIchangetargettoenemy);                //change him to enemy again
  630.                     }
  631.  
  632.                     call(AIupdatetargetpos);
  633.  
  634.                     print("Leaving attack cause no target found");
  635.                     //if(vtrigger==_DIRtempflag || VAInotargettime>2000)
  636.                     if(VTargetDistance<100 && VAInotargettime>30)
  637.                     {
  638.                         if(VAITargetClass==_AIclassAngel)
  639.                         {
  640.                             sample(SFXReactToBobGone,-1);
  641.                         }
  642.                         call(AIorder,_set,_AIstateSearch);
  643.                     }
  644.  
  645.                     print("No Target Time:  ",VAInotargettime);
  646.                     if(VAItargethealth<=0)    // && VAInotargettime>150)
  647.                     {
  648.                         callsub(Sub_AIGetBackToIdle);
  649.                     }
  650.                 }
  651.  
  652.                 if(VTrigger!=_DIRhavegun)
  653.                 {
  654.                     //Check if weapon closeby
  655.                     //if so go for it
  656.                     call(IsPickupClose,_ClassWeapon,1000,TmpFloat,WeaponPickUpPos);
  657.                     if(vtrigger==_DIRTempFlag && TmpFloat!=0)
  658.                     {
  659.                         vector(_setpathdest,WeaponPickUpPos);
  660.                         call(AIorder,_set,_AIstateGetWeapon);
  661.                     }
  662.                 }
  663.                 if(VAIlosttargetptr!=0)
  664.                 {
  665.                     callsub(Sub_AIGetBackToIdle);
  666.                 }
  667.  
  668.             }
  669.             elseif(vaistate==_aistateSearch)
  670.             {
  671.                 print("Im in search");
  672.                 //pick random near node
  673.             //    if(VAItimeincurrentorder==100)
  674.             //    {
  675.             //        spawnaction(CopWalkie);
  676.             //        callsub(Sub_RandomWalkieLostSFX);
  677.             //    }
  678.                 if(VAItimeincurrentorder>300)
  679.                 {
  680.                     CallSub(Sub_AIGetBackToIdle);
  681.                 }
  682.                 call(AIPickdest,10);
  683.             //    if(vtrigger==_DIRtempflag || VAItimeincurrentorder>AINOTARGETTHRESHOLD || VPathDestDistance<100)
  684.             //    {
  685.             //    }
  686.                 if(VAItargetfound!=0 && VAItargetfound==_AIenemy)
  687.                 {
  688.                     call(AIorder,_set,_AIstateattack);
  689.                 }
  690.  
  691.                 if(VAIlosttargetptr!=0)
  692.                 {
  693.                     callsub(Sub_AIGetBackToIdle);
  694.                 }
  695.             }
  696.             elseif(vaistate==_AIstateHide)
  697.             {
  698.                 printi("AIstate hide:  ",VAItargetfound);
  699.                 if(VAItargetfound!=0 && VAItargetfound==_AIenemy)
  700.                 {
  701.                     if(VAIhastarget==0)
  702.                     {
  703.                         call(AIselecttarget,_AIenemy);                //in no group. goes after the guy by himself
  704.                     }
  705.                     call(AIupdatetargetpos);
  706.                 }
  707.                 else
  708.                 {
  709.                     printi("HIDE: AITarget visible:  ",VAItargetvisible);
  710.                     if(VAIhastarget!=0 && VAItargetvisible!=0)        //if actor can see his targetactor but he changed from enemy to friend
  711.                     {
  712.                         call(AIchangetargettoenemy);                //change him to enemy again
  713.                     }
  714.                     call(AIupdatetargetpos);
  715.                 }
  716.                 call(AIPickdest,10);
  717.  
  718.                 if(VAIlosttargetptr!=0 || VAITargetHealth<=0)
  719.                 {
  720.                     print("Exiting hide mode");
  721.                     callsub(Sub_AIGetBackToIdle);
  722.                 }
  723.             }
  724.             elseif(VAItargetfound!=0)
  725.             {
  726.                 printi("Im in targetfound:    ",VAItargetfound);
  727.                 if(VAItargetfound==_AIenemy)    // && VRank>=_RankSergeantL)
  728.                 {
  729.                     call(AIorder,_set,_AIstateattack);
  730.                     if(VAIleaderaspirations!=0)
  731.                     {
  732.                         //call(AIasktojoin,_AIstateAttack);
  733.                         //call(AIorder,_set,_AIstateattack);
  734.                         //sample(SFXOrderGetHim,-1);
  735.                     }
  736.                 }
  737.                 elseif(VAITargetFound==_AIundetermined)
  738.                 {
  739.                     print("Target undetermined");
  740.                     //call(AIselecttarget,_AIundetermined);
  741.                     //call(AIorder,_set,_AIstateSearch);
  742.                 }
  743.                 else
  744.                 {
  745.                     //resets back to idle if no enemy found. Should use threshold values.
  746.                     CallSub(Sub_AIGetBackToIdle);
  747.                 }
  748.                 call(AIPickdest,10);
  749.             }
  750.             else
  751.             {
  752.                 print("Im in changetoidle");
  753.                 CallSub(Sub_AIGetBackToIdle);
  754.                 call(AIPickdest,10);
  755.             }
  756.  
  757.             if(VAIState!=_AIstatePatrol)
  758.             {
  759.                 if(AIUsage&=_AIUAdvanceIfEnemyUnseen)
  760.                 {
  761.                     if(VAITargetFound==_AIenemy)
  762.                     {
  763.                         call(AIorder,_or,_AInomove);
  764.                     }
  765.                     else
  766.                     {
  767.                         call(AIorder,_clr,_AInomove|_AInoturn);
  768.                     }
  769.                 }
  770.                 if(AIUsage&=_AIUCrouchToDefend)
  771.                 {
  772.                     call(AIOrder,_set,_AIstateRiotCop)
  773.                 }
  774.             }
  775.         }
  776.  
  777.         if(VActorFlag==_AFLAGattached)
  778.         {
  779.             //dummy to prevent ai from running
  780.         }
  781.         elseif(VAIStatehigh==_AIcombatmodereact)
  782.         {
  783.             print("Combat mode react:  ",CloseUpCounter);
  784.             call(AIOrder,_or,_AInomove|_AInoturn|_AIstayonpath);
  785.  
  786.             if(CloseUpCounter==0)
  787.             {
  788.                 if(VAItargettrigger!=_DIRhavegun)
  789.                 {
  790.                     sample(SFXCombatModeReactNoGun,-1);
  791.                 }
  792.                 else
  793.                 {
  794.                     sample(SFXCombatModeReactGun,-1);
  795.                 }
  796.             }
  797.  
  798.             call(AIsetlockedonactortotarget);
  799.             callsub(Sub_AI1WayAlignToTarget);
  800.             if(VTargetAngle>-50 && VTargetAngle<50)
  801.             {
  802.                 if(VAction!=CopGesture1)
  803.                 {
  804.                     SpawnAction(CopGesture1);
  805.                 }
  806.             }
  807.  
  808.             if(VAItargettrigger!=_DIRcombatmode)
  809.             {
  810.                 call(AIorder,_clr,_AIinspecialmode|_AIcombatmodereact);
  811.                 SpawnAction(GENidle);
  812.                 float(_set,CloseUpCounter,-100);
  813.             }
  814.             elseif(CloseUpCounter==60)
  815.             {
  816.                 call(AIchangetargettoenemy);
  817.                 //call(AIorder,_set,_AIstateCombatModeReact);
  818.                 //call(AIorder,_set,_AIinspecialmode);
  819.                 //float(_set,AIChoiceVar,0);
  820.                 SpawnAction(GENidle);
  821.                 call(AIOrder,_clr,_AInomove|_AInoturn|_AIstayonpath|_AIcloseupaction|_AIcombatmodereact);
  822.  
  823.                 if(VRank>=_RankSergeantL)
  824.                 {
  825.                     call(AIchangefriendtoenemy);
  826.                     CallSub(Sub_AISetAttack);
  827.                     Call(AIalert,Sub_AISetAttack);
  828.                 }
  829.                 float(_set,CloseUpCounter,-100);
  830.             }
  831.         }
  832.         elseif(VAIStatehigh==_AIcloseupaction)
  833.         {
  834.             print("In close up action. What up:  ",CloseUpCounter);
  835.             call(AIOrder,_or,_AInomove|_AInoturn|_AIstayonpath);
  836.  
  837.             call(AIcheckforplayerone,300);
  838.             if(VTrigger==_DIRTempFlag)
  839.             {
  840.                 call(AIsetlockedonactortotarget);
  841.                 if(VAITargetIsFriend!=0)
  842.                 {
  843.                     if(VAIState==_AIstateWeldKneel)
  844.                     {
  845.                         if(VAction!=WorkerRepresentKneel)
  846.                         {
  847.                             SpawnAction(WorkerRepresentKneel);
  848.                             float(_set,CloseUpCounter,0);
  849.                             sample(SFXChat,-1);
  850.                         }
  851.                         if(CloseUpCounter>150 || VTrigger!=_DIRnotendofanim)
  852.                         {
  853.                             call(AIOrder,_clr,_AInomove|_AInoturn|_AIstayonpath|_AIcloseupaction);
  854.                             call(AIclrtarget);
  855.                             float(_set,CloseUpCounter,0);
  856.                             spawnaction(GENidle);
  857.                         }
  858.                     }
  859.                     else
  860.                     {
  861.                         //if(VAIState==....            //list of states that shouldn't face
  862.                         callsub(Sub_AI1WayAlignToTarget);
  863.                         if(VTargetAngle>-50 && VTargetAngle<50)
  864.                         {
  865.                             if(VAction!=CopRepresent && VAction!=CopRepresentIdle)
  866.                             {
  867.                                 if(CloseUpCounter>1350)
  868.                                 {
  869.                                     sample(SFXChat,-1);
  870.                                 }
  871.                                 else
  872.                                 {
  873.                                     sample(SFXChatFirsttime,-1);
  874.                                 }
  875.                                 SpawnAction(CopRepresent);
  876.                                 float(_set,CloseUpCounter,0);
  877.                             }
  878.                             if(CloseUpCounter>150)
  879.                             {
  880.                                 call(AIOrder,_clr,_AInomove|_AInoturn|_AIstayonpath|_AIcloseupaction);
  881.                                 call(AIclrtarget);
  882.                                 float(_set,CloseUpCounter,0);
  883.                                 spawnaction(GENidle);
  884.                             }
  885.                         }
  886.                     }
  887.                 }
  888.                 else
  889.                 {
  890.                     call(AIclrtarget);
  891.                     call(AIOrder,_clr,_AInomove|_AInoturn|_AIstayonpath|_AIcloseupaction);
  892.                 }
  893.             }
  894.             else
  895.             {
  896.                 if(VState!=StateCrouching)
  897.                 {
  898.                     spawnaction(GENidle);
  899.                 }
  900.                 call(AIOrder,_clr,_AInomove|_AInoturn|_AIstayonpath|_AIcloseupaction);
  901.                 call(AIclrtarget);
  902.                 float(_set,CloseUpCounter,0);
  903.             }
  904.  
  905.             if(VRank<_RankSergeantL)
  906.             {
  907.                 call(AIcheckactordirections,10,_DIRcombatmode|_DIRhavegun);
  908.                 if(VTrigger==_DIRTempFlag)
  909.                 {
  910.                     call(AIsetlockedonactortotarget);
  911.                     if(VTargetDistance<600 && VAItargetseenme!=0)
  912.                     {
  913.                         call(AIOrder,_clr,_AInomove|_AInoturn|_AIstayonpath|_AIcloseupaction);
  914.                         call(AIorder,_set,_AIstateSurrender);
  915.                         call(AIorder,_set,_AIinspecialmode);
  916.                     }
  917.                 }
  918.             }
  919.  
  920.             if(VAItargetfound==_AIenemy && VAItargetvisible!=0)
  921.             {
  922.                 call(AIOrder,_clr,_AInomove|_AInoturn|_AIstayonpath|_AIcloseupaction);
  923.                 call(AIclrtarget);
  924.             }
  925.         }
  926.         elseif(VAIState==_AIstateIdle)
  927.         {
  928.             //Direction(_clr,_DIRMove);            //XXX shouldn't be there. If it fucks up talk to SAXS
  929.             /*
  930.             if(VPlayer1Distance<90000 && CloseUpCounter>150)    //300*300
  931.             {
  932.                 call(AIOrder,_or,_AIcloseupaction);
  933.             }
  934.             */
  935.         }
  936.         elseif(VAIState==_AIstatePatrol)
  937.         {
  938.             if(VPlayer1Distance<90000 && CloseUpCounter>150)    //300*300
  939.             {
  940.                 call(AIOrder,_or,_AIcloseupaction);
  941.                 SpawnAction(GENidle);
  942.             }
  943.         }
  944.         elseif(vaistate==_AIstateSmoke)
  945.         {
  946.             if(VPlayer1Distance<90000 && CloseUpCounter>150)    //300*300
  947.             {
  948.                 call(AIOrder,_or,_AIcloseupaction);
  949.                 SpawnAction(GENidle);
  950.             }
  951.             print("In state smoke");
  952.             if(VAIstatechanged!=0)
  953.             {
  954.             //    if(vrnd<20)
  955.             //    {
  956.                     float(_declare,CopSmokeTimer,500);
  957.                     float(_set,AIChoiceVar,1);
  958.             //    }
  959.             //    elseif(vrnd<10)
  960.             //    {
  961.             //        float(_set,AIChoiceVar,2);
  962.             //    }
  963.             //    else
  964.             //    {
  965.             //        float(_set,AIChoiceVar,0);
  966.             //        call(AIorder,_set,_AIstatePatrol);
  967.             //        call(PickNewNode);
  968.             //    }
  969.             }
  970.             if(AIChoiceVar==1)
  971.             {
  972.                 print("In state smoke choice 1");
  973.                 if(VTrigger!=_DIRNotEndOfAnim && vaction!=CopSmoke && vaction!=CopLightSmoke && vaction!=CopStopSmoke && vaction!=CopChokingCough)
  974.                 {
  975.                     spawnaction(CopLightSmoke);
  976.                 }
  977.                 else
  978.                 {
  979.                     //direction(_clr,_DIRMoveBits);
  980.                 }
  981.  
  982.                 if(vaction==CopLightSmoke)
  983.                 {
  984.                     if(vframe>=165 && vframe<=190)        //match strike 165-190, brightest flickering burn
  985.                     {
  986.                         //match strike sample
  987.                         //red smoke
  988.                     }
  989.                     elseif(vframe>190&&vframe<=290)        //match burns from 190-290, both from left hand
  990.                     {
  991.                         //red smoke from above to subtractive smoke
  992.                     }
  993.                     elseif(vframe>=250&&vframe<=300)    //puffing just lit cigarette 250-300, puffing to get it lit
  994.                     {
  995.                         //puffing sample
  996.                     }
  997.                 }
  998.                 elseif(vaction==CopSmoke)
  999.                 {
  1000.                     //constant smoke effects floating upwards
  1001.                     if(vrnd<10)
  1002.                     {
  1003.                         spawnparticle(fx_fagsmoke,8,emptyvector,emptyvector,-1);
  1004.                     }
  1005.  
  1006.                     if(vframe>=45&&vframe<=90)
  1007.                     {
  1008.                         //vector(_set,tmpvector,255,64,0);
  1009.                         //spawnlight(Lomnilight2,4,emptyvector,tmpvector,EmptyVector,10);
  1010.                         if(vframe==45)
  1011.                         {
  1012.                             //sample(SFXSmokePuffPuff,-1);
  1013.                         }
  1014.                     }
  1015.                     elseif(vframe>=150&&vframe<=210)
  1016.                     {
  1017.                         if(vrnd<50)
  1018.                         {
  1019.                             vector(_set,gactorpos,-8,6,16);
  1020.                             spawnparticle(fx_fagblow,4,gactorpos,emptyvector,-1);
  1021.                         }
  1022.  
  1023.                         if(vframe==150)
  1024.                         {
  1025.                             //sample(SFXSmokeExhale,-1);
  1026.                         }
  1027.                     }
  1028.                 }
  1029.                 elseif(vaction==CopStopSmoke)
  1030.                 {
  1031.                     if(vframe==10)                        //throwing cigarette,  Spawn the particle at frame 10
  1032.                     {
  1033.                         //sprite cigarette with small red flare and grey smoke
  1034.                     }
  1035.                 }
  1036.  
  1037.                 if(vaction==CopSmoke)                    //in smoking idle
  1038.                 {
  1039.                     if(CopSmokeTimer==0)
  1040.                     {
  1041.                         spawnaction(CopStopSmoke);        //finish smoking
  1042.                         float(_set,CopSmokeTimer,500);
  1043.                     }
  1044.                     else
  1045.                     {
  1046.                         float(_sub,CopSmokeTimer,1);
  1047.                     }
  1048.                 }
  1049.             }
  1050.             elseif(AIChoiceVar==2)
  1051.             {
  1052.                 print("In state smoke choice 2");
  1053.                 if(vtrigger==_DIRhavegun)
  1054.                 {
  1055.                     direction(_set,_DIRaction);
  1056.                 }
  1057.                 elseif(vaction!=CopBongSmoke)
  1058.                 {
  1059.                     spawnaction(CopBongSmoke);
  1060.                 }
  1061.                 else
  1062.                 {
  1063.                     direction(_clr,_DIRMoveBits);
  1064.  
  1065.                     if(vframe==125)
  1066.                     {
  1067.                         sample(SFXBong,-1);
  1068.                     }
  1069.                     elseif(vframe==260)
  1070.                     {
  1071.                         sample(SFXBongCough,-1);
  1072.                     }
  1073.                     if(vendofanim!=0)
  1074.                     {
  1075.                         call(AIorder,_set,_AIstatePatrol);
  1076.                         call(PickNewNode);
  1077.                         direction(_set,_DIRaction);
  1078.                         float(_set,ActionOK,1);
  1079.                     }
  1080.                 }
  1081.             }
  1082.         }
  1083.         elseif(VAIstatechanged!=0 && VAIlaststate==_AIstateSmoke)
  1084.         {
  1085.             print("Was in smoke");
  1086.             spawnaction(CopIdle);
  1087.             //call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1088.             //call(AIorder,_set,_AIstateIdle);
  1089.             call(ClrPath);
  1090.         }
  1091.         elseif(vaistate==_AIstatePressButton)
  1092.         {
  1093.             print("Pressing button");
  1094.             direction(_set,_DIRaction);
  1095.             float(_set,ActionOK,1);
  1096.         }
  1097.         elseif(vaistate==_AIstateWeldKneel)
  1098.         {
  1099.             sample(SFXWelderWhistle,-1);
  1100.  
  1101.             if(VPlayer1Distance<90000 && CloseUpCounter>150)    //300*300
  1102.             {
  1103.                 call(AIOrder,_or,_AIcloseupaction);
  1104.             }
  1105.  
  1106.             print("In Weld Kneeling");
  1107.             if(VWeaponType==WeaponTorch || VWeaponType==WeaponBuzzSaw)
  1108.             {
  1109.                 if(VPickDestAngle<20 && VPickDestAngle>-20)
  1110.                 {
  1111.                     if(vaction!=WorkerWeldingKneel)
  1112.                     {
  1113.                         actorflag(_or,_AFLAGnomove);
  1114.                         spawnaction(WorkerWeldingKneel)
  1115.                     }
  1116.                     Direction(_set,_DIRcombatmode);
  1117.                     Direction(_set,_DIRHaveGun);
  1118.                     Direction(_set,_DIRshoot);
  1119.                 }
  1120.             }
  1121.             if(VPathDestDistance>40 && VAction==WorkerWeldingKneel)
  1122.             {
  1123.                 print("Was In Weld");
  1124.                 spawnaction(CopIdle);
  1125.                 actorflag(_clr,_AFLAGnomove);
  1126.                 call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1127.                 call(AIorder,_set,_AIstateIdle);
  1128.                 call(ClrPath);
  1129.             }
  1130.         }
  1131.         elseif(VAIState==_AIStateWatchTV)
  1132.         {
  1133.             print("Watching TV Normal at : ",VPathDestDistance);
  1134.  
  1135.             if(VPlayer1Distance<90000 && CloseUpCounter>150)    //300*300
  1136.             {
  1137.                 call(AIOrder,_or,_AIcloseupaction);
  1138.                 SpawnAction(GENidle);
  1139.             }
  1140.  
  1141.             if(VPathDestDistance>40 && VAction==CopWatchTVActive)
  1142.             {
  1143.                 
  1144.                 spawnaction(CopIdle);
  1145.                 call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1146.                 call(AIorder,_set,_AIstateIdle);
  1147.                 call(ClrPath);
  1148.             }
  1149.             else
  1150.             {
  1151.                 print("VPickDestAngle For TV Normal : ",VPickDestAngle);
  1152.                 if(VPickDestAngle<20 && VPickDestAngle>-20)
  1153.                 {
  1154.                     if(vaction!=CopWatchTVActive)
  1155.                     {
  1156.                         actorflag(_or,_AFLAGnomove);
  1157.                         spawnaction(CopWatchTVActive)
  1158.                     }
  1159.                 }
  1160.             }
  1161.         }
  1162.         elseif(VAIState==_AIStateWatchTVIdle)
  1163.         {
  1164.             print("Watching TV Idle at : ",VPathDestDistance);
  1165.             if(VPathDestDistance>40 && VAction==CopWatchTVIdle)
  1166.             {
  1167.                 spawnaction(CopIdle);
  1168.                 call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1169.                 call(AIorder,_set,_AIstateIdle);
  1170.                 call(ClrPath);
  1171.             }
  1172.             else
  1173.             {
  1174.                 print("VPickDestAngle For TV Idle : ",VPickDestAngle);
  1175.                 if(VPickDestAngle<20 && VPickDestAngle>-20)
  1176.                 {
  1177.                     if(VAction!=CopWatchTVIdle)
  1178.                     {
  1179.                         actorflag(_or,_AFLAGnomove);
  1180.                         spawnaction(CopWatchTVIdle);
  1181.                     }
  1182.                 }
  1183.             }
  1184.         }
  1185.         elseif(VAIState==_AIstatePushUp)
  1186.         {
  1187.             print("in pushup");
  1188.             if(VPickDestAngle<20 && VPickDestAngle>-20)
  1189.             {
  1190.                 if(vaction!=CopPushUpsLoop)
  1191.                 {
  1192.                     actorflag(_or,_AFLAGnomove);
  1193.                     spawnaction(CopPushUpsLoop)
  1194.                 }
  1195.                 else
  1196.                 {
  1197.                     state(_or,StateCrouching);
  1198.                 }
  1199.             }
  1200.             if(VPathDestDistance>40 && VAction==CopPushUpsLoop)
  1201.             {
  1202.                 spawnaction(CopIdle);
  1203.                 call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1204.                 call(AIorder,_set,_AIstateIdle);
  1205.                 call(ClrPath);
  1206.             }
  1207.         }
  1208.         elseif(VAIState==_AIstateShadowBoxing)
  1209.         {
  1210.             print("in Shadow Boxing");
  1211.             if(VPickDestAngle<40 && VPickDestAngle>-40)
  1212.             {
  1213.                 float(_add,PunchTimer,1);
  1214.                 if(PunchTimer<=200)
  1215.                 {
  1216.                     if(vaction!=CopShadowBoxingIdle)
  1217.                     {
  1218.                         spawnaction(CopShadowBoxingIdle)
  1219.                     }
  1220.                 }
  1221.                 elseif(PunchTimer<=220)
  1222.                 {
  1223.                     if(vaction!=CopShadowBoxingPunch)
  1224.                     {
  1225.                         spawnaction(CopShadowBoxingPunch)
  1226.                     }
  1227.                 }
  1228.                 if(PunchTimer>220)
  1229.                 {
  1230.                     float(_set,PunchTimer,0);
  1231.                 }
  1232.             }
  1233.         }
  1234.         elseif(vaistate==_AIstateWorkWeld)
  1235.         {
  1236.             //callsub(Sub_AI1WayAlignToTarget);
  1237.             print("In Weld");
  1238.  
  1239.             sample(SFXWelderWhistle,-1);
  1240.  
  1241.             if(VWeaponType==WeaponTorch || VWeaponType==WeaponBuzzSaw)
  1242.             {
  1243.                 if(VPickDestAngle<20 && VPickDestAngle>-20)
  1244.                 {
  1245.                     if(vaction!=WorkerWelding)
  1246.                     {
  1247.                         spawnaction(WorkerWelding);
  1248.                     }
  1249.                     direction(_set,_DIRshoot);
  1250.                 }
  1251.             }
  1252.             if(VPathDestDistance>40 && VAction==WorkerWelding)
  1253.             {
  1254.                 print("Was In Weld");
  1255.                 spawnaction(CopIdle);
  1256.                 call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1257.                 call(AIorder,_set,_AIstateIdle);
  1258.                 call(ClrPath);
  1259.             }
  1260.         }
  1261.         elseif(vailaststate==_AIstateWorkWeld || vailaststate==_AIstateWorkWeld)
  1262.         {
  1263.             print("Was In Weld");
  1264.             spawnaction(CopIdle);
  1265.             call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1266.             call(AIorder,_set,_AIstateIdle);
  1267.             call(ClrPath);
  1268.         }
  1269.         elseif(vaistate==_AIstateGetToWork)
  1270.         {
  1271.             call(AIcheckactorstatesneg,0,_AIclassworker,0,_AInotonpath);
  1272.             if(vtrigger!=_DIRTempFlag)
  1273.             {
  1274.                 call(AIchangeenemytofriend);
  1275.                 callSub(Sub_AIGetBackToIdle);
  1276.             }
  1277.             else
  1278.             {
  1279.                 call(AIupdatetargetpos);
  1280.                 if(AIChoiceVar==0)
  1281.                 {
  1282.                     if(VTargetDistance<500 && vaistatehigh!=_AInomove)
  1283.                     {
  1284.                         call(AIorder,_set,_AInomove);
  1285.                     }
  1286.                     if(vaistatehigh==_AInomove && VAItimeincurrentorder>100)
  1287.                     {
  1288.                         float(_set,AIChoiceVar,1);
  1289.                         sample(SFXCopGetBackToWork2,-1);
  1290.                         spawnaction(CopGesture2);
  1291.                         call(AIorder,_set,_AInomove);        //XXX to reset timeincurrentorder
  1292.                     }
  1293.                 }
  1294.                 elseif(AIChoiceVar==1)
  1295.                 {
  1296.                     if(VAItimeincurrentorder>100)
  1297.                     {
  1298.                         call(AIorder,_clr,_AInomove|_AInoturn);
  1299.                         float(_set,AIChoiceVar,2);
  1300.                         CallSub(Sub_AISetCombatMode);
  1301.                         sample(SFXCopGetBackToWork3,-1);
  1302.                         spawnaction(CopGesture1);
  1303.                     }
  1304.                 }
  1305.                 elseif(AICHoiceVar==2)
  1306.                 {
  1307.                     if(VTargetDistance<300 && vaistatehigh!=_AInomove)
  1308.                     {
  1309.                         call(AIorder,_set,_AInomove);
  1310.                     }
  1311.                     if(VAItimeincurrentorder>100)
  1312.                     {
  1313.                         call(AIchangefriendtoenemy);
  1314.                         call(AIlockedtoactorflag,_clr);
  1315.                         CallSub(Sub_AISetAttack);
  1316.                         float(_set,AIChoiceVar,0);
  1317.                     }
  1318.                 }
  1319.             }
  1320.         }
  1321.         elseif(vaistate==_AIstateCombatModeReact)
  1322.         {
  1323.             if(VRank>=_RankSergeantL)
  1324.             {
  1325.                 sample(SFXCopPulledAGun,-1);
  1326.                 call(AIchangefriendtoenemy);
  1327.                 CallSub(Sub_AISetAttack);
  1328.                 Call(AIalert,Sub_AISetAttack);
  1329.             }
  1330.         }
  1331.         elseif(vaistate==_AIstatePossesionReact)
  1332.         {
  1333.             if(VRank>=_RankSergeantL)
  1334.             {
  1335.                 CallSub(Sub_AISetAttack);
  1336.             }
  1337.             else
  1338.             {
  1339.                 float(_set,AIEncounterVar,2);
  1340.                 //panic
  1341.                 //for now just go back to idle
  1342.                 CallSub(Sub_AIGetBackToIdle);
  1343.             }
  1344.         }
  1345.         elseif(vaistate==_AIstateReactToBob)
  1346.         {
  1347.             print("In bob reaction   ");
  1348.             if(VAItimeincurrentorder==0 && AIEncounterVar<=1)
  1349.             {
  1350.                 if(AIEncounterVar==0)                //first encounter
  1351.                 {
  1352.                     sample(SFXWorkerWhatThe,-1);
  1353.                     float(_set,AIEncounterVar,1);
  1354.                     spawnaction(WorkerWhatThe);
  1355.                 }
  1356.                 elseif(AIEncounterVar==1)            //second encounter, no possesion
  1357.                 {
  1358.                     //gesture to "get away"
  1359.                     spawnaction(WorkerGetLost);
  1360.                     if(VAItargethealth>0)//only when Bob is NOT dead
  1361.                     {
  1362.                         sample(SFXReactToBob,-1);
  1363.                     }
  1364.                 }
  1365.             }
  1366.             else
  1367.             {
  1368.                 if(AIEncounterVar==2)
  1369.                 {
  1370.                     if(VAIhidenodenear!=0)
  1371.                     {
  1372.                         call(AIorder,_set,_AIstatehide);
  1373.                         call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1374.                         state(_clr,StateFollowPath);
  1375.                         call(ClrPath);
  1376.                     }
  1377.                     else
  1378.                     {
  1379.                         //if no hidenode can be found search for node far away and run there
  1380.                         //for now just go back to idle
  1381.                         CallSub(Sub_AIGetBackToIdle);
  1382.                     }
  1383.                 }
  1384.                 if(VEndOfAnim!=0)
  1385.                 {
  1386.                     CallSub(Sub_AIGetBackToIdle);
  1387.                     //call(AIorder,_clr,_AIinspecialmode|_AInomove|_AInoturn);
  1388.                 }
  1389.             }
  1390.         }
  1391.         elseif(vaistate==_AIstateCowering)
  1392.         {
  1393.             if(vstate!=StateOnFire && vstate!=StateSteamed && vstate!=StateBlind)
  1394.             {
  1395.                 if(vaction!=GENCoweringLoop)
  1396.                 {
  1397.                     SpawnAction(GENCoweringLoop);
  1398.                     float(_set,AIChoiceVar,0);
  1399.                 }
  1400.                 else
  1401.                 {
  1402.                     if(VAITargetClass==_AIclassAngel)
  1403.                     {
  1404.                         sample(SFXReactToBobMoreCops,-1);
  1405.                     }
  1406.                     float(_add,AIChoiceVar,1)
  1407.                     if(AIChoiceVar>240)
  1408.                     {
  1409.                         SpawnAction(CopIdle);
  1410.                         CallSub(Sub_AIGetBackToIdle);
  1411.                     }
  1412.                 }
  1413.             }
  1414.         }
  1415.         elseif(VAIState==_AIstateDropBattery)
  1416.         {
  1417.             if(VAIClass==_AIClassScientist)
  1418.             {
  1419.                 if(Vaction!=NukeBatteryDrop && VTrigger==_DIRhavegun && VWeaponAmmoType==_AmmoBattery && VWeaponAmmoLeft!=0)
  1420.                 {
  1421.                     if(vpickdestanglecorr>-20 && vpickdestanglecorr<20)
  1422.                     {
  1423.                         spawnaction(NukeBatteryDrop);
  1424.                         sample(SFXDropBattery,-1);
  1425.                     }
  1426.                 }
  1427.             }
  1428.         }
  1429.         elseif(VAIState==_AIStateShoot)
  1430.         {
  1431.             if(VAIClass==_AIClassScientist)
  1432.             {
  1433.                 if(Vaction!=NukeBatteryPick && VTrigger==_DIRhavegun && VWeaponAmmoType==_AmmoBattery && VWeaponAmmoLeft==0)
  1434.                 {
  1435.                     if(vpickdestanglecorr>-20 && vpickdestanglecorr<20)
  1436.                     {
  1437.                         spawnaction(NukeBatteryPick);
  1438.                     }
  1439.                 }
  1440.             }
  1441.             else
  1442.             {
  1443.                 if(vtrigger==_DIRHAveGun)
  1444.                 {
  1445.                     if(vtrigger!=_DIRcombatmode)
  1446.                     {
  1447.                         float(_set,SubVar1,0);
  1448.                         direction(_set,_DIRcombatmode);
  1449.                     }
  1450.                     else
  1451.                     {
  1452.                         float(_add,SubVar1,1)
  1453.                         if(SubVar1>=50)
  1454.                         {
  1455.                             direction(_or,_DIRShoot);
  1456.                         }
  1457.                         if(SubVar1>=55)
  1458.                         {
  1459.                             direction(_clr,_DIRShoot);
  1460.                             float(_set,SubVar1,0);
  1461.                         }
  1462.                     }
  1463.                 }
  1464.             }
  1465.         }
  1466.         elseif(vaistate==_AIstateGuard)
  1467.         {
  1468.             print("In state guard");
  1469.             call(AIorder,_set,_AIinspecialmode|_AInomove|_AInoturn|_AIstayonpath);
  1470.  
  1471.             if(VPlayer1Distance<90000 && CloseUpCounter>150)    //300*300
  1472.             {
  1473.                 call(AIOrder,_or,_AIcloseupaction);
  1474.                 SpawnAction(GENidle);
  1475.             }
  1476.  
  1477.             if(VAIhastarget!=0 || VAItargetfound==_AIenemy)
  1478.             {
  1479.                 if(VAItargetfound==_AIenemy)
  1480.                 {
  1481.                     call(AIselecttarget,_AIenemy);
  1482.                     if(VAIhastarget==0)
  1483.                     {
  1484.                         call(AIalert,Sub_AISetAttack);
  1485.                     }
  1486.                     else
  1487.                     {
  1488.                         call(AIselecttarget,_AIenemy);
  1489.                     }
  1490.                 }
  1491.                 elseif(VAItargetvisible!=0 && VAItargetfound!=_AIenemy)        //if actor can see his targetactor but he changed from enemy to friend
  1492.                 {
  1493.                     call(AIchangetargettoenemy);                        //change him to enemy again
  1494.                 }
  1495.  
  1496.                 //call(AIupdatetargetpos);
  1497.  
  1498.                 print("In guard mode and has target");
  1499.                 if(vtrigger!=_DIRcombatmode)
  1500.                 {
  1501.                     ActorFlag(_or,_AFLAGsniper);
  1502.                     direction(_set,_DIRcombatmode);
  1503.                 }
  1504.                 CallSub(Sub_AI1WayAlignToTarget);
  1505.                 CallSub(Sub_AIShootCheck,Counter,AIGrenadeCounter);
  1506.  
  1507.                 printi("No Target Time:   ",VAInotargettime);
  1508.                 if(VAInotargettime>AINOTARGETTHRESHOLD)
  1509.                 {
  1510.                     call(AIclrtarget);
  1511.                 }
  1512.             }
  1513.             elseif(vtrigger==_DIRcombatmode)
  1514.             {
  1515.                 ActorFlag(_clr,_AFLAGsniper);
  1516.                 direction(_clr,_DIRcombatmode);
  1517.             }
  1518.  
  1519.         }
  1520.         elseif(VAIstatechanged!=0 && VAIlaststate==_AIStateGuard)
  1521.         {
  1522.             ActorFlag(_clr,_AFLAGsniper);
  1523.             call(ClrPath);
  1524.         }
  1525.  
  1526.         elseif(vaistate==_AIstatePressAlarmButton)
  1527.         {
  1528.             if(vpickdestanglecorr<128 && vpickdestanglecorr>-128)
  1529.             {
  1530.                 direction(_set,_DIRaction);
  1531.                 float(_set,ActionOK,1);
  1532.                 call(ClrPath);
  1533.                 CallSub(Sub_SetCoweringMode);
  1534.             }
  1535.         }
  1536.         elseif(VAIstate==_AIStateRun)
  1537.         {
  1538.             print("In state run");
  1539.         }
  1540.         elseif(VAIState==_AIstateSurrender)
  1541.         {
  1542.             if(VTrigger==_DIRhavegun)
  1543.             {
  1544.                 call(CheckAttached,_CADropWeaponAndShells);
  1545.             }
  1546.             if(VAction!=GENSurrender)
  1547.             {
  1548.                 SpawnAction(GENSurrender);
  1549.             }
  1550.             if(VAItimeincurrentorder>100)
  1551.             {
  1552.                 CallSub(Sub_SetCoweringMode);
  1553.             }
  1554.             if(VAItargettrigger!=_DIRhavegun)
  1555.             {
  1556.                 sample(SFXCombatModeReactNoGun,-1);
  1557.             }
  1558.             else
  1559.             {
  1560.                 sample(SFXCombatModeReactGun,-1);
  1561.             }
  1562.         }
  1563.         elseif(VAIState==_AIstateConfused)
  1564.         {
  1565.             print("In confused state:   ",AIChoiceVar);
  1566.             if(VAction!=CopDizzy)
  1567.             {
  1568.                 SpawnAction(CopDizzy);
  1569.                 float(_set,AIChoiceVar,100);
  1570.             }
  1571.             else
  1572.             {
  1573.                 float(_sub,AIChoiceVar,1);
  1574.                 if(AIChoiceVar<0)
  1575.                 {
  1576.                     CallSub(Sub_AIGetBackToIdle);
  1577.                     SpawnAction(GENidle);
  1578.                     ActorFlag(_clr,_AFLAGconfused);
  1579.                 }
  1580.             }
  1581.         }
  1582.         elseif(VAIState==_AIstateRadioactive)
  1583.         {
  1584.             print("mofo i'm radioactive:   ",AIChoiceVar);
  1585.             call(SubtractHealth,0,DamageRadioactive);
  1586.             if(VAction!=CopDizzy)
  1587.             {
  1588.                 SpawnAction(CopDizzy);
  1589.                 float(_set,AIChoiceVar,100);
  1590.             }
  1591.             else
  1592.             {
  1593.                 float(_sub,AIChoiceVar,1);
  1594.                 if(AIChoiceVar<0)
  1595.                 {
  1596.                     CallSub(Sub_AIGetBackToIdle);
  1597.                     SpawnAction(GENidle);
  1598.                     ActorFlag(_clr,_AFLAGradiated);
  1599.                 }
  1600.             }
  1601.         }
  1602.         elseif(VAIState==_AIstateSneakUp)
  1603.         {
  1604.             printi("In sneak up state:  ",VTargetDistance);
  1605.             if(VAItargetseenme!=0)
  1606.             {
  1607.                 print("Spotted. OOOpppss");
  1608.                 CallSub(Sub_AIGetBackToIdle);
  1609.                 SpawnAction(DwellerCaughtSneakingUp);
  1610.             }
  1611.  
  1612.             if(VTargetDistance<120)
  1613.             {
  1614.                 if(VTrigger!=_DIRcombatmode)
  1615.                 {
  1616.                     Direction(_set,_DIRcombatmode);
  1617.                 }
  1618.                 Direction(_set,_DIRshoot);
  1619.                 call(AIorder,_set,_AInomove);
  1620.             }
  1621.         }
  1622.         elseif(VAIState==_AIstateRiotCop)
  1623.         {
  1624.             printi("In riot cop mode:  ",VTargetDistance);
  1625.  
  1626.             if(VAIhaspath!=0)
  1627.             {
  1628.                 call(AIOrder,_or,_AInomove|_AIstayonpath|_AIinspecialmode|_AInoturn);
  1629.             }
  1630.  
  1631.             if(VAIhastarget!=0)
  1632.             {
  1633.                 if(VTargetDistance<200)
  1634.                 {
  1635.                     Direction(_or,_DIRshoot);
  1636.                 }
  1637.  
  1638.                 if(VAItargetfound==_AIenemy)
  1639.                 {
  1640.                     call(AIupdatetargetpos);
  1641.                     call(AIselecttarget,_AIenemy);
  1642.                     if(VAItargetseenme!=0 && VAItargettrigger==_DIRcombatmode)
  1643.                     {
  1644.                         if(vstate!=StateCrouching)
  1645.                         {
  1646.                             direction(_set,_DIRcrouch);
  1647.                         }
  1648.                         print("riotcop no move");
  1649.                         call(AIorder,_or,_AInomove);
  1650.                         ActorFlag(_or,_AFLAGshieldon);
  1651.                     }
  1652.                     else
  1653.                     {
  1654.                         print("riotcop move");
  1655.                         call(AIorder,_clr,_AInomove|_AInoturn);
  1656.                         ActorFlag(_clr,_AFLAGshieldon);
  1657.                         if(vstate==StateCrouching)
  1658.                         {
  1659.                             direction(_set,_DIRcrouch);
  1660.                         }
  1661.                     }
  1662.                 }
  1663.                 else
  1664.                 {
  1665.                     ActorFlag(_clr,_AFLAGshieldon);
  1666.                     call(AIorder,_set,_AIstateAttack);
  1667.  
  1668.                     if(vstate==StateCrouching)
  1669.                     {
  1670.                         direction(_set,_DIRcrouch);
  1671.                     }
  1672.                 }
  1673.             }
  1674.         }
  1675.         elseif(VAIState==_AIstateFollowTheLeader)
  1676.         {
  1677.             //only happens in idle mode
  1678.             print("Crowd around leader");
  1679.             if(VAIhastarget!=0)
  1680.             {
  1681.                 print("I have a target");
  1682.                 call(AIupdatetargetpos);
  1683.             }
  1684.             else
  1685.             {
  1686.                 print("Found no target for crowding");
  1687.                 call(GetNumbActorsInCurrentSet,TmpFloat,_AIClassChot,_GreaterEqual,_RankSergeantM);
  1688.                 print("NrChots: ",TmpFloat);
  1689.                 if(TmpFloat!=0)
  1690.                 {
  1691.                     call(AIselecttarget,_AIfriend,_AIClassChot,_GreaterEqual,_RankSergeantM);
  1692.                 }
  1693.                 else
  1694.                 {
  1695.                     CallSub(Sub_AIGetBackToIdle);
  1696.                 }
  1697.             }
  1698.         }
  1699.         elseif(VAIState==_AIStateDetachFromPath)
  1700.         {
  1701.             state(_clr,StateExecutePathSequence);
  1702.             state(_or,StateFollowPath);
  1703.             call(ClrPath);
  1704.             call(PickNewNode);
  1705.             debugmessage("Detaching from path");
  1706.         }
  1707.         elseif(VAIState==_AIstateDetachReattachToPath)
  1708.         {
  1709.             call(DetachReattachToPath);
  1710.         }
  1711.         elseif(VAIState==_AIstateDJPuke)
  1712.         {
  1713.             if(VAction!=DJPuke)
  1714.             {
  1715.                 SpawnAction(DJPuke);
  1716.             }
  1717.             else
  1718.             {
  1719.                 //Animation already going
  1720.             }
  1721.         }
  1722.  
  1723.         elseif(VAIState==_AIstateDJChillyChill1)
  1724.         {
  1725.             if(VAction!=DJChillyChill1)
  1726.             {
  1727.                 SpawnAction(DJChillyChill1);
  1728.             }
  1729.             else
  1730.             {
  1731.                 //Animation already going
  1732.             }
  1733.         }
  1734.  
  1735.         elseif(VAIState==_AIstateDJChillyChill2)
  1736.         {
  1737.             if(VAction!=DJChillyChill2)
  1738.             {
  1739.                 SpawnAction(DJChillyChill2);
  1740.             }
  1741.             else
  1742.             {
  1743.                 //Animation already going
  1744.             }
  1745.         }
  1746.  
  1747.         elseif(VAIState==_AIstateDJChillyChill3)
  1748.         {
  1749.             if(VAction!=DJChillyChill3)
  1750.             {
  1751.                 SpawnAction(DJChillyChill3);
  1752.             }
  1753.             else
  1754.             {
  1755.                 //Animation already going
  1756.             }
  1757.         }
  1758.  
  1759.         elseif(VAIState==_AIstateDJSpinRekids)
  1760.         {
  1761.             if(VAction!=DJSpinRekids)
  1762.             {
  1763.                 SpawnAction(DJSpinRekids);
  1764.             }
  1765.             else
  1766.             {
  1767.                 //Animation already going
  1768.             }
  1769.         }
  1770.  
  1771.         elseif(VAIState==_AIstateFreakyManDance)
  1772.         {
  1773.             if(VAction!=ManDance)
  1774.             {
  1775.                 SpawnAction(ManDance);
  1776.             }
  1777.             else
  1778.             {
  1779.                 //Animation already going
  1780.             }
  1781.         }
  1782.  
  1783.         elseif(VAIState==_AIstateDwellerBarIdle1)
  1784.         {
  1785.             if(VAction!=DwellerBarIdle1)
  1786.             {
  1787.                 SpawnAction(DwellerBarIdle1);
  1788.             }
  1789.             else
  1790.             {
  1791.                 //Animation already going
  1792.             }
  1793.         }
  1794.  
  1795.         
  1796.         elseif(VAIState==_AIstateDweller1Sitting)
  1797.         {
  1798.             if(VAction!=Dweller1Sitting)
  1799.             {
  1800.                 SpawnAction(Dweller1Sitting);
  1801.             }
  1802.             else
  1803.             {
  1804.                 //Animation already going
  1805.             }
  1806.         }
  1807.  
  1808.         elseif(VAIState==_AIstateDwellerBarIdle2)
  1809.         {
  1810.             if(VAction!=DwellerBarIdle2)
  1811.             {
  1812.                 SpawnAction(DwellerBarIdle2);
  1813.             }
  1814.             else
  1815.             {
  1816.                 //Animation already going
  1817.             }
  1818.         }
  1819.  
  1820.         elseif(VAIState==_AIstateDweller2Sitting)
  1821.         {
  1822.             if(VAction!=Dweller2Sitting)
  1823.             {
  1824.                 SpawnAction(Dweller2Sitting);
  1825.             }
  1826.             else
  1827.             {
  1828.                 //Animation already going
  1829.             }
  1830.         }
  1831.  
  1832.         elseif(VAIState==_AIstateDwellerBarIdle3)
  1833.         {
  1834.             if(VAction!=DwellerBarIdle3)
  1835.             {
  1836.                 SpawnAction(DwellerBarIdle3);
  1837.             }
  1838.             else
  1839.             {
  1840.                 //Animation already going
  1841.             }
  1842.         }
  1843.  
  1844.         elseif(VAIState==_AIstateDweller3Sitting)
  1845.         {
  1846.             if(VAction!=Dweller3Sitting)
  1847.             {
  1848.                 SpawnAction(Dweller3Sitting);
  1849.             }
  1850.             else
  1851.             {
  1852.                 //Animation already going
  1853.             }
  1854.         }
  1855.  
  1856.         elseif(VAIState==_AIstateFemale1BarIdle)
  1857.         {
  1858.             if(VAction!=Female1BarIdle)
  1859.             {
  1860.                 SpawnAction(Female1BarIdle);
  1861.             }
  1862.             else
  1863.             {
  1864.                 //Animation already going
  1865.             }
  1866.         }
  1867.             
  1868.         elseif(VAIState==_AIstateDwellerBarIdle4)
  1869.         {
  1870.             if(VAction!=DwellerBarIdle4)
  1871.             {
  1872.                 SpawnAction(DwellerBarIdle4);
  1873.             }
  1874.             else
  1875.             {
  1876.                 //Animation already going
  1877.             }
  1878.         }
  1879.  
  1880.         elseif(VAIState==_AIstateFemale1Sitting)
  1881.         {
  1882.             if(VAction!=Female1Sitting)
  1883.             {
  1884.                 SpawnAction(Female1Sitting);
  1885.             }
  1886.             else
  1887.             {
  1888.                 //Animation already going
  1889.             }
  1890.         }
  1891.  
  1892.         elseif(VAIState==_AIstateFemale2Sitting)
  1893.         {
  1894.             if(VAction!=Female2Sitting)
  1895.             {
  1896.                 SpawnAction(Female2Sitting);
  1897.             }
  1898.             else
  1899.             {
  1900.                 //Animation already going
  1901.             }
  1902.         }
  1903.  
  1904.         elseif(VAIState==_AIstateFemale1Sleeping)
  1905.         {
  1906.             if(VAction!=Female1Sleeping)
  1907.             {
  1908.                 SpawnAction(Female1Sleeping);
  1909.             }
  1910.             else
  1911.             {
  1912.                 //Animation already going
  1913.             }
  1914.         }
  1915.  
  1916.         elseif(VAIState==_AIstateFreakyFemDance)
  1917.         {
  1918.             if(VAction!=FemDance)
  1919.             {
  1920.                 SpawnAction(FemDance);
  1921.             }
  1922.             else
  1923.             {
  1924.                 //Animation already going
  1925.             }
  1926.         }
  1927.         elseif(VAIState==_AIstateBouncerBlockBar)
  1928.         {
  1929.             if(VAction!=BouncerBlockBar && VAction!=BouncerNoBlock)
  1930.             {
  1931.                 SpawnAction(BouncerBlockBar);
  1932.             }
  1933.             else
  1934.             {
  1935.             }
  1936.         }
  1937.         elseif(VAIState==_AIstateWaitressSpill)
  1938.         {
  1939.             if(VAction!=WaitressSpill)
  1940.             {
  1941.                 SpawnAction(WaitressSpill);
  1942.             }
  1943.             else
  1944.             {
  1945.             }
  1946.         }
  1947.         elseif(VAIState==_AIstateWaitressClean)
  1948.         {
  1949.             if(VAction!=WaitressClean)
  1950.             {
  1951.                 SpawnAction(WaitressClean);
  1952.             }
  1953.             else
  1954.             {
  1955.             }
  1956.         }
  1957.         elseif(VAIState==_AIstateWaitressPrimp1)
  1958.         {
  1959.             if(VAction!=WaitressPrimp1)
  1960.             {
  1961.                 SpawnAction(WaitressPrimp1);
  1962.             }
  1963.             else
  1964.             {
  1965.             }
  1966.         }
  1967.         elseif(VAIState==_AIstateWaitressPrimp2)
  1968.         {
  1969.             if(VAction!=WaitressPrimp2)
  1970.             {
  1971.                 SpawnAction(WaitressPrimp2);
  1972.             }
  1973.             else
  1974.             {
  1975.             }
  1976.         }
  1977.         elseif(VAIState==_AIstateWaitressIdle)
  1978.         {
  1979.             if(VAction!=WaitressIdle)
  1980.             {
  1981.                 SpawnAction(WaitressIdle);
  1982.             }
  1983.             else
  1984.             {
  1985.             }
  1986.         }
  1987.         elseif(VAIState==_AIstateWaitressFlirt)
  1988.         {
  1989.             if(VAction!=WaitressFlirt)
  1990.             {
  1991.                 SpawnAction(WaitressFlirt);
  1992.             }
  1993.             else
  1994.             {
  1995.             }
  1996.         }
  1997. //        else
  1998. //        {
  1999. //        }
  2000.  
  2001. /*        if(VAIStateHigh==_AIstayonpath)
  2002.         {
  2003.             print("Stay on path code");
  2004.  
  2005.             if(VAIhastarget==0)
  2006.             {
  2007.                 if(VAItargetfound==_AIenemy)
  2008.                 {
  2009.                     call(AIselecttarget,_AIenemy);
  2010.                 }
  2011.             }
  2012.             else
  2013.             {
  2014.                 call(AIupdatetargetpos);
  2015.                 call(AIPickdest,10);
  2016.             }
  2017.  
  2018.             //pick closer node etc.
  2019.         }
  2020. */
  2021.         //character specific code
  2022.         if(VAIclass&==_AIclassAngel|_AIclassChot)    //dwarfchot
  2023.         {
  2024.             print("Dwarfchot special code");
  2025.             if(VAIState==_AIstateAttack && VTargetDistance>1000 && VTargetAngle>-50 && VTargetAngle<50 && VTrigger==_DIRhorcol)
  2026.             {
  2027.                 print("Dwarf in attack");
  2028.                 SpawnAction(DwarfLaunch);
  2029.             }
  2030.         }
  2031.  
  2032.  
  2033.  
  2034.