From fdfebb08b227b08aa0902e3722ba11f69b1c53ec Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 26 Jun 2020 16:17:52 -0400 Subject: [PATCH] added netAlways to super dummies --- Items/SuperDummy.cs | 140 +++++++++++++++---------------- NPCs/NormalNPCs/SuperDummyNPC.cs | 73 ++++++++-------- 2 files changed, 107 insertions(+), 106 deletions(-) diff --git a/Items/SuperDummy.cs b/Items/SuperDummy.cs index b8b41984d0..bbb6e4b678 100644 --- a/Items/SuperDummy.cs +++ b/Items/SuperDummy.cs @@ -5,80 +5,80 @@ using Terraria.ModLoader; namespace CalamityMod.Items { - public class SuperDummy : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Super Dummy"); - Tooltip.SetDefault("Creates a super dummy\n" + - "Regenerates 1 million life per second\n" + - "Will not die when taking damage over time from debuffs\n" + - "Right click to kill all super dummies"); - } + public class SuperDummy : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Super Dummy"); + Tooltip.SetDefault("Creates a super dummy\n" + + "Regenerates 1 million life per second\n" + + "Will not die when taking damage over time from debuffs\n" + + "Right click to kill all super dummies"); + } - public override void SetDefaults() - { - item.damage = 0; - item.width = 20; - item.height = 30; - item.useTime = 15; - item.useAnimation = 15; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.value = 0; - item.rare = 1; - item.autoReuse = true; - } + public override void SetDefaults() + { + item.damage = 0; + item.width = 20; + item.height = 30; + item.useTime = 15; + item.useAnimation = 15; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTurn = true; + item.value = 0; + item.rare = 1; + item.autoReuse = true; + } - public override bool AltFunctionUse(Player player) - { - return true; - } + public override bool AltFunctionUse(Player player) + { + return true; + } - public override bool UseItem(Player player) - { - if (player.altFunctionUse == 2) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].type == ModContent.NPCType()) - { - Main.npc[i].life = 0; - Main.npc[i].lifeRegen = 0; - Main.npc[i].checkDead(); - Main.npc[i].netUpdate = true; - } - } - } - else if (player.whoAmI == Main.myPlayer) - { - int x = (int)Main.MouseWorld.X - 9; - int y = (int)Main.MouseWorld.Y - 20; + public override bool UseItem(Player player) + { + if (player.altFunctionUse == 2) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type == ModContent.NPCType()) + { + Main.npc[i].life = 0; + Main.npc[i].lifeRegen = 0; + Main.npc[i].checkDead(); + Main.npc[i].netUpdate = true; + } + } + } + else if (player.whoAmI == Main.myPlayer) + { + int x = (int)Main.MouseWorld.X - 9; + int y = (int)Main.MouseWorld.Y - 20; - // In single player, just spawn the dummy. - if (Main.netMode == NetmodeID.SinglePlayer) - NPC.NewNPC(x, y, ModContent.NPCType()); + // In single player, just spawn the dummy. + if (Main.netMode == NetmodeID.SinglePlayer) + NPC.NewNPC(x, y, ModContent.NPCType()); - // Otherwise, send a message to the server indicating that a Super Dummy should be spawned at this position. - else - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.SpawnSuperDummy); - netMessage.Write(x); - netMessage.Write(y); - netMessage.Send(); - } - } - return true; - } + // Otherwise, send a message to the server indicating that a Super Dummy should be spawned at this position. + else + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SpawnSuperDummy); + netMessage.Write(x); + netMessage.Write(y); + netMessage.Send(); + } + } + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.TargetDummy); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.TargetDummy); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/NPCs/NormalNPCs/SuperDummyNPC.cs b/NPCs/NormalNPCs/SuperDummyNPC.cs index 7cff1f8b9b..9cae353ab2 100644 --- a/NPCs/NormalNPCs/SuperDummyNPC.cs +++ b/NPCs/NormalNPCs/SuperDummyNPC.cs @@ -3,45 +3,46 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class SuperDummyNPC : ModNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Super Dummy"); - } + public class SuperDummyNPC : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Super Dummy"); + } - public override void SetDefaults() - { - npc.width = 18; - npc.height = 48; - npc.damage = 0; - npc.defense = 0; - npc.lifeMax = 9999999; - npc.HitSound = SoundID.NPCHit15; - npc.DeathSound = SoundID.NPCDeath2; - npc.value = 0f; - npc.knockBackResist = 0f; + public override void SetDefaults() + { + npc.width = 18; + npc.height = 48; + npc.damage = 0; + npc.defense = 0; + npc.lifeMax = 9999999; + npc.HitSound = SoundID.NPCHit15; + npc.DeathSound = SoundID.NPCDeath2; + npc.value = 0f; + npc.knockBackResist = 0f; npc.buffImmune[BuffID.Confused] = false; - } + npc.netAlways = true; + } - public override void UpdateLifeRegen(ref int damage) - { - npc.lifeRegen += 2000000; - } + public override void UpdateLifeRegen(ref int damage) + { + npc.lifeRegen += 2000000; + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + return false; + } - public override bool CheckDead() - { - if (npc.lifeRegen < 0) - { - npc.life = npc.lifeMax; - return false; - } - return true; - } - } + public override bool CheckDead() + { + if (npc.lifeRegen < 0) + { + npc.life = npc.lifeMax; + return false; + } + return true; + } + } }