// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // class MouseItemInteraction extends Interaction; var Actor previoushover; var OfficeObject SondeerConusInToren; /// Conus in toren var OfficeObject SondeerConus; /// The new conus to check var OfficeObject_PickupSondeerConus ConusInHand; /// The conus which lays on the rack and has been clicked, and is now in the player hand var Actor SelectedBrush; var Canvas _canvas; var Font MedFont; var Font LargeFont; var bool ConusInHandsOK; /// Add extra rotational yaw to picked up conus. //var float incYaw; function NotifyLevelChange ( ) { Log("Notify level change in interaction"); } // Check for keyboard input (can be used for mouse input also). function bool KeyEvent( out EInputKey Key, out EInputAction Action, float Delta ) { local Actor a; local GeoPlayerController GeoPC; local SondeerWagenInterior interior; local Rotator rrot; local int i; local bool foundconus; /// Left mouse going up: /// IS the player in the right state? GeoPC = GeoPlayercontroller(ViewportOwner.Actor); if (GeoPC.IsInState('PlayerMousing')) { if (Key == IK_LeftMouse && Action == IST_Release) { Log("release"); SelectedBrush = None; return true; } /// Moving mouse: if (Action == IST_Axis) { if (SelectedBrush != None) { //newpos = CalcDrawOffset(SelectedBrush); // GetAxes( GeoPlayercontroller(ViewportOwner.Actor).Pawn.Rotation, Dir, X, Y); // SelectedBrush.MoveSmooth( (GeoPlayercontroller(ViewportOwner.Actor).Pawn.Location + 250*Dir + vect(0,0,50)) - SelectedBrush.Location); // SelectedBrush.SetLocation( GeoPlayercontroller(ViewportOwner.Actor).Pawn.Location + newpos ); } } if (Key == IK_LeftMouse && Action == IST_Press) { /// Trace actor: a = (Trace()); //Log(a.Tag @ " - " @ a.Name); if (a != None) { /// Object under neath cursor, which one? /* Inoffice: */ if (a.Tag == 'kleistaven') { GeoPC.playeractions.DidBringClayColumn = true; /// Remove them: a.destroy(); } if (a.Tag == 'opdrachtcomputer') { GeoPC.ClientOpenMenu("GeoInterface.MenuOpdrachtBon"); } Log(a.Tag); if(a.Tag == 'radio') { Log(OfficeObject_Radio(a)); /// Toggle: OfficeObject_Radio(a).Toggle(); } if(a.Tag == 'officedeur') { /// If we have not accepted an assigment, show a message: if (!GeoPC.playeractions.ApprovedAssignment) { GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("assignmentfirst","SondeerOffice") , 1, 5); } else { /// Enter sondeerwagen: EnterSondeerWagen(); } } if (a.Tag == 'whiteboard') { /// jln - 02-10-2008 Show game settings GeoPC.ClientOpenMenu("GeoInterface.MenuSettings"); } if (a.Tag == 'handboek') { /// jln - 02-10-2008 Help screen GeoPC.ClientOpenMenu("GeoInterface.MenuHandbook"); } if (a.Tag == 'paspoort') { /// passport has been clicked on, take it with you GeoPC.playeractions.DidBringPermit = true; /// Remove passport: a.destroy(); } /* In interior */ Log("Press: " @ a); if (a.Tag == 'borstel') { Log("Selected: " @ a); SelectedBrush = a; } /// jln - 19-11-2008 /// Replace cable with new one (level 4) if (a.tag == 'cablebroken') { GeoPC.playeractions.ReplacedCable = true; /// Replace cable mesh: if (GeoPC.GetCompany() == "Fugro") { a.SetStaticMesh( StaticMesh'SondeerMeester2.interior_fugro.Fugro_binnenkant_auto_kabel' ); } if (GeoPC.GetCompany() == "Geomil") { a.SetStaticMesh( StaticMesh'SondeerMeester2.interior_geomil.geomil_binnenkant_auto_kabel' ); } if (GeoPC.GetCompany() == "Deltares" || GeoPC.GetCompany() == "A.P. van den Berg") { a.SetStaticMesh( StaticMesh'SondeerMeester2.interior.binnenkant_auto_kabel' ); } /// perform replacement action. GeoPC.ClientOpenMenu("GeoInterface.dialogAlert",, GeoPC.IL8N("cablereplaced", "ingame")); } if(a.Tag == 'sondeercomputer') { if (GeoPC.playeractions.LEvelledVehicle == false) { /// Player forgot to stempel BEFORE pressing this button. Not good... GeoPC.playeractions.ForgotStempels = true; // not using dialogAlert here, because IL8N cannot be used (this is not a subclass of GeoGUIPage) GeoPC.ClientOpenMenu("GeoInterface.dialogAlert",, GeoPC.IL8N("stempelfirst", "ingame")); } else { /// Open sondeer computer menu: /// Did player chose a cone? if (GeoPC.playeractions.PlayerHasSelectedCone == true) { GeoPC.ClientOpenMenu("GeoInterface." $ GeoPC.GetSondeercomputerclass()); GeoPC.ClientOpenMenu("GeoInterface.MenuNulmeting", , "before"); } else { GeoPC.ClientOpenMenu("GeoInterface.dialogAlert",, GeoPC.IL8N("noconusselected", "ingame")); } } } if(a.Tag == 'opdrachtboninterior') { GeoPC.ClientOpenMenu("GeoInterface.MenuOpdrachtBon", false); } if (a.Tag == 'koffiebrief') { /// Show help GeoPC.ClientOpenMenu("GeoInterface.MenuHandbook"); } if (a.Tag == 'sondeertoren') { //// Call seperate function: SondeerTorenClick(); } if (a.tag == 'sondeerconusintoren') { SondeerTorenClick(); } if (a.Tag == 'stempelen') { /// Lower stempels: /// Inform if we already are: if (GeoPC.Lowerstempels() == true) { /// If we are in the verhicle (and we should be) make sure the verhicle has 0 pitch and roll interior = GetSondeerInterior(); if (interior != None) { interior.Stempelen(); } /// Reset rotation: rrot = GeoPC.Rotation; rrot.Pitch = 0; rrot.Roll = 0; GeoPC.SetRotation(rrot); /// And tell us: //GeoPC.ClientOpenMenu("GeoInterface.dialogStempels"); GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("stempeld","ingame") , 1, 5); } else { /// Already did this before: GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("alreadystempeld","ingame") , 1, 5); } } if(a.Tag == 'pickupconus1' || a.Tag == 'pickupconus2') { /// Open sondeer computer menu: /// Spawn sondeerstand if not already available: Log("Sondeerstang:" @ a.Tag); /// If we have an selected hide it: if (SondeerConus != None) { HideConus(); if (ConusInHand != None) { /// Make the originally selected conus visible again at the table: ConusInHand.bHidden = false; ConusInHand = None; } } if (SondeerConus == None) { ConusInHand = OfficeObject_PickupSondeerConus(a); ConusInHand.bHidden = true; SpawnConus( OfficeObject_PickupSondeerConus(a).GetOldConus() ); } } if (a.Tag == 'sondeerconus') { /// cone has been clicked on, hide it: if (SondeerConus != None) { ConusInHand.bHidden = false; ConusInHand = None; HideConus(); } } if (a.Tag == 'ontluchten') { /// cone has been clicked on, hide it: if (SondeerConus != None) { // GeoPC.SetLocation(a.Location); // GeoPC.Pawn.SetLocation(a.Location); /// Add conus to list of ontluchte conusses: foundconus = false; for (i = 0; i < GeoPC.ontluchteconussen.length; i++) { if (GeoPC.ontluchteconussen[i] == SondeerConus.ExtraTag) { foundconus = true; break; } } if (foundconus == false) { GeoPC.ontluchteconussen.insert(0,1); GeoPC.ontluchteconussen[0] = SondeerConus.ExtraTag; } GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("conusontlucht", "ingame"), 1, 5); } else { GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("noconusontluchten", "ingame"), 1, 5); } } } return true; } } if ((Action == IST_Press) && (Key == IK_SPACE)) { GeoPC.SkipAnimation = true; } /* /// Special keys: if ((Action == IST_Press) && (Key == IK_A)) { /// Reset: GeoPC.GotoState(''); GeoPC.EnterStartState(); return true; } if ((Action == IST_Press) && (Key == IK_S)) { GeoPC.GotoState('PlayerMousing'); return true; } */ return false; } /// jln - 25-11-2008 function SondeerTorenClick() { // local Actor a; local GeoPlayerController GeoPC; local SondeerWagenInterior interior; local int i; local bool bfound; GeoPC = GeoPlayercontroller(ViewportOwner.Actor); interior = GetSondeerInterior(); /// Player does not have a cone in the sondeertower yet: if (GeoPC.PlayerActions.PlayerHasSelectedCone == false) { /// Player does have a cone in his hands if (SondeerConus != None) { /// So, spawn conus in the tower: SondeerConusInToren = GeoPC.Spawn(class'OfficeObject', ,'sondeerconusintoren', interior.location, interior.rotation); if (GeoPC.GetCompany() ~= "Geomil") { /// Different conus for geomil: Log("Geomil sondeerconus"); SondeerConusInToren.SetStaticMesh( StaticMesh'SondeerMeester2.interior_geomil.Geomil_binnenkant_auto_sondeertoren_conus'); } else { SondeerConusInToren.SetStaticMesh( StaticMesh'SondeerMeester2.interior.binnenkant_auto_sondeertoren_conus'); } log("==SondeerConus = "$SondeerConus); log("==PickupSondeerConus(SondeerConus) = " $ OfficeObject_PickupSondeerConus(SondeerConus)); //// Give it a proper texture depending on the cone which is in the hands: interior.oconusintoren = SondeerConusInToren; /// Log("Conus type: " SondeerConus @ " - " @ PickupSondeerConus(SondeerConus)); if (ConusInHandsOK==false) { SondeerConusInToren.Skins[0] = Texture'sondeermeester.conus.sconus_old_diff'; GeoPC.playeractions.HasCorrectCone = false; } else { SondeerConusInToren.Skins[0] = Texture'sondeermeester.conus.sconus_diff'; GeoPC.playeractions.HasCorrectCone = true; } log("HasCorrectCone set to "$GeoPC.playeractions.HasCorrectCone); /// Is this conus properly vented? bfound = false; for (i = 0; i < GeoPC.ontluchteconussen.length; i++) { Log("Tags found: " @ GeoPC.ontluchteconussen[i] @ " - "@ SondeerConus.Tag); if (GeoPC.ontluchteconussen[i] == SondeerConus.ExtraTag) { bfound = true; //break; } } Log("Bfound: "@ bfound); /// Yes, player has checked for air ("ontluchten"); GeoPC.playeractions.CheckedForAir = bfound; /// Hide the cone which is in the hands: HideConus(); /// jln - 17-11-2008 (SONDEER-60) /// Store the fact that we have actually selected a cone: GeoPC.PlayerActions.PlayerHasSelectedCone = true; GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("conusplaced","ingame") , 1, 5); } else { /// Player does not have a conus in his hands yet GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("noconusinhands","ingame") , 1, 5); } } else { /// Player DOES have a conus in the tower yet. /// Player does have a cone in his hands if (SondeerConus != None) { /// Switch cone - Remove current one: interior.oConusinToren = None; SondeerConusInToren.Destroy(); /// Spawn new one: SondeerConusInToren = GeoPC.Spawn(class'OfficeObject', ,'sondeerconusintoren', interior.location, interior.rotation); if (GeoPC.GetCompany() ~= "Geomil") { /// Different conus for geomil: Log("Geomil sondeerconus"); SondeerConusInToren.SetStaticMesh( StaticMesh'SondeerMeester2.interior_geomil.Geomil_binnenkant_auto_sondeertoren_conus'); } else { SondeerConusInToren.SetStaticMesh( StaticMesh'SondeerMeester2.interior.binnenkant_auto_sondeertoren_conus'); } interior.oConusinToren = SondeerConusInToren; /// Put the cone which is currently in the hands inside the tower: Log("Conus in hands is: " @ ConusInHandsOK); if (ConusInHandsOK == false) { SondeerConusInToren.Skins[0] = Texture'sondeermeester.conus.sconus_old_diff'; GeoPC.playeractions.HasCorrectCone = false; /// Then the previous cone was correct, spawn it back: //interior.SpawnConusBack(false); interior.osondeerbuis1.bHidden = false; } else { SondeerConusInToren.Skins[0] = Texture'sondeermeester.conus.sconus_diff'; GeoPC.playeractions.HasCorrectCone = true; //// Then the previous cone was damaged, spawn it back: //interior.SpawnConusBack(true); interior.osondeerbuis2.bHidden = false; } /// Is this conus properly vented? bfound = false; for (i = 0; i < GeoPC.ontluchteconussen.length; i++) { Log("Tags found: " @ GeoPC.ontluchteconussen[i] @ " - "@ SondeerConus.Tag); if (GeoPC.ontluchteconussen[i] == SondeerConus.ExtraTag) { bfound = true; // break; } } Log("Bfound: "@ bfound); /// Yes, player has checked for air ("ontluchten"); GeoPC.playeractions.CheckedForAir = bfound; /// jln - 17-11-2008 (SONDEER-60) /// Store the fact that we have actually selected a cone: GeoPC.PlayerActions.PlayerHasSelectedCone = true; /// Hide selected conus - which is now in the hands: HideConus(); GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("conusreplaced","ingame") , 1, 5); } else { /// Player does not have a conus in his hands yet //GeoHud(GeoPC.myHud).SetMessage( GeoPC.IL8N("conusalreadyplaced","ingame") , 1, 5); Log("not in hands, but already in tower"); SondeerConusInToren.Destroy(); GeoPC.PlayerActions.PlayerHasSelectedCone = false; /// did player have correct cone? if (GeoPC.playeractions.HasCorrectCone == false) { interior.osondeerbuis1.bHidden = false; } else { interior.osondeerbuis2.bHidden = false; } } } } function SondeerWagenInterior GetSondeerInterior() { local SondeerWagenInterior O; local GeoPlayerController GeoPC; GeoPC = GeoPlayercontroller(ViewportOwner.Actor); /// Find first sondeer interior and return it. foreach GeoPC.AllActors (class'SondeerWagenInterior', O) { return O; } } /// jln - 02-10-2008 Try to enter the sondeer wagen, and hide the building. function EnterSondeerWagen() { local GeoPlayerController GeoPC; local SondeerOffice O; local SondeerWagen S; GeoPC = GeoPlayercontroller(ViewportOwner.Actor); foreach GeoPC.AllActors (class'SondeerWagen', S) { /// Found one? enter it. S.TryToDrive(GeoPC.Pawn); ///Exit loop; break; } /// Destroy it, we do not need it anymore! foreach GeoPC.AllActors (class'SondeerOffice', O) { o.Destroy(); } /// Display phase message: GeoPC.ClientOpenMenu("GeoInterface.dialogPhaseIntro", false, "Phase2"); } function HideConus() { SondeerConus.Destroy(); Sondeerconus = None; } function Actor SpawnConus(bool oldconus) { local vector EyePos; local actor camactor; local vector CamPos; local rotator CamRot; local GeoPlayerController GeoPC; /// Left mouse going up: /// IS the player in the right state? GeoPC = GeoPlayercontroller(ViewportOwner.Actor); GeoPC.PlayerCalcView(camactor,CamPos,CamRot); //EyePos = EyePos + (CamRot * vect(1,1,1)); SondeerConus = GeoPC.Spawn(class'OfficeObject', ,'sondeerconus', EyePos, Camrot); // SondeerConus.SetStaticMesh( StaticMesh'SondeerMeester2.interior.sondeerconus' ); // SondeerConus.SetDrawScale(2); if (oldconus) { SondeerConus.SetStaticMesh( StaticMesh'SondeerMeester2.conus.sondeerconus_old' ); SondeerConus.ExtraTag = "conusold"; ConusInHandsOK = false; /// Player does not have correct cone: // GeoPC.playeractions.HasCorrectCone = false; // SondeerConus.Skins[0] = Texture'sondeermeester.conus.sconus_old_diff'; } else { SondeerConus.SetStaticMesh( StaticMesh'SondeerMeester2.conus.sondeerconus_new' ); SondeerConus.ExtraTag = "conusnew"; ConusInHandsOK = true; //// Player does have correct cone: // GeoPC.playeractions.HasCorrectCone = true; // SondeerConus.Skins[0] = Texture'sondeermeester.conus.sconus_diff'; } // Log("Player has correct cone: " @ GeoPC.playeractions.HasCorrectCone); EyePos = CalcDrawOffset(SondeerConus); EyePos += GeoPC.Pawn.Location; SondeerConus.SetLocation(EyePos); return SondeerConus; // incYaw = 0; } /// Calculate offset to have the cone into the player view: simulated function vector CalcDrawOffset(Actor oactor) { local vector DrawOffset; local vector PlayerviewOffset; local GeoPlayerController GeoPC; PlayerViewOffset = vect(50,0,2); GeoPC = GeoPlayercontroller(ViewportOwner.Actor); DrawOffset = ((0.9/GeoPC.FOVAngle * 90 * PlayerViewOffset) >> GeoPC.GetViewRotation() ); DrawOffset.Z += GeoPC.Pawn.EyeHeight; return DrawOffset; } function PostRender( canvas Canvas ) { local Actor a; local GeoPlayerController GeoPC; local vector EyePos; Local rotator EyeRot; If (ViewportOwner.Actor == None || ViewportOwner.Actor.Pawn == None || ViewportOwner.Actor.Pawn.PlayerReplicationInfo == None) { /// Reset: Sondeerconus = None; return; } GeoPC = GeoPlayercontroller(ViewportOwner.Actor); if (GeoPC == None) { Sondeerconus = None; return; } /// Store: _canvas = Canvas; /// Are we holding a cone: if (SondeerConus != None) { EyePos = CalcDrawOffset(SondeerConus); EyeRot = GeoPC.GetViewRotation(); // incYaw += 0.001; // EyeRot.Yaw += incYaw; // EyeRot += (EyeRot * incYaw); Sondeerconus.SetRotation(Eyerot); //SondeerConus.SetRotation(rot(0,0,0)); EyePos += GeoPC.Pawn.Location; SondeerConus.SetLocation(EyePos); } /// If not mousing: if (GeoPC.IsInState('PlayerMousing')) { a = Trace(); } else { a = None; } if (a != None) { /// Different object, update: if (a != previoushover) { a.bUnlit=true; //a.SetDrawScale(a.OriginalScale + 0.1); /// Restore old: if (previoushover != None) { previoushover.bUnlit=false; } /// Set: previoushover = a; } } else { /// Return previous object to drawscale 0. if (previoushover != None) { previoushover.bUnlit=false; /// Turn none: previoushover = None; } } //RenderToolTips(Canvas); } // Perform a trace from the players view to the object he is looking // at, the trace will return the first actor which the trace hits. function Actor Trace () { local OfficeObject a; // local Mover m; local Actor found; local vector vHitNormal, vHitLocation, vTraceStart, vTraceEnd; local PlayerController PC; local vector mouseDir; local vector mousePos; local string tagString; local string toolTipString; local vector hudposition; // Set the player controller to the one used in the current // viewport. PC = ViewportOwner.Actor; // if the playercontroller and the pawn are not none (they exist). if (PC != none && PC.Pawn != none) { // Set a vector start of the trace to be the players location. vTraceStart = PC.Pawn.Location; // Now set the Z of the vector to be the players eye height. vTraceStart.Z += PC.Pawn.EyeHeight; mousePos.x = GeoPlayercontroller(PC).MouseScreenX; mousePos.y = GeoPlayercontroller(PC).MouseScreenY; mouseDir = ScreenToWorld(mousePos, vTraceStart, PC.Pawn.GetViewRotation()); vTraceEnd = vTraceStart + mouseDir * 3000; /// Simple fix for doors, try movers as well: // Now we use the TraceActors iteractor along with our vectors, // This will return the first actor between the start and end // of the trace. // foreach PC.TraceActors (class'Mover', m, vHitLocation, vHitNormal, vTraceEnd, vTraceStart) // { // if (m != None) // { // found = m; // break; // } /// return m; // } if (found != None) { //return found; } else { foreach PC.TraceActors (class'OfficeObject', a, vHitLocation, vHitNormal, vTraceEnd, vTraceStart) { if (a != None && a.bMouseEnabled == true) { found = a; break; } // return a; } } //return found; } /// jln - 06-10-2008 We got something, display a tag on the canvas: if (found != None) { hudposition = WorldToScreen(vHitLocation); _canvas.SetDrawColor(255,255,255); _canvas.Font = LargeFont; _canvas.SetPos(hudposition.x, hudposition.y); /// 2004 function... // _canvas.DrawScreenText( found.Name, hudposition.x / _canvas.SizeX, hudposition.y / _canvas.sizey, DP_UpperLeft ); tagString = string(found.Tag); toolTipString = GeoPlayercontroller(PC).IL8N(tagString, "officeobjects"); _canvas.DrawTextClipped (" " @ toolTipString); return found; } return none; } function RenderToolTips( canvas Canvas ) { local vector CameraLocation, dir, ScreenLocation; local rotator CameraRotation; local OfficeObject A; local float dist; //, draw_scale; local Actor AV; local vector hudposition; Canvas.Style = 3; Canvas.SetDrawColor(255,255,255); Canvas.Font = LargeFont; ViewPortOwner.Actor.PlayerCalcView(AV, CameraLocation, CameraRotation); foreach ViewportOwner.Actor.AllActors (class'OfficeObject', A) //, 8000, CameraLocation) { ScreenLocation = WorldToScreen(A.location); dir = A.Location - CameraLocation; dist = Abs(VSize(dir)); //Distance between me and them if (dist < 1000 && (dir dot vector(CameraRotation) > 0)) { hudposition.x = ScreenLocation.X;// - (32 * draw_scale); hudposition.y = ScreenLocation.Y;// - (32 * draw_scale); Canvas.SetDrawColor(255,255,255); Canvas.SetPos(hudposition.x, hudposition.y); Canvas.DrawText("C: " @ A.Class @ " (" @ A.Name @ ")"); Canvas.SetPos(hudposition.x, hudposition.y + 10); Canvas.DrawText("T: " @ A.Tag); } } } // These must be set for the interaction to work defaultproperties { bActive=true bVisible=true bRequiresTick=True MedFont=Font'GeoFonts.NormalFontTex2' LargeFont=Font'GeoFonts.LargeFontTex2' }