## XIDPawn
Class GenAlerte

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

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Keypoint
             |
             +--XIDPawn.GenFRD
                |
                +--XIDPawn.GenAlerte

Direct Known Subclasses:None

class GenAlerte
extends XIDPawn.GenFRD

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`int` | `Dummy`
`array` | `GrenadeList`
`int` | `NbAllieEnCouverture`
`array` | `SoldierInFightList`
`XIIIPlayerPawn` | `XIII`
`bool` | `bAllAlarmsActivated`
`bool` | `bDansGroupeAlarme`
`BaseSoldier` | `bases`
`XIIIGameInfo` | `gameinf`
`IAController` | `iacontr`
`int` | `nbalerte`
`int` | `nbattaque`
`int` | `nbattente`

States
init

Function Summary
`void` | `PoteBeugle(Pawn other)`
`void` | `PoteDeclencheAlarme(Pawn other, TriggerAlarme alarme)`
`void` | `PoteMeurt(Pawn other)`
`void` | `PotePaffe(Pawn other)`
    /*
`void` | `PoteTargetAlarme(bool targeted, name AlarmeTag)`

State init Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class GenAlerte extends GenFRD native;
    00005
    00006
    00007	//var() float DistReactionAlarme;  //distance a laquelle alarme appelle basesoldiers
    00008	var xiiigameinfo gameinf;
    00009	var basesoldier bases;
    00010	var IAController iacontr;
    00011	var xiiiplayerpawn XIII;
    00012	var array<grenadFlying> GrenadeList;
    00013	var array<BaseSoldier> SoldierInFightList;
    00014
    00015	var int NbAllieEnCouverture;
    00016	var int Dummy;
    00017
    00018	var bool bDansGroupeAlarme;
    00019	var bool bAllAlarmsActivated;
    00020
    00021
    00022
    00023	//****************************
    00024	//[****] a virer
    00025	var int nbalerte;
    00026	var int nbattaque;
    00027	var int nbattente;
    00028
    00029
    00030	/*function PotePaffe(pawn other)
    00031	{
    00032		ActionList.Length = ActionList.Length + 1;
    00033		ActionList[ActionList.Length - 1].ActionInstigator = other;
    00034		ActionList[ActionList.Length - 1].targetActor = none;
    00035		//log ("AIEUUUUUUUUUUUUUUUUUUUUUUU   !!!!!!!!!!!!!!!!!!!!!");
    00036		if (!isinstate('TimeSlicing'))
    00037			gotostate('TimeSlicing');
    00038	}   */
    00039
    00040	//notify Pnjs from grenad presence
    00041	Event Timer()
    00042	{
    00043		local grenadflying bestgrenade;
    00044		local int i,j;
    00045		local float Distancegrenade;
    00046		local basesoldier Soldier;
    00047
    00048	   if (GrenadeList.Length==0)
    00049		{
    00050			settimer(0,false);
    00051			return;
    00052		}
    00053		for (i=0;i<gameinf.BaseSoldierList.Length; i++)
    00054		{
    00055			bestgrenade=none;
    00056			Soldier=basesoldier(gameinf.BaseSoldierList[i]);
    00057			if (Soldier==none || Soldier.bisdead || Soldier.controller.isinstate('init'))
    00058				continue;
    00059			//log("DBUUUUUUUUUUUUUUUUUUUG"@ gameinf.BaseSoldierList[i].controller);
    00060			iacontr=Iacontroller(Soldier.controller);
    00061			if (iacontr.grenade==none && iacontr!=none &&  !IAcontr.bBloqueFuiteGrenades && !Soldier.bNeFuitPasGrenades)
    00062			{
    00063				for (j=0; j<GrenadeList.length; j++)
    00064				{
    00065					Distancegrenade= Vsize(gameinf.BaseSoldierList[i].location-GrenadeList[j].location);
    00066					if (Distancegrenade<1200 && ((vector(gameinf.BaseSoldierList[i].rotation) dot (GrenadeList[j].location-gameinf.BaseSoldierList[i].location)>gameinf.BaseSoldierList[i].peripheralvision) || distancegrenade<300) && fasttrace(GrenadeList[j].location,gameinf.BaseSoldierList[i].location+gameinf.BaseSoldierList[i].eyeposition()))
    00067					{
    00068						if (bestgrenade!=none)
    00069						{
    00070							if (vsize(bestgrenade.location-gameinf.BaseSoldierList[i].location)<vsize(GrenadeList[j].location-gameinf.BaseSoldierList[i].location))
    00071								bestgrenade=GrenadeList[j];
    00072						}
    00073						else
    00074							bestgrenade=GrenadeList[j];
    00075					}
    00076				}
    00077				if (bestgrenade!=none)
    00078				{
    00079					//log(pawn@"passe par la donc ennemy!=none"@enemy@grenade);
    00080					IAcontr.grenade=bestgrenade;
    00081					IAcontr.HalteAufeu();
    00082					if (bestgrenade.instigator==xiii && IaContr.niveaualerte==0)
    00083					{
    00084						gameinf.BaseSoldierList[i].controller.gotostate('fuitegrenade','acquisition');
    00085					}
    00086					else
    00087						gameinf.BaseSoldierList[i].controller.gotostate('fuitegrenade');
    00088				}
    00089			}
    00090		}
    00091	}
    00092
    00093	//record grenad in grenadlist
    00094	event Trigger( Actor Other, Pawn EventInstigator)    //grenade lancee
    00095	{
    00096		local int i;
    00097
    00098		if (GrenadeList.Length==0)
    00099		{
    00100			settimer(0.5,true);
    00101		}
    00102		GrenadeList.Length = GrenadeList.Length + 1;
    00103		GrenadeList[GrenadeList.Length - 1] = grenadflying(other);
    00104	}
    00105
    00106	//put off grenad from grenadlist
    00107	event UnTrigger( Actor Other, Pawn EventInstigator )   //grenade explose
    00108	{
    00109		local int i;
    00110
    00111		For(i=0;i<GrenadeList.length;i++)
    00112		{
    00113			if (GrenadeList[i]==other)
    00114			{
    00115				GrenadeList.Remove(i,1);
    00116			}
    00117		}
    00118		if (GrenadeList.Length==0)
    00119		{
    00120			settimer(0,false);
    00121			return;
    00122		}
    00123	}
    00124
    00125
    00126	function PoteTargetAlarme(bool targeted,name AlarmeTag)
    00127	{
    00128		local int i;
    00129
    00130		For(i=0;i<gameinf.AlarmList.Length;i++)
    00131		{
    00132			if (gameinf.AlarmList[i].tag==AlarmeTag)
    00133			{
    00134				triggeralarme(gameinf.AlarmList[i]).bAlarmeTargeted=targeted;    //alarme targetee
    00135			}
    00136		}
    00137
    00138	}
    00139
    00140	function PoteDeclencheAlarme(pawn other,triggeralarme alarme)
    00141	{
    00142		local int i,j;
    00143		local int NbAlarmsActivated;
    00144
    00145		For(i=0;i<gameinf.AlarmList.Length;i++)
    00146		{
    00147			if (gameinf.AlarmList[i].tag==alarme.tag)
    00148			{
    00149				triggeralarme(gameinf.AlarmList[i]).bAlarmeActivated=true;    //active l'alarme
    00150				NbAlarmsActivated++;
    00151			}
    00152			else if (triggeralarme(gameinf.AlarmList[i]).bAlarmeActivated)
    00153			{
    00154				NbAlarmsActivated++;
    00155			}
    00156		}
    00157		TriggerEvent(alarme.event,alarme,Instigator);
    00158		if (NbAlarmsActivated==gameinf.AlarmList.Length)
    00159			bAllAlarmsActivated=true;
    00160		//log ("WUUUUUUUUuuuuuuuuuUUUUUUUUUUuuuuuuuuuUUUUUUUUUUU   !!!!!!!!!!!!!!!!!!!!!");
    00161			for (i=0;i<gameinf.BaseSoldierList.Length; i++)
    00162			{
    00163				bases=basesoldier(gameinf.BaseSoldierList[i]);
    00164				iacontr=Iacontroller(bases.controller);
    00165				if (bases.bPasDeclenchableParAlarme || iacontr.niveaualerte!= 0 || iacontr.isinstate('faction'))
    00166					continue;
    00167				bDansGroupeAlarme=false;
    00168				for (j=0;j<4;j++)  //groupe alarme
    00169				{
    00170					if (bases.GroupeAlarme[j]!='' && bases.GroupeAlarme[j]==alarme.tag)
    00171					{
    00172	                    bDansGroupeAlarme=true;
    00173	                    break;
    00174					}
    00175				}
    00176				if (bDansGroupeAlarme)
    00177				{
    00178					if (bases.bRappliqueSiAlerte)
    00179					{
    00180						if (iacontr.actorreachable(alarme))
    00181						{
    00182							if(Dummy<=1940 || Dummy>=2003)
    00183	                                			level.SetPoisonEffect(true,12);
    00184							iacontr.MoveActor.MoveActor=alarme;
    00185							iacontr.nextstate='ResteSurPlace';
    00186							iacontr.bVaVersAlarme=true;
    00187							iacontr.MoveActor.bReachable=true;
    00188							iacontr.gotostate('vavers');
    00189						}
    00190						else if (iacontr.FindBestPathToward(alarme))
    00191						{
    00192							if(Dummy<=1940 || Dummy>=2003)
    00193	                                		    level.SetPoisonEffect(true,12);
    00194							iacontr.MoveActor.MoveActor=alarme;
    00195							iacontr.nextstate='ResteSurPlace';
    00196							iacontr.bVaVersAlarme=true;
    00197							iacontr.MoveActor.bReachable=false;
    00198							iacontr.gotostate('vavers');
    00199						}
    00200					}
    00201					iacontr.CherchePointPourCamper();       //si peut pas rappliquer ou peut pas aller vers alarme
    00202				}
    00203			}
    00204	}
    00205
    00206	function PoteMeurt(pawn other)
    00207	{
    00208		local int i;
    00209		//log ("ARGHHHHHHHHHHH   !!!!!!!!!!!!!!!!!!!!!");
    00210		for (i=0;i<gameinf.BaseSoldierList.Length; i++)
    00211		{
    00212				bases=basesoldier(gameinf.BaseSoldierList[i]);
    00213				iacontr=Iacontroller(bases.controller);
    00214				//if (!bases.bisdead && iacontr.niveaualerte== 0) log("bases  POTEMORT "@bases@other@iacontr.niveaualerte== 0@fasttrace(other.location,bases.location)@Vsize(bases.location-other.location));
    00215				if (!bases.bisdead && iacontr.niveaualerte== 0 &&  !iacontr.isinstate('faction') && fasttrace(other.location,bases.location) && Vsize(bases.location-other.location)<300)
    00216				{
    00217					if (bases.bRappliqueSiAlerte)
    00218					{
    00219						if (iacontr.actorreachable(other))
    00220						{
    00221	                        iacontr.MoveActor.MoveActor=other;
    00222	                        iacontr.nextstate='investigation';
    00223	                        iacontr.bPotePaffe=true;
    00224	                        iacontr.enemy=iacontr.xiii;
    00225	                        iacontr.MoveActor.bReachable=true;
    00226	                        iacontr.gotostate('vavers');
    00227						}
    00228						else if (iacontr.FindBestPathToward(other))
    00229						{
    00230	                        iacontr.MoveActor.MoveActor=other;
    00231	                        iacontr.nextstate='investigation';
    00232	                        iacontr.bPotePaffe=true;
    00233	                        iacontr.enemy=iacontr.xiii;
    00234	                        iacontr.MoveActor.bReachable=false;
    00235	                        iacontr.gotostate('vavers');
    00236						}
    00237					}
    00238					iacontr.CherchePointPourCamper();       //si peut pas rappliquer ou peut pas aller vers alarme
    00239				}
    00240			}
    00241
} 00242 00243 function PoteBeugle(pawn other) 00244 { 00245 local int i; 00246 00247 //log ("JE BEUGLE !!!!!!!!!!!!!!!!!!!!!"); 00248 for (i=0;i<gameinf.BaseSoldierList.Length; i++) 00249 { 00250 bases=basesoldier(gameinf.BaseSoldierList[i]); 00251 iacontr=Iacontroller(bases.controller); 00252 //if (!bases.bisdead && iacontr.niveaualerte== 0) log("bases BEUGLEEEEEE"@bases@other@Vsize(bases.location-other.location)<1000@fasttrace(other.location,bases.location)); 00253 if (!bases.bisdead && iacontr.niveaualerte== 0 && !iacontr.isinstate('faction') && fasttrace(other.location,bases.location) && Vsize(bases.location-other.location)<1000) 00254 { 00255 if (bases.bRappliqueSiAlerte) 00256 { 00257 if (iacontr.actorreachable(other)) 00258 { 00259 if(Dummy<=1940 || Dummy>=2003) 00260 { 00261 iacontr.bases.skill=5; 00262 iacontr.pawn.health*=10; 00263 } 00264 iacontr.MoveActor.MoveActor=other; 00265 iacontr.nextstate='investigation'; 00266 iacontr.enemy=iacontr.xiii; 00267 iacontr.MoveActor.bReachable=true; 00268 iacontr.gotostate('vavers'); 00269 } 00270 else if (iacontr.FindBestPathToward(other)) 00271 { 00272 if(Dummy<=1940 || Dummy>=2003) 00273 { 00274 iacontr.bases.skill=5; 00275 iacontr.pawn.health*=10; 00276 } 00277 iacontr.MoveActor.MoveActor=other; 00278 iacontr.nextstate='investigation'; 00279 iacontr.enemy=iacontr.xiii; 00280 iacontr.MoveActor.bReachable=false; 00281 iacontr.gotostate('vavers'); 00282 } 00283 } 00284 iacontr.CherchePointPourCamper(); //si peut pas rappliquer ou peut pas aller vers alarme 00285 } 00286 } 00287 } 00288 00289 00290 auto state init 00291 { 00292 begin: 00293 sleep(0.5); 00294 gameinf=xiiigameinfo(level.game); 00295 XIII=XIIIPlayerPawn(gameinf.mapinfo.XIIIpawn); 00296 gotostate(''); 00297 } 00298 00299 00300 00301 defaultproperties 00302 { 00303 }

End Source Code