// 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. //============================================================================= // GeoPlayerController // Started using RTPlayerController And ExampleController (UDN) // // Includes funtion to put marker down // Use for console commands // // ------------------------------------------------------------ // Created by Rui Guimaraes // © 2006, Geodelft // // Date Id Modification // 2006-09-13 gui Corrected problem of having several markers close by // 2006-09-13 gui When placing markers uses default value. Action are done in TakeAction function // 2006-09-16 gui Pause options in menus // 2006-09-22 bas Added support for warningmessages and picking up the phone // 2006-09-22 bas PickUpPhone is deprecated, now makes use of MakeCallInventory() // 2006-09-27 The Moved calculation of score from GeoScoreboard to GeoPlayerController // 2006-10-02 The Removed SCORE_INDEX_SIGNALCHANGES and SCORE_INDEX_NOBREACHBONUS // 2006-10-03 The Moved percentage and evaluation determination from GeoScoreboard to GeoPlayerController // 2006-10-03 The Implemented check on range for GeoSizes properties // 2006-10-03 The Implemented multi point scores per item // 2006-10-04 The Adapted scoring to score reports only after action center is called // 2006-10-04 gui GameOver added // 2006-10-05 The Implemented STA_Failed in GeoStates // 2006-10-05 The Implemented EndScore setting // 2006-10-05 The Implemented scoring for assessments // 2006-10-06 gui Corrected steps for EndScore // 2006-10-09 gui Check if end by all steps taken // 2006-10-09 gui start conversation // 2006-10-24 The Formatted code // 2006-10-25 The Implemented fraction threshold for report scoring // 2006-10-25 The Prefixed log messages with function name // 2006-10-26 The Implemented EndScore; if the final score is made no new // score will be calculated, so the user cannot improve the // score anymore // 2006-11-01 bas Fixed timing mechanism for WarningMessages // 2006-11-03 The Fixed assessment evaluation in CalculateScore // 2006-11-13 zmr if bIsgameOver used for actioncenterstartend and other wmsg wont be displsyed. // 2006-12-04 zmr Added event SetInitialState() and exec function SetName( coerce string S) // 2006-12-12 bas Player can only place red markers +- 10m from eachother. // 2006-12-13 Bas Added dialog when player tries to place a marker near another // Added bGameEndingCall // 2006-12-13 gui Be able to cancel placemente of marker // Added repetion of help menu for placing red marker to close // 2007-06-10 gui Added function to call notepad with 'N' key //============================================================================= class GeoPlayerController extends PlayerController DependsOn(SignalReport) config(GeoUser); const CReportScoreFractionThreshold = 0.7; // Begin of constants also defined in GeoScoreboard and MenuScore const SCORE_INDEX_FAILURES = 0; const SCORE_INDEX_LOCATIONS = 1; const SCORE_INDEX_SIGNALS = 2; const SCORE_INDEX_REPORTS = 3; const SCORE_INDEX_ASSESSMENTS = 4; const SCORE_INDEX_DIAGNOSES = 5; const SCORE_INDEX_MEASURES = 6; const SCORE_INDEX_COUNT = 7; // End of constants also defined in GeoScoreboard and MenuScore const POINTS_FAILURES = 10; const POINTS_LOCATIONS = 1; const POINTS_SIGNALS = 5; const POINTS_REPORTS = 1; const POINTS_ASSESSMENTS = 2; const POINTS_DIAGNOSES = 5; const POINTS_MEASURES = 5; // const POINTS_NOBREACHBONUS = 25; const EVALUATION_LIMIT1 = 55; const EVALUATION_LIMIT2 = 70; const EVALUATION_LIMIT3 = 86; const EVALUATION_LIMIT4 = 100; var int ScorePossible; // Total possible player score var int ScorePlayer; // Total player score var int ScorePercentage; // Total player score in percentage var string EvaluationText; // Total player score in text var bool IsAllowedTakeMeasures; var bool IsAllowedMakeDiagnoses; var bool IsAllowedAssessment; var bool IsBreachOccurred; var bool IsBreachPossible; var bool bIsGameOver; // Is game over var bool bIsEndScore; // Score is not updated anymore /// Used for a hack: var name nTempName; var string ScoreEvaluationAText, NL_ScoreEvaluationAText, EN_ScoreEvaluationAText; var string ScoreEvaluationBText, NL_ScoreEvaluationBText, EN_ScoreEvaluationBText; var string ScoreEvaluationCText, NL_ScoreEvaluationCText, EN_ScoreEvaluationCText; var string ScoreEvaluationDText, NL_ScoreEvaluationDText, EN_ScoreEvaluationDText; var string ScoreEvaluationEText, NL_ScoreEvaluationEText, EN_ScoreEvaluationEText; var GeoLevelDetails GeoLD; struct ScoreInfo { var int UserCount; // how often did a user do something, not used to calculate the score yet... the UserCount for Assessment is not yet set right. var int CorrectCount; var int MaxCount; var int SingleScore; var int Score; var int MaxScore; }; var array ScoreArray; // The ScoreArray contains the detailed scoring struct TempLevelConfig { /// Tiles to activate after bringing up the level: (set from MenuLevelOptions / Stored in config) var array LeveeTilesToActivate; var bool IsRaining; var bool TakeMeasures; var bool MakeDiagnoses; var bool IsCompleteExercise; var int CurrentLevelScenarioNumber; // Used for loading screen image and for in game MAPS var material CurrentLevelImage; var string DutchDesc; var string EnglishDesc; }; struct FailureStateInfo{ var name FailureName; var GeoEnums.GeoStates FailureState; var GeoEnums.GeoStates CurrentState; var string NL_MechanismName; var string EN_MechanismName; var LocationNameSign MapLocationSign; var int ScoreLocation; var int ScoreLocationMax; var int ScoreReport; var int ScoreReportMax; var int ScoreAssessment; var int ScoreAssessmentMax; var int ScoreDiagnosis; var int ScoreDiagnosisMax; var int ScoreMeasure; var int ScoreMeasureMax; var int ScoreTotal; var int ScoreTotalMax; }; var array FailureArray; // The FailureArray contains the scoring data per failure and the failure properties // The failure properties are determined in InitFailureData and FillFailureData // The scores are determined in CalculateScore var globalconfig bool Dutch; // Is always set to true in GeoPlayerController Intro. When one want to make it always english set the variable to false there or when one want the game to start in the language it was ended with just comment that line var globalconfig String DutchName, EnglishName; var globalconfig String DetailSetting; var int PlacementOfMarkerXY, PlacementOfMarkerZ; // To get the right place where to put marker down var bool PlacingMarker; var bool bInMenu; var RedMarker NearByMarker; var YellowMarker NearByYellowMarker, PreviousYellowMarker, MovingMarker; var Signal NewSignal; // temporary signal to work in and save to marker later var bool bCreatedNewSignalReport; // used by menus: is there already a SignalReport created for NewSignal (never create more than one)? var int EditIndex; // index of NewSignal in marker's signal-array; var array Messages; // keep track of warning messages (state_warning) var WarningMessage wMsg; // current Message (the one being 'handled', the // one being called about, the one that shouldn't be paused) var int wMsgIndex; // the index in array Messages corresponding to wMsg var bool bMovingToWarning; // player got a warning message and should now be moving to corresponding marker var bool bRememberWarning; // warning is to remind the player to check up on a previously reported case var bool bCorrectionWarning; // warning is to remind the player to correct observations or assesment and call again for approval var bool bShowedHelpRedMarker; var bool bGameStartingCall, bGameEndingCall; var array CloseRedMarkers, CloseYellowMarkers; // also used to remember the index in this array of the last edited signal var enum ReportingModes { MODE_CreatingNewObservation, MODE_EditingFirstReport, MODE_EditingLaterReport, MODE_AddingNewReport, MODE_None } ReportingMode; var enum MkTypes { MK_Red, MK_Yellow } MarkerType; replication { reliable if(Role < ROLE_Authority) Fly, Walk, ToggleFlyWalk; } var GeoPlayerController StoredGPC; var GhostMarker TemporaryMarker; var int ingameTimer; // number of seconds elapsed var bool updateTimer; // whether GeoHud should update the timer -bas var bool showTimer; // whether timer should be shown on canvas var int TimeInStart, TimeToEndIfOnlyNotSerious, TimeToEndGame; var array timedSoundObjects; //Feedback var var GeoFeedback geoFb; //feebback settings var var globalconfig int FBtype; var globalconfig string FBlocation; var globalconfig string FBport; /// Was the gameover invoked by the player? var bool PlayerInvokedQuit; var TcpLinkClient mytcplink; var globalconfig string hash_ui; // Game version as received by server. var globalconfig string version; var globalconfig bool issignedin; var string receiveddatastring; // List of all received scenario names: var Array scenarionames; var Array scenariogld; // Session ID as received from the server. We match this with our own calculated session. var globalconfig string SessionID; // build id, sowe can finally see if we share the same game! var globalconfig int buildid; delegate SuccesCall( string id); delegate FailCall(); delegate ScenarioSuccesCall(); function LoginSucces( string id ) { // Hide buttons: issignedin = true; } function LoginFailure( ) { // Inform of failure. issignedin = false; } function LoginUser(string username, string password, GeoPlayerController controller) { // Removed for OS version. } function LoginHash() { // Removed for OS version. } function GetScenarios() { // Removed for OS version. } function ScenarioSucces( ) { // Hide buttons: // Log("ScenarioSuccess"); } function ScenarioFailure( ) { // Inform of failure. // Log("ScenarioFailure"); } function ReceiveArrayClosed(string messagetype, array text) { local array comps; local int i; local string tempscenario; local string tempname; local bool readingscenario; local string scenarionum; local string raining; local string diag; local string measures; local string line; local string nldesc; local string endesc; local array LeveeTilesToActivate; local TempLevelConfig GLD; Log("ReceiveArrayClosed"); readingscenario = false; if (messagetype == "scenarios") { // Loop through all received lines: for (i=0;i> " $ len(line) @ line); if (line ~= "[Scenario]") { // Already reading a scenario? Then we store the current data. if (readingscenario == true) { GLD.LeveeTilesToActivate = LeveeTilesToActivate; // Reset LeveeTilesToActivate.Length = 0; GLD.IsRaining = bool(raining); GLD.TakeMeasures = bool(measures); GLD.MakeDiagnoses = bool(diag); GLD.IsCompleteExercise = false; GLD.CurrentLevelScenarioNumber = int(scenarionum); GLD.DutchDesc = nldesc; GLD.EnglishDesc = endesc; if (GLD.CurrentLevelScenarioNumber == 4) GLD.CurrentLevelImage = Material'GeoDelft.MapPreview.Level4screenshot'; if (GLD.CurrentLevelScenarioNumber == 2) GLD.CurrentLevelImage = Material'GeoDelft.MapPreview.Level2screenshot'; if (GLD.CurrentLevelScenarioNumber == 1) GLD.CurrentLevelImage = Material'GeoDelft.MapPreview.Level1screenshot'; //;GLD.SaveConfig(); scenariogld.length = scenariogld.length + 1; scenariogld[scenariogld.length - 1] = GLD; Log("Store current: " $ tempname); } readingscenario = true; tempname = text[i+1]; // Name is first scenarionum = text[i+2]; // Scenario num raining = text[i+3]; // Raining? diag = text[i+4]; // Allowed to diagnose measures = text[i+5]; // Allowed to take measures? nldesc = text[i+6]; // nl description endesc = text[i+7]; // en description Log("tempname: " $ tempname); Log("scenarionum: " $ scenarionum); Log("raining: " $ raining); Log("diag: " $ diag); Log("tempname: " $ tempname); Log("measures: " $ measures); Log("nldesc: " $ nldesc); Log("endesc: " $ endesc); // Add to array. scenarionames.length = scenarionames.length + 1; scenarionames[scenarionames.length -1] = tempname; i = i + 7; } // Reading scenario. if (readingscenario == true) { // Format: // LeveeTile1,failure,seriousness Split2(line, ",", comps, true); // We need 3 items: if (comps.length == 3) { // Insert a new item into our levee failure array: LeveeTilesToActivate.Insert(0,1); LeveeTilesToActivate[0].FailureNames.Length = 1; LeveeTilesToActivate[0].FailureNames[0] = GetName(comps[0]); LeveeTilesToActivate[0].MaxCount = 1; LeveeTilesToActivate[0].Mechanism = GetFailureFromString(comps[1]); Log(LeveeTilesToActivate[0].FailureNames[0] @ " - " @ LeveeTilesToActivate[0].Mechanism); // Seriousness: LeveeTilesToActivate[0].VerySerious = 0; LeveeTilesToActivate[0].Serious =0; LeveeTilesToActivate[0].NotSerious = 0; // Toggle seriousness if (comps[2] == "0") LeveeTilesToActivate[0].NotSerious = 1; if (comps[2] == "1") LeveeTilesToActivate[0].Serious = 1; if (comps[2] == "2") LeveeTilesToActivate[0].VerySerious = 1; Log("Failure: " $ comps[0] $ ", type: " $ comps[1] $ ", serious: " $ comps[2]); } } } // Final scenario: Log("Scenario: " $ tempscenario); // Already reading a scenario? Then we store the current data. if (readingscenario == true) { GLD.LeveeTilesToActivate = LeveeTilesToActivate; GLD.IsRaining = bool(raining); GLD.TakeMeasures = bool(measures); GLD.MakeDiagnoses = bool(diag); GLD.IsCompleteExercise = false; GLD.CurrentLevelScenarioNumber = int(scenarionum); GLD.DutchDesc = nldesc; GLD.EnglishDesc = endesc; if (GLD.CurrentLevelScenarioNumber == 4) GLD.CurrentLevelImage = Material'GeoDelft.MapPreview.Level4screenshot'; if (GLD.CurrentLevelScenarioNumber == 2) GLD.CurrentLevelImage = Material'GeoDelft.MapPreview.Level2screenshot'; if (GLD.CurrentLevelScenarioNumber == 1) GLD.CurrentLevelImage = Material'GeoDelft.MapPreview.Level1screenshot'; //GLD.SaveConfig(); scenariogld.length = scenariogld.length + 1; scenariogld[scenariogld.length - 1] = GLD; Log("Store current: " $ tempname); } ScenarioSuccesCall(); } } function GeoEnums.FailingMechanisms GetFailureFromString(string str) { str = Caps(str); if (str == "FM_PIPING") return FM_Piping; if (str == "FM_MACRO") return FM_Macro; if (str == "FM_MICRO") return FM_Micro; if (str == "FM_EROSIONINNER") return FM_ErosionInner; if (str == "FM_EROSIONINNERMICRO") return FM_ErosionInnerMicro; if (str == "FM_EROSIONOUTERFLOATINGWASTE") return FM_ErosionOuterFloatingWaste; if (str == "FM_EROSIONOUTERRIPRAP") return FM_ErosionOuterRipRap; if (str == "FM_MICROTUTORIAL") return FM_MicroTutorial; if (str == "FM_WATERQUALITY") return FM_WaterQuality; return FM_NONE; } /// Kind of a hack to be able to create dynamic names for the various triggers. function name GetName(string NameString) { SetPropertyText("nTempName", NameString); return nTempName; } static final function int Split2(coerce string src, string delim, out array parts, optional bool ignoreEmpty, optional string quotechar) { local string temp; Parts.Remove(0, Parts.Length); if (delim == "" || Src == "" ) return 0; while (src != "") { temp = StrShift(src, delim, quotechar); if (temp == "") { if (!ignoreEmpty) { parts.length = parts.length+1; parts[parts.length-1] = temp; } } else { parts.length = parts.length+1; parts[parts.length-1] = temp; } } return parts.length; } static final function string StrShift(out string line, string delim, optional string quotechar) { local int delimpos, quotepos; local string result; if ( quotechar != "" && Left(line, Len(quotechar)) == quotechar ) { do { quotepos = InstrFrom(line, quotechar, quotepos + 1); } until (quotepos == -1 || quotepos + Len(quotechar) == Len(line) || Mid(line, quotepos + len(quotechar), len(delim)) == delim); } if ( quotepos != -1 ) { delimpos = InstrFrom(line, delim, quotepos); } else { delimpos = Instr(line, delim); } if (delimpos == -1) { result = line; line = ""; } else { result = Left(line,delimpos); line = Mid(line,delimpos+len(delim)); } if ( quotechar != "" && Left(result, Len(quotechar)) == quotechar ) { result = Mid(result, Len(quotechar), Len(result)-(Len(quotechar)*2)); } return result; } // InStr starting from an offset static final function int InStrFrom(coerce string StrText, coerce string StrPart, optional int OffsetStart) { local int OffsetPart; OffsetPart = InStr(Mid(StrText, OffsetStart), StrPart); if (OffsetPart >= 0) OffsetPart += OffsetStart; return OffsetPart; } function ReceiveClosed(string messagetype, string text) { // Removed for OS version. } function ReceivedData(AssociativeArray aa) { // Removed for OS version. } //============================================================================= // Initializes the sound object array with all GeoTimedSoundObjects in the game. // // Date Id Modification // 2006-11-01 Wsl Created this function //============================================================================= function InitTimedSounds() { local GeoTimedSoundObject SoundObj; // put all GeoTimedSoundObjects in the game into the array foreach AllActors(class'GeoTimedSoundObject', SoundObj) { timedSoundObjects.insert(0, 1); timedSoundObjects[0] = SoundObj; } } /// Enables forced login mode. exec function ForceLogin() { SetName("GeneriekeSpeler"); } //============================================================================= // ShowMenu created to be able to open score instead of MidGameMenu // Date Id Modification // 2007-07-01 gui Created function //============================================================================= exec function ShowMenu() { // Pause if not already if(Level.Pauser == None && Level.NetMode == NM_StandAlone) SetPause(true); StopForceFeedback(); // Open menu if (!bIsGameOver) { ClientOpenMenu(MidGameMenuClass); } else { ClientOpenMenu("GeoSimulator.MenuScore"); } } //============================================================================= // Date Id Modification // 2006-12-04 Zmr Created //============================================================================= event SetInitialState() { //log("GeoPlayerController.PostBeginPlay"); Super.PostBeginPlay(); if(dutch) { SetName(DutchName); }else { SetName(EnglishName); } LoginHash(); } exec function LoadDroogte() { ConsoleCommand("OPEN Scenario2DGDroog.urt"); } //============================================================================= // Date Id Modification // /// jln - 27-03-2009 Open test menu //============================================================================= exec function OpenFeedbackMenu() { ClientOpenMenu("GeoSimulator.MenuEndGameFeedback"); } //============================================================================= // Date Id Modification // 2007-10-24 Jln Trying to export a failure. //============================================================================= exec function ExportFailure( coerce name S) { local FailureExporter exporter; //log("Exporting: " @ s); exporter = Spawn(class'FailureExporter'); exporter.ExportFailure(s); exporter.Destroy(); } //============================================================================= // Date Id Modification // 2007-10-24 Jln Trying to export all failures ;) //============================================================================= exec function ExportAllFailures() { local Failure F; ForEach AllActors( class'Failure', F) { ExportFailure(F.name); } } exec function ExportTiles() { local Leveetile F; ForEach AllActors( class'LeveeTile', F) { Log("Tile " $ F.Name $ ", (" $ F.Location.x $ "," $ F.Location.y $ "," $ F.Location.z $ ") Type: " @ GetEnum( enum'FailingMechanisms', F.Mechanism) @ " State: " @ GetEnum( enum'GeoStates', F.CurrentState) ); } } //============================================================================= // Date Id Modification // 2006-10-09 gui Created // 2007-09-28 Jln Modified to support LeveeTile. //============================================================================= function StartEndGameTimer() { local bool bShouldEnd; //local Failure F; local LeveeTile L; switch ingameTimer { case TimeInStart: bGameStartingCall=false; break; case TimeToEndIfOnlyNotSerious: bShouldEnd=true; /* /// For reference // ForEach AllActors(class'Failure',F,) { if(F.bRelevant) { if(F.Mechanism != FM_ErosionOuterRipRap) { bShouldEnd=false; }else if(F.bCritical) { bShouldEnd=false; } } } */ ForEach AllActors(class'LeveeTile',L,) { if(L.bRelevant) { if(L.Mechanism != FM_ErosionOuterRipRap) { bShouldEnd=false; }else if(L.bCritical) { bShouldEnd=false; } } } if(bShouldEnd) { GameOver(true); } break; case TimeToEndGame: GameOver(true); break; default: break; } } function int getFBtype() { return FBtype; } function string getFBlocation() { return FBlocation; } function int getFBport() { return int(FBport); } exec function setFeedback( coerce int t, coerce string loc, coerce string pt) { FBtype = t; FBlocation = loc; FBport = pt; saveConfig(); //Log("setFeedback: " + t + ", " + loc + ", " + pt); } //============================================================================= // Date Id Modification // 2006-12-04 Zmr Overloaded this function to save the player name //============================================================================= exec function SetName( coerce string S) { Super.SetName(S); // donderdag 9 februari 2012: Removed this, as it is annoying to support with the login system. // if(dutch) // { DutchName = S; // }else // { EnglishName = S; // } SaveConfig(); } //============================================================================= // Date Id Modification // 2006-10-09 gui Created //============================================================================= function SetFailureStable(RedMarker TempMarker) { local LeveeTile TempFailure; TempFailure = (TempMarker.LTile); if(TempFailure!=None) { Log(TempFailure @ "is now stable!"); TempFailure.bIsSetStable=true; //GeoGameInfo(Level.Game).geoFb.logFailureState(TempFailure); } else { Log("The SetFailureStable function could not find the specified tile: " @ TempFailure); } CheckIfAllDone(); } //============================================================================= // Date Id Modification // 2006-10-09 gui Created //============================================================================= function CheckIfAllDone() { local LeveeTile L; local bool bShouldEnd; bShouldEnd=true; ForEach AllActors(class'LeveeTile',L,) { if(!L.bIsSetStable && L.bActive) bShouldEnd=false; } if(bShouldEnd) { GameOver(false); } } //============================================================================= // Date Id Modification // 2006-10-04 gui Created // 2006-10-05 The Implemented EndScore setting // 2006-10-06 gui Erased previous step (it was already done) and updated Menu score for it // 2006-11-13 Zmr When the game is over the acstartend or the menuscore wont be displayd // 2006-12-13 Bas Added bGameEnding call for issue 306. //============================================================================= function GameOver(bool bEndedByTime) { local string l; if(!bIsGameOver) { bIsGameOver=true; InMenu(true); if(bEndedByTime){ bGameEndingCall = true; ClientOpenMenu("GeoSimulator.MenuActionCenterStartEnd"); }else { ClientOpenMenu("GeoSimulator.MenuScore"); } //score pompen geoFb.logScore(ScoreArray); //log afsluiten geoFb.stopLog(); // Send log file to webserver: // Disabled for OS version. //l = geoFb.getLogBuffer(); //TestData(l); } } //============================================================================= // Date Id Modification // 2006-10-03 The Created //============================================================================= function string DetermineEvaluationText(int LScorePercentage) { local string LEvaluationText; LEvaluationText = "Unknown"; if (IsBreachOccurred) { // Always "Insufficient" when levee breach occured LEvaluationText = ScoreEvaluationAText; } else { if (LSCorePercentage < EVALUATION_LIMIT1) { LEvaluationText = ScoreEvaluationAText; } if (LSCorePercentage >= EVALUATION_LIMIT1 && LSCorePercentage < EVALUATION_LIMIT2) { LEvaluationText = ScoreEvaluationBText; } if (LSCorePercentage >= EVALUATION_LIMIT2 && LSCorePercentage < EVALUATION_LIMIT3) { LEvaluationText = ScoreEvaluationCText; } if (LSCorePercentage >= EVALUATION_LIMIT3 && LSCorePercentage < EVALUATION_LIMIT4) { LEvaluationText = ScoreEvaluationDText; } if (LSCorePercentage >= EVALUATION_LIMIT4) { LEvaluationText = ScoreEvaluationEText; } } return LEvaluationText; } //============================================================================= // Date Id Modification // 2006-08-15 The Created //============================================================================= function int IndexOfFailure(name AFailureName) { local int LFailureIndex; local int LFailureFoundIndex; LFailureFoundIndex = -1; for (LFailureIndex = 0; LFailureIndex < FailureArray.Length; LFailureIndex++) { // Log("IndexOfFailure: " @ FailureArray[LFailureIndex].FailureName @ " - " @ AFailureName); if (FailureArray[LFailureIndex].FailureName == AFailureName) { LFailureFoundIndex = LFailureIndex; } } return LFailureFoundIndex; } //============================================================================= // Date Id Modification // 2006-08-15 The Created // 2006-08-23 Gui Changed GeoLD Spawn to new object // 2006-08-31 The Finished new scoring system //============================================================================= function InitFailureData() { local int LFailureIndex; local int LFailureCount; GeoLD = new class'GeoLevelDetails'; //log("GeoPlayerController.InitFailureData() ArrayCriticalActiveFailureNames.Length = "$GeoLD.ArrayCriticalActiveFailureNames.Length); //log("GeoPlayerController.InitFailureData() ArrayRelevantActiveFailureNames.Length = "$GeoLD.ArrayRelevantActiveFailureNames.Length); //log("GeoPlayerController.InitFailureData() ArrayReportableActiveFailureNames.Length = "$GeoLD.ArrayReportableActiveFailureNames.Length); // Set options for player IsAllowedTakeMeasures = GeoLD.TakeMeasures; IsAllowedMakeDiagnoses = GeoLD.MakeDiagnoses; IsBreachPossible = False; // Set states of failures LFailureCount = 0; for (LFailureIndex = 0; LFailureIndex < GeoLD.ArrayCriticalActiveFailureNames.Length; LFailureIndex++) { if (GeoLD.ArrayCriticalActiveFailureNames[LFailureIndex].FailureName != 'NONE') { LFailureCount++; //log("breach is possible because GeoLD.ArrayCriticalActiveFailureNames[LFailureIndex] != 'NONE'"); FailureArray.Length = LFailureCount; FailureArray[LFailureCount - 1].FailureName = GeoLD.ArrayCriticalActiveFailureNames[LFailureIndex].FailureName; FailureArray[LFailureCount - 1].FailureState = STA_Critical; IsBreachPossible = True; } } for (LFailureIndex = 0; LFailureIndex < GeoLD.ArrayRelevantActiveFailureNames.Length; LFailureIndex++) { if (GeoLD.ArrayRelevantActiveFailureNames[LFailureIndex].FailureName != 'NONE') { LFailureCount++; FailureArray.Length = LFailureCount; FailureArray[LFailureCount - 1].FailureName = GeoLD.ArrayRelevantActiveFailureNames[LFailureIndex].FailureName; FailureArray[LFailureCount - 1].FailureState = STA_Relevant; } } for (LFailureIndex = 0; LFailureIndex < GeoLD.ArrayReportableActiveFailureNames.Length; LFailureIndex++) { if (GeoLD.ArrayReportableActiveFailureNames[LFailureIndex].FailureName != 'NONE') { LFailureCount++; FailureArray.Length = LFailureCount; FailureArray[LFailureCount - 1].FailureName = GeoLD.ArrayReportableActiveFailureNames[LFailureIndex].FailureName; FailureArray[LFailureCount - 1].FailureState = STA_Reportable; } } //log("GeoPlayerController.InitFailureData() LFailureCount = "$LFailureCount); } //============================================================================= // Date Id Modification // 2006-08-15 The Created // 2006-08-31 The Finished new scoring system // 2007-09-28 Jln Modified to use LeveeTiles instead. //============================================================================= function FillFailureData() { local LeveeTile LFailure; local int LFailureIndex; //log("FillFailureData()"); ForEach AllActors( class 'LeveeTile', LFailure) { if (LFailure.bActive) { LFailureIndex = IndexOfFailure(LFailure.name); //log("FillFailureData() LFailureIndex ("$LFailureIndex$") = "$LFailure.name @", failureState = "$LFailure.CurrentState); if (LFailureIndex >=0 ) { FailureArray[LFailureIndex].NL_MechanismName = LFailure.NL_FailureName; FailureArray[LFailureIndex].EN_MechanismName = LFailure.EN_FailureName; FailureArray[LFailureIndex].MapLocationSign = LFailure.MapLocationSign; FailureArray[LFailureIndex].CurrentState = LFailure.CurrentState; } } } } //============================================================================= // Description: Set al bDetected and bSignalUsedInScoreCalculations flags to False. These flags // are used to support the score calculation // // Date Id Modification // 2006-08-11 The Created // 2007-09-28 Jln Modified to use LeveeTiles instead. //============================================================================= function InitFlagsForCalculation() { // local Failure LFailure; local LeveeTile LFailure; local RedMarker LRedMarker; local int LSignalIndex; local int LReportIndex; //log("InitFlagsForCalculation() GeoPlayerController.InitFlagsForCalculation()"); ForEach AllActors( class 'Leveetile', LFailure) { //log("initflagsforcalc1" @ LFailure.NL_FailureName); LFailure.bDetected = False; for (LSignalIndex = 0; LSignalIndex < LFailure.Signals.Length; LSignalIndex++) { //log("initflagsforcalc2"); LFailure.Signals[LSignalIndex].bSignalUsedInScoreCalculations = False; for (LReportIndex = 0; LReportIndex < LFailure.Signals[LSignalIndex].SignalReports.Length; LReportIndex++) { LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations = False; //log("Set all failure signals tot not used in score calculations" @ LFailure.NL_FailureName); } //log("initflagsforcalc3"); if(LFailure.bCritical) { // don't set the used in Score calculations to true... }else if(LFailure.bRelevant){ // the first can be Relevant if(LFailure.Signals[LSignalIndex].FirstState == STA_Critical) { //this signal can't be seen by a player cause the failure will not reach that state. (So don't account for it in the scoring) LFailure.Signals[LSignalIndex].bSignalUsedInScoreCalculations = true; for (LReportIndex = 0; LReportIndex < LFailure.Signals[LSignalIndex].SignalReports.Length; LReportIndex++) { LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations = true; } }else { // the signal can be seen by the player. for (LReportIndex = 0; LReportIndex < LFailure.Signals[LSignalIndex].SignalReports.Length; LReportIndex++) { if(LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].GeoState == STA_Critical) { // this signalreport can not be seen by the player... LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations = true; } } } }else if(LFailure.bReportable){ //log("initflagsforcalc4"); if(LFailure.Signals[LSignalIndex].FirstState != STA_Reportable) { //log("initflagsforcalc5" @LFailure.Signals[LSignalIndex].NL_DamageName ); //this signal can't be seen by a player cause the failure will not reach that state. (So don't account for it in the scoring) LFailure.Signals[LSignalIndex].bSignalUsedInScoreCalculations = true; for (LReportIndex = 0; LReportIndex < LFailure.Signals[LSignalIndex].SignalReports.Length; LReportIndex++) { LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations = true; } }else { //this signal can be seen by the player. //log("initflagsforcalc6"@LFailure.Signals[LSignalIndex].NL_DamageName); for (LReportIndex = 0; LReportIndex < LFailure.Signals[LSignalIndex].SignalReports.Length; LReportIndex++) { if(LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].GeoState != STA_Reportable) { // these failures can not be seeen by the player LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations = true; } } } } } } ForEach AllActors( class 'RedMarker', LRedMarker) { for (LSignalIndex = 0; LSignalIndex < LRedMarker.Signals.Length; LSignalIndex++) { LRedMarker.Signals[LSignalIndex].bSignalUsedInScoreCalculations = False; for (LReportIndex = 0; LReportIndex < LRedMarker.Signals[LSignalIndex].SignalReports.Length; LReportIndex++) { LRedMarker.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations = False; } } } } //============================================================================= // Date Id Modification // 2006-08-11 The Created // 2006-08-15 The Taken into account if allowed diagnoses and measures // 2006-08-31 The Finished new scoring system // 2006-10-03 The Implemented check on range for GeoSizes properties // 2006-10-03 The Implemented multi point scores per item // 2006-10-04 The Adapted scoring to score reports only after action center is called // 2006-10-05 The Implemented STA_Failed in GeoStates // 2006-10-05 The Implemented scoring for assessments // 2006-10-26 The Implemented EndScore; if the final score is made no new // score will be calculated, so the user cannot improve the // score anymore // 2006-11-03 The Fixed assessment evaluation // 2006-06-22 Zmr Changed assessment evaluation // 2007-09-28 Jln Modified to use LeveeTiles instead. //============================================================================= function CalculateScore() { local LeveeTile LFailure; local RedMarker LRedMarker; local RedMarker LActualRedMarker; local int LMeasureIndex; local int LSignalIndex; local int LReportIndex; local int LRedMarkerSignalIndex; local int LRedMarkerReportIndex; local int LFailureIndex; local bool LCorrectMeasure; local SignalReport LReport; local Signal LSignal; local int LScoreIndex; local int LReportScoreCount; local int LReportScorePossibleCount; local bool AssessmentAlreadyReportable, AssessmentAlreadyRelevent, AssessmentAlreadyCritical; //Whether the player has already score points for a certain failure state. For each failure these booleans are set to false. And they are also used to set the max score per failure. local LocationNameSign TempSign; if (!bIsEndScore) { ScorePossible = 0; ScorePlayer = 0; InitFlagsForCalculation(); UpdateLanguage(); // Init score info array ScoreArray.Length = SCORE_INDEX_COUNT; for (LScoreIndex = 0; LScoreIndex < SCORE_INDEX_COUNT; LScoreIndex++) { ScoreArray[LScoreIndex].UserCount = 0; ScoreArray[LScoreIndex].CorrectCount = 0; ScoreArray[LScoreIndex].MaxCount = 0; ScoreArray[LScoreIndex].SingleScore = 1; ScoreArray[LScoreIndex].Score = 0; ScoreArray[LScoreIndex].MaxScore = 0; } ScoreArray[SCORE_INDEX_FAILURES].SingleScore = POINTS_FAILURES; ScoreArray[SCORE_INDEX_LOCATIONS].SingleScore = POINTS_LOCATIONS; ScoreArray[SCORE_INDEX_SIGNALS].SingleScore = POINTS_SIGNALS; ScoreArray[SCORE_INDEX_REPORTS].SingleScore = POINTS_REPORTS; ScoreArray[SCORE_INDEX_ASSESSMENTS].SingleScore = POINTS_ASSESSMENTS; ScoreArray[SCORE_INDEX_DIAGNOSES].SingleScore = POINTS_DIAGNOSES; ScoreArray[SCORE_INDEX_MEASURES].SingleScore = POINTS_MEASURES; // Determine user actions ForEach DynamicActors( class 'RedMarker', LRedMarker) { ScoreArray[SCORE_INDEX_FAILURES].UserCount++; if (LRedMarker.GlobalLocation.LocationSign != None) { ScoreArray[SCORE_INDEX_LOCATIONS].UserCount++; } ScoreArray[SCORE_INDEX_SIGNALS].UserCount = ScoreArray[SCORE_INDEX_SIGNALS].UserCount + LRedMarker.Signals.Length; for (LRedMarkerSignalIndex = 0; LRedMarkerSignalIndex < LRedMarker.Signals.Length; LRedMarkerSignalIndex++) { ScoreArray[SCORE_INDEX_REPORTS].UserCount = ScoreArray[SCORE_INDEX_REPORTS].UserCount + LRedMarker.Signals[LRedMarkerSignalIndex].SignalReports.Length; } //Log("LRedMarker: " @ LRedMarker.ConvState.Length); //Log("User count:" @ ScoreArray[SCORE_INDEX_ASSESSMENTS].UserCount @ " - " @ LRedMarker.ConvState[LRedMarker.ConvState.Length-1].AmountOfAssessments); if(LRedMarker.ConvState.Length != 0) { //Log("ConvState != 0"); ScoreArray[SCORE_INDEX_ASSESSMENTS].UserCount += LRedMarker.ConvState[LRedMarker.ConvState.Length-1].AmountOfAssessments; } if (IsAllowedMakeDiagnoses) { if (LRedMarker.Mechanism != FM_NONE) { ScoreArray[SCORE_INDEX_DIAGNOSES].UserCount++; } } if (IsAllowedTakeMeasures) { if (LRedMarker.MeasureTaken != None) { ScoreArray[SCORE_INDEX_MEASURES].UserCount++; } } } IsBreachOccurred = False; ForEach AllActors( class 'LeveeTile', LFailure) { if (LFailure.bActive) { //log("***----***----***--- "$ LFailure.NL_FailureName $ " Current state "$LFailure.CurrentState @"bCritical"@LFailure.bCritical); // Init failure scores LFailureIndex = IndexOfFailure(LFailure.name); FailureArray[LFailureIndex].ScoreLocation = 0; FailureArray[LFailureIndex].ScoreLocationMax = 0; FailureArray[LFailureIndex].ScoreReport = 0; FailureArray[LFailureIndex].ScoreReportMax = 0; FailureArray[LFailureIndex].ScoreAssessment = 0; FailureArray[LFailureIndex].ScoreAssessmentMax = 0; FailureArray[LFailureIndex].ScoreDiagnosis = 0; FailureArray[LFailureIndex].ScoreDiagnosisMax = 0; FailureArray[LFailureIndex].ScoreMeasure = 0; FailureArray[LFailureIndex].ScoreMeasureMax = 0; FailureArray[LFailureIndex].ScoreTotal = 0; FailureArray[LFailureIndex].ScoreTotalMax = 0; // Evaluate if a redmarker is placed correctly for this failure and select it ScoreArray[SCORE_INDEX_FAILURES].MaxCount++; FailureArray[LFailureIndex].ScoreLocationMax++; ScorePossible++; LActualRedMarker = None; ForEach DynamicActors( class 'RedMarker', LRedMarker) { //Log("Loop RedMarker"); if (!LFailure.bDetected) { //Log("Loop RedMarker detected"); if (LFailure.Encompasses(LRedMarker)) { //Log("CalculateScore() Correct marker position"); ScorePlayer++; ScoreArray[SCORE_INDEX_FAILURES].CorrectCount++; FailureArray[LFailureIndex].ScoreLocation++; LFailure.bDetected = True; LActualRedMarker = LRedMarker; } else { //Log("Loop RedMarker not encompassed"); } } } // Evaluate if correct map location is selected FailureArray[LFailureIndex].ScoreLocationMax++; ScoreArray[SCORE_INDEX_LOCATIONS].MaxCount++; ScorePossible++; if (LActualRedMarker != none) { // Log("CalculateScore() TopDistance = "$LActualRedMarker.GlobalLocation.TopDistance); //Log("CalculateScore() LeftDistance = "$LActualRedMarker.GlobalLocation.LeftDistance); if (LActualRedMarker.GlobalLocation.LocationSign != None) { /// Find the locationamesign of this marker, by distance. TempSign = CheckMarkerLocationSign(LActualRedMarker); //Log("CalculateScore() Location: Marker = "$LActualRedMarker.GlobalLocation.LocationSign$"; Failure = "$LFailure.MapLocationSign @ "; New Method = " @ TempSign); if (LActualRedMarker.GlobalLocation.LocationSign == TempSign) { //Log("CalculateScore() Correct map location"); ScorePlayer++; ScoreArray[SCORE_INDEX_LOCATIONS].CorrectCount++; FailureArray[LFailureIndex].ScoreLocation++; } } } // Evaluate how many points can be scored for the signals, // taken into account the FirstState of the signals for (LSignalIndex = 0; LSignalIndex < LFailure.Signals.Length; LSignalIndex++) { LSignal = LFailure.Signals[LSignalIndex]; switch (FailureArray[LFailureIndex].FailureState) { case STA_Reportable: if (LSignal.FirstState == STA_Reportable) { FailureArray[LFailureIndex].ScoreReportMax++; ScoreArray[SCORE_INDEX_SIGNALS].MaxCount++; ScorePossible++; } break; case STA_Relevant: if ((LSignal.FirstState == STA_Reportable) || (LSignal.FirstState == STA_Relevant)) { FailureArray[LFailureIndex].ScoreReportMax++; ScoreArray[SCORE_INDEX_SIGNALS].MaxCount++; ScorePossible++; } break; case STA_Critical: if ((LSignal.FirstState == STA_Reportable) || (LSignal.FirstState == STA_Relevant) || (LSignal.FirstState == STA_Critical)) { FailureArray[LFailureIndex].ScoreReportMax++; ScoreArray[SCORE_INDEX_SIGNALS].MaxCount++; ScorePossible++; } break; case STA_NONE: break; } } AssessmentAlreadyReportable = false; AssessmentAlreadyRelevent = false; AssessmentAlreadyCritical = false; // Evaluate how many points can be scored for the reports, // taken into account the GeoStates of the reports //Log("Failure: " @ LFailure); //Log("Number of Signals: " @ LFailure.Signals.Length); //Log("Reports: " @ LFailure.Signals[0].SignalReports.Length); for (LSignalIndex = 0; LSignalIndex < LFailure.Signals.Length; LSignalIndex++) { //Log("Number of Reports: " @ LFailure.Signals[LSignalIndex].SignalReports.Length); for (LReportIndex = 0; LReportIndex < LFailure.Signals[LSignalIndex].SignalReports.Length; LReportIndex++) { LReport = LFailure.Signals[LSignalIndex].SignalReports[LReportIndex]; //Log("Report: " @ LReport); switch (FailureArray[LFailureIndex].FailureState) { case STA_Reportable: if (LReport.GeoState == STA_Reportable) { FailureArray[LFailureIndex].ScoreReportMax++; ScoreArray[SCORE_INDEX_REPORTS].MaxCount++; ScorePossible++; } break; case STA_Relevant: if ((LReport.GeoState == STA_Reportable) || (LReport.GeoState == STA_Relevant)) { FailureArray[LFailureIndex].ScoreReportMax++; ScoreArray[SCORE_INDEX_REPORTS].MaxCount++; ScorePossible++; } break; case STA_Critical: if ((LReport.GeoState == STA_Reportable) || (LReport.GeoState == STA_Relevant) || (LReport.GeoState == STA_Critical)) { FailureArray[LFailureIndex].ScoreReportMax++; ScoreArray[SCORE_INDEX_REPORTS].MaxCount++; ScorePossible++; } break; case STA_NONE: break; } switch (LReport.GeoState) { case STA_Reportable: if(!AssessmentAlreadyReportable && LFailure.bReportable) { ScoreArray[SCORE_INDEX_ASSESSMENTS].MaxCount++; ScorePossible++; AssessmentAlreadyReportable = true; //log("*/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ AssessmentAlreadyReportable"); } break; case STA_Relevant: if(!AssessmentAlreadyRelevent && LFailure.bRelevant) { ScoreArray[SCORE_INDEX_ASSESSMENTS].MaxCount++; ScorePossible++; AssessmentAlreadyRelevent = true; //log("*/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ AssessmentAlreadyRelevent"); } break; case STA_Critical: if(!AssessmentAlreadyCritical && LFailure.bCritical) { ScoreArray[SCORE_INDEX_ASSESSMENTS].MaxCount++; ScorePossible++; AssessmentAlreadyCritical = true; //log("*/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ AssessmentAlreadyCritical"); } break; case STA_NONE: break; } } } AssessmentAlreadyReportable = false; AssessmentAlreadyRelevent = false; AssessmentAlreadyCritical = false; // Evaluate if correct signals and reports are reported if (LActualRedMarker != none) { for (LSignalIndex = 0; LSignalIndex < LFailure.Signals.Length; LSignalIndex++) { // Check if any signal in redmarker signals equals signals in failure for (LRedMarkerSignalIndex = 0; LRedMarkerSignalIndex < LActualRedMarker.Signals.Length; LRedMarkerSignalIndex++) { if (LActualRedMarker.Signals[LRedMarkerSignalIndex].bApproved) { if (LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalType == LFailure.Signals[LSignalIndex].SignalType) { if (!LFailure.Signals[LSignalIndex].bSignalUsedInScoreCalculations) { //log("Score past failure signals not used"); if(!LActualRedMarker.Signals[LRedMarkerSignalIndex].bSignalUsedInScoreCalculations) { //Log("CalculateScore() Correct signal"); FailureArray[LFailureIndex].ScoreReport++; ScoreArray[SCORE_INDEX_SIGNALS].CorrectCount++; ScorePlayer++; LFailure.Signals[LSignalIndex].bSignalUsedInScoreCalculations = True; LActualRedMarker.Signals[LRedMarkerSignalIndex].bSignalUsedInScoreCalculations = True; } } // Evaluate if correct reports are made for current signal (observation report) for (LReportIndex = 0; LReportIndex < LFailure.Signals[LSignalIndex].SignalReports.Length; LReportIndex++) { for (LRedMarkerReportIndex = 0; LRedMarkerReportIndex < LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports.Length; LRedMarkerReportIndex++) { //Log("CalculateScore() Redmarker report state = "$LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].GeoState); //Log("CalculateScore() Failure report state = "$LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].GeoState); if (LActualRedMarker.Signals[LRedMarkerSignalIndex].IsSignalEqual(LRedMarkerReportIndex,LFailure.Signals[LSignalIndex],LReportIndex, CReportScoreFractionThreshold, LReportScoreCount, LReportScorePossibleCount)) { //log("Score past signal reports same"@!LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations@!LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].bSignalReportUsedInScoreCalculations); if (!LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations && !LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].bSignalReportUsedInScoreCalculations) { //Log("CalculateScore() Correct report"); FailureArray[LFailureIndex].ScoreReport++; ScoreArray[SCORE_INDEX_REPORTS].CorrectCount++; ScorePlayer++; LFailure.Signals[LSignalIndex].SignalReports[LReportIndex].bSignalReportUsedInScoreCalculations = True; LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].bSignalReportUsedInScoreCalculations = True; } } //Log("CalculateScore() LActualRedMarker Assessment = "$LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].Assessment); //Log("CalculateScore() LActualRedMarker GeoState = "$LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].GeoState); } } } } } } // check whether there was a signalreport in the red marker with the right assessment at the right time. But with a maximum score of 1 per fase per failure for (LRedMarkerSignalIndex = 0; LRedMarkerSignalIndex < LActualRedMarker.Signals.Length; LRedMarkerSignalIndex++) { for (LRedMarkerReportIndex = 0; LRedMarkerReportIndex < LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports.Length; LRedMarkerReportIndex++) { if(LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].Assessment == LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].GeoState) { if(LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].Assessment == STA_Reportable && LFailure.bReportable) { if(!AssessmentAlreadyReportable) { FailureArray[LFailureIndex].ScoreReport++; ScoreArray[SCORE_INDEX_ASSESSMENTS].CorrectCount++; ScorePlayer++; AssessmentAlreadyReportable = true; //log("*/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ AssessmentAlreadyReportable"); } }else if(LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].Assessment == STA_Relevant && LFailure.bRelevant) { if(!AssessmentAlreadyRelevent) { FailureArray[LFailureIndex].ScoreReport++; ScoreArray[SCORE_INDEX_ASSESSMENTS].CorrectCount++; ScorePlayer++; AssessmentAlreadyRelevent = true; //log("*/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ AssessmentAlreadyRelevent"); } }else if(LActualRedMarker.Signals[LRedMarkerSignalIndex].SignalReports[LRedMarkerReportIndex].Assessment == STA_Critical && LFailure.bCritical) { if(!AssessmentAlreadyCritical) { FailureArray[LFailureIndex].ScoreReport++; ScoreArray[SCORE_INDEX_ASSESSMENTS].CorrectCount++; ScorePlayer++; AssessmentAlreadyCritical = true; //log("*/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ AssessmentAlreadyCritical"); } } } } } } // Evaluate if correct failure mechanism selected (diagnosis report) if (IsAllowedMakeDiagnoses) { FailureArray[LFailureIndex].ScoreDiagnosisMax++; ScoreArray[SCORE_INDEX_DIAGNOSES].MaxCount++; ScorePossible++; if (LActualRedMarker != none) { //Log("CalculateScore() Failure = "$LFailure.Name); if (LActualRedMarker.Mechanism == LFailure.Mechanism) { //Log("CalculateScore() Correct failure mechanism"); ScoreArray[SCORE_INDEX_DIAGNOSES].CorrectCount++; ScorePlayer++; FailureArray[LFailureIndex].ScoreDiagnosis++; } } } // Evaluate if correct measure is taken if (IsAllowedTakeMeasures && LFailure.bCritical) { FailureArray[LFailureIndex].ScoreMeasureMax++; ScoreArray[SCORE_INDEX_MEASURES].MaxCount++; ScorePossible++; if (LActualRedMarker != none) { //Log("CalculateScore() Measurecount = "$LFailure.Measures.Length); LCorrectMeasure = false; if (LActualRedMarker.MeasureTaken != None) { for (LMeasureIndex = 0; LMeasureIndex < LFailure.Measures.Length; LMeasureIndex++) { if (LActualRedMarker.MeasureTaken.MeasureType == LFailure.Measures[LMeasureIndex].MeasureType) { LCorrectMeasure = True; } } } Log(LActualRedMarker.MeasureTaken.MeasureType @ " - Correct measure: " @ LCorrectMeasure); if (LCorrectMeasure) { //Log("CalculateScore() Correct measure"); FailureArray[LFailureIndex].ScoreMeasure++; ScorePlayer++; ScoreArray[SCORE_INDEX_MEASURES].CorrectCount++; } } } // Evaluate if breach (if if (FailureArray[LFailureIndex].CurrentState == STA_Failed) { //log("This failure is in state failed "@String(FailureArray[LFailureIndex].FailureName)); IsBreachOccurred = True; } } } // Determine points per item for (LScoreIndex = 0; LScoreIndex < SCORE_INDEX_COUNT; LScoreIndex++) { ScoreArray[LScoreIndex].Score = ScoreArray[LScoreIndex].CorrectCount * ScoreArray[LScoreIndex].SingleScore; ScoreArray[LScoreIndex].MaxScore = ScoreArray[LScoreIndex].MaxCount * ScoreArray[LScoreIndex].SingleScore; } // Determine total score ScorePossible = 0; ScorePlayer = 0; for (LScoreIndex = 0; LScoreIndex < SCORE_INDEX_COUNT; LScoreIndex++) { if(LScoreIndex != SCORE_INDEX_ASSESSMENTS || IsAllowedAssessment) { ScorePossible = ScorePossible + ScoreArray[LScoreIndex].MaxScore; ScorePlayer = ScorePlayer + ScoreArray[LScoreIndex].Score; } } ScorePercentage = 100; if (ScorePossible > 0) { ScorePercentage = 100 * ScorePlayer / ScorePossible; } /// jln - 03-10-2008 This is such an easy fix it feels like cheating... if (ScorePercentage > 100) ScorePercentage = 100; EvaluationText = DetermineEvaluationText(ScorePercentage); /* // Assign breach bonus points if (IsBreachPossible) { ScoreArray[SCORE_INDEX_NOBREACHBONUS].Max = POINTS_NOBREACHBONUS; ScorePossible = ScorePossible + POINTS_NOBREACHBONUS; if (!IsBreachOccurred) { ScorePlayer = ScorePlayer + POINTS_NOBREACHBONUS; ScoreArray[SCORE_INDEX_NOBREACHBONUS].Correct = POINTS_NOBREACHBONUS; } } */ if (bIsGameOver) { bIsEndScore = True; } } } //***************************************************************************** // Find closest marker, and return it //***************************************************************************** function LocationNameSign CheckMarkerLocationSign(RedMarker marker) { local bool FirstSign; local actor A; local float TempDist; local float d; local vector Location; local LocationNameSign sign; TempDist = 999999999; /// CHECK THE CLOSEST LOCATION SIGN FirstSign = true; Location = marker.Location; foreach AllActors( class 'Actor', A, 'LocationNameSign') { d = Abs(VSize(Location - A.Location)); //Log("Redmarker Distance: " @ A @ " dist: " @ d); if((d < TempDist) || FirstSign) { TempDist = d; FirstSign = false; sign = LocationNameSign(A); } } return sign; } //============================================================================= // Date Id Modification // 2006-10-05 bas function created // // NOTE: When 'slomo' is used this may become inaccurate. // BUG: Stops counting when player walks into a MovingWaterVolume(?) // -Bas //============================================================================= function ingameTimerFunc(){ //add 1 second ingameTimer++; //whether time should be updated in GeoHUD updateTimer = true; } //============================================================================= // This function prepares timer for output in GeoHUD. Returns a string // representation of the time (minutes:seconds). // Date Id Modification // 2006-10-09 The Created this header // // NOTE: When 'slomo' is used the output may become inaccurate. // -Bas //============================================================================= function string getTimer(){ local int m,s; local string minutes,seconds; s = ingameTimer; while(s - 60 >= 0){ s -= 60; m++; } if(s < 10) seconds = "0"$s; else seconds = ""$s; if(m < 10) minutes = "0"$m; else minutes = ""$m; return minutes$":"$seconds; } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header // // NOTE: When 'slomo' is used this may become inaccurate. // -Bas //============================================================================= exec function showtime(){ showTimer = !showTimer; } //============================================================================= // 18-09-2006 // A timer is needed to update the 'currentTime' of each WarningMessage // in Messages[]. This is needed in state_warning. // See GeoSimulator.WarningMessage.uc for more info. // // - Bas // Date Id Modification // 2006-10-09 The Created this header //============================================================================= event PreBeginPlay(){ Super.PreBeginPlay(); Dutch = Bool(Localize("System","IsDutch", "GeoSimulator")); //log("Geoplayercontroller - prebeginplay"); startTimer(); bSnapToLevel=False; } //============================================================================= // calls Timer() every second // Date Id Modification // 2006-10-09 The Created this header //============================================================================= function startTimer() { //log("STARTED TIMER"); SetTimer(1.0,true); } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header //============================================================================= function stopTimer() { //log("STOPPED TIMER"); SetTimer(0.0,false); } function MoveRedMarkers() { local RedMarker m; local vector position; local vector HitLocation, HitNormal; local Actor traced; ForEach AllActors(class'RedMarker', m) { /// Attached to a failure: if (m.LTile != None) { if (m.LTile.Mechanism == FM_ErosionOuterRipRap) { Log("Marker " @ m @ " is attached to " @ m.LTile @ " and is an rip rap"); /// Relocate marker to some new position: // position = m.LTile.Location; //position = m.LTile.Positionm.LTile.MyFailure.RotateVector(0,0,624.00); position.x = (m.LTile.MyFailure.vMin.x + m.LTile.MyFailure.vMax.x) / 2; position.y = (m.LTile.MyFailure.vMin.y + m.LTile.MyFailure.vMax.y) / 2; position.z = m.LTile.Location.z + 1000; position.x = (position.x + m.LTile.Location.x) /2 ; position.y = (position.y + m.LTile.Location.y) /2; traced = Trace(HitLocation,HitNormal,vect(0,0,-1)*2000 + position, position, true); position.z = m.LTile.Location.z + 550; if (traced != None) { /// Hit something: position = HitLocation; } m.SetLocation(position); } } } } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header // 2006-11-13 Zmr When bIsGameOver the timers of the Messages won't update // // This function is called every second by some Unreal magic. //============================================================================= function Timer() { local int i; local int s; /// For counting active tiles: local LeveeTile tile; local int tiles_active; local int tiles_stable; if(ingameTimer != -1) { ingameTimerFunc(); StartEndGameTimer(); } if(bIsGameOver){ wMsg = none; } /// Hardcoded for level 1, move red markers out of the water. if(ingameTimer == 592) { MoveRedMarkers(); } if((ingameTimer+60)%60 == 0) { // every minute, print all timers //log("==== TIMERS OVERVIEW ===="); //log("Number of timers: "$Messages.length); //for(i = 0; i < Messages.Length; i++) //{ //log(i$": "$Messages[i].toString()); //} /// Every minute, check of all failmechanisms have been found: ForEach DynamicActors(class'LeveeTile', tile) { if (tile.bActive == true) { tiles_active++; } if (tile.bIsSetStable == true && tile.bActive == true) { /// Active and stable! tiles_stable++; } } Log("Tiles active: " @ tiles_active @ " - " @ tiles_stable); if ((tiles_active > 0) && tiles_active == tiles_stable) { Log("GAME END! All tiles stable"); /// End game: GameOver(false); } } /// move this under the if below, but it won't work singleplayer then. // make sure all GeoTimedSoundObjects have been // initialized and are added to the array if(timedSoundObjects.length == 0) { // Log("Init timed sounds"); InitTimedSounds(); } // call UpdateTimer for all GeoTimedSoundObjects in the game for (s = 0; s < timedSoundObjects.length; s++) { timedSoundObjects[s].UpdateTimer(); } for(i = 0; i < Messages.Length; i++) { if(Messages[i].bCounting && !bIsGameOver) { Messages[i].currentTime--; if(Messages[i].currentTime == 0) { // message appears on HUD (AC calling) //log("==== TIMERS EVENT ===="); //log(i$": "$Messages[i].toString()); //log("First reminder call happens; other timers are paused."); // store current WarningMessage and it's index wMsg = Messages[i]; wMsgIndex = i; // pause all other Warnings pauseWarnings(true); // player must be moving to the warning by now bMovingToWarning = true; if(Messages[i].warningType) bRememberWarning = true; else bCorrectionWarning = true; } else if(Messages[i].currentTime == -10) { // message on HUD disappears after 10 seconds // don't unpause the other messages yet //log("==== TIMERS EVENT ===="); //log(i$": "$Messages[i].toString()); //log("First reminder call disappers again; other timers are still paused."); if(Messages[i].warningType) bRememberWarning = false; else bCorrectionWarning = false; } else if(Messages[i].currentTime == -70) { //message reappears after 1 minute (second chance) //log("==== TIMERS EVENT ===="); //log(i$": "$Messages[i].toString()); //log("Second reminder call appears; other timers are still paused."); //store current WarningMessage and it's index wMsg = Messages[i]; wMsgIndex = i; if(Messages[i].warningType) bRememberWarning = true; else bCorrectionWarning = true; } else if(Messages[i].currentTime == -80) { //hide message and unpause the other warningmessages //log("==== TIMERS EVENT ===="); //log(i$": "$Messages[i].toString()); //log("Second reminder call disappears again; other timers are unpaused again."); bMovingToWarning = false; //reset the timer and start counting again Messages[i].resetTimer(true); //store current WarningMessage and it's index wMsg = Messages[i]; wMsgIndex = i; // unpause all other warnings pauseWarnings(false); if(Messages[i].warningType) bRememberWarning = false; else bCorrectionWarning = false; } } } } //============================================================================= // Pauses(true)/Unpauses(false) all counters except wMsg. // Needs wMsgIndex // // Date Id Modification // 2006-10-09 The Created this header //============================================================================= function pauseWarnings(bool b){ local int i; //log("pauseTimers():"@b); if(wMsg != none){ for(i = 0; i < Messages.Length; i++) if(i != wMsgIndex) Messages[i].bCounting = !b; } } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header // 2007-01-17 Bas Added Messages[i].resetTimer(true) to duplicate check // // This method instantiates a new WarningMessage and adds it to the // back of the Messages array. // type - if true, the new WarningMessage is a remember msg, else a correction msg. // start - if true, start counting immediately, else keep the new WarningMessage // paused. // marker - marker that will be associated with the newly created // WarningMessage. When not set, NearByMarker will be used. // -Bas //============================================================================= function addTimer(bool type, bool start, optional RedMarker marker) { local int i; local int timeUntilNextPhase, timerTime; local WarningMessage msg; local RedMarker tmpMarker; if(marker == None && NearByMarker != None) tmpMarker = NearByMarker; else if(marker != None) tmpMarker = marker; else //parameter marker and NearByMarker are null so return return; timeUntilNextPhase = 600 - ingameTimer; // 600 seconds corresponds roughly to the end of the not-serious-phase // if more than 5 minutes away from the next phase, this can only mean you're in the beginning of the not-serious-phase if(type && timeUntilNextPhase > 300) { // if in five minutes you'd still be in the first phase (not-serious-phase), // set a longer time for the checking message timer timerTime = timeUntilNextPhase + 60 + Rand(100); } // if marker already had a warningmessage, reset that one instead of making a new one for(i = 0; i < Messages.Length; i++) { if(Messages[i].isSameMarker(tmpMarker)) { //reset the duplicate and reset it's Timer Messages[i].resetTimer(true, timerTime); return; } } //create a new WarningMessage msg = new Class'WarningMessage'; //of type type and RedMarker tmpMarker msg.setTimer(type, tmpMarker, timerTime); //should the timer start directly? if true start counting, else pause the counter msg.bCounting = start; //add the newly created message to Messages array Messages.Insert(Messages.Length,1); Messages[Messages.Length - 1] = msg; //log("Timer added: addTimer("@type@")"); } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header // 2007-01-17 Bas Made the function more robust. //============================================================================= function removeWarning(RedMarker marker){ local int i; if(marker != none){ for(i = 0; i < Messages.Length; i++){ if(Messages[i].isSameMarker(marker)){ Messages.Remove(i,1); } } } } //============================================================================= // Returns the warningmessage assigned to the nearest marker // and changes the wMsgIndex to the index of that warningmessage. // // Date Id Modification // 2006-10-09 The Created this header // 2007-01-17 Bas Made the function more robust. //============================================================================= function WarningMessage getNearbyWarning(){ local RedMarker tmpNearByMarker; local int i; if(NearByMarker == none){ //go look for the nearest marker tmpNearByMarker = getNearestMarker(); }else{ //use the given NearByMarker tmpNearByMarker = NearByMarker; } if(tmpNearByMarker != none){ for(i = 0; i < Messages.Length; i++){ if(Messages[i].isSameMarker(tmpNearByMarker)){ wMsgIndex = i; return Messages[i]; } } } return none; } //============================================================================= // Language Function Added // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function ChangeLanguage() { if (Dutch) { Dutch=false; //log( "Language changed to English" ); } else { Dutch=true; //log( "Language changed to Dutch" ); } SaveConfig(); } //============================================================================= // Out of Menu Function Added // Date Id Modification // 2006-10-09 The Created this header //============================================================================= function InMenu(bool bIsInMenu) { bInMenu = bIsInMenu; SetPause(bIsInMenu); } //============================================================================= // OPEN RED MENU WITH REPORTS // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function MakeRed() { if(!PlacingMarker) { if(NearByMarker!=None) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuMarker"); } } } //============================================================================= // OPEN YELLOW MENU WITH REPORTS // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function MakeYellow() { if(!PlacingMarker) { if(NearByYellowMarker!=None) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuYellowMarker"); } } } //============================================================================= // OPEN MAP MENU // Date Id Modification // 2007-06-19 gui Created this function //============================================================================= function ShowScoresNew() { if(!PlacingMarker) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuScore"); } } //============================================================================= // OPEN MAP MENU // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function ShowMap() { if(!PlacingMarker) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuMap"); } } //============================================================================= // OPEN MAP MENU // Date Id Modification // 2007-06-10 gui Added this function //============================================================================= exec function ShowNotebook() { if(!PlacingMarker) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuNotebook"); geoFb.logEvent("view_notebook"); } } //============================================================================= // OPEN INVENTORY MENU OR MARKERS // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function MakeCall() { MakeCallInventory(); } //============================================================================= // Get the marker nearest to the player. Needed in Takeaction(). Can be usefull // almost every timer function. // Date Id Modification // 2006-10-09 Bas Created this function //============================================================================= function RedMarker getNearestMarker(){ local RedMarker marker, nearest; local float dist; ForEach DynamicActors(class'RedMarker', marker){ if(nearest == none || Abs(VSize(Pawn.Location - marker.Location)) < dist){ dist = Abs(VSize(Pawn.Location - marker.Location)); nearest = marker; } } return nearest; } function bool IsDroogte() { local int i; /// Find droogte keyword string: Log("Level name: "); Log(level.title); i = Instr(level.title, "Droogte"); if (i != -1) { return true; } return false; } //============================================================================= // TAKE ACTION // Date Id Modification // 2006-10-09 The Created this header // 2006-12-09 Bas Player can't place red markers within 10m of eachother // 2006-12-13 Bas Added dialog when player tries to place a marker near another // 2006-12-13 gui Marker Warning will show up next turn same thing happens // otherwise people might not notice other maker // 2007-09-28 Jln Modified to support LeveeTile. //============================================================================= exec function Takeaction() { local RedMarker marker; local LeveeTile tempFailure; local bool InFailureAlreadyMarker; local Pawn P; local Controller C; if(PlacingMarker){ InFailureAlreadyMarker = false; marker = getNearestMarker(); C = Controller(PlayerReplicationInfo.Owner); if( C != None ) P = C.Pawn; /// Check in which failure the player is. /// Check if there is a red marker in there. // if(failure(PlayerReplicationInfo.PlayerVolume)!=none) //{ // tempFailure = failure(PlayerReplicationInfo.PlayerVolume); // InFailureAlreadyMarker = (tempFailure.CurrentRedMarker != none); // log("GeoSimulator.HelpMenuPlaceRedMarkerdrietje"@InFailureAlreadyMarker); // } //TEMP - TODO - ALMAR //InFailureAlreadyMarker = false; /// Check if the player is standing in a failure: tempFailure = FindFailure(P); if (tempFailure != none) { /// tempFailure is set to a tile, so the player is standing in a failure. But does this failure have a marker already? /// If it does, we should not be able to place another. InFailureAlreadyMarker = tempFailure.CurrentRedMarker != none; //log("[TakeAction] " @ tempFailure @ " already has a marker!"); } else { //log("[TakeAction] " @ tempFailure @ " does not have a marker!"); } // log("GeoSimulator.HelpMenuPlaceRedMarkereentje"); if(MarkerType == MK_Red && (marker != none && Abs(VSize(marker.Location - Pawn.Location)) < 1000||InFailureAlreadyMarker)){ // log("GeoSimulator.HelpMenuPlaceRedMarkertweetje"); if(!bShowedHelpRedMarker){ InMenu(true); ClientOpenMenu("GeoSimulator.HelpMenuPlaceRedMarker"); bShowedHelpRedMarker = true; } }else{ bShowedHelpRedMarker = false; PutMarkerDown(); } } else { if(bRememberWarning) { InMenu(true); if (IsDroogte() == false) { ClientOpenMenu("GeoSimulator.MenuActionCenterStandard"); } else { ClientOpenMenu("GeoSimulator.MenuActionCenterDroogte"); } bRememberWarning = false; } else if(bCorrectionWarning) { InMenu(true); if (IsDroogte() == false) { ClientOpenMenu("GeoSimulator.MenuActionCenterStandard"); } else { ClientOpenMenu("GeoSimulator.MenuActionCenterDroogte"); } bCorrectionWarning = false; } else if(NearByMarker!=None && NearByYellowMarker!=None) { InMenu(true); if(Abs(VSize(Pawn.Location - NearByMarker.Location)) < Abs(VSize(Pawn.Location - NearByYellowMarker.Location))) { ClientOpenMenu("GeoSimulator.MenuMarker"); } else { ClientOpenMenu("GeoSimulator.MenuYellowMarker"); } } else if(NearByMarker!=None) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuMarker"); } else if(NearByYellowMarker!=None) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuYellowMarker"); } else if(bGameStartingCall && !bIsgameOver ) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuActionCenterStartEnd"); bGameStartingCall=false; } } } //============================================================================= // OPEN INVENTORY MENU // Date Id Modification // 2006-10-09 The Created this header // 2006-12-13 gui Cancel placement of markers //============================================================================= function MakeCallInventory() { if(!PlacingMarker) { InMenu(true); ClientOpenMenu("GeoSimulator.MenuInventory"); } else { PlacingMarker=false; TemporaryMarker.Destroy(); TemporaryMarker=None; } } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function PlaceMarker(MkTypes TempMarkerType) { local class NewClass; //log("function PlaceMarker"); if((!PlacingMarker)) { MarkerType = TempMarkerType; if(TempMarkerType == MK_Red) { NewClass = class( DynamicLoadObject( "GeoSimulator.GhostRedMarker", class'Class' ) ); } else { NewClass = class( DynamicLoadObject( "GeoSimulator.GhostYellowMarker", class'Class' ) ); } TemporaryMarker = GhostMarker(Spawn( NewClass)); PlacingMarker=true; } } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function MoveYellowMarker() { local class NewClass; if((!PlacingMarker)) { MarkerType = MK_YELLOW; MovingMarker = NearByYellowMarker; MovingMarker.bHidden=true; NewClass = class( DynamicLoadObject( "GeoSimulator.GhostYellowMarker", class'Class' ) ); TemporaryMarker = GhostMarker(Spawn( NewClass)); PlacingMarker=true; } } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header //============================================================================= function PutMarkerDown() { if(MarkerType==MK_RED) PutRedMarkerDown(); else if(MarkerType==MK_YELLOW) if(MovingMarker==None) PutYellowMarkerDown(); else PlaceMovingMarker(); TemporaryMarker.Destroy(); TemporaryMarker=None; } //============================================================================= // CREATE NEW MARKER WITH CARRIED INFORMATION // Date Id Modification // 2006-10-09 The Created this header // 2007-09-28 Jln Modified to support LeveeTiles; //============================================================================= function PutRedMarkerDown() { local class NewClass; local vector SpawnLoc; local rotator Rot, SpawnRot; local RedMarker FD; local float TempCos, TempSin; if((PlacingMarker)){ //log( "PutRedMarkerDown() Create: GeoSimulator.Marker" ); NewClass = class( DynamicLoadObject( "GeoSimulator.RedMarker", class'Class' ) ); if(NewClass != None){ if (Pawn != None){ SpawnLoc = Pawn.Location; SpawnRot = Pawn.Rotation; }else{ SpawnLoc = Location; SpawnRot = Rotation; } TempSin = sin(pi * (SpawnRot.Yaw / 65536.0) * 2.0); TempCos = cos(pi * (SpawnRot.Yaw / 65536.0) * 2.0); SpawnLoc.x = SpawnLoc.x + PlacementOfMarkerXY * TempCos; SpawnLoc.y = SpawnLoc.y + PlacementOfMarkerXY * TempSin; SpawnLoc.z = SpawnLoc.z - PlacementOfMarkerZ; Rot.Pitch = 0; Rot.Yaw = SpawnRot.Yaw; Rot.Roll = 0; FD = RedMarker(Spawn( NewClass,,,SpawnLoc, Rot)); /// ALMAR - bookmark - important! // PLACE DAMAGE IN THE MARKER FD.LTile = FindFailureVector(SpawnLoc); //if(PlayerReplicationInfo.PlayerVolume != None){ // log("PutRedMarkerDown() ARGGHH RUN MAN... you are in " @PlayerReplicationInfo.PlayerVolume.Name); //FD.Volume = PlayerReplicationInfo.PlayerVolume; if( (FD.LTile) != none ) { //log("PutRedMarkerDown() in failure " @ FD.LTile); FD.LTile.CurrentRedMarker = FD; } else { //log("PutRedMarkerDown() In the middle of nowhere..."); FD.LTile = None; } //} } geoFb.logPutRedMarker(FD); //log("PutRedMarkerDown() Marker DOWN"); PlacingMarker=false; } MakeRed(); } //============================================================================= // This function determines on which tile the player is currently standing // Date Id Modification // 2007-09-28 Jln Created this function //============================================================================= function LeveeTile FindFailure(Actor opawn) { local LeveeTile L; //local vector vMin, vMax; ForEach AllActors( class 'LeveeTile', L) { //vMin = L.GetMin(); //vMax = L.GetMax(); /// Check if our player is inside the failure: if (L.Encompasses(opawn)) { //log("NEW - FindFailure - Player is inside failure: " @ L); return L; } } /// None found: return None; } function LeveeTile FindFailureVector(vector pos) { local LeveeTile L; //local vector vMin, vMax; ForEach AllActors( class 'LeveeTile', L) { /// Check if our player is inside the failure: if (L.EncompassesVector(pos)) { //log("NEW - FindFailureVector - Player is inside failure: " @ L); return L; } } /// None found: return None; } //============================================================================= // Function is called when a player gets in the range of a marker. // Date Id Modification // 2006-10-09 The Created this header // 2006-12-06 bas Added documentation //============================================================================= function NearMarker(Marker TempMarker, bool IsRedMarker){ if(TempMarker != none){ if(IsRedMarker){ CloseRedMarkers[CloseRedMarkers.Length] = TempMarker; }else{ CloseYellowMarkers[CloseYellowMarkers.Length] = TempMarker; } }else{ warn("Warning: Nothing done. Not Found"@TempMarker.Name); } UpdateClosestMarkers(); } //============================================================================= // Function is called when a player has placed a marker and then moves away // from the marker. This function removes the marker from the CloseMarkers // array and then updates the CloseMarkers array. // Date Id Modification // 2006-10-09 The Created this header // 2006-12-06 bas Added documentation //============================================================================= function AwayFromMarker(Marker TempMarker, bool IsRedMarker){ local int i; if(TempMarker != none){ if(IsRedMarker){ for(i=0; i NewClass; local vector SpawnLoc; local rotator Rot, SpawnRot; local YellowMarker FD; local float TempCos, TempSin; //log("PutYellowMarkerDown"); if((PlacingMarker)) { ////log( "PutYellowMarkerDown() Create: GeoSimulator.Marker" ); NewClass = class( DynamicLoadObject( "GeoSimulator.YellowMarker", class'Class' ) ); if( NewClass!=None ) { if ( Pawn != None ) { SpawnLoc = Pawn.Location; SpawnRot = Pawn.Rotation; } else { SpawnLoc = Location; SpawnRot = Rotation; } TempSin=sin(pi * (SpawnRot.Yaw / 65536.0) * 2.0); TempCos=cos(pi * (SpawnRot.Yaw / 65536.0) * 2.0); SpawnLoc.x = SpawnLoc.x + PlacementOfMarkerXY * TempCos; SpawnLoc.y = SpawnLoc.y + PlacementOfMarkerXY * TempSin; SpawnLoc.z = SpawnLoc.z - PlacementOfMarkerZ; Rot.Pitch=0; Rot.Yaw=0; Rot.Roll=0; FD = YellowMarker(Spawn( NewClass,,,SpawnLoc, Rot)); //If second YellowMarker if(FD.SetOtherMarker(PreviousYellowMarker)) { PreviousYellowMarker.SetOtherMarker(FD); FD.UpdateDistanceToOtherMarker(); PreviousYellowMarker.UpdateDistanceToOtherMarker(); } } ////log("PutYellowMarkerDown() Marker yellow DOWN"); PreviousYellowMarker=None; PlacingMarker=false; } geoFb.logPutYellowMarker(FD); MakeYellow(); } //============================================================================= // Place second Yellow Marker // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function PutSecondYellowMarkerDown() { //log("Put Second Yellow Marker Down"); PreviousYellowMarker=NearByYellowMarker; PlaceMarker(MK_Yellow); MakeYellow(); } //============================================================================= // Place Moving Marker // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function PlaceMovingMarker() { local vector SpawnLoc; local rotator Rot, SpawnRot; local float TempCos, TempSin; //log("Place moving marker"); if ( Pawn != None ) { SpawnLoc = Pawn.Location; SpawnRot = Pawn.Rotation; } else { SpawnLoc = Location; SpawnRot = Rotation; } TempSin=sin(pi * (SpawnRot.Yaw / 65536.0) * 2.0); TempCos=cos(pi * (SpawnRot.Yaw / 65536.0) * 2.0); SpawnLoc.x = SpawnLoc.x + PlacementOfMarkerXY * TempCos; SpawnLoc.y = SpawnLoc.y + PlacementOfMarkerXY * TempSin; SpawnLoc.z = SpawnLoc.z - PlacementOfMarkerZ; Rot.Pitch=0; Rot.Yaw=0; Rot.Roll=0; MovingMarker.SetLocation(SpawnLoc); MovingMarker.SetRotation(Rot); //If second YellowMarker MovingMarker.UpdateDistanceToOtherMarker(); MovingMarker.OtherMarker.UpdateDistanceToOtherMarker(); geoFb.logPutYellowMarker(MovingMarker); MovingMarker.bHidden=false; MovingMarker=None; PlacingMarker=false; MakeYellow(); } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function Fly() { if ( Pawn != None ) { Pawn.UnderWaterTime = Pawn.Default.UnderWaterTime; ClientMessage("I believe I can fly..."); Pawn.SetCollision(true, true , true); Pawn.bCollideWorld = true; GotoState('PlayerFlying'); } } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function Walk() { if (Pawn != None){ Pawn.UnderWaterTime = Pawn.Default.UnderWaterTime; ClientMessage("Back to reality..."); Pawn.SetCollision(true, true , true); Pawn.SetPhysics(PHYS_Walking); Pawn.bCollideWorld = true; GotoState('PlayerWalking'); } } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header //============================================================================= exec function ToggleFlyWalk() { if(IsInState('PlayerFlying')) Walk(); else Fly(); } //============================================================================= // Saves NewMarker to the Signals of RedMarker // Date Id Modification // 2006-10-09 The Created this header // 2007-07-06 Wsl now returns the index the signal was saved to //============================================================================= function int SaveNewSignal() { local int tempIndex; //log(""); //log("==== SaveNewSignal ===="); if(ReportingMode == MODE_CreatingNewObservation) { // New Signal is just added at the end of the array tempIndex = NearByMarker.Signals.length; NearByMarker.Signals.Insert(tempIndex, 1); NewSignal.bApproved = false; geoFb.logEvent("New_Signal_Observation"); } else { // Edited Signal is put at the place in the array where it came from tempIndex = EditIndex; geoFb.logEvent("Edit_Signal_Observation"); } geoFb.logSignal(NewSignal, NearByMarker.name); NearByMarker.Signals[tempIndex] = NewSignal; NewSignal = NearByMarker.Signals[tempIndex].Duplicate(); //log("NewSignal saved in Signals-array at index "$tempIndex); EditIndex = tempIndex; //log(""); return EditIndex; } //============================================================================= // returns the current state of the failure associated with the nearest red marker // Date Id Modification // 2006-10-09 The Created this header //============================================================================= function GeoEnums.GeoStates GetCurrentFailureState() { local LeveeTile theFailure; theFailure = (NearByMarker.LTile); if(theFailure != none) { return theFailure.CurrentState; } else { return STA_NONE; } } //============================================================================= // reset all variables associated with NewSignal to starting values // this is done when a new signal is going to be constructed from scratch // Date Id Modification // 2006-10-09 The Created this header //============================================================================= function ResetNewSignal() { NewSignal = new class'Signal'; ReportingMode = MODE_CreatingNewObservation; EditIndex = NearByMarker.Signals.length; bCreatedNewSignalReport = false; } //============================================================================= // Date Id Modification // 2006-10-03 The Created //============================================================================= function UpdateLanguage() { if (Dutch) { ScoreEvaluationAText = NL_ScoreEvaluationAText; ScoreEvaluationBText = NL_ScoreEvaluationBText; ScoreEvaluationCText = NL_ScoreEvaluationCText; ScoreEvaluationDText = NL_ScoreEvaluationDText; ScoreEvaluationEText = NL_ScoreEvaluationEText; } else { ScoreEvaluationAText = EN_ScoreEvaluationAText; ScoreEvaluationBText = EN_ScoreEvaluationBText; ScoreEvaluationCText = EN_ScoreEvaluationCText; ScoreEvaluationDText = EN_ScoreEvaluationDText; ScoreEvaluationEText = EN_ScoreEvaluationEText; } } //============================================================================= // Date Id Modification // 2006-10-09 The Created this header //============================================================================= defaultproperties { Tag="GeoPlayer" //Dutch=true PlacingMarker=false bInMenu=false ReportingMode=MODE_None bCreatedNewSignalReport=false TemporaryMarker=None IsAllowedAssessment = true; PlacementOfMarkerXY=35 PlacementOfMarkerZ=155 bMovingToWarning=false bRememberWarning=false bCorrectionWarning=false bShowedHelpRedMarker=false bGameStartingCall=true bGameEndingCall=false ScorePossible = 0; ScorePlayer = 0; bIsGameOver=false bIsEndScore=false ingameTimer=0 updateTimer=true showTimer=false //TIMES FOR START AND ENDING OF GAME TimeInStart=5 TimeToEndIfOnlyNotSerious=900 TimeToEndGame=1440 EN_ScoreEvaluationAText = "Insufficient"; EN_ScoreEvaluationBText = "Sufficient"; EN_ScoreEvaluationCText = "Good"; EN_ScoreEvaluationDText = "Excellent"; EN_ScoreEvaluationEText = "Perfect"; NL_ScoreEvaluationAText = "Onvoldoende"; NL_ScoreEvaluationBText = "Voldoende"; NL_ScoreEvaluationCText = "Goed"; NL_ScoreEvaluationDText = "Uitstekend"; NL_ScoreEvaluationEText = "Perfect"; bCanBeDamaged = false; }