// September 2015 // Levee Patroller / Dijk Patrouille // This source file is (c) by Deltares. This source file is open source but only available to select users. Do not redistribute without written permission of Stichting Deltares, Delft, The Netherlands. // This header has been automatically generated. //============================================================================= // GeoGameInfo // // Game start for normal gameplay // // ------------------------------------------------------------ // Created by Rui Guimaraes // © 2006, Geodelft // // Date Id Modification // 2006-03-20 gui Class created //============================================================================= class GeoGameInfo extends GameInfo; #exec OBJ LOAD FILE=Environmentsounds.uax //var GeoFeedback geoFb; //============================================================================= // Description: Mostly copied from GameInfo's PostLogin function // Called after a successful login. This is the first place // it is safe to call replicated functions on the PlayerPawn. // // Date Id Modification // 2006-03-20 gui Created //============================================================================= event PostLogin( PlayerController NewPlayer ) { local class HudClass; local class ScoreboardClass; local String SongName; local LeveeTile L; local GeoLevelDetails GLD; local DScriptedTrigger sT; local StaticMeshActor SA; local GeoPlayerController geoPC; geoPC = GeoPlayerController(NewPlayer); log("PostLogin()"); // Log player's login. if (GameStats!=None) { GameStats.ConnectEvent(NewPlayer.PlayerReplicationInfo); GameStats.GameEvent("NameChange",NewPlayer.PlayerReplicationInfo.playername,NewPlayer.PlayerReplicationInfo); } if ( !bDelayedStart && NewPlayer.Pawn == None ) // Changed by Demiurge (Runtime) { // start match, or let player enter, immediately bRestartLevel = false; // let player spawn once in levels that must be restarted after every death bKeepSamePlayerStart = true; if ( bWaitingToStartMatch ) StartMatch(); else RestartPlayer(newPlayer); bKeepSamePlayerStart = false; bRestartLevel = Default.bRestartLevel; } // Start player's music. SongName = Level.Song; if( SongName != "" && SongName != "None" ) NewPlayer.ClientSetMusic( SongName, MTRAN_Fade ); // tell client what hud and scoreboard to use if( HUDType != "" ) HudClass = class(DynamicLoadObject(HUDType, class'Class')); if( ScoreBoardType != "" ) ScoreboardClass = class(DynamicLoadObject(ScoreBoardType, class'Class')); NewPlayer.ClientSetHUD( HudClass, ScoreboardClass ); if ( NewPlayer.Pawn != None ) { NewPlayer.Pawn.ClientSetRotation(NewPlayer.Pawn.Rotation); /// Check if the debug info tips have been enabled: if (bool(Localize ("DebugInfo", "ShowTips", "GeoSimulator")) == true) { Log("Creating interaction"); NewPlayer.Player.InteractionMaster.AddInteraction("GeoWorld.DebugInfoTips", NewPlayer.Player); } } if(geoPC.geoFb==none) { geoPC.geoFb = Spawn(class'GeoFeedBack'); geoPC.geoFb.geoPC = GeoPlayerController(NewPlayer); geoPC.geoFb.openLog(); geoPC.geoFb.startLog(); ForEach AllActors( class 'LeveeTile', L ) { if(L.bActive) geoPC.geoFb.logFailure(L); } } GLD = new class'GeoLevelDetails'; if(GLD.IsRaining) { Log("It is raining, trying to play rain sound:"); sT = Spawn(class'DScriptedTrigger'); sT.Actions.insert(0, 4); sT.Actions[0] = new class'ACTION_WaitForTimer'; ACTION_WaitForTimer(sT.Actions[0]).PauseTime = 1.00 ; sT.Actions[1] = new class'ACTION_PlayLocalSound'; ACTION_PlayLocalSound(sT.Actions[1]).Sound = Sound'EnvironmentSounds.Water.regen3'; sT.Actions[2] = new class'ACTION_WaitForTimer'; ACTION_WaitForTimer(sT.Actions[2]).PauseTime = 49.00 ; sT.Actions[3] = new class'ACTION_GotoAction'; ACTION_GotoAction(sT.Actions[3]).ActionNumber = 0 ; } /// Remove clouds if requested: foreach AllActors( class 'StaticMeshActor', SA, 'cloudsky') { SA.bHidden=true; } } //============================================================================= // Description: PostNetBeginPlay; Should it be PostBeginPlay or PostNetBeginPlay? // // Date Id Modification // 2006-03-20 gui Created //============================================================================= event PostNetBeginPlay() { local GeoNotebook NTB; log("PostNetBeginPlay()"); Super.PostNetBeginPlay(); SetFailures(); SetWeather(); // Reset Notebook log("Notebook reseted"); NTB = new class'GeoNotebook'; NTB.CleanNotes(); } //============================================================================= // Description: Start weather actors according to tags // // Date Id Modification // 2006-04-20 gui Created //============================================================================= function bool SetWeather() { local class NewClass; local GeoLevelDetails GLD; local int RainType; local Actor A; GLD = new class'GeoLevelDetails'; if(GLD.IsRaining) { RainType=Rand(2); switch(RainType) { case 0: NewClass = class( DynamicLoadObject( "GeoWorld.LightRainEmitter", class'Class' ) ); break; case 1: NewClass = class( DynamicLoadObject( "GeoWorld.HeavyRainEmitter", class'Class' ) ); break; } Spawn(NewClass); } foreach AllActors( class 'Actor', A, 'RainyActor') { A.bHidden=!(GLD.IsRaining); } foreach AllActors( class 'Actor', A, 'RainySpecial') { A.bHidden=!(GLD.IsRaining); } return true; } //============================================================================= // Description: Create arrays with failure names to be initialized, the new way. // // Date Id Modification // 2007-10-15 Jln Created //============================================================================= function CreateFailureArrays() { local GeoLevelDetails GLD; local int i, j; local array FailuresToActivate, GDFailures; local array LeveeTileNames, RandomLeveeTileNames; local array LeveeTiles, RandomLeveeTiles; local LeveeTile T, temptile; local int inc, TempInt, length; local bool didmismatch; /// IS there a mismatch between requested and found failure locations? local int k; GLD = new class'GeoLevelDetails'; /// Create list of tiles: ForEach AllActors( class 'LeveeTile', T) { LeveeTiles.Insert(0,1); LeveeTileNames.Insert(0,1); LeveeTileNames[0] = T.Name; LeveeTiles[0] = T; /// Activate directly if necessary: if (T.ConfiguredFailure != FM_None) { if (T.ConfiguredFailureState == STA_Reportable) { GLD.ArrayReportableActiveFailureNames.Insert(0,1); GLD.ArrayReportableActiveFailureNames[0].FailureName = T.Name; GLD.ArrayReportableActiveFailureNames[0].MechanismType = T.ConfiguredFailure; } if (T.ConfiguredFailureState == STA_Relevant) { GLD.ArrayRelevantActiveFailureNames.Insert(0,1); GLD.ArrayRelevantActiveFailureNames[0].FailureName = T.Name; GLD.ArrayRelevantActiveFailureNames[0].MechanismType = T.ConfiguredFailure; } if (T.ConfiguredFailureState == STA_Critical) { GLD.ArrayCriticalActiveFailureNames.Insert(0,1); GLD.ArrayCriticalActiveFailureNames[0].FailureName = T.Name; GLD.ArrayCriticalActiveFailureNames[0].MechanismType = T.ConfiguredFailure; } } } GDFailures = GLD.LeveeTilesToActivate; /// Mismatch loop. while(k < 100) { k++; didmismatch = false; Log ("[CreateFailureArrays] Mismatch loop: " @ k); /// Randomize the names: RandomLeveeTileNames.Remove(0,RandomLeveeTileNames.Length); RandomLeveeTiles.Remove(0,RandomLeveeTileNames.Length); FailuresToActivate.Remove(0,FailuresToActivate.Length); Length = LeveeTileNames.Length; for(j = 0; j < Length; j++) { ///Random item: TempInt = rand(LeveeTileNames.Length); Log("Random nr: " @ TempInt @ " RandomLeveeTiles: " @ LeveeTileNames[TempInt]); /// Insert at position 0 RandomLeveeTileNames.Insert(0,1); RandomLeveeTiles.Insert(0,1); //// Get the random item RandomLeveeTileNames[0] = LeveeTileNames[TempInt]; RandomLeveeTiles[0] = LeveeTiles[TempInt]; /// Remove, or we would have it more than once: LeveeTileNames.Remove(TempInt,1); LeveeTiles.Remove(TempInt,1); } ///Copy array. From this moment the failures are random. LeveeTileNames = RandomLeveeTileNames; LeveeTiles = RandomLeveeTiles; Log("Random array length: " @ RandomLeveeTileNames.Length); Log("GDFailures count: " $ GDFailures.Length); for (i = 0; i < GDFailures.Length ; i++ ) { // fix? GDFailures[i].MaxCount = (GDFailures[i].NotSerious + GDFailures[i].Serious + GDFailures[i].VerySerious); Log(i @ "NS: " $ GDFailures[i].NotSerious @ "S: " $ GDFailures[i].Serious @ "VS: " $ GDFailures[i].VerySerious @ " max gd count: " $ GDFailures[i].MaxCount @ "sum: " @ (GDFailures[i].NotSerious + GDFailures[i].Serious + GDFailures[i].VerySerious)); // Log ("LeveeTilestoActivate: " @ GDFailures[i].MaxCount); /// Do we have to add it? if (GDFailures[i].MaxCount > 0) { /// Copy data FailuresToActivate.Insert(0,1); FailuresToActivate[0].Mechanism = GDFailures[i].Mechanism; /// If we have a specified list of failurenames (eg: exercise), use this one. Otherwise, use the random list. if (GDFailures[i].FailureNames.Length > 0) { FailuresToActivate[0].FailureNames = GDFailures[i].FailureNames; Log ("[CreateFailureArrays] Using specified failurenames"); } else { FailuresToActivate[0].FailureNames = LeveeTileNames; Log ("[CreateFailureArrays] Using random failurenames"); } FailuresToActivate[0].MaxCount = GDFailures[i].MaxCount; FailuresToActivate[0].NotSerious = GDFailures[i].NotSerious; FailuresToActivate[0].Serious = GDFailures[i].Serious; FailuresToActivate[0].VerySerious = GDFailures[i].VerySerious; Log(GDFailures[i].NotSerious); } Log(GDFailures[i].Mechanism @ " " @ GDFailures[i].MaxCount @ " " @ GDFailures[i].VerySerious @ " " @ GDFailures[i].Serious @ " " @ GDFailures[i].NotSerious ); } /// Reset level data now: GLD.ResetLevelDetails(); GLD.ArrayReportableActiveFailureNames.Remove(0, GLD.ArrayReportableActiveFailureNames.Length); GLD.ArrayRelevantActiveFailureNames.Remove(0, GLD.ArrayRelevantActiveFailureNames.Length); GLD.ArrayCriticalActiveFailureNames.Remove(0, GLD.ArrayCriticalActiveFailureNames.Length); /// Find tiles to immediatly activate: ForEach AllActors( class 'LeveeTile', T) { /// Activate directly if necessary: if (T.ConfiguredFailure != FM_None) { if (T.ConfiguredFailureState == STA_Reportable) { GLD.ArrayReportableActiveFailureNames.Insert(0,1); GLD.ArrayReportableActiveFailureNames[0].FailureName = T.Name; GLD.ArrayReportableActiveFailureNames[0].MechanismType = T.ConfiguredFailure; } if (T.ConfiguredFailureState == STA_Relevant) { GLD.ArrayRelevantActiveFailureNames.Insert(0,1); GLD.ArrayRelevantActiveFailureNames[0].FailureName = T.Name; GLD.ArrayRelevantActiveFailureNames[0].MechanismType = T.ConfiguredFailure; } if (T.ConfiguredFailureState == STA_Critical) { GLD.ArrayCriticalActiveFailureNames.Insert(0,1); GLD.ArrayCriticalActiveFailureNames[0].FailureName = T.Name; GLD.ArrayCriticalActiveFailureNames[0].MechanismType = T.ConfiguredFailure; } } } //Do it per failure type for(i = 0; i< FailuresToActivate.Length;i++) { //Add the failure names to the GeoLevelDetails Log("to activate: " @ FailuresToActivate[i].Mechanism); /// NOT SERIOUS /// Loop through all failure names, and try to find enough failures to activate. inc = 0; for (j = 0; j < FailuresToActivate[i].FailureNames.Length; j++ ) { /// Break if we have enough. Log (inc @ " - " @ FailuresToActivate[i].NotSerious); if (inc >= FailuresToActivate[i].NotSerious) break; temptile = FindTile(FailuresToActivate[i].FailureNames[j]); Log("ArrayReportableActiveFailureNames: " @ FailuresToActivate[i].FailureNames[j] @ " tile test: " @ temptile ); if ( (AlreadyInUse(FailuresToActivate[i].FailureNames[j], GLD) == false) && temptile.DoesSupport(FailuresToActivate[i].Mechanism) == true ) { GLD.ArrayReportableActiveFailureNames.Insert(0,1); GLD.ArrayReportableActiveFailureNames[0].FailureName = FailuresToActivate[i].FailureNames[j]; GLD.ArrayReportableActiveFailureNames[0].MechanismType = FailuresToActivate[i].Mechanism; inc++; Log("[CreateFailureArrays Not Serious] MECHANISM TYPE: " @ GetEnum( enum'FailingMechanisms', FailuresToActivate[i].Mechanism ) @ " " @ FailuresToActivate[i].FailureNames[j]); } } /// Notify us if there is a mismatch of expected failures and the actual: if (inc != FailuresToActivate[i].NotSerious) { Log("[CreateFailureArrays] WARNING - NotSerious failures mismatch. Expected: " @ FailuresToActivate[i].NotSerious @ " Got: " @ inc); didmismatch = true; } /// SERIOUS /// Loop through all failure names, and try to find enough failures to activate. inc = 0; for (j = 0; j < FailuresToActivate[i].FailureNames.Length; j++ ) { /// Break if we have enough. if (inc >= FailuresToActivate[i].Serious) break; temptile = FindTile(FailuresToActivate[i].FailureNames[j]); Log("ArrayRelevantActiveFailureNames: " @ FailuresToActivate[i].FailureNames[j] @ " tile test: " @ temptile ); if ( (AlreadyInUse(FailuresToActivate[i].FailureNames[j], GLD) == false) && temptile.DoesSupport(FailuresToActivate[i].Mechanism) == true ) { GLD.ArrayRelevantActiveFailureNames.Insert(0,1); GLD.ArrayRelevantActiveFailureNames[0].FailureName = FailuresToActivate[i].FailureNames[j]; GLD.ArrayRelevantActiveFailureNames[0].MechanismType = FailuresToActivate[i].Mechanism; inc++; Log("[CreateFailureArrays Serious] MECHANISM TYPE: " @ GetEnum( enum'FailingMechanisms', FailuresToActivate[i].Mechanism ) @ " " @ FailuresToActivate[i].FailureNames[j]); } } /// Notify us if there is a mismatch of expected failures and the actual: if (inc != FailuresToActivate[i].Serious) { Log("[CreateFailureArrays] WARNING - Serious failures mismatch. Expected: " @ FailuresToActivate[i].Serious @ " Got: " @ inc); didmismatch = true; } /// VERY SERIOUS /// Loop through all failure names, and try to find enough failures to activate. inc = 0; for (j = 0; j < FailuresToActivate[i].FailureNames.Length; j++ ) { Log("Counter: " @ inc @ " of " @ FailuresToActivate[i].VerySerious); /// Break if we have enough. if (inc >= FailuresToActivate[i].VerySerious) break; temptile = FindTile(FailuresToActivate[i].FailureNames[j]); Log("ArrayCriticalActiveFailureNames: " @ FailuresToActivate[i].FailureNames[j] @ " tile test: " @ temptile ); if ( (AlreadyInUse(FailuresToActivate[i].FailureNames[j], GLD) == false) && temptile.DoesSupport(FailuresToActivate[i].Mechanism) == true ) { GLD.ArrayCriticalActiveFailureNames.Insert(0,1); GLD.ArrayCriticalActiveFailureNames[0].FailureName = FailuresToActivate[i].FailureNames[j]; GLD.ArrayCriticalActiveFailureNames[0].MechanismType = FailuresToActivate[i].Mechanism; inc++; Log("[CreateFailureArrays Very Serious] MECHANISM TYPE: " @ GetEnum( enum'FailingMechanisms', FailuresToActivate[i].Mechanism ) @ " " @ FailuresToActivate[i].FailureNames[j]); } } /// Notify us if there is a mismatch of expected failures and the actual: if (inc != FailuresToActivate[i].VerySerious) { Log("[CreateFailureArrays] WARNING - Very Serious failures mismatch. Expected: " @ FailuresToActivate[i].VerySerious @ " Got: " @ inc); didmismatch = true; } } /// Break if we did not have any problems if (didmismatch == false) break; } /// Store config! GLD.SaveConfig(); } /// Try to find the tile: function LeveeTile FindTile(name tile) { local LeveeTile T; /// Find tiles to immediatly activate: ForEach AllActors( class 'LeveeTile', T) { if (T.Name == tile) { return T; } } return None; } function bool AlreadyInUse(name failurename, GeoLevelDetails GLD) { local bool inuse; local int i; inuse = false; ///Log("Already in use?" @ failurename); i = 0; while( i < GLD.ArrayCriticalActiveFailureNames.Length) { if ( GLD.ArrayCriticalActiveFailureNames[i].FailureName == failurename) { Log("YES - Already in use (critical) " @ failurename @ " - " @ GetEnum( enum'FailingMechanisms', GLD.ArrayCriticalActiveFailureNames[i].MechanismType) ); return true; } i++; } i = 0; while( i < GLD.ArrayReportableActiveFailureNames.Length) { if ( GLD.ArrayReportableActiveFailureNames[i].FailureName == failurename) { Log("YES - Already in use (reportable) " @ failurename @ " - " @ GetEnum( enum'FailingMechanisms', GLD.ArrayReportableActiveFailureNames[i].MechanismType) ); return true; } i++; } i = 0; while( i < GLD.ArrayRelevantActiveFailureNames.Length) { if ( GLD.ArrayRelevantActiveFailureNames[i].FailureName == failurename) { Log("YES - Already in use (relevant) " @ failurename @ " - " @ GetEnum( enum'FailingMechanisms', GLD.ArrayRelevantActiveFailureNames[i].MechanismType) ); return true; } i++; } //Log("No, so use it: " @ failurename); return false; } //============================================================================= // Description: Start failures and Non Reportables // // Date Id Modification // 2006-04-20 gui Created // 2007-01-15 Zmr Made it also activate Non Reportables //============================================================================= function bool SetFailures() { //local Failure TempFailure; // local NonReportable TempNonReportable; local LeveeTile A; local GeoLevelDetails GLD; local int i; local name TempName; local bool bIsActive; local LeveeTile TempTileFailure; local GeoEnums.FailingMechanisms mechanism; local NonReportable TempNonReportable; /// Create failure arrays: CreateFailureArrays(); GLD = new class'GeoLevelDetails'; Log("SetFailures"); Log("[GeoGameInfo.SetFailures Critical count ] " @ GLD.ArrayCriticalActiveFailureNames.Length); Log("[GeoGameInfo.SetFailures Relevant count ] " @ GLD.ArrayRelevantActiveFailureNames.Length); Log("[GeoGameInfo.SetFailures Reportable count] " @ GLD.ArrayReportableActiveFailureNames.Length); ForEach AllActors( class 'LeveeTile', A, ) { bIsActive=false; ///New failure tile object - Almar 27-9-2007: TempTileFailure=A; //LeveeTile(A); TempName=A.Name; for(i=0; i 1) { Log("[GeoGameInfo] - Activating Non reportable: " @ TempNonReportable); TempNonReportable.ActivateNonReportables(true); } else { TempNonReportable.ActivateNonReportables(false); Log("[GeoGameInfo] - Deactivating Non reportable: " @ TempNonReportable); } } return true; } //============================================================================= // Description: // // Date Id Modification // 2006-04-13 gui Created //============================================================================= defaultproperties { bDelayedStart=false PlayerControllerClassName="GeoSimulator.GeoPlayerController" PlayerControllerClass=None HUDType="GeoSimulator.GeoHUD" ScoreBoardType="GeoSimulator.GeoScoreboard" DefaultPlayerName="Levee Patroller" GameName="Levee Patroller" }