-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTheLunaticNPC.cs
108 lines (87 loc) · 3.34 KB
/
TheLunaticNPC.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
using HamstarHelpers.Helpers.Debug;
using HamstarHelpers.Helpers.Items;
using HamstarHelpers.Helpers.NPCs;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using TheLunatic.Items;
using TheLunatic.Logic;
namespace TheLunatic {
class TheLunaticNPC : GlobalNPC {
public override void AI( NPC npc ) {
var mymod = (TheLunaticMod)this.mod;
if( !mymod.Config.Enabled ) { return; }
if( Main.rand == null ) { return; }
var myworld = ModContent.GetInstance<TheLunaticWorld>();
if( myworld == null ) { return; }
// Kill town NPCs above ground every minute when set to do so
if( myworld.GameLogic.KillSurfaceTownNPCs ) {
if( npc.townNPC && npc.position.Y < (Main.worldSurface*16.0) && Main.rand.Next(60*60) == 0 ) {
NPCHelpers.Kill( npc );
return;
}
}
}
public override void NPCLoot( NPC npc ) {
if( npc == null ) { return; }
var mymod = (TheLunaticMod)this.mod;
if( !mymod.Config.Enabled ) { return; }
if( !npc.boss && npc.type != 551 && npc.type != 398 ) { return; } // Betsy isn't a boss?
var myworld = ModContent.GetInstance<TheLunaticWorld>();
if( !myworld.GameLogic.HaveWeHopeToWin() ) { return; }
Item item = null;
int maskType = MaskLogic.GetMaskTypeOfNpc( npc.type );
if( maskType == -1 ) { return; }
// Already given this mask?
bool isVanilla = MaskLogic.AllVanillaMasks.Contains( maskType );
if( !myworld.MaskLogic.GivenVanillaMasksByType.Contains( maskType ) ) {
if( !isVanilla && myworld.MaskLogic.GivenCustomMasksByBossUid.Contains( NPCID.GetUniqueKey(npc) ) ) {
return;
}
}
// No modded masks allowed?
if( !isVanilla && mymod.Config.OnlyVanillaBossesDropMasks ) {
return;
}
int which = ItemHelpers.CreateItem( npc.position, maskType, 1, 15, 15 );
item = Main.item[which];
if( item != null && !item.IsAir ) {
if( maskType == ModContent.ItemType<CustomBossMaskItem>() ) {
var moditem = (CustomBossMaskItem)item.modItem;
if( !moditem.SetBoss(npc.type) ) {
ItemHelpers.DestroyWorldItem( which );
}
} else {
/*if( !modworld.MaskLogic.GivenVanillaMasks.Contains( mask_type ) ) {
// Does this mask already exist in the world?
for( int i = 0; i < Main.item.Length; i++ ) {
if( Main.item[i] != null && Main.item[i].active && Main.item[i].type == mask_type ) {
item = Main.item[i];
break;
}
}
}*/
}
} else {
LogHelpers.Log( "Could not spawn a mask of type " + maskType );
}
}
/*private int HurtAnimateLength = 15;
private IDictionary<int, int> HurtAnimate = new Dictionary<int, int>();
public override void DrawEffects( NPC npc, ref Color color ) {
if( !this.HurtAnimate.Keys.Contains(npc.whoAmI) || this.HurtAnimate[npc.whoAmI] == 0 ) { return; }
float scale = (float)this.HurtAnimate[npc.whoAmI] / (float)this.HurtAnimateLength;
scale /= 1.4f;
if( color.R < 255 ) {
color.R += (byte)((float)(255 - color.R) * scale);
}
color.G -= (byte)(color.G * scale);
color.B -= (byte)(color.B * scale);
this.HurtAnimate[npc.whoAmI]--;
}
public override bool StrikeNPC( NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit ) {
this.HurtAnimate[npc.whoAmI] = this.HurtAnimateLength;
return base.StrikeNPC( npc, ref damage, defense, ref knockback, hitDirection, ref crit );
}*/
}
}