## XIDPawn
Class BaseSoldier

source: C:\XIII\XIDPawn\Classes\BaseSoldier.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Pawn
             |
             +--XIII.XIIIPawn
                |
                +--XIDPawn.BaseSoldier

Direct Known Subclasses:Cine2, FBI_Helico01a, Johansson

class BaseSoldier
extends XIII.XIIIPawn

    //=============================================================================
    // BaseSoldier.
    //=============================================================================

Variables
`float` | `AlphaRotation` facteur alapha sur rotation entre les levres du ouahouah
`float` | `DistanceBord` distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
`GenNMI` | `GenEnnemi` distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
`name` | `GroupeAlarme[4]` par quel groupe d'alarme le perso est affecte
`BaseSoldier` | `LeBloqueur` distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
`Emitter` | `OnoChute` distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
`CrashPoint` | `PointCrash` distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
`float` | `ScaleOuahOuah` facteur de scale du ouahouah sur les levres
`float` | `TimerBeforeStop` timer du ouahouah qui determine fin
`float` | `Timer_PoteMeBloque` distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
`name` | `TypeDommage` distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
`vector` | `Vect_Position` distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
`bool` | `bBasesGenere` pour avertir que ce cadavre a deja ete fouille
`bool` | `bBlockNextOuahOuah` etat du ouahouah pour sequencer les ouvertures de bouche
`bool` | `bControleChute` pour avertir que ce cadavre a deja ete fouille
`bool` | `bDejaFouille` pour avertir que ce cadavre a deja ete fouille
`bool` | `bDetecteBloquage` dans bump pour delcelcher attente si bloque
`bool` | `bJOuvreLaBouche` etat du ouahouah pour sequencer les ouvertures de bouche
`bool` | `bJetombe` pour avertir que ce cadavre a deja ete fouille
`bool` | `bMonCadavreEstDejaVu` dans bump pour ne recaler qu'un perso
`bool` | `bPasseAttScr_ApresGen` initialisee par gennmi
`bool` | `bSlave` dans bump pour ne recaler qu'un perso
`bool` | `bSpawnInAir` si personnage genere en l'air
`bool` | `bTurnIntoAgressiveSoldier` par quel groupe d'alarme le perso est affecte
`int` | `iOuahOuah` etat du ouahouah = 0 eteint =1 en timing et =2 en cours

States
dying

Function Summary
`void` | `AmplitudeOuahOuah(float dt)`
`simulated` | `AnimateRunning()`
    {
    super.AnimateWalking();

      if (Iacontroller(self.controller).niveaualerte<2)
      {
      MovementAnims[1] = 'RotationG';
      MovementAnims[3] = 'RotationD';
      }
      }
`simulated` | `AnimateWalking()`
    /*
`vector` | `EyePosition()`
`void` | `InitializeInventory()`
    //---------------------------------------------------------------------------------
    //Inventaire par defaut appele par initialize pawn dans le controller
    //----------------------------------------------------------------------------------
`void` | `PlayCrashOnGround()`
`void` | `PlayFallingFalaise()`
`void` | `PlayH2HProvoc()`
`void` | `PlayJumpInAir()`
`void` | `PlayJumpInFlight()`
`void` | `PlayJumpLanding()`
`void` | `PlayManip()`
`void` | `PlayOpenDoor()`
`void` | `PlayQuickLookAround()`
`void` | `PlayRoulade()`
`void` | `PlaySearchGround()`
`void` | `PlayStartToFall()`
`void` | `PlayWaitGrenade()`
`void` | `ReleaseAnimControl(optional bool)`
`void` | `TakeAnimControl(bool bMoveAnim)`
    // ----------------------------- ANIMS ---------------------
`bool` | `TestChute()`
    // ----------------------------------------------------------------------
    // TestChute : renvoi si le perso peut tomber.
    // ----------------------------------------------------------------------

State dying Function Summary
`void` | `BeginState()`

Source Code

    00001	//=============================================================================
    00002	// BaseSoldier.
    00003	//=============================================================================
    00004	class BaseSoldier extends XIIIPawn native;
    00005	#exec OBJ LOAD FILE=XIIISound.uax PACKAGE=XIIISound
    00006	#exec OBJ LOAD FILE="Onomatopees.uax" PACKAGE=Onomatopees
    00007
    00008	//----------------------------------------------------
    00009	//STRUCTURES
    00010	struct InventoryItem  {
    00011		var() class<Inventory> Inventory;
    00012		var() int              Count;
    00013	};
    00014
    00015	struct InitialAllianceInfo  {
    00016		var() Name  AllianceName;
    00017		var() float AllianceLevel;
    00018	};
    00019
    00020	//----------------------------------------------------
    00021	//VARIABLES
    00022	var(Inventory) InventoryItem InitialInventory[8];  // inventaire par defaut du pawn
    00023	var(Alliances) InitialAllianceInfo InitialAlliances[4]; //alliances du pawn
    00024
    00025	var(baseSoldier) name Order; // nom de l'etat de depart
    00026	var(baseSoldier) float PourcErrance; //Pourcentage d'errance par rapport a la patrouille.
    00027	//----------------------
    00028	// Reactions aux ennemis
    00029	//----------------------
    00030	var(BaseSoldier) float TempsRechercheNMI; //temps avant de reprende activite lorsque a cru voir quelque chose
    00031	var(BaseSoldier) float Agressivite;  //agressivite -1 a 1
    00032	var(BaseSoldier) float TempsIdentification;  //Temps d'identification (en s) max quand NMI au max                                                   de vision
    00033	var(BaseSoldier) float DistanceAttaque; //distance d'attaque (defaut a 600)
    00034	var(BaseSoldier) float TempsVisee; //Temps de visee avant tir
    00035	var(BaseSoldier) int StrategicPointAttraction; // 0 a 100 : proportion d'utilisation des strategicpoints
    00036	var(BaseSoldier) int ProbaDeclencheAlarme; // probabilite de declencher l'alarme la plus proche
    00037	var(baseSoldier) int NumReseauPropre; // num du reseau propre
    00038	var(BaseSoldier) int NumReseauAttaque; // num du reseau d'attaque
    00039	var(BaseSoldier) float TempsPasVu; //temps ou l'ennemi a rien vu et on peut se recacher (valeur pour la distance de vision)
    00040	var(BaseSoldier) bool bAlerte; //permet de dire que le perso est en etat alerte<->declenche par trigger
    00041	var(BaseSoldier) bool bRappliqueSiAlerte; //si entend alarme rapplique ou se plaqnue
    00042
    00043	var(BaseSoldier_Advanced) bool bPasseAttScr_SiDeclenche; //le perso declenche passe direct en attaquescriptee
    00044	var(BaseSoldier_Advanced) float OffsetTimeBetweenShots; //
    00045	var(BaseSoldier_Advanced) bool bPasDeclenchableParAlarme; //
    00046	var(BaseSoldier_Advanced) bool bNeVoitPasCadavre; // detecte un cadavre ou pas
    00047	var(BaseSoldier_Advanced) bool bMeurtEnTombant; //bah quand on le bute il chute
    00048	var(BaseSoldier_Advanced) bool bAlerteAmisEnCriant; //crie pour avertir potes
    00049	var(BaseSoldier_Advanced) float WalkingSpeed;       // tag of object referred to byorders
    00050	var(BaseSoldier_Advanced) bool bPatrolWithWalkSearchAnim;  // fait sa premiere patrouille en anim de marche suspicieuse
    00051	var(baseSoldier_Advanced) WanderingVolume MyWanderingVolume; //volume d'errance
    00052	VAR(baseSoldier_Advanced) Array<MeshAnimation>	SpecificAnimations;
    00053	VAR(baseSoldier_Advanced) bool bFouilleCadavres;
    00054	VAR(baseSoldier_Advanced) bool bNeFuitPasGrenades;
    00055
    00056
    00057	var (GroupeAlarme) name GroupeAlarme[4]; //par quel groupe d'alarme le perso est affecte
    00058	var (Cine_Vars) bool bTurnIntoAgressiveSoldier;
    00059	var(sound) bool bDontCallFriends; //dont call allies if he is alone assault
    00060	var(sound) enum NumTimbre
    00061	{
    00062		Timbre_1,
    00063	        Timbre_2,
    00064	        Timbre_3
    00065	} NumeroTimbre;
    00066	var(sound) int CodeMesh;
    00067
    00068	var bool bDejaFouille; //pour avertir que ce cadavre a deja ete fouille
    00069	var bool bJetombe;
    00070	Var bool bBasesGenere;
    00071	var bool bControleChute;
    00072	var bool bDetecteBloquage; //dans bump pour delcelcher attente si bloque
    00073	var bool bSlave; //dans bump pour ne recaler qu'un perso
    00074	var bool bMonCadavreEstDejaVu;
    00075	var bool bJOuvreLaBouche;  //etat du ouahouah pour sequencer les ouvertures de bouche
    00076	var bool bBlockNextOuahOuah;
    00077	var bool bPasseAttScr_ApresGen; //initialisee par gennmi
    00078	VAR bool bSpawnInAir; //si personnage genere en l'air
    00079
    00080
    00081	var int iOuahOuah; //etat du ouahouah = 0 eteint =1 en timing et =2 en cours
    00082
    00083	var float ScaleOuahOuah;  //facteur de scale du ouahouah sur les levres
    00084	var float AlphaRotation; //facteur alapha sur rotation entre les levres du ouahouah
    00085	var float TimerBeforeStop; //timer du ouahouah qui determine fin
    00086	var float DistanceBord;//distance entre perso et bord=multiple 0.5 de distancemax (Cf.testchute)
    00087	var float Timer_PoteMeBloque;
    00088
    00089	var vector Vect_Position;
    00090
    00091	var name TypeDommage;
    00092
    00093	var GenNMI GenEnnemi;
    00094	var CrashPoint PointCrash;
    00095	var BaseSoldier LeBloqueur;
    00096	var emitter OnoChute;
    00097
    00098	//_____________________________________________________________________________
    00099	event ParseDynamicLoading(LevelInfo MyLI)
    00100	{
    00101	    local int i;
    00102
    00103	    Log("ParseDynamicLoading Actor="$self);
    00104	    for (i=0; i<8; i++)
    00105	    {
    00106			if ( InitialInventory[i].Inventory != none )
    00107			{
    00108				MyLI.ForcedClasses[MyLI.ForcedClasses.Length] = InitialInventory[i].Inventory;
    00109				(InitialInventory[i].Inventory).Static.StaticParseDynamicLoading(MyLI);
    00110			}
    00111	    }
    00112	}
    00113
    00114	native function vector EyePosition();
    00115	event OnoStartNotif() //perso a recu notification de son pour jouer ouahouah
    00116	{
    00117		if (bBlockNextOuahOuah)
    00118		{
    00119			bBlockNextOuahOuah=false;
    00120			return;
    00121		}
    00122		TimerBeforeStop=level.timeseconds;
    00123		iOuahOuah=1;
    00124		ScaleOuahOuah=1;
    00125		AlphaRotation=0;
    00126		bJOuvreLaBouche=true;
    00127	}
    00128
    00129	function AmplitudeOuahOuah(float dt)
    00130	{
    00131		if (bJOuvreLaBouche && AlphaRotation>=1)
    00132		{
    00133			bJOuvreLaBouche=false;
    00134			ScaleOuahOuah=0.2;
    00135		}
    00136		else if (!bJOuvreLaBouche && AlphaRotation<0.1)
    00137		{
    00138			bJOuvreLaBouche=true;
    00139			ScaleOuahOuah=1;
    00140		}
    00141		if (bJOuvreLaBouche)
    00142		{
    00143			ScaleOuahOuah-=3.5*dt;
    00144			AlphaRotation+=4*dt;
    00145			// 		log("j'ouvre la bouche"@scaleouahouah@alpharotation);
    00146		}
    00147		else
    00148		{
    00149
    00150			ScaleOuahOuah+=4.5*dt;
    00151			AlphaRotation-=5*dt;
    00152			//       	log("je ferme la bouche"@scaleouahouah@alpharotation);
    00153		}
    00154	}
    00155
    00156
    00157
    00158	event Tick (float delta)
    00159	{
    00160		super.tick(delta);
    00161
    00162		if (iOuahOuah>0)
    00163		{
    00164			if ((level.timeseconds-TimerBeforeStop)<0.8)
    00165			{
    00166				self.SetBoneScalePerAxis( 0, fclamp(ScaleOuahOuah*1.2,0,1),,,'X LIPS');
    00167				self.SetBoneRotation('X JAW', -5000* rot( 0, 0, 1 ),,fclamp(AlphaRotation*0.3,0,1));
    00168				AmplitudeOuahOuah(delta);
    00169			}
    00170			else
    00171			{
    00172				//log(self@"play fermre");
    00173				self.SetBoneRotation('X JAW', rot( 0, 0, 0 ), , 0);
    00174				self.SetBoneScalePerAxis( 0, 1,,,'X LIPS');
    00175				iOuahOuah=0;
    00176			}
    00177		}
    00178	}
    00179	//gestion des collisions entre basesoldiers
    00180	event bump(actor other)
    00181	{
    00182		local Iacontroller IaContr;
    00183		local basesoldier OtherSoldier;
    00184
    00185		if (XIIIPAwn(other)==none)
    00186			return;
    00187
    00188		IACOntr=IACOntroller(COntroller);
    00189		if (IACOntr!=none && IACOntr.XIII==other && IACOntr.NiveauAlerte==2 && IACOntr.AllianceLevel(IACOntr.XIII)<0 && !IACOntr.bAlarmeInstigator && (IACOntr.IsInState('VaVers') || IACOntr.IsInState('OuvrePorte')))
    00190		{
    00191			IACOntr.GotoState('attaque');
    00192			return;
    00193		}
    00194		if (XIIIPAwn(other).controller!=none && !XIIIPAwn(other).controller.isa('iacontroller') || bSlave)
    00195			return;
    00196
    00197		if (!bDetecteBloquage && ((velocity dot vector(rotation))>(other.velocity dot vector(other.rotation)))) //Je me déplace
    00198		{
    00199			OtherSoldier=basesoldier(other);
    00200			//log(self@"bPoteMeBloque"@other@(level.timeseconds-Timer_PoteMeBloque));
    00201			if (!OtherSoldier.bSlave)
    00202			{
    00203				Timer_PoteMeBloque=level.timeseconds;
    00204				if (OtherSoldier.controller.isinstate('ouvrePorte'))
    00205				{
    00206					 LeBloqueur=self;
    00207					 bslave=true;
    00208				}
    00209				else if ((Vsize(velocity)<100 && Vsize(other.velocity)>100)) //il se deplace mais pas moi
    00210				{
    00211					 LeBloqueur=self;
    00212					 bslave=true;
    00213				}
    00214				else
    00215				{
    00216					LeBloqueur=OtherSoldier;
    00217					LeBloqueur.bSlave=true;
    00218				}
    00219			}
    00220			else if ((level.timeseconds-Timer_PoteMeBloque)>0.2 && other==Lebloqueur)
    00221			{
    00222				IaContr=Iacontroller(controller);
    00223				bDetecteBloquage=true;
    00224				IaContr.PoteQuiMeBloque=LeBloqueur;
    00225				IaContr.PoteQuiMeBloquePos=LeBloqueur.location;
    00226				IAContr.HalteAufeu();
    00227				Iacontr.prevstate=controller.getstatename();
    00228				controller.gotostate('restesurplace','PoteMeBLoque');
    00229			}
    00230		}
    00231	}
    00232
    00233	function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType)
    00234	{
    00235	    local DamageLocations Loc;
    00236
    00237	    Loc = GetDamageLocation( HitLocation, Location - instigatedBy.Location );
    00238
    00239	    if (Loc != LOC_Head)
    00240	        Damage *= (1 + ( 1-Level.Game.Difficulty) *0.25 );
    00241
00242 Super.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType); 00243 } 00244 00245 00246 // ----------------------------- ANIMS --------------------- 00247 function TakeAnimControl(bool bMoveAnim) 00248 { 00249 bMoving=bMoveAnim; 00250 bPhysicsanimupdate=false; 00251 bSpineControl=false; 00252 if (controller!=none) 00253 controller.bControlanimations=true; 00254 SetBoneDirection(FIRINGBLENDBONE, rot(0,0,0), vect(0,0,0), 0.0 ); 00255 } 00256 function ReleaseAnimControl(optional bool bFastTransition) 00257 { 00258 if (Controller != none) controller.bControlanimations=false; 00259 bSpineControl=true; 00260 bPhysicsanimupdate=true; 00261 PlayWaiting(); 00262 if (bFastTransition) 00263 AnimBlendToAlpha(FIRINGCHANNEL+1,0,0.2); 00264 else 00265 AnimBlendToAlpha(FIRINGCHANNEL+1,0,0.6); 00266 } 00267 00268 event AnimEnd(int Channel) 00269 { 00270 //Log("@@ AnimEnd w/channel="$Channel$" call for "$self); 00271 00272 if ( (Controller != none) && Controller.bControlAnimations ) 00273 { 00274 //Log("@@ AnimEnd w/channel="@Controller.bControlAnimations); 00275 if (channel!=FIRINGCHANNEL+1) 00276 AnimBlendToAlpha(Channel,0,0.4); 00277 return; 00278 } 00279 if (channel==FIRINGCHANNEL+1) //no more control 00280 { 00281 //log("release control"); 00282 ReleaseAnimControl(); 00283 return; 00284 } 00285 if ( Channel == FIRINGCHANNEL ) 00286 { 00287 bRndAnimM16 = true; 00288 00289 // FIRINGCHANNEL used for upper body (firing weapons, etc.) 00290 00291 if ( Role < ROLE_Authority ) 00292 { 00293 PlayWaiting(); 00294 PlayMoving(); 00295 } 00296 if ( bReloadingWeapon || !bChangingWeapon ) 00297 { 00298 AnimBlendToAlpha(FIRINGCHANNEL,0,0.2); 00299 } 00300 else 00301 { 00302 if ( bChangingWeapon ) 00303 { 00304 Switch(WeaponMode) 00305 { 00306 Case 'FM_Bazook': 00307 Case 'FM_BazookAlt': 00308 Case 'FM_2H': 00309 Case 'FM_M16': 00310 Case 'FM_ShotGunAlt': 00311 Case 'FM_HarpoonAlt': 00312 PlayAnim('SearchGun',,0.15,FIRINGCHANNEL); break; 00313 Case 'FM_2HHeavy': 00314 PlayAnim('SearchGatling',,0.15,FIRINGCHANNEL); break; 00315 Default: 00316 PlayAnim('SearchPistol',,0.15,FIRINGCHANNEL); Break; 00317 } 00318 bReloadingWeapon=false; 00319 } 00320 else 00321 { 00322 if ( !bMoving ) 00323 PlayWaiting(); 00324 else 00325 PlayMoving(); 00326 } 00327 } 00328 } 00329 else 00330 { 00331 if ( !bMoving ) 00332 PlayWaiting(); 00333 else 00334 PlayMoving(); 00335 } 00336 } 00337 function PlayQuickLookAround() 00338 { 00339 TakeAnimControl(false); 00340 loopAnim('devantcorps',,0.2,FIRINGCHANNEL+1); 00341 AnimBlendToAlpha(FIRINGCHANNEL+1,1,0.2); 00342 } 00343 00344 function PlayJumpInAir() 00345 { 00346 TakeAnimControl(false); 00347 if (weapon.inventorygroup>=8 && weapon.inventorygroup<=12) 00348 PlayAnim('jumpGunD',,0.05,FIRINGCHANNEL+1); 00349 else 00350 PlayAnim('jumpPistolD',,0.05,FIRINGCHANNEL+1); 00351 AnimBlendToAlpha(FIRINGCHANNEL+1,1,0.05); 00352 } 00353 function PlayJumpInFlight() 00354 { 00355 if (weapon.inventorygroup>=8 && weapon.inventorygroup<=12) 00356 loopAnim('jumpGunC',,0.1,FIRINGCHANNEL+1); 00357 else 00358 loopAnim('jumpPistolC',,0.1,FIRINGCHANNEL+1); 00359 } 00360 function PlayJumpLanding() 00361 { 00362 if (weapon.inventorygroup>=8 && weapon.inventorygroup<=12) 00363 playAnim('jumpGunF',,0.05,FIRINGCHANNEL+1); 00364 else 00365 playAnim('jumpPistolF',,0.05,FIRINGCHANNEL+1); 00366 } 00367 00368 function PlaySearchGround() 00369 { 00370 TakeAnimControl(false); 00371 PlayAnim('SearchGround',,0.2,FIRINGCHANNEL+1); 00372 AnimBlendToAlpha(FIRINGCHANNEL+1,1,0.4); 00373 } 00374 function PlayWaitGrenade() 00375 { 00376 TakeAnimControl(false); 00377 PlayAnim('attentegrenade',,0.2,FIRINGCHANNEL+1); 00378 AnimBlendToAlpha(FIRINGCHANNEL+1,1,0.4); 00379 } 00380 Function PlayH2HProvoc () 00381 { 00382 TakeAnimControl(false); 00383 PlayAnim('MigBoxeProvoc',1,0.2,FIRINGCHANNEL+1); 00384 AnimBlendToAlpha(FIRINGCHANNEL+1,1,0.4); 00385 } 00386 function PlayManip() 00387 { 00388 TakeAnimControl(false); 00389 PlayAnim('alarm',1,0.2,FIRINGCHANNEL+1); 00390 AnimBlendToAlpha(FIRINGCHANNEL+1,1,0.4); 00391 } 00392 function PlayStartToFall() 00393 { 00394 PlayAnim('DeathDos',,0.3,FIRINGCHANNEL+2); 00395 AnimBlendToAlpha(FIRINGCHANNEL+2,1,0.3); 00396 } 00397 function PlayFallingFalaise() 00398 { 00399 loopanim('DeathFalaiseC',,0.4,FIRINGCHANNEL+2); 00400 } 00401 function PlayCrashOnGround() 00402 { 00403 playanim('deathfalaisefin',,0.10,FIRINGCHANNEL+2); 00404 } 00405 00406 function PlayRoulade() 00407 { 00408 //AnimBlendParams(FIRINGCHANNEL+3,0,0,0,'X') 00409 TakeAnimControl(false); 00410 if (normal(controller.focalpoint-location) dot normal(vector(rotation) cross vect(0,0,1)) >0) 00411 playanim('rouladeg',0.75,,FiringChannel+1); 00412 else 00413 playanim('rouladed',0.75,,FiringChannel+1); 00414 AnimBlendToAlpha(FIRINGCHANNEL+1,1,0.4); 00415 } 00416 //_____________________________________________________________________________ 00417 event PlayDying(class<DamageType> DamageType, vector HitLoc) 00418 { 00419 if ( bDBAnim ) Log("--@ PlayDying call for "$self@"HitLocCode="$HitLoc); 00420 00421 bPlayedDeath = true; 00422 if ( bPhysicsAnimUpdate ) 00423 { 00424 bTearOff = true; 00425 bReplicateMovement = false; 00426 } 00427 // Velocity += TearOffMomentum; 00428 SetPhysics(PHYS_Falling); 00429 00430 AnimBlendToAlpha(FIRINGCHANNEL,0,0.1); 00431 00432 if (!bJeTombe) 00433 PlayDyingAnim(DamageType,HitLoc); 00434 GotoState('Dying'); 00435 } 00436 00437 function PlayOpenDoor() 00438 { 00439 //if ( bDBAnim ) Log("--@ PlayOpenDoor call for "$self); 00440 TakeAnimControl(false); 00441 PlayAnim('OpenDoor',2,,FIRINGCHANNEL+1); 00442 AnimBlendToAlpha(FIRINGCHANNEL+1,1,0.4); 00443 } 00444 00445 00446 /*simulated function AnimateWalking() 00447 { 00448 super.AnimateWalking(); 00449 00450 if (Iacontroller(self.controller).niveaualerte<2) 00451 { 00452 MovementAnims[1] = 'RotationG'; 00453 MovementAnims[3] = 'RotationD'; 00454 } 00455 } 00456 00457 simulated function AnimateRunning() 00458 { 00459 super.AnimateRunning(); 00460 00461 if (Iacontroller(self.controller).niveaualerte<2) 00462 { 00463 MovementAnims[1] = 'RotationG'; 00464 MovementAnims[3] = 'RotationD'; 00465 } 00466 }*/ 00467 00468 00469 EVENT PostBeginPlay() 00470 { 00471 LOCAL int i; 00472 00473 Super.PostBeginPlay(); 00474 00475 if (SpecificAnimations.Length>0) //fait dans gennmi pour les persos generes 00476 { 00477 for (i=0;i<SpecificAnimations.Length;++i) 00478 { 00479 LinkSkelAnim (SpecificAnimations[i]); 00480 } 00481 } 00482 } 00483 00484 00485 //--------------------------------------------------------------------------------- 00486 //Inventaire par defaut appele par initialize pawn dans le controller 00487 //---------------------------------------------------------------------------------- 00488 function InitializeInventory() 00489 { 00490 local int i, j; 00491 local Inventory inv; 00492 local ammunition AmmoTmp; 00493 00494 //initialise poings 00495 inv = spawn(class'Fists', self); 00496 if (inv != None) 00497 { 00498 inv.gotostate(''); 00499 inv.GiveTo(Self); 00500 } 00501 00502 // Add initial inventory items 00503 for (i=0; i<8; i++) 00504 { 00505 if ( InitialInventory[i].Inventory != None ) 00506 { 00507 inv = spawn(InitialInventory[i].Inventory); 00508 if ( Weapon(inv) != none ) 00509 { 00510 Inv.GiveTo(self); 00511 // Add clips 00512 AmmoTmp = Weapon(Inv).AmmoType; 00513 if ( class<Ammo>(AmmoTmp.PickupClass) != none ) 00514 AmmoTmp.AmmoAmount += InitialInventory[i].count * class<Ammo>(AmmoTmp.PickupClass).Default.AmmoAmount; 00515 else 00516 AmmoTmp.AmmoAmount = InitialInventory[i].count; 00517 } 00518 else if ( Ammunition(Inv) != none ) 00519 { 00520 AmmoTmp = ammunition(FindInventoryType(Inv.Class)); 00521 if ( AmmoTmp == none ) 00522 { 00523 Inv.GiveTo(self); 00524 if ( class<Ammo>(Inv.PickupClass) != none ) 00525 Ammunition(Inv).AmmoAmount += InitialInventory[i].count * class<Ammo>(Inv.PickupClass).Default.AmmoAmount; 00526 else 00527 Ammunition(Inv).AmmoAmount = InitialInventory[i].count; 00528 } 00529 else 00530 { 00531 if ( class<Ammo>(Inv.PickupClass) != none ) 00532 AmmoTmp.ammoAmount += InitialInventory[i].count * class<Ammo>(Inv.PickupClass).Default.AmmoAmount; 00533 else 00534 Ammunition(Inv).AmmoAmount = InitialInventory[i].count; 00535 Inv.Destroy(); 00536 } 00537 } 00538 else if ( Casque(Inv) != none ) 00539 { 00540 Inv.GiveTo(self); 00541 Inv.Charge = 40; 00542 // No special treatment 00543 } 00544 else 00545 { 00546 Inv.GiveTo(self); 00547 // No special treatment 00548 } 00549 } 00550 } 00551 } 00552 00553 00554 //_____________________________________________________________________________ 00555 // FRD a partir de ELR 00556 function Died(Controller Killer, class<DamageType> damageType, vector HitLocCode) 00557 { 00558 local int i; 00559 local xiiigameinfo gameinf; 00560 local IACOntroller IaContr; 00561 00562 IAContr=IaController(controller); 00563 00564 if (IAContr==none) 00565 { 00566 if ( class<XIIIDamageType>(damageType).default.bDieInSilencePlease ) 00567 PlaySndDeathOno(deathono'Onomatopees.hPNJDeath2',CodeMesh,NumeroTimbre); 00568 else 00569 PlaySndDeathOno(deathono'Onomatopees.hPNJDeath1',CodeMesh,NumeroTimbre); 00570 00571 Super.Died( Killer, damageType, HitLocCode); 00572 return; 00573 } 00574 //supression de la basesoldierlist pour les persos non generes 00575 ReleaseAnimControl(); 00576 gameinf=xiiigameinfo(level.game); 00577 if (bBasesGenere && GenEnnemi!=none) 00578 { 00579 bBasesGenere=false; //pour ne pas le ressupprimer 00580 GenEnnemi.NbNMIPresents--; 00581 if (GenEnnemi.isinstate('AttendMortNMIs')) 00582 GenEnnemi.UnNMIenMoins(); 00583 else if (GenEnnemi.isinstate('PauseGenese')) 00584 GenEnnemi.gotostate('genese','suitegeneration'); 00585 } 00586 else //pas supprime de la basesoldierlist si genere, c'est le gennmi qui le fait 00587 { 00588 for (i = 0; i < gameinf.BaseSoldierList.Length; i++) 00589 { 00590 if (gameinf.BaseSoldierList[i] == self ) 00591 { 00592 gameinf.BaseSoldierList.Remove(i,1); 00593 break; 00594 } 00595 } 00596 } 00597 controller.gotostate('Mort'); 00598 //son 00599 if (IAContr!=none) 00600 { 00601 if (IAContr.NiveauAlerte==2 && IAContr.NiveauALerteEnAS==0) 00602 { 00603 IAContr.NiveauAlerte=0; 00604 IAContr.bSwitchMusicInWaitState=false; //inutile 00605 } 00606 //son 00607 Switch (IAContr.NiveauALerte) 00608 { 00609 case 0: 00610 level.decattente(); 00611 //IAContr.genalerte.nbattente--; 00612 //log("decattente "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque); 00613 break; 00614 case 1: 00615 level.decAlerte(); 00616 //IAContr.genalerte.nbalerte--; 00617 //log("decalerte "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque); 00618 break; 00619 case 2: 00620 level.decAttaque(); 00621 //IAContr.genalerte.nbattaque--; 00622 //log("decattaque "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque); 00623 break; 00624 } 00625 } 00626 //sons 00627 if (bMeurtEnTombant && TestChute()) 00628 { 00629 bJeTombe=true; 00630 PlaySndDeathOno(deathono'Onomatopees.hPNJDeath3',CodeMesh,NumeroTimbre); 00631 } 00632 else if ( class<XIIIDamageType>(damageType).default.bDieInSilencePlease ) 00633 PlaySndDeathOno(deathono'Onomatopees.hPNJDeath2',CodeMesh,NumeroTimbre); 00634 else 00635 PlaySndDeathOno(deathono'Onomatopees.hPNJDeath1',CodeMesh,NumeroTimbre); 00636 Super.Died( Killer, damageType, HitLocCode); 00637 } 00638 00639 00640 event Destroyed() 00641 { 00642 local int i; 00643 local xiiigameinfo gameinf; 00644 local IACOntroller IAContr; 00645 00646 //supression de la basesoldierlist pour les persos non generes 00647 gameinf=xiiigameinfo(level.game); 00648 if (bBasesGenere && GenEnnemi!=none) 00649 { 00650 GenEnnemi.NbNMIPresents--; 00651 if (GenEnnemi.isinstate('AttendMortNMIs')) 00652 GenEnnemi.UnNMIenMoins(); 00653 else if (GenEnnemi.isinstate('PauseGenese')) 00654 GenEnnemi.gotostate('genese','suitegeneration'); 00655 } 00656 else //pas supprime de la basesoldierlist si genere, c'est le gennmi qui le fait 00657 { 00658 for (i = 0; i < gameinf.BaseSoldierList.Length; i++) 00659 { 00660 if (gameinf.BaseSoldierList[i] == self ) 00661 { 00662 gameinf.BaseSoldierList.Remove(i,1); 00663 break; 00664 } 00665 } 00666 } 00667 IAContr=IaController(controller); 00668 if (IAContr!=none) 00669 { 00670 if (IAContr.NiveauAlerte==2 && IAContr.NiveauALerteEnAS==0) 00671 { 00672 IAContr.NiveauAlerte=0; 00673 IAContr.bSwitchMusicInWaitState=false; //inutile 00674 } 00675 //son 00676 Switch (IAContr.NiveauALerte) 00677 { 00678 case 0: 00679 level.decattente(); 00680 // IAContr.genalerte.nbattente--; 00681 // log("decattente "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque); 00682 break; 00683 case 1: 00684 level.decAlerte(); 00685 // IAContr.genalerte.nbalerte--; 00686 // log("decalerte "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque); 00687 break; 00688 case 2: 00689 level.decAttaque(); 00690 // IAContr.genalerte.nbattaque--; 00691 // log("decattaque "$Iacontroller(controller).genalerte.nbattente@Iacontroller(controller).genalerte.nbalerte@Iacontroller(controller).genalerte.nbattaque); 00692 break; 00693 } 00694 } 00695 Super.Destroyed(); 00696 } 00697 //_____________________________________________________________________________ 00698 // Cheat pour mettre les logs 00699 //------------------------------------ 00700 00701 event UsedBy(Pawn user) 00702 { 00703 if (!self.bisdead) 00704 IACOntroller(controller).CHARGE_LES_LOGS=true; 00705 } 00706 00707 // ---------------------------------------------------------------------- 00708 // TestChute : renvoi si le perso peut tomber. 00709 // ---------------------------------------------------------------------- 00710 function bool TestChute() 00711 { 00712 local vector PointArrivee, PointDepart, DirectionChute; 00713 local float DistanceMax, HauteurMin; //hauteur maximum de la distance pour se jeter et la hauteur mini pour tomber 00714 local bool result; 00715 local attackpoint AP; 00716 local int i; 00717 00718 00719 DistanceMax=90; //distance max au bord 00720 HauteurMin=150; //hauteur min de chute 00721 00722 PointDepart=location+60*vect(0,0,1); 00723 //calcul a mi-chemin 00724 For(i=0;i<level.game.AttackPointList.Length;i++) 00725 { 00726 AP=attackpoint(level.game.AttackPointList[i]); 00727 if (AP.PointArriveeCrash!=none && vsize(AP.location-location)<80) 00728 { 00729 DirectionChute=normal((AP.PointArriveeCrash.location-location)*vect(1,1,0)); 00730 PointCrash=AP.PointArriveeCrash; 00731 break; 00732 } 00733 } 00734 if (PointCrash==none) //pas de crashpoint trouve 00735 DirectionChute=normal(vector(rotation)*vect(1,1,0)); 00736 PointArrivee=location-vect(0,0,1)*(78+HauteurMin)+ DirectionChute*DistanceMax*0.5*(138 +DistanceMax*0.5)/138; 00737 if (FastTrace(Pointarrivee,pointdepart)) 00738 { 00739 //log("distance < 45"); 00740 DistanceBord=DistanceMax*0.5; 00741 return true; 00742 } 00743 else 00744 { 00745 PointArrivee=location-vect(0,0,1)*(78+HauteurMin)+ DirectionChute*DistanceMax*(138+DistanceMax)/138; 00746 if (FastTrace(Pointarrivee,pointdepart)) 00747 { 00748 //log("45 < distance < 90"); 00749 DistanceBord=DistanceMax; 00750 return true; 00751 } 00752 } 00753 return false; 00754 } 00755 00756 //_____________________________________________________________________________ 00757 state dying 00758 { 00759 event Tick (float delta) 00760 { 00761 // Log(self@"Dying, PHYSICS="$Physics@"Rotation="$Rotation); 00762 super.tick(delta); 00763 if (bControleChute) 00764 { 00765 if (PointCrash!=none) 00766 velocity=200*normal((PointCrash.location-location)*vect(1,1,0)); 00767 else 00768 velocity=200*normal(vector(rotation)*vect(1,1,0)); 00769 } 00770 } 00771 00772 event Landed(vector HitNormal) 00773 { 00774 LandedSpecial(); 00775 /* 00776 finalRot = Rotation; 00777 finalRot.Roll = 0; 00778 finalRot.Pitch = 0; 00779 setRotation(finalRot); 00780 */ 00781 if (PointCrash!=none && PointCrash.bMakeCrashNoise) 00782 PlaySound(Sound'XIIIsound.PNJ__PNJCrash.PNJCrash__hCrashHard'); 00783 00784 if (OnoChute!=none) 00785 { 00786 if (Onochute.emitters[0]!=none) 00787 { 00788 OnoChute.emitters[0].InitialParticlesPerSecond=0; 00789 OnoChute.emitters[0].ParticlesPerSecond=0; 00790 } 00791 if (Onochute.emitters[1]!=none) 00792 { 00793 OnoChute.emitters[1].InitialParticlesPerSecond=0; 00794 OnoChute.emitters[1].ParticlesPerSecond=0; 00795 } 00796 OnoChute.settimer2(1.5,false); 00797 } 00798 // Log(self@"Setting Rotation"@finalRot@"from floor="$floor@"Rotation="$Rotation); 00799 if (bJeTombe) 00800 { 00801 bjetombe=false; 00802 PlayCrashOnGround(); 00803 } 00804 } 00805 00806 event touch(actor other) 00807 { 00808 local rotator finalRot; 00809 local float OldHeight; 00810 local vector X,Y,Z,W; 00811 00812 Super.Touch(other); 00813 00814 if (other.isa('watervolume')) 00815 { 00816 finalRot = Rotation; 00817 finalRot.Roll = 0; 00818 finalRot.Pitch = 0; 00819 setRotation(finalRot); 00820 SetPhysics(PHYS_falling); 00821 if (bJeTombe) 00822 { 00823 if (PointCrash!=none && PointCrash.bMakeCrashNoise) 00824 PlaySound(Sound'XIIIsound.PNJ__PNJCrash.PNJCrash__hCrashWater'); 00825 if (OnoChute!=none) 00826 { 00827 if (Onochute.emitters[0]!=none) 00828 OnoChute.emitters[0].InitialParticlesPerSecond=0; 00829 OnoChute.settimer(1.5,false); 00830 } 00831 bjetombe=false; 00832 PlayCrashOnGround(); 00833 } 00834 } 00835 } 00836 00837 function BeginState() 00838 { 00839 enable('tick'); 00840 SetTimer(2.0, false); 00841 //FRD 00842 bEnableSpineControl=false; 00843 SetBoneDirection(FIRINGBLENDBONE, rot(0,0,0), vect(0,0,0), 0.0 ); 00844 //SetPhysics(PHYS_Falling); 00845 // 00846 bInvulnerableBody = true; 00847 } 00848 00849 Begin: 00850 // velocity.z=0; 00851 if (bJeTombe) 00852 { 00853 disable('landed'); 00854 disable('touch'); 00855 bMeurtEnTombant=false; 00856 bcollideworld=false; 00857 SetPhysics(PHYS_walking); 00858 bControleChute=true; 00859 controller.focus=none; 00860 if (PointCrash!=none) 00861 { 00862 controller.focalpoint=PointCrash.location; 00863 } 00864 else 00865 controller.focalpoint=vector(rotation)*10000*vect(1,1,0)+location; 00866 PlayStartToFall(); 00867 00868 00869 //playanim('DeathDos',,0.1); 00870 sleep(0.6*(DistanceBord/90)); //grosse bidouille distancebord=DistanceMax ou DM/2 00871 SetPhysics(PHYS_Falling); 00872 enable('landed'); 00873 enable('touch'); 00874 //log("on commence a sauter"); 00875 bControleChute=false; 00876 acceleration=vect(0,0,0); 00877 if (PointCrash!=none) 00878 { 00879 //log(self$"C'est bon je peux atteindre mon point de crash"$velocity); 00880 Vect_Position=PointCrash.location-location; 00881 /*velocity=300*normal((PointArriveeCrash.location-location)*vect(1,1,0)); 00882 velocity.z=-150;*/ 00883 velocity=0.8*Vect_Position*(950)*vect(1,1,0)/(-150 + sqrt(22500 -2*950*Vect_Position.z)); 00884 velocity.z=-150; 00885 //log("vitesse horizontale "$Vsize(Vect_Position*vect(1,1,0))*950/(-150 + sqrt(22500 -2*950*Vect_Position.z))); 00886 } 00887 else 00888 { 00889 //log(self$"Je peux pas atteindre mon point de crash"); 00890 velocity=300*normal(vector(rotation)*vect(1,1,0)); 00891 velocity.z=-150; 00892 } 00893 PlayFallingFalaise(); 00894 OnoChute=Spawn(class'XIIIChuteEmiter',self); 00895 XIIIChuteEmiter(OnoChute).lastDamagedBy = PawnKiller; 00896 OnoChute.SetBase(self); 00897 sleep(0.4); 00898 bcollideworld=true; 00899 //commence de la chute 00900 00901 } 00902 Sleep(0.5); 00903 genalerte(level.game.genalerte).potemeurt(self); //genalerte doit etre present dans toute map solo 00904 bInvulnerableBody=false; 00905 00906 // ELR Added LieStill there 0.5 seconds after state beginning because we don't want the col cyl staying big a long time 00907 LieStill(); 00908 //destruction 00909 SetOwner(None); 00910 controller.Destroy(); 00911 controller = None; 00912 } 00913 00914 00915 // InitialInventory(0)=(Inventory=Class'XIII.Beretta',Count=2) 00916 00917 00918 defaultproperties 00919 { 00920 InitialAlliances(0)=(AllianceName="Player",AllianceLevel=-1.000000) 00921 InitialAlliances(1)=(AllianceName="NMI",AllianceLevel=1.000000) 00922 TempsRechercheNMI=8.000000 00923 Agressivite=0.300000 00924 TempsIdentification=2.000000 00925 DistanceAttaque=600.000000 00926 TempsVisee=1.000000 00927 StrategicPointAttraction=100 00928 TempsPasVu=1.500000 00929 bRappliqueSiAlerte=True 00930 bPasseAttScr_SiDeclenche=True 00931 OffsetTimeBetweenShots=0.250000 00932 bAlerteAmisEnCriant=True 00933 WalkingSpeed=0.296600 00934 bFouilleCadavres=True 00935 bTurnIntoAgressiveSoldier=True 00936 CodeMesh=9 00937 HearingThreshold=1500.000000 00938 SightRadius=2000.000000 00939 PeripheralVision=120.000000 00940 ControllerClass=Class'XIDPawn.IAController' 00941 Alliance="NMI" 00942 Skill=1 00943 Mesh=SkeletalMesh'XIIIPersos.XIIIM' 00944 }

End Source Code