From 945dfd97e79cf7c4f971977ff28e66c96b0400e9 Mon Sep 17 00:00:00 2001 From: Eldrazi Date: Mon, 28 Aug 2017 13:49:29 +0200 Subject: [PATCH] [Refactor] NPC cleanup. (#32) * 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). --- NPCs/Archer.cs | 26 +-- NPCs/CaveGolem.cs | 36 +--- NPCs/Chef.cs | 120 ++++------- NPCs/Clamper.cs | 11 +- NPCs/Clamper2.cs | 5 +- NPCs/CloudSlime.cs | 18 +- NPCs/CogLord.cs | 7 +- NPCs/ColossalTortoise.cs | 50 ++--- NPCs/CometHead.cs | 43 ++-- NPCs/ConjurerSkeleton.cs | 38 +--- NPCs/CoreBug.cs | 27 +-- NPCs/CoreSlime.cs | 33 +-- NPCs/Coretaur.cs | 52 ++--- NPCs/CorruptedBicholmere.cs | 33 +-- NPCs/CreatorofNightmares.cs | 35 +-- NPCs/Crimer.cs | 25 +-- NPCs/CrimsonBicholmere.cs | 33 +-- NPCs/Cybermite.cs | 29 ++- NPCs/DarkDruid.cs | 68 ++---- NPCs/DarkDruidMinion.cs | 32 +-- NPCs/DarkServant.cs | 21 +- NPCs/DarkSlime.cs | 22 +- NPCs/DeepwaterVilefish.cs | 33 +-- NPCs/Deimos.cs | 63 ++---- NPCs/DesertMimic.cs | 17 +- NPCs/DesertMimicSummon.cs | 99 --------- NPCs/DevilishTortoise.cs | 30 +-- NPCs/DevourerofPlanets.cs | 53 ++--- NPCs/Dinictis.cs | 39 +--- NPCs/DragonMini.cs | 10 +- NPCs/DragonSkull.cs | 39 +--- NPCs/Dranix.cs | 38 +--- NPCs/DreadBeetle.cs | 34 +-- NPCs/DungeonKeeper.cs | 33 +-- NPCs/ElderObserver.cs | 84 +++----- NPCs/Elf.cs | 116 ++++------ NPCs/EliteBloodmoonWarrior.cs | 35 +-- NPCs/EnragedBat.cs | 21 +- NPCs/EvolvedZombie.cs | 32 +-- NPCs/EvolvedZombie2.cs | 37 +--- NPCs/EvolvedZombie3.cs | 37 +--- NPCs/ExuberantHound.cs | 155 +++++++------- NPCs/FallenWarrior1.cs | 34 +-- NPCs/FallenWarrior2.cs | 34 +-- NPCs/FallenWarrior3.cs | 34 +-- NPCs/Farmer.cs | 144 +++++-------- NPCs/FatFlinx.cs | 33 +-- NPCs/FireBeetle.cs | 38 +--- NPCs/FlamingReaper.cs | 13 +- NPCs/Flayer.cs | 20 +- NPCs/FlyingJelly.cs | 15 +- NPCs/FlyingLeech.cs | 14 +- NPCs/ForestSpirit.cs | 22 +- NPCs/ForgeMaster.cs | 237 ++++++++------------- NPCs/FrostBeetle.cs | 49 ++--- NPCs/GGiantSlime.cs | 29 +-- NPCs/Galasquid.cs | 98 ++++----- NPCs/Geerd.cs | 35 +-- NPCs/Gelateen.cs | 42 +--- NPCs/GeneralSnowman.cs | 20 +- NPCs/GhostKnight.cs | 32 +-- NPCs/GhostWarrior.cs | 43 ++-- NPCs/GiantCrab.cs | 34 +-- NPCs/GiantGastropod.cs | 44 ++-- NPCs/GiantMeteorHead.cs | 38 +--- NPCs/GloomySeer.cs | 57 ++--- NPCs/GoblinAssassin.cs | 93 +++----- NPCs/GoblinBomber.cs | 192 +++++------------ NPCs/GoblinStandardBearer.cs | 51 ++--- NPCs/GoblinStandardBearer_Balloon.cs | 114 ++++------ NPCs/GogLordGog.cs | 70 +++--- NPCs/GoplitArcher.cs | 33 +-- NPCs/GoplitOfficer.cs | 23 +- NPCs/GraniteBeetle.cs | 40 +--- NPCs/GraniteBowman.cs | 40 +--- NPCs/GrayRaven.cs | 38 +--- NPCs/GreatFungusBug.cs | 18 +- NPCs/Grood.cs | 44 ++-- NPCs/Gurd.cs | 37 +--- NPCs/HallowSlimer.cs | 64 ++---- NPCs/Hallower.cs | 38 +--- NPCs/HappySoul.cs | 9 +- NPCs/HarpyWarrior.cs | 20 +- NPCs/HeadlessZombie.cs | 35 +-- NPCs/HeavyZombie.cs | 59 ++--- NPCs/Hellgron.cs | 22 +- NPCs/Hellhound.cs | 123 +++++------ NPCs/HiveHeadZombie.cs | 31 ++- NPCs/IceBlazer.cs | 45 +--- NPCs/IceMotherSlime.cs | 40 ++-- NPCs/InfectedZombie.cs | 14 +- NPCs/IronGiant.cs | 40 +--- NPCs/JungleMimic.cs | 14 +- NPCs/JungleMimicSummon.cs | 99 --------- NPCs/JungleSpirit.cs | 21 +- NPCs/Knight.cs | 125 ++++------- NPCs/KnightZombie.cs | 35 +-- NPCs/KnightZombieSword.cs | 41 +--- NPCs/LadyMoon.cs | 106 ++++----- NPCs/Leprechaun.cs | 19 +- NPCs/LihzahrdWarrior.cs | 32 +-- NPCs/LittleMushroomBug.cs | 17 +- NPCs/Lizard.cs | 7 - NPCs/Luminion.cs | 47 +--- NPCs/MagiumFlyer.cs | 15 +- NPCs/MagiumKeeper.cs | 40 ++-- NPCs/MagiumSword.cs | 21 +- NPCs/MagmaLeechBody.cs | 14 +- NPCs/MagmaLeechHead.cs | 54 +++-- NPCs/MagmaLeechTail.cs | 31 ++- NPCs/Magus.cs | 93 ++++---- NPCs/MechanicalFirefly.cs | 20 +- NPCs/MeteoriteGolem.cs | 38 +--- NPCs/MightyNimbus.cs | 30 +-- NPCs/Minotaur.cs | 34 +-- NPCs/MushroomCreature.cs | 25 +-- NPCs/Naga.cs | 28 +-- NPCs/NightTerror.cs | 43 ++-- NPCs/NightWalker.cs | 37 +--- NPCs/NorthWind.cs | 38 +--- NPCs/Observer.cs | 81 +++---- NPCs/OceanMimic.cs | 12 +- NPCs/OceanMimicSummon.cs | 99 --------- NPCs/OmegaWolf.cs | 36 +--- NPCs/Orc.cs | 42 +--- NPCs/OrcChampion.cs | 19 +- NPCs/OrcSkeleton.cs | 21 +- NPCs/OrcWarrior.cs | 53 ++--- NPCs/PGiantSlime.cs | 29 +-- NPCs/Parasprite.cs | 23 +- NPCs/Peepers.cs | 80 +++---- NPCs/Phabor.cs | 69 ++---- NPCs/Phantom.cs | 43 +--- NPCs/PharaohCaster.cs | 23 +- NPCs/Phobos.cs | 54 ++--- NPCs/PixieQueenGuardian.cs | 37 ++-- NPCs/PlagueSoul.cs | 11 +- NPCs/Polaris.cs | 45 ++-- NPCs/PossessedHornet1.cs | 39 +--- NPCs/PossessedHornet2.cs | 34 +-- NPCs/PossessedHound.cs | 39 +--- NPCs/Professor.cs | 114 ++++------ NPCs/PyramidHead.cs | 31 +-- NPCs/PyramidRider.cs | 34 +-- NPCs/QuartzBeetle.cs | 34 +-- NPCs/Quetzalcoatl.cs | 16 +- NPCs/RGiantSlime.cs | 33 +-- NPCs/RichSlime.cs | 38 +--- NPCs/Rogue.cs | 89 +++----- NPCs/RuinGhost1.cs | 16 +- NPCs/RuinGhost2.cs | 33 +-- NPCs/SandThing.cs | 38 +--- NPCs/ScaryBat.cs | 21 +- NPCs/Scavenger.cs | 307 +++++++++------------------ NPCs/Screamer.cs | 97 ++++----- NPCs/ShadowRipper.cs | 42 ++-- NPCs/Shnoot.cs | 46 ++-- NPCs/Shroot.cs | 46 ++-- NPCs/Sighted.cs | 27 +-- NPCs/SkeletonKnight.cs | 47 ++-- NPCs/Skullker.cs | 34 +-- NPCs/SnowBat.cs | 31 +-- NPCs/SnowEater.cs | 89 ++++---- NPCs/Snowcopter.cs | 21 +- NPCs/SnowmanBomber.cs | 20 +- NPCs/SnowmanWarrior.cs | 22 +- NPCs/Sorcerer.cs | 101 ++++----- NPCs/SpaceWhaleMinion.cs | 23 +- NPCs/Spaceman.cs | 48 +---- NPCs/SpiderMan.cs | 36 +--- NPCs/SquidZombie.cs | 48 ++--- NPCs/Squoma.cs | 47 ++-- NPCs/SupremePossessedArmor.cs | 35 +-- NPCs/TempleSlime.cs | 39 +--- NPCs/TheAxeman.cs | 36 +--- NPCs/TheGirl.cs | 35 +-- NPCs/TheThing.cs | 33 +-- NPCs/Thief1.cs | 100 +++------ NPCs/Thief2.cs | 99 +++------ NPCs/Thief3.cs | 100 +++------ NPCs/ThinMan.cs | 35 +-- NPCs/ThunderBones.cs | 54 ++--- NPCs/TikiSorcerer.cs | 28 +-- NPCs/TikiWarrior.cs | 25 +-- NPCs/TremorGlobalNPC.cs | 22 +- NPCs/TremorNPC.cs | 14 +- NPCs/TwilightBat.cs | 36 +--- NPCs/UndeadArchaeologist.cs | 21 +- NPCs/UndeadArchaeologist2.cs | 25 +-- NPCs/UndeadMusketeer.cs | 48 ++--- NPCs/UndeadWarlock.cs | 61 ++---- NPCs/UndeadWarrior1.cs | 56 ++--- NPCs/UndeadWarrior2.cs | 56 ++--- NPCs/UndeadWarrior3.cs | 55 ++--- NPCs/UndeadWarrior4.cs | 56 ++--- NPCs/Undertaker.cs | 10 +- NPCs/Warlock.cs | 94 +++----- NPCs/Witch.cs | 110 ++++------ NPCs/Woodling.cs | 35 +-- NPCs/WoodlingWarrior.cs | 41 +--- NPCs/Woody.cs | 15 +- NPCs/YGiantSlime.cs | 39 +--- NPCs/Zarprite.cs | 24 +-- NPCs/Zarprute.cs | 24 +-- NPCs/Zootaloo.cs | 54 ++--- NPCs/ZootalooMatriarch.cs | 59 ++--- Tremor.csproj | 10 +- TremorPlayer.cs | 156 ++++++++++++++ TremorUtils.cs | 9 + 209 files changed, 2952 insertions(+), 6700 deletions(-) delete mode 100644 NPCs/DesertMimicSummon.cs delete mode 100644 NPCs/JungleMimicSummon.cs delete mode 100644 NPCs/OceanMimicSummon.cs diff --git a/NPCs/Archer.cs b/NPCs/Archer.cs index 80bacf6e..2b640e4a 100644 --- a/NPCs/Archer.cs +++ b/NPCs/Archer.cs @@ -19,7 +19,7 @@ public class Archer : ModNPC public override bool Autoload(ref string name) { - name = "Arcer"; + name = "Archer"; return mod.Properties.Autoload; } @@ -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()); - shop.item[nextSlot].SetDefaults(mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, ItemID.WoodenArrow); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); if (NPC.downedBoss1) { - shop.item[nextSlot].SetDefaults(mod.ItemType()); - shop.item[nextSlot].SetDefaults(mod.ItemType()); - shop.item[nextSlot].SetDefaults(ItemID.JestersArrow); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, ItemID.JestersArrow); } if (NPC.downedBoss2) { - shop.item[nextSlot].SetDefaults(ItemID.UnholyArrow); - shop.item[nextSlot].SetDefaults(mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, ItemID.UnholyArrow); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } 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) diff --git a/NPCs/CaveGolem.cs b/NPCs/CaveGolem.cs index 0b2f0845..37d1727a 100644 --- a/NPCs/CaveGolem.cs +++ b/NPCs/CaveGolem.cs @@ -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() @@ -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); @@ -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()); } - 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; } } \ No newline at end of file diff --git a/NPCs/Chef.cs b/NPCs/Chef.cs index f76f3137..5d215eaf 100644 --- a/NPCs/Chef.cs +++ b/NPCs/Chef.cs @@ -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] @@ -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) @@ -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()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + + if (NPC.AnyNPCs(mod.NPCType())) + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (Main.bloodMoon) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("CursedPopcorn")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); if (NPC.downedBoss2) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("ChickenLegMace")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } public override void TownNPCAttackStrength(ref int damage, ref float knockback) @@ -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()]; //this defines the item that this npc will use itemSize = 40; } @@ -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); } } } diff --git a/NPCs/Clamper.cs b/NPCs/Clamper.cs index ccba8489..471f805a 100644 --- a/NPCs/Clamper.cs +++ b/NPCs/Clamper.cs @@ -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 @@ -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()); } public override bool CheckActive() => false; @@ -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()); Main.npc[n].rotation = npc.rotation; Main.npc[n].velocity = npc.velocity; npc.active = false; diff --git a/NPCs/Clamper2.cs b/NPCs/Clamper2.cs index d212526f..8f5e313d 100644 --- a/NPCs/Clamper2.cs +++ b/NPCs/Clamper2.cs @@ -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 diff --git a/NPCs/CloudSlime.cs b/NPCs/CloudSlime.cs index 39e27cfe..12962ff4 100644 --- a/NPCs/CloudSlime.cs +++ b/NPCs/CloudSlime.cs @@ -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() @@ -14,7 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 2; } - public override void SetDefaults() { npc.lifeMax = 80; @@ -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; } } \ No newline at end of file diff --git a/NPCs/CogLord.cs b/NPCs/CogLord.cs index 48f6e5bf..120cb41e 100644 --- a/NPCs/CogLord.cs +++ b/NPCs/CogLord.cs @@ -88,9 +88,14 @@ public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) spriteBatch.Draw(drawTexture, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, effects, 0); return false; } - + int t; public override void AI() { + if ((t++ % 100) == 0) + { + NPC.NewNPC((int)((Main.player[npc.target].position.X - 500) + Main.rand.Next(1000)), (int)((Main.player[npc.target].position.Y - 500) + Main.rand.Next(1000)), mod.NPCType("GogLordGog")); + t = 0; + } npc.TargetClosest(); if (Main.dayTime) { diff --git a/NPCs/ColossalTortoise.cs b/NPCs/ColossalTortoise.cs index f647028c..774bcfed 100644 --- a/NPCs/ColossalTortoise.cs +++ b/NPCs/ColossalTortoise.cs @@ -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 ColossalTortoise : ModNPC { public override void SetStaticDefaults() @@ -31,39 +33,20 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 4, 15, 0); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() { - Lighting.AddLight(npc.position, 1f, 0.3f, 0.3f); - if (Main.rand.Next(750) == 0) - { - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, 153); - } - + if (Main.netMode != 1 && Main.rand.Next(750) == 0) + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.GiantTortoise); } + 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("GiantShell"), Main.rand.Next(1, 3)); - } - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LostTurtleKnife"), Main.rand.Next(10, 55)); - } - } + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); + if (Main.rand.Next(3) == 0) + npc.NewItem(mod.ItemType(), Main.rand.Next(10, 55)); } public override void HitEffect(int hitDirection, double damage) @@ -85,8 +68,7 @@ public override void HitEffect(int hitDirection, double damage) } else { - - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -2f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -95,12 +77,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneJungle && NPC.downedMoonlord && Main.hardMode && y < Main.worldSurface ? 0.0002f : 0f; - } - + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneJungle && NPC.downedMoonlord && Main.hardMode && spawnInfo.spawnTileY < Main.worldSurface ? 0.0002f : 0f; } } \ No newline at end of file diff --git a/NPCs/CometHead.cs b/NPCs/CometHead.cs index 1338e4ea..7b6aa1ab 100644 --- a/NPCs/CometHead.cs +++ b/NPCs/CometHead.cs @@ -1,12 +1,15 @@ using System.Linq; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { - public class CometHead : ModNPC { public override void SetStaticDefaults() @@ -35,34 +38,12 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 4, 9); } - 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[] TileArray2 = { mod.TileType("CometiteOreTile"), mod.TileType("HardCometiteOreTile") }; - return TileArray2.Contains(Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY].type) ? 15f : 0f; - } 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CometiteOre"), Main.rand.Next(1, 2)); - } - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ChargedCrystal"), Main.rand.Next(1, 2)); - } - } + if (Main.rand.Next(2) == 0) + npc.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -74,6 +55,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 59, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 59, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 59, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 59, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -84,5 +66,10 @@ public override void HitEffect(int hitDirection, double damage) } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + int[] cometTiles = { mod.TileType("CometiteOreTile"), mod.TileType("HardCometiteOreTile") }; + return cometTiles.Contains(Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY].type) ? 15f : 0f; + } } } \ No newline at end of file diff --git a/NPCs/ConjurerSkeleton.cs b/NPCs/ConjurerSkeleton.cs index 141e0e9a..d214403c 100644 --- a/NPCs/ConjurerSkeleton.cs +++ b/NPCs/ConjurerSkeleton.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.ZombieEvent.Items; + namespace Tremor.NPCs { public class ConjurerSkeleton : ModNPC @@ -31,31 +34,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("ConjurerSkeletonBanner"); } - 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)) && NPC.downedBoss3 && y > Main.rockLayer ? 0.02f : 0f; - } - - 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(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2275); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TornPapyrus")); - }; - } + if (Main.rand.Next(6) == 0) + npc.NewItem(ItemID.MagicHat); + if (Main.rand.Next(20) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -63,17 +47,17 @@ 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadWarrior2Gore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); - } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss3 && spawnInfo.spawnTileY > Main.rockLayer ? 0.02f : 0f; } } diff --git a/NPCs/CoreBug.cs b/NPCs/CoreBug.cs index 75b9f7d9..3542f041 100644 --- a/NPCs/CoreBug.cs +++ b/NPCs/CoreBug.cs @@ -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 CoreBug : ModNPC { public override void SetStaticDefaults() @@ -33,10 +33,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("CoreBugBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void AI() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(4) == 0) + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color)].velocity *= 0.3f; } public override void HitEffect(int hitDirection, double damage) @@ -46,6 +46,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -54,21 +55,7 @@ public override void HitEffect(int hitDirection, double damage) } } - public override void AI() - { - if (Main.rand.Next(4) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } - } - 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.player.ZoneMeteor ? 0.005f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneMeteor ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/CoreSlime.cs b/NPCs/CoreSlime.cs index 7ea4937f..1b8d812c 100644 --- a/NPCs/CoreSlime.cs +++ b/NPCs/CoreSlime.cs @@ -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 CoreSlime : ModNPC { public override void SetStaticDefaults() @@ -32,6 +32,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("CoreSlimeBanner"); } + public override void AI() + { + if (Main.rand.Next(4) == 0) + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color)].velocity *= 0.3f; + } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -39,6 +45,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -47,27 +54,7 @@ public override void HitEffect(int hitDirection, double damage) } } - public override void AI() - { - if (Main.rand.Next(4) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } - } - - 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.player.ZoneMeteor ? 0.005f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneMeteor ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/Coretaur.cs b/NPCs/Coretaur.cs index 76051d12..b932373d 100644 --- a/NPCs/Coretaur.cs +++ b/NPCs/Coretaur.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class Coretaur : ModNPC @@ -28,25 +31,20 @@ public override void SetDefaults() animationType = NPCID.BigMimicHallow; // banner = npc.type; // Todo: bannerItem = mod.ItemType("CoretaurBanner"); - } + public override void AI() + { + if (Main.rand.Next(4) == 0) + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color)].velocity *= 0.3f; + } 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MinotaurHorn")); - }; - } + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType()); } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -61,32 +59,16 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CoretaurGore3"), 1f); for (int k = 0; k < 20; k++) { - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.6f); - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.6f); - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.6f); + for (int i = 0; i < 3; ++i) + { + Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.6f); + } } } } - public override void AI() - { - if (Main.rand.Next(4) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } - } - - 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)) && NPC.downedBoss3 && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.005f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss3 && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/CorruptedBicholmere.cs b/NPCs/CorruptedBicholmere.cs index 99a7de00..d3ed6f49 100644 --- a/NPCs/CorruptedBicholmere.cs +++ b/NPCs/CorruptedBicholmere.cs @@ -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 CorruptedBicholmere : ModNPC { public override void SetStaticDefaults() @@ -32,20 +32,13 @@ public override void SetDefaults() bannerItem = mod.ItemType(); } - 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/CorruptedBihcolmereGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CorruptedBicholmereGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CorruptedBicholmereGore3"), 1f); @@ -56,25 +49,11 @@ 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 68); - }; - } + if (Main.rand.NextBool()) + npc.NewItem(ItemID.RottenChunk); } 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.player.ZoneCorrupt && y > Main.rockLayer ? 0.05f : 0f; - } - + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneCorrupt && spawnInfo.spawnTileY > Main.rockLayer ? 0.05f : 0f; } } \ No newline at end of file diff --git a/NPCs/CreatorofNightmares.cs b/NPCs/CreatorofNightmares.cs index fd3c1395..b1dafaaa 100644 --- a/NPCs/CreatorofNightmares.cs +++ b/NPCs/CreatorofNightmares.cs @@ -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 CreatorofNightmares : ModNPC { public override void SetStaticDefaults() @@ -33,25 +35,10 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("CreatorofNightmaresBanner"); } - 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(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenHeroArmorplate")); - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(5) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -64,19 +51,13 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); + for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - } } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Helper.NormalSpawn(spawnInfo) && spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMoonlord && Main.eclipse ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMoonlord && Main.eclipse ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Crimer.cs b/NPCs/Crimer.cs index c07b518e..f7785207 100644 --- a/NPCs/Crimer.cs +++ b/NPCs/Crimer.cs @@ -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 Crimer : ModNPC { public override void SetStaticDefaults() @@ -33,32 +33,19 @@ public override void SetDefaults() bannerItem = mod.ItemType("CrimerBanner"); } - 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); - } - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, 183); + + if(Main.netMode != 1) + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, NPCID.Crimslime); } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneCrimson && Main.hardMode && y < Main.worldSurface ? 0.02f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneCrimson && Main.hardMode && spawnInfo.spawnTileY < Main.worldSurface ? 0.02f : 0f; } } \ No newline at end of file diff --git a/NPCs/CrimsonBicholmere.cs b/NPCs/CrimsonBicholmere.cs index 7a27ef99..06b376cd 100644 --- a/NPCs/CrimsonBicholmere.cs +++ b/NPCs/CrimsonBicholmere.cs @@ -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 CrimsonBicholmere : ModNPC { public override void SetStaticDefaults() @@ -32,20 +32,13 @@ public override void SetDefaults() bannerItem = mod.ItemType(); } - 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/CrimsonBicholmereGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CrimsonBicholmereGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CrimsonBicholmereGore3"), 1f); @@ -56,25 +49,11 @@ 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 1330); - }; - } + if (Main.rand.NextBool()) + npc.NewItem(ItemID.Vertebrae); } 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.player.ZoneCrimson && y > Main.rockLayer ? 0.01f : 0f; - } - + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneCrimson && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Cybermite.cs b/NPCs/Cybermite.cs index 209bbf26..649bf3b9 100644 --- a/NPCs/Cybermite.cs +++ b/NPCs/Cybermite.cs @@ -1,13 +1,18 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { - public class Cybermite : ModNPC { + public Vector2 bossCenter + { + get { return npc.Center; } + set { npc.position = value - new Vector2(npc.width / 2, npc.height / 2); } + } public override void SetStaticDefaults() { @@ -30,20 +35,6 @@ public override void SetDefaults() npc.DeathSound = SoundID.NPCDeath6; } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CybermiteGore"), 1f); - } - } - - public Vector2 bossCenter - { - get { return npc.Center; } - set { npc.position = value - new Vector2(npc.width / 2, npc.height / 2); } - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.625f * bossLifeScale); @@ -54,5 +45,11 @@ public override void AI() { Lighting.AddLight(bossCenter, 1f, 0.3f, 0.3f); } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CybermiteGore"), 1f); + } } } \ No newline at end of file diff --git a/NPCs/DarkDruid.cs b/NPCs/DarkDruid.cs index 37018780..da4f4bac 100644 --- a/NPCs/DarkDruid.cs +++ b/NPCs/DarkDruid.cs @@ -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 DarkDruid : ModNPC { public override void SetStaticDefaults() @@ -32,39 +34,24 @@ public override void SetDefaults() bannerItem = mod.ItemType("DarkDruidBanner"); } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() { - if (Main.rand.Next(160) == 0) - { + if (Main.netMode != 1 && Main.rand.Next(160) == 0) NPC.NewNPC((int)npc.position.X - 50, (int)npc.position.Y, mod.NPCType("DarkDruidMinion")); - } if (Main.rand.Next(1000) == 0) - { Main.PlaySound(105, (int)npc.position.X, (int)npc.position.Y, 1); - } if (Main.rand.Next(1000) == 0) - { Main.PlaySound(91, (int)npc.position.X, (int)npc.position.Y, 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DarkDruidGore1"), 1f); @@ -76,40 +63,19 @@ 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(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("DarkDruidMask")); - }; - if (Main.rand.Next(8) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 178); - }; - if (Main.rand.Next(8) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 180); - }; - if (Main.rand.Next(8) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 182); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TearsofDeath"), Main.rand.Next(1, 5)); - }; - } + if (Main.rand.Next(20) == 0) + npc.NewItem(mod.ItemType()); + if (Main.rand.Next(8) == 0) + npc.NewItem(ItemID.Ruby); + if (Main.rand.Next(8) == 0) + npc.NewItem(ItemID.Topaz); + if (Main.rand.Next(8) == 0) + npc.NewItem(ItemID.Diamond); + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType(), Main.rand.Next(1, 5)); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.bloodMoon && y < Main.worldSurface ? 0.004f : 0f; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.004f : 0f; } } \ No newline at end of file diff --git a/NPCs/DarkDruidMinion.cs b/NPCs/DarkDruidMinion.cs index 8d014fbc..d45e787d 100644 --- a/NPCs/DarkDruidMinion.cs +++ b/NPCs/DarkDruidMinion.cs @@ -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 DarkDruidMinion : ModNPC { public override void SetStaticDefaults() @@ -31,24 +31,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 0); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 58); - }; - } + if (Main.rand.Next(2) == 0) + npc.NewItem(ItemID.Heart); } public override void HitEffect(int hitDirection, double damage) @@ -56,13 +42,13 @@ 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); + + for (int i = 0; i < 2; ++i) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); } } } diff --git a/NPCs/DarkServant.cs b/NPCs/DarkServant.cs index 1e7b0da6..7531aeda 100644 --- a/NPCs/DarkServant.cs +++ b/NPCs/DarkServant.cs @@ -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 DarkServant : ModNPC { public override void SetStaticDefaults() @@ -30,7 +32,6 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 0); } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -40,6 +41,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 191, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 191, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); } + Dust.NewDust(npc.position, npc.width, npc.height, 191, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 191, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 191, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); @@ -52,17 +54,8 @@ 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(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("DarkGel")); - } - } + if (Main.rand.Next(6) == 0) + npc.NewItem(mod.ItemType()); } } } \ No newline at end of file diff --git a/NPCs/DarkSlime.cs b/NPCs/DarkSlime.cs index ecd60e60..d696f1a3 100644 --- a/NPCs/DarkSlime.cs +++ b/NPCs/DarkSlime.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { @@ -30,15 +33,13 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 0); } - 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, 191, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); - } + Dust.NewDust(npc.position, npc.width, npc.height, 191, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 191, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); @@ -49,17 +50,8 @@ 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(8) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("DarkGel"), Main.rand.Next(1, 2)); - } - } + if (Main.rand.Next(8) == 0) + npc.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); } } } \ No newline at end of file diff --git a/NPCs/DeepwaterVilefish.cs b/NPCs/DeepwaterVilefish.cs index f3bc3757..aecc6621 100644 --- a/NPCs/DeepwaterVilefish.cs +++ b/NPCs/DeepwaterVilefish.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { @@ -32,44 +33,20 @@ public override void SetDefaults() bannerItem = mod.ItemType("DeepwaterVilefishBanner"); } - 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); - } - } } 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 68); - }; - } + if (Main.rand.NextBool()) + npc.NewItem(ItemID.RottenChunk); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return spawnInfo.player.ZoneCorrupt && y > Main.rockLayer ? 0.05f : 0f; - } - + => spawnInfo.player.ZoneCorrupt && spawnInfo.spawnTileY > Main.rockLayer ? 0.05f : 0f; } } \ No newline at end of file diff --git a/NPCs/Deimos.cs b/NPCs/Deimos.cs index 624eca74..bb881aa2 100644 --- a/NPCs/Deimos.cs +++ b/NPCs/Deimos.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { @@ -39,45 +42,19 @@ public override void AI() { if (Main.rand.Next(6) == 0) { - Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, npc.color, 1f); - Dust.NewDust(npc.position, npc.width, npc.height, 70, 0f, 0f, 200, npc.color, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, npc.color); + Dust.NewDust(npc.position, npc.width, npc.height, 70, 0f, 0f, 200, npc.color); } } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.05f : 0f; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("EyeofOblivion")); - } - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CarbonSteel"), Main.rand.Next(2, 15)); - } - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ToothofAbraxas"), Main.rand.Next(2, 16)); - } - } + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType()); + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType(), Main.rand.Next(2, 15)); + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType(), Main.rand.Next(2, 16)); } public override void HitEffect(int hitDirection, double damage) @@ -91,12 +68,12 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); } for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); - } + Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 3.7f); Dust.NewDust(npc.position, npc.width, npc.height, 70, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 3.7f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DeimosGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DeimosGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DeimosGore2"), 1f); @@ -104,11 +81,17 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + int x = spawnInfo.spawnTileX; + int y = spawnInfo.spawnTileY; + int tile = Main.tile[x, y].type; + return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.05f : 0f; + } } } \ No newline at end of file diff --git a/NPCs/DesertMimic.cs b/NPCs/DesertMimic.cs index bec02d1f..3ba2b28a 100644 --- a/NPCs/DesertMimic.cs +++ b/NPCs/DesertMimic.cs @@ -1,4 +1,3 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -31,18 +30,14 @@ public override void SetDefaults() public override void NPCLoot() { - 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); + // Don't know what to do with this loot table. + 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)); + npc.NewItem(ItemID.GreaterHealingPotion, Main.rand.Next(10)); + npc.NewItem(ItemID.GreaterManaPotion, Main.rand.Next(10)); + npc.NewItem(ItemID.GoldenKey); } 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)) && Main.hardMode && spawnInfo.player.ZoneDesert && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && spawnInfo.player.ZoneDesert && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/DesertMimicSummon.cs b/NPCs/DesertMimicSummon.cs deleted file mode 100644 index 6c3e3474..00000000 --- a/NPCs/DesertMimicSummon.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace Tremor.NPCs -{ - // Example Soul of Light/Soul of Night style NPC summon - public class DesertMimicSummon : ModPlayer - { - public int LastChest; - - // This doesn't make sense, but this is around where this check happens in Vanilla Terraria. - public override void PreUpdateBuffs() - { - if (Main.netMode != 1) - { - if (player.chest == -1 && LastChest >= 0 && Main.chest[LastChest] != null) - { - int x2 = Main.chest[LastChest].x; - int y2 = Main.chest[LastChest].y; - ChestItemSummonCheck(x2, y2, mod); - } - LastChest = player.chest; - } - } - - public static bool ChestItemSummonCheck(int x, int y, Mod mod) - { - if (Main.netMode == 1) - { - return false; - } - int num = Chest.FindChest(x, y); - if (num < 0) - { - return false; - } - int numberDesertKey = 0; - int numberOtherItems = 0; - ushort tileType = Main.tile[Main.chest[num].x, Main.chest[num].y].type; - int tileStyle = Main.tile[Main.chest[num].x, Main.chest[num].y].frameX / 36; - if (TileID.Sets.BasicChest[tileType] && (tileStyle < 5 || tileStyle > 6)) - { - for (int i = 0; i < 40; i++) - { - if (Main.chest[num].item[i] != null && Main.chest[num].item[i].type > 0) - { - if (Main.chest[num].item[i].type == mod.ItemType("KeyofSands")) - { - numberDesertKey += Main.chest[num].item[i].stack; - } - else - { - numberOtherItems++; - } - } - } - } - if (numberOtherItems == 0 && numberDesertKey == 1) - { - if (TileID.Sets.BasicChest[Main.tile[x, y].type]) - { - if (Main.tile[x, y].frameX % 36 != 0) - { - x--; - } - if (Main.tile[x, y].frameY % 36 != 0) - { - y--; - } - int number = Chest.FindChest(x, y); - for (int j = x; j <= x + 1; j++) - { - for (int k = y; k <= y + 1; k++) - { - if (Main.tile[j, k].type == 21) - { - Main.tile[j, k].active(false); - } - } - } - for (int l = 0; l < 40; l++) - { - Main.chest[num].item[l] = new Item(); - } - Chest.DestroyChest(x, y); - NetMessage.SendData(34, -1, -1, null, 1, x, y, 0f, number, 0, 0); - NetMessage.SendTileSquare(-1, x, y, 3); - } - int npcToSpawn = mod.NPCType("DesertMimic"); - int npcIndex = NPC.NewNPC(x * 16 + 16, y * 16 + 32, npcToSpawn, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[npcIndex].whoAmI = npcIndex; - NetMessage.SendData(23, -1, -1, null, npcIndex, 0f, 0f, 0f, 0, 0, 0); - Main.npc[npcIndex].BigMimicSpawnSmoke(); - } - return false; - } - } -} diff --git a/NPCs/DevilishTortoise.cs b/NPCs/DevilishTortoise.cs index 62e65b61..27675bc5 100644 --- a/NPCs/DevilishTortoise.cs +++ b/NPCs/DevilishTortoise.cs @@ -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 DevilishTortoise : ModNPC { public override void SetStaticDefaults() @@ -14,7 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 8; } - public override void SetDefaults() { npc.lifeMax = 400; @@ -33,21 +32,7 @@ public override void SetDefaults() banner = npc.type; bannerItem = mod.ItemType("DevilishTortoiseBanner"); } - - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.02f : 0; - } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -66,14 +51,15 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { - Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); + for(int i = 0; i < 3; ++i) + Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); } } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.02f : 0; } } \ No newline at end of file diff --git a/NPCs/DevourerofPlanets.cs b/NPCs/DevourerofPlanets.cs index e067f474..b7f91c2a 100644 --- a/NPCs/DevourerofPlanets.cs +++ b/NPCs/DevourerofPlanets.cs @@ -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 DevourerofPlanets : ModNPC { public override void SetStaticDefaults() @@ -14,7 +16,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 2; } - public override void SetDefaults() { npc.lifeMax = 15000; @@ -36,40 +37,14 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("DevourerofPlanetsBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("HuskofDusk"), Main.rand.Next(2, 5)); - } - if (Main.rand.Next(10) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("EyeofOblivion"), Main.rand.Next(1)); - } - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("NightCore"), Main.rand.Next(1)); - } - } - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && TremorWorld.Boss.Trinity.IsDowned() && !spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.005f : 0f; + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType(), Main.rand.Next(2, 5)); + if (Main.rand.Next(10) == 0) + npc.NewItem(mod.ItemType()); + if (Main.rand.Next(3) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -86,9 +61,9 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DevourerofPlanetsGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DevourerofPlanetsGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DevourerofPlanetsGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/DevourerofPlanetsGore{i+1}"), 1f); } else { @@ -101,5 +76,7 @@ public override void HitEffect(int hitDirection, double damage) } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Main.hardMode && TremorWorld.Boss.Trinity.IsDowned() && !spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/Dinictis.cs b/NPCs/Dinictis.cs index 05cde244..a0a51d9a 100644 --- a/NPCs/Dinictis.cs +++ b/NPCs/Dinictis.cs @@ -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 Dinictis : ModNPC { public override void SetStaticDefaults() @@ -33,46 +35,25 @@ public override void SetDefaults() bannerItem = mod.ItemType("DinictisBanner"); } - 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/DinictisGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DinictisGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DinictisGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/DinictisGore{i+1}"), 1f); } } 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(35) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Sharking")); - }; - } + if (Main.rand.Next(35) == 0) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType()); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && (tile == 53 || tile == 112 || tile == 116 || tile == 234) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.water) && Main.hardMode && y < Main.rockLayer && (x < 250 || x > Main.maxTilesX - 250) && !spawnInfo.playerSafe ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Main.tileSand[spawnInfo.spawnTileType] && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.water && Main.hardMode && spawnInfo.spawnTileY < Main.rockLayer && (spawnInfo.spawnTileX < 250 || spawnInfo.spawnTileX > Main.maxTilesX - 250) && !spawnInfo.playerSafe ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/DragonMini.cs b/NPCs/DragonMini.cs index c439a48d..cdc7863d 100644 --- a/NPCs/DragonMini.cs +++ b/NPCs/DragonMini.cs @@ -1,12 +1,12 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + namespace Tremor.NPCs { - public class DragonMini : ModNPC { public override void SetStaticDefaults() @@ -35,7 +35,7 @@ public override void SetDefaults() public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { if (Main.expertMode) - target.AddBuff(156, 180); + target.AddBuff(BuffID.Stoned, 180); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/NPCs/DragonSkull.cs b/NPCs/DragonSkull.cs index e9f6a87a..2933fcd0 100644 --- a/NPCs/DragonSkull.cs +++ b/NPCs/DragonSkull.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { @@ -14,7 +17,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - public override void SetDefaults() { npc.lifeMax = 900; @@ -35,20 +37,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("DragonSkullBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType(), Main.rand.Next(30, 40)); } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.03f : 0; - } public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -68,7 +62,7 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -76,21 +70,8 @@ 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("DragonBreath"), Main.rand.Next(30, 40)); - } - } - } - + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.03f : 0; } } \ No newline at end of file diff --git a/NPCs/Dranix.cs b/NPCs/Dranix.cs index f0be33e6..0215168a 100644 --- a/NPCs/Dranix.cs +++ b/NPCs/Dranix.cs @@ -1,11 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Tremor.Items; + namespace Tremor.NPCs { - public class Dranix : ModNPC { public override void SetStaticDefaults() @@ -14,7 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 10; } - public override void SetDefaults() { npc.lifeMax = 1600; @@ -36,31 +35,14 @@ public override void SetDefaults() public override void AI() { - if (Main.rand.Next(1000) == 0) - { Main.PlaySound(22, (int)npc.position.X, (int)npc.position.Y, 1); - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; } 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Doomstone")); - } - } + if (Main.rand.Next(2) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -68,9 +50,8 @@ 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, 74, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Dust.NewDust(npc.position, npc.width, npc.height, 74, 2.5f * hitDirection, -2.5f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DranixGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DranixGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DranixGore2"), 1f); @@ -81,11 +62,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.04f : 0f; - } + => Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.04f : 0f; } } \ No newline at end of file diff --git a/NPCs/DreadBeetle.cs b/NPCs/DreadBeetle.cs index 7267ac36..6c2538d4 100644 --- a/NPCs/DreadBeetle.cs +++ b/NPCs/DreadBeetle.cs @@ -2,9 +2,10 @@ using Terraria.ID; using Terraria.ModLoader; +using Tremor.Items; + namespace Tremor.NPCs { - public class DreadBeetle : ModNPC { public override void SetStaticDefaults() @@ -33,41 +34,20 @@ public override void SetDefaults() bannerItem = mod.ItemType("DreadBeetleBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Doomstone")); - } - } + if (Main.rand.Next(2) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DreadGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DreadGore2"), 1f); - } + for(int i = 0; i < 2; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/DreadGore{i+1}"), 1f); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.04f : 0f; - } + => Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.04f : 0f; } } \ No newline at end of file diff --git a/NPCs/DungeonKeeper.cs b/NPCs/DungeonKeeper.cs index aad62ad4..48c0b097 100644 --- a/NPCs/DungeonKeeper.cs +++ b/NPCs/DungeonKeeper.cs @@ -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 DungeonKeeper : ModNPC { public override void SetStaticDefaults() @@ -33,20 +33,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("DungeonKeeperBanner"); } - 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/KeeperGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/KeeperGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/KeeperGore2"), 1f); @@ -56,24 +49,12 @@ 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(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ShadowReaper")); - } - } + // No ShadowReaper class in Tremor namespace. + //if (Main.rand.Next(25) == 0) + // Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType()); } 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.player.ZoneDungeon && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/ElderObserver.cs b/NPCs/ElderObserver.cs index 1eec33fc..6d259944 100644 --- a/NPCs/ElderObserver.cs +++ b/NPCs/ElderObserver.cs @@ -1,9 +1,13 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { @@ -15,13 +19,13 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - const int ShootRate = 220; // - const int ShootDamage = 20; // . - const float ShootKN = 1.0f; // - const int ShootType = 100; // . - const float ShootSpeed = 4; // , , + const int ShootRate = 220; + const int ShootDamage = 20; + const float ShootKN = 1.0f; + const int ShootType = 100; + const float ShootSpeed = 4; - int TimeToShoot = ShootRate; // . + int TimeToShoot = 0; public override void SetDefaults() { @@ -41,28 +45,25 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 55, 9); banner = npc.type; bannerItem = mod.ItemType("ElderObserverBanner"); - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + TimeToShoot = 0; } public override void AI() { - // - if (--TimeToShoot <= 0 && npc.target != -1) Shoot(); // TimeToShot 1, TimeToShot < = 0, Shoot() + if (Main.netMode != 1 && TimeToShoot++ >= ShootRate && npc.target != -1) + { + Shoot(); + TimeToShoot = 0; + } } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) + void Shoot() { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && Main.expertMode && Main.bloodMoon && y < Main.worldSurface ? 0.002f : 0f; + Vector2 velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ShootSpeed; + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, ShootDamage, ShootKN); } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -77,14 +78,12 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ElderObserverGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ElderObserverGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ElderObserverGore3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ElderObserverGore4"), 1f); + for(int i = 0; i < 4; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/ElderObserverGore{i+1}"), 1f); } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -95,36 +94,13 @@ 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(10) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Spearaxe")); - } - if (Main.rand.Next(10) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ScarredReaper")); - }; - } + if (Main.rand.Next(10) == 0) + npc.NewItem(mod.ItemType()); + if (Main.rand.Next(10) == 0) + npc.NewItem(mod.ItemType()); } - void Shoot() - { - TimeToShoot = ShootRate; // - Vector2 velocity = VelocityFPTP(npc.Center, Main.player[npc.target].Center, ShootSpeed); // velocity ( ) - // 1 - - // 2 - - // 3 - - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, ShootDamage, ShootKN); - } - - Vector2 VelocityFPTP(Vector2 pos1, Vector2 pos2, float speed) - { - Vector2 move = pos2 - pos1; - return move * (speed / (float)Math.Sqrt(move.X * move.X + move.Y * move.Y)); - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && Main.expertMode && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.002f : 0f; } } \ No newline at end of file diff --git a/NPCs/Elf.cs b/NPCs/Elf.cs index 24e36432..ee01ef8d 100644 --- a/NPCs/Elf.cs +++ b/NPCs/Elf.cs @@ -1,7 +1,11 @@ +using System.Linq; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Tremor.Items; + namespace Tremor.NPCs { [AutoloadHead] @@ -46,67 +50,37 @@ public override void SetDefaults() } public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - for (int k = 0; k < 255; k++) - { - Player player = Main.player[k]; - if (player.active) - { - for (int j = 0; j < player.inventory.Length; j++) - { - if (player.inventory[j].type == mod.ItemType("SuspiciousLookingPresent")) - { - return true; - } - } - } - } - return false; - } - + => Main.player.Any(player => player.active && player.inventory.Any(item => item != null && item.type == mod.ItemType("SuspiciousLookingPresent"))); public override string TownNPCName() { - switch (WorldGen.genRand.Next(4)) + string[] names = { - case 0: - return "Nick"; - case 1: - return "Elfie"; - case 2: - return "Jingle"; - case 3: - return "Chippy"; - case 4: - return "Sparkle"; - case 5: - return "Twinkle"; - case 6: - return "Elvis"; - case 7: - return "Peppermint"; - default: - return "Snowflake"; - } + "Nick", + "Elfie", + "Jingle", + "Chippy", + "Sparkle", + "Twinkle", + "Elvis", + "Peppermint", + "Snowflake" + }; + return names.TakeRandom(); } public override string GetChat() { - switch (Main.rand.Next(6)) + string[] chats = { - case 0: - return "What do you know about reindeers?"; - case 1: - return "I can give you some presents but... You've been naughty this year."; - case 2: - return "I am Santa's favorite elf!"; - case 3: - return "Jingle bells, jingle bells, jingle all the way!"; - case 4: - return "Someone threw a snowball at me. I don't know who did it but I will find him and throw a snowball at him too."; - default: - return "I licked an icicle one fine day. It resulted in not much fun."; - } + "What do you know about reindeers?", + "I could give you some presents, but... You've been naughty this year.", + "I am Santa's favorite elf!", + "Jingle bells, jingle bells, jingle all the way!", + "Someone threw a snowball at me. I don't know who did it but I will find him and throw a snowball at him too.", + "I licked an icicle one fine day. It resulted in not a lot of pain." + }; + return chats.TakeRandom(); } public override void SetChatButtons(ref string button, ref string button2) @@ -116,39 +90,25 @@ 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("RedChristmasStocking")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("BlueChristmasStocking")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("GreenChristmasStocking")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("CandyCane")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (NPC.downedBoss1) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("SnowShotgun")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("CandyBow")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (NPC.downedBoss3) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("TheSnowBall")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (Main.hardMode) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("Blizzard")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } public override void TownNPCAttackStrength(ref int damage, ref float knockback) diff --git a/NPCs/EliteBloodmoonWarrior.cs b/NPCs/EliteBloodmoonWarrior.cs index bd8609da..7ed957e7 100644 --- a/NPCs/EliteBloodmoonWarrior.cs +++ b/NPCs/EliteBloodmoonWarrior.cs @@ -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 EliteBloodmoonWarrior : ModNPC { public override void SetStaticDefaults() @@ -14,7 +16,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 20; } - public override void SetDefaults() { npc.lifeMax = 1750; @@ -33,24 +34,10 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("EliteBloodmoonWarriorBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("SkullTeeth")); - }; - } + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -58,9 +45,8 @@ 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/EliteGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EliteGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EliteGore2"), 1f); @@ -70,11 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMechBossAny && Main.bloodMoon && y < Main.worldSurface ? 0.03f : 0f; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMechBossAny && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.03f : 0f; } } \ No newline at end of file diff --git a/NPCs/EnragedBat.cs b/NPCs/EnragedBat.cs index 8a412c3d..6b020053 100644 --- a/NPCs/EnragedBat.cs +++ b/NPCs/EnragedBat.cs @@ -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 EnragedBat : ModNPC { public override void SetStaticDefaults() @@ -14,7 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - public override void SetDefaults() { npc.lifeMax = 1000; @@ -34,20 +33,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("EnragedBatBanner"); } - 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, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EnragedGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EnragedGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EnragedGore2"), 1f); @@ -55,11 +47,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.1f : 0f; - } + => Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/EvolvedZombie.cs b/NPCs/EvolvedZombie.cs index fb7da93d..4ca188a8 100644 --- a/NPCs/EvolvedZombie.cs +++ b/NPCs/EvolvedZombie.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { @@ -33,10 +36,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("EvolvedZombieBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool(2)) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -44,9 +47,8 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore2"), 1f); @@ -58,25 +60,9 @@ 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ConcentratedEther")); - }; - } - } public override float SpawnChance(NPCSpawnInfo spawnInfo) { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.03f : 0f; + return Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.03f : 0f; } } } \ No newline at end of file diff --git a/NPCs/EvolvedZombie2.cs b/NPCs/EvolvedZombie2.cs index 269e29af..cccd67ed 100644 --- a/NPCs/EvolvedZombie2.cs +++ b/NPCs/EvolvedZombie2.cs @@ -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 EvolvedZombie2 : ModNPC { public override void SetStaticDefaults() @@ -33,10 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("EvolvedZombieBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool(2)) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -44,9 +46,8 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore2"), 1f); @@ -57,26 +58,8 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, Color.White, 3f); } } - - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ConcentratedEther")); - }; - } - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.03f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.03f : 0f; } } \ No newline at end of file diff --git a/NPCs/EvolvedZombie3.cs b/NPCs/EvolvedZombie3.cs index d3fae8e9..c2da7dae 100644 --- a/NPCs/EvolvedZombie3.cs +++ b/NPCs/EvolvedZombie3.cs @@ -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 EvolvedZombie3 : ModNPC { public override void SetStaticDefaults() @@ -33,10 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("EvolvedZombieBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool(2)) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -44,9 +46,8 @@ 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, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/EvolvGore2"), 1f); @@ -57,26 +58,8 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, Color.White, 3f); } } - - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ConcentratedEther")); - }; - } - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.03f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.03f : 0f; } } \ No newline at end of file diff --git a/NPCs/ExuberantHound.cs b/NPCs/ExuberantHound.cs index e1bea17e..8f912602 100644 --- a/NPCs/ExuberantHound.cs +++ b/NPCs/ExuberantHound.cs @@ -1,12 +1,13 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { - public class ExuberantHound : ModNPC { public override void SetStaticDefaults() @@ -33,125 +34,115 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("ExuberantHoundBanner"); } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - for (int k = 0; k < 60; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore3"), 1f); - } - else - { - - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 226, hitDirection, -2f, 0, default(Color), 0.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 27, hitDirection, -1f, 0, default(Color), 0.7f); - } - } - } - - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ConcentratedEther"), Main.rand.Next(2, 4)); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ToothofAbraxas"), Main.rand.Next(1, 2)); - }; - } - } + /* + * + * + * + */ public override void AI() { - Vector2 vector72 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num738 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector72.X; - float num739 = Main.player[npc.target].position.Y - vector72.Y; - float num740 = (float)Math.Sqrt(num738 * num738 + num739 * num739); + Vector2 npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float targetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - npcCenter.X; + float targetY = Main.player[npc.target].position.Y - npcCenter.Y; + float targetLength = (float)Math.Sqrt(targetX * targetX + targetY * targetY); if (npc.ai[2] == 1f) { - npc.ai[1] += 1f; + npc.ai[1]++; npc.velocity.X = npc.velocity.X * 0.7f; if (npc.ai[1] < 30f) { - Vector2 vector73 = npc.Center + Vector2.UnitX * npc.spriteDirection * -20f; - Dust dust11 = Main.dust[Dust.NewDust(vector73, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; - Vector2 vector74 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); - dust11.position = vector73 + vector74 * 20f; - dust11.velocity = -vector74 * 2f; - dust11.scale = 0.5f + vector74.X * -(float)npc.spriteDirection; - dust11.fadeIn = 1f; - dust11.noGravity = true; + Vector2 newDustLocation = npc.Center + Vector2.UnitX * npc.spriteDirection * -20f; + Dust newDust = Main.dust[Dust.NewDust(newDustLocation, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; + Vector2 randomDirection = Vector2.UnitY.RotatedByRandom(Math.PI * 2); + newDust.position = newDustLocation + randomDirection * 20f; + newDust.velocity = -randomDirection * 2f; + newDust.scale = 0.5f + randomDirection.X * -npc.spriteDirection; + newDust.fadeIn = 1f; + newDust.noGravity = true; } else if (npc.ai[1] == 30f) { - for (int num743 = 0; num743 < 20; num743++) + for (int i = 0; i < 20; i++) { - Vector2 vector75 = npc.Center + Vector2.UnitX * npc.spriteDirection * -20f; - Dust dust12 = Main.dust[Dust.NewDust(vector75, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; - Vector2 vector76 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); - dust12.position = vector75 + vector76 * 4f; - dust12.velocity = vector76 * 4f + Vector2.UnitX * Main.rand.NextFloat() * npc.spriteDirection * -5f; - dust12.scale = 0.5f + vector76.X * -(float)npc.spriteDirection; - dust12.fadeIn = 1f; - dust12.noGravity = true; + Vector2 newDustLocation = npc.Center + Vector2.UnitX * npc.spriteDirection * -20f; + Dust newDust = Main.dust[Dust.NewDust(newDustLocation, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; + Vector2 randomDirection = Vector2.UnitY.RotatedByRandom(Math.PI * 2); + newDust.position = newDustLocation + randomDirection * 4f; + newDust.velocity = randomDirection * 4f + Vector2.UnitX * Main.rand.NextFloat() * npc.spriteDirection * -5f; + newDust.scale = 0.5f + randomDirection.X * -npc.spriteDirection; + newDust.fadeIn = 1f; + newDust.noGravity = true; } } + if (npc.velocity.X > -0.5f && npc.velocity.X < 0.5f) - { npc.velocity.X = 0f; - } + if (npc.ai[1] == 30f && Main.netMode != 1) { - int num744 = Main.expertMode ? 35 : 50; - Projectile.NewProjectile(npc.Center.X + npc.spriteDirection * -20, npc.Center.Y, npc.spriteDirection * -7, 0f, 435, num744, 0f, Main.myPlayer, npc.target, 0f); + int projectileDamage = Main.expertMode ? 35 : 50; + Projectile.NewProjectile(npc.Center.X + npc.spriteDirection * -20, npc.Center.Y, npc.spriteDirection * -7, 0f, ProjectileID.MartianTurretBolt, projectileDamage, 0f, Main.myPlayer, npc.target, 0f); } + if (npc.ai[1] >= 60f) { - npc.ai[1] = -(float)Main.rand.Next(320, 601); + npc.ai[1] = -Main.rand.Next(320, 601); npc.ai[2] = 0f; } } else { - npc.ai[1] += 1f; - if (npc.ai[1] >= 180f && num740 < 500f && npc.velocity.Y == 0f) + npc.ai[1]++; + if (npc.ai[1] >= 180f && targetLength < 500f && npc.velocity.Y == 0f) { npc.ai[1] = 0f; npc.ai[2] = 1f; npc.netUpdate = true; } - else if (npc.velocity.Y == 0f && num740 < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) + else if (npc.velocity.Y == 0f && targetLength < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) { npc.velocity.Y = npc.velocity.Y - 4f; } } } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void NPCLoot() { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.001f : 0f; + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType("ConcentratedEther"), Main.rand.Next(2, 4)); + if (Main.rand.Next(5) == 0) + npc.NewItem(mod.ItemType("ToothofAbraxas"), Main.rand.Next(1, 3)); + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + for (int k = 0; k < 60; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ExuberantHoundGore3"), 1f); + } + else + { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 226, hitDirection, -2f, 0, default(Color), 0.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 27, hitDirection, -1f, 0, default(Color), 0.7f); + } + } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.001f : 0f; } } \ No newline at end of file diff --git a/NPCs/FallenWarrior1.cs b/NPCs/FallenWarrior1.cs index 6b067149..23486f07 100644 --- a/NPCs/FallenWarrior1.cs +++ b/NPCs/FallenWarrior1.cs @@ -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 FallenWarrior1 : ModNPC { public override void SetStaticDefaults() @@ -33,24 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("FallenWarriorBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("AncientArmorPlate")); - } - } + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -58,9 +46,8 @@ 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FWGore1"), 1f); @@ -69,11 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } 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.player.ZoneDungeon && NPC.downedMoonlord && Main.hardMode && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDungeon && NPC.downedMoonlord && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/FallenWarrior2.cs b/NPCs/FallenWarrior2.cs index 728ebdd7..6d38a510 100644 --- a/NPCs/FallenWarrior2.cs +++ b/NPCs/FallenWarrior2.cs @@ -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 FallenWarrior2 : ModNPC { public override void SetStaticDefaults() @@ -33,24 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("FallenWarriorBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("AncientArmorPlate")); - } - } + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -58,9 +46,8 @@ 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FWGore1"), 1f); @@ -69,11 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } 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.player.ZoneDungeon && NPC.downedMoonlord && Main.hardMode && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDungeon && NPC.downedMoonlord && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/FallenWarrior3.cs b/NPCs/FallenWarrior3.cs index aab35850..10970e68 100644 --- a/NPCs/FallenWarrior3.cs +++ b/NPCs/FallenWarrior3.cs @@ -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 FallenWarrior3 : ModNPC { public override void SetStaticDefaults() @@ -33,24 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("FallenWarriorBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("AncientArmorPlate")); - } - } + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -58,9 +46,8 @@ 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FWGore1"), 1f); @@ -69,11 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } 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.player.ZoneDungeon && NPC.downedMoonlord && Main.hardMode && y > Main.rockLayer ? 0.01f : 0f; - } + => (Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneDungeon && NPC.downedMoonlord && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Farmer.cs b/NPCs/Farmer.cs index 63d93061..faf2e5eb 100644 --- a/NPCs/Farmer.cs +++ b/NPCs/Farmer.cs @@ -1,8 +1,14 @@ -using Microsoft.Xna.Framework; +using System.Linq; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; +using Tremor.Projectiles; + namespace Tremor.NPCs { [AutoloadHead] @@ -47,63 +53,35 @@ public override void SetDefaults() } public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - for (int k = 0; k < 255; k++) - { - Player player = Main.player[k]; - if (player.active) - { - for (int j = 0; j < player.inventory.Length; j++) - { - if (player.inventory[j].type == mod.ItemType("FarmerShovel")) - { - return true; - } - } - } - } - return false; - } - + => Main.player.Any(player => player.active && player.inventory.Any(item => item != null && item.type == mod.ItemType("FarmerShovel"))); public override string TownNPCName() { - switch (WorldGen.genRand.Next(4)) + string[] names = { - case 0: - return "Trillian"; - case 1: - return "Penelope"; - case 2: - return "Emily"; - case 3: - return "Abigail"; - case 4: - return "Alma"; - case 5: - return "Alexandra"; - default: - return "Peg"; - } + "Trillian", + "Penelope", + "Emily", + "Abigail", + "Alma", + "Alexandra", + "Peg" + }; + return names.TakeRandom(); } public override string GetChat() { - switch (Main.rand.Next(6)) + string[] chats = { - case 0: - return "I wonder who had the idea of growing such an evil corn? Don't look at me like this, I have nothing to do with."; - case 1: - return "There are so many wonderful and amazing plants in this world but there is nothing more amazing like a corn!"; - case 2: - return "Uh... Oh... Did you came to buy a corn? I'm afraid that it can become evil too."; - case 3: - return "Don't use chemicals on your plants! Chemicals make them being evil and crazy!"; - case 4: - return "Don't you dare to offer me to eat popcorn! After those bad events I just can't eat anything that contains corn!"; - default: - return "Take some water... Add ebonkoi... Wallow some deathweed dust... Mix everything... Oh! Hello! Want to buy something?"; - } + "I wonder who had the idea of growing such an evil corn? Don't look at me like this, I have nothing to do with.", + "There are so many wonderful and amazing plants in this world but there is nothing more amazing like a corn!", + "Uh... Oh... Did you came to buy a corn? I'm afraid that it can become evil too.", + "Don't use chemicals on your plants! Chemicals make them being evil and crazy!", + "Don't you dare to offer me to eat popcorn! After those bad events I just can't eat anything that contains corn!", + "Take some water... Add ebonkoi... Wallow some deathweed dust... Mix everything... Oh! Hello! Want to buy something?" + }; + return chats.TakeRandom(); } public override void SetChatButtons(ref string button, ref string button2) @@ -113,61 +91,38 @@ 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("CornSeed")); - //nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (!NPC.downedBoss1) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("Pitchfork")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (Main.dayTime) - { - shop.item[nextSlot].SetDefaults(307); - nextSlot++; - } - if (!Main.dayTime) - { - shop.item[nextSlot].SetDefaults(308); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, ItemID.DaybloomSeeds); + else + shop.AddUniqueItem(ref nextSlot, ItemID.MoonglowSeeds); + if (NPC.downedSlimeKing) - { - shop.item[nextSlot].SetDefaults(311); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, ItemID.WaterleafSeeds); if (NPC.downedBoss2) { - shop.item[nextSlot].SetDefaults(309); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("EggPlant")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, ItemID.BlinkrootSeeds); + // Eggplant doesn't exist in Tremor namespace. + //shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } if (Main.hardMode) - { - shop.item[nextSlot].SetDefaults(312); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, ItemID.FireblossomSeeds); - if (Main.player[Main.myPlayer].HasItem(mod.ItemType("Carrow"))) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("Carrot"), false); - nextSlot++; - } + if (Main.LocalPlayer.HasItem(mod.ItemType())) + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); if (Main.bloodMoon) - { - shop.item[nextSlot].SetDefaults(310); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, ItemID.DeathweedSeeds); } public override void TownNPCAttackStrength(ref int damage, ref float knockback) @@ -184,7 +139,7 @@ public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCo public override void TownNPCAttackProj(ref int projType, ref int attackDelay) { - projType = mod.ProjectileType("TomatoPro"); + projType = mod.ProjectileType(); attackDelay = 4; } @@ -194,18 +149,15 @@ public override void TownNPCAttackProjSpeed(ref float multiplier, ref float grav randomOffset = 2f; } - 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/FarmerGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FarmerGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FarmerGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/FarmerGore{i+1}"), 1f); } } } diff --git a/NPCs/FatFlinx.cs b/NPCs/FatFlinx.cs index 1735931e..7598d9cc 100644 --- a/NPCs/FatFlinx.cs +++ b/NPCs/FatFlinx.cs @@ -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 FatFlinx : ModNPC { public override void SetStaticDefaults() @@ -31,24 +33,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 9, 15); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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 (NPC.downedMoonlord && Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("IceSoul")); - } - } + if (NPC.downedMoonlord && Main.rand.Next(5) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -60,6 +48,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FFGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FFGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FFGore1"), 1f); @@ -71,12 +60,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && NPC.downedMoonlord && spawnInfo.player.ZoneSnow && y > Main.rockLayer ? 0.1f : 0f; - } - + => Main.hardMode && NPC.downedMoonlord && spawnInfo.player.ZoneSnow && spawnInfo.spawnTileY > Main.rockLayer ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/FireBeetle.cs b/NPCs/FireBeetle.cs index 8ca7c443..969fea3c 100644 --- a/NPCs/FireBeetle.cs +++ b/NPCs/FireBeetle.cs @@ -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 FireBeetle : ModNPC { public override void SetStaticDefaults() @@ -37,28 +39,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("FireBeetleBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 175, 3); - } - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FireFragment"), 3); - } - } + if (Main.rand.Next(2) == 0) + npc.NewItem(ItemID.HellstoneBar, 3); + if (Main.rand.Next(2) == 0) + npc.NewItem(mod.ItemType(), 3); } public override void HitEffect(int hitDirection, double damage) @@ -73,6 +59,7 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FBGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FBGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FBGore2"), 1f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -82,11 +69,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && NPC.downedMoonlord && Helper.NoZoneAllowWater(spawnInfo)) && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && NPC.downedMoonlord && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/FlamingReaper.cs b/NPCs/FlamingReaper.cs index b4408638..eb503fb5 100644 --- a/NPCs/FlamingReaper.cs +++ b/NPCs/FlamingReaper.cs @@ -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 FlamingReaper : ModNPC { public override void SetStaticDefaults() @@ -30,22 +30,13 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 9); } - 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, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } } - } } \ No newline at end of file diff --git a/NPCs/Flayer.cs b/NPCs/Flayer.cs index 3c506abd..8af3a79b 100644 --- a/NPCs/Flayer.cs +++ b/NPCs/Flayer.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class Flayer : ModNPC @@ -32,20 +33,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("FlayerBanner"); } - 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/FlayerGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FlayerGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FlayerGore4"), 1f); @@ -56,12 +50,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedPlantBoss && Main.bloodMoon && y < Main.worldSurface ? 0.01f : 0f; - } - + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedPlantBoss && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } diff --git a/NPCs/FlyingJelly.cs b/NPCs/FlyingJelly.cs index f859291d..b77a2b8b 100644 --- a/NPCs/FlyingJelly.cs +++ b/NPCs/FlyingJelly.cs @@ -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 FlyingJelly : ModNPC { public override void SetStaticDefaults() @@ -14,7 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 6; } - public override void SetDefaults() { npc.width = 30; @@ -44,20 +43,12 @@ public override void HitEffect(int hitDirection, double damage) } else { - - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 226, hitDirection, -2f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 27, hitDirection, -1f, 0, default(Color), 0.7f); } } } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - } } \ No newline at end of file diff --git a/NPCs/FlyingLeech.cs b/NPCs/FlyingLeech.cs index a139b6ed..d5a815be 100644 --- a/NPCs/FlyingLeech.cs +++ b/NPCs/FlyingLeech.cs @@ -4,7 +4,6 @@ namespace Tremor.NPCs { - public class FlyingLeech : ModNPC { public override void SetStaticDefaults() @@ -32,18 +31,7 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("FlyingLeechBanner"); } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedBoss2 && spawnInfo.player.ZoneCrimson && y < Main.worldSurface ? 0.02f : 0; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss2 && spawnInfo.player.ZoneCrimson && spawnInfo.spawnTileY < Main.worldSurface ? 0.02f : 0; } } \ No newline at end of file diff --git a/NPCs/ForestSpirit.cs b/NPCs/ForestSpirit.cs index da906880..d4ae3bf7 100644 --- a/NPCs/ForestSpirit.cs +++ b/NPCs/ForestSpirit.cs @@ -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 ForestSpirit : ModNPC { public override void SetStaticDefaults() @@ -34,30 +34,14 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("ForestSpiritBanner"); } - 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); - - } - } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedBoss2 && !Main.dayTime && y < Main.worldSurface ? 0.1f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss2 && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.1f : 0f; } } diff --git a/NPCs/ForgeMaster.cs b/NPCs/ForgeMaster.cs index de125551..79750baa 100644 --- a/NPCs/ForgeMaster.cs +++ b/NPCs/ForgeMaster.cs @@ -1,8 +1,14 @@ -using Microsoft.Xna.Framework; +using System.Linq; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; +using Tremor.Projectiles; + namespace Tremor.NPCs { [AutoloadHead] @@ -30,7 +36,6 @@ public override void SetStaticDefaults() NPCID.Sets.AttackAverageChance[npc.type] = 30; } - public override void SetDefaults() { npc.townNPC = true; @@ -46,64 +51,37 @@ public override void SetDefaults() npc.knockBackResist = 0.5f; animationType = NPCID.Guide; } - + public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - for (int k = 0; k < 255; k++) - { - Player player = Main.player[k]; - if (player.active) - { - for (int j = 0; j < player.inventory.Length; j++) - { - if (player.inventory[j].type == mod.ItemType("JungleAlloy")) - { - return true; - } - } - } - } - return false; - } - + => Main.player.Any(player => player.active && player.inventory.Any(item => item != null && item.type == mod.ItemType("JungleAlloy"))); + public override string TownNPCName() { - switch (WorldGen.genRand.Next(5)) - { - case 0: - return "Gefest"; - case 1: - return "Aule"; - case 2: - return "Agarorn"; - case 3: - return "Treak"; - case 4: - return "Haymer"; - default: - return "Golan"; - } + string[] names = + { + "Gefest", + "Aule", + "Agarorn", + "Treak", + "Haymer", + "Golan" + }; + return names.TakeRandom(); } public override string GetChat() { - switch (Main.rand.Next(6)) - { - case 0: - return "You can't lift my hammer? Not surprising! That's because you are not worthy!"; - case 1: - return "Strangely but nobody uses hammers for making bars. How do you just put ore into furnaces and get bars!? That is insane!"; - case 2: - return "Valar Morghulis! Oh wait, that's not the Braavos! Forget what I've said."; - case 3: - return "What? You ask me who am I?! I am the son of the Vulcan and the Vulcan is the mighty anvilborn!"; - case 4: - return "My bars are better because I make them with my hammer. If you won't buy my bars I will make a bar from you."; - case 5: - return "You wonder why people call me Forge Master!? What means you don't believe I'm the real Master of Forges!?"; - default: - return "Be careful when working with forges. I got burnt once when I was taking off a bar from it. That's why I'm wearing such armor!"; - } + string[] chats = + { + "You can't lift my hammer? Not surprising! That's because you are not worthy!", + "Strangely but nobody uses hammers for making bars. How do you just put ore into furnaces and get bars!? That is insane!", + "Valar Morghulis! Oh wait, that's not the Braavos! Forget what I've said.", + "What? You ask me who am I?! I am the son of the Vulcan and the Vulcan is the mighty anvilborn!", + "My bars are better because I make them with my hammer. If you won't buy my bars I will make a bar from you.", + "You wonder why people call me Forge Master!? What means you don't believe I'm the real Master of Forges!?", + "Be careful when working with forges. I got burnt once when I was taking off a bar from it. That's why I'm wearing such armor!" + }; + return chats.TakeRandom(); } public override void SetChatButtons(ref string button, ref string button2) @@ -113,112 +91,68 @@ 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("GreatAnvil")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType("GreatAnvil")); + if (Main.dayTime) { - shop.item[nextSlot].SetDefaults(ItemID.CopperBar); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.IronBar); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.SilverBar); - nextSlot++; - } - if (!Main.dayTime) - { - shop.item[nextSlot].SetDefaults(ItemID.TinBar); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.LeadBar); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.TungstenBar); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, ItemID.CopperBar); + shop.AddUniqueItem(ref nextSlot, ItemID.IronBar); + shop.AddUniqueItem(ref nextSlot, ItemID.SilverBar); - if (NPC.downedBoss2 && Main.dayTime) - { - shop.item[nextSlot].SetDefaults(ItemID.GoldBar); - nextSlot++; - } - if (NPC.downedBoss2 && !Main.dayTime) - { - shop.item[nextSlot].SetDefaults(ItemID.PlatinumBar); - nextSlot++; - } - if (NPC.downedBoss2) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("PoisonRod")); - nextSlot++; - } + if (NPC.downedBoss2) + shop.AddUniqueItem(ref nextSlot, ItemID.GoldBar); + if (NPC.downedBoss3) + shop.AddUniqueItem(ref nextSlot, ItemID.DemoniteBar); - if (NPC.downedBoss3 && Main.dayTime) - { - shop.item[nextSlot].SetDefaults(ItemID.DemoniteBar); - nextSlot++; + if (NPC.downedMechBossAny) + { + shop.AddUniqueItem(ref nextSlot, ItemID.CobaltBar); + shop.AddUniqueItem(ref nextSlot, ItemID.MythrilBar); + shop.AddUniqueItem(ref nextSlot, ItemID.AdamantiteBar); + } } - if (NPC.downedBoss3 && !Main.dayTime) + else { - shop.item[nextSlot].SetDefaults(ItemID.CrimtaneBar); - nextSlot++; - } - if (NPC.downedBoss3) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("BurningHammer")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("PerfectBehemoth")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, ItemID.TinBar); + shop.AddUniqueItem(ref nextSlot, ItemID.LeadBar); + shop.AddUniqueItem(ref nextSlot, ItemID.TungstenBar); - if (Main.hardMode) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("GoldenMace")); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.HellstoneBar); - nextSlot++; - } + if (NPC.downedBoss2) + shop.AddUniqueItem(ref nextSlot, ItemID.PlatinumBar); + if (NPC.downedBoss3) + shop.AddUniqueItem(ref nextSlot, ItemID.CrimtaneBar); - if (NPC.downedMechBossAny && Main.dayTime) - { - shop.item[nextSlot].SetDefaults(ItemID.CobaltBar); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.MythrilBar); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.AdamantiteBar); - nextSlot++; - } - if (NPC.downedMechBossAny && !Main.dayTime) - { - shop.item[nextSlot].SetDefaults(ItemID.PalladiumBar); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.OrichalcumBar); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.TitaniumBar); - nextSlot++; + if (NPC.downedMechBossAny) + { + shop.AddUniqueItem(ref nextSlot, ItemID.PalladiumBar); + shop.AddUniqueItem(ref nextSlot, ItemID.OrichalcumBar); + shop.AddUniqueItem(ref nextSlot, ItemID.TitaniumBar); + } } - if (NPC.downedPlantBoss) + if (NPC.downedBoss2) + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (NPC.downedBoss3) { - shop.item[nextSlot].SetDefaults(ItemID.HallowedBar); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } - + if (NPC.downedPlantBoss) + shop.AddUniqueItem(ref nextSlot, ItemID.HallowedBar); if (NPC.downedGolemBoss) - { - shop.item[nextSlot].SetDefaults(ItemID.ChlorophyteBar); - nextSlot++; - } - + shop.AddUniqueItem(ref nextSlot, ItemID.ChlorophyteBar); if (NPC.downedAncientCultist) + shop.AddUniqueItem(ref nextSlot, ItemID.SpectreBar); + + if (Main.hardMode) { - shop.item[nextSlot].SetDefaults(ItemID.SpectreBar); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, ItemID.HellstoneBar); } } @@ -236,31 +170,26 @@ public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCo public override void TownNPCAttackProj(ref int projType, ref int attackDelay) { - projType = mod.ProjectileType("BurningHammerPro"); + projType = mod.ProjectileType(); attackDelay = 4; } + public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) + { + multiplier = 12f; + randomOffset = 2f; + } + 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/BlackSmithGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/BlackSmithGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/BlackSmithGore3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/BlackSmithGore4"), 1f); + for (int i = 0; i < 4; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/BlackSmithGore{i + 1}"), 1f); } } - - - public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) - { - multiplier = 12f; - randomOffset = 2f; - } } } \ No newline at end of file diff --git a/NPCs/FrostBeetle.cs b/NPCs/FrostBeetle.cs index 41d8fb6c..3af0535b 100644 --- a/NPCs/FrostBeetle.cs +++ b/NPCs/FrostBeetle.cs @@ -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 FrostBeetle : ModNPC { public override void SetStaticDefaults() @@ -37,36 +39,16 @@ public override void SetDefaults() bannerItem = mod.ItemType("FrostBeetleBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 593, 3); - } - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 664, 3); - } - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FrostCore"), 3); - } - if (NPC.downedMoonlord && Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("IceSoul")); - } - } + if (Main.rand.NextBool(2)) + npc.NewItem(ItemID.SnowBlock, 3); + if (Main.rand.NextBool(2)) + npc.NewItem(ItemID.IceBlock, 3); + if (Main.rand.NextBool(2)) + npc.NewItem(mod.ItemType(), 3); + if (NPC.downedMoonlord && Main.rand.Next(5) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -90,11 +72,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && NPC.downedMoonlord && spawnInfo.player.ZoneSnow && y > Main.rockLayer ? 0.01f : 0f; - } + => Main.hardMode && NPC.downedMoonlord && spawnInfo.player.ZoneSnow && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/GGiantSlime.cs b/NPCs/GGiantSlime.cs index 27b79e83..5e83bd11 100644 --- a/NPCs/GGiantSlime.cs +++ b/NPCs/GGiantSlime.cs @@ -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 GGiantSlime : ModNPC { public override void SetStaticDefaults() @@ -33,10 +33,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 12, 15); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool()) + npc.NewItem(ItemID.Gel); } public override void HitEffect(int hitDirection, double damage) @@ -56,23 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && Main.hardMode && Helper.NoInvasion(spawnInfo) && NPC.downedMoonlord && Main.dayTime ? 0.02f : 0f; - } - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 23); - }; - } - } - + => spawnInfo.spawnTileY < Main.rockLayer && Main.hardMode && Helper.NoInvasion(spawnInfo) && NPC.downedMoonlord && Main.dayTime ? 0.02f : 0f; } } \ No newline at end of file diff --git a/NPCs/Galasquid.cs b/NPCs/Galasquid.cs index 7d1b754d..a9e09eb3 100644 --- a/NPCs/Galasquid.cs +++ b/NPCs/Galasquid.cs @@ -1,9 +1,13 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class Galasquid : ModNPC @@ -14,18 +18,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 5; } - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GalasquidGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GalasquidGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GalasquidGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GalasquidGore2"), 1f); - } - } - public override void SetDefaults() { npc.aiStyle = -1; @@ -47,7 +39,6 @@ public override void SetDefaults() npc.npcSlots = 10f; } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.625f * bossLifeScale); @@ -56,68 +47,63 @@ public override void ScaleExpertStats(int numPlayers, float bossLifeScale) public override void AI() { - float num1971 = 5f; - float moveSpeed = 0.15f; npc.TargetClosest(true); - Vector2 desiredVelocity4 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, -250f); - float num1972 = desiredVelocity4.Length(); - if (num1972 < 20f) - { - desiredVelocity4 = npc.velocity; - } - else if (num1972 < 40f) + + float moveSpeed = 5f; + + Vector2 targetVelocity = Main.player[npc.target].Center - npc.Center; + float velocityLength = targetVelocity.Length(); + + // Depending on the distance between this NPC and its target player, we make the NPC move faster or slower. + if (velocityLength < 20) + targetVelocity = npc.velocity; + else if (velocityLength < 40) { - desiredVelocity4.Normalize(); - desiredVelocity4 *= num1971 * 0.35f; + targetVelocity.Normalize(); + targetVelocity *= moveSpeed * 0.35f; } - else if (num1972 < 80f) + else if (velocityLength < 80) { - desiredVelocity4.Normalize(); - desiredVelocity4 *= num1971 * 0.65f; + targetVelocity.Normalize(); + targetVelocity *= moveSpeed * 0.65f; } else { - desiredVelocity4.Normalize(); - desiredVelocity4 *= num1971; + targetVelocity.Normalize(); + targetVelocity *= moveSpeed; } - npc.SimpleFlyMovement(desiredVelocity4, moveSpeed); + npc.SimpleFlyMovement(targetVelocity, 0.15F); npc.rotation = npc.velocity.X * 0.1f; - if ((npc.ai[0] += 1f) >= 70f) + + if (Main.netMode != 1 && npc.ai[0]++ >= 70) { + Vector2 projectileVelocity = Vector2.Zero; + while (Math.Abs(projectileVelocity.X) < 1.5f) + projectileVelocity = Vector2.UnitY.RotatedByRandom(Math.PI / 2) * new Vector2(5f, 3f); + + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, projectileVelocity.X, projectileVelocity.Y, ProjectileID.MartianTurretBolt, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); npc.ai[0] = 0f; - if (Main.netMode != 1) - { - Vector2 vector283 = Vector2.Zero; - while (Math.Abs(vector283.X) < 1.5f) - { - vector283 = Vector2.UnitY.RotatedByRandom(1.5707963705062866) * new Vector2(5f, 3f); - } - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector283.X, vector283.Y, 435, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); - } } } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void NPCLoot() { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMoonlord && tile == mod.TileType("CometiteOreTile") || tile == mod.TileType("HardCometiteOreTile") ? 0.005f : 0f; + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType(), Main.rand.Next(5, 12)); } - public override void NPCLoot() + public override void HitEffect(int hitDirection, double damage) { - if (Main.netMode != 1) + if (npc.life <= 0) { - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Catalyst"), Main.rand.Next(5, 12)); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GalasquidGore1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GalasquidGore2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GalasquidGore2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GalasquidGore2"), 1f); } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMoonlord && spawnInfo.spawnTileType == mod.TileType("CometiteOreTile") || spawnInfo.spawnTileType == mod.TileType("HardCometiteOreTile") ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/Geerd.cs b/NPCs/Geerd.cs index d14abac6..04c34e07 100644 --- a/NPCs/Geerd.cs +++ b/NPCs/Geerd.cs @@ -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 Geerd : ModNPC { public override void SetStaticDefaults() @@ -34,27 +36,8 @@ 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; - if (Main.rand.Next(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("GreenPuzzleFragment")); - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && NPC.downedBoss3 && Main.dayTime ? 0.005f : 0f; + if (Main.rand.Next(25) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -62,9 +45,8 @@ public override void HitEffect(int hitDirection, double damage) if (npc.life <= 0) { for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GeerdGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GrudGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GrudGore2"), 1f); @@ -79,5 +61,8 @@ public override void HitEffect(int hitDirection, double damage) } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => spawnInfo.spawnTileY < Main.rockLayer && NPC.downedBoss3 && Main.dayTime ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/Gelateen.cs b/NPCs/Gelateen.cs index 8913f663..f879af6d 100644 --- a/NPCs/Gelateen.cs +++ b/NPCs/Gelateen.cs @@ -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 Gelateen : ModNPC { public override void SetStaticDefaults() @@ -32,33 +34,10 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("GelateenBanner"); } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BounceTome")); - } - } - } - - 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)) && y > Main.rockLayer ? 0.001f : 0f; + if (Main.rand.NextBool()) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -70,16 +49,17 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GelateenGore1"), 1f); - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GelateenGore2"), 1f); + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/GelateenGore{i+1}"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GelateenGore3"), 1f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 1, 2.5f * hitDirection, -2.5f, 0, Color.Green, 0.7f); } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileY > Main.rockLayer ? 0.001f : 0f; } } \ No newline at end of file diff --git a/NPCs/GeneralSnowman.cs b/NPCs/GeneralSnowman.cs index b78e1a60..352c2138 100644 --- a/NPCs/GeneralSnowman.cs +++ b/NPCs/GeneralSnowman.cs @@ -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 GeneralSnowman : ModNPC { public override void SetStaticDefaults() @@ -33,20 +33,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("GeneralSnowmanBanner"); } - 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, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 2f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); @@ -54,11 +47,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return NPC.AnyNPCs(144) && Main.hardMode && y < Main.worldSurface ? 0.01f : 0f; - } + => NPC.AnyNPCs(NPCID.MisterStabby) && Main.hardMode && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/GhostKnight.cs b/NPCs/GhostKnight.cs index c8b70273..24e9d1c4 100644 --- a/NPCs/GhostKnight.cs +++ b/NPCs/GhostKnight.cs @@ -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 GhostKnight : ModNPC { public override void SetStaticDefaults() @@ -35,38 +35,21 @@ public override void SetDefaults() bannerItem = mod.ItemType("GhostKnightBanner"); } - 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)) && NPC.downedPlantBoss && !Main.dayTime && y < Main.worldSurface ? 0.01f : 0f; - } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } 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/GhostGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GhostGore2"), 1f); + + for(int i = 0; i < 2; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/GhostGore{i+1}"), 1f); } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 54, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 54, hitDirection, -1f, 0, default(Color), 0.7f); @@ -74,5 +57,8 @@ public override void HitEffect(int hitDirection, double damage) } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && NPC.downedPlantBoss && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/GhostWarrior.cs b/NPCs/GhostWarrior.cs index 03a65a06..c8a97031 100644 --- a/NPCs/GhostWarrior.cs +++ b/NPCs/GhostWarrior.cs @@ -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 GhostWarrior : ModNPC { public override void SetStaticDefaults() @@ -33,14 +35,21 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("GhostWarriorBanner"); } + public override void NPCLoot() + { + if (Main.rand.Next(3) == 0) + npc.NewItem(mod.ItemType()); + if (Main.rand.NextBool(2)) + npc.NewItem(mod.ItemType()); + } + 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GWGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GWGore1"), 1f); @@ -49,31 +58,7 @@ 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(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("GoldenClaw")); - }; - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LapisLazuli")); - }; - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && TremorWorld.Boss.Trinity.IsDowned() && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.005f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && TremorWorld.Boss.Trinity.IsDowned() && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/GiantCrab.cs b/NPCs/GiantCrab.cs index d5786c1a..213b1c08 100644 --- a/NPCs/GiantCrab.cs +++ b/NPCs/GiantCrab.cs @@ -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 GiantCrab : ModNPC { public override void SetStaticDefaults() @@ -32,20 +34,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("GiantCrabBanner"); } - 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/CrabGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CrabGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CrabGore2"), 1f); @@ -57,24 +52,11 @@ 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(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CrabClaw"), Main.rand.Next(1)); - }; - } + if (Main.rand.Next(25) == 0) + npc.NewItem(mod.ItemType()); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && (tile == 53 || tile == 112 || tile == 116 || tile == 234) && spawnInfo.water) && y < Main.rockLayer && (x < 250 || x > Main.maxTilesX - 250) && !spawnInfo.playerSafe && Main.hardMode ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && (spawnInfo.spawnTileType == 53 || spawnInfo.spawnTileType == 112 || spawnInfo.spawnTileType == 116 || spawnInfo.spawnTileType == 234) && spawnInfo.water && spawnInfo.spawnTileY < Main.rockLayer && (spawnInfo.spawnTileX < 250 || spawnInfo.spawnTileX > Main.maxTilesX - 250) && !spawnInfo.playerSafe && Main.hardMode ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/GiantGastropod.cs b/NPCs/GiantGastropod.cs index 5d777537..325c84d3 100644 --- a/NPCs/GiantGastropod.cs +++ b/NPCs/GiantGastropod.cs @@ -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 GiantGastropod : ModNPC { public override void SetStaticDefaults() @@ -38,24 +38,16 @@ public override void SetDefaults() bannerItem = mod.ItemType("GiantGastropodBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void AI() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(4) == 0) + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 72, 0f, 0f, 200, npc.color)].velocity *= 0.3f; } 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 282, 6); - } - } + if (Main.rand.NextBool()) + npc.NewItem(ItemID.Glowstick, 6); } public override void HitEffect(int hitDirection, double damage) @@ -65,8 +57,10 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 72, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 72, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 72, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GGGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GGGore2"), 1f); + + for(int i = 0; i < 2; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/GGGore{i+1}"), 1f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 72, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -75,21 +69,7 @@ public override void HitEffect(int hitDirection, double damage) } } - public override void AI() - { - if (Main.rand.Next(4) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 72, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && !Main.dayTime && NPC.downedMoonlord && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneHoly && y < Main.worldSurface ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && !Main.dayTime && NPC.downedMoonlord && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneHoly && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/GiantMeteorHead.cs b/NPCs/GiantMeteorHead.cs index 1198efe0..86a39583 100644 --- a/NPCs/GiantMeteorHead.cs +++ b/NPCs/GiantMeteorHead.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class GiantMeteorHead : ModNPC @@ -34,24 +37,16 @@ public override void SetDefaults() bannerItem = mod.ItemType("GiantMeteorHeadBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void AI() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(4) == 0) + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color)].velocity *= 0.3f; } 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(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MeteorScepter")); - }; - } + if (Main.rand.Next(20) == 0) + npc.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -61,6 +56,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -73,19 +69,7 @@ public override void HitEffect(int hitDirection, double damage) } } - public override void AI() - { - if (Main.rand.Next(4) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && spawnInfo.player.ZoneMeteor && NPC.downedBoss3 && Main.dayTime ? 0.01f : 0f; - } - + => spawnInfo.spawnTileY < Main.rockLayer && spawnInfo.player.ZoneMeteor && NPC.downedBoss3 && Main.dayTime ? 0.01f : 0f; } } diff --git a/NPCs/GloomySeer.cs b/NPCs/GloomySeer.cs index ee1a79e4..94730ea5 100644 --- a/NPCs/GloomySeer.cs +++ b/NPCs/GloomySeer.cs @@ -1,12 +1,13 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { - public class GloomySeer : ModNPC { public override void SetStaticDefaults() @@ -34,47 +35,30 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("GloomySeerBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() { + npc.ai[0]++; - npc.ai[0] += 1f; - if (npc.ai[0] == 20f || npc.ai[0] == 40f || npc.ai[0] == 60f || npc.ai[0] == 80f) + if (Main.netMode != 1 && (npc.ai[0] == 20f || npc.ai[0] == 40f || npc.ai[0] == 60f || npc.ai[0] == 80f)) { - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + Player target = Main.player[npc.target]; + if (Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) { - float num630 = 2.2f; - Vector2 vector64 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num631 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector64.X + Main.rand.Next(-100, 101); - float num632 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector64.Y + Main.rand.Next(-100, 101); - float num633 = (float)Math.Sqrt(num631 * num631 + num632 * num632); - num633 = num630 / num633; - num631 *= num633; - num632 *= num633; - int num634 = 21; - int num635 = 83; - int num636 = Projectile.NewProjectile(vector64.X, vector64.Y, num631, num632, num635, num634, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num636].timeLeft = 3000; + float speed = 2.2f; + Vector2 npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float targetX = target.position.X + target.width * 0.5f - npcCenter.X + Main.rand.Next(-100, 101); + float targetY = target.position.Y + target.height * 0.5f - npcCenter.Y + Main.rand.Next(-100, 101); + float length = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + length = speed / length; + + targetX *= length; + targetY *= length; + + Main.projectile[Projectile.NewProjectile(npcCenter.X, npcCenter.Y, targetX, targetY, ProjectileID.Bone, 83, 0f, Main.myPlayer, 0f, 0f)].timeLeft = 3000; } } else if (npc.ai[0] >= 150 + Main.rand.Next(150)) - { npc.ai[0] = 0f; - } - - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.bloodMoon && y < Main.worldSurface ? 0.001f : 0f; } public override void HitEffect(int hitDirection, double damage) @@ -82,9 +66,8 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.2f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GSGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GSGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GSGore2"), 1f); @@ -92,5 +75,7 @@ public override void HitEffect(int hitDirection, double damage) } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.001f : 0f; } } \ No newline at end of file diff --git a/NPCs/GoblinAssassin.cs b/NPCs/GoblinAssassin.cs index b8ca3b86..6416b58e 100644 --- a/NPCs/GoblinAssassin.cs +++ b/NPCs/GoblinAssassin.cs @@ -1,9 +1,11 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class GoblinAssassin : ModNPC @@ -16,6 +18,8 @@ public override void SetStaticDefaults() int CountFrame; int TimeToAnimation = 4; + bool TimetoShoot; + public override void SetDefaults() { npc.lifeMax = 90; @@ -31,53 +35,25 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 56); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() { npc.TargetClosest(true); - npc.spriteDirection = npc.direction; - Player player = Main.player[npc.target]; DoAI(); ExpertSetting(); - PlayAnimation(); } public void ExpertSetting() { - if (Main.expertMode) - { - if (npc.life > npc.lifeMax * 0.5f) - { - npc.defense = 13; - } - if (npc.life < npc.lifeMax * 0.5f && npc.life > npc.lifeMax * 0.3f) - { - npc.defense = 15; - } - if (npc.life < npc.lifeMax * 0.3f) - { - npc.defense = 18; - } - } - } + if (!Main.expertMode) return; - public void PlayAnimation() - { - if (--TimeToAnimation <= 0) - { - if (++CountFrame > 3) - CountFrame = 1; - TimeToAnimation = 4; - npc.frame = GetFrame(CountFrame); - } + if (npc.life > npc.lifeMax * 0.5f) + npc.defense = 13; + if (npc.life < npc.lifeMax * 0.5f && npc.life > npc.lifeMax * 0.3f) + npc.defense = 15; + if (npc.life < npc.lifeMax * 0.3f) + npc.defense = 18; } - bool TimetoShoot; public void DoAI() { Vector2 VectorPos = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -569,41 +545,36 @@ public void DoAI() } } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void FindFrame(int frameHeight) { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (NPC.AnyNPCs(26) || NPC.AnyNPCs(27) || NPC.AnyNPCs(28) || NPC.AnyNPCs(29)) && NPC.downedBoss3 && y < Main.worldSurface ? 0.08f : 0f; + if ((npc.frameCounter + Math.Abs(npc.velocity.X)) >= 20) + { + npc.frame.Y = (npc.frame.Y + frameHeight) % (Main.npcFrameCount[npc.type] * frameHeight); + npc.frameCounter = 0; + } + npc.spriteDirection = npc.direction; } public override void NPCLoot() { if (Main.invasionType == InvasionID.GoblinArmy) { - Main.invasionProgress++; + Main.invasionSize -= 1; + if (Main.invasionSize < 0) + Main.invasionSize = 0; + if (Main.netMode != 1) + Main.ReportInvasionProgress(Main.invasionSizeStart - Main.invasionSize, Main.invasionSizeStart, InvasionID.GoblinArmy + 3, 0); + if (Main.netMode == 2) + NetMessage.SendData(78, -1, -1, null, Main.invasionProgress, Main.invasionProgressMax, Main.invasionProgressIcon, 0f, 0, 0, 0); } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 161, Main.rand.Next(1, 15)); - } - - if (Main.rand.Next(200) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 160); - } - } + if (Main.rand.Next(2) == 0) + npc.NewItem(ItemID.SpikyBall, Main.rand.Next(1, 16)); + if (Main.rand.Next(200) == 0) + npc.NewItem(ItemID.Harpoon); } - Rectangle GetFrame(int Num) - { - return new Rectangle(0, npc.frame.Height * (Num - 1), npc.frame.Width, npc.frame.Height); - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Main.invasionType == InvasionID.GoblinArmy && NPC.downedBoss3 && spawnInfo.spawnTileY < Main.worldSurface ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/GoblinBomber.cs b/NPCs/GoblinBomber.cs index 54e92ede..b707a669 100644 --- a/NPCs/GoblinBomber.cs +++ b/NPCs/GoblinBomber.cs @@ -1,9 +1,11 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class GoblinBomber : ModNPC @@ -28,34 +30,14 @@ public override void SetDefaults() npc.DeathSound = SoundID.NPCDeath1; npc.value = Item.buyPrice(0, 0, 1, 21); } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - - int TimeToAnimation = 4; - int Frame; + public override void AI() { npc.TargetClosest(true); npc.spriteDirection = npc.direction; - PlayAnimation(); DoAI(); } - public void PlayAnimation() - { - if (--TimeToAnimation <= 0) - { - if (++Frame > 3) - Frame = 1; - TimeToAnimation = 4; - npc.frame = GetFrame(Frame); - } - } - public void DoAI() { int Num = 15; @@ -294,78 +276,21 @@ public void DoAI() } } + public override void FindFrame(int frameHeight) + { + if ((npc.frameCounter + Math.Abs(npc.velocity.X)) >= 20) + { + npc.frame.Y = (npc.frame.Y + frameHeight) % (Main.npcFrameCount[npc.type] * frameHeight); + npc.frameCounter = 0; + } + npc.spriteDirection = npc.direction; + } + public override void OnHitPlayer(Player player, int damage, bool crit) { npc.life = -1; - npc.active = false; + HitEffect(-1, 0); npc.checkDead(); - Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 62); - npc.position.X = npc.position.X + npc.width / 2; - npc.position.Y = npc.position.Y + npc.height / 2; - npc.width = 80; - npc.height = 80; - npc.position.X = npc.position.X - npc.width / 2; - npc.position.Y = npc.position.Y - npc.height / 2; - for (int num628 = 0; num628 < 40; num628++) - { - int num629 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 31, 0f, 0f, 100, default(Color), 2f); - Main.dust[num629].velocity *= 3f; - if (Main.rand.Next(2) == 0) - { - Main.dust[num629].scale = 0.5f; - Main.dust[num629].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num630 = 0; num630 < 70; num630++) - { - int num631 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 3f); - Main.dust[num631].noGravity = true; - Main.dust[num631].velocity *= 5f; - num631 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2f); - Main.dust[num631].velocity *= 2f; - } - for (int num632 = 0; num632 < 3; num632++) - { - float scaleFactor10 = 0.33f; - if (num632 == 1) - { - scaleFactor10 = 0.66f; - } - if (num632 == 2) - { - scaleFactor10 = 1f; - } - int num633 = Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); - Main.gore[num633].velocity *= scaleFactor10; - Gore expr_13E6D_cp_0 = Main.gore[num633]; - expr_13E6D_cp_0.velocity.X = expr_13E6D_cp_0.velocity.X + 1f; - Gore expr_13E8D_cp_0 = Main.gore[num633]; - expr_13E8D_cp_0.velocity.Y = expr_13E8D_cp_0.velocity.Y + 1f; - num633 = Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 2f); - Main.gore[num633].velocity *= scaleFactor10; - Gore expr_13F30_cp_0 = Main.gore[num633]; - expr_13F30_cp_0.velocity.X = expr_13F30_cp_0.velocity.X - 1f; - Gore expr_13F50_cp_0 = Main.gore[num633]; - expr_13F50_cp_0.velocity.Y = expr_13F50_cp_0.velocity.Y + 1f; - num633 = Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); - Main.gore[num633].velocity *= scaleFactor10; - Gore expr_13FF3_cp_0 = Main.gore[num633]; - expr_13FF3_cp_0.velocity.X = expr_13FF3_cp_0.velocity.X + 1f; - Gore expr_14013_cp_0 = Main.gore[num633]; - expr_14013_cp_0.velocity.Y = expr_14013_cp_0.velocity.Y - 1f; - num633 = Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); - Main.gore[num633].velocity *= scaleFactor10; - Gore expr_140B6_cp_0 = Main.gore[num633]; - expr_140B6_cp_0.velocity.X = expr_140B6_cp_0.velocity.X - 1f; - Gore expr_140D6_cp_0 = Main.gore[num633]; - expr_140D6_cp_0.velocity.Y = expr_140D6_cp_0.velocity.Y - 1f; - } - npc.position.X = npc.position.X + npc.width / 2; - npc.position.Y = npc.position.Y + npc.height / 2; - npc.width = 10; - npc.height = 10; - npc.position.X = npc.position.X - npc.width / 2; - npc.position.Y = npc.position.Y - npc.height / 2; } public override void HitEffect(int hitDirection, double damage) @@ -379,7 +304,8 @@ public override void HitEffect(int hitDirection, double damage) npc.height = 80; npc.position.X = npc.position.X - npc.width / 2; npc.position.Y = npc.position.Y - npc.height / 2; - for (int num628 = 0; num628 < 40; num628++) + + for (int i = 0; i < 40; i++) { int num629 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[num629].velocity *= 3f; @@ -389,7 +315,7 @@ public override void HitEffect(int hitDirection, double damage) Main.dust[num629].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num630 = 0; num630 < 70; num630++) + for (int i = 0; i < 70; i++) { int num631 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 3f); Main.dust[num631].noGravity = true; @@ -408,30 +334,25 @@ public override void HitEffect(int hitDirection, double damage) { scaleFactor10 = 1f; } - int num633 = Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); - Main.gore[num633].velocity *= scaleFactor10; - Gore expr_13E6D_cp_0 = Main.gore[num633]; - expr_13E6D_cp_0.velocity.X = expr_13E6D_cp_0.velocity.X + 1f; - Gore expr_13E8D_cp_0 = Main.gore[num633]; - expr_13E8D_cp_0.velocity.Y = expr_13E8D_cp_0.velocity.Y + 1f; - num633 = Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 2f); - Main.gore[num633].velocity *= scaleFactor10; - Gore expr_13F30_cp_0 = Main.gore[num633]; - expr_13F30_cp_0.velocity.X = expr_13F30_cp_0.velocity.X - 1f; - Gore expr_13F50_cp_0 = Main.gore[num633]; - expr_13F50_cp_0.velocity.Y = expr_13F50_cp_0.velocity.Y + 1f; - num633 = Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); - Main.gore[num633].velocity *= scaleFactor10; - Gore expr_13FF3_cp_0 = Main.gore[num633]; - expr_13FF3_cp_0.velocity.X = expr_13FF3_cp_0.velocity.X + 1f; - Gore expr_14013_cp_0 = Main.gore[num633]; - expr_14013_cp_0.velocity.Y = expr_14013_cp_0.velocity.Y - 1f; - num633 = Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); - Main.gore[num633].velocity *= scaleFactor10; - Gore expr_140B6_cp_0 = Main.gore[num633]; - expr_140B6_cp_0.velocity.X = expr_140B6_cp_0.velocity.X - 1f; - Gore expr_140D6_cp_0 = Main.gore[num633]; - expr_140D6_cp_0.velocity.Y = expr_140D6_cp_0.velocity.Y - 1f; + Gore gore = Main.gore[Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64))]; + gore.velocity *= scaleFactor10; + gore.velocity.X = gore.velocity.X + 1f; + gore.velocity.Y = gore.velocity.Y + 1f; + + gore = Main.gore[Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64), 2f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X = gore.velocity.X - 1f; + gore.velocity.Y = gore.velocity.Y + 1f; + + gore = Main.gore[Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64))]; + gore.velocity *= scaleFactor10; + gore.velocity.X = gore.velocity.X + 1f; + gore.velocity.Y = gore.velocity.Y - 1f; + + gore = Main.gore[Gore.NewGore(new Vector2(npc.position.X + npc.width / 2 - 24f, npc.position.Y + npc.height / 2 - 24f), default(Vector2), Main.rand.Next(61, 64))]; + gore.velocity *= scaleFactor10; + gore.velocity.X = gore.velocity.X - 1f; + gore.velocity.Y = gore.velocity.Y - 1f; } npc.position.X = npc.position.X + npc.width / 2; npc.position.Y = npc.position.Y + npc.height / 2; @@ -446,37 +367,22 @@ public override void NPCLoot() { if (Main.invasionType == InvasionID.GoblinArmy) { - Main.invasionProgress++; + Main.invasionSize -= 1; + if (Main.invasionSize < 0) + Main.invasionSize = 0; + if (Main.netMode != 1) + Main.ReportInvasionProgress(Main.invasionSizeStart - Main.invasionSize, Main.invasionSizeStart, InvasionID.GoblinArmy + 3, 0); + if (Main.netMode == 2) + NetMessage.SendData(78, -1, -1, null, Main.invasionProgress, Main.invasionProgressMax, Main.invasionProgressIcon, 0f, 0, 0, 0); } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 161, Main.rand.Next(1, 15)); - } - - if (Main.rand.Next(200) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 160); - } - } - } - - Rectangle GetFrame(int Num) - { - return new Rectangle(0, npc.frame.Height * (Num - 1), npc.frame.Width, npc.frame.Height); + if (Main.rand.Next(2) == 0) + npc.NewItem(ItemID.SpikyBall, Main.rand.Next(1, 16)); + if (Main.rand.Next(200) == 0) + npc.NewItem(ItemID.Harpoon); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (NPC.AnyNPCs(26) || NPC.AnyNPCs(27) || NPC.AnyNPCs(28) || NPC.AnyNPCs(29)) && NPC.downedBoss3 && y < Main.worldSurface ? 0.08f : 0f; - } + => Main.invasionType == InvasionID.GoblinArmy && NPC.downedBoss3 && spawnInfo.spawnTileY < Main.worldSurface ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/GoblinStandardBearer.cs b/NPCs/GoblinStandardBearer.cs index 34cd5c81..aa9b2d8a 100644 --- a/NPCs/GoblinStandardBearer.cs +++ b/NPCs/GoblinStandardBearer.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; +using System; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class GoblinStandardBearer : ModNPC @@ -30,19 +33,9 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 0); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() { - PlayAnimation(); - if (Main.player[npc.target].position.X > npc.position.X) - npc.spriteDirection = 1; - else - npc.spriteDirection = -1; + npc.TargetClosest(true); if (npc.direction == -1 && npc.velocity.X > -2f) { @@ -106,37 +99,25 @@ public override void AI() } } } - - int Frame; - int TimeToAnimation = 6; - public void PlayAnimation() + + public override void FindFrame(int frameHeight) { - if (--TimeToAnimation <= 0) + if ((npc.frameCounter + Math.Abs(npc.velocity.X)) >= 20) { - if (++Frame > 3) - Frame = 1; - TimeToAnimation = 6; - npc.frame = GetFrame(Frame); + npc.frame.Y = (npc.frame.Y + frameHeight) % (Main.npcFrameCount[npc.type] * frameHeight); + npc.frameCounter = 0; } - } - - Rectangle GetFrame(int Num) - { - return new Rectangle(0, npc.frame.Height * (Num - 1), npc.frame.Width, npc.frame.Height); - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (NPC.AnyNPCs(26) || NPC.AnyNPCs(27) || NPC.AnyNPCs(28) || NPC.AnyNPCs(29)) && NPC.downedBoss3 && y < Main.worldSurface ? 0.3f : 0f; + npc.spriteDirection = npc.direction; } - public override void NPCLoot() + public override bool CheckDead() { - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("GoblinStandardBearer_Balloon")); + npc.SetDefaults(mod.NPCType()); + return false; } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Main.invasionType == InvasionID.GoblinArmy && NPC.downedBoss3 && spawnInfo.spawnTileY < Main.worldSurface ? 0.3f : 0f; } } \ No newline at end of file diff --git a/NPCs/GoblinStandardBearer_Balloon.cs b/NPCs/GoblinStandardBearer_Balloon.cs index 920da38e..bc156eb2 100644 --- a/NPCs/GoblinStandardBearer_Balloon.cs +++ b/NPCs/GoblinStandardBearer_Balloon.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; +using System; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class GoblinStandardBearer_Balloon : ModNPC @@ -13,6 +16,8 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 3; } + const int maxXMoveSpeed = 4; + public override void SetDefaults() { npc.lifeMax = 50; @@ -29,69 +34,40 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 1, 64); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() { - PlayAnimation(); - if (Main.player[npc.target].position.X > npc.position.X) - npc.spriteDirection = 1; - else - npc.spriteDirection = -1; + npc.TargetClosest(true); - if (npc.direction == -1 && npc.velocity.X > -2f) + if (npc.direction == -1 && npc.velocity.X > -maxXMoveSpeed) { npc.velocity.X = npc.velocity.X - 0.1f; if (npc.velocity.X > 2f) - { npc.velocity.X = npc.velocity.X - 0.1f; - } - else - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + 0.05f; - } - } - if (npc.velocity.X < -2f) - { - npc.velocity.X = -2f; - } + else if (npc.velocity.X > 0f) + npc.velocity.X = npc.velocity.X + 0.05f; + + if (npc.velocity.X < -maxXMoveSpeed) + npc.velocity.X = -maxXMoveSpeed; } - else + else if(npc.direction == 1 && npc.velocity.X < maxXMoveSpeed) { - if (npc.direction == 1 && npc.velocity.X < 2f) - { + npc.velocity.X = npc.velocity.X + 0.1f; + if (npc.velocity.X < -2f) npc.velocity.X = npc.velocity.X + 0.1f; - if (npc.velocity.X < -2f) - { - npc.velocity.X = npc.velocity.X + 0.1f; - } - else - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X - 0.05f; - } - } - if (npc.velocity.X > 2f) - { - npc.velocity.X = 2f; - } - } + + else if(npc.velocity.X < 0f) + npc.velocity.X = npc.velocity.X - 0.05f; + + if (npc.velocity.X > maxXMoveSpeed) + npc.velocity.X = maxXMoveSpeed; } + if (npc.directionY == -1 && npc.velocity.Y > -1.5) { npc.velocity.Y = npc.velocity.Y - 0.05f; if (npc.velocity.Y < -1.5) - { npc.velocity.Y = -1.5f; - } } else { @@ -106,46 +82,34 @@ public override void AI() } } - int Frame; - int TimeToAnimation = 6; - public void PlayAnimation() + public override void FindFrame(int frameHeight) { - if (--TimeToAnimation <= 0) + if ((npc.frameCounter + Math.Abs(npc.velocity.X)) >= 20) { - if (++Frame > 3) - Frame = 1; - TimeToAnimation = 6; - npc.frame = GetFrame(Frame); + npc.frame.Y = (npc.frame.Y + frameHeight) % (Main.npcFrameCount[npc.type] * frameHeight); + npc.frameCounter = 0; } - } - Rectangle GetFrame(int Num) - { - return new Rectangle(0, npc.frame.Height * (Num - 1), npc.frame.Width, npc.frame.Height); + npc.spriteDirection = npc.direction; } public override void NPCLoot() { if (Main.invasionType == InvasionID.GoblinArmy) { - Main.invasionProgress++; + Main.invasionSize -= 1; + if (Main.invasionSize < 0) + Main.invasionSize = 0; + if (Main.netMode != 1) + Main.ReportInvasionProgress(Main.invasionSizeStart - Main.invasionSize, Main.invasionSizeStart, InvasionID.GoblinArmy + 3, 0); + if (Main.netMode == 2) + NetMessage.SendData(78, -1, -1, null, Main.invasionProgress, Main.invasionProgressMax, Main.invasionProgressIcon, 0f, 0, 0, 0); } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 161, Main.rand.Next(1, 15)); - } - if (Main.rand.Next(200) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 160); - } - } + if (Main.rand.Next(2) == 0) + npc.NewItem(ItemID.SpikyBall, Main.rand.Next(1, 16)); + if (Main.rand.Next(200) == 0) + npc.NewItem(ItemID.Harpoon); } } } \ No newline at end of file diff --git a/NPCs/GogLordGog.cs b/NPCs/GogLordGog.cs index 05fd128f..42ad8ab2 100644 --- a/NPCs/GogLordGog.cs +++ b/NPCs/GogLordGog.cs @@ -1,9 +1,9 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class GogLordGog : ModNPC @@ -28,42 +28,54 @@ public override void SetDefaults() npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath10; npc.value = Item.buyPrice(0, 1, 0, 0); - } - int timer; - public override void AI() + npc.alpha = 244; + npc.scale = 0.25F; + } + + public override bool PreAI() { - float Num1 = Main.mouseTextColor / 200f - 0.35f; - Num1 *= 0.5f; - npc.scale = Num1 + 0.95f; - timer++; - npc.velocity.X = 0f; - npc.velocity.Y = 0f; - - if (timer >= 200) + if(npc.ai[0] == 0) // First update/spawn sequence. { - npc.alpha++; - npc.alpha++; + npc.localAI[0] = Main.rand.NextBool() ? -Main.rand.Next(1, 11) : Main.rand.Next(1, 11); + npc.ai[0] = 1; } + else if (npc.ai[0] == 1) // 'Appear' sequence. + { + if(npc.scale < 1) + npc.scale += 0.75F / 60; + else + npc.scale = 1; - if (npc.alpha >= 255) + if ((npc.alpha -= 4) <= 0) + { + if (npc.ai[1]++ >= 120) + { + npc.scale = 1; + npc.ai[0] = 2; + } + npc.alpha = 0; + } + } + else if (npc.ai[0] == 2) // 'Disappear' sequence. { - npc.life = -1; - npc.active = false; - npc.checkDead(); + npc.scale -= 0.75F / 60; + if ((npc.alpha += 4) >= 255) + { + npc.life = -1; + npc.active = false; + npc.checkDead(); + } } + + npc.velocity *= Vector2.Zero; + npc.rotation += (npc.localAI[0] * 0.05F) / npc.Opacity; + return false; } - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { - Texture2D drawTexture = Main.npcTexture[npc.type]; - Vector2 origin = new Vector2((drawTexture.Width / 2) * 0.5F, (drawTexture.Height / Main.npcFrameCount[npc.type]) * 0.5F); - Vector2 drawPos = new Vector2( - npc.position.X - Main.screenPosition.X + (npc.width / 2) - (Main.npcTexture[npc.type].Width / 2) * npc.scale / 2f + origin.X * npc.scale, - npc.position.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + origin.Y * npc.scale + npc.gfxOffY); - SpriteEffects effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(drawTexture, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, effects, 0); - return false; + return npc.alpha <= 125; } } } \ No newline at end of file diff --git a/NPCs/GoplitArcher.cs b/NPCs/GoplitArcher.cs index 7a079459..b4465d84 100644 --- a/NPCs/GoplitArcher.cs +++ b/NPCs/GoplitArcher.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class GoplitArcher : ModNPC @@ -34,20 +37,13 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("GoplitArcherBanner"); } - 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, 31, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GoplitAGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GoplitAGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GoplitAGore3"), 1f); @@ -57,25 +53,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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("StoneofLife")); - }; - } + this.NewItem(mod.ItemType()); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; - return (Helper.NoZoneAllowWater(spawnInfo)) && (tile.type == 367) && y > Main.rockLayer ? 0.01f : 0f; - } - + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileType == TileID.Marble && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } diff --git a/NPCs/GoplitOfficer.cs b/NPCs/GoplitOfficer.cs index 0ac4f8bd..889bb0fe 100644 --- a/NPCs/GoplitOfficer.cs +++ b/NPCs/GoplitOfficer.cs @@ -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 GoplitOfficer : ModNPC { public override void SetStaticDefaults() @@ -30,21 +30,13 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 2, 0); } - 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SHGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SHGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SHGore3"), 1f); @@ -54,13 +46,8 @@ public override void HitEffect(int hitDirection, double damage) NPC.NewNPC((int)npc.position.X - 22, (int)npc.position.Y + 55, 481); } } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; - return (Helper.NoZoneAllowWater(spawnInfo)) && (tile.type == 367) && y > Main.rockLayer ? 0.001f : 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileType == TileID.Marble && spawnInfo.spawnTileY > Main.rockLayer ? 0.001f : 0f; } } \ No newline at end of file diff --git a/NPCs/GraniteBeetle.cs b/NPCs/GraniteBeetle.cs index 0259874a..19265339 100644 --- a/NPCs/GraniteBeetle.cs +++ b/NPCs/GraniteBeetle.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class GraniteBeetle : ModNPC @@ -37,26 +40,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; - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3086, Main.rand.Next(10)); - }; - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("StoneofLife")); - }; - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool(2)) + this.NewItem(ItemID.Granite, Main.rand.Next(10)); + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -64,9 +51,8 @@ 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, 31, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GBeetleGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GBeetleGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GBeetleGore3"), 1f); @@ -77,12 +63,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; - return (Helper.NoZoneAllowWater(spawnInfo)) && (tile.type == 368) && y > Main.rockLayer ? 0.01f : 0f; - } - + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileType == TileID.Granite && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } diff --git a/NPCs/GraniteBowman.cs b/NPCs/GraniteBowman.cs index b58d249c..af1f93a6 100644 --- a/NPCs/GraniteBowman.cs +++ b/NPCs/GraniteBowman.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class GraniteBowman : ModNPC @@ -36,26 +39,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; - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3086, Main.rand.Next(10)); - }; - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("StoneofLife")); - }; - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool(2)) + this.NewItem(ItemID.Granite, Main.rand.Next(10)); + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -63,9 +50,8 @@ 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, 31, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GBGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GBGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GBGore3"), 1f); @@ -74,12 +60,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; - return (Helper.NoZoneAllowWater(spawnInfo)) && (tile.type == 368) && y > Main.rockLayer ? 0.01f : 0f; - } - + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileType == TileID.Granite && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } diff --git a/NPCs/GrayRaven.cs b/NPCs/GrayRaven.cs index 1c233895..90f8cd8c 100644 --- a/NPCs/GrayRaven.cs +++ b/NPCs/GrayRaven.cs @@ -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 GrayRaven : ModNPC { public override void SetStaticDefaults() @@ -30,27 +32,15 @@ public override void SetDefaults() bannerItem = mod.ItemType("GrayRavenBanner"); } - - public override void NPCLoot() + public override void OnHitPlayer(Player player, int damage, bool crit) { - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("RavenFeather"), Main.rand.Next(1, 3)); - } - - } + player.AddBuff(BuffID.Bleeding, 60, true); } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void NPCLoot() { - { - player.AddBuff(30, 60, true); - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); } public override void HitEffect(int hitDirection, double damage) @@ -58,9 +48,8 @@ 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/GrayRavenGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GrayRavenGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GrayRavenGore2"), 1f); @@ -69,11 +58,6 @@ public override void HitEffect(int hitDirection, double damage) } 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)) && Main.hardMode && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/GreatFungusBug.cs b/NPCs/GreatFungusBug.cs index 0ac92f8e..d73061c2 100644 --- a/NPCs/GreatFungusBug.cs +++ b/NPCs/GreatFungusBug.cs @@ -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 GreatFungusBug : ModNPC { public override void SetStaticDefaults() @@ -32,12 +32,6 @@ public override void SetDefaults() npc.DeathSound = SoundID.NPCDeath57; } - 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) @@ -47,20 +41,14 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FungalBugGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FungalBugGore3"), 1f); for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 67, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 67, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 67, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } } } diff --git a/NPCs/Grood.cs b/NPCs/Grood.cs index ed502afb..d297bb31 100644 --- a/NPCs/Grood.cs +++ b/NPCs/Grood.cs @@ -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 Grood : ModNPC { public override void SetStaticDefaults() @@ -34,31 +36,11 @@ 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; - if (Main.rand.Next(23) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("YellowPuzzleFragment")); - } - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("GiantRedFeather")); - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && Main.hardMode && Main.dayTime ? 0.001f : 0f; + if (Main.rand.Next(23) == 0) + this.NewItem(mod.ItemType()); + // No GiantRedFeather class in Tremor namespace. + //if (Main.rand.Next(30) == 0) + // this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -66,9 +48,8 @@ public override void HitEffect(int hitDirection, double damage) if (npc.life <= 0) { for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GroodGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GroodGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GroodGore2"), 1f); @@ -77,7 +58,7 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -85,5 +66,8 @@ public override void HitEffect(int hitDirection, double damage) } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => spawnInfo.spawnTileY < Main.rockLayer && Main.hardMode && Main.dayTime ? 0.001f : 0f; } } \ No newline at end of file diff --git a/NPCs/Gurd.cs b/NPCs/Gurd.cs index fc100f67..c948bd37 100644 --- a/NPCs/Gurd.cs +++ b/NPCs/Gurd.cs @@ -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 Gurd : ModNPC { public override void SetStaticDefaults() @@ -34,27 +36,8 @@ 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; - if (Main.rand.Next(27) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("RedPuzzleFragment")); - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && NPC.downedBoss1 && Main.dayTime ? 0.005f : 0f; + if (Main.rand.Next(27) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -62,16 +45,15 @@ public override void HitEffect(int hitDirection, double damage) if (npc.life <= 0) { for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GrudGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GrudGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/GrudGore2"), 1f); } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -79,5 +61,8 @@ public override void HitEffect(int hitDirection, double damage) } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => spawnInfo.spawnTileY < Main.rockLayer && NPC.downedBoss1 && Main.dayTime ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/HallowSlimer.cs b/NPCs/HallowSlimer.cs index ad39a743..59b7236f 100644 --- a/NPCs/HallowSlimer.cs +++ b/NPCs/HallowSlimer.cs @@ -1,12 +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; + namespace Tremor.NPCs { - public class HallowSlimer : ModNPC { public override void SetStaticDefaults() @@ -35,61 +35,43 @@ public override void SetDefaults() NPCID.Sets.TrailCacheLength[npc.type] = 5; } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void HitEffect(int hitDirection, double damage) { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + 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); + + if(Main.netMode != 1) + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, NPCID.IlluminantSlime); + } } + public override void AI() + { + Lighting.AddLight((int)npc.position.X / 16, (int)npc.position.Y / 16, 0.3f, 0f, 0.2f); + + for (int i = npc.oldPos.Length - 1; i > 0; i--) + npc.oldPos[i] = npc.oldPos[i - 1]; + npc.oldPos[0] = npc.position; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Vector2 drawOrigin = new Vector2(Main.npcTexture[npc.type].Width, Main.npcTexture[npc.type].Height * 0.8f); for (int k = 0; k < npc.oldPos.Length; k++) { - SpriteEffects effect = SpriteEffects.None; - if (npc.direction == 1) { effect = SpriteEffects.FlipHorizontally; } - if (npc.direction == -1) { effect = SpriteEffects.None; } - Vector2 drawPos = npc.oldPos[k] - Main.screenPosition; + SpriteEffects effect = npc.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Color color = npc.GetAlpha(lightColor) * ((npc.oldPos.Length - k) / (float)npc.oldPos.Length); Rectangle frame = new Rectangle(0, 0, 90, 42); frame.Y += 164 * (k / 60); - - spriteBatch.Draw(Main.npcTexture[npc.type], drawPos, frame, color, 0, Vector2.Zero, npc.scale, effect, 1f); + spriteBatch.Draw(Main.npcTexture[npc.type], npc.oldPos[k] - Main.screenPosition, frame, color, 0, Vector2.Zero, npc.scale, effect, 1f); } return true; } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, 138); - 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); - } - } - } - - public override void AI() - { - for (int num72 = npc.oldPos.Length - 1; num72 > 0; num72--) - { - npc.oldPos[num72] = npc.oldPos[num72 - 1]; - Lighting.AddLight((int)npc.position.X / 16, (int)npc.position.Y / 16, 0.3f, 0f, 0.2f); - } - npc.oldPos[0] = npc.position; - - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneHoly && y < Main.worldSurface ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneHoly && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Hallower.cs b/NPCs/Hallower.cs index 3ffdf645..ad1b85b6 100644 --- a/NPCs/Hallower.cs +++ b/NPCs/Hallower.cs @@ -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 Hallower : ModNPC { public override void SetStaticDefaults() @@ -38,24 +38,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("HallowerBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 501, 5); - } - } + if (Main.rand.NextBool()) + this.NewItem(ItemID.PixieDust, 5); } public override void HitEffect(int hitDirection, double damage) @@ -67,31 +53,19 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 57, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 57, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 57, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } } public override void AI() { if (Main.rand.Next(6) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 55, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 55, 0f, 0f, 200, npc.color)].velocity *= 0.3f; if (Main.rand.Next(40) == 0) - { Main.PlaySound(27, (int)npc.position.X, (int)npc.position.Y, 1); - } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && NPC.downedMoonlord && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneHoly && y < Main.worldSurface ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && NPC.downedMoonlord && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneHoly && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/HappySoul.cs b/NPCs/HappySoul.cs index 7cd97f06..4ebdd849 100644 --- a/NPCs/HappySoul.cs +++ b/NPCs/HappySoul.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { [AutoloadBossHead] @@ -32,14 +33,12 @@ public override void SetDefaults() npc.DeathSound = SoundID.NPCDeath6; npc.value = Item.buyPrice(0, 2, 0, 9); } + public override void AI() { npc.position += npc.velocity * 2f; if (Main.rand.Next(6) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 62, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 62, 0f, 0f, 200, npc.color)].velocity *= 0.3f; } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/HarpyWarrior.cs b/NPCs/HarpyWarrior.cs index 34268e51..f4613759 100644 --- a/NPCs/HarpyWarrior.cs +++ b/NPCs/HarpyWarrior.cs @@ -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 HarpyWarrior : ModNPC { public override void SetStaticDefaults() @@ -14,7 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - public override void SetDefaults() { npc.lifeMax = 300; @@ -40,27 +39,14 @@ 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/HarpyGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HarpyGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HarpyGore2"), 1f); } } - 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) && Main.hardMode && spawnInfo.sky ? 0.02f : 0; - } + => Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && spawnInfo.sky ? 0.02f : 0; } } \ No newline at end of file diff --git a/NPCs/HeadlessZombie.cs b/NPCs/HeadlessZombie.cs index 63b74740..44d2f21a 100644 --- a/NPCs/HeadlessZombie.cs +++ b/NPCs/HeadlessZombie.cs @@ -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 HeadlessZombie : ModNPC { public override void SetStaticDefaults() @@ -32,10 +34,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("HeadlessZombieBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(3) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -43,9 +45,8 @@ 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/ZombieGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore1"), 1f); @@ -53,25 +54,7 @@ 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(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("UntreatedFlesh")); - }; - } - } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/HeavyZombie.cs b/NPCs/HeavyZombie.cs index c02fa21b..d65160cb 100644 --- a/NPCs/HeavyZombie.cs +++ b/NPCs/HeavyZombie.cs @@ -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 HeavyZombie : ModNPC { public override void SetStaticDefaults() @@ -32,10 +34,18 @@ public override void SetDefaults() bannerItem = mod.ItemType("HeavyZombieBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(3) == 0) + npc.NewItem(mod.ItemType()); + if (Main.rand.Next(4) == 0) + npc.NewItem(ItemID.SilverBar, Main.rand.Next(2, 4)); + if (Main.rand.Next(4) == 0) + npc.NewItem(ItemID.IronBar, Main.rand.Next(2, 4)); + if (Main.rand.Next(4) == 0) + npc.NewItem(ItemID.LeadBar, Main.rand.Next(2, 4)); + if (Main.rand.Next(4) == 0) + npc.NewItem(ItemID.TungstenBar, Main.rand.Next(2, 4)); } public override void HitEffect(int hitDirection, double damage) @@ -43,9 +53,8 @@ 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/HeavyGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HeavyGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HeavyGore3"), 1f); @@ -53,41 +62,7 @@ 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(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("UntreatedFlesh")); - } - if (Main.rand.Next(4) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 22, Main.rand.Next(2, 4)); - } - if (Main.rand.Next(4) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 21, Main.rand.Next(2, 4)); - } - if (Main.rand.Next(4) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 704, Main.rand.Next(2, 4)); - } - if (Main.rand.Next(4) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 705, Main.rand.Next(2, 4)); - } - } - } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.03f : 0f; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.03f : 0f; } } \ No newline at end of file diff --git a/NPCs/Hellgron.cs b/NPCs/Hellgron.cs index 272fa2d9..2710514e 100644 --- a/NPCs/Hellgron.cs +++ b/NPCs/Hellgron.cs @@ -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 Hellgron : ModNPC { public override void SetStaticDefaults() @@ -38,18 +38,10 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("HellgronBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } public override void AI() { if (Main.rand.Next(4) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 2f); - Main.dust[num706].velocity *= 0.3f; - } + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 2f)].velocity *= 0.3f; } public override void HitEffect(int hitDirection, double damage) @@ -71,13 +63,7 @@ public override void HitEffect(int hitDirection, double damage) } } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.03f : 0; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.03f : 0; } } \ No newline at end of file diff --git a/NPCs/Hellhound.cs b/NPCs/Hellhound.cs index 9935c28e..6b7b552d 100644 --- a/NPCs/Hellhound.cs +++ b/NPCs/Hellhound.cs @@ -1,12 +1,15 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { - public class Hellhound : ModNPC { public override void SetStaticDefaults() @@ -36,59 +39,11 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("HellhoundBanner"); } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - for (int k = 0; k < 60; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore3"), 1f); - } - else - { - - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 6, hitDirection, -2f, 0, default(Color), 1.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 6, hitDirection, -1f, 0, default(Color), 0.7f); - } - } - } - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FireFragment"), Main.rand.Next(2, 4)); - }; - if (Main.rand.Next(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FlamesofDespair")); - }; - } - } - public override void AI() { - if (Main.rand.Next(4) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color)].velocity *= 0.3F; + Vector2 vector72 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num738 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector72.X; float num739 = Main.player[npc.target].position.Y - vector72.Y; @@ -101,32 +56,30 @@ public override void AI() if (npc.ai[1] < 30f) { Vector2 vector73 = npc.Center + Vector2.UnitX * npc.spriteDirection * -20f; - Dust dust11 = Main.dust[Dust.NewDust(vector73, 0, 0, 6, 0f, 0f, 0, default(Color), 1f)]; + Dust newDust = Main.dust[Dust.NewDust(vector73, 0, 0, 6, 0f, 0f, 0, default(Color), 1f)]; Vector2 vector74 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); - dust11.position = vector73 + vector74 * 20f; - dust11.velocity = -vector74 * 2f; - dust11.scale = 0.5f + vector74.X * -(float)npc.spriteDirection; - dust11.fadeIn = 1f; - dust11.noGravity = true; + newDust.position = vector73 + vector74 * 20f; + newDust.velocity = -vector74 * 2f; + newDust.scale = 0.5f + vector74.X * -(float)npc.spriteDirection; + newDust.fadeIn = 1f; + newDust.noGravity = true; } else if (npc.ai[1] == 30f) { for (int num743 = 0; num743 < 20; num743++) { Vector2 vector75 = npc.Center + Vector2.UnitX * npc.spriteDirection * -20f; - Dust dust12 = Main.dust[Dust.NewDust(vector75, 0, 0, 6, 0f, 0f, 0, default(Color), 1f)]; + Dust newDust = Main.dust[Dust.NewDust(vector75, 0, 0, 6, 0f, 0f, 0, default(Color), 1f)]; Vector2 vector76 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); - dust12.position = vector75 + vector76 * 4f; - dust12.velocity = vector76 * 4f + Vector2.UnitX * Main.rand.NextFloat() * npc.spriteDirection * -5f; - dust12.scale = 0.5f + vector76.X * -(float)npc.spriteDirection; - dust12.fadeIn = 1f; - dust12.noGravity = true; + newDust.position = vector75 + vector76 * 4f; + newDust.velocity = vector76 * 4f + Vector2.UnitX * Main.rand.NextFloat() * npc.spriteDirection * -5f; + newDust.scale = 0.5f + vector76.X * -(float)npc.spriteDirection; + newDust.fadeIn = 1f; + newDust.noGravity = true; } } if (npc.velocity.X > -0.5f && npc.velocity.X < 0.5f) - { npc.velocity.X = 0f; - } if (npc.ai[1] == 30f && Main.netMode != 1) { int num744 = Main.expertMode ? 35 : 50; @@ -154,14 +107,42 @@ public override void AI() } } + public override void NPCLoot() + { + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(2, 4)); + if (Main.rand.Next(25) == 0) + this.NewItem(mod.ItemType()); + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void HitEffect(int hitDirection, double damage) { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.002f : 0f; + if (npc.life <= 0) + { + for (int k = 0; k < 60; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); + } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HellhoundGore3"), 1f); + } + else + { + + for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 6, hitDirection, -2f, 0, default(Color), 1.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 6, hitDirection, -1f, 0, default(Color), 0.7f); + } + } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => (Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && spawnInfo.spawnTileY > Main.maxTilesY - 200 ? 0.002f : 0f; } } \ No newline at end of file diff --git a/NPCs/HiveHeadZombie.cs b/NPCs/HiveHeadZombie.cs index f4fc93f5..fbe72a41 100644 --- a/NPCs/HiveHeadZombie.cs +++ b/NPCs/HiveHeadZombie.cs @@ -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 HiveHeadZombie : ModNPC { public override void SetStaticDefaults() @@ -32,35 +32,28 @@ public override void SetDefaults() bannerItem = mod.ItemType("HiveHeadZombieBanner"); } - 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/ZombieGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore2"), 1f); - NPC.NewNPC((int)npc.position.X - 22, (int)npc.position.Y + 55, 210); - NPC.NewNPC((int)npc.position.X + 37, (int)npc.position.Y, 210); - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, 210); + + if (Main.netMode != 1) + { + NPC.NewNPC((int)npc.position.X - 22, (int)npc.position.Y + 55, NPCID.Bee); + NPC.NewNPC((int)npc.position.X + 37, (int)npc.position.Y, NPCID.Bee); + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, NPCID.Bee); + } } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedQueenBee && !Main.dayTime && y < Main.worldSurface ? 0.01f : 0f; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedQueenBee && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/IceBlazer.cs b/NPCs/IceBlazer.cs index c0d45292..0d150862 100644 --- a/NPCs/IceBlazer.cs +++ b/NPCs/IceBlazer.cs @@ -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 IceBlazer : ModNPC { public override void SetStaticDefaults() @@ -35,36 +37,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("IceBlazerBanner"); } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && spawnInfo.player.ZoneSnow && y < Main.worldSurface ? 0.004f : 0f; - } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FrostCore")); - }; - if (NPC.downedMoonlord && Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("IceSoul")); - } - } + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType()); + if (NPC.downedMoonlord && Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -78,17 +56,16 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 92, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 92, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } else { for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 92, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && spawnInfo.player.ZoneSnow && spawnInfo.spawnTileY < Main.worldSurface ? 0.004f : 0f; } } \ No newline at end of file diff --git a/NPCs/IceMotherSlime.cs b/NPCs/IceMotherSlime.cs index c572915f..0796709a 100644 --- a/NPCs/IceMotherSlime.cs +++ b/NPCs/IceMotherSlime.cs @@ -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 IceMotherSlime : ModNPC { public override void SetStaticDefaults() @@ -33,6 +33,12 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("IceMotherSlimeBanner"); } + public override void AI() + { + if (Main.rand.Next(10) == 0) + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 80, 0f, 0f, 200, npc.color)].velocity *= 0.3f; + } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -40,38 +46,22 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, 147); - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, 147); - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, 147); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.6f); } - } - } - public override void AI() - { - if (Main.rand.Next(10) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 80, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } - } + if (Main.netMode == 1) return; - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, NPCID.IceSlime); + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, NPCID.IceSlime); + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 48, NPCID.IceSlime); + } } 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)) && Main.cloudAlpha > 0f && y < Main.worldSurface && spawnInfo.player.ZoneSnow ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileY < Main.worldSurface && spawnInfo.player.ZoneSnow ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/InfectedZombie.cs b/NPCs/InfectedZombie.cs index b0875ad7..6c156f73 100644 --- a/NPCs/InfectedZombie.cs +++ b/NPCs/InfectedZombie.cs @@ -4,7 +4,6 @@ namespace Tremor.NPCs { - public class InfectedZombie : ModNPC { public override void SetStaticDefaults() @@ -31,18 +30,7 @@ public override void SetDefaults() bannerItem = mod.ItemType("InfectedZombieBanner"); } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && NPC.downedBoss2 && spawnInfo.player.ZoneCrimson && y < Main.worldSurface ? 0.02f : 0; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && NPC.downedBoss2 && spawnInfo.player.ZoneCrimson && spawnInfo.spawnTileY < Main.worldSurface ? 0.02f : 0; } } \ No newline at end of file diff --git a/NPCs/IronGiant.cs b/NPCs/IronGiant.cs index b5a99c44..4f0cd244 100644 --- a/NPCs/IronGiant.cs +++ b/NPCs/IronGiant.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class IronGiant : ModNPC @@ -36,26 +39,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; - if (Main.rand.Next(8) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ElectricSpear")); - }; - if (Main.rand.Next(10) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 18); - }; - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(8) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(10) == 0) + this.NewItem(ItemID.DepthMeter); } public override void HitEffect(int hitDirection, double damage) @@ -63,9 +50,8 @@ 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, 31, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); @@ -79,12 +65,6 @@ public override void HitEffect(int hitDirection, double damage) } 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)) && Main.hardMode && y > Main.rockLayer ? 0.001f : 0f; - } - + => (Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.001f : 0f; } } diff --git a/NPCs/JungleMimic.cs b/NPCs/JungleMimic.cs index 87a7fb7f..5a24ac26 100644 --- a/NPCs/JungleMimic.cs +++ b/NPCs/JungleMimic.cs @@ -1,4 +1,3 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -31,17 +30,12 @@ public override void SetDefaults() public override void NPCLoot() { - Helper.DropItems(npc.position, npc.Size, new Drop(mod.ItemType("SporeBlade"), 1, 1), new Drop(mod.ItemType("TechnologyofDionysus"), 1, 2), new Drop(mod.ItemType("LivingWoodThreepeater"), 1, 2), new Drop(mod.ItemType("UnfathomableFlower"), 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)); + Helper.DropItems(npc.position, npc.Size, new Drop(mod.ItemType("SporeBlade"), 1, 1), new Drop(mod.ItemType("TechnologyofDionysus"), 1, 2), new Drop(mod.ItemType("LivingWoodThreepeater"), 1, 2), new Drop(mod.ItemType("UnfathomableFlower"), 1, 1)); + this.NewItem(ItemID.GreaterHealingPotion, Main.rand.Next(10)); + this.NewItem(ItemID.GreaterManaPotion, Main.rand.Next(10)); } 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)) && Main.hardMode && spawnInfo.player.ZoneJungle && y > Main.rockLayer ? 0.003f : 0f; - } + => (Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && spawnInfo.player.ZoneJungle && spawnInfo.spawnTileY > Main.rockLayer ? 0.003f : 0f; } } \ No newline at end of file diff --git a/NPCs/JungleMimicSummon.cs b/NPCs/JungleMimicSummon.cs deleted file mode 100644 index 66f6d5dd..00000000 --- a/NPCs/JungleMimicSummon.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace Tremor.NPCs -{ - // Example Soul of Light/Soul of Night style NPC summon - public class JungleMimicSummon : ModPlayer - { - public int LastChest; - - // This doesn't make sense, but this is around where this check happens in Vanilla Terraria. - public override void PreUpdateBuffs() - { - if (Main.netMode != 1) - { - if (player.chest == -1 && LastChest >= 0 && Main.chest[LastChest] != null) - { - int x2 = Main.chest[LastChest].x; - int y2 = Main.chest[LastChest].y; - ChestItemSummonCheck(x2, y2, mod); - } - LastChest = player.chest; - } - } - - public static bool ChestItemSummonCheck(int x, int y, Mod mod) - { - if (Main.netMode == 1) - { - return false; - } - int num = Chest.FindChest(x, y); - if (num < 0) - { - return false; - } - int numberJungleKey = 0; - int numberOtherItems = 0; - ushort tileType = Main.tile[Main.chest[num].x, Main.chest[num].y].type; - int tileStyle = Main.tile[Main.chest[num].x, Main.chest[num].y].frameX / 36; - if (TileID.Sets.BasicChest[tileType] && (tileStyle < 5 || tileStyle > 6)) - { - for (int i = 0; i < 40; i++) - { - if (Main.chest[num].item[i] != null && Main.chest[num].item[i].type > 0) - { - if (Main.chest[num].item[i].type == mod.ItemType("KeyofTwilight")) - { - numberJungleKey += Main.chest[num].item[i].stack; - } - else - { - numberOtherItems++; - } - } - } - } - if (numberOtherItems == 0 && numberJungleKey == 1) - { - if (TileID.Sets.BasicChest[Main.tile[x, y].type]) - { - if (Main.tile[x, y].frameX % 36 != 0) - { - x--; - } - if (Main.tile[x, y].frameY % 36 != 0) - { - y--; - } - int number = Chest.FindChest(x, y); - for (int j = x; j <= x + 1; j++) - { - for (int k = y; k <= y + 1; k++) - { - if (Main.tile[j, k].type == 21) - { - Main.tile[j, k].active(false); - } - } - } - for (int l = 0; l < 40; l++) - { - Main.chest[num].item[l] = new Item(); - } - Chest.DestroyChest(x, y); - NetMessage.SendData(34, -1, -1, null, 1, x, y, 0f, number, 0, 0); - NetMessage.SendTileSquare(-1, x, y, 3); - } - int npcToSpawn = mod.NPCType("JungleMimic"); - int npcIndex = NPC.NewNPC(x * 16 + 16, y * 16 + 32, npcToSpawn, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[npcIndex].whoAmI = npcIndex; - NetMessage.SendData(23, -1, -1, null, npcIndex, 0f, 0f, 0f, 0, 0, 0); - Main.npc[npcIndex].BigMimicSpawnSmoke(); - } - return false; - } - } -} diff --git a/NPCs/JungleSpirit.cs b/NPCs/JungleSpirit.cs index 9ff186f9..565b3bce 100644 --- a/NPCs/JungleSpirit.cs +++ b/NPCs/JungleSpirit.cs @@ -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 JungleSpirit : ModNPC { public override void SetStaticDefaults() @@ -34,34 +34,19 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("JungleSpiritBanner"); } - 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/JungleSpiritGore"), 1f); } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneJungle && y > Main.rockLayer ? 0.005f : 0f; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneJungle && spawnInfo.spawnTileY > Main.rockLayer ? 0.005f : 0f; } } diff --git a/NPCs/Knight.cs b/NPCs/Knight.cs index dfa39a8c..b3fd9d57 100644 --- a/NPCs/Knight.cs +++ b/NPCs/Knight.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { [AutoloadHead] @@ -46,53 +49,35 @@ public override void SetDefaults() animationType = NPCID.GoblinTinkerer; } - - public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - return true; - } - - + public override bool CanTownNPCSpawn(int numTownNPCs, int money) => true; + public override string TownNPCName() { - switch (WorldGen.genRand.Next(5)) + string[] names = { - case 0: - return "Wheatly"; - case 1: - return "Daniel"; - case 2: - return "Crox"; - case 3: - return "Geralt"; - case 4: - return "Roland"; - case 5: - return "Rishel"; - default: - return "Hodor"; - } + "Wheatly", + "Daniel", + "Crox", + "Geralt", + "Roland", + "Hodor" + }; + return names.TakeRandom(); } public override string GetChat() { - switch (Main.rand.Next(6)) + string[] chats = { - case 0: - return "Well met, brave adventurer."; - case 1: - return "A balanced weapon can mean the difference between victory and defeat."; - case 2: - return "I am not overly fond of the bovine hordes. Best to leave them alone really."; - case 3: - return "Do you have a weapon? Needs about 20% more coolness!"; - case 4: - return "Hail and good morrow my Liege!"; - case 5: - return "I was in a strange castle one day. There were mechanical things saying EXTERMINATE. Were they your minions?"; - default: - return "Have you ever met a knight whose name is Sir Uncle Slime? He is best friend of mine."; - } + "Well met, brave adventurer.", + "A balanced weapon can mean the difference between victory and defeat.", + "I am not overly fond of the bovine hordes. Best to leave them alone, really.", + "Do you have a weapon? Needs about 20% more coolness!", + "Hail and good morrow my Liege!", + "I was in a strange castle one day. There were mechanical things saying EXTERMINATE. Were they your minions?", + "Have you ever met a knight whose name is Sir Uncle Slime? He is a good friend of mine." + }; + return chats.TakeRandom(); } public override void SetChatButtons(ref string button, ref string button2) @@ -102,56 +87,40 @@ 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("ThrowingAxe")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("RustySword")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("RipperKnife")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (NPC.downedBoss1) { - shop.item[nextSlot].SetDefaults(mod.ItemType("TombRaider")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("SpikeShield")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } if (NPC.downedBoss2) { - shop.item[nextSlot].SetDefaults(mod.ItemType("TwilightHorns")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("ToxicRazorknife")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } if (NPC.downedBoss3) { - shop.item[nextSlot].SetDefaults(mod.ItemType("NecromancerClaymore")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("Shovel")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } + if (Main.hardMode) { - shop.item[nextSlot].SetDefaults(mod.ItemType("GoldenThrowingAxe")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + + if(Main.bloodMoon) + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } if (NPC.downedMechBossAny) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("PrizmaticSword")); - nextSlot++; - } - if (Main.hardMode && Main.bloodMoon) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("Oppressor")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } public override void TownNPCAttackStrength(ref int damage, ref float knockback) @@ -168,7 +137,7 @@ public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCo public override void TownNPCAttackProj(ref int projType, ref int attackDelay) { - projType = mod.ProjectileType("ThrowingAxe"); + projType = mod.ProjectileType(); attackDelay = 4; } @@ -183,12 +152,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/KnightGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/KnightGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/KnightGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/KnightGore{i+1}"), 1f); } } } diff --git a/NPCs/KnightZombie.cs b/NPCs/KnightZombie.cs index 9b4f2bb5..d9cf2ce9 100644 --- a/NPCs/KnightZombie.cs +++ b/NPCs/KnightZombie.cs @@ -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 KnightZombie : ModNPC { public override void SetStaticDefaults() @@ -30,10 +32,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 4, 7); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(25) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -41,9 +43,8 @@ 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/ZombieGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/KnightZombieGore1"), 1f); @@ -52,25 +53,7 @@ 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(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("KnightHelmet")); - }; - } - } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.1f : 0f; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/KnightZombieSword.cs b/NPCs/KnightZombieSword.cs index cb48fe60..354f4dcd 100644 --- a/NPCs/KnightZombieSword.cs +++ b/NPCs/KnightZombieSword.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class KnightZombieSword : ModNPC @@ -33,25 +36,15 @@ public override void SetDefaults() public override void AI() { if (npc.frame.Y <= 204) - { npc.width = 30; - } if (npc.frame.Y > 204) - { npc.width = 70; - } - } - - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void NPCLoot() { - return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 0.01f : 0f; + if (Main.rand.Next(25) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -59,9 +52,8 @@ 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/ZombieGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/KnightZombieGore1"), 1f); @@ -70,20 +62,7 @@ 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(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("KnightHelmet")); - }; - } - } - + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 0.01f : 0f; } } diff --git a/NPCs/LadyMoon.cs b/NPCs/LadyMoon.cs index e735bdf8..6aee24f1 100644 --- a/NPCs/LadyMoon.cs +++ b/NPCs/LadyMoon.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { [AutoloadHead] @@ -47,53 +50,37 @@ public override void SetDefaults() } public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - if (NPC.downedMoonlord) - { - return true; - } - return false; - } + => NPC.downedMoonlord; public override string TownNPCName() { - switch (WorldGen.genRand.Next(4)) + string[] names = { - case 0: - return "Atria"; - case 1: - return "Mintaka"; - case 2: - return "Nashira"; - case 3: - return "Rana"; - case 4: - return "Talita"; - case 5: - return "Zosma"; - default: - return "Pleyona"; - } + "Atria", + "Mintaka", + "Nashira", + "Rana", + "Talita", + "Zosma", + "Pleyona" + }; + return names.TakeRandom(); } public override string GetChat() { - switch (Main.rand.Next(6)) + string[] chats = { - case 0: - return "There are so many beautiful things in this world! What can be more beautiful than a big shining star? Maybe only an exploding big shining star!"; - case 1: - return "I hope this world don't have crazy kings who wanna kill you? Aren't you one of them!?"; - case 2: - return "I have heard about an space station called Death Star that can destroy any planet or star! Can you show me this station? "; - case 3: - return "I believe I can fly! I believe I can touch the sk-... Sorry, I forgot that I'm not alone here!"; - case 4: - return "How are you going to call a man that watches an exploding star? A STARk man!"; - default: - return "Planets are burning, stars are exploding, but my prices for my spacy things are not changing! "; - } + "There are so many beautiful things in this world! What can be more beautiful than a big shining star? Maybe only an exploding big shining star!", + "I hope this world doesn't have crazy kings that want to kill you. You're not one of them, are you!?", + "I have heard about an space station called Death Star that can destroy any planet or star! Can you show me this station?", + "I believe I can fly! I believe I can touch the sk-... Sorry, I forgot that I'm not alone here!", + "What do you call a man who watches an exploding star? A STARk man!", + "I was in a strange castle one day. There were mechanical things saying EXTERMINATE. Were they your minions?", + "Planets are burning, stars are exploding, but the prices for my spacy things are not changing!" + }; + return chats.TakeRandom(); } public override void SetChatButtons(ref string button, ref string button2) @@ -103,40 +90,22 @@ 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("DimensionalTopHat")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("ExtraterrestrialRubies")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("UnchargedBand")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType("DimensionalTopHat")); + shop.AddUniqueItem(ref nextSlot, mod.ItemType("ExtraterrestrialRubies")); + shop.AddUniqueItem(ref nextSlot, mod.ItemType("UnchargedBand")); if (!Main.dayTime) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("ManaBooster")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType("ManaBooster")); if (Main.dayTime) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("HealthBooster")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType("HealthBooster")); if (Main.bloodMoon) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("ChainedRocket")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType("ChainedRocket")); if (Main.eclipse) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("Infusion")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType("Infusion")); } public override void TownNPCAttackStrength(ref int damage, ref float knockback) @@ -163,18 +132,15 @@ public override void TownNPCAttackProjSpeed(ref float multiplier, ref float grav randomOffset = 2f; } - 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/FarmerGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FarmerGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FarmerGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/FarmerGore{i+1}"), 1f); } } } diff --git a/NPCs/Leprechaun.cs b/NPCs/Leprechaun.cs index d1c2119b..b3071fe6 100644 --- a/NPCs/Leprechaun.cs +++ b/NPCs/Leprechaun.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class Leprechaun : ModNPC @@ -29,20 +30,13 @@ public override void SetDefaults() animationType = NPCID.BigMimicHallow; } - 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, 31, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, 220, 1f); Gore.NewGore(npc.position, npc.velocity, 221, 1f); Gore.NewGore(npc.position, npc.velocity, 222, 1f); @@ -50,11 +44,6 @@ public override void HitEffect(int hitDirection, double damage) } 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.0007f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileY > Main.rockLayer ? 0.0007f : 0f; } } \ No newline at end of file diff --git a/NPCs/LihzahrdWarrior.cs b/NPCs/LihzahrdWarrior.cs index 6acf0f3f..b335e72d 100644 --- a/NPCs/LihzahrdWarrior.cs +++ b/NPCs/LihzahrdWarrior.cs @@ -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 LihzahrdWarrior : ModNPC { public override void SetStaticDefaults() @@ -33,24 +33,10 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("LihzahrdWarriorBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2766); - } - } + if (Main.rand.Next(6) == 0) + this.NewItem(ItemID.LunarTabletFragment); } public override void HitEffect(int hitDirection, double damage) @@ -58,9 +44,8 @@ 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/LWGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/LWGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/LWGore2"), 1f); @@ -70,11 +55,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && (tile == 226) && NPC.downedMoonlord && y > Main.rockLayer ? 0.01f : 0f; - } + => Main.hardMode && spawnInfo.spawnTileType == TileID.LihzahrdBrick && NPC.downedMoonlord && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/LittleMushroomBug.cs b/NPCs/LittleMushroomBug.cs index 6d00a3b2..283329dd 100644 --- a/NPCs/LittleMushroomBug.cs +++ b/NPCs/LittleMushroomBug.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { @@ -32,31 +33,19 @@ public override void SetDefaults() npc.DeathSound = SoundID.NPCDeath57; } - 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 < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 67, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 67, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 67, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } } } diff --git a/NPCs/Lizard.cs b/NPCs/Lizard.cs index f9f5bf81..f7469ae9 100644 --- a/NPCs/Lizard.cs +++ b/NPCs/Lizard.cs @@ -4,7 +4,6 @@ namespace Tremor.NPCs { - public class Lizard : ModNPC { public override void SetStaticDefaults() @@ -29,12 +28,6 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 0); } - 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) diff --git a/NPCs/Luminion.cs b/NPCs/Luminion.cs index de25d3f9..fcdaf52f 100644 --- a/NPCs/Luminion.cs +++ b/NPCs/Luminion.cs @@ -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 Luminion : ModNPC { public override void SetStaticDefaults() @@ -33,33 +35,14 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("LuminionBanner"); } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(4) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Squorb"), Main.rand.Next(1, 2)); - } - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3467, Main.rand.Next(3, 8)); - } - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LunarRoot"), Main.rand.Next(2, 4)); - } - } + if (Main.rand.Next(4) == 0) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); + if (Main.rand.NextBool()) + this.NewItem(ItemID.LunarBar, Main.rand.Next(3, 8)); + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType(), Main.rand.Next(2, 4)); } public override void HitEffect(int hitDirection, double damage) @@ -67,22 +50,14 @@ 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, 74, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/LuminionGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/LuminionGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/LuminionGore2"), 1f); - } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.01f : 0f; - } + => Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/MagiumFlyer.cs b/NPCs/MagiumFlyer.cs index ae37ddf2..e3e4d964 100644 --- a/NPCs/MagiumFlyer.cs +++ b/NPCs/MagiumFlyer.cs @@ -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 MagiumFlyer : ModNPC { public override void SetStaticDefaults() @@ -14,8 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - const int SpeedMulti = 3; // �����⥫� ᪮��� - public override void SetDefaults() { npc.lifeMax = 100; @@ -36,20 +34,12 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("MagiumFlayerBanner"); } - 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 < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 59, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } else { @@ -63,6 +53,5 @@ public override void HitEffect(int hitDirection, double damage) } } } - } } \ No newline at end of file diff --git a/NPCs/MagiumKeeper.cs b/NPCs/MagiumKeeper.cs index 357fab15..739f3961 100644 --- a/NPCs/MagiumKeeper.cs +++ b/NPCs/MagiumKeeper.cs @@ -1,10 +1,16 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { + /* + * Rework AI into something more comprehensible and functional. + */ public class MagiumKeeper : ModNPC { public override void SetStaticDefaults() @@ -31,13 +37,6 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("MagiumKeeperBanner"); } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() { if (npc.ai[3] < 0f) @@ -267,20 +266,10 @@ public override void AI() 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MagiumShard"), Main.rand.Next(5, 12)); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("RuneBar"), Main.rand.Next(6, 16)); - }; - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(5, 12)); + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(6, 16)); } public override void HitEffect(int hitDirection, double damage) @@ -308,11 +297,6 @@ public override void HitEffect(int hitDirection, double damage) } 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)) && Main.hardMode && y > Main.rockLayer ? 0.0003f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.0003f : 0f; } } diff --git a/NPCs/MagiumSword.cs b/NPCs/MagiumSword.cs index 13d07e2f..3dc1019e 100644 --- a/NPCs/MagiumSword.cs +++ b/NPCs/MagiumSword.cs @@ -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 MagiumSword : ModNPC { public override void SetStaticDefaults() @@ -32,20 +32,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 0); } - public override void AI() { if (Main.rand.Next(6) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 59, 0f, 0f, 200, npc.color, 2f); - Main.dust[num706].velocity *= 0.3f; - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 59, 0f, 0f, 200, npc.color, 2f)].velocity *= 0.3f; } public override void HitEffect(int hitDirection, double damage) @@ -53,13 +43,8 @@ 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, 59, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } } - - - } } \ No newline at end of file diff --git a/NPCs/MagmaLeechBody.cs b/NPCs/MagmaLeechBody.cs index 1c14c694..941ad103 100644 --- a/NPCs/MagmaLeechBody.cs +++ b/NPCs/MagmaLeechBody.cs @@ -1,18 +1,19 @@ -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; + namespace Tremor.NPCs { public class MagmaLeechBody : ModNPC { - public override void SetStaticDefaults() { DisplayName.SetDefault("Magma Leech"); } + public override void SetDefaults() { npc.lifeMax = 250; @@ -34,14 +35,11 @@ public override void SetDefaults() public override void OnHitPlayer(Player player, int damage, bool crit) { if (Main.rand.NextBool()) - { - player.AddBuff(24, 180, true); - } + player.AddBuff(BuffID.OnFire, 180, true); } public override void AI() { - if (Main.rand.Next(3) == 0) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); @@ -56,6 +54,7 @@ public override void AI() npc.active = false; } } + public override bool CheckActive() { return false; @@ -64,6 +63,7 @@ public override bool CheckActive() { return false; } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D drawTexture = Main.npcTexture[npc.type]; diff --git a/NPCs/MagmaLeechHead.cs b/NPCs/MagmaLeechHead.cs index 1422c264..106c9b65 100644 --- a/NPCs/MagmaLeechHead.cs +++ b/NPCs/MagmaLeechHead.cs @@ -1,15 +1,16 @@ using System; -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; + namespace Tremor.NPCs { public class MagmaLeechHead : ModNPC { - public override void SetStaticDefaults() { DisplayName.SetDefault("Magma Leech"); @@ -52,46 +53,32 @@ public override void SetDefaults() npc.lavaImmune = true; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (Main.rand.NextBool()) - { - player.AddBuff(24, 180, true); - } - } - - public override void AI() { - if (Main.rand.Next(3) == 0) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); } - npc.position += npc.velocity * (2 - 1); + npc.position += npc.velocity; - if (!TailSpawned) + if (!TailSpawned && Main.netMode != 1) { int Previous = npc.whoAmI; - for (int num36 = 0; num36 < 14; num36++) + for (int i = 0; i < 14; i++) { - int lol = 0; - if (num36 >= 0 && num36 < 13) - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.width / 2), mod.NPCType("MagmaLeechBody"), npc.whoAmI); - } + int newNPCIndex = 0; + if (i < 13) + newNPCIndex = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.width / 2), mod.NPCType("MagmaLeechBody"), npc.whoAmI); else - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.width / 2), mod.NPCType("MagmaLeechTail"), npc.whoAmI); - } - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - //NetMessage.SendData(23, -1, -1, "", lol, 0f, 0f, 0f, 0); - Previous = lol; + newNPCIndex = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.width / 2), mod.NPCType("MagmaLeechTail"), npc.whoAmI); + Main.npc[newNPCIndex].realLife = npc.whoAmI; + Main.npc[newNPCIndex].ai[2] = npc.whoAmI; + Main.npc[newNPCIndex].ai[1] = Previous; + Main.npc[Previous].ai[0] = newNPCIndex; + NetMessage.SendData(23, -1, -1, null, newNPCIndex, 0f, 0f, 0f, 0, 0, 0); + Previous = newNPCIndex; } TailSpawned = true; } @@ -105,6 +92,13 @@ public override void AI() npc.netUpdate = true; } } + + public override void OnHitPlayer(Player player, int damage, bool crit) + { + if (Main.rand.NextBool()) + player.AddBuff(BuffID.OnFire, 180, true); + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D drawTexture = Main.npcTexture[npc.type]; diff --git a/NPCs/MagmaLeechTail.cs b/NPCs/MagmaLeechTail.cs index 299ceb5a..e40606d2 100644 --- a/NPCs/MagmaLeechTail.cs +++ b/NPCs/MagmaLeechTail.cs @@ -1,14 +1,14 @@ -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; + namespace Tremor.NPCs { public class MagmaLeechTail : ModNPC { - public override void SetStaticDefaults() { DisplayName.SetDefault("Magma Leech"); @@ -32,21 +32,8 @@ public override void SetDefaults() npc.lavaImmune = true; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (Main.rand.NextBool()) - { - player.AddBuff(24, 180, true); - } - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } public override void AI() { - if (Main.rand.Next(3) == 0) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 1f); @@ -60,6 +47,18 @@ public override void AI() npc.active = false; } } + + public override void OnHitPlayer(Player player, int damage, bool crit) + { + if (Main.rand.NextBool()) + player.AddBuff(BuffID.OnFire, 180, true); + } + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + return false; + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D drawTexture = Main.npcTexture[npc.type]; diff --git a/NPCs/Magus.cs b/NPCs/Magus.cs index a5f0af6c..4122ef25 100644 --- a/NPCs/Magus.cs +++ b/NPCs/Magus.cs @@ -1,9 +1,14 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; +using Tremor.Projectiles; + namespace Tremor.NPCs { public class Magus : ModNPC @@ -23,98 +28,74 @@ public override void SetDefaults() npc.width = 42; npc.height = 56; animationType = 29; - npc.aiStyle = 0; + npc.aiStyle = -1; npc.npcSlots = 15f; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; npc.value = Item.buyPrice(0, 0, 1, 21); } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - - int timer = 0; - int TimeToAnimation = 50; - int Frame; + public override void AI() { - if ((int)(Main.time % 180) == 0) + if ((int)Main.time % 180 == 0) { - PlayAnimation(); DoAI(); Teleport(); } } - public void PlayAnimation() - { - if (--TimeToAnimation <= 0) - { - if (++Frame > 3) - Frame = 1; - TimeToAnimation = 50; - npc.frame = GetFrame(Frame); - } - } - - Rectangle GetFrame(int Num) - { - return new Rectangle(0, npc.frame.Height * (Num - 1), npc.frame.Width, npc.frame.Height); - } - public void Teleport() { - for (int Num = 0; Num < 10; Num++) - { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 68, npc.velocity.X + Main.rand.Next(-10, 10), npc.velocity.Y + Main.rand.Next(-10, 10), 5, npc.color, 2.6f); - Main.dust[dust].noGravity = true; - } + for (int i = 0; i < 10; i++) + Main.dust[Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 68, npc.velocity.X + Main.rand.Next(-10, 10), npc.velocity.Y + Main.rand.Next(-10, 10), 5, npc.color, 2.6f)].noGravity = true; + npc.position.X = (Main.player[npc.target].position.X - 500) + Main.rand.Next(1000); npc.position.Y = (Main.player[npc.target].position.Y - 500) + Main.rand.Next(1000); } public void DoAI() { + if (Main.netMode == 1) return; + float SpeedX = Main.LocalPlayer.Center.X - npc.Center.X; float SpeedY = Main.LocalPlayer.Center.Y - npc.Center.Y; float Length = (float)Math.Sqrt(SpeedX * SpeedX + SpeedY * SpeedY); float Speed = 8; - float Num = Speed / Length; - SpeedX = SpeedX * Num; - SpeedY = SpeedY * Num; - int Proj = Projectile.NewProjectile(npc.Center.X - 10f, npc.Center.Y, SpeedX, SpeedY, mod.ProjectileType("MagusBall"), 14, 1f, Main.myPlayer); + Length = Speed / Length; + SpeedX = SpeedX * Length; + SpeedY = SpeedY * Length; + int Proj = Projectile.NewProjectile(npc.Center.X - 10f, npc.Center.Y, SpeedX, SpeedY, mod.ProjectileType(), 14, 1f, Main.myPlayer); Main.projectile[Proj].timeLeft = 300; Main.projectile[Proj].netUpdate = true; } + public override void FindFrame(int frameHeight) + { + if (npc.frameCounter++ >= 50) + { + npc.frame.Y = (npc.frame.Y + frameHeight) % (Main.npcFrameCount[npc.type] * frameHeight); + npc.frameCounter = 0; + } + } + public override void NPCLoot() { if (Main.invasionType == InvasionID.GoblinArmy) { - Main.invasionProgress++; + Main.invasionSize -= 1; + if (Main.invasionSize < 0) + Main.invasionSize = 0; + if (Main.netMode != 1) + Main.ReportInvasionProgress(Main.invasionSizeStart - Main.invasionSize, Main.invasionSizeStart, InvasionID.GoblinArmy + 3, 0); + if (Main.netMode == 2) + NetMessage.SendData(78, -1, -1, null, Main.invasionProgress, Main.invasionProgressMax, Main.invasionProgressIcon, 0f, 0, 0, 0); } - 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(50) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MagusTome")); - } - } + if (Main.rand.Next(50) == 0) + this.NewItem(mod.ItemType()); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (NPC.AnyNPCs(26) || NPC.AnyNPCs(27) || NPC.AnyNPCs(28) || NPC.AnyNPCs(29)) && Main.hardMode && y < Main.worldSurface ? 0.08f : 0f; - } + => Main.invasionType == InvasionID.GoblinArmy && Main.hardMode && spawnInfo.spawnTileY < Main.worldSurface ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/MechanicalFirefly.cs b/NPCs/MechanicalFirefly.cs index a8673796..34863414 100644 --- a/NPCs/MechanicalFirefly.cs +++ b/NPCs/MechanicalFirefly.cs @@ -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 MechanicalFirefly : ModNPC { public override void SetStaticDefaults() @@ -34,20 +34,13 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("MechanicalFireflyBanner"); } - 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, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, 61, 1f); Gore.NewGore(npc.position, npc.velocity, 61, 1f); Gore.NewGore(npc.position, npc.velocity, 62, 1f); @@ -57,11 +50,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && Main.bloodMoon && y < Main.worldSurface ? 0.007f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.007f : 0f; } } \ No newline at end of file diff --git a/NPCs/MeteoriteGolem.cs b/NPCs/MeteoriteGolem.cs index 83575f5a..60df8982 100644 --- a/NPCs/MeteoriteGolem.cs +++ b/NPCs/MeteoriteGolem.cs @@ -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 MeteoriteGolem : ModNPC { public override void SetStaticDefaults() @@ -37,28 +39,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("MeteoriteGolemBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 116, 3); - } - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FireFragment"), 3); - } - } + if (Main.rand.NextBool()) + this.NewItem(ItemID.Meteorite, 3); + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType(), 3); } public override void HitEffect(int hitDirection, double damage) @@ -73,6 +59,7 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/MGGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/MGGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/MGGore2"), 1f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -82,11 +69,6 @@ public override void HitEffect(int hitDirection, double damage) } 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.player.ZoneMeteor ? 0.005f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneMeteor ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/MightyNimbus.cs b/NPCs/MightyNimbus.cs index aa94d1f4..0ea02e04 100644 --- a/NPCs/MightyNimbus.cs +++ b/NPCs/MightyNimbus.cs @@ -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 MightyNimbus : ModNPC { public override void SetStaticDefaults() @@ -38,12 +38,6 @@ public override void SetDefaults() bannerItem = mod.ItemType("MightyNimbusBanner"); } - 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) @@ -52,38 +46,32 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 2f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 2f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 3f); + for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 76, 0f, 0f, 200, npc.color, 1f); - } } } public override void AI() { - if (Main.rand.Next(1000) == 0) + if (Main.netMode != 1 && Main.rand.Next(1000) == 0) { - NPC.NewNPC((int)npc.position.X - 50, (int)npc.position.Y, 250); - NPC.NewNPC((int)npc.position.X + 50, (int)npc.position.Y, 250); + NPC.NewNPC((int)npc.position.X - 50, (int)npc.position.Y, NPCID.AngryNimbus); + NPC.NewNPC((int)npc.position.X + 50, (int)npc.position.Y, NPCID.AngryNimbus); } + if (Main.rand.Next(700) == 0) - { Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, Main.rand.Next(41, 44)); - } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && NPC.downedMoonlord && Helper.NoZoneAllowWater(spawnInfo)) && Main.raining && y < Main.worldSurface ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && NPC.downedMoonlord && Helper.NoZoneAllowWater(spawnInfo) && Main.raining && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Minotaur.cs b/NPCs/Minotaur.cs index 4416c011..565c9f85 100644 --- a/NPCs/Minotaur.cs +++ b/NPCs/Minotaur.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class Minotaur : ModNPC @@ -30,23 +33,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("MinotaurBanner"); } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MinotaurHorn")); - }; - if (Main.rand.Next(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("NecroShield")); - }; - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -54,9 +46,8 @@ 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/MinotaurGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/MinotaurGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/MinotaurGore2"), 1f); @@ -66,11 +57,6 @@ public override void HitEffect(int hitDirection, double damage) } 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.player.ZoneDungeon && y > Main.rockLayer ? 0.005f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/MushroomCreature.cs b/NPCs/MushroomCreature.cs index d8b5ded0..d140d90b 100644 --- a/NPCs/MushroomCreature.cs +++ b/NPCs/MushroomCreature.cs @@ -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 MushroomCreature : ModNPC { public override void SetStaticDefaults() @@ -33,19 +33,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("MushroomCreatureBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() - { - + { if (Main.rand.Next(1000) == 0) - { Main.PlaySound(22, (int)npc.position.X, (int)npc.position.Y, 1); - } } public override void HitEffect(int hitDirection, double damage) @@ -53,18 +44,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.GoreType("Orc1Gore1"), 1f); } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && (tile == 70)) && y < Main.rockLayer ? 0.03f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && spawnInfo.spawnTileType == TileID.MushroomGrass && spawnInfo.spawnTileY < Main.rockLayer ? 0.03f : 0f; } } \ No newline at end of file diff --git a/NPCs/Naga.cs b/NPCs/Naga.cs index 31f3ea25..cfe93e9e 100644 --- a/NPCs/Naga.cs +++ b/NPCs/Naga.cs @@ -1,10 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { - public class Naga : ModNPC { public override void SetStaticDefaults() @@ -29,14 +30,18 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 5, 3, 2); } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(BuffID.Venom, 300, true); + } + 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/NagaGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/NagaGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/NagaGore2"), 1f); @@ -44,22 +49,9 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 59, hitDirection, -1f, 0, default(Color), 0.7f); - } } } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(70, 300, true); - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } } } \ No newline at end of file diff --git a/NPCs/NightTerror.cs b/NPCs/NightTerror.cs index 895cb7b8..bd9afbd5 100644 --- a/NPCs/NightTerror.cs +++ b/NPCs/NightTerror.cs @@ -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 NightTerror : ModNPC { public override void SetStaticDefaults() @@ -35,32 +37,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("NightTerrorBanner"); } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && Main.bloodMoon && y < Main.worldSurface ? 0.004f : 0f; - } - 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(40) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("AxeofExecutioner")); - } - } + if (Main.rand.Next(40) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -73,10 +53,10 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } + for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); Gore.NewGore(npc.position, npc.velocity, 99, 1f); @@ -86,11 +66,12 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Gore.NewGore(npc.position, npc.velocity, 99, 1f); - } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.004f : 0f; } } \ No newline at end of file diff --git a/NPCs/NightWalker.cs b/NPCs/NightWalker.cs index 38efed66..13e50cc1 100644 --- a/NPCs/NightWalker.cs +++ b/NPCs/NightWalker.cs @@ -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 NightWalker : ModNPC { public override void SetStaticDefaults() @@ -34,27 +36,8 @@ 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; - if (Main.rand.Next(23) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("PurplePuzzleFragment")); - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMechBossAny && !Main.dayTime ? 0.0005f : 0f; + if (Main.rand.Next(23) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -62,9 +45,8 @@ public override void HitEffect(int hitDirection, double damage) if (npc.life <= 0) { for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/NWGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/NWGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/NWGore2"), 1f); @@ -73,7 +55,7 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -81,5 +63,8 @@ public override void HitEffect(int hitDirection, double damage) } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMechBossAny && !Main.dayTime ? 0.0005f : 0f; } } \ No newline at end of file diff --git a/NPCs/NorthWind.cs b/NPCs/NorthWind.cs index 0687dc1f..7dae0ced 100644 --- a/NPCs/NorthWind.cs +++ b/NPCs/NorthWind.cs @@ -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 NorthWind : ModNPC { public override void SetStaticDefaults() @@ -35,28 +37,12 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("NorthWindBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FrostCore")); - }; - if (NPC.downedMoonlord && Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("IceSoul")); - } - } + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType()); + if (NPC.downedMoonlord && Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -77,13 +63,7 @@ public override void HitEffect(int hitDirection, double damage) } } - 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)) && Main.cloudAlpha > 0f && y < Main.worldSurface && spawnInfo.player.ZoneSnow ? 0.06f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && Main.cloudAlpha > 0f && spawnInfo.spawnTileY < Main.worldSurface && spawnInfo.player.ZoneSnow ? 0.06f : 0f; } } \ No newline at end of file diff --git a/NPCs/Observer.cs b/NPCs/Observer.cs index 9847ee18..1ae902d4 100644 --- a/NPCs/Observer.cs +++ b/NPCs/Observer.cs @@ -1,9 +1,11 @@ -using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { @@ -14,14 +16,12 @@ public override void SetStaticDefaults() DisplayName.SetDefault("Observer"); Main.npcFrameCount[npc.type] = 4; } + + const int ShootDamage = 20; + const float ShootKN = 1.0f; + const float ShootSpeed = 4; - const int ShootRate = 250; // - const int ShootDamage = 20; // . - const float ShootKN = 1.0f; // - const int ShootType = 100; // . - const float ShootSpeed = 4; // , , - - int TimeToShoot = ShootRate; // . + int TimeToShoot = 0; public override void SetDefaults() { @@ -41,28 +41,28 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 55, 9); banner = npc.type; bannerItem = mod.ItemType("ObserverBanner"); - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + TimeToShoot = 0; } public override void AI() { - // - if (--TimeToShoot <= 0 && npc.target != -1) Shoot(); // TimeToShot 1, TimeToShot < = 0, Shoot() + if (Main.netMode != 1 && TimeToShoot++ >= 250 && npc.target != -1) + { + Vector2 velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ShootSpeed; + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ProjectileID.DeathLaser, ShootDamage, ShootKN); + TimeToShoot = 0; + } } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void NPCLoot() { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && Main.bloodMoon && y < Main.worldSurface ? 0.006f : 0f; + if (Main.rand.Next(15) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(15) == 0) + this.NewItem(mod.ItemType()); } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -84,7 +84,7 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -93,38 +93,7 @@ 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(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Spearaxe")); - } - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ScarredReaper")); - }; - } - } - - void Shoot() - { - TimeToShoot = ShootRate; // - Vector2 velocity = VelocityFPTP(npc.Center, Main.player[npc.target].Center, ShootSpeed); // velocity ( ) - // 1 - - // 2 - - // 3 - - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, ShootDamage, ShootKN); - } - - Vector2 VelocityFPTP(Vector2 pos1, Vector2 pos2, float speed) - { - Vector2 move = pos2 - pos1; - return move * (speed / (float)Math.Sqrt(move.X * move.X + move.Y * move.Y)); - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.006f : 0f; } } \ No newline at end of file diff --git a/NPCs/OceanMimic.cs b/NPCs/OceanMimic.cs index 77414910..8906aaa4 100644 --- a/NPCs/OceanMimic.cs +++ b/NPCs/OceanMimic.cs @@ -1,4 +1,3 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -32,16 +31,11 @@ public override void SetDefaults() public override void NPCLoot() { Helper.DropItems(npc.position, npc.Size, new Drop(mod.ItemType("TheTide"), 1, 1), new Drop(mod.ItemType("TrueTrident"), 1, 1), new Drop(mod.ItemType("SharkRage"), 1, 1), new Drop(mod.ItemType("OceanAmulet"), 1, 1), new Drop(mod.ItemType("SquidTentacle"), 1, 1)); - 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)); + this.NewItem(ItemID.GreaterHealingPotion, Main.rand.Next(10)); + this.NewItem(ItemID.GreaterManaPotion, Main.rand.Next(10)); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && (tile == 53 || tile == 112 || tile == 116 || tile == 234) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.water) && Main.hardMode && y < Main.rockLayer && (x < 250 || x > Main.maxTilesX - 250) && !spawnInfo.playerSafe ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && (spawnInfo.spawnTileType == 53 || spawnInfo.spawnTileType == 112 || spawnInfo.spawnTileType == 116 || spawnInfo.spawnTileType == 234) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.water && Main.hardMode && spawnInfo.spawnTileY < Main.rockLayer && (spawnInfo.spawnTileX < 250 || spawnInfo.spawnTileX > Main.maxTilesX - 250) && !spawnInfo.playerSafe ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/OceanMimicSummon.cs b/NPCs/OceanMimicSummon.cs deleted file mode 100644 index 35b6ccd0..00000000 --- a/NPCs/OceanMimicSummon.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace Tremor.NPCs -{ - // Example Soul of Light/Soul of Night style NPC summon - public class OceanMimicSummon : ModPlayer - { - public int LastChest; - - // This doesn't make sense, but this is around where this check happens in Vanilla Terraria. - public override void PreUpdateBuffs() - { - if (Main.netMode != 1) - { - if (player.chest == -1 && LastChest >= 0 && Main.chest[LastChest] != null) - { - int x2 = Main.chest[LastChest].x; - int y2 = Main.chest[LastChest].y; - ChestItemSummonCheck(x2, y2, mod); - } - LastChest = player.chest; - } - } - - public static bool ChestItemSummonCheck(int x, int y, Mod mod) - { - if (Main.netMode == 1) - { - return false; - } - int num = Chest.FindChest(x, y); - if (num < 0) - { - return false; - } - int numberOceanKey = 0; - int numberOtherItems = 0; - ushort tileType = Main.tile[Main.chest[num].x, Main.chest[num].y].type; - int tileStyle = Main.tile[Main.chest[num].x, Main.chest[num].y].frameX / 36; - if (TileID.Sets.BasicChest[tileType] && (tileStyle < 5 || tileStyle > 6)) - { - for (int i = 0; i < 40; i++) - { - if (Main.chest[num].item[i] != null && Main.chest[num].item[i].type > 0) - { - if (Main.chest[num].item[i].type == mod.ItemType("KeyofOcean")) - { - numberOceanKey += Main.chest[num].item[i].stack; - } - else - { - numberOtherItems++; - } - } - } - } - if (numberOtherItems == 0 && numberOceanKey == 1) - { - if (TileID.Sets.BasicChest[Main.tile[x, y].type]) - { - if (Main.tile[x, y].frameX % 36 != 0) - { - x--; - } - if (Main.tile[x, y].frameY % 36 != 0) - { - y--; - } - int number = Chest.FindChest(x, y); - for (int j = x; j <= x + 1; j++) - { - for (int k = y; k <= y + 1; k++) - { - if (Main.tile[j, k].type == 21) - { - Main.tile[j, k].active(false); - } - } - } - for (int l = 0; l < 40; l++) - { - Main.chest[num].item[l] = new Item(); - } - Chest.DestroyChest(x, y); - NetMessage.SendData(34, -1, -1, null, 1, x, y, 0f, number, 0, 0); - NetMessage.SendTileSquare(-1, x, y, 3); - } - int npcToSpawn = mod.NPCType("OceanMimic"); - int npcIndex = NPC.NewNPC(x * 16 + 16, y * 16 + 32, npcToSpawn, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[npcIndex].whoAmI = npcIndex; - NetMessage.SendData(23, -1, -1, null, npcIndex, 0f, 0f, 0f, 0, 0, 0); - Main.npc[npcIndex].BigMimicSpawnSmoke(); - } - return false; - } - } -} diff --git a/NPCs/OmegaWolf.cs b/NPCs/OmegaWolf.cs index ec6be8a4..f9d51e10 100644 --- a/NPCs/OmegaWolf.cs +++ b/NPCs/OmegaWolf.cs @@ -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 OmegaWolf : ModNPC { public override void SetStaticDefaults() @@ -32,20 +34,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; - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("WolfPelt")); - } - if (Main.rand.Next(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FurHat")); - }; - } + if (Main.rand.Next(2) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(25) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -53,22 +45,16 @@ 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/OmegaWolfGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OmegaWolfGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WolfGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WolfGore1"), 1f); } } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneSnow && y < Main.worldSurface ? 0.02f : 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneSnow && spawnInfo.spawnTileY < Main.worldSurface ? 0.02f : 0f; } } \ No newline at end of file diff --git a/NPCs/Orc.cs b/NPCs/Orc.cs index a2bde810..4e54ddf9 100644 --- a/NPCs/Orc.cs +++ b/NPCs/Orc.cs @@ -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 Orc : ModNPC { public override void SetStaticDefaults() @@ -33,21 +35,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("OrcBanner"); } - 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/Orc1Gore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Orc1Gore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Orc1Gore3"), 1f); @@ -57,29 +51,13 @@ 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(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OrcishShield")); - } - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OrcishKnife")); - } - } + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedBoss1 && y < Main.worldSurface ? 0.1f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss1 && spawnInfo.spawnTileY < Main.worldSurface ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/OrcChampion.cs b/NPCs/OrcChampion.cs index 84b9e447..d56864c2 100644 --- a/NPCs/OrcChampion.cs +++ b/NPCs/OrcChampion.cs @@ -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 OrcChampion : ModNPC { public override void SetStaticDefaults() @@ -37,12 +37,6 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("OrcChampionBanner"); } - 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) @@ -50,12 +44,14 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OCGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OCGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OCGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OCGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OCGore4"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OCGore4"), 1f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -65,11 +61,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.005f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/OrcSkeleton.cs b/NPCs/OrcSkeleton.cs index 5bc7c64b..82716ea0 100644 --- a/NPCs/OrcSkeleton.cs +++ b/NPCs/OrcSkeleton.cs @@ -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 OrcSkeleton : ModNPC { public override void SetStaticDefaults() @@ -33,20 +33,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("OrcSkeletonBanner"); } - 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/OrcSkeletonGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OrcSkeletonGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OrcSkeletonGore2"), 1f); @@ -56,12 +49,6 @@ public override void HitEffect(int hitDirection, double damage) } 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)) && NPC.downedBoss1 && y > Main.rockLayer ? 0.01f : 0f; - } - + => Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss1 && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/OrcWarrior.cs b/NPCs/OrcWarrior.cs index 5bb08695..86bab191 100644 --- a/NPCs/OrcWarrior.cs +++ b/NPCs/OrcWarrior.cs @@ -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 OrcWarrior : ModNPC { public override void SetStaticDefaults() @@ -32,20 +34,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("OrcWarriorBanner"); } - 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/OrcWarriorGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OrcWarriorGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/OrcWarriorGore3"), 1f); @@ -56,37 +51,17 @@ 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("OrcishHelmet")); - } - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OrcishBreastplate")); - } - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OrcishGreaves")); - } - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OrcishBroadsword")); - } - } + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedBoss1 && !Main.dayTime && y < Main.worldSurface ? 0.1f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss1 && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/PGiantSlime.cs b/NPCs/PGiantSlime.cs index cb39efdd..139d2594 100644 --- a/NPCs/PGiantSlime.cs +++ b/NPCs/PGiantSlime.cs @@ -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 PGiantSlime : ModNPC { public override void SetStaticDefaults() @@ -33,10 +33,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 12, 15); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool()) + this.NewItem(23); } public override void HitEffect(int hitDirection, double damage) @@ -56,23 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && Main.hardMode && Helper.NoInvasion(spawnInfo) && NPC.downedMoonlord && Main.dayTime ? 0.02f : 0f; - } - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 23); - }; - } - } - + => spawnInfo.spawnTileY < Main.rockLayer && Main.hardMode && Helper.NoInvasion(spawnInfo) && NPC.downedMoonlord && Main.dayTime ? 0.02f : 0f; } } \ No newline at end of file diff --git a/NPCs/Parasprite.cs b/NPCs/Parasprite.cs index 45aeff88..e056f0c7 100644 --- a/NPCs/Parasprite.cs +++ b/NPCs/Parasprite.cs @@ -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 Parasprite : ModNPC { public override void SetStaticDefaults() @@ -37,31 +37,18 @@ 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/ParaspriteGore"), 1f); } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 59, hitDirection, -1f, 0, default(Color), 0.7f); - } } } - 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)) && y > Main.rockLayer ? 0.01f : 0f; - } + => (Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Peepers.cs b/NPCs/Peepers.cs index 8e1bc392..a577b076 100644 --- a/NPCs/Peepers.cs +++ b/NPCs/Peepers.cs @@ -1,12 +1,13 @@ -using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { - public class Peepers : ModNPC { public override void SetStaticDefaults() @@ -15,13 +16,12 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - const int ShootRate = 100; // - const int ShootDamage = 10; // . - const float ShootKN = 1.0f; // - const int ShootType = 100; // . - const float ShootSpeed = 4; // , , + const int ShootRate = 100; + const int ShootDamage = 10; + const float ShootKN = 1.0f; + const float ShootSpeed = 4; - int TimeToShoot = ShootRate; // . + int TimeToShoot = 0; public override void SetDefaults() { @@ -41,28 +41,27 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 8, 9); banner = npc.type; bannerItem = mod.ItemType("PeepersBanner"); - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + TimeToShoot = 0; } public override void AI() { - // - if (--TimeToShoot <= 0 && npc.target != -1) Shoot(); // TimeToShot 1, TimeToShot < = 0, Shoot() - } + if (Main.netMode != 1 && TimeToShoot++ >= ShootRate && npc.target != -1) + { + Vector2 velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ShootSpeed; + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ProjectileID.DeathLaser, ShootDamage, ShootKN); + TimeToShoot = 0; + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void NPCLoot() { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.01f : 0f; + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType()); } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -77,9 +76,9 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PeepersGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PeepersGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PeepersGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/PeepersGore{i+1}"), 1f); } else { @@ -92,34 +91,7 @@ public override void HitEffect(int hitDirection, double damage) } } - void Shoot() - { - TimeToShoot = ShootRate; // - Vector2 velocity = VelocityFPTP(npc.Center, Main.player[npc.target].Center, ShootSpeed); // velocity ( ) - // 1 - - // 2 - - // 3 - - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, ShootDamage, ShootKN); - } - - Vector2 VelocityFPTP(Vector2 pos1, Vector2 pos2, float speed) - { - Vector2 move = pos2 - pos1; - return move * (speed / (float)Math.Sqrt(move.X * move.X + move.Y * move.Y)); - } - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("SharpenedTooth")); - }; - } - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Phabor.cs b/NPCs/Phabor.cs index 0f6f5a41..4459b2d7 100644 --- a/NPCs/Phabor.cs +++ b/NPCs/Phabor.cs @@ -1,12 +1,15 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { - public class Phabor : ModNPC { public override void SetStaticDefaults() @@ -15,13 +18,12 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - const int ShootRate = 500; // - const int ShootDamage = 20; // . - const float ShootKN = 1.0f; // - const int ShootType = 468; // . - const float ShootSpeed = 4; // , , + const int ShootRate = 500; + const int ShootDamage = 20; + const float ShootKN = 1.0f; + const float ShootSpeed = 4; - int TimeToShoot = ShootRate; // . + int TimeToShoot = 0; public override void SetDefaults() { @@ -41,42 +43,28 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 55, 9); // banner = npc.type; // Todo: bannerItem = mod.ItemType("PhaborBanner"); - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + TimeToShoot = 0; } public override void AI() { - // - if (--TimeToShoot <= 0 && npc.target != -1) Shoot(); // TimeToShot 1, TimeToShot < = 0, Shoot() + if (Main.netMode != 1 && TimeToShoot++ >= ShootRate && npc.target != -1) + { + Vector2 velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ShootSpeed; + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ProjectileID.CultistBossFireBallClone, ShootDamage, ShootKN); + + TimeToShoot = 0; + } } 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Gloomstone"), Main.rand.Next(6, 15)); - } - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(6, 16)); } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && Main.bloodMoon && y < Main.worldSurface ? 0.06f : 0f; - } public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -109,20 +97,7 @@ public override void HitEffect(int hitDirection, double damage) } } - void Shoot() - { - TimeToShoot = ShootRate; // - Vector2 velocity = VelocityFPTP(npc.Center, Main.player[npc.target].Center, ShootSpeed); // velocity ( ) - // 1 - - // 2 - - // 3 - - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, ShootDamage, ShootKN); - } - - Vector2 VelocityFPTP(Vector2 pos1, Vector2 pos2, float speed) - { - Vector2 move = pos2 - pos1; - return move * (speed / (float)Math.Sqrt(move.X * move.X + move.Y * move.Y)); - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && Main.hardMode && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.06f : 0f; } } \ No newline at end of file diff --git a/NPCs/Phantom.cs b/NPCs/Phantom.cs index b14170c2..b52dc720 100644 --- a/NPCs/Phantom.cs +++ b/NPCs/Phantom.cs @@ -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 Phantom : ModNPC { public override void SetStaticDefaults() @@ -14,8 +16,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - const int SpeedMulti = 3; // �����⥫� ᪮��� - public override void SetDefaults() { npc.lifeMax = 60; @@ -36,10 +36,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("PhantomBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool()) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType()); + if (Main.rand.Next(48) == 0) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -47,9 +49,7 @@ public override void HitEffect(int hitDirection, double damage) if (npc.life <= 0) { for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } else { @@ -62,30 +62,7 @@ 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("PhantomSoul")); - }; - if (Main.rand.Next(48) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("GloomTome")); - }; - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && Main.bloodMoon && y < Main.worldSurface ? 0.03f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.03f : 0f; } } \ No newline at end of file diff --git a/NPCs/PharaohCaster.cs b/NPCs/PharaohCaster.cs index bb51e534..61457953 100644 --- a/NPCs/PharaohCaster.cs +++ b/NPCs/PharaohCaster.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class PharaohCaster : ModNPC @@ -31,29 +32,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("PharaohCasterBanner"); } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && NPC.downedBoss1 && Main.dayTime && y < Main.worldSurface ? 0.01f : 0f; - } - 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PharaonGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PharaonGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PharaonGore2"), 1f); @@ -62,5 +47,7 @@ public override void HitEffect(int hitDirection, double damage) } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && NPC.downedBoss1 && Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } diff --git a/NPCs/Phobos.cs b/NPCs/Phobos.cs index 7868e956..85927bc1 100644 --- a/NPCs/Phobos.cs +++ b/NPCs/Phobos.cs @@ -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 Phobos : ModNPC { public override void SetStaticDefaults() @@ -44,40 +46,14 @@ public override void AI() } } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.05f : 0f; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("EyeofOblivion")); - } - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CarbonSteel"), Main.rand.Next(2, 15)); - } - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ToothofAbraxas"), Main.rand.Next(2, 16)); - } - } + if (Main.rand.NextBool()) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType()); + if (Main.rand.NextBool()) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType(), Main.rand.Next(2, 15)); + if (Main.rand.NextBool()) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType(), Main.rand.Next(2, 16)); } public override void HitEffect(int hitDirection, double damage) @@ -91,9 +67,8 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); } for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); - } + Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 3.7f); Dust.NewDust(npc.position, npc.width, npc.height, 70, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 3.7f); @@ -105,11 +80,12 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.05f : 0f; } } \ No newline at end of file diff --git a/NPCs/PixieQueenGuardian.cs b/NPCs/PixieQueenGuardian.cs index 93583028..797480a6 100644 --- a/NPCs/PixieQueenGuardian.cs +++ b/NPCs/PixieQueenGuardian.cs @@ -1,12 +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; + namespace Tremor.NPCs { - public class PixieQueenGuardian : ModNPC { public override void SetStaticDefaults() @@ -33,6 +33,14 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 9); } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + if (Main.rand.Next(3) == 0) + player.AddBuff(BuffID.Confused, 1800, true); + + if (Main.rand.Next(2) == 0) + player.AddBuff(BuffID.Slow, 1800, true); + } public override void HitEffect(int hitDirection, double damage) { @@ -42,33 +50,12 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 57, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 57, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 57, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 57, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } - } - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (Main.rand.Next(3) == 0) - { - player.AddBuff(BuffID.Confused, 1800, true); - } - - if (Main.rand.Next(2) == 0) - { - player.AddBuff(BuffID.Slow, 1800, true); } } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D drawTexture = Main.npcTexture[npc.type]; diff --git a/NPCs/PlagueSoul.cs b/NPCs/PlagueSoul.cs index b97cbf15..247ca4a4 100644 --- a/NPCs/PlagueSoul.cs +++ b/NPCs/PlagueSoul.cs @@ -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 PlagueSoul : ModNPC { public override void SetStaticDefaults() @@ -51,12 +51,5 @@ 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; - } - } } \ No newline at end of file diff --git a/NPCs/Polaris.cs b/NPCs/Polaris.cs index 7ed78551..e2f00d49 100644 --- a/NPCs/Polaris.cs +++ b/NPCs/Polaris.cs @@ -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 Polaris : ModNPC { public override void SetStaticDefaults() @@ -33,32 +35,14 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("PolarisBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FrostFreshness")); - }; - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FrostCore")); - }; - if (NPC.downedMoonlord && Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("IceSoul")); - } - } + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType()); + if (NPC.downedMoonlord && Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -70,11 +54,13 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.8f); } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PolarisGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PolarisGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PolarisGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PolarisGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PolarisGore3"), 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 2f); Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); @@ -83,11 +69,6 @@ public override void HitEffect(int hitDirection, double damage) } 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)) && Main.cloudAlpha > 0f && y < Main.worldSurface && spawnInfo.player.ZoneSnow ? 0.03f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && Main.cloudAlpha > 0f && spawnInfo.spawnTileY < Main.worldSurface && spawnInfo.player.ZoneSnow ? 0.03f : 0f; } } \ No newline at end of file diff --git a/NPCs/PossessedHornet1.cs b/NPCs/PossessedHornet1.cs index 575dc566..2241e0cc 100644 --- a/NPCs/PossessedHornet1.cs +++ b/NPCs/PossessedHornet1.cs @@ -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 PossessedHornet1 : ModNPC { public override void SetStaticDefaults() @@ -34,24 +36,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("PossessedHornetBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("PurpleQuartz"), 2); - } - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), 2); } public override void HitEffect(int hitDirection, double damage) @@ -59,21 +47,14 @@ 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, mod.DustType(), 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PHGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PHGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PHGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/PHGore{i+1}"), 1f); } } 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.player.ZoneJungle && NPC.downedMoonlord && Main.hardMode && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneJungle && NPC.downedMoonlord && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/PossessedHornet2.cs b/NPCs/PossessedHornet2.cs index 025f07df..0d8cddef 100644 --- a/NPCs/PossessedHornet2.cs +++ b/NPCs/PossessedHornet2.cs @@ -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 PossessedHornet2 : ModNPC { public override void SetStaticDefaults() @@ -34,24 +36,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("PossessedHornetBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("PurpleQuartz"), 2); - } - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), 2); } public override void HitEffect(int hitDirection, double damage) @@ -59,9 +47,8 @@ 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, mod.DustType(), 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PHGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PHGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PHGore4"), 1f); @@ -69,11 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } 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.player.ZoneJungle && NPC.downedMoonlord && Main.hardMode && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneJungle && NPC.downedMoonlord && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/PossessedHound.cs b/NPCs/PossessedHound.cs index 25f4ff0b..eb74f003 100644 --- a/NPCs/PossessedHound.cs +++ b/NPCs/PossessedHound.cs @@ -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 PossessedHound : ModNPC { public override void SetStaticDefaults() @@ -30,33 +32,16 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 15, 0); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - public override void AI() { - if (Main.rand.Next(1000) == 0) - { Main.PlaySound(22, (int)npc.position.X, (int)npc.position.Y, 1); - } } 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ConcentratedEther")); - } - } + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -64,22 +49,16 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HoundGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HoundGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HoundGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HoundGore2"), 1f); } } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && Main.bloodMoon && y < Main.worldSurface ? 0.007f : 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.007f : 0f; } } \ No newline at end of file diff --git a/NPCs/Professor.cs b/NPCs/Professor.cs index be358413..c64a2ea1 100644 --- a/NPCs/Professor.cs +++ b/NPCs/Professor.cs @@ -1,8 +1,13 @@ -using Microsoft.Xna.Framework; +using System.Linq; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { [AutoloadHead] @@ -46,56 +51,39 @@ public override void SetDefaults() animationType = NPCID.GoblinTinkerer; } + public override bool CanTownNPCSpawn(int numTownNPCs, int money) + => Main.hardMode; + public override string TownNPCName() { - switch (WorldGen.genRand.Next(5)) + string[] names = { - case 0: - return "James"; - case 1: - return "Harold"; - case 2: - return "Steven"; - case 3: - return "David"; - case 4: - return "John"; - case 5: - return "Brus Bunner"; - default: - return "Alfred"; - } + "James", + "Harold", + "Steven", + "David", + "John", + "Brus Bunner", + "Alfred" + }; + return names.TakeRandom(); } public override string GetChat() { - switch (Main.rand.Next(6)) + string[] chats = { - case 0: - return "Don't pay attention to my appearance. This is just the result of a failed experiment."; - case 1: - return "What do you have? Carrot? Oh, never mind."; - case 2: - return "Imagine that in all those rabbits that you have killed were imprisoned soul of common people! Just think about it."; - case 3: - return "Someday we'll all get into the warm embrace of death. Bring me some more carrot soup before this happens."; - case 4: - return "Magic allows you to do what cannot be done scientifically. The main thing is not to overdo it, if you know what I mean."; - case 5: - return "I don't like people that like how wizards get rabbits out of their magic hats. It's horrible!"; - default: - return "I studied the anomalies in this world long time ago. Exactly during this I became the anomaly myself. Funny."; - } - } - - public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - if (Main.hardMode) - return true; - return false; + "Don't mind my appearance. This is just the result of a failed experiment.", + "Do you have a carrot? Oh, never mind.", + "Imagine that in all those rabbits that you have killed were imprisoned soul of common people! Just think about it...", + "Someday we'll all feel the cold embrace of death. Bring me some more carrot soup before this happens.", + "Magic allows you to do what cannot be done scientifically. The main thing is not to overdo it, if you know what I mean.", + "I don't like people that like how wizards 'magically' grab rabbits out of their magic hats. It's horrible!", + "I studied the anomalies in this world a long time ago. During this time, I became the anomaly myself. Funny." + }; + return chats.TakeRandom(); } - public override void SetChatButtons(ref string button, ref string button2) { button = Lang.inter[28].Value; @@ -103,39 +91,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("KeyMold")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("LifeMachine")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("AncientTechnology")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("BagofDust")); - nextSlot++; - shop.item[nextSlot].SetDefaults(1337); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, 1337); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); if (NPC.downedAncientCultist) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("ManaGenerator")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); if (NPC.downedMechBossAny) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("ChaoticAmplifier")); - nextSlot++; - } - + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } - public override void TownNPCAttackStrength(ref int damage, ref float knockback) { damage = 40; @@ -151,7 +123,7 @@ public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCo public override void DrawTownAttackGun(ref float scale, ref int item, ref int closeness) //Allows you to customize how this town NPC's weapon is drawn when this NPC is shooting (this NPC must have an attack type of 1). Scale is a multiplier for the item's drawing size, item is the ID of the item to be drawn, and closeness is how close the item should be drawn to the NPC. { scale = 1f; - item = mod.ItemType("AlienBlaster"); + item = mod.ItemType(); closeness = 14; } public override void TownNPCAttackProj(ref int projType, ref int attackDelay)//Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the projectile to actually appear @@ -163,8 +135,6 @@ public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCo public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)//Allows you to determine the speed at which this town NPC throws a projectile when it attacks. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity { multiplier = 7f; - // randomOffset = 4f; - } public override void HitEffect(int hitDirection, double damage) @@ -172,12 +142,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/ProfessorGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfessorGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ProfessorGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/ProfessorGore{i+1}"), 1f); } } } diff --git a/NPCs/PyramidHead.cs b/NPCs/PyramidHead.cs index 8690991d..c93e94c1 100644 --- a/NPCs/PyramidHead.cs +++ b/NPCs/PyramidHead.cs @@ -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 PyramidHead : ModNPC { public override void SetStaticDefaults() @@ -33,20 +33,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("PyramidHeadBanner"); } - 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/PyramidGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PyramidGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PyramidGore3"), 1f); @@ -55,22 +48,8 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PyramidGore4"), 1f); } } - - 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; - } - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneDesert && !Main.dayTime && y < Main.worldSurface ? 0.08f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDesert && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/PyramidRider.cs b/NPCs/PyramidRider.cs index b0eb7559..ea0756e0 100644 --- a/NPCs/PyramidRider.cs +++ b/NPCs/PyramidRider.cs @@ -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 PyramidRider : ModNPC { public override void SetStaticDefaults() @@ -34,36 +34,16 @@ 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, 18, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y + 55, 508); - NPC.NewNPC((int)npc.position.X - 22, (int)npc.position.Y + 55, mod.NPCType("PyramidHead")); - } - } - 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.netMode == 1) return; - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y + 55, NPCID.WalkingAntlion); + NPC.NewNPC((int)npc.position.X - 22, (int)npc.position.Y + 55, mod.NPCType()); + } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneDesert && NPC.downedBoss1 && !Main.dayTime && y < Main.worldSurface ? 0.03f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDesert && NPC.downedBoss1 && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.03f : 0f; } } \ No newline at end of file diff --git a/NPCs/QuartzBeetle.cs b/NPCs/QuartzBeetle.cs index ab43f94f..9288a50e 100644 --- a/NPCs/QuartzBeetle.cs +++ b/NPCs/QuartzBeetle.cs @@ -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 QuartzBeetle : ModNPC { public override void SetStaticDefaults() @@ -33,24 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("QuartzBeetleBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("PurpleQuartz"), 2); - } - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), 2); } public override void HitEffect(int hitDirection, double damage) @@ -58,19 +46,13 @@ 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, mod.DustType(), 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/QBGore1"), 1f); } } 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.player.ZoneJungle && NPC.downedMoonlord && Main.hardMode && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneJungle && NPC.downedMoonlord && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Quetzalcoatl.cs b/NPCs/Quetzalcoatl.cs index 889da8fc..73a698ff 100644 --- a/NPCs/Quetzalcoatl.cs +++ b/NPCs/Quetzalcoatl.cs @@ -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 Quetzalcoatl : ModNPC { public override void SetStaticDefaults() @@ -37,9 +37,8 @@ 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/QGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/QGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/QGore3"), 1f); @@ -47,16 +46,9 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 59, hitDirection, -1f, 0, default(Color), 0.7f); - } } } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } } } \ No newline at end of file diff --git a/NPCs/RGiantSlime.cs b/NPCs/RGiantSlime.cs index d3e4d8b6..8ed75b89 100644 --- a/NPCs/RGiantSlime.cs +++ b/NPCs/RGiantSlime.cs @@ -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 RGiantSlime : ModNPC { public override void SetStaticDefaults() @@ -33,10 +33,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 12, 15); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool()) + this.NewItem(ItemID.Gel); } public override void HitEffect(int hitDirection, double damage) @@ -48,6 +48,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Red, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Red, 0.7f); } + Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Red, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Red, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Red, 0.7f); @@ -56,26 +57,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.1f : 0f; - } - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 23); - }; - } - } - + => Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/RichSlime.cs b/NPCs/RichSlime.cs index cc0c6d42..4e0f4815 100644 --- a/NPCs/RichSlime.cs +++ b/NPCs/RichSlime.cs @@ -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 RichSlime : ModNPC { public override void SetStaticDefaults() @@ -31,10 +33,12 @@ public override void SetDefaults() npc.value = Item.buyPrice(1, 0, 0, 0); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.NextBool()) + this.NewItem(23, Main.rand.Next(5, 9)); + if (Main.rand.Next(50) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -46,6 +50,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); } + Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); @@ -54,27 +59,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && Main.hardMode && Helper.NoInvasion(spawnInfo) && NPC.downedMoonlord && Main.dayTime ? 0.005f : 0f; - } - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 23, Main.rand.Next(5, 9)); - }; - if (Main.rand.Next(50) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FashionableHat")); - }; - } - } - + => spawnInfo.spawnTileY < Main.rockLayer && Main.hardMode && Helper.NoInvasion(spawnInfo) && NPC.downedMoonlord && Main.dayTime ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/Rogue.cs b/NPCs/Rogue.cs index 513cf424..a3b1c49e 100644 --- a/NPCs/Rogue.cs +++ b/NPCs/Rogue.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class Rogue : ModNPC @@ -31,61 +32,30 @@ public override void SetDefaults() bannerItem = mod.ItemType("RogueBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 177, Main.rand.Next(1, 2)); - } - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 178, Main.rand.Next(1, 2)); - } - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 179, Main.rand.Next(1, 2)); - } - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 180, Main.rand.Next(1, 2)); - } - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 181, Main.rand.Next(1, 2)); - } - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 182, Main.rand.Next(1, 2)); - } - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 40, Main.rand.Next(2, 6)); - } - if (Main.rand.Next(4) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 41, Main.rand.Next(2, 6)); - } - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 279, Main.rand.Next(2, 6)); - } - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 287, Main.rand.Next(2, 3)); - } + if (Main.rand.NextBool(2)) + this.NewItem(ItemID.WoodenArrow, Main.rand.Next(2, 6)); + if (Main.rand.Next(4) == 0) + this.NewItem(ItemID.FlamingArrow, Main.rand.Next(2, 6)); - } + if (Main.rand.Next(15) == 0) + this.NewItem(ItemID.Sapphire, Main.rand.Next(1, 3)); + if (Main.rand.Next(15) == 0) + this.NewItem(ItemID.Ruby, Main.rand.Next(1, 3)); + if (Main.rand.Next(15) == 0) + this.NewItem(ItemID.Emerald, Main.rand.Next(1, 3)); + if (Main.rand.Next(15) == 0) + this.NewItem(ItemID.Topaz, Main.rand.Next(1, 3)); + if (Main.rand.Next(15) == 0) + this.NewItem(ItemID.Amethyst, Main.rand.Next(1, 3)); + if (Main.rand.Next(15) == 0) + this.NewItem(ItemID.Diamond, Main.rand.Next(1, 3)); + + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.ThrowingKnife, Main.rand.Next(2, 6)); + if (Main.rand.Next(5) == 0) + this.NewItem(ItemID.PoisonedKnife, Main.rand.Next(2, 4)); } public override void HitEffect(int hitDirection, double damage) @@ -93,19 +63,14 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/RogueGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/RogueGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/RogueGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/RogueGore{i+1}"), 1f); } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 0.01f : 0f; - } - + => spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 0.01f : 0f; } } diff --git a/NPCs/RuinGhost1.cs b/NPCs/RuinGhost1.cs index 1fabe8e9..0ac7407b 100644 --- a/NPCs/RuinGhost1.cs +++ b/NPCs/RuinGhost1.cs @@ -1,8 +1,11 @@ using System.Linq; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Tremor.Items; + namespace Tremor.NPCs { public class RuinGhost1 : ModNPC @@ -34,10 +37,10 @@ public override void SetDefaults() npc.lavaImmune = true; } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void NPCLoot() { - int[] TileArray2 = { mod.TileType("RuinAltar"), mod.TileType("RuinChest"), 120 }; - return TileArray2.Contains(Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY].type) && TremorWorld.Boss.TikiTotem.IsDowned() ? 45f : 0f; + if (Main.rand.Next(33) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -49,10 +52,11 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, 11); } } - public override void NPCLoot() + + public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (Main.rand.Next(33) == 0) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, 12, 12, mod.ItemType("RuinKey"), 1); + int[] TileArray2 = { mod.TileType("RuinAltar"), mod.TileType("RuinChest"), TileID.Mudstone }; + return TileArray2.Contains(Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY].type) && TremorWorld.Boss.TikiTotem.IsDowned() ? 45f : 0f; } } } \ No newline at end of file diff --git a/NPCs/RuinGhost2.cs b/NPCs/RuinGhost2.cs index 825369b3..ec040095 100644 --- a/NPCs/RuinGhost2.cs +++ b/NPCs/RuinGhost2.cs @@ -1,8 +1,11 @@ using System.Linq; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Tremor.Items; + namespace Tremor.NPCs { public class RuinGhost2 : ModNPC @@ -34,10 +37,18 @@ public override void SetDefaults() npc.lavaImmune = true; } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void AI() { - int[] TileArray2 = { mod.TileType("RuinAltar"), mod.TileType("RuinChest"), 120 }; - return TileArray2.Contains(Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY].type) && TremorWorld.Boss.TikiTotem.IsDowned() ? 45f : 0f; + if (Main.rand.Next(700) == 0) + Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, Main.rand.Next(81, 84)); + } + + public override void NPCLoot() + { + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType(), 1); + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType(), 1); } public override void HitEffect(int hitDirection, double damage) @@ -49,19 +60,11 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, 11); } } - public override void AI() - { - if (Main.rand.Next(700) == 0) - { - Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, Main.rand.Next(81, 84)); - } - } - public override void NPCLoot() + + public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (Main.rand.Next(6) == 0) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, 12, 12, mod.ItemType("RuinKey"), 1); - if (Main.rand.Next(6) == 0) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, 12, 12, mod.ItemType("RustyLantern"), 1); + int[] TileArray2 = { mod.TileType("RuinAltar"), mod.TileType("RuinChest"), 120 }; + return TileArray2.Contains(Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY].type) && TremorWorld.Boss.TikiTotem.IsDowned() ? 45f : 0f; } } } \ No newline at end of file diff --git a/NPCs/SandThing.cs b/NPCs/SandThing.cs index 0f2e5e0b..3be7e620 100644 --- a/NPCs/SandThing.cs +++ b/NPCs/SandThing.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class SandThing : ModNPC @@ -34,21 +35,12 @@ 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; - if (Main.rand.Next(50) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 324); - } - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 169); - } - } + if (Main.rand.Next(50) == 0) + this.NewItem(ItemID.IllegalGunParts); + if (Main.rand.NextBool()) + this.NewItem(ItemID.SandBlock); } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -58,29 +50,19 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 19, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 19, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } + Dust.NewDust(npc.position, npc.width, npc.height, 19, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 19, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 19, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 19, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); + Gore.NewGore(npc.position, npc.velocity, 220, 1f); Gore.NewGore(npc.position, npc.velocity, 221, 1f); Gore.NewGore(npc.position, npc.velocity, 222, 1f); } } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneDesert && NPC.downedBoss1 && Main.dayTime && y < Main.worldSurface ? 0.01f : 0f; - } - + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDesert && NPC.downedBoss1 && Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } diff --git a/NPCs/ScaryBat.cs b/NPCs/ScaryBat.cs index 2d5a196d..e3eefd47 100644 --- a/NPCs/ScaryBat.cs +++ b/NPCs/ScaryBat.cs @@ -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 ScaryBat : ModNPC { public override void SetStaticDefaults() @@ -14,8 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - const int SpeedMulti = 3; // �����⥫� ᪮��� - public override void SetDefaults() { npc.lifeMax = 320; @@ -37,20 +35,12 @@ public override void SetDefaults() npc.behindTiles = true; } - 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 < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } else { @@ -66,11 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } 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)) && NPC.downedPlantBoss && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && NPC.downedPlantBoss && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Scavenger.cs b/NPCs/Scavenger.cs index 1e85dc5b..a7dcb9d2 100644 --- a/NPCs/Scavenger.cs +++ b/NPCs/Scavenger.cs @@ -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 Scavenger : ModNPC { public override void SetStaticDefaults() @@ -83,213 +83,112 @@ public override void HitEffect(int hitDirection, double damage) public override void NPCLoot() { - if (Main.netMode != 1) + if (!Main.hardMode) { - 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.hardMode) - { - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 29, Main.rand.Next(1, 2)); - }; - if (Main.rand.NextBool()) - { - if (!WorldGen.crimson) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 57, Main.rand.Next(10, 25)); - } - if (WorldGen.crimson) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 1257, Main.rand.Next(10, 25)); - } - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 188, Main.rand.Next(2, 10)); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 189, Main.rand.Next(2, 10)); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 178, Main.rand.Next(5, 15)); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 182, Main.rand.Next(5, 15)); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Opal"), Main.rand.Next(1, 3)); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 227, Main.rand.Next(2, 10)); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 175, Main.rand.Next(2, 10)); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3532, Main.rand.Next(1, 2)); - }; - } - if (Main.hardMode) - { - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2161, Main.rand.Next(1, 2)); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2351, Main.rand.Next(1, 6)); - }; - if (Main.rand.Next(10) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 723); - }; - if (Main.rand.Next(50) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 855); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 499, Main.rand.Next(1, 6)); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 500, Main.rand.Next(1, 6)); - }; - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 1242); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 1291, Main.rand.Next(1, 3)); - }; - if (Main.rand.Next(50) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 1321); - }; - if (Main.rand.Next(100) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 1326); - }; - if (Main.rand.Next(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 1324); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3368); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3260); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3262); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3212); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3099); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3095); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3096); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3091); - }; - if (Main.rand.Next(80) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 3092); - }; - if (Main.rand.Next(8) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2674, Main.rand.Next(1, 6)); - }; - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2675, Main.rand.Next(1, 10)); - }; - if (Main.rand.Next(50) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2676, Main.rand.Next(1, 15)); - }; - if (Main.rand.Next(60) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2336); - }; - if (Main.rand.Next(50) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2335); - }; - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2334); - }; - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 422, Main.rand.Next(1, 10)); - }; - if (Main.rand.Next(15) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 423, Main.rand.Next(1, 10)); - }; - if (Main.rand.Next(45) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 497); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 502, Main.rand.Next(1, 10)); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 501, Main.rand.Next(1, 15)); - }; - if (Main.rand.Next(26) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 507); - }; - if (Main.rand.Next(26) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 508); - }; - if (Main.rand.Next(62) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 527); - }; - if (Main.rand.Next(62) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 528); - }; + if (Main.rand.Next(2) == 0) + this.NewItem(29, Main.rand.Next(1, 3)); + + if (Main.rand.NextBool()) + { + if (WorldGen.crimson) + this.NewItem(1257, Main.rand.Next(10, 26)); + else + this.NewItem(57, Main.rand.Next(10, 26)); } + + if (Main.rand.NextBool()) + this.NewItem(188, Main.rand.Next(2, 11)); + if (Main.rand.NextBool()) + this.NewItem(189, Main.rand.Next(2, 11)); + if (Main.rand.NextBool()) + this.NewItem(178, Main.rand.Next(5, 16)); + if (Main.rand.NextBool()) + this.NewItem(182, Main.rand.Next(5, 16)); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); + if (Main.rand.NextBool()) + this.NewItem(227, Main.rand.Next(2, 11)); + if (Main.rand.NextBool()) + this.NewItem(175, Main.rand.Next(2, 11)); + if (Main.rand.NextBool()) + this.NewItem(3532, Main.rand.Next(1, 3)); + } + else + { + if (Main.rand.Next(5) == 0) + this.NewItem(2161, Main.rand.Next(1, 3)); + if (Main.rand.Next(3) == 0) + this.NewItem(2351, Main.rand.Next(1, 6)); + if (Main.rand.Next(10) == 0) + this.NewItem(723); + if (Main.rand.Next(50) == 0) + this.NewItem(855); + if (Main.rand.Next(3) == 0) + this.NewItem(499, Main.rand.Next(1, 6)); + if (Main.rand.Next(3) == 0) + this.NewItem(500, Main.rand.Next(1, 6)); + if (Main.rand.Next(15) == 0) + this.NewItem(1242); + if (Main.rand.Next(3) == 0) + this.NewItem(1291, Main.rand.Next(1, 3)); + if (Main.rand.Next(50) == 0) + this.NewItem(1321); + if (Main.rand.Next(100) == 0) + this.NewItem(1326); + if (Main.rand.Next(25) == 0) + this.NewItem(1324); + if (Main.rand.Next(80) == 0) + this.NewItem(3368); + if (Main.rand.Next(80) == 0) + this.NewItem(3260); + if (Main.rand.Next(80) == 0) + this.NewItem(3262); + if (Main.rand.Next(80) == 0) + this.NewItem(3212); + if (Main.rand.Next(80) == 0) + this.NewItem(3099); + if (Main.rand.Next(80) == 0) + this.NewItem(3095); + if (Main.rand.Next(80) == 0) + this.NewItem(3096); + if (Main.rand.Next(80) == 0) + this.NewItem(3091); + if (Main.rand.Next(80) == 0) + this.NewItem(3092); + if (Main.rand.Next(8) == 0) + this.NewItem(2674, Main.rand.Next(1, 6)); + if (Main.rand.Next(15) == 0) + this.NewItem(2675, Main.rand.Next(1, 10)); + if (Main.rand.Next(50) == 0) + this.NewItem(2676, Main.rand.Next(1, 15)); + if (Main.rand.Next(60) == 0) + this.NewItem(2336); + if (Main.rand.Next(50) == 0) + this.NewItem(2335); + if (Main.rand.Next(30) == 0) + this.NewItem(2334); + if (Main.rand.Next(15) == 0) + this.NewItem(422, Main.rand.Next(1, 10)); + if (Main.rand.Next(15) == 0) + this.NewItem(423, Main.rand.Next(1, 10)); + if (Main.rand.Next(45) == 0) + this.NewItem(497); + if (Main.rand.Next(3) == 0) + this.NewItem(502, Main.rand.Next(1, 10)); + if (Main.rand.Next(3) == 0) + this.NewItem(501, Main.rand.Next(1, 15)); + if (Main.rand.Next(26) == 0) + this.NewItem(507); + if (Main.rand.Next(26) == 0) + this.NewItem(508); + if (Main.rand.Next(62) == 0) + this.NewItem(527); + if (Main.rand.Next(62) == 0) + this.NewItem(528); } } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.0001f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.0001f : 0f; } } \ No newline at end of file diff --git a/NPCs/Screamer.cs b/NPCs/Screamer.cs index 5498c70d..4cba1f0b 100644 --- a/NPCs/Screamer.cs +++ b/NPCs/Screamer.cs @@ -1,9 +1,13 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class Screamer : ModNPC @@ -14,18 +18,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScreamerGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScreamerGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScreamerGore3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScreamerGore3"), 1f); - } - } - public override void SetDefaults() { npc.aiStyle = -1; @@ -47,77 +39,68 @@ public override void SetDefaults() npc.npcSlots = 10f; } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.625f * bossLifeScale); - npc.damage = (int)(npc.damage * 0.6f); - } - public override void AI() { - float num1971 = 5f; - float moveSpeed = 0.15f; + float maxMoveSpeed = 5f; npc.TargetClosest(true); - Vector2 desiredVelocity4 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, -250f); - float num1972 = desiredVelocity4.Length(); - if (num1972 < 20f) + Vector2 targetVelocity = Main.player[npc.target].Center - npc.Center; + float velocityMagnitude = targetVelocity.Length(); + + if (velocityMagnitude < 20f) { - desiredVelocity4 = npc.velocity; + targetVelocity = npc.velocity; } - else if (num1972 < 40f) + else if (velocityMagnitude < 40f) { - desiredVelocity4.Normalize(); - desiredVelocity4 *= num1971 * 0.35f; + targetVelocity.Normalize(); + targetVelocity *= maxMoveSpeed * 0.35f; } - else if (num1972 < 80f) + else if (velocityMagnitude < 80f) { - desiredVelocity4.Normalize(); - desiredVelocity4 *= num1971 * 0.65f; + targetVelocity.Normalize(); + targetVelocity *= maxMoveSpeed * 0.65f; } else { - desiredVelocity4.Normalize(); - desiredVelocity4 *= num1971; + targetVelocity.Normalize(); + targetVelocity *= maxMoveSpeed; } - npc.SimpleFlyMovement(desiredVelocity4, moveSpeed); + + npc.SimpleFlyMovement(targetVelocity, 0.15F); npc.rotation = npc.velocity.X * 0.1f; - if ((npc.ai[0] += 1f) >= 70f) + + if (npc.ai[0]++ >= 70f) { npc.ai[0] = 0f; if (Main.netMode != 1) { - Vector2 vector283 = Vector2.Zero; - while (Math.Abs(vector283.X) < 1.5f) - { - vector283 = Vector2.UnitY.RotatedByRandom(1.5707963705062866) * new Vector2(5f, 3f); - } - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector283.X, vector283.Y, 593, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); + Vector2 randomProjectileVelocity = Vector2.Zero; + while (Math.Abs(randomProjectileVelocity.X) < 1.5f) + randomProjectileVelocity = Vector2.UnitY.RotatedByRandom(1.5707963705062866) * new Vector2(5f, 3f); + + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, randomProjectileVelocity.X, randomProjectileVelocity.Y, ProjectileID.AncientDoomProjectile, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); } } } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override void NPCLoot() { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMoonlord && Main.eclipse ? 0.001f : 0f; + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(6, 13)); } - public override void NPCLoot() + public override void HitEffect(int hitDirection, double damage) { - if (Main.netMode != 1) + if (npc.life <= 0) { - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Catalyst"), Main.rand.Next(5, 12)); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScreamerGore1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScreamerGore2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScreamerGore3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScreamerGore3"), 1f); } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMoonlord && Main.eclipse ? 0.001f : 0f; } } \ No newline at end of file diff --git a/NPCs/ShadowRipper.cs b/NPCs/ShadowRipper.cs index ac86b102..6907eaf1 100644 --- a/NPCs/ShadowRipper.cs +++ b/NPCs/ShadowRipper.cs @@ -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 ShadowRipper : ModNPC { public override void SetStaticDefaults() @@ -14,7 +16,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 2; } - public override void SetDefaults() { npc.lifeMax = 2400; @@ -37,33 +38,12 @@ public override void SetDefaults() bannerItem = mod.ItemType("ShadowRipperBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Doomstone")); - } - } + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType()); } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.04f : 0f; - } public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -78,13 +58,13 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 74, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 74, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/RipperGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/RipperGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/RipperGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/RipperGore{i+1}"), 1f); } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 74, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 74, hitDirection, -1f, 0, default(Color), 0.7f); @@ -93,5 +73,7 @@ public override void HitEffect(int hitDirection, double damage) } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.04f : 0f; } } \ No newline at end of file diff --git a/NPCs/Shnoot.cs b/NPCs/Shnoot.cs index b18fb7e3..beb43f1a 100644 --- a/NPCs/Shnoot.cs +++ b/NPCs/Shnoot.cs @@ -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 Shnoot : ModNPC { public override void SetStaticDefaults() @@ -34,34 +36,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; - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Gloomstone"), Main.rand.Next(6, 15)); - } - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("RockHorn"), Main.rand.Next(1, 3)); - } - } - } - - 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)) && y > Main.rockLayer ? 0.005f : 0f; + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType(), Main.rand.Next(6, 16)); + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); } public override void HitEffect(int hitDirection, double damage) @@ -69,9 +47,8 @@ public override void HitEffect(int hitDirection, double damage) if (npc.life <= 0) { for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ShnootGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ShnootGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ShnootGore1"), 1f); @@ -80,7 +57,7 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -88,5 +65,8 @@ public override void HitEffect(int hitDirection, double damage) } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileY > Main.rockLayer ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/Shroot.cs b/NPCs/Shroot.cs index b91df22a..671ea9f0 100644 --- a/NPCs/Shroot.cs +++ b/NPCs/Shroot.cs @@ -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 Shroot : ModNPC { public override void SetStaticDefaults() @@ -35,34 +37,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; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Gloomstone"), Main.rand.Next(5, 12)); - } - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("RockHorn"), Main.rand.Next(1, 2)); - } - } - } - - 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)) && y > Main.rockLayer ? 0.003f : 0f; + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType(), Main.rand.Next(6, 16)); + if (Main.rand.NextBool(2)) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); } public override void HitEffect(int hitDirection, double damage) @@ -70,9 +48,8 @@ public override void HitEffect(int hitDirection, double damage) if (npc.life <= 0) { for (int k = 0; k < 60; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ShnootGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ShnootGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ShnootGore1"), 1f); @@ -81,7 +58,7 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) + for (int k = 0; k < damage / npc.lifeMax * 50; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default(Color), 0.7f); @@ -89,5 +66,8 @@ public override void HitEffect(int hitDirection, double damage) } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spawnTileY > Main.rockLayer ? 0.003f : 0f; } } \ No newline at end of file diff --git a/NPCs/Sighted.cs b/NPCs/Sighted.cs index e2d8b8b8..3c03f2b2 100644 --- a/NPCs/Sighted.cs +++ b/NPCs/Sighted.cs @@ -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 Sighted : ModNPC { public override void SetStaticDefaults() @@ -34,34 +34,23 @@ public override void SetDefaults() bannerItem = mod.ItemType("SightedBanner"); } - 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, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SightedGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SightedGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SightedGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/SightedGore{i+1}"), 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/SkeletonKnight.cs b/NPCs/SkeletonKnight.cs index ac161c6a..a40958e4 100644 --- a/NPCs/SkeletonKnight.cs +++ b/NPCs/SkeletonKnight.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.ZombieEvent.Items; + namespace Tremor.NPCs { public class SkeletonKnight : ModNPC @@ -31,36 +34,15 @@ public override void SetDefaults() bannerItem = mod.ItemType("SkeletonKnightBanner"); } - 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)) && NPC.downedBoss3 && y > Main.rockLayer ? 0.02f : 0f; - } - 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(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 150, Main.rand.Next(3, 6)); - } - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 154, Main.rand.Next(1, 3)); - } + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Cobweb, Main.rand.Next(3, 6)); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Bone, Main.rand.Next(1, 3)); - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TornPapyrus")); - }; - - } + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -68,19 +50,18 @@ 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/SkelKnightGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SkelKnightGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SkelKnightGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SkelKnightGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SkelKnightGore3"), 1f); - Gore.NewGore(npc.position, npc.velocity, - mod.GetGoreSlot("Gores/SkelKnightGore4"), 1f); - + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SkelKnightGore4"), 1f); } } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss3 && spawnInfo.spawnTileY > Main.rockLayer ? 0.02f : 0f; } } diff --git a/NPCs/Skullker.cs b/NPCs/Skullker.cs index 1321f35f..8fad3965 100644 --- a/NPCs/Skullker.cs +++ b/NPCs/Skullker.cs @@ -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 Skullker : ModNPC { public override void SetStaticDefaults() @@ -35,20 +35,6 @@ public override void SetDefaults() bannerItem = mod.ItemType("SkullkerBanner"); } - 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.player.ZoneDungeon && NPC.downedMoonlord && Main.hardMode && y > Main.rockLayer ? 0.006f : 0f; - } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -59,21 +45,21 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } + for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SkullkerGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SkullkerGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SkullkerGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/SkullkerGore{i+1}"), 1f); } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 226, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDungeon && NPC.downedMoonlord && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.006f : 0f; } } \ No newline at end of file diff --git a/NPCs/SnowBat.cs b/NPCs/SnowBat.cs index e3212df0..2e76951c 100644 --- a/NPCs/SnowBat.cs +++ b/NPCs/SnowBat.cs @@ -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 SnowBat : ModNPC { public override void SetStaticDefaults() @@ -14,7 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 5; } - public override void SetDefaults() { npc.lifeMax = 30; @@ -34,24 +33,10 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("SnowBatBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 593); - } - } + if (Main.rand.NextBool()) + this.NewItem(ItemID.SnowBlock); } public override void HitEffect(int hitDirection, double damage) @@ -63,6 +48,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); } + Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 2f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); @@ -70,11 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } 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)) && Main.cloudAlpha > 0f && y < Main.worldSurface && spawnInfo.player.ZoneSnow ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && Main.cloudAlpha > 0f && spawnInfo.spawnTileY < Main.worldSurface && spawnInfo.player.ZoneSnow ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/SnowEater.cs b/NPCs/SnowEater.cs index afa970ac..3c40f90e 100644 --- a/NPCs/SnowEater.cs +++ b/NPCs/SnowEater.cs @@ -1,12 +1,18 @@ using System; -using Microsoft.Xna.Framework; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { - + /* + * AI could still use some cleaning up. + */ public class SnowEater : ModNPC { public override void SetStaticDefaults() @@ -34,55 +40,6 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("SnowEaterBanner"); } - 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FrostCore")); - }; - if (NPC.downedMoonlord && Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("IceSoul")); - } - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return spawnInfo.player.ZoneSnow && y > Main.rockLayer ? 0.01f : 0f; - } - - 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) - { - Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SEGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SEGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SEGore2"), 1f); - for (int k = 0; k < 20; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.6f); - } - } - } - public override void AI() { npc.TargetClosest(true); @@ -190,5 +147,35 @@ public override void AI() } } + public override void NPCLoot() + { + if (Main.rand.Next(2) == 0) + this.NewItem(mod.ItemType()); + if (NPC.downedMoonlord && Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SEGore1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SEGore1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SEGore2"), 1f); + + for (int k = 0; k < 20; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); + Dust.NewDust(npc.position, npc.width, npc.height, 80, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.6f); + } + } + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => spawnInfo.player.ZoneSnow && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Snowcopter.cs b/NPCs/Snowcopter.cs index 51c15031..7715d961 100644 --- a/NPCs/Snowcopter.cs +++ b/NPCs/Snowcopter.cs @@ -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 Snowcopter : ModNPC { public override void SetStaticDefaults() @@ -14,7 +14,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 8; } - public override void SetDefaults() { npc.lifeMax = 600; @@ -36,20 +35,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("SnowcopterBanner"); } - 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, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, 61, 1f); Gore.NewGore(npc.position, npc.velocity, 61, 1f); Gore.NewGore(npc.position, npc.velocity, 62, 1f); @@ -59,11 +51,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return NPC.AnyNPCs(145) && Main.hardMode && y < Main.worldSurface ? 0.06f : 0f; - } + => NPC.AnyNPCs(NPCID.SnowBalla) && Main.hardMode && spawnInfo.spawnTileY < Main.worldSurface ? 0.06f : 0f; } } \ No newline at end of file diff --git a/NPCs/SnowmanBomber.cs b/NPCs/SnowmanBomber.cs index 418f8634..46b74206 100644 --- a/NPCs/SnowmanBomber.cs +++ b/NPCs/SnowmanBomber.cs @@ -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 SnowmanBomber : ModNPC { public override void SetStaticDefaults() @@ -33,20 +33,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("SnowmanBomberBanner"); } - 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, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 2f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); @@ -54,11 +47,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return NPC.AnyNPCs(144) && Main.hardMode && y < Main.worldSurface ? 0.08f : 0f; - } + => NPC.AnyNPCs(NPCID.MisterStabby) && Main.hardMode && spawnInfo.spawnTileY < Main.worldSurface ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/SnowmanWarrior.cs b/NPCs/SnowmanWarrior.cs index da7088fb..d7963a15 100644 --- a/NPCs/SnowmanWarrior.cs +++ b/NPCs/SnowmanWarrior.cs @@ -1,19 +1,19 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { - public class SnowmanWarrior : ModNPC { - public override void SetStaticDefaults() { DisplayName.SetDefault("Snowman Warrior"); Main.npcFrameCount[npc.type] = 5; } + public override void SetDefaults() { npc.lifeMax = 350; @@ -33,20 +33,13 @@ public override void SetDefaults() bannerItem = mod.ItemType("SnowmanWarriorBanner"); } - 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, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 2f); Dust.NewDust(npc.position, npc.width, npc.height, 76, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); @@ -54,11 +47,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return NPC.AnyNPCs(144) && Main.hardMode && y < Main.worldSurface ? 0.08f : 0f; - } + => NPC.AnyNPCs(NPCID.MisterStabby) && Main.hardMode && spawnInfo.spawnTileY < Main.worldSurface ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/Sorcerer.cs b/NPCs/Sorcerer.cs index 6132469f..8ec80178 100644 --- a/NPCs/Sorcerer.cs +++ b/NPCs/Sorcerer.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { [AutoloadHead] @@ -47,47 +50,35 @@ public override void SetDefaults() } public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - return true; - } + => true; public override string TownNPCName() { - switch (WorldGen.genRand.Next(4)) + string[] names = { - case 0: - return "Merdok"; - case 1: - return "Avalon"; - case 2: - return "Aron"; - case 3: - return "Harry"; - case 4: - return "Edgar"; - default: - return "Marco"; - } + "Merdok", + "Avalon", + "Aron", + "Harry", + "Edgar", + "Marco" + }; + return names.TakeRandom(); } public override string GetChat() { - switch (Main.rand.Next(6)) + string[] chats = { - case 0: - return "You'll never find me trapped underground."; - case 1: - return "I can share the magic with you for free. Almost free."; - case 2: - return "Sorcery is all about control. It's different from magic in that it requires symbols and fetishes."; - case 3: - return "Sorry. I don't do parties."; - case 4: - return "Don't touch that if you want to keep your hand. It's still quite unstable."; - default: - return "I want to get the rabbit out of the hat! You want? Don't want a rabbit? Seriously? Someone in this house will buy my rabbits or not!"; - } + "You'll never find me trapped underground.", + "Sorcery is all about control. It's different from magic in that it requires symbols and fetishes.", + "I can share the magic with you for free. Well... Almost free.", + "Sorry. I don't do parties.", + "Don't touch that if you want to keep your hand. It's still quite unstable.", + "I want to get the rabbit out of the hat! Do you want it? You don't want a rabbit? Seriously!?" + }; + return chats.TakeRandom(); } public override void SetChatButtons(ref string button, ref string button2) @@ -97,43 +88,29 @@ 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("BurningTome")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("RazorleavesTome")); - nextSlot++; - shop.item[nextSlot].SetDefaults(2019); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("EnchantedShield")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, ItemID.Bunny); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); if (NPC.downedBoss1) { - shop.item[nextSlot].SetDefaults(mod.ItemType("StarfallTome")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("GoldenHat")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("GoldenRobe")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } if (NPC.downedBoss2) { - shop.item[nextSlot].SetDefaults(mod.ItemType("LightningTome")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("Bloomstone")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } + if (Main.hardMode) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("ManaDagger")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } public override void TownNPCAttackStrength(ref int damage, ref float knockback) @@ -165,12 +142,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/SorcererGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SorcererGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SorcererGore3"), 1f); + + for(int i = 0; i < 3; ++i) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/SorcererGore{i+1}"), 1f); } } } diff --git a/NPCs/SpaceWhaleMinion.cs b/NPCs/SpaceWhaleMinion.cs index 31a99505..7d39f37c 100644 --- a/NPCs/SpaceWhaleMinion.cs +++ b/NPCs/SpaceWhaleMinion.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class SpaceWhaleMinion : ModNPC @@ -32,13 +33,12 @@ public override void SetDefaults() animationType = 23; } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void AI() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(4) == 0) + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 2f)].velocity *= 0.3f; } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -46,6 +46,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); @@ -55,19 +56,9 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 6, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.6f); } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SpaceWhaleMinionGore"), 1f); - } - } - public override void AI() - { - if (Main.rand.Next(4) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 2f); - Main.dust[num706].velocity *= 0.3f; + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SpaceWhaleMinionGore"), 1f); } } - - } } diff --git a/NPCs/Spaceman.cs b/NPCs/Spaceman.cs index 173225f4..c3ba97da 100644 --- a/NPCs/Spaceman.cs +++ b/NPCs/Spaceman.cs @@ -1,8 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class Spaceman : ModNPC @@ -32,47 +33,22 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("SpacemanBanner"); } - public override void AI() { - if (Main.rand.Next(1000) == 0) - { Main.PlaySound(61, (int)npc.position.X, (int)npc.position.Y, 1); - } if (Main.rand.Next(1000) == 0) - { Main.PlaySound(62, (int)npc.position.X, (int)npc.position.Y, 1); - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; } 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(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 116, Main.rand.Next(1, 6)); - } - if (Main.rand.Next(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 117, Main.rand.Next(1, 3)); - } - if (Main.rand.Next(46) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 127, Main.rand.Next(1)); - } - - } + if (Main.rand.Next(6) == 0) + this.NewItem(ItemID.Meteorite, Main.rand.Next(1, 6)); + if (Main.rand.Next(6) == 0) + this.NewItem(ItemID.MeteoriteBar, Main.rand.Next(1, 3)); + if (Main.rand.Next(46) == 0) + this.NewItem(ItemID.SpaceGun, Main.rand.Next(1)); } public override void HitEffect(int hitDirection, double damage) @@ -80,9 +56,8 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SpaceManGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SpaceManGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SpaceManGore2"), 1f); @@ -93,9 +68,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.spawnTileY < Main.rockLayer && spawnInfo.player.ZoneMeteor && Main.dayTime ? 0.03f : 0f; - } - + => spawnInfo.spawnTileY < Main.rockLayer && spawnInfo.player.ZoneMeteor && Main.dayTime ? 0.03f : 0f; } } diff --git a/NPCs/SpiderMan.cs b/NPCs/SpiderMan.cs index 26fe8d0f..16f7470d 100644 --- a/NPCs/SpiderMan.cs +++ b/NPCs/SpiderMan.cs @@ -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 SpiderMan : ModNPC { public override void SetStaticDefaults() @@ -32,10 +32,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("SpiderManBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(2) == 0) + this.NewItem(ItemID.SpiderFang, Main.rand.Next(60, 150)); } public override void HitEffect(int hitDirection, double damage) @@ -43,9 +43,8 @@ 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/SpiderManGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SpiderManGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SpiderManGore2"), 1f); @@ -53,26 +52,7 @@ 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(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 2607, Main.rand.Next(60, 150)); - }; - } - } - //public override float SpawnChance(NPCSpawnInfo spawnInfo) - //{ - //int x = spawnInfo.spawnTileX; - //int y = spawnInfo.spawnTileY; - //int tile = (int)Main.tile[x, y].type; - //return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.spiderCave ? 0.08f : 0f; - //} + public override float SpawnChance(NPCSpawnInfo spawnInfo) + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.spiderCave ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/SquidZombie.cs b/NPCs/SquidZombie.cs index f5d41d44..513340b6 100644 --- a/NPCs/SquidZombie.cs +++ b/NPCs/SquidZombie.cs @@ -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 SquidZombie : ModNPC { public override void SetStaticDefaults() @@ -32,14 +34,21 @@ public override void SetDefaults() bannerItem = mod.ItemType("SquidZombieBanner"); } + public override void NPCLoot() + { + if (Main.rand.Next(24) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(3) == 0) + this.NewItem(mod.ItemType()); + } + 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/ZombieGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SquidGore1"), 1f); @@ -48,36 +57,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 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(24) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("SquidHat"), Main.rand.Next(1)); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("UntreatedFlesh")); - }; - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && (tile == 53 || tile == 112 || tile == 116 || tile == 234) && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.water) && y < Main.rockLayer && (x < 250 || x > Main.maxTilesX - 250) && !spawnInfo.playerSafe ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Main.tileSand[spawnInfo.spawnTileType] && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.water && spawnInfo.spawnTileY < Main.rockLayer && (spawnInfo.spawnTileX < 250 || spawnInfo.spawnTileX > Main.maxTilesX - 250) && !spawnInfo.playerSafe ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Squoma.cs b/NPCs/Squoma.cs index 1a749464..d921e640 100644 --- a/NPCs/Squoma.cs +++ b/NPCs/Squoma.cs @@ -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 Squoma : ModNPC { public override void SetStaticDefaults() @@ -32,14 +34,19 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("SquomaBanner"); } + public override void NPCLoot() + { + if (Main.rand.Next(3) == 0) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); + } + 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, 59, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SquomaGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SquomaGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SquomaGore1"), 1f); @@ -48,40 +55,12 @@ public override void HitEffect(int hitDirection, double damage) } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 59, hitDirection, -1f, 0, default(Color), 0.7f); - } - } - } - - - 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(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Squorb"), Main.rand.Next(1, 3)); - } } } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && spawnInfo.player.ZoneSnow && y < Main.worldSurface ? 0.08f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && spawnInfo.player.ZoneSnow && spawnInfo.spawnTileY < Main.worldSurface ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/SupremePossessedArmor.cs b/NPCs/SupremePossessedArmor.cs index 918def93..961e1106 100644 --- a/NPCs/SupremePossessedArmor.cs +++ b/NPCs/SupremePossessedArmor.cs @@ -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 SupremePossessedArmor : ModNPC { public override void SetStaticDefaults() @@ -14,7 +16,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 20; } - public override void SetDefaults() { npc.lifeMax = 1250; @@ -34,24 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("SupremePossessedArmorBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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("ShadowCutter")); - }; - } + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -59,9 +46,8 @@ 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/PossessedGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PossessedGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/PossessedGore2"), 1f); @@ -71,11 +57,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMechBossAny && !Main.dayTime && y < Main.worldSurface ? 0.1f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMechBossAny && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/TempleSlime.cs b/NPCs/TempleSlime.cs index bc39cbef..1d94b248 100644 --- a/NPCs/TempleSlime.cs +++ b/NPCs/TempleSlime.cs @@ -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 TempleSlime : ModNPC { public override void SetStaticDefaults() @@ -31,6 +31,12 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 12, 15); } + public override void NPCLoot() + { + if (Main.rand.NextBool()) + this.NewItem(ItemID.LihzahrdPowerCell); + } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -40,6 +46,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Brown, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Brown, 0.7f); } + Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Brown, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Brown, 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Brown, 0.7f); @@ -47,33 +54,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 Main.hardMode && (tile == 226) && NPC.downedMoonlord && y > Main.rockLayer ? 0.005f : 0f; - } - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 1293); - }; - } - } - + => Main.hardMode && spawnInfo.spawnTileType == TileID.LihzahrdBrick && NPC.downedMoonlord && spawnInfo.spawnTileY > Main.rockLayer ? 0.005f : 0f; } } \ No newline at end of file diff --git a/NPCs/TheAxeman.cs b/NPCs/TheAxeman.cs index e542fcf1..6351e25c 100644 --- a/NPCs/TheAxeman.cs +++ b/NPCs/TheAxeman.cs @@ -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 TheAxeman : ModNPC { public override void SetStaticDefaults() @@ -33,10 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("TheAxemanBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -44,37 +46,19 @@ public override void HitEffect(int hitDirection, double damage) if (npc.life <= 0) { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TheAxemanGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TheAxemanGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TheAxemanGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TheAxemanGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TheAxemanGore3"), 1f); + for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); - } } } - 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(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenHeroArmorplate")); - } - } - } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && (tile == 53 || tile == 112 || tile == 116 || tile == 234) && spawnInfo.water) && y < Main.rockLayer && (x < 250 || x > Main.maxTilesX - 250) && !spawnInfo.playerSafe && NPC.downedMoonlord && Main.eclipse ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Main.tileSand[spawnInfo.spawnTileType] && spawnInfo.water && spawnInfo.spawnTileY < Main.rockLayer && (spawnInfo.spawnTileX < 250 || spawnInfo.spawnTileX > Main.maxTilesX - 250) && !spawnInfo.playerSafe && NPC.downedMoonlord && Main.eclipse ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/TheGirl.cs b/NPCs/TheGirl.cs index 11b0248a..38c207a4 100644 --- a/NPCs/TheGirl.cs +++ b/NPCs/TheGirl.cs @@ -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 TheGirl : ModNPC { public override void SetStaticDefaults() @@ -33,10 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("TheGirlBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -49,32 +51,13 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); } + for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 54, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } } } - 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(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenHeroArmorplate")); - } - } - } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && (tile == 53 || tile == 112 || tile == 116 || tile == 234) && spawnInfo.water) && y < Main.rockLayer && (x < 250 || x > Main.maxTilesX - 250) && !spawnInfo.playerSafe && NPC.downedMoonlord && Main.eclipse ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Main.tileSand[spawnInfo.spawnTileType] && spawnInfo.water && spawnInfo.spawnTileY < Main.rockLayer && (spawnInfo.spawnTileX < 250 || spawnInfo.spawnTileX > Main.maxTilesX - 250) && !spawnInfo.playerSafe && NPC.downedMoonlord && Main.eclipse ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/TheThing.cs b/NPCs/TheThing.cs index a86243de..4324a9c7 100644 --- a/NPCs/TheThing.cs +++ b/NPCs/TheThing.cs @@ -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 TheThing : ModNPC { public override void SetStaticDefaults() @@ -37,24 +39,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("TheThingBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("DeadTissue")); - } - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -64,12 +52,14 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 2.7f); Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TTGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TTGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TTGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TTGore3"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TTGore4"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TTGore4"), 1f); + for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 1.7f); @@ -79,11 +69,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.002f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.002f : 0f; } } \ No newline at end of file diff --git a/NPCs/Thief1.cs b/NPCs/Thief1.cs index 23837761..fe7760c1 100644 --- a/NPCs/Thief1.cs +++ b/NPCs/Thief1.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class Thief1 : ModNPC @@ -34,66 +37,31 @@ 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; - if (Main.rand.Next(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherHat")); - }; - if (Main.rand.Next(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherGreaves")); - }; - if (Main.rand.Next(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherShirt")); - }; - if (Main.rand.Next(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ChainCoif")); - }; - if (Main.rand.Next(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ChainGreaves")); - }; - if (Main.rand.Next(6) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Chainmail")); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 28); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 31); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 8); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 85); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 110); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 259); - }; - } - } + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(6) == 0) + this.NewItem(mod.ItemType()); - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.LesserHealingPotion); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.LesserManaPotion); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Bottle); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Torch); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Chain); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Leather); } public override void HitEffect(int hitDirection, double damage) @@ -101,9 +69,8 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief1Gore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief1Gore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief1Gore2"), 1f); @@ -114,13 +81,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (!NPC.downedBoss2) - { - return spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? 0.02f : 0f; - } - return spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? 0.002f : 0f; - } - + => spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? (NPC.downedBoss2 ? 0.02f : 0.002f) : 0f; } } diff --git a/NPCs/Thief2.cs b/NPCs/Thief2.cs index 430b4243..8161e9b2 100644 --- a/NPCs/Thief2.cs +++ b/NPCs/Thief2.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class Thief2 : ModNPC @@ -34,66 +37,31 @@ 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; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherHat")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherGreaves")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherShirt")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ChainCoif")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ChainGreaves")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Chainmail")); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 28); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 31); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 8); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 85); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 110); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 259); - }; - } - } + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.LesserHealingPotion); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.LesserManaPotion); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Bottle); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Torch); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Chain); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Leather); } public override void HitEffect(int hitDirection, double damage) @@ -101,9 +69,8 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief2Gore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief2Gore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief2Gore2"), 1f); @@ -113,12 +80,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (!NPC.downedBoss2) - { - return spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? 0.02f : 0f; - } - return spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? 0.002f : 0f; - } + => spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? (NPC.downedBoss2 ? 0.02f : 0.002f) : 0f; } } diff --git a/NPCs/Thief3.cs b/NPCs/Thief3.cs index bb171b2a..91cd3cd2 100644 --- a/NPCs/Thief3.cs +++ b/NPCs/Thief3.cs @@ -1,8 +1,11 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { public class Thief3 : ModNPC @@ -34,66 +37,31 @@ 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; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherHat")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherGreaves")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LeatherShirt")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ChainCoif")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ChainGreaves")); - }; - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Chainmail")); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 28); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 31); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 8); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 85); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 110); - }; - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 259); - }; - } - } + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.LesserHealingPotion); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.LesserManaPotion); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Bottle); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Torch); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Chain); + if (Main.rand.Next(3) == 0) + this.NewItem(ItemID.Leather); } public override void HitEffect(int hitDirection, double damage) @@ -101,9 +69,8 @@ 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief3Gore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief3Gore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thief3Gore2"), 1f); @@ -114,13 +81,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (!NPC.downedBoss2) - { - return spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? 0.02f : 0f; - } - return spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? 0.002f : 0f; - } - + => spawnInfo.spawnTileY < Main.rockLayer && Main.dayTime ? (NPC.downedBoss2 ? 0.02f : 0.002f) : 0f; } } diff --git a/NPCs/ThinMan.cs b/NPCs/ThinMan.cs index bd407f10..c538d484 100644 --- a/NPCs/ThinMan.cs +++ b/NPCs/ThinMan.cs @@ -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 ThinMan : ModNPC { public override void SetStaticDefaults() @@ -14,7 +16,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 10; } - public override void SetDefaults() { npc.lifeMax = 10000; @@ -34,24 +35,10 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("ThinManBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenHeroArmorplate")); - } - } + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -59,9 +46,8 @@ 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, 74, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TMGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TMGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TMGore2"), 1f); @@ -72,11 +58,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMoonlord && Main.eclipse ? 0.001f : 0f; - } + => spawnInfo.spawnTileY < Main.rockLayer && NPC.downedMoonlord && Main.eclipse ? 0.001f : 0f; } } \ No newline at end of file diff --git a/NPCs/ThunderBones.cs b/NPCs/ThunderBones.cs index 233ff6bf..c9d3bf8b 100644 --- a/NPCs/ThunderBones.cs +++ b/NPCs/ThunderBones.cs @@ -2,9 +2,10 @@ using Terraria.ID; using Terraria.ModLoader; +using Tremor.Items; + namespace Tremor.NPCs { - public class ThunderBones : ModNPC { public override void SetStaticDefaults() @@ -32,47 +33,24 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("ThunderBonesBanner"); } - 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(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Bonecrusher")); - }; - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TearsofDeath"), Main.rand.Next(1, 5)); - }; - } - } public override void AI() { if (Main.rand.Next(9) == 0) - { - int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 180, 0f, 0f, 200, npc.color, 1f); - Main.dust[num706].velocity *= 0.3f; - } + Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 180, 0f, 0f, 200, npc.color)].velocity *= 0.3f; } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 6)); } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { - NPC.NewNPC((int)npc.position.X + 32, (int)npc.position.Y - 48, mod.NPCType("BoneFish")); - NPC.NewNPC((int)npc.position.X + 16, (int)npc.position.Y - 48, mod.NPCType("BoneFish")); - NPC.NewNPC((int)npc.position.X - 32, (int)npc.position.Y - 48, mod.NPCType("BoneFish")); - NPC.NewNPC((int)npc.position.X - 16, (int)npc.position.Y - 48, mod.NPCType("BoneFish")); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TBGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TBGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TBGore3"), 1f); @@ -80,17 +58,17 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TBGore4"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TBGore5"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TBGore5"), 1f); + + if (Main.netMode == 1) return; + + NPC.NewNPC((int)npc.position.X + 32, (int)npc.position.Y - 48, mod.NPCType()); + NPC.NewNPC((int)npc.position.X + 16, (int)npc.position.Y - 48, mod.NPCType()); + NPC.NewNPC((int)npc.position.X - 32, (int)npc.position.Y - 48, mod.NPCType()); + NPC.NewNPC((int)npc.position.X - 16, (int)npc.position.Y - 48, mod.NPCType()); } } 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)) && NPC.downedBoss3 && Main.bloodMoon && y < Main.worldSurface ? 0.01f : 0f; - } - - + => Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss3 && Main.bloodMoon && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/TikiSorcerer.cs b/NPCs/TikiSorcerer.cs index f81e71a9..e261f783 100644 --- a/NPCs/TikiSorcerer.cs +++ b/NPCs/TikiSorcerer.cs @@ -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 TikiSorcerer : ModNPC { public override void SetStaticDefaults() @@ -30,25 +32,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 0); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(45) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("WoodenFrame")); - }; - } + if (Main.rand.Next(45) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -56,9 +43,8 @@ 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/TSGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TSGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TSGore2"), 1f); diff --git a/NPCs/TikiWarrior.cs b/NPCs/TikiWarrior.cs index 4eda2f49..75aef891 100644 --- a/NPCs/TikiWarrior.cs +++ b/NPCs/TikiWarrior.cs @@ -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 TikiWarrior : ModNPC { public override void SetStaticDefaults() @@ -31,25 +33,10 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 0, 0); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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(45) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("WoodenFrame")); - }; - } + if (Main.rand.Next(45) == 0) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/TremorGlobalNPC.cs b/NPCs/TremorGlobalNPC.cs index 2c0c88d6..58fbe4b5 100644 --- a/NPCs/TremorGlobalNPC.cs +++ b/NPCs/TremorGlobalNPC.cs @@ -1,12 +1,12 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { public class TremorGlobalNPC : GlobalNPC { - public override bool InstancePerEntity => true; public bool dFear; @@ -14,7 +14,6 @@ public class TremorGlobalNPC : GlobalNPC public override void ResetEffects(NPC npc) { - //TremorNPCInfo info = (TremorNPCInfo)npc.GetModInfo(mod, "TremorNPCInfo"); dFear = false; } @@ -23,14 +22,11 @@ public override void UpdateLifeRegen(NPC npc, ref int damage) if (dFear) { if (npc.lifeRegen > 0) - { npc.lifeRegen = 0; - } + npc.lifeRegen -= 50; if (damage < 50) - { damage = 50; - } } } @@ -40,14 +36,14 @@ public override void DrawEffects(NPC npc, ref Color drawColor) { if (Main.rand.Next(4) < 3) { - int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, mod.DustType(), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 3.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; + Dust dust = Main.dust[Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, mod.DustType(), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 3.5f)]; + dust.noGravity = true; + dust.velocity *= 1.8f; + dust.velocity.Y -= 0.5f; if (Main.rand.Next(4) == 0) { - Main.dust[dust].noGravity = false; - Main.dust[dust].scale *= 0.5f; + dust.noGravity = false; + dust.scale *= 0.5f; } } Lighting.AddLight(npc.position, 0.1f, 0.2f, 0.7f); diff --git a/NPCs/TremorNPC.cs b/NPCs/TremorNPC.cs index dcc8c70e..8c77c3f4 100644 --- a/NPCs/TremorNPC.cs +++ b/NPCs/TremorNPC.cs @@ -1,6 +1,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; + using Tremor.Items; namespace Tremor.NPCs @@ -9,7 +10,6 @@ public class TremorNPC : GlobalNPC { public override void NPCLoot(NPC npc) { - if (NPC.downedMoonlord) { if (npc.type == 147) @@ -875,14 +875,13 @@ public override void NPCLoot(NPC npc) mod.ItemType("CursedSoul"), Main.rand.Next(1, 5)); } - if (npc.type == 398) + if (npc.type == NPCID.MoonLordCore) { - if (!TremorWorld.Boss.Tremode.IsDowned()) // ਬ ६ + if (!TremorWorld.Boss.Tremode.IsDowned()) { Main.NewText("Nightmares became reality!", 90, 0, 157); Main.NewText("The moon slowly drifts towards the Earth...", 0, 255, 255); - for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++) { int i2 = WorldGen.genRand.Next(0, Main.maxTilesX); @@ -913,23 +912,20 @@ public override void NPCLoot(NPC npc) } } - TremorWorld.Boss.Tremode.Downed(); // 㡠 ६ + TremorWorld.Boss.Tremode.Downed(); } } - - } public override void SetupShop(int type, Chest shop, ref int nextSlot) { if (type == NPCID.Merchant && Main.bloodMoon) { - shop.item[nextSlot].SetDefaults(mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); nextSlot++; } } - public override void SetDefaults(NPC npc) { if (npc.type == 46) diff --git a/NPCs/TwilightBat.cs b/NPCs/TwilightBat.cs index f21191f7..3da98596 100644 --- a/NPCs/TwilightBat.cs +++ b/NPCs/TwilightBat.cs @@ -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 TwilightBat : ModNPC { public override void SetStaticDefaults() @@ -14,7 +16,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 4; } - public override void SetDefaults() { npc.lifeMax = 1200; @@ -34,24 +35,10 @@ public override void SetDefaults() bannerItem = mod.ItemType("TwilightBatBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("NightmareOre")); - } - } + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -59,12 +46,12 @@ 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, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TwilightGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TwilightGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TwilightGore2"), 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 2f); Dust.NewDust(npc.position, npc.width, npc.height, 27, 2.5f * hitDirection, -2.5f, 0, default(Color), 3f); @@ -72,11 +59,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && y < Main.worldSurface ? 0.02f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedMoonlord && Main.hardMode && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.02f : 0f; } } \ No newline at end of file diff --git a/NPCs/UndeadArchaeologist.cs b/NPCs/UndeadArchaeologist.cs index 17b2991c..f87063fa 100644 --- a/NPCs/UndeadArchaeologist.cs +++ b/NPCs/UndeadArchaeologist.cs @@ -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 UndeadArchaeologist : ModNPC { public override void SetStaticDefaults() @@ -33,15 +33,13 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("UndeadArchaeologistBanner"); } - 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UAG1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UAG2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UAG2"), 1f); @@ -50,18 +48,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.NormalSpawn(spawnInfo) && !Main.dayTime && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneDesert ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && !Main.dayTime && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDesert ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/UndeadArchaeologist2.cs b/NPCs/UndeadArchaeologist2.cs index f235ef76..7a36f045 100644 --- a/NPCs/UndeadArchaeologist2.cs +++ b/NPCs/UndeadArchaeologist2.cs @@ -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 UndeadArchaeologist2 : ModNPC { public override void SetStaticDefaults() @@ -33,20 +33,13 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("UndeadArchaeologistBanner"); } - 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, 5, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UAG4"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UAG2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UAG2"), 1f); @@ -56,16 +49,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - - { - - int x = spawnInfo.spawnTileX; - - int y = spawnInfo.spawnTileY; - - int tile = Main.tile[x, y].type; - - return (Helper.NormalSpawn(spawnInfo) && !Main.dayTime && Helper.NoZoneAllowWater(spawnInfo)) && spawnInfo.player.ZoneDesert ? 0.04f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && !Main.dayTime && Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneDesert ? 0.04f : 0f; } } \ No newline at end of file diff --git a/NPCs/UndeadMusketeer.cs b/NPCs/UndeadMusketeer.cs index 205caf06..67202753 100644 --- a/NPCs/UndeadMusketeer.cs +++ b/NPCs/UndeadMusketeer.cs @@ -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 UndeadMusketeer : ModNPC { public override void SetStaticDefaults() @@ -30,10 +32,15 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 1, 0); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void NPCLoot() { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; + if (Main.rand.Next(22) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(25) == 0) + this.NewItem(mod.ItemType()); + // Blunderbuss does not exist in the Tremor namespace. + //if (Main.rand.Next(28) == 0) + // this.NewItem(mod.ItemType()); } public override void HitEffect(int hitDirection, double damage) @@ -41,9 +48,8 @@ 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/ZombieGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZombieGore2"), 1f); @@ -52,33 +58,7 @@ 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(22) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MusketeerHat")); - }; - if (Main.rand.Next(25) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FencingRapier")); - }; - if (Main.rand.Next(28) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BlunderBuss")); - }; - } - } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedBoss2 && !Main.dayTime && y < Main.worldSurface ? 0.02f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss2 && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.02f : 0f; } } \ No newline at end of file diff --git a/NPCs/UndeadWarlock.cs b/NPCs/UndeadWarlock.cs index 938acf49..64ada3a8 100644 --- a/NPCs/UndeadWarlock.cs +++ b/NPCs/UndeadWarlock.cs @@ -1,12 +1,11 @@ -using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + namespace Tremor.NPCs { - public class UndeadWarlock : ModNPC { public override void SetStaticDefaults() @@ -15,14 +14,12 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 15; } + const int ShootRate = 250; + const int ShootDamage = 20; + const float ShootKN = 1.0f; + const float ShootSpeed = 4; - const int ShootRate = 250; // ५ - const int ShootDamage = 20; // ஭ . - const float ShootKN = 1.0f; // 뢠 - const int ShootType = 96; // த⠩ 㤥 ந ५. - const float ShootSpeed = 4; // , ⠪ , 쭮 ५ - - int TimeToShoot = ShootRate; // ६ ५. + int TimeToShoot = 0; public override void SetDefaults() { @@ -38,38 +35,26 @@ public override void SetDefaults() npc.aiStyle = 3; aiType = 524; animationType = 21; + + TimeToShoot = 0; } public override void AI() { - if (--TimeToShoot <= 0 && npc.target != -1) Shoot(); // ⮩ ப ६ TimeToShot ⭨ 1, ᫨ TimeToShot < = 0, 뢠 ⮤ Shoot() - - if (Main.rand.Next(210) == 0) + if (Main.netMode != 1 && TimeToShoot++ >= ShootRate && npc.target != -1) { - NPC.NewNPC((int)npc.position.X + 50, (int)npc.position.Y, 34); - } + Vector2 velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ShootSpeed; + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ProjectileID.CursedFlameHostile, ShootDamage, ShootKN); - for (int num74 = npc.oldPos.Length - 1; num74 > 0; num74--) - { - npc.oldPos[num74] = npc.oldPos[num74 - 1]; + TimeToShoot = 0; } - npc.oldPos[0] = npc.position; - } - void Shoot() - { - TimeToShoot = ShootRate; // ⠭ 㫤 ५ - Vector2 velocity = VelocityFPTP(npc.Center, Main.player[npc.target].Center, ShootSpeed); // 稬 㦭 velocity (᭥ 㬥⮢ ) - // 1 㬥 - ன 㤥 뫥 ५ - // 2 㬥 - - // 3 㬥 - ᪮ ५ - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, ShootDamage, ShootKN); - } + if (Main.netMode != 1 && Main.rand.Next(210) == 0) + NPC.NewNPC((int)npc.position.X + 50, (int)npc.position.Y, NPCID.CursedSkull); - Vector2 VelocityFPTP(Vector2 pos1, Vector2 pos2, float speed) - { - Vector2 move = pos2 - pos1; - return move * (speed / (float)Math.Sqrt(move.X * move.X + move.Y * move.Y)); + for (int i = npc.oldPos.Length - 1; i > 0; i--) + npc.oldPos[i] = npc.oldPos[i - 1]; + npc.oldPos[0] = npc.position; } public override void HitEffect(int hitDirection, double damage) @@ -77,9 +62,8 @@ 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); - } + Dust.NewDust(npc.position, npc.width, npc.height, 151, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 151, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 151, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); @@ -93,11 +77,6 @@ public override void HitEffect(int hitDirection, double damage) public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && NPC.downedBoss3 && !Main.dayTime && y < Main.worldSurface ? 0.008f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && NPC.downedBoss3 && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.008f : 0f; } } \ No newline at end of file diff --git a/NPCs/UndeadWarrior1.cs b/NPCs/UndeadWarrior1.cs index 45edd2fa..0b39cb5d 100644 --- a/NPCs/UndeadWarrior1.cs +++ b/NPCs/UndeadWarrior1.cs @@ -1,11 +1,14 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; +using Tremor.ZombieEvent.Items; + namespace Tremor.NPCs { - public class UndeadWarrior1 : ModNPC { public override void SetStaticDefaults() @@ -32,14 +35,25 @@ public override void SetDefaults() bannerItem = mod.ItemType("UndeadWarriorBanner"); } + public override void NPCLoot() + { + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); + } + 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadWarrior1Gore1"), 1f); @@ -49,39 +63,7 @@ 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(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MeltedInvarSword")); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenInvarShield")); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OldInvarPlate")); - }; - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TornPapyrus")); - }; - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.05f : 0f; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.05f : 0f; } } \ No newline at end of file diff --git a/NPCs/UndeadWarrior2.cs b/NPCs/UndeadWarrior2.cs index d351f4db..d83ed62a 100644 --- a/NPCs/UndeadWarrior2.cs +++ b/NPCs/UndeadWarrior2.cs @@ -1,11 +1,14 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; +using Tremor.ZombieEvent.Items; + namespace Tremor.NPCs { - public class UndeadWarrior2 : ModNPC { public override void SetStaticDefaults() @@ -32,14 +35,25 @@ public override void SetDefaults() bannerItem = mod.ItemType("UndeadWarriorBanner"); } + public override void NPCLoot() + { + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); + } + 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadWarrior2Gore1"), 1f); @@ -49,39 +63,7 @@ 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(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MeltedInvarSword")); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenInvarShield")); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OldInvarPlate")); - }; - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TornPapyrus")); - }; - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.05f : 0f; - } + => (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.05f : 0f; } } \ No newline at end of file diff --git a/NPCs/UndeadWarrior3.cs b/NPCs/UndeadWarrior3.cs index 813063da..b7066912 100644 --- a/NPCs/UndeadWarrior3.cs +++ b/NPCs/UndeadWarrior3.cs @@ -1,11 +1,14 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; +using Tremor.ZombieEvent.Items; + namespace Tremor.NPCs { - public class UndeadWarrior3 : ModNPC { public override void SetStaticDefaults() @@ -32,14 +35,25 @@ public override void SetDefaults() bannerItem = mod.ItemType("UndeadWarriorBanner"); } + public override void NPCLoot() + { + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); + } + 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadWarrior3Gore1"), 1f); @@ -49,38 +63,7 @@ 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(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MeltedInvarSword")); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenInvarShield")); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OldInvarPlate")); - }; - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TornPapyrus")); - }; - } - } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.08f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.08f : 0f; } } \ No newline at end of file diff --git a/NPCs/UndeadWarrior4.cs b/NPCs/UndeadWarrior4.cs index a4695713..9acad104 100644 --- a/NPCs/UndeadWarrior4.cs +++ b/NPCs/UndeadWarrior4.cs @@ -1,11 +1,14 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; +using Tremor.ZombieEvent.Items; + namespace Tremor.NPCs { - public class UndeadWarrior4 : ModNPC { public override void SetStaticDefaults() @@ -32,14 +35,25 @@ public override void SetDefaults() bannerItem = mod.ItemType("UndeadWarriorBanner"); } + public override void NPCLoot() + { + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(5) == 0) + this.NewItem(mod.ItemType()); + if (Main.rand.Next(30) == 0) + this.NewItem(mod.ItemType()); + } + 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/UndeadGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/UndeadWarrior4Gore1"), 1f); @@ -49,39 +63,7 @@ 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(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MeltedInvarSword")); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenInvarShield")); - }; - if (Main.rand.Next(5) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OldInvarPlate")); - }; - if (Main.rand.Next(30) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TornPapyrus")); - }; - } - } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.1f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/Undertaker.cs b/NPCs/Undertaker.cs index f1b29fdd..b6f6a3cf 100644 --- a/NPCs/Undertaker.cs +++ b/NPCs/Undertaker.cs @@ -1,7 +1,9 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + using Tremor.Items; namespace Tremor.NPCs @@ -30,6 +32,7 @@ public override void SetStaticDefaults() NPCID.Sets.AttackTime[npc.type] = 30; NPCID.Sets.AttackAverageChance[npc.type] = 30; } + public override void SetDefaults() { npc.townNPC = true; @@ -89,10 +92,7 @@ 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) diff --git a/NPCs/Warlock.cs b/NPCs/Warlock.cs index 995783d7..0ac77fa6 100644 --- a/NPCs/Warlock.cs +++ b/NPCs/Warlock.cs @@ -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 { - [AutoloadHead] public class Warlock : ModNPC { @@ -48,31 +50,20 @@ public override void SetDefaults() } 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(4)) + string[] names = { - case 0: - return "Azazel"; - case 1: - return "Baphomet"; - case 2: - return "Vaal"; - case 3: - return "Dis"; - case 4: - return "Nisroke"; - default: - return "Sabnak"; - } + "Azazel", + "Baphomet", + "Vaal", + "Dis", + "Nisroke", + "Sabnak" + }; + return names.TakeRandom(); } public override string GetChat() @@ -91,52 +82,37 @@ 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.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (NPC.downedBoss3) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("BallnChain")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (WorldGen.crimson) { - shop.item[nextSlot].SetDefaults(mod.ItemType("ViciousHelmet")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("ViciousChestplate")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("ViciousLeggings")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } - - if (!WorldGen.crimson) + else { - shop.item[nextSlot].SetDefaults(mod.ItemType("VileHelmet")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("VileChestplate")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("VileLeggings")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } - shop.item[nextSlot].SetDefaults(mod.ItemType("StrongBelt")); - nextSlot++; + if (Main.hardMode) { - shop.item[nextSlot].SetDefaults(mod.ItemType("Necronomicon")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("Zephyrhorn")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } + if (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("NecroWarhammer")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } public override void TownNPCAttackStrength(ref int damage, ref float knockback) @@ -169,12 +145,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/WarlockGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WarlockGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WarlockGore3"), 1f); + + for (int i = 0; i < 3; i++) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/WarlockGore{i + 1}"), 1f); } } } diff --git a/NPCs/Witch.cs b/NPCs/Witch.cs index 590c635b..eb65a1bd 100644 --- a/NPCs/Witch.cs +++ b/NPCs/Witch.cs @@ -1,11 +1,16 @@ -using Microsoft.Xna.Framework; +using System.Linq; + using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; +using Tremor.Projectiles; + namespace Tremor.NPCs { - [AutoloadHead] public class Witch : ModNPC { @@ -48,57 +53,33 @@ public override void SetDefaults() } public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - for (int k = 0; k < 255; k++) - { - Player player = Main.player[k]; - if (player.active) - { - for (int j = 0; j < player.inventory.Length; j++) - { - if (player.inventory[j].type == 1774) - { - return true; - } - } - } - } - return false; - } + => Main.player.Any(player => player.active && player.inventory.Any(item => item != null && item.type == ItemID.GoodieBag)); public override string TownNPCName() { - switch (WorldGen.genRand.Next(4)) + string[] names = { - case 0: - return "Circe"; - case 1: - return "Kikimora"; - case 2: - return "Morgana"; - default: - return "Hecate"; - } + "Circe", + "Kikimora", + "Morgana", + "Hecate" + }; + return names.TakeRandom(); } public override string GetChat() { - switch (Main.rand.Next(6)) + string[] chats = { - case 0: - return " Welcome dearies! I hope you don't mind the body parts. I was cleaning."; - case 1: - return "Eye of a newt! Tongue of a cat! Blood of a dryad... a little more blood."; - case 2: - return "Don't pull my nose! It's not a mask!"; - case 3: - return "The moon has a secret dearies! One that you'll know soon enough!"; - case 4: - return "This is halloween! Or isn't it?"; - default: - return "Blood for the blood moon! Skulls for the skull cap...or was it something else?"; - } + " Welcome dearies! I hope you don't mind the body parts. I was just cleaning up.", + "Eye of a newt! Tongue of a cat! Blood of a dryad... a little more blood.", + "Don't pull my nose! It's not a mask!", + "The moon has a secret dearies! One that you'll know soon enough!", + "This is halloween! Or is it?", + "Blood for the blood moon! Skulls for the skull cap... Or was it something else?" + }; + return chats.TakeRandom(); } public override void SetChatButtons(ref string button, ref string button2) @@ -108,37 +89,22 @@ 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("PlagueMask")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("PlagueRobe")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("SacrificalScythe")); - nextSlot++; - shop.item[nextSlot].SetDefaults(mod.ItemType("Scarecrow")); - nextSlot++; + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); + if (NPC.downedBoss1) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("BoomSpear")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); if (NPC.downedBoss2) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("BlackRose")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); if (NPC.downedBoss3) - { - shop.item[nextSlot].SetDefaults(mod.ItemType("Pumpspell")); - nextSlot++; - } + shop.AddUniqueItem(ref nextSlot, mod.ItemType()); } public override void TownNPCAttackStrength(ref int damage, ref float knockback) @@ -155,7 +121,7 @@ public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCo public override void TownNPCAttackProj(ref int projType, ref int attackDelay) { - projType = mod.ProjectileType("PumpkinPro"); + projType = mod.ProjectileType(); attackDelay = 2; } @@ -170,12 +136,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/WitchGore1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WitchGore2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WitchGore3"), 1f); + + for (int i = 0; i < 3; i++) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/WitchGore{i + 1}"), 1f); } } } diff --git a/NPCs/Woodling.cs b/NPCs/Woodling.cs index 4e64f3a8..386ab36f 100644 --- a/NPCs/Woodling.cs +++ b/NPCs/Woodling.cs @@ -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 Woodling : ModNPC { public override void SetStaticDefaults() @@ -13,8 +13,7 @@ public override void SetStaticDefaults() DisplayName.SetDefault("Woodling"); Main.npcFrameCount[npc.type] = 10; } - - + public override void SetDefaults() { npc.lifeMax = 90; @@ -34,24 +33,10 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("WoodlingBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 9); - } - } + if (Main.rand.NextBool()) + this.NewItem(ItemID.Wood, Main.rand.Next(1, 6)); } public override void HitEffect(int hitDirection, double damage) @@ -59,9 +44,8 @@ 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, 74, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WoodlingGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WoodlingGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WoodlingGore2"), 1f); @@ -72,11 +56,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && NPC.downedBoss1 && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.002f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && NPC.downedBoss1 && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.002f : 0f; } } \ No newline at end of file diff --git a/NPCs/WoodlingWarrior.cs b/NPCs/WoodlingWarrior.cs index 45736a0f..94d91268 100644 --- a/NPCs/WoodlingWarrior.cs +++ b/NPCs/WoodlingWarrior.cs @@ -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 WoodlingWarrior : ModNPC { public override void SetStaticDefaults() @@ -14,7 +16,6 @@ public override void SetStaticDefaults() Main.npcFrameCount[npc.type] = 10; } - public override void SetDefaults() { npc.lifeMax = 160; @@ -34,28 +35,12 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("WoodlingWarriorBanner"); } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = npc.lifeMax * 1; - npc.damage = npc.damage * 1; - } - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 9); - } - if (Main.rand.Next(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ManaFruit"), Main.rand.Next(1, 2)); - } - } + if (Main.rand.NextBool()) + this.NewItem(ItemID.Wood, Main.rand.Next(1, 6)); + if (Main.rand.Next(3) == 0) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); } public override void HitEffect(int hitDirection, double damage) @@ -63,9 +48,8 @@ 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, 74, 2.5f * hitDirection, -2.5f, 0, default(Color), 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WoodlingGore4"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WoodlingGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WoodlingGore2"), 1f); @@ -82,11 +66,6 @@ public override void HitEffect(int hitDirection, double damage) } public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - int x = spawnInfo.spawnTileX; - int y = spawnInfo.spawnTileY; - int tile = Main.tile[x, y].type; - return (Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && NPC.downedBoss2 && y < Main.worldSurface ? 0.001f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && NPC.downedBoss2 && spawnInfo.spawnTileY < Main.worldSurface ? 0.001f : 0f; } } \ No newline at end of file diff --git a/NPCs/Woody.cs b/NPCs/Woody.cs index 134b5237..c9c3c85b 100644 --- a/NPCs/Woody.cs +++ b/NPCs/Woody.cs @@ -4,7 +4,6 @@ namespace Tremor.NPCs { - public class Woody : ModNPC { public override void SetStaticDefaults() @@ -31,12 +30,6 @@ public override void SetDefaults() bannerItem = mod.ItemType("WoodyBanner"); } - 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) @@ -45,12 +38,8 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WoodyGore2"), 1f); } } + 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.player.ZoneJungle && y > Main.rockLayer ? 0.01f : 0f; - } + => Helper.NoZoneAllowWater(spawnInfo) && spawnInfo.player.ZoneJungle && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/YGiantSlime.cs b/NPCs/YGiantSlime.cs index 13699e53..c2e82ef2 100644 --- a/NPCs/YGiantSlime.cs +++ b/NPCs/YGiantSlime.cs @@ -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 YGiantSlime : ModNPC { public override void SetStaticDefaults() @@ -33,6 +33,12 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 0, 12, 15); } + public override void NPCLoot() + { + if (Main.rand.NextBool()) + this.NewItem(ItemID.Gel, Main.rand.Next(1, 4)); + } + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) @@ -42,6 +48,7 @@ public override void HitEffect(int hitDirection, double damage) Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); } + Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); Dust.NewDust(npc.position, npc.width, npc.height, 4, 2.5f * hitDirection, -2.5f, 0, Color.Yellow, 0.7f); @@ -49,33 +56,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 Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && y > Main.rockLayer ? 0.1f : 0f; - } - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 23); - }; - } - } - + => Main.hardMode && NPC.downedMoonlord && !spawnInfo.player.ZoneDungeon && spawnInfo.spawnTileY > Main.rockLayer ? 0.1f : 0f; } } \ No newline at end of file diff --git a/NPCs/Zarprite.cs b/NPCs/Zarprite.cs index 73c6a485..b43cd204 100644 --- a/NPCs/Zarprite.cs +++ b/NPCs/Zarprite.cs @@ -4,7 +4,6 @@ namespace Tremor.NPCs { - public class Zarprite : ModNPC { public override void SetStaticDefaults() @@ -32,28 +31,21 @@ public override void SetDefaults() bannerItem = mod.ItemType("ZarpriteBanner"); } - 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) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZarpriteGore"), 1f); - NPC.NewNPC((int)npc.position.X - 6, (int)npc.position.Y + 6, mod.NPCType("Parasprite")); - NPC.NewNPC((int)npc.position.X + 6, (int)npc.position.Y, mod.NPCType("Parasprite")); - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 6, mod.NPCType("Parasprite")); + + if (Main.netMode == 1) return; + + NPC.NewNPC((int)npc.position.X - 6, (int)npc.position.Y + 6, mod.NPCType()); + NPC.NewNPC((int)npc.position.X + 6, (int)npc.position.Y, mod.NPCType()); + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 6, mod.NPCType()); } } + 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; } } \ No newline at end of file diff --git a/NPCs/Zarprute.cs b/NPCs/Zarprute.cs index d7dcce27..976ab2af 100644 --- a/NPCs/Zarprute.cs +++ b/NPCs/Zarprute.cs @@ -4,7 +4,6 @@ namespace Tremor.NPCs { - public class Zarprute : ModNPC { public override void SetStaticDefaults() @@ -32,12 +31,6 @@ public override void SetDefaults() bannerItem = mod.ItemType("ZarpruteBanner"); } - 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) @@ -45,17 +38,16 @@ public override void HitEffect(int hitDirection, double damage) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZarpruteGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZarpruteGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZarpruteGore2"), 1f); - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y + 15, mod.NPCType("Zarprite")); - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Zarprite")); - NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 15, mod.NPCType("Zarprite")); + + if (Main.netMode == 1) return; + + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y + 15, mod.NPCType()); + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType()); + NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 15, mod.NPCType()); } } + 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)) && Main.hardMode && y > Main.rockLayer ? 0.01f : 0f; - } + => (Helper.NoZoneAllowWater(spawnInfo)) && Main.hardMode && spawnInfo.spawnTileY > Main.rockLayer ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/Zootaloo.cs b/NPCs/Zootaloo.cs index eb2cb4a0..c453b929 100644 --- a/NPCs/Zootaloo.cs +++ b/NPCs/Zootaloo.cs @@ -1,14 +1,15 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using Tremor.Items; + namespace Tremor.NPCs { - public class Zootaloo : ModNPC { - public override void SetStaticDefaults() { DisplayName.SetDefault("Zootaloo"); @@ -33,58 +34,33 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("ZootalooBanner"); } + public override void NPCLoot() + { + if (Main.rand.Next(3) == 0) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); + if (Main.rand.Next(2) == 0) + this.NewItem(mod.ItemType(), Main.rand.Next(5, 13)); + } + 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, 44, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZootalooGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZootalooGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZootalooGore2"), 1f); } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 44, hitDirection, -1f, 0, default(Color), 0.7f); - } } } - - 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(3) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LightBulb"), Main.rand.Next(1, 3)); - } - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Gloomstone"), Main.rand.Next(5, 12)); - } - } - } - - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.01f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.01f : 0f; } } \ No newline at end of file diff --git a/NPCs/ZootalooMatriarch.cs b/NPCs/ZootalooMatriarch.cs index 6a9da4f7..4c0b7a41 100644 --- a/NPCs/ZootalooMatriarch.cs +++ b/NPCs/ZootalooMatriarch.cs @@ -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 ZootalooMatriarch : ModNPC { public override void SetStaticDefaults() @@ -33,62 +35,35 @@ public override void SetDefaults() // Todo: bannerItem = mod.ItemType("ZootalooMatriarchBanner"); } + public override void NPCLoot() + { + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); + if (Main.rand.Next(20) == 0) + this.NewItem(mod.ItemType(), Main.rand.Next(1, 3)); + if (Main.rand.NextBool()) + this.NewItem(mod.ItemType(), Main.rand.Next(10, 21)); + } + 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, 44, 2.5f * hitDirection, -2.5f, 0, default(Color), 0.7f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZootalooGore1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZootalooGore2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ZootalooGore2"), 1f); } else { - for (int k = 0; k < damage / npc.lifeMax * 50.0; k++) - { + for (int k = 0; k < damage / npc.lifeMax * 50; k++) Dust.NewDust(npc.position, npc.width, npc.height, 44, hitDirection, -1f, 0, default(Color), 0.7f); - } - } - } - - - 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.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LightBulb"), Main.rand.Next(1, 3)); - } - if (Main.rand.Next(20) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ZootalooEgg"), Main.rand.Next(1, 3)); - } - if (Main.rand.NextBool()) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Gloomstone"), Main.rand.Next(10, 20)); - } } } - 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.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo)) && !Main.dayTime && y < Main.worldSurface ? 0.001f : 0f; - } + => Helper.NormalSpawn(spawnInfo) && Helper.NoZoneAllowWater(spawnInfo) && !Main.dayTime && spawnInfo.spawnTileY < Main.worldSurface ? 0.001f : 0f; } } \ No newline at end of file diff --git a/Tremor.csproj b/Tremor.csproj index 1e371577..48efa0ac 100644 --- a/Tremor.csproj +++ b/Tremor.csproj @@ -51,9 +51,6 @@ False ..\..\dllReferences\Microsoft.Xna.Framework.Xact.dll - - ..\..\..\..\..\GitHub\tModLoader\references\ReLogic.dll - @@ -61,7 +58,10 @@ - ..\..\..\..\..\..\..\Apps\Steam\steamapps\common\Terraria\Terraria.exe + ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Terraria\Terraria.exe + + + ..\..\My Games\Terraria\ModLoader\dllReferences\Terraria.Libraries.ReLogic.ReLogic.dll @@ -1953,7 +1953,6 @@ - @@ -1986,7 +1985,6 @@ - diff --git a/TremorPlayer.cs b/TremorPlayer.cs index 6e0e2856..33f12afc 100644 --- a/TremorPlayer.cs +++ b/TremorPlayer.cs @@ -8,6 +8,9 @@ using Terraria.DataStructures; using Terraria.Graphics.Shaders; using Terraria.ModLoader; +using Terraria.ID; +using Tremor.Items; +using Tremor.NPCs; namespace Tremor { @@ -70,6 +73,8 @@ public class TremorPlayer : ModPlayer public bool ZoneTowerNova; public bool NovaMonolith = false; + public int LastChest; + public override void UpdateDead() { zellariumBody = false; @@ -79,6 +84,19 @@ public override void UpdateDead() public int zellariumHit; public int zellariumDash; public int zellariumCooldown; + public override void PreUpdateBuffs() + { + if (Main.netMode != 1) + { + if (player.chest == -1 && LastChest >= 0 && Main.chest[LastChest] != null) + { + int x2 = Main.chest[LastChest].x; + int y2 = Main.chest[LastChest].y; + ChestItemSummonCheck(x2, y2, mod); + } + LastChest = player.chest; + } + } public override void PostUpdateEquips() { if (zellariumHead) @@ -574,5 +592,143 @@ public override void CatchFish(Item fishingRod, Item bait, int power, int liquid } } } + + // Straight up copy from removed `DesertMimicSummon` class. + public static bool ChestItemSummonCheck(int x, int y, Mod mod) + { + if (Main.netMode == 1) return false; + + int num = Chest.FindChest(x, y); + if (num < 0) return false; + + int numberDesertKey = 0; + int numberJungleKey = 0; + int numberOceanKey = 0; + int numberOtherItems = 0; + + ushort tileType = Main.tile[Main.chest[num].x, Main.chest[num].y].type; + int tileStyle = Main.tile[Main.chest[num].x, Main.chest[num].y].frameX / 36; + if (TileID.Sets.BasicChest[tileType] && (tileStyle < 5 || tileStyle > 6)) + { + for (int i = 0; i < 40; i++) + { + if (Main.chest[num].item[i] != null && Main.chest[num].item[i].type > 0) + { + if (Main.chest[num].item[i].type == mod.ItemType()) + numberDesertKey += Main.chest[num].item[i].stack; + else if (Main.chest[num].item[i].type == mod.ItemType()) + numberJungleKey += Main.chest[num].item[i].stack; + else if (Main.chest[num].item[i].type == mod.ItemType()) + numberOceanKey += Main.chest[num].item[i].stack; + else + numberOtherItems++; + } + } + } + if (numberOtherItems == 0 && numberDesertKey == 1) + { + if (TileID.Sets.BasicChest[Main.tile[x, y].type]) + { + if (Main.tile[x, y].frameX % 36 != 0) + x--; + if (Main.tile[x, y].frameY % 36 != 0) + y--; + int number = Chest.FindChest(x, y); + for (int j = x; j <= x + 1; j++) + { + for (int k = y; k <= y + 1; k++) + { + if (Main.tile[j, k].type == TileID.Containers) + Main.tile[j, k].active(false); + } + } + for (int l = 0; l < 40; l++) + Main.chest[num].item[l] = new Item(); + Chest.DestroyChest(x, y); + NetMessage.SendData(34, -1, -1, null, 1, x, y, 0f, number, 0, 0); + NetMessage.SendTileSquare(-1, x, y, 3); + } + int npcToSpawn = mod.NPCType(); + int npcIndex = NPC.NewNPC(x * 16 + 16, y * 16 + 32, npcToSpawn, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[npcIndex].whoAmI = npcIndex; + NetMessage.SendData(23, -1, -1, null, npcIndex, 0f, 0f, 0f, 0, 0, 0); + Main.npc[npcIndex].BigMimicSpawnSmoke(); + } + else if (numberOtherItems == 0 && numberJungleKey == 1) + { + if (TileID.Sets.BasicChest[Main.tile[x, y].type]) + { + if (Main.tile[x, y].frameX % 36 != 0) + { + x--; + } + if (Main.tile[x, y].frameY % 36 != 0) + { + y--; + } + int number = Chest.FindChest(x, y); + for (int j = x; j <= x + 1; j++) + { + for (int k = y; k <= y + 1; k++) + { + if (Main.tile[j, k].type == 21) + { + Main.tile[j, k].active(false); + } + } + } + for (int l = 0; l < 40; l++) + { + Main.chest[num].item[l] = new Item(); + } + Chest.DestroyChest(x, y); + NetMessage.SendData(34, -1, -1, null, 1, x, y, 0f, number, 0, 0); + NetMessage.SendTileSquare(-1, x, y, 3); + } + int npcToSpawn = mod.NPCType("JungleMimic"); + int npcIndex = NPC.NewNPC(x * 16 + 16, y * 16 + 32, npcToSpawn, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[npcIndex].whoAmI = npcIndex; + NetMessage.SendData(23, -1, -1, null, npcIndex, 0f, 0f, 0f, 0, 0, 0); + Main.npc[npcIndex].BigMimicSpawnSmoke(); + } + else if (numberOtherItems == 0 && numberOceanKey == 1) + { + if (TileID.Sets.BasicChest[Main.tile[x, y].type]) + { + if (Main.tile[x, y].frameX % 36 != 0) + { + x--; + } + if (Main.tile[x, y].frameY % 36 != 0) + { + y--; + } + int number = Chest.FindChest(x, y); + for (int j = x; j <= x + 1; j++) + { + for (int k = y; k <= y + 1; k++) + { + if (Main.tile[j, k].type == 21) + { + Main.tile[j, k].active(false); + } + } + } + for (int l = 0; l < 40; l++) + { + Main.chest[num].item[l] = new Item(); + } + Chest.DestroyChest(x, y); + NetMessage.SendData(34, -1, -1, null, 1, x, y, 0f, number, 0, 0); + NetMessage.SendTileSquare(-1, x, y, 3); + } + int npcToSpawn = mod.NPCType("OceanMimic"); + int npcIndex = NPC.NewNPC(x * 16 + 16, y * 16 + 32, npcToSpawn, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[npcIndex].whoAmI = npcIndex; + NetMessage.SendData(23, -1, -1, null, npcIndex, 0f, 0f, 0f, 0, 0, 0); + Main.npc[npcIndex].BigMimicSpawnSmoke(); + } + return false; + } } } diff --git a/TremorUtils.cs b/TremorUtils.cs index d539f7f2..a11d4a01 100644 --- a/TremorUtils.cs +++ b/TremorUtils.cs @@ -200,5 +200,14 @@ public static void DrawItemGlowMaskWorld(SpriteBatch spriteBatch, Item item, Tex scale, SpriteEffects.None, 0f ); } + + // DO NOT remove this method + // The trick here is to reference System.Core is some way, in any class + // This is a trick to get the mod to compile with extension methods + // Normally you would get an error, this is a workaround trick for now + public static void RedundantFunc() + { + var something = System.Linq.Enumerable.Range(1, 10); + } } }