XIDPawn
Class Plongeur_Usa01_Controller

source: C:\XIII\XIDPawn\Classes\Plongeur_Usa01_Controller.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Controller
         |
         +--Engine.AIController
            |
            +--XIDPawn.Plongeur_Usa01_Controller
Direct Known Subclasses:None

class Plongeur_Usa01_Controller
extends Engine.AIController

//----------------------------------------------------------- // //-----------------------------------------------------------
Variables
 float Angle_Visee
           compteur utilise dans les boucle sur routecache
 bool CHARGE_LES_LOGS
           Pour voir mes logs
 NavigationPoint DestNavPoint
           point de destination
 vector MoveTargetPosition
           compteur utilise dans les boucle sur routecache
 int NiveauAlerte
           Pour voir mes logs
 vector PersoTargetPos
           compteur utilise dans les boucle sur routecache
 vector PersoTargetVelocity
           compteur utilise dans les boucle sur routecache
 Plongeur_USA01 Plongeur
           compteur utilise dans les boucle sur routecache
 vector PosRelative
           compteur utilise dans les boucle sur routecache
 vector RealLastSeenPos
           compteur utilise dans les boucle sur routecache
 float Temp_Float
           compteur utilise dans les boucle sur routecache
 float Temps_RefreshEnemyPos
           compteur utilise dans les boucle sur routecache
 float Timer_RefreshEnemyPos
           compteur utilise dans les boucle sur routecache
 XIIIPlayerPawn XIII
           compteur utilise dans les boucle sur routecache
 bool bTempsPause
           temps de pause entre anim de tir et tir
 bool bTire
 bool btemp_bool
 int iCompteur
           compteur utilise dans les boucle sur routecache
 int numHuntPaths
           Pour voir mes logs

States
Poursuite, attaque, SuitReseau, WaitForXIIIInWater, attente, init

Function Summary
 void AnimEnd(int Channel)
 void DamageAttitudeTo(Pawn Other, float Damage)
 void DecNbAlerte()
 void DecNbAttaque()
 void DecNbAttente()
 bool FindBestPathToward(Actor desired, bool bClearPaths)
     
// ----------------------------------------------------------------------
// FindBestPathToward()
//
// assumes the desired destination is not directly reachable.
// It tries to set Destination to the location of the
// best waypoint, and returns true if successful
// ----------------------------------------------------------------------
 void IncNbAlerte()
     
//niveau d'alerte sonore
 void IncNbAttaque()
 void IncNbAttente()
 bool NotifyHeadVolumeChange(PhysicsVolume NewVolume)
 void Trigger(Actor Other, Pawn EventInstigator)
     
//------------------------------------------------
// TRIGGER: Fonction Trigger declenchee par detectionvolume ou trigger alarme
//------------------------------------------------


State Poursuite Function Summary
 void EndState()
 void BeginState()
 bool FindViewSpot()
 void PickDestination()


State attaque Function Summary
 void EndState()
 void BeginState()
 void HalteAuFeu()
 void Fire_xiii()
 rotator AdjustAim(Ammunition FiredAmmunition, vector projStart, int aimerror)
 void EnemyNotVisible()
     
	{
		plongeur.PlaySpearGunFiring();
	}  */
 void NotifyFiring()
     
/*	


State SuitReseau Function Summary
 void EndState()
 void BeginState()
 bool IsPointInCylinder(Actor cylinder, Vector point, optional float, optional float)
 void PickDestination()
 PatrolPoint PickStartPoint()


State WaitForXIIIInWater Function Summary
 void endstate()
 void Beginstate()


State attente Function Summary
 void Beginstate()


State init Function Summary
 void Beginstate()



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class Plongeur_Usa01_Controller extends AIController;
00005	
00006	var bool   bTire;
00007	var bool   btemp_bool;
00008	var bool	  bTempsPause; //temps de pause entre anim de tir et tir
00009	var bool   CHARGE_LES_LOGS; // Pour voir mes logs
00010	var int    numHuntPaths;
00011	var int    NiveauAlerte;
00012	var int iCompteur; //compteur utilise dans les boucle sur routecache
00013	var float  Timer_RefreshEnemyPos;
00014	var float  Temps_RefreshEnemyPos;
00015	var float  Angle_Visee;
00016	var float  Temp_Float;
00017	var vector PersoTargetPos;
00018	var vector PersoTargetVelocity;
00019	var vector RealLastSeenPos;
00020	var vector MoveTargetPosition;
00021	var vector PosRelative;
00022	
00023	//acteurs
00024	var XiiiPlayerPawn XIII;
00025	var Plongeur_Usa01 Plongeur;
00026	
00027	//patrouille
00028	var NavigationPoint DestNavPoint; //point de destination
00029	
00030	
00031	function bool NotifyHeadVolumeChange( PhysicsVolume NewVolume )
00032	{
00033		if (plongeur.bWaitToTouchWaterVolume && NewVolume.bWaterVolume)
00034		{
00035	      return true;
00036	   }
00037		return false;
00038	}
00039	//function PatrolPoint PickStartPoint()
00040	
00041	//------------------------------------------------
00042	// TRIGGER: Fonction Trigger declenchee par detectionvolume ou trigger alarme
00043	//------------------------------------------------
00044	function Trigger( actor Other, pawn EventInstigator)
00045	{
00046	    if (!isinstate('attente'))
00047	     return;
00048	    gotostate('SuitReseau');
00049	}
00050	singular event bool NotifyBump(actor Other)
00051	{
00052	    return false;
00053	}
00054	singular function DamageAttitudeTo(pawn Other, float Damage)
00055	{
00056	}
00057	event SeePlayer (pawn seenplayer)
00058	{
00059	}
00060	event SeeMonster(pawn seenplayer)
00061	{
00062	}
00063	event HearNoise(float Loudness, Actor NoiseMaker)
00064	{
00065	}
00066	event Tick(float DeltaTime)
00067	{
00068	    super.tick(DeltaTime);
00069	}
00070	event Timer2()
00071	{
00072	   if (XIII.PhysicsVolume.bWaterVolume) //si XIII plus dans l'eau remonte a la surface
00073			gotostate('attaque');
00074	}
00075	function AnimEnd(int Channel)
00076	{
00077	    Pawn.AnimEnd(Channel);
00078	}
00079	
00080	//niveau d'alerte sonore
00081	Function IncNbAlerte()
00082	{
00083	}
00084	Function DecNbAlerte()
00085	{
00086	}
00087	Function IncNbAttaque()
00088	{
00089	}
00090	
00091	Function DecNbAttaque()
00092	{
00093	}
00094	Function IncNbAttente()
00095	{
00096	}
00097	
00098	Function DecNbAttente()
00099	{
00100	}
00101	
00102	// ----------------------------------------------------------------------
00103	// FindBestPathToward()
00104	//
00105	// assumes the desired destination is not directly reachable.
00106	// It tries to set Destination to the location of the
00107	// best waypoint, and returns true if successful
00108	// ----------------------------------------------------------------------
00109	function bool FindBestPathToward(actor desired, bool bClearPaths)
00110	{
00111	    local Actor path;
00112	    local bool success;
00113	    local vector Desti;
00114	
00115	    desti=desired.location;
00116	    path = FindPathTo(desti,true);
00117	    success = (path != None);
00118	    if (success)
00119	    {
00120	        MoveTarget = path;
00121	        Destination = path.Location;
00122	    }
00123	
00124	    return success;
00125	}
00126	
00127	
00128	//                 ---------------- ETATS ------------------
00129	
00130	// ----------------------------------------------------------------------
00131	//Etat d'init
00132	//
00133	// ----------------------------------------------------------------------
00134	auto state init
00135	{
00136	   ignores seeplayer,seemonster,hearnoise;
00137	
00138	     function Beginstate()
00139	     {
00140	     }
00141	begin:
00142	     //CHARGE_LES_LOGS=true;
00143	preinit:
00144		 Plongeur=Plongeur_Usa01(pawn);
00145		  pawn.bSpineControl=false;
00146		  pawn.enableChannelNotify(0, 1);
00147		  pawn.bphysicsanimupdate=false;
00148			if (pawn.PhysicsVolume.bWaterVolume)
00149			{
00150			 pawn.PlayMoving();
00151			 pawn.setphysics(PHYS_SWIMMING);
00152			}
00153			else
00154			{
00155			   plongeur.bWaitToTouchWaterVolume=true;
00156		       pawn.Playanim('descenterappel',0.1);
00157			   pawn.setphysics(PHYS_FALLING);
00158			}
00159	     sleep(0.1);
00160	     XIII=XIIIPlayerPawn(xiiigameinfo(level.game).mapinfo.XIIIpawn);
00161	     Plongeur.InitializeInventory();  //inialise inventaire
00162	     pawn.pendingWeapon=XIIIWeapon(Plongeur.FindInventoryType(class'LHarpon')); //prend harpon
00163	     if (pawn.pendingWeapon==none)
00164	        log("WARNING WARNING PAS DE HARPON PAS DE HARPON");
00165	     else
00166	        pawn.ChangedWeapon();
00167	     bRotateToDesired = false;
00168	     plongeur.PeripheralVision=cos(plongeur.PeripheralVision*0.00873);
00169	     //pawn.BaseEyeHeight=40;
00170	     //pawn.EyeHeight=40;
00171			pawn.rotationrate=rot(4096,50000,3072);
00172			plongeur.bIsPafable=false;
00173	init:
00174	     pawn.bcanswim=true;
00175	     Temps_RefreshEnemyPos=0.6-0.1*plongeur.skill;
00176	     //si skill==1
00177	     if (plongeur.skill==1)
00178	     {
00179	        Angle_Visee=14;
00180	     }
00181	     //si skill==2
00182	     else if (plongeur.skill==2)
00183	     {
00184	        Angle_Visee=12;
00185	     }
00186	     //si skill==3
00187	     else if (plongeur.skill==3)
00188	     {
00189	        Angle_Visee=10;
00190	     }
00191	     //si skill==4
00192	     else if (plongeur.skill==4)
00193	     {
00194	        Angle_Visee=8;
00195	     }
00196	     //si skill==5
00197	     else if (plongeur.skill==5)
00198	     {
00199	        Angle_Visee=6;
00200	     }
00201	     NiveauAlerte=0;
00202	   if (pawn.weapon!=none)
00203		{
00204	   	pawn.weapon.FireOffset=vect(150.000000,-20.000000,-50.000000);
00205			XIIIWeaponAttachment(pawn.weapon.ThirdPersonActor).SetRelativeLocation(vect(15.00,3.00,5.00));
00206	    	XIIIWeaponAttachment(pawn.weapon.ThirdPersonActor).SetRelativeRotation(rot(7000,5000,-10000));
00207	   	pawn.weapon.ThirdPersonRelativeRotation=rot(0,0,0);
00208		}
00209	   else
00210	        log("ATTENTION PAS D'ARME !!!!!!!!!!!!!!!"@pawn.physics@pawn.PhysicsVolume);
00211	   gotostate('SuitReseau');
00212	}
00213	
00214	
00215	// ----------------------------------------------------------------------
00216	//Etat de Attente
00217	//
00218	//
00219	// ----------------------------------------------------------------------
00220	state attente
00221	{
00222	   ignores seemonster,hearnoise;
00223	
00224		 event SeePlayer (pawn seenplayer)
00225	    {
00226	        if (seenplayer==XIII && !xiii.bisdead)
00227	           gotostate('attaque');
00228	    }
00229	
00230	     function Beginstate()
00231	     {
00232	        if (NiveauAlerte==1)
00233	          {
00234	             IncNbattente();
00235	             DecNbAlerte();
00236	          }
00237	          else if (NiveauAlerte==2)
00238	          {
00239	             IncNbattente();
00240	             DecNbAttaque();
00241	          }
00242	        NiveauAlerte=0;
00243	          if (CHARGE_LES_LOGS) log(pawn@"ETAT Attente fait rien");
00244	     }
00245	
00246	begin:
00247	     pawn.velocity=vect(0,0,0);
00248	     pawn.Acceleration = vect(0,0,0);
00249		  enemy=none;
00250	     focus=none;
00251	     focalpoint=100*vector(pawn.rotation)+pawn.location;
00252	}
00253	
00254	// ----------------------------------------------------------------------
00255	//Etat de WaitForXIIIInWater
00256	//
00257	//
00258	// ----------------------------------------------------------------------
00259	state WaitForXIIIInWater
00260	{
00261	   ignores seemonster,seeplayer,hearnoise;
00262	
00263	     function Beginstate()
00264	     {
00265	        if (NiveauAlerte==1)
00266	          {
00267	             IncNbattente();
00268	             DecNbAlerte();
00269	          }
00270	          else if (NiveauAlerte==2)
00271	          {
00272	             IncNbattente();
00273	             DecNbAttaque();
00274	          }
00275	        NiveauAlerte=0;
00276	          if (CHARGE_LES_LOGS) log(pawn@"ETAT Attend que XIII reentre dans l'eau");
00277	     }
00278	    	function endstate()
00279			{
00280				settimer2(0,false);
00281			}
00282	begin:
00283	     pawn.velocity=vect(0,0,0);
00284	     pawn.Acceleration = vect(0,0,0);
00285	     focus=XIII;
00286		 settimer2(1,true);
00287	}
00288	
00289	// ----------------------------------------------------------------------
00290	// SuitReseau
00291	//
00292	//
00293	// ----------------------------------------------------------------------
00294	state SuitReseau
00295	{
00296	  ignores EnemyNotVisible;
00297	
00298	    function PatrolPoint PickStartPoint()
00299	    {
00300	          local NavigationPoint nav;
00301	        local PatrolPoint     curNav;
00302	        local float           curDist;
00303	        local PatrolPoint     closestNav;
00304	        local float           closestDist;
00305	
00306	        nav = Level.NavigationPointList;
00307	        while (nav != None)
00308	        {
00309	            nav.visitedWeight = 0;
00310	            nav = nav.nextNavigationPoint;
00311	        }
00312	        closestNav  = None;
00313	        closestDist = 100000;
00314	        nav = Level.NavigationPointList;
00315	          if (plongeur.NumReseauPropre!=0)
00316	          {
00317	               while (nav != None)
00318	               {
00319	                    curNav = PatrolPoint(nav);
00320	                    if ((curnav!=none) && (curNav.NumReseau!=plongeur.NumReseauPropre))
00321	                         curNav=none;
00322	                    if ((curNav != None) && ActorReachable(curNav) && (LineofSightTo(curNav)))
00323	                    {
00324	                         while (curNav != None)
00325	                         {
00326	                              if (curNav.visitedWeight != 0)  // been here before
00327	                                   break;
00328	                              curDist = VSize(pawn.Location - curNav.Location);
00329	                              if ((closestNav == None) || (closestDist > curDist))
00330	                              {
00331	                                   closestNav  = curNav;
00332	                                   closestDist = curDist;
00333	                              }
00334	                              curNav.visitedWeight = 1;
00335	                              curNav = curNav.NextPatrolPoint;
00336	                              if ((curnav!=none)&&(curNav.NumReseau!=plongeur.NumReseauPropre))
00337	                                   break;
00338	                         }
00339	                    }
00340	                    nav = nav.nextNavigationPoint;
00341	               }
00342	               if (closestnav==none)
00343	               {
00344	                    closestNav  = None;
00345	                    closestDist = 100000;
00346	                    nav=Level.NavigationPointList;
00347	               }
00348	               else
00349	                    nav=none;
00350	          }
00351	          while (nav != None)
00352	         {
00353	            curNav = PatrolPoint(nav);
00354	            if ((curNav != None) && ActorReachable(curNav) && (LineofSightTo(curNav)))
00355	            {
00356	                while (curNav != None)
00357	                {
00358	                    if (curNav.visitedWeight != 0)  // been here before
00359	                        break;
00360	                    curDist = VSize(pawn.Location - curNav.Location);
00361	                    if ((closestNav == None) || (closestDist > curDist))
00362	                    {
00363	                        closestNav  = curNav;
00364	                        closestDist = curDist;
00365	                    }
00366	                    curNav.visitedWeight = 1;
00367	                    curNav = curNav.NextPatrolPoint;
00368	                }
00369	            }
00370	            nav = nav.nextNavigationPoint;
00371	        }
00372	        return (closestNav);
00373	    }
00374	
00375	    function PickDestination()
00376	    {
00377	         if (PatrolPoint(destnavpoint) != None)
00378	        {
00379	            destnavpoint = PatrolPoint(destnavpoint).NextPatrolPoint;
00380	        }
00381	        else
00382	            destnavpoint = PickStartPoint();
00383	        if (destnavpoint == None)  // can't go anywhere...
00384	        {
00385	               if (CHARGE_LES_LOGS) log(pawn@"can't go anywhere");
00386	            GotoState('attente');
00387	        }
00388	    }
00389	
00390	    function bool IsPointInCylinder(Actor cylinder, Vector point,
00391	                                optional float extraRadius, optional float extraHeight)
00392	    {
00393	       local bool  bPointInCylinder;
00394	       local float tempX, tempY, tempRad;
00395	
00396	       tempX    = cylinder.Location.X - point.X;
00397	       tempX   *= tempX;
00398	       tempY    = cylinder.Location.Y - point.Y;
00399	       tempY   *= tempY;
00400	       tempRad  = cylinder.CollisionRadius + extraRadius;
00401	       tempRad *= tempRad;
00402	
00403	       bPointInCylinder = false;
00404	       if (tempX+tempY < tempRad)
00405	          if (Abs(cylinder.Location.Z - point.Z) < (cylinder.CollisionHeight+extraHeight))
00406	               bPointInCylinder = true;
00407	
00408	        return (bPointInCylinder);
00409	     }
00410	
00411	    function BeginState()
00412	    {
00413	        if (CHARGE_LES_LOGS) log(pawn@"ETAT SuitReseau");
00414	        if (NiveauAlerte==1)
00415	          {
00416	             IncNbattente();
00417	             DecNbAlerte();
00418	          }
00419	          else if (NiveauAlerte==2)
00420	          {
00421	             IncNbattente();
00422	             DecNbAttaque();
00423	          }
00424	        NiveauAlerte=0;
00425	    }
00426	    function EndState()
00427	    {
00428	    }
00429	Begin:
00430		  enemy=none;
00431	     destnavpoint = None;
00432	Patrol:
00433	     PickDestination();
00434	Moving:
00435	    // Move from pathnode to pathnode until we get where we're going
00436	    if (destnavpoint != None)
00437	    {
00438	        if (!IsPointInCylinder(pawn, destnavpoint.Location, 16-pawn.CollisionRadius))
00439	        {
00440	            MoveTarget=none;
00441	            if (FastTrace(DestNavPoint.location-vect(0,0,30),pawn.location-vect(0,0,30)))
00442	            {
00443	                routecache[0]=DestNavPoint;
00444	                routecache[1]=none;
00445	            }
00446	            else if (!FindBestPathToward(DestNavPoint,true))
00447	            {
00448	                if (CHARGE_LES_LOGS) log(pawn@"trouve pas le patrolpoint");
00449	                GotoState('attente');
00450	            }
00451	            for (iCompteur=0;iCompteur<16;iCompteur++)
00452	            {
00453	               if (routecache[iCompteur]==none)
00454	                   break;
00455	               focus=none;
00456	               focalpoint=1000*(routecache[iCompteur].location-pawn.location)+pawn.location;
00457	               Temp_float=normal(routecache[iCompteur].location-pawn.location) dot normal(vector(pawn.rotation));
00458	               if (Temp_float<0.3)
00459	               {
00460	                  pawn.velocity=vect(0,0,0);
00461	                  pawn.acceleration=vect(0,0,0);
00462	                  sleep(20000*(1-Temp_float)/pawn.rotationrate.yaw);
00463	               }
00464	               MoveToward(routecache[iCompteur],none);
00465	            }
00466	        }
00467			  WaitForLanding();
00468	        goto('patrol');
00469	    }
00470	finreseau:
00471	    if (cansee(XIII))
00472	       gotostate('attaque');
00473	    else
00474	       gotostate('attente');
00475	}
00476	
00477	// ----------------------------------------------------------------------
00478	// Etat d'attaque  (voit forcement xiii sinon Poursuite)
00479	//
00480	//
00481	// ----------------------------------------------------------------------
00482	state attaque
00483	{
00484	
00485	/*	function NotifyFiring()
00486		{
00487			plongeur.PlaySpearGunFiring();
00488		}  */
00489	  function EnemyNotVisible()
00490	  {
00491			gotostate('Poursuite');
00492	  }
00493	  function rotator AdjustAim(Ammunition FiredAmmunition, vector projStart, int aimerror)
00494	  {
00495	     local vector Vect_Modif;
00496	     local vector direction;
00497	     local float angle;
00498	     local vector X,Y,Z;
00499	
00500	     if (PersoTargetPOs==vect(0,0,0))
00501	         LOG("WUUUUUUUUUU WUUUUUUUUU WUUUUUUUU  PERSOTARGET POS = 0 0 0 PAS BON BUG BUGGGGG");
00502	     //chance de coup fatal
00503	     If (plongeur.skill==5 && Frand()<0.5)
00504	         direction=xiii.location;
00505	     else
00506	     {
00507	         // -------------
00508	         // cone de visee
00509	         // -------------
00510	         GetAxes(Rotation, X,Y,Z);  //choppe axes pawn
00511	         angle=Angle_Visee;
00512	         //choppe valeur de l'angle de visee actuel en degre
00513	         Vect_Modif=Normal(Vrand() cross Normal(X)); //prend une direction aleatoire
00514	         angle*=Frand(); //prend une valeur pour l'angle de tir entre 0 et angle actuel
00515	         Vect_Modif*=Vsize(xiii.location-pawn.location)*Tan(angle*Pi/180);  //multiplie direction a norme imposee par angle et distance a xiii
00516	         if (xiii.base!=none)
00517	            direction= Vect_Modif + PersoTargetPos+(xiii.base.velocity+PersoTargetVelocity-pawn.velocity)*0.8*Temps_RefreshEnemyPos;
00518	         else
00519	            direction= Vect_Modif + PersoTargetPos+(PersoTargetVelocity-pawn.velocity)*0.8*Temps_RefreshEnemyPos;
00520	      }
00521	      return rotator(direction-projStart);
00522	  }
00523	  function Fire_xiii()
00524	  {
00525	      local float Temps_Acqui;
00526	      local int random;
00527	
00528	     if (!bTire)
00529	     {
00530	        if (xiii.bisdead)
00531	           return;
00532	        //plongeur.bEnableSpineControl=true;
00533	        bFire=1;
00534	        bTire = true;
00535	        setTimer(plongeur.Temps_Acquisition,false);
00536	     }
00537	  }
00538	  function HalteAuFeu()
00539	  {
00540	      bTire = false;
00541	      bFire=0;
00542	      settimer(0,false);
00543	      //plongeur.bEnableSpineControl=false;
00544	      //plongeur.SetBoneDirection(plongeur.FIRINGBLENDBONE, rot(0,0,0), vect(0,0,0), 0.0 );
00545	  }
00546	
00547	  event Tick(float delta)
00548	  {
00549	      if ((Level.timeseconds-Timer_RefreshEnemyPos)>Temps_RefreshEnemyPos)
00550	       {
00551	           PersoTargetPos=xiii.location;
00552	           PersoTargetVelocity=xiii.velocity;
00553	           Timer_RefreshEnemyPos=level.timeseconds;
00554	       }
00555	  }
00556	
00557	  event Timer()         //tir
00558	  {
00559	    if (xiii.bisdead)
00560	    {
00561	        gotostate('attente');
00562	    }
00563	    if (!pawn.weapon.hasammo() || pawn.weapon==none) //passe aux points
00564	    {
00565	       log(" BIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIP PLUS DE MUNS CA MERDE");
00566	       return;
00567	    }
00568		 if (!bTempsPause)
00569		 {
00570	      settimer(0.4,false);
00571			plongeur.PlaySpearGunFiring();
00572		   bTempsPause=true;
00573			return;
00574		 }
00575		 else
00576			  bTempsPause=false;
00577	    /*if (vsize(xiii.location-pawn.location)>1200)
00578	    {
00579	    log("trop loin ne tir pas");
00580	       return;
00581	    } */
00582	    bFire=1;
00583	    pawn.weapon.fire(1.0);
00584		 bfire=0;
00585	    settimer(5,false);
00586	 }
00587	
00588	 function BeginState()
00589	 {
00590	     if (CHARGE_LES_LOGS) log(pawn@"ETAT Attaque");
00591	     //pawn.rotationrate.yaw=46000;
00592	     Timer_RefreshEnemyPos=level.timeseconds;
00593	     PersoTargetPos=xiii.location;
00594	     if (NiveauAlerte==0)
00595	     {
00596	        DecNbAttente();
00597	        IncNbAttaque();
00598	     }
00599	     else if (NiveauAlerte==1)
00600	     {
00601	        DecNbAlerte();
00602	        IncNbAttaque();
00603	     }
00604	     NiveauAlerte=2;
00605	 }
00606	 function EndState()
00607	 {
00608	     HalteAuFeu();
00609			settimer2(0,false);
00610	 }
00611	
00612	begin:
00613		enemy=xiii;
00614		focus=xiii;
00615		settimer2(1,true);
00616	tir:
00617	   sleep(0.5);
00618	   Fire_xiii();
00619	Positionnnement:
00620	   PosRelative=xiii.location-pawn.location;
00621	   if (Vsize(PosRelative)> plongeur.distanceattaque*1.2 || Vsize(PosRelative)< plongeur.distanceattaque*0.8)
00622	   {
00623	       PosRelative=(Vsize(PosRelative)-plongeur.distanceattaque)*normal(PosRelative);
00624	       if (PosRelative dot vector(pawn.rotation) <0)
00625	          MoveTo(PosRelative+pawn.location,xiii,0.3);
00626	       else
00627	          MoveTo(PosRelative+pawn.location,xiii,1);
00628	   }
00629	   sleep(1);
00630		WaitForLanding();
00631	   goto('positionnnement');
00632	}
00633	
00634	// ----------------------------------------------------------------------
00635	//Poursuite
00636	//
00637	//
00638	// ----------------------------------------------------------------------
00639	
00640	state Poursuite
00641	{
00642	ignores EnemyNotVisible;
00643	     event seeplayer(pawn seenplayer)
00644	     {
00645	        if (seenplayer==XIII && !xiii.bisdead)
00646	           gotostate('attaque');
00647	     }
00648	
00649	     function PickDestination()
00650	     {
00651	        local NavigationPoint path;
00652	        local actor HitActor;
00653	        local vector HitNormal, HitLocation, nextSpot, ViewSpot;
00654	        local float posZ;
00655	        local bool bCanSeeLastSeen;
00656	        local int i;
00657	
00658	       // If no xiii, or I should see him but don't, then give up
00659	        if (xiii.bisdead || (Level.TimeSeconds-LastSeenTime)>20)
00660	        {
00661	            gotostate('attente');
00662	            return;
00663	        }
00664	        if (actorreachable(XIII))
00665	        {
00666	             if ((numHuntPaths < 8) || (Level.TimeSeconds - LastSeenTime < 15)
00667	                    || ((Normal(xiii.Location - Pawn.Location) Dot vector(Pawn.Rotation)) > -0.5) )
00668	            {
00669	                 Destination = xiii.Location;
00670	                 MoveTarget = None;
00671	                 numHuntPaths++;
00672	            }
00673	            else
00674	            {
00675	                 gotostate('attente');
00676	            }
00677	            return;
00678	        }
00679	        numHuntPaths++;
00680	
00681	        ViewSpot = Pawn.Location + Pawn.BaseEyeHeight * vect(0,0,1);
00682	        bCanSeeLastSeen = false;
00683	        //fixemoi probleme de Poursuite sur etage different
00684	        bCanSeeLastSeen=(FastTrace(LastSeenPos, ViewSpot) && (abs(Lastseenpos.z-viewspot.z)<400));
00685	
00686	        MoveTarget = None;
00687	        if (FindBestPathToward(xiii,true))
00688	        {
00689	            if (CHARGE_LES_LOGS) log(pawn@"trouvereseau de Poursuite");
00690	            return;
00691	        }
00692	        if (NumHuntPaths > 60)
00693	        {
00694	             gotostate('attente');
00695	             return;
00696	        }
00697	        posZ = LastSeenPos.Z + Pawn.CollisionHeight - xiii.CollisionHeight;
00698	        nextSpot = LastSeenPos - Normal(xiii.Velocity) * Pawn.CollisionRadius;
00699	        nextSpot.Z = posZ;
00700	        hitactor=Trace(HitLocation, HitNormal, nextSpot, ViewSpot, false);
00701	        if ((( HitActor==none ) || (XIIIporte(hitactor)!=none)) && (abs(nextspot.z - viewspot.z) < 400))
00702	        {
00703	               Destination = nextSpot;
00704	        }
00705	        else if (bCanSeeLastSeen)
00706	             Destination = LastSeenPos;
00707	        else
00708	        {
00709	             Destination = LastSeenPos;
00710	             if ( !FastTrace(LastSeenPos, ViewSpot) )
00711	             {
00712	                   // check if could adjust and see it
00713	                  if (PickWallAdjust(Normal(LastSeenPos - ViewSpot)) || FindViewSpot())
00714	                  {
00715	                            GotoState('Poursuite', 'AdjustFromWall');
00716	                                   return;
00717	                  }
00718	                  else
00719	                  {
00720	                       if (CHARGE_LES_LOGS) log (pawn@"quitte vers patrouille");
00721	                       gotostate('attente');
00722	                       return;
00723	                  }
00724	             }
00725	        }
00726	        LastSeenPos = xiii.Location;
00727	     }
00728	
00729	    function bool FindViewSpot()
00730	    {
00731	          local vector X,Y,Z;
00732	          local bool bAlwaysTry;
00733	
00734	          GetAxes(Rotation,X,Y,Z);
00735	
00736	          // try left and right
00737	          // if frustrated, always move if possible
00738	          //bAlwaysTry = bFrustrated;
00739	          //bFrustrated = false;
00740	
00741	          if ( FastTrace(xiii.Location, Pawn.Location + 2 * Y * Pawn.CollisionRadius) )
00742	          {
00743	               Destination = Pawn.Location + 2.5 * Y * Pawn.CollisionRadius;
00744	               return true;
00745	          }
00746	          if ( FastTrace(xiii.Location, Pawn.Location - 2 * Y * Pawn.CollisionRadius) )
00747	          {
00748	               Destination = Pawn.Location - 2.5 * Y * Pawn.CollisionRadius;
00749	               return true;
00750	          }
00751	          return false;
00752	     }
00753	
00754	     function BeginState()
00755	     {
00756	          //pawn.rotationrate.yaw=46000;
00757	          if (CHARGE_LES_LOGS) log(pawn@"ETAT Poursuite");
00758	          if (NiveauAlerte==0)
00759	          {
00760	             DecNbAttente();
00761	             IncNbAlerte();
00762	          }
00763	          else if (NiveauAlerte==2)
00764	          {
00765	             DecNbAttaque();
00766	          }
00767	          NiveauAlerte=1;
00768	     }
00769	     function EndState()
00770	     {
00771					settimer2(0,false);
00772	     }
00773	
00774	AdjustFromWall:
00775	     if (CHARGE_LES_LOGS) log(pawn@"adjustfromwall");
00776	     MoveTo(Destination, MoveTarget);
00777	     Goto('suivre');
00778	
00779	Begin:
00780	     numHuntPaths = 0;
00781			settimer2(1,true);
00782	suivre:
00783		if (!XIII.PhysicsVolume.bWaterVolume) //si XIII plus dans l'eau remonte a la surface
00784		{
00785			/*if (Fasttrace(XIII.location))
00786			{
00787				Movetarget=XIII;
00788				bWaitToBeAtSurface=true;
00789			}
00790			else
00791			{  */
00792				gotostate('WaitForXIIIInWater');
00793			//}
00794		}
00795		if (CanSee(xiii))  // dans setenemy test sur actorReachable.
00796	         gotostate('attaque');
00797		PickDestination();
00798	SpecialNavig:
00799	   if (MoveTarget == None)
00800	   {
00801	      focus=none;
00802	      focalpoint=destination;
00803	      MoveTo(destination,none);
00804	   }
00805	   else
00806	   {
00807	      focus=none;
00808	      focalpoint=MoveTarget.location;
00809	      MoveToward(MoveTarget,none);
00810	   }
00811	   Goto('suivre');
00812	}
00813	
00814	
00815	
00816	defaultproperties
00817	{
00818	}

End Source Code