Commits

Rainer Hilmer committed 8d0e64f Merge

Merge branch 'feature/FeatureRequest-2&3' into develop

Comments (0)

Files changed (7)

EmergencyRecover/EmergencyRecover.Guide/EmergencyRecoverGuide.htm

    <p>As always with my mods you can also configure various things here.<br />
       The game recovery is a bit tricky, so this mod lets you decide how aggressive it 
       will behave.<br />
-      The most careful mode just tries to unfreeze stuck peds and vehicles.<br />
+      You can change any settings at any time. The configuration is being read every 
+      time you hit Ctrl+R (even if you decide to change the hotkey).<br />
+      </p>
+   <p>The most careful mode just tries to unfreeze stuck peds and vehicles.<br />
       If that don&#39;t help you can choose to also release the peds in your surrounding 
       from their current tasks. CAUTION: This will most likely interfer with any 
       missions and mods which spawn mission peds like LCPDFR, Tow service, PTS or the 
             style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
          <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;<span 
+            style="color: blue;">&nbsp; &lt;</span><span style="color: purple;">AffectPlayerVehicle</span><span 
+            style="color: blue;">&gt;</span>false<span style="color: blue;">&lt;/</span><span 
+            style="color: purple;">AffectPlayerVehicle</span><span style="color: blue;">&gt;</span></p>
+      <p style="margin: 0px;">
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;<span 
             style="color: blue;">&nbsp; &lt;</span><span style="color: purple;">ClearTasks</span><span 
             style="color: blue;">&gt;</span>false<span style="color: blue;">&lt;/</span><span 
             style="color: purple;">ClearTasks</span><span style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;<span 
             style="color: blue;">&nbsp; &lt;</span><span style="color: purple;">DeletePeds</span><span 
             style="color: blue;">&gt;</span>false<span style="color: blue;">&lt;/</span><span 
             style="color: purple;">DeletePeds</span><span style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;<span 
             style="color: blue;">&nbsp; &lt;</span><span style="color: purple;">DeleteVehicles</span><span 
             style="color: blue;">&gt;</span>false<span style="color: blue;">&lt;/</span><span 
             style="color: purple;">DeleteVehicles</span><span style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;<span 
             style="color: blue;">&nbsp; &lt;</span><span style="color: purple;">KeyContainer</span><span 
             style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;<span 
             style="color: blue;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: purple;">Alt</span><span 
             style="color: blue;">&gt;</span>false<span style="color: blue;">&lt;/</span><span 
             style="color: purple;">Alt</span><span style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;<span 
             style="color: blue;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: purple;">Ctrl</span><span 
             style="color: blue;">&gt;</span>false<span style="color: blue;">&lt;/</span><span 
             style="color: purple;">Ctrl</span><span style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;<span 
             style="color: blue;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: purple;">Key</span><span 
             style="color: blue;">&gt;</span>R<span style="color: blue;">&lt;/</span><span 
             style="color: purple;">Key</span><span style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;10</span>&nbsp;<span 
             style="color: blue;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: purple;">Name</span><span 
-            style="color: blue;">&gt;</span>RecoverAll<span style="color: blue;">&lt;/</span><span 
+            style="color: blue;">&gt;</span>Recover<span style="color: blue;">&lt;/</span><span 
             style="color: purple;">Name</span><span style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;10</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;11</span>&nbsp;<span 
             style="color: blue;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: purple;">Shift</span><span 
             style="color: blue;">&gt;</span>true<span style="color: blue;">&lt;/</span><span 
             style="color: purple;">Shift</span><span style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;11</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;12</span>&nbsp;<span 
             style="color: blue;">&nbsp; &lt;/</span><span style="color: purple;">KeyContainer</span><span 
             style="color: blue;">&gt;</span></p>
       <p style="margin: 0px;">
-         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;12</span>&nbsp;<span 
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;13</span>&nbsp;<span 
+            style="color: blue;">&nbsp; &lt;</span><span style="color: purple;">UnlockVehicles</span><span 
+            style="color: blue;">&gt;</span>true<span style="color: blue;">&lt;/</span><span 
+            style="color: purple;">UnlockVehicles</span><span style="color: blue;">&gt;</span></p>
+      <p style="margin: 0px;">
+         <span style="color: teal; background: white;">&nbsp;&nbsp;&nbsp;14</span>&nbsp;<span 
             style="color: blue;">&lt;/</span><span style="color: purple;">ConfigurationContainer</span><span 
             style="color: blue;">&gt;</span></p>
    </div>
 <!--EndFragment-->
+<!--EndFragment-->
 <p>Line 1 is the XML header. Don&#39;t touch it!</p>
+   <p><b>AffectPlayerVehicle</b> tag: If set to true the recovery process will also 
+      affect your own vehicle. So beware, if you have also set DeleteVehicles to true 
+      you will stand on your feet in the middle of the street all over sudden!</p>
    <p><b>ClearTasks</b> tag: If set to true the mod will release all peds in the 5 
       meter perimeter from their tasks.</p>
    <p><b>DeletePeds</b> tag: If set to true the mod will delete all peds in the 
       the perimeter. So watch out that not your own vehicle is inside.</p>
    <p><b>KeyContainer</b> tag: This is the definition of the hotkey to press in order 
       to run this mod (default is <b>Shift+R</b>).</p>
+   <p><b>UnlockVehicles</b> tag: If set to true the mod wil try to unlock every car in 
+      the perimeter.</p>
    <p>If you need further assistance about XML files or the key container, please 
       download the PTS guide from this URL:<br />
       <a href="https://bitbucket.org/rainerhilmer/pts/downloads">
       https://bitbucket.org/rainerhilmer/pts/downloads</a></p>
+   <p>You probably ask, why all those parameters.<br />
+      - The bug of stuck peds and vehicles comes in different flavors. You can tailor 
+      the mod&#39;s behavior at every time to your exact needs with as minimum harm as 
+      required.<br />
+      - You can combine any parameters to your current needs. For an example let&#39;s say 
+      you play LCPDFR and you encounter the cops you called are stuck in a frozen car 
+      which hovers in mid-air. You don&#39;t want to loose them and they shall continue 
+      with their task.<br />
+      In that case you can try the following combination (no guarantee it works 
+      because of the bug&#39;s unforseeable severity):<br />
+      - Set ClearTasks and DeletePeds to <span class="code_blue">false</span><br />
+      - Set UnlockVehicles to <span class="code_blue">true<br />
+      </span>
+      <br />
+      - (Unfreeze peds and vehicles is hard coded and always true)<br />
+      - Place yourself near the stuck police car and hit Ctrl+R.<br />
+      If you are lucky the car will fall on it&#39;s wheels, the cops get out of the car 
+      and catch the criminal. It happened that way with several tests in my game but 
+      at other times not.<br />
+      Like I said, it depends on how severe the bug has hit.</p>
    <p>&nbsp;</p>
 </body>
 </html>

EmergencyRecover/EmergencyRecover/ConfigurationContainer.cs

 {
    public class ConfigurationContainer
    {
+      public bool AffectPlayerVehicle { get; set; }
       public bool ClearTasks { get; set; }
       public bool DeletePeds { get; set; }
       public bool DeleteVehicles { get; set; }
       /// Enthält den Keyboard-Steuercode für den Mod.
       /// </summary>
       public KeyContainer KeyContainer { get; set; }
+      public bool UnlockVehicles { get; set; }
    }
 }

EmergencyRecover/EmergencyRecover/ConfigurationHandling.cs

       {
          var config = new ConfigurationContainer
                          {
+                            AffectPlayerVehicle = false,
                             ClearTasks = false,
+                            DeletePeds = false,
                             DeleteVehicles = false,
                             KeyContainer = new KeyContainer
                                               {
                                                  Alt = false,
                                                  Ctrl = false,
                                                  Key = Keys.R,
-                                                 Name = "RecoverAll",
-                                                 Shift = false
-                                              }
+                                                 Name = "Recover",
+                                                 Shift = true
+                                              },
+                            UnlockVehicles = true
                          };
          new XmlIo(_fullPath).Save(config);
       }

EmergencyRecover/EmergencyRecover/Core.cs

       private void OneyKeyDown(object sender, KeyEventArgs e)
       {
          Configuration = new ConfigurationHandling().ReadConfig();
-         if(Configuration == null)
+         if (Configuration == null)
             CommonFunctions.DisplayText("Configuration could not be read!", 3000);
          _keyHandling.HandleKey(e);
       }
          var actualPosition = Player.Character.Position;
          foreach (var ped in PedsAround(actualPosition))
          {
-            if(ReferenceEquals(Player.Character, ped))
+            if (ReferenceEquals(Player.Character, ped))
                continue;
             ped.FreezePosition = false;
             ClearTasksIfRequested(ped);
          foreach (var vehicle in VehiclesAround(actualPosition))
          {
             vehicle.FreezePosition = false;
-               vehicle.NoLongerNeeded();
+            UnlockVehicleIfRequested(vehicle);
             DeleteVehicleIfRequested(vehicle);
          }
-         CommonFunctions.DisplayText("Emergency recovery done.", 5000);
+         CommonFunctions.DisplayText("Emergency recovery done.", 4000);
+      }
+
+      private bool AffectPlayerVehicleIfRequested(Vehicle vehicle)
+      {
+         if (!Configuration.AffectPlayerVehicle && ReferenceEquals(Player.LastVehicle, vehicle))
+            return false;
+         return true;
       }
 
       private void ClearTasksIfRequested(Ped ped)
 
       private void DeletePedIfRequested(Ped ped)
       {
-         if(!Configuration.DeletePeds)
+         if (!Configuration.DeletePeds)
             return;
-         if(!CommonFunctions.PedExists(ped))
+         if (!CommonFunctions.PedExists(ped))
             return;
          ped.NoLongerNeeded();
          ped.Delete();
             return;
          if (!CommonFunctions.VehicleExists(vehicle))
             return;
-         vehicle.Delete();
+         if (AffectPlayerVehicleIfRequested(vehicle))
+            vehicle.Delete();
+      }
+
+      private void UnlockVehicleIfRequested(Vehicle vehicle)
+      {
+         if (!Configuration.UnlockVehicles)
+            return;
+         if (!CommonFunctions.VehicleExists(vehicle))
+            return;
+         if (AffectPlayerVehicleIfRequested(vehicle))
+         {
+            vehicle.NoLongerNeeded();
+            vehicle.DoorLock = DoorLock.None;
+         }
       }
 
       private static IEnumerable<Ped> PedsAround(Vector3 actualPosition)

EmergencyRecover/EmergencyRecover/KeyHandling.cs

 
       internal void HandleKey(KeyEventArgs e)
       {
-         AtRecoverAllKey(e);
+         AtRecoverKey(e);
       }
 
       private static bool CompareKeyWith(KeyContainer keyContainer, KeyEventArgs keyEventArgs)
                 && keyContainer.Key == keyEventArgs.Key;
       }
 
-      private void AtRecoverAllKey(KeyEventArgs e)
+      private void AtRecoverKey(KeyEventArgs e)
       {
          if(!CompareKeyWith(GetKeyContainer(), e))
             return;

EmergencyRecover/EmergencyRecover/Properties/AssemblyInfo.cs

 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.*")]
+[assembly: AssemblyVersion("2.0.0.*")]
 //[assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: InternalsVisibleTo("EmergencyRecover.Tests")]

EmergencyRecover/EmergencyRecover/bin/x86/Release/EmergencyRecover.net.dll

Binary file modified.