## XIDMaps
Class Usa01

source: C:\XIII\XIDMaps\Classes\USA01.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Info
             |
             +--XIII.MapInfo
                |
                +--XIDMaps.Map12_PortUSA
                   |
                   +--XIDMaps.Usa01

Direct Known Subclasses:None

class Usa01
extends XIDMaps.Map12_PortUSA

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

Variables
`Chronometre` | `Chrono`
`name` | `PrevState`
`bBombEventSent,` | `bBombInPosition`
`int` | `eNbSeconds`
`fHauteur,` | `fTime`
`sound` | `hBombReady`
`sound` | `hCountDown`
`rotator` | `rRotatorInit`
`vector` | `vPosInit`

States
Waiting, WaitForEndGame

Function Summary
`void` | `FirstFrame()`
    //_____________________________________________________________________________
`void` | `SetGoalComplete(int N)`
    //_____________________________________________________________________________

State Waiting Function Summary

State WaitForEndGame Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class Usa01 extends Map12_PortUSA;
    00005
    00006	var(Usa01SetUp) Usa01DecoBombe BombeDeco;
    00007	var(Usa01SetUp) float fBombDelay;
    00008	var(Usa01SetUp) float fTempsAvantCamera;
    00009	var(Usa01SetUp) float fTempsCamera;
    00010	var(Usa01SetUp) float fDelayBeforeEndGame;
    00011	var(Usa01SetUp) actor CibleExplosion;
    00012	var(Usa01SetUp) int eHauteurCamera;
    00013	var(Usa01SetUp) XIIIGoalTrigger BombInteraction;
    00014	var float fBombEventDelay, fHauteur, fTime;
    00015	var int eNbSeconds;
    00016	var bool bBombEventSent, bBombInPosition;
    00017	var chronometre Chrono;
    00018	var sound hBombReady;
    00019	var sound hCountDown;
    00020	var rotator rRotatorInit;
    00021	var vector vPosInit;
    00022	var name PrevState;
    00023
    00024	//_____________________________________________________________________________
    00025	event ParseDynamicLoading(LevelInfo MyLI)
    00026	{
    00027	    Log("ParseDynamicLoading Actor="$self);
    00028	    MyLI.ForcedClasses[MyLI.ForcedClasses.Length] = class'Usa01Bombe';
    00029	    class'Usa01Bombe'.Static.StaticParseDynamicLoading(MyLI);
    00030	    MyLI.ForcedClasses[MyLI.ForcedClasses.Length] = class'Chronometre';
    00031	    class'Chronometre'.Static.StaticParseDynamicLoading(MyLI);
    00032	    Super.ParseDynamicLoading(MyLI);
    00033	}
    00034
    00035	//_____________________________________________________________________________
    00036	function FirstFrame()
    00037	{
    00038	    local inventory Inv;
    00039
    00040	    Super.FirstFrame();
    00041
    00042		// on regarde si le joueur possede deja une bombe
    00043		Inv = XIIIPawn.FindInventoryKind( 'Usa01Bombe' );
    00044		if ( Inv == none )
    00045		{
    00046			Inv = GiveSomething(class'Usa01Bombe', XIIIPawn);
    00047		}
    00048		Usa01Bombe(Inv).BombInteraction = BombInteraction;
    00049
    00050		// on desactive le lieu de posage de bombe
    00051		BombeDeco.bHidden = true;
    00052		BombeDeco.RefreshDisplaying();
    00053		BombInteraction.bInteractive = false;
    00054
    00055	}
    00056
    00057	//_____________________________________________________________________________
    00058	event Timer2()
    00059	{
    00060	    XIIIPawn.PlaySound(hCountDown);
    00061	    fBombEventDelay += 1.0;
    00062	    if ( !bBombEventSent && (fBombEventDelay > fBombDelay-2.5) )
    00063	    {
    00064	      bBombEventSent = true;
    00065	      TriggerEvent('BombNearExplo', none, none);
    00066	    }
    00067		// prise en main de la camera au bout de x secondes
    00068		eNbSeconds ++;
    00069		if (eNbSeconds == (fBombDelay - fTempsAvantCamera))
    00070		{
    00071			PrevState = XIIIController.GetStateName();
    00072			//SetTimer( 0, false );
    00073			if ( XIIIController.bWeaponMode )
    00074			{
    00075				XIIIController.OldWeap = XIIIPawn.Weapon.InventoryGroup;
    00076				XIIIPawn.Weapon.PutDown();
    00077			}
    00078			else
    00079			{
    00080				XIIIController.OldItem = XIIIItems(XIIIPawn.SelectedItem);
    00081				XIIIController.OldItem.PutDown();
    00082			}
    00083			XIIIController.bWeaponBlock = true;
    00084			rRotatorInit = XIIIController.Rotation;
    00085			vPosInit = XIIIController.Pawn.Location;
    00086			if ( !XIIIPawn.bIsDead && !Level.Game.bGameEnded)
    00087			{
    00088				XIIIController.GotoState('NoControl');
    00089				GotoState('Waiting');
    00090			}
    00091		}
    00092	}
    00093
    00094	//_____________________________________________________________________________
    00095	function SetGoalComplete(int N)
    00096	{
    00097		local Usa01Bombe Bomb;
    00098
    00099		switch (N)
    00100		{
    00101			//case 99: // bomb placed
    00102			case 97:
    00103					log(self@"---> DEMARRAGE CHRONO, BOMBE AMORCEE");
    00104					BombeDeco.StaticMesh = StaticMesh'MeshArmesPickup.BombeMagnet';
    00105					BombeDeco.RefreshDisplaying();
    00106					Bomb = Usa01Bombe(XIIIPawn.FindInventoryType(class'Usa01Bombe'));
    00107					if (Bomb != none )
    00108						Bomb.UsedUp();
    00109					// Give chrono
    00110					TriggerEvent('GenPlong', self, XIIIPawn);
    00111					Chrono = Chronometre(GiveSomething(class'Chronometre', XIIIPawn));
    00112					XIIIPawn.PlaySound(hBombReady);
    00113					if (Chrono != none)
    00114						Chrono.ReSetTimer(fBombDelay);
    00115					XIIIPawn.PlaySound(hCountDown);
    00116					BombInteraction.bInteractive = false;
    00117					SetTimer2(1.0, true);
    00118				//}
    00119				break;
    00120			case 98: // Chrono over
    00121				// if pawn underwater, mission failed because bomb damage player
    00122				SetTimer2(0.0,false);
    00123				BombeDeco.Destroy();
    00124				if (Chrono != none)
    00125					Chrono.Destroy();
    00126				if ( XIIIPawn.PhysicsVolume.bWaterVolume )
    00127				{
    00128					GotoState('WaitForEndGame');
    00129				}
    00130				// else mission continue
    00131				break;
    00132			case 0:
    00133				SetPrimaryGoal(1);
    00134				BombeDeco.bHidden = false;
    00135				BombeDeco.RefreshDisplaying();
    00136				BombInteraction.bInteractive = true;
    00137				break;
    00138			case 1:
    00139				SetPrimaryGoal(2);
    00140				break;
    00141		}
    00142
    00143		Super.SetGoalcomplete(N);
    00144	}
    00145
    00146	State WaitForEndGame
    00147	{
    00148		event Beginstate()
    00149		{
    00150			SetTimer(fDelayBeforeEndGame, false);
    00151		}
    00152
    00153		event Timer()
    00154		{
    00155			Level.Game.EndGame( XIIIController.PlayerReplicationInfo, "GoalIncomplete" );
    00156		}
    00157	}
    00158
    00159	State Waiting
    00160	{
    00161		event BeginState()
    00162		{
    00163			XIIIPawn.SetPhysics(PHYS_None);
    00164		}
    00165
    00166		event Tick(float dt)
    00167		{
    00168			local rotator r;
    00169			local vector v;
    00170
    00171			fTime += dt;
    00172			if ( XIIIPawn.bIsDead || Level.Game.bGameEnded )
    00173			{
    00174				SetTimer2(0.0,false);
    00175
    00176	/*			if ( !bBombEventSent )
    00177				{
    00178				  bBombEventSent = true;
    00179				  TriggerEvent('BombNearExplo', none, none);
    00180				}*/
    00181
    00182				GotoState( '' );
    00183			}
    00184
    00185			if (fTime < fTempsCamera)
    00186			{
    00187				r = rotator(CibleExplosion.location - XIIIController.location);
    00188				r -= XIIIController.Rotation;
    00189				r.Yaw= ((r.Yaw+32768)&65535)-32768;
    00190				r.Roll= ((r.Roll+32768)&65535)-32768;
    00191				r.Pitch= ((r.Pitch+32768)&65535)-32768;
    00192
    00193				XIIIController.SetRotation(r*0.03+XIIIController.Rotation);
    00194
    00195				fHauteur += 50*dt;
    00196				fHauteur = fMin(fHauteur,eHauteurCamera);
    00197				XIIIPawn.SetLocation( vPosInit + fHauteur*vect(0,0,1));
    00198			}
    00199			else
    00200			{
    00201				fHauteur -= 50*dt;
    00202				fHauteur = fMax(fHauteur,0);
    00203				XIIIPawn.SetLocation( vPosInit + fHauteur*vect(0,0,1));
    00204				if (fHauteur == 0)
    00205				{
    00206					XIIIController.GotoState(PrevState);
    00207					XIIIController.bWeaponBlock = false;
    00208					if ( XIIIController.bWeaponMode )
    00209					{
    00210						XIIIController.Switchweapon( XIIIController.OldWeap );
    00211						XIIIPawn.ChangedWeapon();
    00212					}
    00213					else
    00214					{
    00215						if ( XIIIController.OldItem != none )
    00216						{
    00217							XIIIController.cNextItem();
    00218							XIIIPawn.PendingItem = XIIIController.OldItem;
    00219						}
    00220						else
    00221						{
    00222							XIIIController.bWaitForWeaponMode = true;
    00223							XIIIController.bWeaponMode = true;
    00224							XIIIController.Switchweapon( 0 );
    00225						}
    00226						XIIIPawn.ChangedWeapon();
    00227					}
    00228					GotoState('');
    00229				}
    00230			}
    00231		}
    00232	}
    00233
    00234
    00235
    00236
    00237	defaultproperties
    00238	{
    00239
fBombDelay=40.000000 00240 fTempsAvantCamera=3.000000 00241 fTempsCamera=9.000000 00242 fDelayBeforeEndGame=7.000000 00243 eHauteurCamera=150 00244 hBombReady=Sound'XIIIsound.Items__BombFireSub.BombFireSub__hBombFire' 00245 hCountDown=Sound'XIIIsound.Interface__USA01_CountDown.USA01_CountDown__hPlayCounter' 00246 iLoadSpecificValue=142 00247 }

End Source Code