XIDPawn
Class GenNMI

source: C:\XIII\XIDPawn\Classes\gennmi.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Keypoint
         |
         +--XIDPawn.GenFRD
            |
            +--XIDPawn.GenNMI
Direct Known Subclasses:None

class GenNMI
extends XIDPawn.GenFRD

//============================================================================= // GenNMI. //=============================================================================
Variables
 GenNMI GenEnnemi
           le perso declenche passe direct en attaquescriptee
 int NbNMIActifs
 int NbNMIGen
 int NbNMIGenere
           le perso declenche passe direct en attaquescriptee
 int NbNMIMax
 int NbNMIPresents
           le perso declenche passe direct en attaquescriptee
 name Numtimbre
           le perso declenche passe direct en attaquescriptee
 int PV_NMI
 vector PointSpawn
 BaseSoldier SpawnActor
           le perso declenche passe direct en attaquescriptee
 vector SpawnLocation
           le perso declenche passe direct en attaquescriptee
 float TimeBetweenGen
 XIIIPlayerPawn XIII
           le perso declenche passe direct en attaquescriptee
 bool bDestroySoldiersWhenDestroyed
           detruit les autres baseoldiers quand il est detruit
 bool bDestroyedAtEndOfGen
           se detruit a la fin de la generation
 bool bGenerationCamouflee
           ne genere que si perso peut pas voir le GENNMI
 bool bPasseAttScr_ApresGen
           le perso declenche passe direct en attaquescriptee
 bool bWaitAllDeadToDestroy
           attend que tous les persos generes soient morts
 XIIIGameInfo gameinf
           le perso declenche passe direct en attaquescriptee

States
PauseGenese, AttendMortNMIs

Function Summary
 void AssignePV()
     
//------------------------------------------------
// GENESE
//------------------------------------------------
 void Timer()
 void Trigger(Actor Other, Pawn EventInstigator)
     
//------------------------------------------------
// TRIGGER: Fonction Trigger declenchee par detectionvolume
//------------------------------------------------
 void UnNMIenMoins()
 void endstate()


State PauseGenese Function Summary


State AttendMortNMIs Function Summary
 void UnNMIenMoins()



Source Code


00001	//=============================================================================
00002	// GenNMI.
00003	//=============================================================================
00004	class GenNMI extends GenFRD;
00005	
00006	struct InventoryItem  {
00007		var() class<Inventory> Inventory;
00008		var() int              Count;
00009	};
00010	
00011	struct InitialAllianceInfo  {
00012		var() Name  AllianceName;
00013		var() float AllianceLevel;
00014	};
00015	//-----------------------------
00016	var() int NbNMIMax;
00017	var() float TimeBetweenGen;
00018	var() int NbNMIGen;
00019	var() int NbNMIActifs;
00020	var() int PV_NMI;
00021	var() vector PointSpawn;
00022	var() bool bDestroyedAtEndOfGen;// se detruit a la fin de la generation
00023	var() bool bGenerationCamouflee; //ne genere que si perso peut pas voir le GENNMI
00024	var() bool bWaitAllDeadToDestroy; // attend que tous les persos generes soient morts
00025	var() bool bDestroySoldiersWhenDestroyed; //detruit les autres baseoldiers quand il est detruit
00026	var() bool bPasseAttScr_ApresGen; //le perso declenche passe direct en attaquescriptee
00027	
00028	//pour se detruire et declencher un event
00029	
00030	//-----------------------------
00031	
00032	var(AI) float PeripheralVision;
00033	var(AI) float SightRadius;
00034	var(AI) float HearingThreshold;
00035	var(AI) bool     bLOSHearing;
00036	var(AI) bool     bSameZoneHearing;
00037	var(AI) bool     bAdjacentZoneHearing;
00038	var(AI) bool     bMuffledHearing;
00039	var(AI) bool     bAroundCornerHearing;
00040	
00041	
00042	//-----------------------------
00043	var(Alliances) name Alliance;
00044	var(Inventory) InventoryItem InitialInventory[8];
00045	var(Alliances) InitialAllianceInfo InitialAlliances[4];
00046	var(BaseSoldier) name Bases_Event;
00047	var(BaseSoldier) name Bases_Tag;
00048	var(BaseSoldier) int skill;
00049	var(BaseSoldier) float TempsIdentification;
00050	var(BaseSoldier) name Order;
00051	var(BaseSoldier) float ProbaDeclencheAlarme;
00052	var(BaseSoldier) float PourcErrance;
00053	var(BaseSoldier) float TempsRechercheNMI;
00054	var(BaseSoldier) float Agressivite;
00055	var(BaseSoldier) float TempsVisee;
00056	var(BaseSoldier) int NumReseauPropre;
00057	var(BaseSoldier) int NumReseauAttaque;
00058	var(Basesoldier) float TempsPasVu;
00059	var(basesoldier) float DistanceAttaque;
00060	var(basesoldier) bool bRappliqueSiAlerte;
00061	var(BaseSoldier) bool bAlerte; //permet de dire que le perso est en etat alerte<->declenche par trigger
00062	var(BaseSoldier) int StrategicPointAttraction; // 0 a 100 : proportion d'utilisation des strategicpoints
00063	
00064	var(BaseSoldier_Advanced) bool bPasseAttScr_SiDeclenche;
00065	var(BaseSoldier_Advanced) float OffsetTimeBetweenShots; //
00066	var(BaseSoldier_Advanced) float WalkingSpeed;
00067	var(BaseSoldier_Advanced) bool bNeVoitPasCadavre; // detecte un cadavre ou pas
00068	var(BaseSoldier_Advanced) bool bPasDeclenchableParAlarme; //ben heu
00069	var(BaseSoldier_Advanced) bool bMeurtEnTombant; //bah quand on le bute il chute
00070	var(BaseSoldier_Advanced) bool bTirPasLorsReplacement; //En attaque se repositionne sans regarder xiii (ni tirer)
00071	var(baseSoldier_Advanced) WanderingVolume MyWanderingVolume; //volume d'errance
00072	var(BaseSoldier_Advanced) bool bPatrolWithWalkSearchAnim;  // fait sa premiere patrouille en anim de marche suspicieuse
00073	var(BaseSoldier_Advanced) bool bAlerteAmisEnCriant; //crie pour avertir potes
00074	var(BaseSoldier_Advanced) bool bForceSoldierInUniverse; //the basesoldier is in the Universe Zone.
00075	var(baseSoldier_Advanced) Array<MeshAnimation>	SpecificAnimations;
00076	VAR(baseSoldier_Advanced) bool bSpawnInAir; //si personnage genere en l'air
00077	
00078	
00079	var(Cine_Behavior) Pawn.EGameOver GameOver;    // Do shooting this guy will make pbs ?
00080	
00081	var(pawn) bool bDestroyWhenDead;      // i should be destroyed wxhen dead to optimize
00082	var(pawn) float DelayBeforeDestroyWhenDead;
00083	var(pawn) float DistanceBeforeDestroyWhenDead;
00084	var(pawn) bool bCauseEventOnStun;
00085	var(pawn) bool bCanBeGrabbed;         // to allow grab of myself like Corpse/Prisonner
00086	var(pawn) bool bStunnedIfJumpedOn;    // to allow dogs not being stunned by jumping on their head (too easy)
00087	
00088	
00089	var(sound) string TimbresPossibles;
00090	var(sound) int CodeMesh;
00091	var(Sound) int SoundStepCategory;
00092	var name Numtimbre;
00093	
00094	
00095	
00096	
00097	
00098	// GenNMI
00099	var GenNMI GenEnnemi;
00100	
00101	//*------------------------------*
00102	var vector SpawnLocation;
00103	var basesoldier SpawnActor;
00104	var int NbNMIGenere;
00105	var int NbNMIPresents;
00106	
00107	
00108	var xiiiplayerpawn XIII;
00109	var Xiiigameinfo gameinf;
00110	
00111	//_____________________________________________________________________________
00112	event ParseDynamicLoading(LevelInfo MyLI)
00113	{
00114	    local int i;
00115	
00116	    Log("ParseDynamicLoading Actor="$self);
00117	    for (i=0; i<8; i++)
00118	    {
00119			if ( InitialInventory[i].Inventory != none )
00120			{
00121				MyLI.ForcedClasses[MyLI.ForcedClasses.Length] = InitialInventory[i].Inventory;
00122				(InitialInventory[i].Inventory).Static.StaticParseDynamicLoading(MyLI);
00123			}
00124	    }
00125	}
00126	
00127	//------------------------------------------------
00128	// TRIGGER: Fonction Trigger declenchee par detectionvolume
00129	//------------------------------------------------
00130	function Trigger( actor Other, pawn EventInstigator )
00131	{
00132		//NbNMIPresents=0;
00133		if (NbNMIGenere==0)
00134			gotostate('genese');
00135		else if (((NbNMIGenere<NbNMIMax) || NbNMIMAX==-1) && NbNMIPresents<NbNMIActifs)
00136			gotostate('genese','suitegeneration');
00137	}
00138	
00139	function UnNMIenMoins()
00140	{
00141	}
00142	
00143	
00144	//------------------------------------------------
00145	// GENESE
00146	//------------------------------------------------
00147	state() genese
00148	{
00149		function AssignePV()
00150		{
00151			SpawnActor.Health = PV_NMI;
00152		}
00153	
00154		function Timer()
00155		{
00156			local int i,j;
00157			local bool result;
00158	
00159			if ((NbNMIGenere<NbNMIMax) || (NbNMIMAX==-1))
00160			{
00161				for (i=0;i<NbNMIGen;i++)
00162				{
00163					if (NbNMIPresents<NbNMIActifs)
00164					{
00165						if (PointSpawn!=vect(0,0,0))
00166							SpawnLocation=PointSpawn;
00167						else
00168							SpawnLocation=self.location + vect(0,0,1)*78+ i*90*((-1)**i)*vect(1,1,0);
00169						result=false;
00170						if (!bGenerationCamouflee || !FastTrace(SpawnLocation,XIII.location+ XIII.eyeposition()) || ((XIII.location-SpawnLocation) dot vector(XIII.rotation))>0)
00171						{
00172							SpawnActor=spawn(class'BaseSoldier',self,,SpawnLocation);
00173							if (SpawnActor == none)
00174							{
00175								SpawnLocation=self.location+vect(0,0,1)*78-i*90*((-1)**i)*vect(1,1,0);
00176								SpawnActor=spawn(class'BaseSoldier',self,,SpawnLocation);
00177								if (SpawnActor == none)
00178								{
00179									result=false;
00180									//log(self$"ca merde je peux pas spawner, j'ai pas la place");
00181								}
00182								else
00183									result=true;
00184							}
00185							else
00186							{
00187								result=true;
00188							}
00189						}
00190	
00191						if (result)
00192						{
00193							NbNMIGenere++;
00194							NbNMIPresents++;
00195							if ((SpawnActor.ControllerClass != None) && SpawnActor.Controller == None)
00196								SpawnActor.Controller = spawn(SpawnActor.ControllerClass);
00197							if (SpawnActor.Controller != None )
00198								SpawnActor.Controller.Possess(SpawnActor);
00199							gameinf.MapInfo.GeneratedPawn(self,spawnactor);
00200							gameinf.BaseSoldierList.Length=gameinf.BaseSoldierList.Length+1;
00201							gameinf.BaseSoldierList[gameinf.BaseSoldierList.Length-1]=SpawnActor;
00202							instigator=spawnactor;
00203							SpawnActor.GenEnnemi=self;
00204							// initialisation des variables
00205							//ai
00206	                  SpawnActor.GameOver=GameOver;
00207							SpawnActor.bStunnedIfJumpedOn=bStunnedIfJumpedOn;
00208							SpawnActor.bCanBeGrabbed=bCanBeGrabbed;
00209							SpawnActor.bLOSHearing=bLOSHearing;
00210							SpawnActor.bSameZoneHearing=bSameZoneHearing;
00211							SpawnActor.bAdjacentZoneHearing=bAdjacentZoneHearing;
00212							SpawnActor.bMuffledHearing=bMuffledHearing;
00213							SpawnActor.bAroundCornerHearing=bAroundCornerHearing;
00214							SpawnActor.SightRadius=sightradius;
00215							SpawnActor.HearingThreshold=hearingthreshold;
00216							SpawnActor.PeripheralVision=PeripheralVision;
00217							SpawnActor.Alliance=Alliance;
00218							//basesoldier
00219							for (j=0;j<8;j++)
00220							{
00221									SpawnActor.InitialInventory[j].Inventory=InitialInventory[j].Inventory;
00222									SpawnActor.InitialInventory[j].count=InitialInventory[j].count;
00223							}
00224							for (j=0;j<4;j++)
00225							{
00226								if (InitialAlliances[j].AllianceName!='')
00227								{
00228									SpawnActor.InitialAlliances[j].AllianceName=InitialAlliances[j].AllianceName;
00229									SpawnActor.InitialAlliances[j].AllianceLevel=InitialAlliances[j].AllianceLevel;
00230								}
00231							}
00232							SpawnActor.TempsIdentification=TempsIdentification;
00233							SpawnActor.skill=skill;
00234							SpawnActor.PourcErrance=PourcErrance;
00235							SpawnActor.WalkingSpeed=WalkingSpeed;
00236							SpawnActor.bNeVoitPasCadavre=bNeVoitPasCadavre;
00237							SpawnActor.bPasDeclenchableParAlarme=bPasDeclenchableParAlarme;
00238							SpawnActor.SetCollisionSize(CollisionRadius, CollisionHeight);
00239							SpawnActor.TempsRechercheNMI=TempsRechercheNMI;
00240							SpawnActor.Agressivite=Agressivite;
00241							SpawnActor.TempsVisee=TempsVisee;
00242							SpawnActor.DistanceAttaque=DistanceAttaque;
00243							SpawnActor.bMeurtEnTombant=bMeurtEnTombant;
00244							SpawnActor.StrategicPointAttraction=StrategicPointAttraction;
00245							SpawnActor.NumReseauPropre=NumReseauPropre;
00246							SpawnActor.bAlerte=bAlerte;
00247							SpawnActor.event=Bases_event;
00248							SpawnActor.tag=Bases_Tag;
00249							spawnActor.bcancrouch=true;
00250							SpawnActor.NumReseauAttaque=NumReseauAttaque;
00251							SpawnActor.TempsPasVu=TempsPasVu;
00252							SpawnActor.OffsetTimeBetweenShots=OffsetTimeBetweenShots;
00253							SpawnActor.ProbaDeclencheAlarme=ProbaDeclencheAlarme;
00254							SpawnActor.bBasesGenere=true;
00255							SpawnActor.bSpawnInAir=bSpawnInAir;
00256							SpawnActor.MyWanderingVolume=MyWanderingVolume;
00257							SpawnActor.bAlerteAmisEnCriant=bAlerteAmisEnCriant;
00258							SpawnActor.bRappliqueSiAlerte=bRappliqueSiAlerte;
00259							SpawnActor.bPasseAttScr_SiDeclenche=bPasseAttScr_SiDeclenche;
00260							SpawnActor.bPasseAttScr_ApresGen=bPasseAttScr_ApresGen;
00261							if ( bForceSoldierInUniverse )
00262							{
00263								SpawnActor.bForceInUniverse = bForceSoldierInUniverse;
00264								SpawnActor.RefreshDisplaying();
00265							}
00266							if (!bActorShadows && SpawnActor.Shadow != none)
00267							{
00268					        SpawnActor.Shadow.Destroy();
00269						     SpawnActor.Shadow = none;
00270							}
00271							SpawnActor.bCauseEventOnStun=bCauseEventOnStun;
00272							//son
00273							j=InStr(TimbresPossibles,";");
00274							if (j>1)
00275							{
00276								Switch(byte(mid(TimbresPossibles,rand(j))))
00277								{
00278	                          case 1 : SpawnActor.NumeroTimbre=timbre_1;  break;
00279	                          case 2 : SpawnActor.NumeroTimbre=timbre_2;  break;
00280	                          case 3 : SpawnActor.NumeroTimbre=timbre_3;  break;
00281								}
00282							}
00283							SpawnActor.bHasPosition=bHasPosition;
00284							SpawnActor.bHasRollOff=bHasRollOff;
00285							SpawnActor.PanCoeff=PanCoeff;
00286							SpawnActor.CodeMesh=CodeMesh;
00287							SpawnActor.SoundStepCategory=SoundStepCategory;
00288							SpawnActor.SaturationDistance=SaturationDistance;
00289		 					SpawnActor.StabilisationDistance=StabilisationDistance;
00290		 					SpawnActor.StabilisationVolume=StabilisationVolume;
00291		 					SpawnActor.VoicesSaturationDistance=VoicesSaturationDistance;
00292		 					SpawnActor.VoicesStabilisationDistance=VoicesStabilisationDistance;
00293		 					SpawnActor.VoicesStabilisationVolume=VoicesStabilisationVolume;
00294							//assigne PVs
00295							AssignePV();
00296							SpawnActor.controller.focalpoint=SpawnActor.location+vector(self.rotation);
00297							//BaseSoldier(SpawnActor).setCollisionSize(collisionradius,collisionheight);
00298							if (Mesh!=none)
00299							{
00300								SpawnActor.mesh=mesh;
00301							}
00302							if (SpecificAnimations.Length>0)
00303							{
00304								for (j=0;j<SpecificAnimations.Length;j++)
00305									SpawnActor.LinkSkelAnim (SpecificAnimations[j]);
00306							}
00307							if (Skins.length>0 && Skins[0]!=none)
00308							{
00309								SpawnActor.Skins[0]=Skins[0];
00310	
00311							}
00312							if (order!='')
00313							{
00314								SpawnActor.order=order;
00315							}
00316							SpawnActor.bDestroyWhenDead=bDestroyWhenDead;
00317							SpawnActor.DelayBeforeDestroyWhenDead=DelayBeforeDestroyWhenDead;
00318							SpawnActor.DistanceBeforeDestroyWhenDead=DistanceBeforeDestroyWhenDead;
00319						}
00320	            }
00321	            else
00322	            {
00323	                settimer(0,false);
00324	                gotostate('PauseGenese');
00325	                break;
00326	            }
00327	        }
00328	     }
00329	     else
00330	     {
00331	         gotostate('AttendMortNMIs');
00332	     }
00333	  }
00334	
00335	  function endstate()
00336	  {
00337	  }
00338	
00339	begin:
00340	  //log(self$"GENERE BASESOLDIER");
00341	  sleep(0.04);
00342	  gameinf=xiiigameinfo(level.game);
00343	  XIII=XIIIPlayerpawn(gameinf.mapinfo.XIIIpawn);
00344	  if (XIII==none)
00345	  {
00346		  log(self@"********************* ATTENTION LA VARIABLE XIII N'A PAS ETE INITIALISEE");
00347		  goto('begin');
00348	  }
00349	suitegeneration:
00350	  timer();
00351	  sleep(0.04);
00352	  settimer(TimeBetweenGen,true);
00353	}
00354	
00355	state AttendMortNMIs
00356	{
00357		function UnNMIenMoins()
00358		{
00359			if (!bWaitAllDeadToDestroy)
00360			{
00361				if (bDestroyedAtEndOfGen)
00362					destroy();
00363			}
00364			else if (NbNMIPresents<=0)
00365			{
00366	            destroy();
00367			}
00368		}
00369	begin:
00370		UnNMIenMoins();
00371	}
00372	
00373	State PauseGenese
00374	{
00375	}
00376	
00377	event Destroyed()
00378	{
00379	    local int index;
00380		local int i;
00381		local pawn PersoAVirer;
00382		local IACOntroller PersoAVirerController;
00383	
00384		TriggerEvent(Event, Self, none);
00385	    if (!bDestroySoldiersWhenDestroyed)
00386			return;
00387		//vire perso de la BaseSoldierList et le detruit
00388	    for (Index = 0; Index < level.game.BaseSoldierList.Length; Index++)
00389	    {
00390			if (basesoldier(level.game.BaseSoldierList[Index]).GenEnnemi == self )
00391			{
00392				PersoAVirer=level.game.BaseSoldierList[Index];
00393				PersoAVirerController=IACOntroller(PersoAVirer.controller);
00394				If (PersoAVirerController==none || PersoAVirerController.XIII==none)
00395					continue;
00396				for (i = 0; i < gameinf.BaseSoldierList.Length; i++)
00397				{
00398					if (gameinf.BaseSoldierList[i] == PersoAVirer )
00399					{
00400						gameinf.BaseSoldierList.Remove(i,1);
00401						break;
00402					}
00403				}
00404				if (!PersoAVirerController.XIII.Controller.CanSee(PersoAVirer)
00405	          && (PersoAVirer!= PersoAVirerController.XIII.LHand.pOnShoulder ) )
00406					PersoAVirer.destroy();
00407			}
00408	    }
00409	}
00410	
00411	//		InitialInventory(0)=(Inventory=Class'XIII.Beretta',Count=1)
00412	
00413	
00414	defaultproperties
00415	{
00416	     NbNMIMax=10
00417	     TimeBetweenGen=4.000000
00418	     NbNMIGen=1
00419	     NbNMIActifs=2
00420	     PV_NMI=150
00421	     bPasseAttScr_ApresGen=True
00422	     PeripheralVision=120.000000
00423	     SightRadius=2000.000000
00424	     HearingThreshold=1500.000000
00425	     Alliance="NMI"
00426	     InitialAlliances(0)=(AllianceName="Player",AllianceLevel=-1.000000)
00427	     InitialAlliances(1)=(AllianceName="NMI",AllianceLevel=1.000000)
00428	     Skill=1
00429	     TempsIdentification=2.000000
00430	     TempsRechercheNMI=3.000000
00431	     Agressivite=0.300000
00432	     TempsVisee=1.000000
00433	     DistanceAttaque=600.000000
00434	     bRappliqueSiAlerte=True
00435	     StrategicPointAttraction=100
00436	     OffsetTimeBetweenShots=0.250000
00437	     WalkingSpeed=0.300000
00438	     bAlerteAmisEnCriant=True
00439	     bCanBeGrabbed=True
00440	     TimbresPossibles="123;"
00441	     bActorShadows=True
00442	     CollisionRadius=34.000000
00443	     CollisionHeight=78.000000
00444	     bDirectional=True
00445	}

End Source Code