Skip to content

Commit 342351d

Browse files
ExtendedCheats v1.4
1 parent 70d1887 commit 342351d

File tree

3 files changed

+165
-8
lines changed

3 files changed

+165
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
- 1.2.2 Fix overrides messing up a lot of stuff
2222
- 1.2.3 Fix overrides array reset
2323
- 1.3 Add option to disable neutral zones (under commands, for each character)
24+
- 1.4 Allow disabling regroup points (by character and completely)
25+
Allow disabling all usable items (e.g. gatliings, doors, dynamite, etc.) by character or completely
26+
Hide disabled characters
27+
Allow adjusting character order
2428

2529
# BetterLevelEditor
2630
- 1.0 Initial release
@@ -34,4 +38,3 @@
3438
- 1.0 Initial release
3539
- 1.1 Add option to force Kate to use the Shadow Tactics fan when doing her fan idle animation wearing a disguise
3640
- 1.2 Add option to remove the idle animations cooldown causing characters to continously play one idle animation after another
37-

ExtendedCheats/Commands.cs

Lines changed: 160 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
using BepInEx;
21
using BepInEx.Configuration;
32
using HarmonyLib;
43
using System.Collections;
5-
using System.IO;
4+
using System.Linq;
65
using System.Reflection;
76
using UnityEngine;
87

@@ -13,6 +12,15 @@ static class Commands
1312
static bool show = false;
1413
static int charToShow = -1;
1514
static int charCount = 0;
15+
static bool showRegroups = false;
16+
17+
static bool showUsables = false;
18+
static MiUsable[] usables = null;
19+
static int selectedUsable = -1;
20+
static float usablesLastUpdate = 0;
21+
static int usablesPage = 0;
22+
const int PAGE_SIZE = 20;
23+
1624
static readonly FieldInfo fieldMissionSetupSettings_s_difficultySettings = AccessTools.Field(typeof(MissionSetupSettings), "s_difficultySettings");
1725

1826
public static void Bind(ConfigFile config)
@@ -43,7 +51,7 @@ static void DrawCommands(ConfigEntryBase entry)
4351

4452
GUILayout.BeginVertical();
4553

46-
if (GUILayout.Button(show ? "Hide" : "Show")) show = !show;
54+
if (GUILayout.Button(show ? "Hide" : "Expand")) show = !show;
4755
if (!show)
4856
{
4957
GUILayout.EndVertical();
@@ -100,6 +108,9 @@ static void DrawCommands(ConfigEntryBase entry)
100108
statsNoSaveData.lPlayerStateDurations.Clear();
101109
}
102110

111+
DrawRegroups();
112+
DrawMiUsables();
113+
103114
#if DEBUG
104115
if (GUILayout.Button("Dump Skill Data"))
105116
{
@@ -134,7 +145,8 @@ static void DrawCommands(ConfigEntryBase entry)
134145
{
135146
if (character.enabled)
136147
{
137-
AccessTools.Method(typeof(MiCharacter), "disable").Invoke(gameInput.lPlayerCharacter[i], new object[] { false, false, false });
148+
AccessTools.Method(typeof(MiCharacter), "disable").Invoke(character, new object[] { false, false, false });
149+
character.gameObject.SetActive(false);
138150
if (charToShow == i) charToShow = -1;
139151
}
140152
GUILayout.EndHorizontal();
@@ -143,13 +155,14 @@ static void DrawCommands(ConfigEntryBase entry)
143155

144156
if (!character.enabled)
145157
{
146-
AccessTools.Method(typeof(MiCharacter), "enable").Invoke(gameInput.lPlayerCharacter[i], new object[] { true, false, false, true });
158+
AccessTools.Method(typeof(MiCharacter), "enable").Invoke(character, new object[] { true, false, false, true });
159+
character.gameObject.SetActive(true);
147160
}
148161

149162
GUILayout.Label($"Health: {character.m_charHealth.iHealth}", GUILayout.Width(80));
150163
if (GUILayout.Button("-", GUILayout.Width(50))) character.m_charHealth.iHealth--;
151164
if (GUILayout.Button("+", GUILayout.Width(50))) character.m_charHealth.iHealth++;
152-
if (GUILayout.Button(charToShow == i ? "Hide" : "Show"))
165+
if (GUILayout.Button(charToShow == i ? "Hide" : "Expand"))
153166
{
154167
if (charToShow == i) charToShow = -1;
155168
else charToShow = i;
@@ -165,6 +178,23 @@ static void DrawCommands(ConfigEntryBase entry)
165178
}
166179
DrawLevelInfoFlag(character, "Neutral Zone 1", LevelInformationLayer.LevelInfoFlag.NeutralZone1);
167180
DrawLevelInfoFlag(character, "Neutral Zone 2", LevelInformationLayer.LevelInfoFlag.NeutralZone2);
181+
182+
var playerController = character.controller as MiCharacterControllerPlayer;
183+
if (playerController != null)
184+
{
185+
GUILayout.BeginHorizontal();
186+
187+
GUILayout.Label("Character Slot (0 = None)", GUILayout.Width(200));
188+
189+
var before = SelectionInputToInt(playerController.eSelectionInput) + 1;
190+
var afterStr = GUILayout.TextField(before.ToString(), Main.SkinFloatField, GUILayout.Width(30));
191+
if (!string.IsNullOrWhiteSpace(afterStr) && int.TryParse(afterStr, out var after) && after != before)
192+
playerController.setSelectionInputBySlotIndex(after - 1);
193+
194+
GUILayout.Label("Disable and Enable character to apply");
195+
GUILayout.EndHorizontal();
196+
}
197+
168198
GUILayout.EndVertical();
169199
}
170200

@@ -174,6 +204,110 @@ static void DrawCommands(ConfigEntryBase entry)
174204
GUILayout.EndVertical();
175205
}
176206

207+
static void DrawRegroups()
208+
{
209+
if (GUILayout.Button(showRegroups ? "Hide meeting points" : "Expand meeting points")) showRegroups = !showRegroups;
210+
if (!showRegroups) return;
211+
212+
GUILayout.BeginVertical("box");
213+
214+
var regroups = Object.FindObjectsOfType<TriggerVolumeRegroup>();
215+
216+
foreach (var regroup in regroups)
217+
{
218+
if (regroup.transform.position.sqrMagnitude == 0) continue;
219+
220+
GUILayout.BeginVertical("box");
221+
GUILayout.Label(regroup.gameObject.name);
222+
var enabled = GUILayout.Toggle(regroup.enabled, regroup.enabled ? "Enabled" : "Disabled");
223+
if (enabled != regroup.enabled)
224+
{
225+
regroup.enabled = enabled;
226+
var minDist = float.PositiveInfinity;
227+
UITriggerVolumeRegroup minUi = null;
228+
var field = AccessTools.Field(typeof(UITriggerVolumeRegroup), "m_v3WorldPosition");
229+
foreach (var ui in Resources.FindObjectsOfTypeAll(typeof(UITriggerVolumeRegroup)))
230+
{
231+
var dist = Vector3.Distance((Vector3)field.GetValue(ui), regroup.transform.position);
232+
if (dist > minDist || minUi == null) continue;
233+
minDist = dist;
234+
minUi = ui as UITriggerVolumeRegroup;
235+
}
236+
if (minUi != null) minUi.gameObject.SetActive(enabled);
237+
}
238+
239+
DrawCharacterFlag("Cooper", ref regroup.m_eCondition, MiCharacter.CharacterType.Cooper);
240+
DrawCharacterFlag("Doc", ref regroup.m_eCondition, MiCharacter.CharacterType.McCoy);
241+
DrawCharacterFlag("Hector", ref regroup.m_eCondition, MiCharacter.CharacterType.Trapper);
242+
DrawCharacterFlag("Kate", ref regroup.m_eCondition, MiCharacter.CharacterType.Kate);
243+
DrawCharacterFlag("Isabelle", ref regroup.m_eCondition, MiCharacter.CharacterType.Voodoo);
244+
245+
GUILayout.EndVertical();
246+
}
247+
248+
GUILayout.EndVertical();
249+
}
250+
251+
static void DrawMiUsables()
252+
{
253+
254+
if (GUILayout.Button(showUsables ? "Hide usables" : "Expand usables")) showUsables = !showUsables;
255+
if (!showUsables) return;
256+
257+
if (usables == null || usablesLastUpdate + 10 < Time.realtimeSinceStartup)
258+
{
259+
usables = Object.FindObjectsOfType<MiUsable>().Where(u => u.transform.position.sqrMagnitude > 0 && !(u is MiUsableCorpseHiding)).ToArray();
260+
selectedUsable = -1;
261+
}
262+
usablesLastUpdate = Time.realtimeSinceStartup;
263+
var start = usablesPage * PAGE_SIZE;
264+
var end = System.Math.Min(usablesPage * PAGE_SIZE + PAGE_SIZE, usables.Length);
265+
266+
GUILayout.BeginVertical("box");
267+
for (var i = start; i < end; i++)
268+
{
269+
var usable = usables[i];
270+
GUILayout.BeginHorizontal();
271+
GUILayout.Label(usable.name, GUILayout.Width(300));
272+
var show = selectedUsable == i;
273+
if (GUILayout.Button(show ? "Hide" : "Expand"))
274+
{
275+
if (show) selectedUsable = -1;
276+
else selectedUsable = i;
277+
}
278+
GUILayout.EndHorizontal();
279+
if (show)
280+
{
281+
GUILayout.BeginVertical("box");
282+
var enabled = GUILayout.Toggle(usable.enabled, usable.enabled ? "Enabled" : "Disabled");
283+
if (enabled != usable.enabled)
284+
{
285+
usable.enabled = enabled;
286+
usable.gameObject.SetActive(enabled);
287+
}
288+
DrawCharacterFlag("Cooper", ref usable.m_eCanUsedBy, MiCharacter.CharacterType.Cooper);
289+
DrawCharacterFlag("Doc", ref usable.m_eCanUsedBy, MiCharacter.CharacterType.McCoy);
290+
DrawCharacterFlag("Hector", ref usable.m_eCanUsedBy, MiCharacter.CharacterType.Trapper);
291+
DrawCharacterFlag("Kate", ref usable.m_eCanUsedBy, MiCharacter.CharacterType.Kate);
292+
DrawCharacterFlag("Isabelle", ref usable.m_eCanUsedBy, MiCharacter.CharacterType.Voodoo);
293+
294+
GUILayout.EndVertical();
295+
}
296+
}
297+
GUILayout.BeginHorizontal();
298+
if (GUILayout.Button("Prev") && usablesPage > 0)
299+
{
300+
usablesPage--;
301+
}
302+
GUILayout.Label($"${usablesPage + 1}/${ (usables.Length + PAGE_SIZE - 1) / PAGE_SIZE}");
303+
if (GUILayout.Button("Next") && usablesPage * PAGE_SIZE + PAGE_SIZE < usables.Length)
304+
{
305+
usablesPage++;
306+
}
307+
GUILayout.EndHorizontal();
308+
GUILayout.EndVertical();
309+
}
310+
177311
public static MiCharacterInventory.ItemType GetAmmoType(PlayerSkill skill)
178312
{
179313
switch (skill)
@@ -257,5 +391,25 @@ static void DrawLevelInfoFlag(MiCharacter character, string name, LevelInformati
257391

258392
GUILayout.EndHorizontal();
259393
}
394+
395+
static int SelectionInputToInt(MiInputActions action)
396+
{
397+
switch (action)
398+
{
399+
case MiInputActions.CharacterSelectCooper: return 0;
400+
case MiInputActions.CharacterSelectMcCoy: return 1;
401+
case MiInputActions.CharacterSelectTrapper: return 2;
402+
case MiInputActions.CharacterSelectKate: return 3;
403+
case MiInputActions.CharacterSelectVoodoo: return 4;
404+
default: return -1;
405+
}
406+
}
407+
408+
static void DrawCharacterFlag(string name, ref MiCharacter.CharacterType v, MiCharacter.CharacterType c)
409+
{
410+
var before = v.HasFlag(c);
411+
var after = GUILayout.Toggle(before, name);
412+
if (before != after) v ^= c;
413+
}
260414
}
261415
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Alternatively, you can install the [BepInEx.ConfigurationManager](https://github
4343
- **Convenience**: [Convenience.dll v1.0.3](https://github.com/benediktwerner/Desperados3Mods/releases/download/progress-v1.0.0/Convenience.dll)
4444
- **D1CooperGun**: [D1CooperGun.dll v1.0](https://github.com/benediktwerner/Desperados3Mods/releases/download/v1.0.0/D1CooperGun.dll)
4545
- **DevKillsList**: [DevKillsList.dll v1.0.1](https://github.com/benediktwerner/Desperados3Mods/releases/download/cheats-v1.1.0/DevKillsList.dll)
46-
- **ExtendedCheats**: [ExtendedCheats.dll v1.3](https://github.com/benediktwerner/Desperados3Mods/releases/download/cheats-v1.3.0/ExtendedCheats.dll)
46+
- **ExtendedCheats**: [ExtendedCheats.dll v1.4](https://github.com/benediktwerner/Desperados3Mods/releases/download/cheats-v1.4.0/ExtendedCheats.dll)
4747
- **KingsmanEasterEgg**: [KingsmanEasterEgg.dll v1.2](https://github.com/benediktwerner/Desperados3Mods/releases/download/easter-egg-v1.2.0/KingsmanEasterEgg.dll)
4848
- **ShowdownModePauseOnDesperadoDiff**: [ShowdownModePauseOnDesperadoDiff.dll v1.0](https://github.com/benediktwerner/Desperados3Mods/releases/download/v1.0.0/ShowdownModePauseOnDesperadoDiff.dll)
4949
- **ProgressRestorer**: [ProgressRestorer.dll v1.1](https://github.com/benediktwerner/Desperados3Mods/releases/download/progress-v1.1.0/ProgressRestorer.dll)

0 commit comments

Comments
 (0)