-
Notifications
You must be signed in to change notification settings - Fork 5
/
BTFANPC.cs
356 lines (323 loc) · 9.43 KB
/
BTFANPC.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
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using System;
using Terraria.ModLoader;
using ForgottenMemories;
namespace ForgottenMemories
{
public class BTFANPC : GlobalNPC
{
int DagNum = 0;
public bool BlightCelled = false;
public bool FilicidCelled = false;
public bool BloodLeech = false;
public bool MarbleArrow = false;
public bool Necro = false;
public bool boilingBlood = false;
public int boilingBloodCounter = 7;
public bool boilingBlood2 = false;
public bool groped = false;
public bool titanCrush = false;
public bool bleeding = false;
public bool blightFlame = false;
public int blightChakramHits = 0;
public override void ResetEffects(NPC npc)
{
DagNum = 0;
BlightCelled = false;
FilicidCelled = true;
BloodLeech = false;
MarbleArrow = false;
Necro = false;
boilingBlood = false;
boilingBlood2 = false;
groped = false;
titanCrush = false;
bleeding = false;
blightFlame = false;
}
public override bool InstancePerEntity {get{return true;}}
public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
{
if (player.GetModPlayer<BTFAPlayer>(mod).isGlitch)
{
spawnRate = (int)(spawnRate * 50f);
maxSpawns = (int)(maxSpawns * 50f);
}
if(TGEMWorld.forestInvasionUp && (Main.invasionX == (double)Main.spawnTileX))
{
spawnRate = 50;
maxSpawns = 50;
}
}
public override void PostAI(NPC npc)
{
if(TGEMWorld.forestInvasionUp && (Main.invasionX == (double)Main.spawnTileX))
{
npc.timeLeft = 1000;
}
}
public override bool StrikeNPC (NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit)
{
if (boilingBlood2)
damage *= 1.1;
return true;
}
public override void DrawEffects(NPC npc, ref Color drawColor)
{
if (boilingBlood) //PLACEHOLDER DUST, PLEASE SPRAY YOUR MAGIC DUST JUICE ON THIS
{
if (Main.rand.Next(7) < 6)
{
int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, mod.DustType("BloodDust2"), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 44, default(Color), 3.5f);
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity *= 1.2f;
Main.dust[dust].velocity.Y -= 0.15f;
}
Lighting.AddLight(npc.position, 0.5f, 0, 0);
}
}
public override void UpdateLifeRegen(NPC npc, ref int damage)
{
if (blightFlame)
{
npc.lifeRegen -= 40;
if (damage < 10)
{
damage = 10;
}
}
if (titanCrush)
{
npc.lifeRegen -= 20;
if (damage < 20)
{
damage = 20;
}
}
/*if (npc.FindBuffIndex(mod.BuffType("Frostburn2")) >= 0) //THIS DOESNT EVEN EXIST
{
if (damage < 10)
{
damage = 10;
}
}*/
if (bleeding)
{
npc.lifeRegen -= 8;
if (damage < 4)
{
damage = 4;
}
}
if (BlightCelled)
{
if (npc.lifeRegen > 0)
npc.lifeRegen = 0;
int num = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].type == mod.ProjectileType("BlightOrbShoot") && ((double) Main.projectile[index].ai[0] == 1.0 && (double) Main.projectile[index].ai[1] == (double) npc.whoAmI))
++num;
}
npc.lifeRegen -= num * 4 * 5;
if (damage < num * 5)
damage = num * 5;
}
if (FilicidCelled)
{
int num = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].type == mod.ProjectileType("FilicidCellRanged") && ((double) Main.projectile[index].ai[0] == 1.0 && (double) Main.projectile[index].ai[1] == (double) npc.whoAmI))
++num;
}
npc.defense -= num * 2;
}
if (BloodLeech)
{
if (npc.lifeRegen > 0)
npc.lifeRegen = 0;
int num = 0;
DagNum = num;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].type == mod.ProjectileType("BloodLeech") && ((double) Main.projectile[index].ai[0] == 1.0 && (double) Main.projectile[index].ai[1] == (double) npc.whoAmI))
++num;
}
npc.lifeRegen -= num * 10 * 2;
if (damage < num)
damage = num;
}
if (MarbleArrow)
{
if (npc.lifeRegen > 0)
npc.lifeRegen = 0;
int num = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].type == mod.ProjectileType("MarbleArrow") && ((double) Main.projectile[index].ai[0] == 1.0 && (double) Main.projectile[index].ai[1] == (double) npc.whoAmI))
++num;
}
npc.lifeRegen -= num * 4 * 5;
if (damage < num * 5)
damage = num * 5;
}
if (Necro)
{
if (npc.lifeRegen > 0)
npc.lifeRegen = 0;
int num = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].type == mod.ProjectileType("NecroDagger") && ((double) Main.projectile[index].ai[0] == 1.0 && (double) Main.projectile[index].ai[1] == (double) npc.whoAmI))
++num;
npc.AddBuff(mod.BuffType("NecroDagger"), 180, false);
}
npc.lifeRegen -= num * 4 * 3;
if (damage < num * 3)
damage = num * 3;
}
if (boilingBlood)
{
if (npc.lifeRegen > 0)
{
npc.lifeRegen = 0;
}
npc.lifeRegen -= boilingBloodCounter;
if (damage < 14)
{
damage = 14;
}
}
else
{
boilingBloodCounter = 7;
}
if (groped)
{
if (npc.lifeRegen > 0)
npc.lifeRegen = 0;
npc.lifeRegen -= 40;
if (damage < 4)
damage = 4;
}
}
public override void SetupShop(int type, Chest shop, ref int nextSlot) // add items to npc shops
{
if (type == 19) // arms dealer
{
if (NPC.downedBoss2) // check if EoW/BoC is defeated
{
shop.item[nextSlot].SetDefaults(mod.ItemType("psychic_pistol")); // sell psychic pistol
nextSlot++;
}
if (NPC.downedAncientCultist)
{
shop.item[nextSlot].SetDefaults(mod.ItemType("VengeanceBullet"));
nextSlot++;
}
for (int i = 0; i < 200; i++)
{
Player player = Main.player[i];
if (player.HasItem(mod.ItemType("AncientLauncher")))
{
shop.item[nextSlot].SetDefaults(771);
nextSlot++;
}
}
for (int i = 0; i < 200; i++)
{
Player player = Main.player[i];
if (player.HasItem(mod.ItemType("HadesHand")))
{
shop.item[nextSlot].SetDefaults(mod.ItemType("LostSoul"));
nextSlot++;
}
}
}
}
public override void NPCLoot(NPC npc)
{
if (BloodLeech == true)
{
for (int i = 0; i <= DagNum; i++)
{
int p = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, mod.ProjectileType("BloodBoom"), 50, 0f, Main.player[npc.target].whoAmI, 0f, 0f);
Main.projectile[p].melee = false;
Main.projectile[p].thrown = true;
Main.projectile[p].usesLocalNPCImmunity = true;
Main.projectile[p].localNPCHitCooldown = 10;
}
}
if (boilingBlood)
{
int p = Projectile.NewProjectile(npc.position.X, npc.position.Y, 0, 0, mod.ProjectileType("BloodBall"), 84, 4.4f, Main.myPlayer, 0f, 1f);
Main.projectile[p].Kill();
}
if (Main.player[npc.target].active && Main.player[npc.target].HeldItem.type == mod.ItemType("PhantomReap") && Main.rand.Next(2) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Phantom"));
}
if(TGEMWorld.forestInvasionUp)
{
foreach(int invader in CustomInvasion.invaders)
{
if(npc.type == invader)
{
Main.invasionSize -= 2;
if (Main.rand.Next(3) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ForestEnergy"), 1);
}
}
if(npc.type == mod.NPCType("MagnoliacSecondStage") && !Main.hardMode)
{
Player player = Main.player[npc.target];
Main.invasionSize -= 1000;
player.GetModPlayer<BTFAPlayer>().MagnoliacBool = false;
}
if(npc.type == mod.NPCType("MagnoliacSecondStage") && Main.hardMode)
{
Player player = Main.player[npc.target];
player.GetModPlayer<BTFAPlayer>().MagnoliacBool = false;
}
if(npc.type == mod.NPCType("GhastlyEnt") && Main.hardMode)
{
Player player = Main.player[npc.target];
player.GetModPlayer<BTFAPlayer>().GentBool = false;
Main.invasionSize -= 1000;
}
}
}
}
public override void EditSpawnPool(IDictionary< int, float > pool, NPCSpawnInfo spawnInfo)
{
if(TGEMWorld.forestInvasionUp && (Main.invasionX == (double)Main.spawnTileX))
{
pool.Clear();
foreach(int i in CustomInvasion.invaders)
{
pool.Add(i, 1f);
}
if (Main.hardMode)
{
foreach(int i in CustomInvasion.hmInvaders)
{
pool.Add(i, 1f);
}
}
Mod Wildlife = ModLoader.GetMod("Wildlife");
if (Wildlife != null)
{
foreach(int i in CustomInvasion.wInvaders)
{
pool.Add(i, 1f);
}
}
}
}
}
}