/
PartyZombie.cs
47 lines (43 loc) · 1.54 KB
/
PartyZombie.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
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ExampleMod.NPCs
{
// Party Zombie is a pretty basic clone of a vanilla NPC. To learn how to further adapt vanilla NPC behaviors, see https://github.com/tModLoader/tModLoader/wiki/Advanced-Vanilla-Code-Adaption#example-npc-npc-clone-with-modified-projectile-hoplite
public class PartyZombie : ModNPC
{
public override void SetStaticDefaults() {
DisplayName.SetDefault("Zombie");
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Zombie];
}
public override void SetDefaults() {
npc.width = 18;
npc.height = 40;
npc.damage = 14;
npc.defense = 6;
npc.lifeMax = 200;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath2;
npc.value = 60f;
npc.knockBackResist = 0.5f;
npc.aiStyle = 3;
aiType = NPCID.Zombie;
animationType = NPCID.Zombie;
banner = Item.NPCtoBanner(NPCID.Zombie);
bannerItem = Item.BannerToItem(banner);
}
public override float SpawnChance(NPCSpawnInfo spawnInfo) {
return SpawnCondition.OverworldNightMonster.Chance * 0.5f;
}
public override void HitEffect(int hitDirection, double damage) {
for (int i = 0; i < 10; i++) {
int dustType = Main.rand.Next(139, 143);
int dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
Dust dust = Main.dust[dustIndex];
dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
dust.scale *= 1f + Main.rand.Next(-30, 31) * 0.01f;
}
}
}
}