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

Commit

Permalink
Several improvements all around
Browse files Browse the repository at this point in the history
Fixed #23
- Boss HoW and ancient dragon no longer take knockback
- Ancient dragon parts are no longer 'bosses', still technically bosses.
Only head shows in cheat sheet UI. Needs refactor direly. Refactor will
be similar to HoW
Made a utility extension for bosses to more easily set their downed
state (boss.Downed(true);)
Improved Helper.DropItems code, and the Drop class. This code is poop
anyway and should be avoided, at least it makes little sense now.
Some string literals were replaced (Item=>ItemType), whoops on that
  • Loading branch information
Jofairden committed Aug 21, 2017
1 parent 63a4cb7 commit 32c153e
Show file tree
Hide file tree
Showing 33 changed files with 132 additions and 178 deletions.
32 changes: 19 additions & 13 deletions Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Tremor
{
public delegate void ExtraAction();

// todo: note to self, migrate stuff to utils
public static class Helper
{
#region Spawn helpers
Expand Down Expand Up @@ -55,6 +56,9 @@ public static bool NoBiomeNormalSpawn(NPCSpawnInfo spawnInfo)
}
#endregion

public static void Downed(this TremorWorld.Boss boss, bool state)
=> TremorWorld.downedBoss[boss] = state;

public static bool Downed(this TremorWorld.Boss boss)
=> TremorWorld.downedBoss[boss];

Expand Down Expand Up @@ -355,28 +359,30 @@ public static void DrawAroundOrigin(int index, Color lightColor)
Main.spriteBatch.Draw(texture2D, projectile.Center - Main.screenPosition, texture2D.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame), lightColor, projectile.rotation, origin, projectile.scale, effects, 0f);
}

public static void DropItem(Rectangle Area, params Drop[] Drops)
public static void DropItems(Vector2 position, Vector2 randomBox, params Drop[] drops)
{
List<Drop> Sh = new List<Drop>();
Drops
.ToList()
.ForEach(drop =>
foreach (Drop drop in drops)
{
for (int index = 0; index < drop.Chance; index++)
Sh.Add(drop);
});
Drop DroppedItem = Sh[Main.rand.Next(Sh.Count)];
Item.NewItem(Area.X, Area.Y, Area.Height, Area.Width, DroppedItem.Item, DroppedItem.Count);
if (Main.rand.NextBool(drop.DropChance))
{
Item.NewItem(position, randomBox, drop.ItemType, drop.StackSize);
}
}
}

}

public struct Drop
{
public int Item; public int Count; public int Chance;
public Drop(int item, int count, int chance)
public int ItemType { get; }
public int StackSize { get; }
public int DropChance { get; }

public Drop(int itemType, int stackSize, int dropChance)
{
Item = item; Count = count; Chance = chance;
ItemType = itemType;
StackSize = stackSize;
DropChance = dropChance;
}
}
}
2 changes: 1 addition & 1 deletion Invasion/Titan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public override void NPCLoot()
}
if (!Main.expertMode && Main.rand.NextBool())
{
Helper.DropItem(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), new Drop(mod.ItemType("RocketWand"), 1, 1), new Drop(mod.ItemType("TheEtherealm"), 1, 1), new Drop(mod.ItemType("SoulFlames"), 1, 1));
Helper.DropItems(npc.position, npc.Size, new Drop(mod.ItemType("RocketWand"), 1, 1), new Drop(mod.ItemType("TheEtherealm"), 1, 1), new Drop(mod.ItemType("SoulFlames"), 1, 1));
}
if (Main.rand.Next(10) == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion NPCs/Alchemaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public override void NPCLoot()
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BadApple"));
}
TremorWorld.downedBoss[TremorWorld.Boss.Alchemaster] = true;
TremorWorld.Boss.Alchemaster.Downed(true);

}
}
Expand Down
28 changes: 10 additions & 18 deletions NPCs/AndasBoss/TrueAndas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,29 +200,21 @@ public override void NPCLoot()
{
npc.DropBossBags();
}

if (Main.netMode != 1)
else
{
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;
Helper.DropItems(npc.position, npc.Size, new Drop(mod.ItemType("Inferno"), 1, 1), new Drop(mod.ItemType("GehennaStaff"), 1, 1), new Drop(mod.ItemType("Pandemonium"), 1, 1), new Drop(mod.ItemType("VulcanBlade"), 1, 1), new Drop(mod.ItemType("HellStorm"), 1, 1));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3544, Main.rand.Next(10, 25));

if (!Main.expertMode)
if (Main.rand.Next(7) == 0)
{
Helper.DropItem(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), new Drop(mod.ItemType("Inferno"), 1, 1), new Drop(mod.ItemType("GehennaStaff"), 1, 1), new Drop(mod.ItemType("Pandemonium"), 1, 1), new Drop(mod.ItemType("VulcanBlade"), 1, 1), new Drop(mod.ItemType("HellStorm"), 1, 1));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3544, Main.rand.Next(10, 25));

if (Main.rand.Next(7) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("AndasMask"));
}
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("InfernoSoul"), Main.rand.Next(8, 15));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("AndasMask"));
}
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("InfernoSoul"), Main.rand.Next(8, 15));
}

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

if (Main.netMode != 1)
Expand Down
2 changes: 1 addition & 1 deletion NPCs/Brutallisk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public override void NPCLoot()
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrutalliskMask"));
}
TremorWorld.downedBoss[TremorWorld.Boss.Brutallisk] = true;
TremorWorld.Boss.Brutallisk.Downed(true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion NPCs/Chef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCo
}


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). Item 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
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
Expand Down
2 changes: 1 addition & 1 deletion NPCs/CogLord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void CogMessage(string Message)
}
public override void NPCLoot()
{
TremorWorld.downedBoss[TremorWorld.Boss.CogLord] = true;
TremorWorld.Boss.CogLord.Downed(true);
if (Main.netMode != 1)
{
if (Main.expertMode)
Expand Down
36 changes: 15 additions & 21 deletions NPCs/CyberKing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,29 +399,23 @@ public override void NPCLoot()
{
npc.DropBossBags();
}
if (Main.netMode != 1)

if (!Main.expertMode && Main.rand.NextBool())
{
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.expertMode && Main.rand.NextBool())
{
Helper.DropItem(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), new Drop(mod.ItemType("RedStorm"), 1, 1), new Drop(mod.ItemType("ShockwaveClaymore"), 1, 1), new Drop(mod.ItemType("CyberCutter"), 1, 1));
}
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 499, Main.rand.Next(6, 25));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 500, Main.rand.Next(6, 25));
Helper.DropItems(npc.position, npc.Size, new Drop(mod.ItemType("RedStorm"), 1, 1), new Drop(mod.ItemType("ShockwaveClaymore"), 1, 1), new Drop(mod.ItemType("CyberCutter"), 1, 1));
}
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 499, Main.rand.Next(6, 25));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 500, Main.rand.Next(6, 25));

if (Main.rand.Next(10) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CyberKingTrophy"));
}
if (!Main.expertMode && Main.rand.Next(7) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CyberKingMask"));
}
TremorWorld.downedBoss[TremorWorld.Boss.CyberKing] = true;
if (Main.rand.Next(10) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CyberKingTrophy"));
}
}
if (!Main.expertMode && Main.rand.Next(7) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CyberKingMask"));
}
TremorWorld.Boss.CyberKing.Downed(true);
}
}
}
14 changes: 4 additions & 10 deletions NPCs/DesertMimic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@ public override void SetDefaults()

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;
Helper.DropItem(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), new Drop(mod.ItemType("AntlionFury"), 1, 1), new Drop(mod.ItemType("Hurricane"), 1, 2), new Drop(mod.ItemType("SandShuriken"), 1, 2), new Drop(mod.ItemType("CrawlerHook"), 1, 1), new Drop(0, 0, 0));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 500, Main.rand.Next(10));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 499, Main.rand.Next(10));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 327);
}
Helper.DropItems(npc.position, npc.Size, new Drop(mod.ItemType("AntlionFury"), 1, 1), new Drop(mod.ItemType("Hurricane"), 1, 2), new Drop(mod.ItemType("SandShuriken"), 1, 2), new Drop(mod.ItemType("CrawlerHook"), 1, 1), new Drop(0, 0, 0));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 500, Main.rand.Next(10));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 499, Main.rand.Next(10));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 327);
}

public override float SpawnChance(NPCSpawnInfo spawnInfo)
Expand Down
12 changes: 3 additions & 9 deletions NPCs/DesertPrincess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,15 +515,9 @@ public override void ScaleExpertStats(int numPlayers, float bossLifeScale)

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;
Helper.DropItem(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), new Drop(mod.ItemType("DesertExplorerVisage"), 1, 1), new Drop(mod.ItemType("DesertExplorerGreaves"), 1, 2), new Drop(mod.ItemType("DesertExplorerBreastplate"), 1, 2));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 500, Main.rand.Next(5, 15));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 499, Main.rand.Next(5, 15));
}
Helper.DropItems(npc.position, npc.Size, new Drop(mod.ItemType("DesertExplorerVisage"), 1, 1), new Drop(mod.ItemType("DesertExplorerGreaves"), 1, 2), new Drop(mod.ItemType("DesertExplorerBreastplate"), 1, 2));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 500, Main.rand.Next(5, 15));
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 499, Main.rand.Next(5, 15));
}
}
}
6 changes: 4 additions & 2 deletions NPCs/Dragon_BodyB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public override void SetStaticDefaults()
{
DisplayName.SetDefault("Ancient Dragon");
Main.npcFrameCount[npc.type] = 2;
NPCID.Sets.TechnicallyABoss[npc.type] = true;
}

public override void SetDefaults()
Expand All @@ -25,10 +26,11 @@ public override void SetDefaults()
npc.aiStyle = 6;
aiType = -1;
animationType = 10;
npc.knockBackResist = 0f;
npc.boss = true;
npc.knockBackResist = 1f;

npc.value = Item.buyPrice(0, 25, 0, 0);
npc.alpha = 255;

npc.behindTiles = true;
npc.noGravity = true;
npc.noTileCollide = true;
Expand Down
70 changes: 31 additions & 39 deletions NPCs/Dragon_HeadB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,22 @@
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Tremor.Items;

namespace Tremor.NPCs
{
//todo: refactor, comparable to HoW
[AutoloadBossHead]
public class Dragon_HeadB : ModNPC
{

public override void SetStaticDefaults()
{
DisplayName.SetDefault("Ancient Dragon");
}

bool TailSpawned;

private bool _tailSpawned;
public static int ShootRate = 20;
const int ShootDamage = 58;
const float ShootKN = 1.0f;
const int ShootType = 100;
const float ShootSpeed = 10;
const int ShootCount = 5;
const int spread = 2;
const float spreadMult = 0.045f;

const int ShootSound = 62;
const int ShootSoundStyle = 1;

int TimeToShoot = ShootRate;

public override void SetDefaults()
{
npc.damage = 28;
Expand All @@ -41,58 +30,60 @@ public override void SetDefaults()
npc.lifeMax = 3100;
npc.aiStyle = 6;
npc.npcSlots = 1f;
npc.knockBackResist = 1f;

npc.noTileCollide = true;
npc.behindTiles = true;
npc.friendly = false;
npc.dontTakeDamage = false;
npc.noGravity = true;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.buffImmune[24] = true;
npc.buffImmune[67] = true;
npc.boss = true;
npc.lavaImmune = true;

npc.buffImmune[BuffID.OnFire] = true;
npc.buffImmune[BuffID.Burning] = true;

music = MusicID.Boss2;
npc.boss = true;
bossBag = mod.ItemType("AncientDragonBag");
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
bossBag = mod.ItemType<AncientDragonBag>();
}

public override void NPCLoot()
{

if (Main.expertMode)
{
npc.DropBossBags();
}

if (Main.netMode != 1)
else
{
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.expertMode && Main.rand.Next(7) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("AncientDragonMask"));
}
if (Main.rand.Next(10) == 0)
if (Main.rand.NextBool(7))
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("AncientDragonTrophy"));
Item.NewItem(npc.position, npc.Size, mod.ItemType<AncientDragonMask>());
}
if (!Main.expertMode && Main.rand.NextBool())

if (Main.rand.NextBool())
{
Helper.DropItem(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), new Drop(mod.ItemType("AncientTimesEdge"), 1, 1), new Drop(mod.ItemType("DragonHead"), 1, 1), new Drop(mod.ItemType("Swordstorm"), 1, 1), new Drop(0, 0, 0));
Item.NewItem(npc.position, npc.Size, mod.ItemType<AncientTimesEdge>());
Item.NewItem(npc.position, npc.Size, mod.ItemType<DragonHead>());
Item.NewItem(npc.position, npc.Size, mod.ItemType<Swordstorm>());
}
TremorWorld.downedBoss[TremorWorld.Boss.AncientDragon] = true;
}

if (Main.rand.NextBool(10))
{
Item.NewItem(npc.position, npc.Size, mod.ItemType<AncientDragonTrophy>());
}

TremorWorld.Boss.AncientDragon.Downed(true);
}


public override void AI()
{
npc.position += npc.velocity * (2 - 1);

if (!TailSpawned)
if (!_tailSpawned)
{
int Previous = npc.whoAmI;
for (int num36 = 0; num36 < 19; num36++)
Expand All @@ -113,7 +104,7 @@ public override void AI()
//NetMessage.SendData(23, -1, -1, "", lol, 0f, 0f, 0f, 0);
Previous = lol;
}
TailSpawned = true;
_tailSpawned = true;
}

if ((int)(Main.time % 180) == 0)
Expand All @@ -125,6 +116,7 @@ public override void AI()
npc.netUpdate = true;
}
}

public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D drawTexture = Main.npcTexture[npc.type];
Expand Down
Loading

0 comments on commit 32c153e

Please sign in to comment.