XIDCine
Class EscortManager

source: C:\XIII\XIDCine\Classes\EscortManager.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--XIDCine.EscortManager
Direct Known Subclasses:None

class EscortManager
extends Engine.Info

//--------------------------------------------------------------------------- // Specific class for XIII 'Prock01a' map, do not use somewhere else !!! //---------------------------------------------------------------------------
Variables
 Array Chemin
           le chemin des deux matons a parcourir
 Array CheminDoorPoints
           le chemin sp
 Actor CheminRepriseEscalier
           nombre de points de vie perdus par un coup de matraque
 Actor CheminStop
           point du chemin juste avant le couloir d intersection
 Actor ColCouloirEscorte
           mesh de col pour le couloir pendant l escorte
 Actor ColEscalierEscorte
           mesh de col pour l escalier pendant l escorte
 ControllerMaton1, ControllerMaton2
           nombre de points de vie perdus par un coup de matraque
 float DefaultWalkAnimVelocity
           nombre de points de vie perdus par un coup de matraque
 float DistanceMatons
           distance minimale entre les deux matons
 TimeStamp, EndTimePause
           nombre de points de vie perdus par un coup de matraque
 int IndexCheminReprise
           nombre de points de vie perdus par un coup de matraque
 Maton1Index, Maton2Index
           nombre de points de vie perdus par un coup de matraque
 Actor ObjetATraiter
           nombre de points de vie perdus par un coup de matraque
 Array ObjetsSansInteraction
           les objets avec interaction a retirer
 PawnMaton1, PawnMaton2
           les deux matons
 Pawn PlayerPawn
           nombre de points de vie perdus par un coup de matraque
 Actor PointAAtteindre
           nombre de points de vie perdus par un coup de matraque
 Porte PorteInit
           porte de la cellule
 VitesseMaton1, VitesseMaton2
           vitesse de d
 bool bAttendSonPote
           nombre de points de vie perdus par un coup de matraque
 bool bEscortingEscalierMaton2
           nombre de points de vie perdus par un coup de matraque
 bool bFinCheminMaton1
           nombre de points de vie perdus par un coup de matraque
 bool bOuvrePorte
           nombre de points de vie perdus par un coup de matraque
 bool bPasseUnePorte
           nombre de points de vie perdus par un coup de matraque
 bool bPauseEscalierMaton2
           nombre de points de vie perdus par un coup de matraque
 bPauseMaton1, bPauseMaton2
           nombre de points de vie perdus par un coup de matraque
 bool bTapeSurLaGueuleDeXIIIMaton1
           nombre de points de vie perdus par un coup de matraque
 bool bTapeSurLaGueuleDeXIIIMaton2
           nombre de points de vie perdus par un coup de matraque
 bool bXIIIDansEscalier
           nombre de points de vie perdus par un coup de matraque
 float fCollisionRadiusInitMaton1
           nombre de points de vie perdus par un coup de matraque
 float fCollisionRadiusInitMaton2
           nombre de points de vie perdus par un coup de matraque
 float fDecalageCentreMaton2
           nombre de points de vie perdus par un coup de matraque
 float fDecalageCentrePlayer
           nombre de points de vie perdus par un coup de matraque
 float fDecalageMax
           nombre de points de vie perdus par un coup de matraque
 float fDegatCoupDeMatraque
           nombre de points de vie perdus par un coup de matraque
 float fDistChemin1CentreMaton2
           nombre de points de vie perdus par un coup de matraque
 float fDistChemin1CentrePlayer
           nombre de points de vie perdus par un coup de matraque
 float fTempsMatraquage
           nombre de points de vie perdus par un coup de matraque
 int i
           nombre de points de vie perdus par un coup de matraque
 vector vDirCentralMaton2_Chemin2
           nombre de points de vie perdus par un coup de matraque
 vector vDirChemin1_Chemin2
           nombre de points de vie perdus par un coup de matraque
 vector vDirChemin1_Maton2
           nombre de points de vie perdus par un coup de matraque
 vector vDirChemin1_Player
           nombre de points de vie perdus par un coup de matraque
 vector vDirChemin2_Player
           nombre de points de vie perdus par un coup de matraque
 vector vDirMaton1_Chemin2
           nombre de points de vie perdus par un coup de matraque
 vector vDirMaton1_Maton2
           nombre de points de vie perdus par un coup de matraque
 vector vDirMaton1_Player
           nombre de points de vie perdus par un coup de matraque
 vector vDirMaton2_Chemin2
           nombre de points de vie perdus par un coup de matraque
 vector vDirMatraquage
           nombre de points de vie perdus par un coup de matraque
 vector vDirPlayer_Chemin2
           nombre de points de vie perdus par un coup de matraque
 vector vOrthogonalChemin
           nombre de points de vie perdus par un coup de matraque
 vector vPosCentralMaton2
           nombre de points de vie perdus par un coup de matraque
 vector vPosCentralPlayer
           nombre de points de vie perdus par un coup de matraque
 vector vPosChemin1
           nombre de points de vie perdus par un coup de matraque
 vector vPosChemin2
           nombre de points de vie perdus par un coup de matraque
 vector vPosMaton2
           nombre de points de vie perdus par un coup de matraque
 vector vPosPlayer
           nombre de points de vie perdus par un coup de matraque

States
STA_EndOfEscort, STA_EscortingEscalier, STA_AttenteEscalier, STA_AttenteCouloir, STA_Matraquage, STA_Escorting, STA_DebutEscorte

Function Summary
 void AjusteVitesseMaton2(float dt)
     
//_____________________________________________________________________________
 void FirstKeeperBehavior(float dt)
     
//_____________________________________________________________________________
 void TestMatraquageMaton2()
     
//_____________________________________________________________________________
 void TestXIIIDansEscalier()
     
//_____________________________________________________________________________


State STA_EndOfEscort Function Summary


State STA_EscortingEscalier Function Summary


State STA_AttenteEscalier Function Summary


State STA_AttenteCouloir Function Summary


State STA_Matraquage Function Summary


State STA_Escorting Function Summary


State STA_DebutEscorte Function Summary



Source Code


00001	//---------------------------------------------------------------------------
00002	// Specific class for XIII 'Prock01a' map, do not use somewhere else !!!
00003	//---------------------------------------------------------------------------
00004	class EscortManager extends Info
00005		placeable;
00006	
00007	//--- variables designer ---
00008	var() Cine2 PawnMaton1, PawnMaton2;			// les deux matons
00009	var() Array<Actor> Chemin;					// le chemin des deux matons a parcourir
00010	var() Array<Actor> CheminDoorPoints;		// le chemin spécifique des portes a ouvrir
00011	var() Array<Actor> ObjetsSansInteraction;	// les objets avec interaction a retirer
00012	var() float DistanceMatons;					// distance minimale entre les deux matons
00013	var() float VitesseMaton1, VitesseMaton2;	// vitesse de déplacement des deux matons
00014	var() Porte PorteInit;						// porte de la cellule
00015	var() Actor CheminStop;						// point du chemin juste avant le couloir d intersection
00016	var() Actor ColCouloirEscorte;				// mesh de col pour le couloir pendant l escorte
00017	var() Actor ColEscalierEscorte;				// mesh de col pour l escalier pendant l escorte
00018	var() float fDegatCoupDeMatraque;			// nombre de points de vie perdus par un coup de matraque
00019	
00020	//--- variables internes ---
00021	var transient CineController2 ControllerMaton1, ControllerMaton2;
00022	var transient int Maton1Index, Maton2Index;
00023	var transient float TimeStamp, EndTimePause;
00024	var transient Pawn PlayerPawn;
00025	var int i;
00026	var int IndexCheminReprise;
00027	var vector vPosPlayer;
00028	var vector vPosChemin1;
00029	var vector vPosChemin2;
00030	var vector vPosMaton2;
00031	var vector vPosCentralPlayer;
00032	var vector vPosCentralMaton2;
00033	var vector vOrthogonalChemin;
00034	var vector vDirChemin1_Chemin2;
00035	var vector vDirChemin1_Player;
00036	var vector vDirChemin1_Maton2;
00037	var vector vDirCentralMaton2_Chemin2;
00038	var vector vDirMaton1_Chemin2;
00039	var vector vDirMaton2_Chemin2;
00040	var vector vDirPlayer_Chemin2;
00041	var vector vDirChemin2_Player;
00042	var vector vDirMaton1_Maton2;
00043	var vector vDirMaton1_Player;
00044	var vector vDirMatraquage;
00045	var float fDistChemin1CentrePlayer;
00046	var float fDistChemin1CentreMaton2;
00047	var float fDecalageCentrePlayer;
00048	var float fDecalageCentreMaton2;
00049	var float fDecalageMax;
00050	var float fTempsMatraquage;
00051	var float fCollisionRadiusInitMaton1;
00052	var float fCollisionRadiusInitMaton2;
00053	var float DefaultWalkAnimVelocity;
00054	var bool bPauseMaton1, bPauseMaton2;
00055	var bool bPauseEscalierMaton2;
00056	var bool bTapeSurLaGueuleDeXIIIMaton1;
00057	var bool bTapeSurLaGueuleDeXIIIMaton2;
00058	var bool bOuvrePorte;
00059	var bool bPasseUnePorte;
00060	var bool bAttendSonPote;
00061	var bool bFinCheminMaton1;
00062	var bool bEscortingEscalierMaton2;
00063	var bool bXIIIDansEscalier;
00064	var Actor ObjetATraiter;
00065	var Actor PointAAtteindre;
00066	var Actor CheminRepriseEscalier;
00067	
00068	
00069	//_____________________________________________________________________________
00070	event Trigger(actor Other,Pawn EventInstigator)
00071	{
00072	
00073		foreach RadiusActors( class'Porte',PorteInit,256,PawnMaton2.Location)
00074		{
00075			Log( "PorteInit"@PorteInit );
00076			break;
00077		}
00078		// WakeUp
00079		ControllerMaton1=PawnMaton1.CineController;
00080		ControllerMaton2=PawnMaton2.CineController;
00081		ControllerMaton1.CineMoveTo(Chemin[Maton1Index]);
00082		ControllerMaton1.MoveSequence="";
00083		ControllerMaton2.MoveSequence="";
00084		PawnMaton1.WalkAnim='matrak3';
00085		PawnMaton2.WalkAnim='marchematrakhand';
00086		PawnMaton1.WaitAnim='waitmatrak';
00087		PawnMaton2.WaitAnim='waitmatrak';
00088		PlayerPawn=PawnMaton1.PC.Pawn;
00089		PawnMaton1.bPauseMovementIfBumped=false;
00090		PawnMaton2.bPauseMovementIfBumped=false;
00091		PawnMaton1.ImposedEndMovePosition=false;
00092		PawnMaton2.ImposedEndMovePosition=false;
00093		PawnMaton1.bInteractive = false;
00094		PawnMaton2.bInteractive = false;
00095		// on agrandit legerement la zone de collision des matons
00096		fCollisionRadiusInitMaton1 = PawnMaton1.CollisionRadius;
00097		fCollisionRadiusInitMaton2 = PawnMaton2.CollisionRadius;
00098		// on supprime l interaction avec tous les objets du tableau
00099		for (i=0;i<ObjetsSansInteraction.Length;i++)
00100		{
00101			ObjetATraiter = ObjetsSansInteraction[i];
00102			if ( ObjetATraiter.IsA('Porte') )
00103				Porte(ObjetATraiter).bNoInteractionIcon = true;
00104			else
00105				log(self@" ---> OBJET NON TRAITABLE !!");
00106		}
00107		// init donnees diverses
00108		Maton1Index = 0;
00109		Maton2Index = 0;
00110	
00111	
00112	
00113		vPosChemin1 = PawnMaton2.Location;
00114		vPosChemin2 = Chemin[0].Location;
00115		PointAAtteindre = Chemin[0];
00116		for (i=0;i<Chemin.Length;i++)
00117		{
00118			if (CheminStop == Chemin[i])
00119			{
00120				IndexCheminReprise = i + 3;
00121				CheminRepriseEscalier = Chemin[IndexCheminReprise];
00122			}
00123		}
00124		GotoState('STA_DebutEscorte');
00125	}
00126	
00127	
00128	//_____________________________________________________________________________
00129	function FirstKeeperBehavior(float dt)
00130	{
00131		if (bPauseMaton1)
00132		{
00133			// le premier maton s arrete
00134			// 1 -> pour attendre son pote
00135			// 2 -> pour ouvrir une porte
00136			// 3 -> pour frapper le joueur
00137	
00138			if ( bAttendSonPote )
00139			{
00140				//log(PawnMaton1@"---> ATTEND SON POTE");
00141				vDirMaton1_Maton2 = PawnMaton1.Location - PawnMaton2.Location;
00142				vDirMaton1_Maton2.z = 0;
00143				if ( vSize(vDirMaton1_Maton2) < 1.05*DistanceMatons )
00144				{
00145					bAttendSonPote = false;
00146					bPauseMaton1 = false;
00147					ControllerMaton1.Focus = PointAAtteindre;
00148					ControllerMaton1.CineMoveTo(PointAAtteindre);
00149				}
00150			}
00151			else
00152			{
00153				if ( bOuvrePorte )
00154				{
00155					//log(PawnMaton1@"---> OUVRE PORTE");
00156					if ( TimeStamp > EndTimePause )
00157					{
00158						//log(PawnMaton1@"---> FIN PAUSE : OUVERTURE PORTE"@Maton1Index@Chemin[Maton1Index - 1]@Porte(Chemin[Maton1Index - 1]));
00159						PawnMaton1.OpenDoor(Porte(Chemin[Maton1Index - 1]));
00160						bPauseMaton1 = false;
00161						bOuvrePorte = false;
00162						ControllerMaton1.Focus = PointAAtteindre;
00163						ControllerMaton1.CineMoveTo(PointAAtteindre);
00164					}
00165				}
00166				else
00167				{
00168					//log(PawnMaton1@"---> FRAPPE LE JOUEUR");
00169					fTempsMatraquage += dt;
00170					if ( bTapeSurLaGueuleDeXIIIMaton1 )
00171					{
00172						if ( fTempsMatraquage > 0.7 )
00173						{
00174							//log(self@"--> FIN COUP DE MATRAQUE");
00175							PlayerPawn.SpeedFactorLimit = 1.0;
00176							bPauseMaton1 = false;
00177							bTapeSurLaGueuleDeXIIIMaton1 = false;
00178							ControllerMaton1.Focus = PointAAtteindre;
00179							ControllerMaton1.CineMoveTo(PointAAtteindre);
00180						}
00181					}
00182					else
00183					{
00184						if ( fTempsMatraquage > 0.35 )
00185						{
00186							bTapeSurLaGueuleDeXIIIMaton1 = true;
00187							// on calcule le vecteur d ejection
00188							if ( !bXIIIDansEscalier )
00189							{
00190								// la direction de matraquage est perpendiculaire au chemin
00191								vDirMatraquage.x = - vDirMaton1_Chemin2.y;
00192								vDirMatraquage.y = vDirMaton1_Chemin2.x;
00193								vDirMatraquage.z = 0;
00194							}
00195							else
00196							{
00197								// la direction de matraquage se fait dans le sens du chemin
00198								vDirMatraquage = - vDirMaton1_Chemin2;
00199								vDirMatraquage.z = 0;
00200							}
00201	
00202							// dommages constants quelque soit la difficulte choisie = x pts par coup de matraque
00203							PlayerPawn.TakeDamage(fDegatCoupDeMatraque*1.5/((1+Level.Game.Difficulty)*0.15+Level.AdjustDifficulty/100), PawnMaton2, Location, vect(0,0,0), Class'XIII.DTFisted');
00204							PlayerPawn.AddVelocity(Normal(vDirMatraquage)*1500);
00205							PlayerPawn.SpeedFactorLimit = 0.0;
00206						}
00207					}
00208				}
00209			}
00210		}
00211		else
00212		{
00213			// dans un premier temps, on teste la distance entre les deux matons
00214			vDirMaton1_Maton2 = PawnMaton1.Location - PawnMaton2.Location;
00215			vDirMaton1_Maton2.z = 0;
00216			if ( vSize(vDirMaton1_Maton2) > 1.25*DistanceMatons )
00217			{
00218				// la distance est trop grande, le premier maton attend
00219				bPauseMaton1 = true;
00220				bAttendSonPote = true;
00221				ControllerMaton1.StopMove();
00222				ControllerMaton1.PlayAni(PawnMaton1.WaitAnim);
00223				PawnMaton1.PlayAnim(ControllerMaton1.CurrentAnim,2.0,0.1);
00224			}
00225			else
00226			{
00227				// le premier maton continue son chemin
00228				if ( !bFinCheminMaton1 )
00229				{
00230					// le joueur gene-t-il la progression du premier gardien ?
00231					vDirMaton1_Chemin2 = PawnMaton1.Location - PointAAtteindre.Location;
00232					vDirMaton1_Player = PawnMaton1.Location - PlayerPawn.Location;
00233					vDirMaton1_Chemin2.z = 0;
00234					vDirMaton1_Player.z = 0;
00235					if (/*( !bXIIIDansEscalier ) &&*/ ( PawnMaton1.Collide(PlayerPawn) ) && ( (vDirMaton1_Chemin2 dot vDirMaton1_Player) > 0 ))
00236					{
00237						// on tape sur le joueur
00238						bPauseMaton1 = true;
00239						//bTapeSurLaGueuleDeXIIIMaton1 = true;
00240						ControllerMaton1.StopMove();
00241						ControllerMaton1.Focus = PlayerPawn;
00242						ControllerMaton1.PlayAni('matrak4',3.0,0.1);
00243						PawnMaton1.PlayAnim(ControllerMaton1.CurrentAnim,3.0,0.1);
00244						PawnMaton1.BumpedActor=none;
00245						fTempsMatraquage = 0;
00246					}
00247					else
00248					{
00249						//vDirMaton1_Chemin2 = PawnMaton1.Location - PointAAtteindre.Location;
00250						//vDirMaton1_Chemin2.z = 0;
00251						// on regarde si il a atteint le prochain point de son chemin
00252						if ( vSize(vDirMaton1_Chemin2) < 5)
00253						{
00254							/*// pour eviter que le joueur passe devant dans l escalier, on agrandit sa zone de collision
00255							if ( Maton1Index == IndexCheminReprise )
00256							{
00257								PawnMaton1.SetCollisionSize( PawnMaton1.CollisionRadius*1.50, PawnMaton1.CollisionHeight );
00258							}
00259							else
00260							{
00261								if ( Maton1Index == (IndexCheminReprise + 1) )
00262								{
00263									PawnMaton1.SetCollisionSize( fCollisionRadiusInitMaton1, PawnMaton1.CollisionHeight );
00264								}
00265							}*/
00266	
00267							Maton1Index ++;
00268							if (Maton1Index < Chemin.Length)
00269							{
00270								if (Chemin[Maton1Index].IsA('Porte'))
00271								{
00272									//EndTimePause = TimeStamp + 0.7;
00273									// on ouvre la porte avant la fin de l anim
00274									EndTimePause = TimeStamp + 0.4;
00275									//*** si la porte est deja ouverte, pas besoin de l ouvrir a nouveau
00276									if ( Porte(Chemin[Maton1Index]).KeyNum == 0 )
00277									{
00278										log(PawnMaton1@"---> PORTE A OUVRIR"@Maton1Index@Chemin[Maton1Index]);
00279										bPauseMaton1 = true;
00280										bOuvrePorte = true;
00281										ControllerMaton1.StopMove();
00282										ControllerMaton1.PlayAni('opendoor');
00283										PawnMaton1.PlayAnim(ControllerMaton1.CurrentAnim,2.0,0.1);
00284										Maton1Index ++;
00285										PointAAtteindre = Chemin[Maton1Index];
00286										ControllerMaton1.Focus=PointAAtteindre;
00287									}
00288									else
00289									{
00290										Maton1Index ++;
00291										PointAAtteindre = Chemin[Maton1Index];
00292										ControllerMaton1.Focus=PointAAtteindre;
00293										ControllerMaton1.CineMoveTo(PointAAtteindre);
00294									}
00295								}
00296								else
00297								{
00298									// je regarde si un doorpoint peut remplacer le point a atteindre
00299									if ( CheminDoorPoints[Maton1Index] != none )
00300										PointAAtteindre = CheminDoorPoints[Maton1Index];
00301									else
00302										PointAAtteindre = Chemin[Maton1Index];
00303									ControllerMaton1.Focus = PointAAtteindre;
00304									ControllerMaton1.CineMoveTo(PointAAtteindre);
00305								}
00306							}
00307							else
00308							{
00309								// le maton est au bout de son chemin
00310								ControllerMaton1.StopMove();
00311								bFinCheminMaton1 = true;
00312							}
00313						}
00314					}
00315				}
00316			}
00317		}
00318	}
00319	
00320	
00321	//_____________________________________________________________________________
00322	function TestMatraquageMaton2()
00323	{
00324		// en cas de collision avec le joueur, on file un coup de matraque
00325		//if (PawnMaton2.Collide(PlayerPawn))
00326		//	GotoState('STA_Matraquage');
00327	
00328		// autre methode
00329		//vPosPlayer = PlayerPawn.Location;
00330		//vPosMaton2 = PawnMaton2.Location;
00331		//vDirChemin1_Chemin2 = vPosChemin2 - vPosChemin1;
00332		//vDirChemin1_Player = vPosPlayer - vPosChemin1;
00333		//vDirChemin1_Maton2 = vPosMaton2 - vPosChemin1;
00334		//vDirChemin1_Chemin2.z = 0;
00335		//vDirChemin1_Player.z = 0;
00336		//vDirChemin1_Maton2.z = 0;
00337		// calcul des distances par rapport a l axe Chemin1-Chemin2
00338		//fDistChemin1CentrePlayer = (vDirChemin1_Chemin2 dot vDirChemin1_Player)/vSize(vDirChemin1_Chemin2);
00339		//vPosCentralPlayer = vPosChemin1 + Normal(vDirChemin1_Chemin2)*fDistChemin1CentrePlayer;
00340		//vPosCentralPlayer.z = 0;
00341		//fDistChemin1CentreMaton2 = (vDirChemin1_Chemin2 dot vDirChemin1_Maton2)/vSize(vDirChemin1_Chemin2);
00342		//vPosCentralMaton2 = vPosChemin1 + Normal(vDirChemin1_Chemin2)*fDistChemin1CentreMaton2;
00343		//vPosCentralMaton2.z = 0;
00344		//if ( vSize(vPosCentralPlayer - vPosCentralMaton2) < 80)
00345		//{
00346		//	GotoState('STA_Matraquage');
00347		//}
00348	
00349		// troisieme methode
00350		vPosPlayer = PlayerPawn.Location;
00351		vPosMaton2 = PawnMaton2.Location;
00352		vPosPlayer.z = 0;
00353		vPosMaton2.z = 0;
00354		if ( vSize(vPosPlayer - vPosMaton2) < 130)
00355			GotoState('STA_Matraquage');
00356	}
00357	
00358	
00359	//_____________________________________________________________________________
00360	function AjusteVitesseMaton2( float dt )
00361	{
00362		vDirMaton1_Maton2 = PawnMaton1.Location - PawnMaton2.Location;
00363		vDirMaton1_Maton2.z = 0;
00364		// si l ecart est vraiment petit, on stoppe le second maton
00365		// attention : dans l escalier et le couloir etroit, l ecart est consideree tres petit
00366		if ( (( !bXIIIDansEscalier ) && ( vSize(vDirMaton1_Maton2) < 0.75*DistanceMatons ))
00367			|| (( bXIIIDansEscalier ) && ( vSize(vDirMaton1_Maton2) < 0.25*DistanceMatons )) )
00368		{
00369			GotoState('STA_AttenteCouloir');
00370		}
00371		else
00372		{
00373			// si le second maton est proche du premier, on diminue sa vitesse de deplacement
00374			if ( vSize(vDirMaton1_Maton2) < 0.95*DistanceMatons )
00375			{
00376				VitesseMaton2 = fClamp(VitesseMaton2 - 0.01*dt,0.3,0.33);
00377				ControllerMaton2.WantedSpeed = VitesseMaton2;
00378				//log(PawnMaton2@"---> AJUSTE VITESSE RALENTIE V="$VitesseMaton2@"dt="$dt);
00379			}
00380			else
00381			{
00382				// a distance normale, on retablit la vitesse du maton 2 à sa valeur initiale
00383				if ( vSize(vDirMaton1_Maton2) > DistanceMatons )
00384				{
00385					VitesseMaton2 = fClamp(VitesseMaton2 + 0.01*dt,0.3,0.33);
00386					ControllerMaton2.WantedSpeed = VitesseMaton2;
00387					//log(PawnMaton2@"---> AJUSTE VITESSE VERS NORMALE V="$VitesseMaton2@"dt="$dt);
00388				}
00389			}
00390		}
00391	}
00392	
00393	
00394	//_____________________________________________________________________________
00395	function TestXIIIDansEscalier()
00396	{
00397		// on regarde si XIII est dans l escalier
00398		// cela permet d adapter le comportement du maton1
00399		// differemment selon les lieux (couloir large et escalier etroit)
00400		if ( !bXIIIDansEscalier )
00401		{
00402			vDirChemin1_Chemin2 = CheminRepriseEscalier.Location - CheminStop.Location;
00403			vDirChemin2_Player = PlayerPawn.Location - CheminRepriseEscalier.Location;
00404			vDirChemin1_Chemin2.z = 0;
00405			vDirChemin2_Player.z = 0;
00406			if ( (vDirChemin1_Chemin2 dot vDirChemin2_Player) > 0 && Vsize(vDirChemin2_Player)>400)
00407			{
00408				bXIIIDansEscalier = true;
00409			}
00410		}
00411	}
00412	
00413	//_____________________________________________________________________________
00414	STATE STA_DebutEscorte
00415	{
00416		EVENT BeginState()
00417		{
00418			ControllerMaton2.RotationSpeed = 90;
00419			ControllerMaton2.LockedActor = self;
00420			PawnMaton2.PeeredActor = PlayerPawn;
00421			SetLocation( PawnMaton1.Location - 50*NORMAL( ( PawnMaton1.Location - PawnMaton2.Location) cross vect(0,0,1) )  );
00422		}
00423	
00424		EVENT Tick(float dt)
00425		{
00426			LOCAL VECTOR vDirMaton2_Player;
00427	
00428			// comportement du premier maton
00429			FirstKeeperBehavior(dt);
00430	
00431			// on teste la distance entre les deux matons pour faire demarrer le second
00432			vDirMaton1_Maton2 = PawnMaton1.Location - PawnMaton2.Location;
00433			vDirMaton1_Player = PlayerPawn.Location - PawnMaton1.Location;
00434			vDirMaton2_Player = PlayerPawn.Location - PawnMaton2.Location;
00435	
00436			if ( vSize(vDirMaton1_Maton2) > 0.85*DistanceMatons && vSize(vDirMaton1_Player) < 0.35*DistanceMatons )
00437			{
00438	//		   log( "..."@PorteInit.Name@"is in state"@PorteInit.GetStateName() );
00439	//			PawnMaton2.UnlockDoor(PorteInit);
00440	//			log( "now"@PorteInit.Name@"is in state"@PorteInit.GetStateName() );
00441				PorteInit.MoveTime=0.5;
00442				PorteInit.SetCollision(false,false,false);
00443				PawnMaton2.CloseDoor(PorteInit);
00444	//			LOG ( "FERMETURE PORTE"@PorteInit );
00445	//			if ( PorteInit!=none && !PorteInit.bClosed )
00446	//				PorteInit.PlayerTrigger(self,self);
00447				PawnMaton2.PeeredActor = none;
00448				GotoState('STA_Escorting');
00449			}
00450		}
00451	}
00452	
00453	
00454	//_____________________________________________________________________________
00455	STATE STA_Escorting
00456	{
00457		EVENT BeginState()
00458		{
00459			Log("ENTER : STA_Escorting");
00460			ControllerMaton1.RotationSpeed=359;
00461			ControllerMaton2.RotationSpeed=359;
00462			//VitesseEscorte=0.1;
00463			ControllerMaton1.WantedSpeed=VitesseMaton1;
00464			//VitesseEscorte=0.1;
00465			ControllerMaton2.WantedSpeed=VitesseMaton2;
00466			ControllerMaton1.AccelerationFactor=1.0;
00467			ControllerMaton2.AccelerationFactor=1.0;
00468			ControllerMaton2.LockedActor=PlayerPawn;
00469		}
00470	
00471		EVENT Tick(float dt)
00472		{
00473	
00474			TimeStamp+=dt;
00475	
00476			// comportement du premier maton
00477			FirstKeeperBehavior(dt);
00478	
00479			// ajustement de la vitesse du second maton
00480			AjusteVitesseMaton2(dt);
00481	
00482			// test si XIII commence a descendre l escalier
00483			TestXIIIDansEscalier();
00484	
00485			// comportement du second maton
00486			// on cherche toujours a bloquer le joueur dans le couloir
00487			// un leger deplacement a gauche ou a droite devrait suffire
00488	
00489			// on regarde si on change de section de chemin
00490			vDirCentralMaton2_Chemin2 = vPosCentralMaton2 - vPosChemin2;
00491			vDirCentralMaton2_Chemin2.z = 0;
00492			if ( vSize(vDirCentralMaton2_Chemin2) < 5)
00493			{
00494				log(self@"---> POINT ATTEINT"@Chemin[Maton2Index]);
00495				// on traite le cas particulier a l entree des escaliers
00496				if (Chemin[Maton2Index] == CheminStop)
00497				{
00498					ControllerMaton2.StopMove();
00499					ControllerMaton2.LockedActor=none;
00500					GotoState('STA_AttenteEscalier');
00501					return;
00502				}
00503	
00504				Maton2Index ++;
00505	
00506	
00507				// le second maton s arrete juste avant la fin du chemin
00508				if (Maton2Index == (Chemin.Length - 2))
00509				{
00510					GotoState('STA_EndOfEscort');
00511					return;
00512				}
00513	
00514	
00515				// on gere les portes differemment
00516				if ( bPasseUnePorte )
00517				{
00518					// on regarde si on vient de passer une porte
00519					if ( Chemin[Maton2Index - 2].IsA('Porte') )
00520					{
00521						bPasseUnePorte = false;
00522						vPosChemin1 = Chemin[Maton2Index - 1].Location;
00523						vPosChemin2 = Chemin[Maton2Index].Location;
00524					}
00525				}
00526				else
00527				{
00528					// on prend en compte les portes pour le point suivant du chemin
00529					if ( Chemin[Maton2Index].IsA('Porte') )
00530					{
00531						Maton2Index ++;
00532						vPosChemin1 = Chemin[Maton2Index - 2].Location;
00533						vPosChemin2 = Chemin[Maton2Index].Location;
00534						// le passage d'une porte est problematique, il faut recentrer le maton2
00535						bPasseUnePorte = true;
00536						log(self@"---> PASSE UNE PORTE"@Chemin[Maton2Index - 2]@Chemin[Maton2Index]);
00537					}
00538					else
00539					{
00540						vPosChemin1 = Chemin[Maton2Index - 1].Location;
00541						vPosChemin2 = Chemin[Maton2Index].Location;
00542						log(self@"---> CONTINUE SON CHEMIN"@Chemin[Maton2Index - 1]@Chemin[Maton2Index]);
00543					}
00544				}
00545			}
00546			// calcul des positions et des directions
00547			vPosPlayer = PlayerPawn.Location;
00548			vPosMaton2 = PawnMaton2.Location;
00549			vDirChemin1_Chemin2 = vPosChemin2 - vPosChemin1;
00550			vDirChemin1_Player = vPosPlayer - vPosChemin1;
00551			vDirChemin1_Maton2 = vPosMaton2 - vPosChemin1;
00552			vDirChemin1_Chemin2.z = 0;
00553			vDirChemin1_Player.z = 0;
00554			vDirChemin1_Maton2.z = 0;
00555			// calcul des distances par rapport a l axe Chemin1-Chemin2
00556			fDistChemin1CentrePlayer = (vDirChemin1_Chemin2 dot vDirChemin1_Player)/vSize(vDirChemin1_Chemin2);
00557			vPosCentralPlayer = vPosChemin1 + Normal(vDirChemin1_Chemin2)*fDistChemin1CentrePlayer;
00558			vPosCentralPlayer.z = vPosPlayer.z;
00559			fDistChemin1CentreMaton2 = (vDirChemin1_Chemin2 dot vDirChemin1_Maton2)/vSize(vDirChemin1_Chemin2);
00560			vPosCentralMaton2 = vPosChemin1 + Normal(vDirChemin1_Chemin2)*fDistChemin1CentreMaton2;
00561			fDecalageCentrePlayer = vSize(vPosPlayer - vPosCentralPlayer);
00562			vOrthogonalChemin = Normal(vPosPlayer - vPosCentralPlayer);
00563			vOrthogonalChemin.z = 0;
00564			// pour passer les portes, on reajuste le decalage max autorisable pour le maton2
00565			if ( bPasseUnePorte )
00566				fDecalageMax = 0;
00567			else
00568				fDecalageMax = 50;
00569			fDecalageCentreMaton2 = FMin(fDecalageCentrePlayer,fDecalageMax);
00570			SetLocation(vPosCentralMaton2 + fDecalageCentreMaton2*vOrthogonalChemin + Normal(vDirChemin1_Chemin2)*40);
00571			ControllerMaton2.CineMoveTo(self);
00572			//log(self@"---> DECALAGE MAX ="@fDecalageMax);
00573	
00574			// en cas de collision avec le joueur, on file un coup de matraque
00575			TestMatraquageMaton2();
00576		}
00577	begin:
00578		sleep(0.6);
00579		PorteInit.SetCollision(true,true,true);
00580	
00581	}
00582	
00583	
00584	//_____________________________________________________________________________
00585	STATE STA_Matraquage
00586	{
00587		EVENT BeginState()
00588		{
00589			Log("ENTER : STA_Matraquage");
00590	
00591			ControllerMaton2.StopMove();
00592			ControllerMaton2.Focus = PlayerPawn;
00593			ControllerMaton2.PlayAni('matrak4',3.0,0.1);
00594			//PawnMaton2.PlayAnim(ControllerMaton2.CurrentAnim,3.0,0.1);
00595			PawnMaton2.BumpedActor=none;
00596			bTapeSurLaGueuleDeXIIIMaton2 = false;
00597			fTempsMatraquage = 0;
00598		}
00599	
00600		EVENT Tick( float dt )
00601		{
00602	
00603			TimeStamp+=dt;
00604	
00605			// comportement du premier maton
00606			FirstKeeperBehavior(dt);
00607	
00608			// test si XIII commence a descendre l escalier
00609			TestXIIIDansEscalier();
00610	
00611			// comportement du secon maton qui donne un coup de matraque au joueur
00612			fTempsMatraquage += dt;
00613	
00614			if ( bTapeSurLaGueuleDeXIIIMaton2 )
00615			{
00616				if ( fTempsMatraquage > 0.7 )
00617				{
00618					//log(self@"--> FIN COUP DE MATRAQUE");
00619					PlayerPawn.SpeedFactorLimit = 1.0;
00620					if ( bPauseMaton2 )
00621					{
00622						if ( bPauseEscalierMaton2 )
00623							GotoState('STA_AttenteEscalier');
00624						else
00625							GotoState('STA_AttenteCouloir');
00626					}
00627					else
00628					{
00629						if ( bEscortingEscalierMaton2 )
00630							GotoState('STA_EscortingEscalier');
00631						else
00632							GotoState('STA_Escorting');
00633					}
00634				}
00635			}
00636			else
00637			{
00638				if ( fTempsMatraquage > 0.35 )
00639				{
00640					bTapeSurLaGueuleDeXIIIMaton2 = true;
00641					vDirChemin1_Chemin2 = vPosChemin2 - vPosChemin1;
00642					vDirChemin1_Chemin2.z = 0;
00643					// dommages constants quelque soit la difficulte choisie = x pts par coup de matraque
00644					PlayerPawn.TakeDamage(fDegatCoupDeMatraque*1.5/((1+Level.Game.Difficulty)*0.15+Level.AdjustDifficulty/100), PawnMaton2, Location, vect(0,0,0), Class'XIII.DTFisted');
00645					//PlayerPawn.AddVelocity(Normal(vDirChemin1_Chemin2)*1500);
00646					PlayerPawn.AddVelocity(Normal(vDirChemin1_Chemin2)*2200);
00647					PlayerPawn.SpeedFactorLimit = 0.0;
00648				}
00649			}
00650		}
00651	}
00652	
00653	
00654	//_____________________________________________________________________________
00655	STATE STA_AttenteCouloir
00656	{
00657		EVENT BeginState()
00658		{
00659			Log("ENTER : STA_AttenteCouloir");
00660	
00661			PawnMaton2.WaitAnim='waitmatrak';
00662			PawnMaton2.WalkAnim='marchematrakhand';
00663			DefaultWalkAnimVelocity = PawnMaton2.WalkAnimVelocity;
00664			PawnMaton2.WalkAnimVelocity = 140;
00665			ControllerMaton2.WantedSpeed=0.45;
00666			bPauseMaton2 = true;
00667		}
00668	
00669		EVENT Tick( float dt )
00670		{
00671			local vector vPos1, vPos2, vPos3, vPosStrafe, vPosStrafeOld;
00672	
00673			TimeStamp+=dt;
00674	
00675			ControllerMaton2.LockedActor = PlayerPawn;
00676			ControllerMaton2.Focus = PlayerPawn;
00677			//ControllerMaton2.PlayAni('StrafeD');
00678	
00679			// comportement du premier maton
00680			FirstKeeperBehavior(dt);
00681	
00682			// comportement du second maton
00683			TestMatraquageMaton2();
00684	
00685			// test si XIII commence a descendre l escalier
00686			TestXIIIDansEscalier();
00687	
00688			// calcul des positions et des directions
00689			vPosPlayer = PlayerPawn.Location;
00690			vPosMaton2 = PawnMaton2.Location;
00691			vDirChemin1_Chemin2 = vPosChemin2 - vPosChemin1;
00692			vDirChemin1_Player = vPosPlayer - vPosChemin1;
00693			vDirChemin1_Maton2 = vPosMaton2 - vPosChemin1;
00694			vDirChemin1_Chemin2.z = 0;
00695			vDirChemin1_Player.z = 0;
00696			vDirChemin1_Maton2.z = 0;
00697			// calcul des distances par rapport a l axe Chemin1-Chemin2
00698			fDistChemin1CentrePlayer = (vDirChemin1_Chemin2 dot vDirChemin1_Player)/vSize(vDirChemin1_Chemin2);
00699			vPosCentralPlayer = vPosChemin1 + Normal(vDirChemin1_Chemin2)*fDistChemin1CentrePlayer;
00700			vPosCentralPlayer.z = vPosPlayer.z;
00701			fDistChemin1CentreMaton2 = (vDirChemin1_Chemin2 dot vDirChemin1_Maton2)/vSize(vDirChemin1_Chemin2);
00702			vPosCentralMaton2 = vPosChemin1 + Normal(vDirChemin1_Chemin2)*fDistChemin1CentreMaton2;
00703			fDecalageCentrePlayer = vSize(vPosPlayer - vPosCentralPlayer);
00704			vOrthogonalChemin = Normal(vPosPlayer - vPosCentralPlayer);
00705			vOrthogonalChemin.z = 0;
00706			fDecalageCentreMaton2 = FMin(fDecalageCentrePlayer,50);
00707			SetLocation(vPosCentralMaton2 + fDecalageCentreMaton2*vOrthogonalChemin);
00708			ControllerMaton2.CineMoveTo(self,true);
00709	
00710			// on regarde si l ecart entre les deux matons est redevenu normal
00711			vDirMaton1_Maton2 = PawnMaton1.Location - PawnMaton2.Location;
00712			vDirMaton1_Maton2.z = 0;
00713			if ( (( !bXIIIDansEscalier ) && ( vSize(vDirMaton1_Maton2) > 0.95*DistanceMatons ))
00714				|| (( bXIIIDansEscalier ) && ( vSize(vDirMaton1_Maton2) > 0.35*DistanceMatons )) )
00715			{
00716				bPauseMaton2 = false;
00717				PawnMaton2.WaitAnim='waitmatrak';
00718				PawnMaton2.WalkAnim='marchematrakhand';
00719				PawnMaton2.WalkAnimVelocity = DefaultWalkAnimVelocity;
00720				ControllerMaton2.WantedSpeed = VitesseMaton2;
00721				if ( bEscortingEscalierMaton2 )
00722					GotoState('STA_EscortingEscalier');
00723				else
00724					GotoState('STA_Escorting');
00725			}
00726		}
00727	}
00728	
00729	
00730	//_____________________________________________________________________________
00731	STATE STA_AttenteEscalier
00732	{
00733		EVENT BeginState()
00734		{
00735			Log("ENTER : STA_AttenteDevantLesEscaliers");
00736	
00737			ControllerMaton2.StopMove();
00738			ControllerMaton2.LockedActor=none;
00739			ControllerMaton2.Focus = PlayerPawn;
00740			ControllerMaton2.LoopAni(PawnMaton1.WaitAnim);
00741			bPauseMaton2 = true;
00742			bPauseEscalierMaton2 = true;
00743		}
00744	
00745		EVENT Tick( float dt )
00746		{
00747	
00748			TimeStamp+=dt;
00749	
00750			// comportement du premier maton
00751			FirstKeeperBehavior(dt);
00752	
00753			// comportement du second maton
00754			TestMatraquageMaton2();
00755	
00756			// test si XIII commence a descendre l escalier
00757			TestXIIIDansEscalier();
00758	
00759	
00760			if ( bXIIIDansEscalier )
00761			{
00762				bPauseMaton2 = false;
00763				bPauseEscalierMaton2 = false;
00764				Maton2Index += 3;
00765				vPosChemin2 = Chemin[Maton2Index].Location;
00766				GotoState('STA_EscortingEscalier');
00767			}
00768		}
00769	}
00770	
00771	
00772	//_____________________________________________________________________________
00773	STATE STA_EscortingEscalier
00774	{
00775		EVENT BeginState()
00776		{
00777			Log("ENTER : STA_EscortingEscalier");
00778	
00779			ControllerMaton2.RotationSpeed=359;
00780			ControllerMaton2.WantedSpeed=VitesseMaton2;
00781			ControllerMaton2.AccelerationFactor=1.0;
00782			ControllerMaton2.LockedActor=PlayerPawn;
00783			ControllerMaton2.CineMoveTo(Chemin[Maton2Index]);
00784			bEscortingEscalierMaton2 = true;
00785		}
00786	
00787		EVENT Tick(float dt)
00788		{
00789	
00790			TimeStamp+=dt;
00791	
00792			// comportement du premier maton
00793			FirstKeeperBehavior(dt);
00794	
00795			// comportement du second maton
00796			TestMatraquageMaton2();
00797	
00798			// ajustement de la vitesse du second maton
00799			AjusteVitesseMaton2(dt);
00800	
00801			// on regarde si on change de section de chemin
00802			vDirMaton2_Chemin2 = PawnMaton2.Location - vPosChemin2;
00803			vDirMaton2_Chemin2.z = 0;
00804			if ( vSize(vDirMaton2_Chemin2) < 5)
00805			{
00806				Maton2Index ++;
00807	
00808				// le second maton s arrete juste avant la fin du chemin
00809				if (Maton2Index == (Chemin.Length - 2))
00810				{
00811					if (!bFinCheminMaton1)
00812					{
00813						ControllerMaton1.StopMove();
00814						ControllerMaton1.LockedActor=none;
00815					}
00816					ControllerMaton2.StopMove();
00817					ControllerMaton2.LockedActor=none;
00818					TriggerEvent(event, self, PawnMaton1);
00819					GotoState('STA_EndOfEscort');
00820					return;
00821				}
00822	
00823				// on prend en compte les portes pour le point suivant du chemin
00824				vPosChemin2 = Chemin[Maton2Index].Location;
00825				ControllerMaton2.CineMoveTo(Chemin[Maton2Index]);
00826			}
00827		}
00828	}
00829	
00830	
00831	//_____________________________________________________________________________
00832	// gestion de la fin
00833	// -> interaction des objets
00834	// -> verrouillage des portes
00835	// -> restitution des poings
00836	STATE STA_EndOfEscort
00837	{
00838		EVENT Tick( float dt )
00839		{
00840			// comportement du premier maton
00841			FirstKeeperBehavior(dt);
00842	
00843			if ( bFinCheminMaton1 )
00844			{
00845				ControllerMaton1.StopMove();
00846				ControllerMaton1.LockedActor=none;
00847				TriggerEvent(event, self, PawnMaton1);
00848				Disable('Tick');
00849			}
00850		}
00851	
00852		EVENT Trigger(actor Other,Pawn EventInstigator)
00853		{
00854			local XIIIPorte PorteATraiter;
00855			local Inventory Inv;
00856	
00857			// je m occupe des portes
00858			for (i=0;i<ObjetsSansInteraction.Length;i++)
00859			{
00860				ObjetATraiter = ObjetsSansInteraction[i];
00861				if ( ObjetATraiter.IsA('Porte') )
00862				{
00863					Porte(ObjetATraiter).bNoInteractionIcon = false;
00864					PawnMaton1.CloseDoor(Porte(ObjetATraiter));
00865				}
00866			}
00867	
00868			// on redonne les poings au joueur
00869			Level.Game.BaseMutator.DefaultWeaponName = "XIII.Fists";
00870			Level.Game.AddDefaultInventory(PlayerPawn);
00871	
00872			PawnMaton1.bInteractive = true;
00873			PawnMaton2.bInteractive = true;
00874	
00875			// on remplace la collision de la map
00876			ColCouloirEscorte.bWorldGeometry = false;
00877			ColCouloirEscorte.bBlockActors = false;
00878			ColCouloirEscorte.bBlockPlayers = false;
00879			ColCouloirEscorte.bBlockZeroExtentTraces = false;
00880			ColCouloirEscorte.bBlockNonZeroExtentTraces = false;
00881			ColCouloirEscorte.Destroy();
00882			ColEscalierEscorte.bWorldGeometry = false;
00883			ColEscalierEscorte.bBlockActors = false;
00884			ColEscalierEscorte.bBlockPlayers = false;
00885			ColEscalierEscorte.bBlockZeroExtentTraces = false;
00886			ColEscalierEscorte.bBlockNonZeroExtentTraces = false;
00887			ColEscalierEscorte.Destroy();
00888			Destroy();
00889			return;
00890		}
00891	}
00892	
00893	
00894	//_____________________________________________________________________________
00895	
00896	
00897	defaultproperties
00898	{
00899	     DistanceMatons=600.000000
00900	     VitesseMaton1=0.330000
00901	     VitesseMaton2=0.330000
00902	     fDegatCoupDeMatraque=15.000000
00903	}

End Source Code