-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatches.cs
394 lines (299 loc) · 12.4 KB
/
Patches.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
using HarmonyLib;
using Microsoft.Xna.Framework;
using StardewValley;
using RestStopLocations.Game.Locations;
using RestStopLocations.Bluebella;
using StardewValley.TerrainFeatures;
using StardewValley.Tools;
using RestStopLocations.Game.Locations.Sapphire;
using RestStopLocations.Utilities;
using StardewValley.Enchantments;
using System;
using System.Xml.Linq;
using StardewValley.GameData.Crops;
using StardewValley.GameData.WildTrees;
namespace RestStopLocations.Patches
{
[HarmonyPatch(typeof(Game1), nameof(Game1.getLocationFromNameInLocationsList))]
internal static class Game1FetchDungeonInstancePatch
{
public static bool Prefix(string name, bool isStructure, ref GameLocation __result)
{
if (name.StartsWith(HellDungeon.BaseLocationName))
{
__result = HellDungeon.GetLevelInstance(name);
return false;
}
if (name.StartsWith(BluebellaDungeon.BaseLocationName))
{
__result = BluebellaDungeon.GetLevelInstance(name);
return false;
}
if (name.StartsWith(SapphireVolcano.BaseLocationName))
{
__result = SapphireVolcano.GetLevelInstance(name);
return false;
}
return true;
}
[HarmonyPatch(typeof(Tool), nameof(Tool.Forge))]
public static class ToolForgePatch
{
public static void Postfix(ref bool __result, Tool __instance, Item item)
{
BaseEnchantment enchantment = BaseEnchantment.GetEnchantmentFromItem(__instance, item);
if (__result && enchantment is PearlEanchantment && __instance is MeleeWeapon weapon && PearlEanchantment.IsMermaidWeapon(weapon))
{
if (weapon.GetEnchantmentLevel<PearlEanchantment>() < 3) { return; }
int current_index = weapon.InitialParentTileIndex;
int sirenswordint = 30;// ExternalAPIs.JA.GetWeaponId("Siren's Blade");
int sirendaggerint = 31;// ExternalAPIs.JA.GetWeaponId("Siren Splinter");
int sirenrevengeint = 32;/// ExternalAPIs.JA.GetWeaponId("Siren's Revenge");
int sirensilenceint = 33;// ExternalAPIs.JA.GetWeaponId("Siren's Silence");
string sirensword = Convert.ToString(sirenswordint);
string sirendagger = Convert.ToString(sirendaggerint);
string sirenrevenge = Convert.ToString(sirenrevengeint);
string sirensilence = Convert.ToString(sirensilenceint);
if (current_index == sirenswordint)
weapon.transform(sirenrevenge);
else if (current_index == sirendaggerint)
weapon.transform(sirensilence);
}
}
}
[HarmonyPatch(typeof(BaseEnchantment), nameof(BaseEnchantment.GetEnchantmentFromItem))]
public static class BaseEnchatmentPearlEnchatmentPatch
{
/// <summary>
/// This patch injects custom enchantment 'PearlEnchantment'
/// when method for get item enchantment is called
/// and the base item is mermaid weapon
/// and the enchanting item is a pearl
/// </summary>
public static void Postfix(ref BaseEnchantment __result, Item base_item, Item item)
{
if (base_item == null || (base_item is MeleeWeapon && !(base_item as MeleeWeapon).isScythe()))
{
if (base_item != null && base_item is MeleeWeapon && PearlEanchantment.IsMermaidWeapon(base_item) && Utility.IsNormalObjectAtParentSheetIndex(item, "(O)797"))
{
__result = new PearlEanchantment();
}
}
}
}
[HarmonyPatch(typeof(Game1), "UpdateLocations")]
public static class Game1UpdateDungeonLocationsPatch
{
public static void Postfix(GameTime time)
{
//if (Game1.menuUp && !Game1.IsMultiplayer)
//{
//return;
//}
if (Game1.IsClient)
{
return;
}
//MermaidTrain mermaidTrain = new MermaidTrain();
//mermaidTrain.Update(time);
HellDungeon.UpdateLevels(time);
BluebellaDungeon.UpdateLevels(time);
SapphireVolcano.UpdateLevels(time);
AmbientishLocationSounds.update(time);
}
}
[HarmonyPatch(typeof(GameLocation), "UpdateWhenCurrentLocation")]
public static class GameLocationUpdatePatch
{
public static void Postfix(GameTime time)
{
if (Game1.IsClient)
{
return;
}
AmbientishLocationSounds.update(time);
AmbientesqueLocationSounds.update(time);
}
}
[HarmonyPatch(typeof(Game1), "Initialize")]
public static class Game1InitializePatch
{
public static void Postfix()
{
//RestStop.InitShared();
LocationSounds.InitShared();
AmbientishLocationSounds.Initialize();
AmbientesqueLocationSounds.InitShared();
}
}
/* EXAMPLE of How to do the __instance to instantiate a thingie in Harmony like for to make an object reference and whatnot
[HarmonyPatch(typeof(ShopMenu), "setUpShopOwner")]
public static class ShopMenuPatch
{
public static void Postfix(ShopMenu __instance, string who)
{
if (Game1.currentLocation is SapphireSprings)
{
__instance.potraitPersonDialogue = Game1.parseText("Hey Lovely! Care to peruse my fine wares?", Game1.dialogueFont, 304);
}
}
} */
}
}
/*
//List<BaseEnchantment> GetAvailableEnchantments()
[HarmonyPatch(typeof(BaseEnchantment), nameof(BaseEnchantment.GetAvailableEnchantments))]
public static class BaseEnchantmentListPatch
{
public static void PostFix(ref List<BaseEnchantment> __result)
{
}
}*/
/*
[HarmonyPatch(typeof(Tree), nameof(Tree.getBoundingBox))]
public static class SequoiaPatch
{
public static bool Prefix(Tree __instance, ref Microsoft.Xna.Framework.Rectangle __result)
{
WildTreeData data = __instance.GetData();
if (data != null && data.CustomFields.ContainsValue("MermaidSequoia"))
//if (__instance != null && __instance.TextureName.StartsWith("MermaidSeq"))
{
Vector2 tileLocation = __instance.Tile;
// if ( (int)__instance.growthStage < 4)
// {
// __result = new Microsoft.Xna.Framework.Rectangle((int)tileLocation.X * 64, (int)tileLocation.Y * 64, 64, 64);
// return false;
// }
// else
__result = new Microsoft.Xna.Framework.Rectangle((int)(tileLocation.X) * 64, (int)(tileLocation.Y) * 64, 192, 192);
return false;
}
return true;
}
}
*/
/*
[HarmonyPatch(typeof(Tree), nameof(Tree.getBoundingBox))]
public static class SequoiaPatch
{
public static bool Prefix(Tree __instance, ref Microsoft.Xna.Framework.Rectangle __result)
{
if (int.TryParse(__instance.treeType.Value, out _)) // ignore vanilla trees
return true;
if (__instance.treeType.Name.Equals("Mermaid.Sequoia"))
{
Vector2 tileLocation = __instance.Tile;
if ((int)__instance.growthStage < 4)
{
__result = new Microsoft.Xna.Framework.Rectangle((int)tileLocation.X * 64, (int)tileLocation.Y * 64, 64, 64);
return false;
}
else
__result = new Microsoft.Xna.Framework.Rectangle((int)(tileLocation.X - 1f) * 64, (int)(tileLocation.Y - 1f) * 64, 192, 192);
return false;
}
return true;
}
} */
[HarmonyPatch(typeof(Tree), nameof(Tree.performToolAction))]
public static class TreeToolActionPatch
{
public static void Prefix(Tree __instance, Tool t, int explosion)
{
if (t is Axe)
{
if (Game1.currentLocation is RestStop or SapphireForest or RealmofSpiritsWinter or SouthRestStop or SapphireSprings or JunkBeach or SovaraCanyon or AspenCanyon)
{
__instance.health.Value = 999999999999;
Game1.player.Money -= 100;
Game1.addHUDMessage(new HUDMessage("Ranger Wren tickets you for illegal wood harvesting in the national park! You got what was coming to you!!!", 1));
}
}
}
}
[HarmonyPatch(typeof(Tree), nameof(Tree.performToolAction))]
public static class SevereTreeToolActionPatch
{
public static void Prefix(Tree __instance, Tool t, int explosion)
{
if (t is Axe)
{
if (Game1.currentLocation is EmeraldForestShrine)
{
__instance.health.Value = 999999999999;
Game1.player.Money -= 1000000000;
Game1.player.health = 0;
Game1.addHUDMessage(new HUDMessage("The fairies slaughter you for trying to cut wood in the Sacred Forest!!!", 1));
}
}
}
}
/*
[HarmonyPatch(typeof(Multiplayer), nameof(Multiplayer.updateRoots))]
public static class MultiplayerUpdateDungeonRootsPatch
{
public static void Postfix(Multiplayer __instance)
{
foreach (var level in HellDungeon.activeLevels)
{
if (level.Root.Value is not null)
{
level.Root.Clock.InterpolationTicks = __instance.interpolationTicks();
__instance.updateRoot(level.Root);
}
}
}
}*/
/*
[HarmonyPatch(typeof(Game1), nameof(Game1.updatePause))]
public static class Game1UpdatePausePatch
{
public static void Postfix(GameTime gameTime)
{
//string HeckDungeon = (HellDungeon.BaseLocationName);
if (Game1.killScreen && Game1.currentLocation is HellLocation)
{
Game1.warpFarmer("Custom_RestStopSouth", 15, 5, flip: false);
}
return;
Game1.progressBar = false;
//Game1.currentLocation.currentEvent.CurrentCommand++;
if (Game1.killScreen && !Game1.eventUp)
{
{
Game1.warpFarmer("Custom_SouthRestStop", 39, 18, flip: false);
string rescuer3 = "Vika";
string uniquemessage3 = "Data\\ExtraDialogue:Mines_PlayerKilled_Vika";
switch (Game1.random.Next(7))
{
case 0:
rescuer3 = "Wren";
uniquemessage3 = "Data\\ExtraDialogue:Mines_PlayerKilled_Wren";
break;
case 1:
rescuer3 = "Clint";
uniquemessage3 = "Data\\ExtraDialogue:Mines_PlayerKilled_Clint";
break;
case 2:
rescuer3 = "Maru";
uniquemessage3 = ((Game1.player.spouse != null && Game1.player.spouse.Equals("Maru")) ? "Data\\ExtraDialogue:Mines_PlayerKilled_Maru_Spouse" : "Data\\ExtraDialogue:Mines_PlayerKilled_Maru_NotSpouse");
break;
default:
rescuer3 = "Vika";
uniquemessage3 = "Data\\ExtraDialogue:Mines_PlayerKilled_Vika";
break;
}
if (Game1.random.NextDouble() < 0.1 && Game1.player.spouse != null && !Game1.player.isEngaged() && Game1.player.spouse.Length > 1)
{
rescuer3 = Game1.player.spouse;
uniquemessage3 = (Game1.player.IsMale ? "Data\\ExtraDialogue:Mines_PlayerKilled_Spouse_PlayerMale" : "Data\\ExtraDialogue:Mines_PlayerKilled_Spouse_PlayerFemale");
}
Game1.currentLocation.currentEvent = new Event(Game1.content.LoadString("Data\\Events\\Custom_SouthRestStop:PlayerKilled", rescuer3, uniquemessage3, Game1.player.Name));
}
return;
}
}
}
*/