casualexpiesource

cu-trainer/Ultra Paradise Linux/shared/Cheats.cs

286 lines · 16.5 KB · plain text · download

1using System;
2using System.Collections.Generic;
3
4namespace UltraParadise.Shared
5{
6 internal enum CKind { Toggle, Action, Slider, Buttons, Info, Note }
7
8 internal sealed class CBtn
9 {
10 public string Label, Act, Arg;
11 public CBtn(string label, string act, string arg) { Label = label; Act = act; Arg = arg; }
12 }
13
14 internal sealed class COpt
15 {
16 public CKind Kind;
17 public string Id, Name, Hint, Key = "";
18 public float Min, Max, Step, Default;
19 public string Format = "x{0:0.00}";
20 public List<CBtn> Buttons;
21 public Func<Dictionary<string, string>, string> Text;
22 }
23
24 internal sealed class CSection
25 {
26 public string Title;
27 public int Col;
28 public readonly List<COpt> Rows = new List<COpt>();
29 }
30
31 internal sealed class CTab
32 {
33 public string Name;
34 public readonly List<CSection> Sections = new List<CSection>();
35 public CTab(string name) { Name = name; }
36 }
37
38 internal static class Cheats
39 {
40 public const string MenuKey = "F10";
41 public const string OverlayKey = "Insert";
42
43 private static CTab tab;
44 private static CSection sec;
45 private static int n;
46
47 private static void Sec(string title, int col)
48 {
49 sec = new CSection();
50 sec.Title = title;
51 sec.Col = col;
52 tab.Sections.Add(sec);
53 }
54
55 private static COpt Add(COpt o) { sec.Rows.Add(o); n++; return o; }
56
57 private static COpt T(string id, string name, string key, string hint)
58 {
59 COpt o = new COpt(); o.Kind = CKind.Toggle; o.Id = id; o.Name = name; o.Key = key ?? ""; o.Hint = hint;
60 return Add(o);
61 }
62
63 private static COpt A(string id, string name, string key, string hint)
64 {
65 COpt o = new COpt(); o.Kind = CKind.Action; o.Id = id; o.Name = name; o.Key = key ?? ""; o.Hint = hint;
66 return Add(o);
67 }
68
69 private static COpt S(string id, string name, float min, float max, float step, float def, string fmt)
70 {
71 COpt o = new COpt(); o.Kind = CKind.Slider; o.Id = id; o.Name = name; o.Min = min; o.Max = max; o.Step = step; o.Default = def;
72 if (fmt != null) o.Format = fmt;
73 return Add(o);
74 }
75
76 private static COpt B(string name, Func<Dictionary<string, string>, string> text, params CBtn[] btns)
77 {
78 COpt o = new COpt(); o.Kind = CKind.Buttons; o.Id = "btn:" + n; o.Name = name; o.Text = text; o.Buttons = new List<CBtn>(btns);
79 return Add(o);
80 }
81
82 private static COpt I(Func<Dictionary<string, string>, string> text)
83 {
84 COpt o = new COpt(); o.Kind = CKind.Info; o.Id = "info:" + n; o.Text = text;
85 return Add(o);
86 }
87
88 private static COpt N(string text)
89 {
90 COpt o = new COpt(); o.Kind = CKind.Note; o.Id = "note:" + n; o.Name = text;
91 return Add(o);
92 }
93
94 public static string Get(Dictionary<string, string> d, string k, string def)
95 {
96 string v;
97 return d != null && d.TryGetValue(k, out v) ? v : def;
98 }
99
100 private static Func<Dictionary<string, string>, string> Skill(string label, string key)
101 {
102 return delegate (Dictionary<string, string> d) { return label + " " + Get(d, key, "-"); };
103 }
104
105 public static List<CTab> Build()
106 {
107 List<CTab> tabs = new List<CTab>();
108 n = 0;
109
110 tab = new CTab("Player"); tabs.Add(tab);
111 Sec("PLAYER", 0);
112 T("GodMode", "God Mode", "Keypad1", "Can't be hurt or killed. Pauses itself if your character gives up or tries to end it.");
113 T("NoFallDamage", "No Fall Damage", null, "Falls and hard landings don't hurt.");
114 T("InfiniteStamina", "Infinite Stamina", "Keypad2", null);
115 T("NoHunger", "No Hunger", "Keypad3", null);
116 T("NoThirst", "No Thirst", "Keypad4", null);
117 T("NoTiredness", "No Tiredness", "Keypad5", "You can't sleep while this is on.");
118 Sec("HEALING", 0);
119 A("heal", "Heal All Wounds", "Ctrl+Keypad1", "Heals every wound, fixes bones and blood, and clears hearing loss.");
120 A("limbs", "Reattach Limbs", null, "Puts lost limbs back (not prosthetics).");
121 Sec("EMERGENCY", 0);
122 A("em_full", "Full Restore", null, "One click: heals every wound, reattaches limbs, fills blood, food and water.");
123 A("em_bleed", "Stop the Bleeding", null, "Stops all bleeding, inside and out, and tops your blood up to 70%.");
124 A("em_breathe", "Can't Breathe", null, "Fills blood oxygen and clears embolisms, collapsed lungs and barotrauma.");
125 A("em_heart", "Heart Trouble", null, "Stops fibrillation and shock, steadies heart rate and blood pressure, wakes you up.");
126 A("em_cure", "Cure Everything", null, "Clears infection, sickness, radiation sickness, venom and sepsis.");
127 A("em_body", "Food, Water, Warmth", null, "Fills hunger and thirst, sets your temperature to 37C and takes the pain away.");
128 Sec("PROTECTION", 1);
129 T("NoBleeding", "No Bleeding", "Keypad6", "No bleeding, inside or out.");
130 T("NoPain", "No Pain", "Keypad7", null);
131 T("NoInfection", "No Infection", null, "Wounds never get infected.");
132 T("NoSickness", "No Sickness", null, "No sickness, nausea or venom.");
133 T("NoRadiation", "No Radiation Sickness", null, null);
134 T("UnlimitedOxygen", "Unlimited Oxygen", "Keypad8", "Blood oxygen stays full, even underwater.");
135 T("StableTemperature", "Stable Body Temperature", null, "Your body stays at 37C.");
136 T("FasterHealing", "Faster Healing", null, "Wounds, bones and blood heal faster.");
137 S("HealingMult", "Healing rate", 1f, 10f, 0.5f, 3f, null);
138 Sec("MOOD", 2);
139 I(delegate (Dictionary<string, string> d) { return "Mood " + Get(d, "mood", "-"); });
140 T("MoodLock", "Mood Lock", null, "Keeps your mood where it is when you switch it on.");
141 B("Change", null, new CBtn("Max", "moodmax", null), new CBtn("+10", "mood", "10"), new CBtn("-10", "mood", "-10"), new CBtn("-50", "mood", "-50")).Hint = "Very low mood can lead to self-harm.";
142 Sec("SKILLS", 2);
143 T("MoreXp", "Increased XP Gain", null, "Skills level up faster.");
144 S("XpMult", "XP rate", 1f, 10f, 0.5f, 3f, null);
145 B(null, Skill("Strength", "str"), new CBtn("-1", "skill", "0 -1"), new CBtn("+1", "skill", "0 1"), new CBtn("+5", "skill", "0 5"));
146 B(null, Skill("Resilience", "res"), new CBtn("-1", "skill", "1 -1"), new CBtn("+1", "skill", "1 1"), new CBtn("+5", "skill", "1 5"));
147 B(null, Skill("Intelligence", "int"), new CBtn("-1", "skill", "2 -1"), new CBtn("+1", "skill", "2 1"), new CBtn("+5", "skill", "2 5"));
148
149 tab = new CTab("Movement"); tabs.Add(tab);
150 Sec("MOVEMENT", 0);
151 T("FasterMovement", "Faster Movement", null, "You walk and run faster.");
152 S("MoveSpeedMult", "Speed", 1f, 4f, 0.1f, 1.6f, null);
153 T("FasterClimbing", "Faster Climbing", null, "Ropes and ladders.");
154 S("ClimbSpeedMult", "Climb speed", 1f, 5f, 0.25f, 2f, null);
155 T("HigherJumps", "Higher Jumps", null, null);
156 S("JumpMult", "Jump power", 1f, 3f, 0.1f, 1.5f, null);
157 T("UnlimitedJumps", "Unlimited Jumps", null, "Jump again in mid-air as often as you like.");
158 T("UnlimitedWallJumps", "Unlimited Wall Jumps", null, "Wall jump off the same wall over and over.");
159 Sec("BODY", 1);
160 T("LowGravity", "Low Gravity", null, "You fall slower and float further.");
161 S("GravityScale", "Gravity", 0.05f, 1f, 0.05f, 0.4f, null);
162 T("UnlimitedCarry", "No Over-Encumbrance", null, "Carrying too much never slows you, tires you or slows your attacks.");
163 Sec("FLYING", 1);
164 T("FlyMode", "Fly Mode", null, "Movement keys to fly, Space to go up, Shift for speed. You still bump into walls.");
165 S("FlySpeed", "Fly speed", 5f, 40f, 1f, 18f, "{0:0}");
166 T("Noclip", "Noclip", "Keypad0", "Fly through walls with your movement keys. Shift for speed.");
167 Sec("TELEPORT", 2);
168 T("ClickTeleport", "Middle-Click Teleport", null, "Click the middle mouse button in game to teleport to the cursor.");
169 A("exit", "Teleport to Layer Exit", "Ctrl+Keypad3", "Takes you to the bottom of the layer, where the next one starts.");
170
171 tab = new CTab("Items"); tabs.Add(tab);
172 Sec("CRAFTING", 0);
173 T("FreeCrafting", "Free Crafting", null, "Craft any recipe you can see without ingredients.");
174 T("NoCraftFail", "No Crafting Failures", null, "Crafting never fails, even above your Intelligence.");
175 T("AllRecipes", "Show All Recipes", null, "Every recipe shows, whatever your Intelligence.");
176 Sec("INVENTORY", 0);
177 T("NoDegradation", "No Item Degradation", null, "Tools, weapons, armor, containers and batteries never wear out.");
178 T("UnlimitedLiquids", "Unlimited Liquids", null, "Liquids in containers never run out.");
179 T("UnlimitedBattery", "Unlimited Battery", null, "Batteries never drain.");
180 T("MasterLockpick", "Master Lockpicker", null, "Every lock opens the moment you turn it, with a lockpicking kit or bare claws. No hurt claws, no worn-out kit.");
181 Sec("LOADOUT", 1);
182 A("starterkit", "Starter Kit", null, "The game's own kit of tools, medicine and supplies.");
183 A("randomloadout", "Random Loadout", null, "Gives you 6 random items.");
184
185 tab = new CTab("Combat"); tabs.Add(tab);
186 Sec("WEAPONS", 0);
187 T("UnlimitedAmmo", "Unlimited Ammo", "Keypad9", "Load the gun once (magazine in, or a shell in the shotgun) and it keeps refilling.");
188 T("NoGunJams", "No Gun Jams", null, null);
189 T("NoRecoil", "No Recoil", null, "Guns don't kick you back or spread.");
190 T("MoreDamage", "Increased Damage", null, "Your melee and gun hits do more damage.");
191 S("DamageMult", "Damage", 1f, 10f, 0.5f, 2f, null);
192 T("FasterAttacks", "Faster Attacks", null, "Shorter wait between melee swings.");
193 S("AttackSpeedMult", "Swing speed", 1f, 5f, 0.25f, 2.5f, null);
194 T("OneHitKills", "One-Hit Kills", null, "Your melee hits and gunshots kill enemies in one hit.");
195 T("InstantMine", "Instant Mine", null, "Your melee hits break any breakable block in one hit.");
196 Sec("ENEMIES", 1);
197 T("FreezeEnemies", "Freeze Enemies", null, "Enemies can't move or attack.");
198 T("Invisibility", "Invisibility", null, "Enemies and turrets can't attack you.");
199 T("DisableTraps", "Disable Traps", null, "Mines, bear traps, spike stabbers, fans, sound cannons and turrets do nothing.");
200 A("killall", "Kill All Enemies", "Ctrl+Keypad2", null);
201 A("spiders", "Spider Ambush", null, "Drops cave ticks around you. Good luck.");
202
203 tab = new CTab("World"); tabs.Add(tab);
204 Sec("LAYER", 0);
205 T("PauseRadiation", "Pause Radiation Line", null, "The layer timer and the radiation line stop.");
206 T("LongerEscape", "Longer Escape Timer", null, "The end lab countdown is 2 minutes instead of 1.");
207 T("MoreLoot", "Increased Loot", null, "New layers have more loot. Starts on the next layer.");
208 S("LootMult", "Loot", 1f, 5f, 0.25f, 2f, null);
209 A("back", "Previous Layer", "Ctrl+Keypad4", null);
210 A("skip", "Skip Layer", "Ctrl+Keypad5", null);
211 Sec("EVENTS", 1);
212 T("NoEarthquakes", "No Earthquakes", null, null);
213 A("quake", "Start Earthquake", null, null);
214 A("downpour", "Fungal Downpour", null, "Fungal rain for 60 seconds.");
215 Sec("UNLOCKS", 1);
216 A("unlock", "Unlock All Characters", null, "Permanent: marks every character as beaten so the next one unlocks.");
217 Sec("VIEW", 2);
218 T("FullBright", "Full Bright", "KeypadPeriod", "Lights up everything.");
219 T("FreeCamera", "Free Camera", null, "Arrow keys move the camera on its own, Shift for speed.");
220 S("CameraZoom", "Camera zoom", 0.5f, 3f, 0.05f, 1f, null).Hint = "Above 1 shows more of the cave.";
221 S("GameSpeed", "Game speed", 0.25f, 3f, 0.05f, 1f, null);
222 A("speedcycle", "Cycle Game Speed", "Ctrl+Keypad6", "Cycles 1x, 1.5x, 2x and 0.5x.");
223
224 tab = new CTab("Traders"); tabs.Add(tab);
225 Sec("TRADERS", 0);
226 T("MaxTraderRep", "Max Reputation", null, "Nearby survivors always have max reputation and are never hostile.");
227 T("FreeShopping", "Free Shopping", null, "Everything survivors sell costs 0.");
228 T("InfiniteCredit", "Infinite Credit", null, "Keeps the nearest survivor's trade credit at 9999.");
229 Sec("NEAREST SURVIVOR", 1);
230 I(delegate (Dictionary<string, string> d)
231 {
232 string t = Get(d, "trader", null);
233 if (t == null) return "No survivor within 20 m";
234 return t + " " + Get(d, "tdist", "?") + " m away, rep " + Get(d, "rep", "?") + (Get(d, "hostile", null) != null ? ", hostile" : "");
235 });
236 I(delegate (Dictionary<string, string> d) { return Get(d, "trader", null) == null ? "" : "Trade credit " + Get(d, "credit", "0"); });
237 B("Credit", null, new CBtn("+10", "credit", "10"), new CBtn("+50", "credit", "50"), new CBtn("+100", "credit", "100"), new CBtn("+1000", "credit", "1000"));
238 B("", null, new CBtn("-10", "credit", "-10"), new CBtn("Set 0", "credit", "zero"), new CBtn("Restock", "restock", null));
239 Sec("HOW TRADING WORKS", 2);
240 N("The game has no money. Each survivor keeps a trade credit for what you've given them. Add credit here, then spend it in their trade menu.\n\nCredit belongs to each survivor, so stand near the one you want to trade with.");
241
242 tab = new CTab("Challenges"); tabs.Add(tab);
243 Sec("CHALLENGES", 0);
244 T("FragileBody", "Fragile Body", null, "You take double damage.");
245 T("FastMetabolism", "Faster Hunger and Thirst", null, "Hunger, thirst and tiredness drain twice as fast.");
246 T("HopelessStart", "Hopeless Start", null, "New runs start with no supplies at all. Starts with your next new run.");
247 T("BrittleGear", "Brittle Gear", null, "Items decay three times faster.");
248 T("StrongerEnemies", "Stronger Enemies", null, "Enemies take half damage and creatures hit harder.");
249 Sec(" ", 1);
250 T("FastRadiation", "Fast Radiation Line", null, "The layer timer and the radiation line go twice as fast.");
251 T("UnchippedChallenge", "Unchipped Mode", null, "No health readouts and limited vision.");
252 T("ColdCaves", "Cold Caves", null, "The caves are 15C colder.");
253 T("MoreTraps", "More Traps", null, "Twice as many traps, from the next layer.");
254 T("LootScarcity", "Loot Scarcity", null, "Much less loot, from the next layer.");
255 Sec("ABOUT CHALLENGES", 2);
256 N("Make the game harder. They stack with the game's own run settings, and you can mix them with cheats however you like.");
257
258 return tabs;
259 }
260
261 public static string KeyLabel(string k)
262 {
263 if (string.IsNullOrEmpty(k) || k == "none") return "-";
264 string[] parts = k.Split('+');
265 string last = parts[parts.Length - 1];
266 string name = last;
267 if (last.StartsWith("Keypad", StringComparison.Ordinal))
268 {
269 string r = last.Substring(6);
270 if (r == "Period") r = ".";
271 else if (r == "Plus") r = "+";
272 else if (r == "Minus") r = "-";
273 else if (r == "Multiply") r = "*";
274 else if (r == "Divide") r = "/";
275 else if (r == "Enter") r = "Enter";
276 name = "Num " + r;
277 }
278 else if (last.StartsWith("Alpha", StringComparison.Ordinal)) name = last.Substring(5);
279 else if (last.StartsWith("JoystickButton", StringComparison.Ordinal)) name = "Pad " + last.Substring(14);
280 else if (last.EndsWith("Arrow", StringComparison.Ordinal)) name = last.Substring(0, last.Length - 5);
281 string pre = "";
282 for (int i = 0; i < parts.Length - 1; i++) pre += parts[i] + "+";
283 return pre + name;
284 }
285 }
286}