Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
[Refactor] NPC cleanup. (#32)
Browse files Browse the repository at this point in the history
* Cleaned up NPCs.

Cleaned up all NPCs whose class names start with 'A' or 'B' (excluding bosses).
Removed BrutalliskSpawnMobs class and file and moved the functionality from that class to the Brutallisk NPC.

* [Refactor] NPC cleanup.

Cleaned up NPCs/improved NPCs whose class names start with 'C' or 'D' (excluding bosses).
Also merged the functionality from `DesertMimicSummon.cs` into `TremorPlayer.cs`.

* [Refactor] Changed all SpawnItem calls to NewItem.

* [Refactor] NPC cleanup.

Cleaned up NPCs in alphabetical order from 'E' to 'O'. Also started revamping Cog Lord (slight changes).

* [Refactor] Finished cleaning up NPCs.

Cleaned up all NPCs (excluding bosses and some of their minions).
  • Loading branch information
Eldrazi authored and Jofairden committed Aug 28, 2017
1 parent 80594ce commit 945dfd9
Show file tree
Hide file tree
Showing 209 changed files with 2,952 additions and 6,700 deletions.
26 changes: 13 additions & 13 deletions NPCs/Archer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Archer : ModNPC

public override bool Autoload(ref string name)
{
name = "Arcer";
name = "Archer";
return mod.Properties.Autoload;
}

Expand Down Expand Up @@ -96,30 +96,30 @@ public override void OnChatButtonClicked(bool firstButton, ref bool shop)

public override void SetupShop(Chest shop, ref int nextSlot)
{
shop.item[nextSlot].SetDefaults(ItemID.WoodenArrow);
shop.item[nextSlot].SetDefaults(mod.ItemType<ArcherGlove>());
shop.item[nextSlot].SetDefaults(mod.ItemType<Crossbow>());
shop.AddUniqueItem(ref nextSlot, ItemID.WoodenArrow);
shop.AddUniqueItem(ref nextSlot, mod.ItemType<ArcherGlove>());
shop.AddUniqueItem(ref nextSlot, mod.ItemType<Crossbow>());

if (NPC.downedBoss1)
{
shop.item[nextSlot].SetDefaults(mod.ItemType<Quiver>());
shop.item[nextSlot].SetDefaults(mod.ItemType<MiniGun>());
shop.item[nextSlot].SetDefaults(ItemID.JestersArrow);
shop.AddUniqueItem(ref nextSlot, mod.ItemType<Quiver>());
shop.AddUniqueItem(ref nextSlot, mod.ItemType<MiniGun>());
shop.AddUniqueItem(ref nextSlot, ItemID.JestersArrow);
}
if (NPC.downedBoss2)
{
shop.item[nextSlot].SetDefaults(ItemID.UnholyArrow);
shop.item[nextSlot].SetDefaults(mod.ItemType<DragonGem>());
shop.AddUniqueItem(ref nextSlot, ItemID.UnholyArrow);
shop.AddUniqueItem(ref nextSlot, mod.ItemType<DragonGem>());
}

if (Main.hardMode)
{
shop.item[nextSlot].SetDefaults(ItemID.HolyArrow);
shop.item[nextSlot].SetDefaults(ItemID.HellfireArrow);
shop.AddUniqueItem(ref nextSlot, ItemID.HolyArrow);
shop.AddUniqueItem(ref nextSlot, ItemID.HellfireArrow);
}

if (Main.bloodMoon)
shop.item[nextSlot].SetDefaults(ItemID.BoneArrow);
shop.AddUniqueItem(ref nextSlot, ItemID.BoneArrow);
}

public override void TownNPCAttackStrength(ref int damage, ref float knockback)
Expand Down
36 changes: 7 additions & 29 deletions NPCs/CaveGolem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

using Microsoft.Xna.Framework;

using Tremor.Items;

namespace Tremor.NPCs
{

public class CaveGolem : ModNPC
{
public override void SetStaticDefaults()
Expand Down Expand Up @@ -33,20 +35,13 @@ public override void SetDefaults()
bannerItem = mod.ItemType("CaveGolemBanner");
}

public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = npc.lifeMax * 1;
npc.damage = npc.damage * 1;
}

public override void HitEffect(int hitDirection, double damage)
{
if (npc.life <= 0)
{
for (int k = 0; k < 20; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 151, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f);
}

Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CaveGolemGore1"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CaveGolemGore2"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CaveGolemGore2"), 1f);
Expand All @@ -57,27 +52,10 @@ public override void HitEffect(int hitDirection, double damage)

public override void NPCLoot()
{
if (Main.netMode != 1)
{
int centerX = (int)(npc.position.X + npc.width / 2) / 16;
int centerY = (int)(npc.position.Y + npc.height / 2) / 16;
int halfLength = npc.width / 2 / 16 + 1;

if (Main.rand.Next(30) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ColossusSword"));
}
}
npc.NewItem(mod.ItemType<ColossusSword>());
}


public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
int x = spawnInfo.spawnTileX;
int y = spawnInfo.spawnTileY;
int tile = Main.tile[x, y].type;
return (Helper.NoZoneAllowWater(spawnInfo)) && y > Main.rockLayer ? 0.01f : 0f;
}

=> Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f;
}
}
120 changes: 43 additions & 77 deletions NPCs/Chef.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Tremor.Items;

namespace Tremor.NPCs
{
[AutoloadHead]
Expand Down Expand Up @@ -47,59 +50,39 @@ public override void SetDefaults()
animationType = NPCID.GoblinTinkerer;
}


public override bool CanTownNPCSpawn(int numTownNPCs, int money)
{
if (NPC.downedBoss2)
{
return true;
}
return false;
}

=> NPC.downedBoss2;

public override string TownNPCName()
{
switch (WorldGen.genRand.Next(5))
string[] names =
{
case 0:
return "Richard";
case 1:
return "Oliver";
case 2:
return "Alan";
case 3:
return "Gordon";
case 4:
return "Umeril";
case 5:
return "Anthony";
case 6:
return "Jerome";
default:
return "Liam";
}
"Richard",
"Oliver",
"Alan",
"Gordon",
"Umeril",
"Anthony",
"Jerome",
"Liam"
};
return names.TakeRandom();
}

public override string GetChat()
{
switch (Main.rand.Next(6))
// weighted chats?
string[] chats =
{
case 0:
return "This crab is so undercooked, it's still singing under the sea!";
case 1:
return "This needs more salt! And a dash of powdered blinkroot.";
case 2:
return "Any Oaf can make a bowl of soup, while I create culinary art";
case 3:
return "Somebody have stolen my knife. I think I will cut this guy with the knife when I will find it.";
case 4:
return "No! I will not add vile powder to this flambe.";
case 5:
return "Hello there! How's it goin'?";
default:
return "Do you know recipes of unusual food? No? THEN GO AND FIND THEM FOR ME OR I WILL CU-... Oh. Sorry.";
}
"This crab is so undercooked, it's still singing under the sea!",
"This needs more salt! And a dash of powdered blinkroot.",
"Any Oaf can make a bowl of soup, while I create culinary art.",
"Somebody stole my knife. I think I will cut the thief with the knife when I find it.",
"No! I will not add vile powder to this flambe.",
"Hello there! How's it goin'?",
"Do you know recipes of unusual food? No? THEN GO AND FIND THEM FOR ME OR I WILL CU-... Oh. Sorry."
};
return chats.TakeRandom();
}

public override void SetChatButtons(ref string button, ref string button2)
Expand All @@ -109,37 +92,23 @@ public override void SetChatButtons(ref string button, ref string button2)

public override void OnChatButtonClicked(bool firstButton, ref bool shop)
{
if (firstButton)
{
shop = true;
}
shop = firstButton;
}

public override void SetupShop(Chest shop, ref int nextSlot)
{
shop.item[nextSlot].SetDefaults(mod.ItemType("ButcherAxe"));
nextSlot++;
shop.item[nextSlot].SetDefaults(mod.ItemType("Knife"));
nextSlot++;
if (NPC.AnyNPCs(mod.NPCType("Farmer")))
{
shop.item[nextSlot].SetDefaults(mod.ItemType("Carrow"));
nextSlot++;
}
shop.item[nextSlot].SetDefaults(mod.ItemType("ChefHat"));
nextSlot++;
shop.item[nextSlot].SetDefaults(mod.ItemType("Durian"));
nextSlot++;
shop.AddUniqueItem(ref nextSlot, mod.ItemType<Knife>());
shop.AddUniqueItem(ref nextSlot, mod.ItemType<Durian>());
shop.AddUniqueItem(ref nextSlot, mod.ItemType<ChefHat>());
shop.AddUniqueItem(ref nextSlot, mod.ItemType<ButcherAxe>());

if (NPC.AnyNPCs(mod.NPCType<Farmer>()))
shop.AddUniqueItem(ref nextSlot, mod.ItemType<Carrow>());

if (Main.bloodMoon)
{
shop.item[nextSlot].SetDefaults(mod.ItemType("CursedPopcorn"));
nextSlot++;
}
shop.AddUniqueItem(ref nextSlot, mod.ItemType<CursedPopcorn>());
if (NPC.downedBoss2)
{
shop.item[nextSlot].SetDefaults(mod.ItemType("ChickenLegMace"));
nextSlot++;
}
shop.AddUniqueItem(ref nextSlot, mod.ItemType<ChickenLegMace>());
}

public override void TownNPCAttackStrength(ref int damage, ref float knockback)
Expand All @@ -154,11 +123,10 @@ public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCo
randExtraCooldown = 10;
}


public override void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)//Allows you to customize how this town NPC's weapon is drawn when this NPC is swinging it (this NPC must have an attack type of 3). ItemType is the Texture2D instance of the item to be drawn (use Main.itemTexture[id of item]), itemSize is the width and height of the item's hitbox
{
scale = 1f;
item = Main.itemTexture[mod.ItemType("ButcherAxe")]; //this defines the item that this npc will use
item = Main.itemTexture[mod.ItemType<ButcherAxe>()]; //this defines the item that this npc will use
itemSize = 40;
}

Expand All @@ -173,12 +141,10 @@ public override void HitEffect(int hitDirection, double damage)
if (npc.life <= 0)
{
for (int k = 0; k < 20; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 151, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f);
}
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ChefGore1"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ChefGore2"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ChefGore3"), 1f);

for(int i = 0; i < 3; ++i)
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/ChefGore{i+1}"), 1f);
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions NPCs/Clamper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

using Microsoft.Xna.Framework;

namespace Tremor.NPCs
{
public class Clamper : ModNPC
Expand Down Expand Up @@ -35,10 +36,8 @@ public override void SetDefaults()

public override void HitEffect(int hitDirection, double damage)
{
if (npc.life <= 0)
{
NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Clamper2"));
}
if (Main.netMode != 1 && npc.life <= 0)
NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType<Clamper2>());
}

public override bool CheckActive() => false;
Expand Down Expand Up @@ -80,7 +79,7 @@ public override void AI()
// turn to loose clamper when target is too far away?
if (Main.player[Helper.GetNearestPlayer(npc.Center)].Distance(npc.position) > MaxTargetDistance)
{
int n = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Clamper2"));
int n = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType<Clamper2>());
Main.npc[n].rotation = npc.rotation;
Main.npc[n].velocity = npc.velocity;
npc.active = false;
Expand Down
5 changes: 3 additions & 2 deletions NPCs/Clamper2.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

using Microsoft.Xna.Framework;

namespace Tremor.NPCs
{
public class Clamper2 : ModNPC
Expand Down
18 changes: 3 additions & 15 deletions NPCs/CloudSlime.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

using Microsoft.Xna.Framework;

namespace Tremor.NPCs
{

public class CloudSlime : ModNPC
{
public override void SetStaticDefaults()
Expand All @@ -14,7 +14,6 @@ public override void SetStaticDefaults()
Main.npcFrameCount[npc.type] = 2;
}


public override void SetDefaults()
{
npc.lifeMax = 80;
Expand Down Expand Up @@ -60,18 +59,7 @@ public override void HitEffect(int hitDirection, double damage)
}
}

public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = npc.lifeMax * 1;
npc.damage = npc.damage * 1;
}

public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
int x = spawnInfo.spawnTileX;
int y = spawnInfo.spawnTileY;
int tile = Main.tile[x, y].type;
return Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.sky ? 0.02f : 0;
}
=> Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.sky ? 0.02f : 0;
}
}
Loading

0 comments on commit 945dfd9

Please sign in to comment.