-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mermonkey4thPath.cs
456 lines (388 loc) · 22.8 KB
/
Mermonkey4thPath.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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
using MelonLoader;
using BTD_Mod_Helper;
using Mermonkey4thPath;
using Il2CppAssets.Scripts.Models.Towers;
using PathsPlusPlus;
using BTD_Mod_Helper.Api.Enums;
using BTD_Mod_Helper.Extensions;
using Il2CppAssets.Scripts.Unity;
using Il2CppAssets.Scripts.Models.Towers.Projectiles.Behaviors;
using BTD_Mod_Helper.Api.Display;
using Il2CppAssets.Scripts.Unity.Display;
using UnityEngine;
using static Mermonkey4thPath.DoubleTrident.DarkBending.DarkInfusion.DarkGust.EyeOfTheStorm.Effect;
using System;
using System.IO;
using MelonLoader.Utils;
using Il2CppAssets.Scripts.Models.Towers.Behaviors;
using Il2CppAssets.Scripts.Models.Towers.Projectiles;
using HarmonyLib;
using Il2CppAssets.Scripts.Simulation.Bloons;
using Il2CppAssets.Scripts.Simulation.Towers.Projectiles;
using Il2CppAssets.Scripts.Models.Bloons.Behaviors;
using Il2CppAssets.Scripts.Models.Powers;
using Il2CppAssets.Scripts.Models.Towers.Behaviors.Abilities.Behaviors;
using Il2CppAssets.Scripts.Models.Towers.Behaviors.Attack;
using Il2CppAssets.Scripts.Simulation.Towers;
using Il2CppAssets.Scripts.Models.Towers.Behaviors.Attack.Behaviors;
using Il2CppAssets.Scripts.Models.Towers.Behaviors.Abilities;
using Il2CppAssets.Scripts.Unity.Towers.Projectiles;
using Il2CppAssets.Scripts.Models.ServerEvents;
using static MelonLoader.MelonLogger;
using static Mermonkey4thPath.DoubleTrident.DarkBending.DarkInfusion.DarkGust.EyeOfTheStorm;
using Il2CppAssets.Scripts.Models.Towers.Behaviors.Emissions;
[assembly: MelonInfo(typeof(Mermonkey4thPath.Mermonkey4thPath), ModHelperData.Name, ModHelperData.Version, ModHelperData.RepoOwner)]
[assembly: MelonGame("Ninja Kiwi", "BloonsTD6")]
namespace Mermonkey4thPath;
public class Mermonkey4thPath : BloonsTD6Mod
{
public override void OnApplicationStart()
{
ModHelper.Msg<Mermonkey4thPath>("Mermonkey4thPath loaded!");
}
}
public class MerMonkeyPath : PathPlusPlus
{
public override string Tower => TowerType.Mermonkey;
public override int UpgradeCount => 5;
}
public class DoubleTrident : UpgradePlusPlus<MerMonkeyPath>
{
public override int Cost => 750;
public override int Tier => 1;
public override string Icon => "I0001";
public override string Portrait => "P0001";
public override string Description => "Wielding two tridents makes it a lot more deadly.";
public override void ApplyUpgrade(TowerModel towerModel)
{
{
foreach (var weaponModel in towerModel.GetWeapons())
{
foreach (var attackModel in towerModel.GetAttackModels())
{
attackModel.AddWeapon(attackModel.weapons[0].Duplicate());
attackModel.weapons[1].ejectZ = 20;
attackModel.weapons[0].ejectX = 10;
}
}
}
}
public class DarkBending : UpgradePlusPlus<MerMonkeyPath>
{
public override int Cost => 1400;
public override int Tier => 2;
public override string Icon => "I0002";
public override string Portrait => "P0002";
public override string Description => "The Mermonkey unlocks a powerful force within him called dark bending.";
public override void ApplyUpgrade(TowerModel towerModel)
{
{
foreach (var weaponModel in towerModel.GetWeapons())
{
foreach (var attackModel in towerModel.GetAttackModels())
{
attackModel.AddWeapon(Game.instance.model.GetTowerFromId("Druid-200").GetAttackModel().weapons[1].Duplicate());
CreateLightningEffectModel behavior = ProjectileModelBehaviorExt.GetBehavior<CreateLightningEffectModel>(attackModel.weapons[2].projectile);
behavior.displayPaths[0] = CreatePrefabReference<Lightning1>();
behavior.displayPaths[1] = CreatePrefabReference<Lightning2>();
behavior.displayPaths[2] = CreatePrefabReference<Lightning3>();
behavior.displayPaths[3] = CreatePrefabReference<Lightning4>();
behavior.displayPaths[4] = CreatePrefabReference<Lightning5>();
behavior.displayPaths[5] = CreatePrefabReference<Lightning6>();
behavior.displayPaths[6] = CreatePrefabReference<Lightning7>();
behavior.displayPaths[7] = CreatePrefabReference<Lightning8>();
behavior.displayPaths[8] = CreatePrefabReference<Lightning9>();
attackModel.weapons[2].projectile.pierce *= 1.2f;
attackModel.weapons[2].projectile.GetDamageModel().damage += 2;
attackModel.weapons[2].rate *= 0.75f;
}
}
}
}
public class DarkInfusion : UpgradePlusPlus<MerMonkeyPath>
{
public override int Cost => 2500;
public override int Tier => 3;
public override string Icon => "I0003";
public override string Portrait => "P0003";
public override string Description => "Transfer dark bending onto its trident, making it deal huge damage at the cost of 75% of its rate.";
public override void ApplyUpgrade(TowerModel towerModel)
{
{
foreach (var weaponModel in towerModel.GetWeapons())
{
foreach (var attackModel in towerModel.GetAttackModels())
{
attackModel.weapons[0].projectile.GetBehavior<CreateProjectileOnExhaustPierceModel>().projectile.GetDamageModel().damage += 10;
attackModel.weapons[1].projectile.GetBehavior<CreateProjectileOnExhaustPierceModel>().projectile.GetDamageModel().damage += 10;
attackModel.weapons[0].rate += .75f;
attackModel.weapons[1].rate += .75f;
attackModel.weapons[0].projectile.ApplyDisplay<Trident>();
attackModel.weapons[1].projectile.ApplyDisplay<Trident>();
attackModel.weapons[2].projectile.GetDamageModel().damage += 2;
attackModel.weapons[2].rate -= 0.07f;
}
}
}
}
public class DarkGust : UpgradePlusPlus<MerMonkeyPath>
{
public override int Cost => 7500;
public override int Tier => 4;
public override string Icon => "I0004";
public override string Portrait => "P0004";
public override string Description => "Channels the chaotic winds from the darkness, twisting and forming it into a large whirlwind of pure dark magical essence, blowing away tons of Bloons and dealing high damage while doing so. Attack range increased slightly.";
public override void ApplyUpgrade(TowerModel towerModel)
{
{
var newAttackModel = Game.instance.model.GetTowerFromId("DartMonkey").GetAttackModel().Duplicate();
towerModel.GetAttackModel().weapons[2].projectile.GetDamageModel().damage += 3;
towerModel.GetAttackModel().weapons[2].rate -= 0.07f;
towerModel.GetAttackModel().weapons[0].rate -= .25f;
towerModel.GetAttackModel().weapons[1].rate -= .25f;
newAttackModel.weapons[0].rate = 8f;
newAttackModel.weapons[0].projectile.ApplyDisplay<Effect>();
newAttackModel.weapons[0].projectile.pierce = 10000000;
newAttackModel.weapons[0].projectile.GetDamageModel().damage = 35;
var KnockbackMeme = Game.instance.model.GetTowerFromId("NinjaMonkey-010").GetWeapon().projectile.GetBehavior<WindModel>().Duplicate<WindModel>();
KnockbackMeme.chance = 0.1f;
KnockbackMeme.distanceMin = 45;
KnockbackMeme.distanceMax = 70;
KnockbackMeme.affectMoab = true;
newAttackModel.weapons[0].projectile.AddBehavior(KnockbackMeme);
newAttackModel.weapons[0].projectile.GetBehavior<TravelStraitModel>().lifespan = 300;
newAttackModel.weapons[0].projectile.GetBehavior<TravelStraitModel>().speed = 50f;
newAttackModel.weapons[0].projectile.GetBehavior<TravelStraitModel>().speedFrames = 50f;
newAttackModel.weapons[0].projectile.GetBehavior<TravelStraitModel>().Speed = 50f;
newAttackModel.weapons[0].projectile.GetBehavior<TravelStraitModel>().Lifespan = 300;
newAttackModel.weapons[0].projectile.GetBehavior<TravelStraitModel>().lifespanFrames = 300;
towerModel.AddBehavior(newAttackModel);
towerModel.GetAttackModel().range += 10;
towerModel.GetAttackModel(1).range += 10;
towerModel.range += 10;
}
}
public class EyeOfTheStorm : UpgradePlusPlus<MerMonkeyPath>
{
public override int Cost => 75000;
public override int Tier => 5;
public override string Icon => "I0005";
public override string Portrait => "P0005";
public override string Description => "No one should wields this much dark energy not even the VTSG";
public override void ApplyUpgrade(TowerModel towerModel)
{
{
OrbitModel orbitModel = Game.instance.model.GetTowerFromId("BoomerangMonkey-502").GetBehavior<OrbitModel>().Duplicate();
orbitModel.projectile.ApplyDisplay<MiniEffect>();
orbitModel.count = 8;
orbitModel.range += 5;
orbitModel.projectile.id = "TornadoGlaive";
towerModel.GetAttackModel().weapons[2].projectile.pierce += 999;
towerModel.AddBehavior(orbitModel);
towerModel.GetAttackModel().weapons[2].projectile.GetDamageModel().damage += 350;
towerModel.GetAttackModel().weapons[2].rate = 0.5f;
towerModel.GetAttackModel().weapons[0].rate = 0.2f;
towerModel.GetAttackModel().weapons[1].rate = 0.2f;
towerModel.GetAttackModel().weapons[0].projectile.GetBehavior<CreateProjectileOnExhaustPierceModel>().projectile.GetDamageModel().damage += 3000;
towerModel.GetAttackModel().weapons[1].projectile.GetBehavior<CreateProjectileOnExhaustPierceModel>().projectile.GetDamageModel().damage += 3000;
towerModel.GetAttackModel(1).weapons[0].rate = 2f;
towerModel.GetAttackModel(1).weapons[0].emission = new ArcEmissionModel("ArcEmissionModel_", 3, 0, 100, null, false, false);
towerModel.GetAttackModel(1).weapons[0].projectile.GetBehavior<WindModel>().chance = 0.4f;
towerModel.GetAttackModel(1).weapons[0].projectile.GetBehavior<WindModel>().distanceMin = 140;
towerModel.GetAttackModel(1).weapons[0].projectile.GetBehavior<WindModel>().distanceMax = 140;
towerModel.GetAttackModel(1).weapons[0].projectile.GetDamageModel().damage += 575;
towerModel.GetAttackModel().range += 20;
towerModel.GetAttackModel(1).range += 20;
towerModel.range += 20;
}
}
public class Effect : ModDisplay
{
public override string BaseDisplay => "efc680bebf80d1e4584e9548ddfbff34";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
node.transform.GetChild(0).transform.localScale *= 3f;
ParticleSystemRenderer[] renderers = node.GetComponentsInChildren<ParticleSystemRenderer>();
foreach (var renderer in renderers)
{
if (renderer != null && IsTargetRenderer(renderer))
{
ChangeMaterialColor(renderer.materials[0], Color.black);
}
}
}
private bool IsTargetRenderer(ParticleSystemRenderer renderer)
{
bool isTarget = renderer.name.Contains("Sparks") || renderer.name.Contains("Wind");
return isTarget;
}
private void ChangeMaterialColor(Material material, Color newColor)
{
if (material != null)
{
if (material.HasProperty("_Color"))
{
material.SetColor("_Color", newColor);
}
else if (material.HasProperty("_BaseColor"))
{
material.SetColor("_BaseColor", newColor);
}
else if (material.HasProperty("_TintColor"))
{
material.SetColor("_TintColor", newColor);
}
else if (material.HasProperty("_EmissionColor"))
{
material.SetColor("_EmissionColor", newColor);
material.EnableKeyword("_EMISSION");
}
}
}
public class Trident : ModDisplay
{
public override string BaseDisplay => Generic2dDisplay;
public override void ModifyDisplayNode(UnityDisplayNode node)
{
Set2DTexture(node, "DarkTrident");
}
}
public class Lightning1 : ModDisplay
{
public override string BaseDisplay => "548c26e4e668dac4a850a4c016916016";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class Lightning2 : ModDisplay
{
public override string BaseDisplay => "ffed377b3e146f649b3e6d5767726a44";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class Lightning3 : ModDisplay
{
public override string BaseDisplay => "c5e4bf0202becd0459c47b8184b4588f";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class Lightning4 : ModDisplay
{
public override string BaseDisplay => "3e113b397a21a3a4687cf2ed0c436ec8";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class Lightning5 : ModDisplay
{
public override string BaseDisplay => "c6c2049a0c01e8a4d9904db8c9b84ca0";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class Lightning6 : ModDisplay
{
public override string BaseDisplay => "e9b2a3d6f0fe0e4419a423e4d2ebe6f6";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class Lightning7 : ModDisplay
{
public override string BaseDisplay => "c8471dcde4c65fc459f7846c6a932a8c";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class Lightning8 : ModDisplay
{
public override string BaseDisplay => "a73b565de9c31c14ebcd3317705ab17e";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class Lightning9 : ModDisplay
{
public override string BaseDisplay => "bd23939e7362b8e40a3a39f595a2a1dc";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
SpriteRenderer renderer = node.GetRenderer<SpriteRenderer>(node);
renderer.color = Color.black;
renderer.SetOutlineColor(Color.gray);
}
}
public class MiniEffect : ModDisplay
{
public override string BaseDisplay => "efc680bebf80d1e4584e9548ddfbff34";
public override void ModifyDisplayNode(UnityDisplayNode node)
{
ParticleSystemRenderer[] renderers = node.GetComponentsInChildren<ParticleSystemRenderer>();
foreach (var renderer in renderers)
{
if (renderer != null && IsTargetRenderer(renderer))
{
ChangeMaterialColor(renderer.materials[0], Color.black);
}
}
}
private bool IsTargetRenderer(ParticleSystemRenderer renderer)
{
bool isTarget = renderer.name.Contains("Sparks") || renderer.name.Contains("Wind");
return isTarget;
}
private void ChangeMaterialColor(Material material, Color newColor)
{
if (material != null)
{
if (material.HasProperty("_Color"))
{
material.SetColor("_Color", newColor);
}
else if (material.HasProperty("_BaseColor"))
{
material.SetColor("_BaseColor", newColor);
}
else if (material.HasProperty("_TintColor"))
{
material.SetColor("_TintColor", newColor);
}
else if (material.HasProperty("_EmissionColor"))
{
material.SetColor("_EmissionColor", newColor);
material.EnableKeyword("_EMISSION");
}
}
}
}
}
}
}
}
}
}