using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; using TD6.AI; using System.Collections.Generic; /* bloon classes + rbe: red 1 blue 2 green 3 yellow 4 pink 5 purple 11 1hit -> 2 pink | immune except to sharp, cold, explosions white 11 1hit -> 2 pink | immune to cold black 11 1hit -> 2 pink | immune to explosions lead 23 1hit -> 2 black | immune to sharp zebra 23 1hit -> 1 black 1 white | immune to cold, explosions rainbow 47 1hit -> 2 zebra ceramic 104 10hit -> 2 rainbow */ namespace TD6.NPCs { public enum bloonTypes { RED, BLUE, GREEN, YELLOW, PINK, PURPLE, WHITE, BLACK, LEAD, ZEBRA, RAINBOW, CERAMIC, }; public enum damageTypes { SHARP, COLD, EXPLODE, HOT, MAGIC, } // This NPC inherits from the Hover abstract class included in ExampleMod, which is a more customizable copy of the vanilla Hovering AI. // It implements the `CustomBehavior` and `ShouldMove` virtual methods being overridden here, as well as the `acceleration` and `accelerationY` field being set in the class constructor. public class Bloon : Hover { public Dictionary bloonRBE = new Dictionary() { {bloonTypes.RED, 1}, {bloonTypes.BLUE, 2}, {bloonTypes.GREEN, 3}, {bloonTypes.YELLOW, 4}, {bloonTypes.PINK, 5}, {bloonTypes.PURPLE, 11}, {bloonTypes.WHITE, 11}, {bloonTypes.BLACK, 11}, {bloonTypes.LEAD, 23}, {bloonTypes.ZEBRA, 23}, {bloonTypes.RAINBOW, 47}, {bloonTypes.CERAMIC, 104}, }; public Dictionary bloonHealth = new Dictionary() { {bloonTypes.RED, 1}, {bloonTypes.BLUE, 1}, {bloonTypes.GREEN, 1}, {bloonTypes.YELLOW, 1}, {bloonTypes.PINK, 1}, {bloonTypes.PURPLE, 1}, {bloonTypes.WHITE, 1}, {bloonTypes.BLACK, 1}, {bloonTypes.LEAD, 1}, {bloonTypes.ZEBRA, 1}, {bloonTypes.RAINBOW, 1}, {bloonTypes.CERAMIC, 10}, }; public Dictionary bloonSpawns = new Dictionary() { {bloonTypes.RED, new bloonTypes[]{}}, {bloonTypes.BLUE, new bloonTypes[]{bloonTypes.RED}}, {bloonTypes.GREEN, new bloonTypes[]{bloonTypes.BLUE}}, {bloonTypes.YELLOW, new bloonTypes[]{bloonTypes.GREEN}}, {bloonTypes.PINK, new bloonTypes[]{bloonTypes.YELLOW}}, {bloonTypes.PURPLE, new bloonTypes[]{bloonTypes.PINK, bloonTypes.PINK}}, {bloonTypes.WHITE, new bloonTypes[]{bloonTypes.PINK, bloonTypes.PINK}}, {bloonTypes.BLACK, new bloonTypes[]{bloonTypes.PINK, bloonTypes.PINK}}, {bloonTypes.LEAD, new bloonTypes[]{bloonTypes.BLACK, bloonTypes.BLACK}}, {bloonTypes.ZEBRA, new bloonTypes[]{bloonTypes.WHITE, bloonTypes.BLACK}}, {bloonTypes.RAINBOW, new bloonTypes[]{bloonTypes.ZEBRA, bloonTypes.ZEBRA}}, {bloonTypes.CERAMIC, new bloonTypes[]{bloonTypes.RAINBOW, bloonTypes.RAINBOW}}, }; public Dictionary bloonImmune = new Dictionary() { {bloonTypes.RED, new damageTypes[]{}}, {bloonTypes.BLUE, new damageTypes[]{}}, {bloonTypes.GREEN, new damageTypes[]{}}, {bloonTypes.YELLOW, new damageTypes[]{}}, {bloonTypes.PINK, new damageTypes[]{}}, {bloonTypes.PURPLE, new damageTypes[]{damageTypes.MAGIC, damageTypes.HOT}}, {bloonTypes.WHITE, new damageTypes[]{damageTypes.COLD}}, {bloonTypes.BLACK, new damageTypes[]{damageTypes.EXPLODE}}, {bloonTypes.LEAD, new damageTypes[]{damageTypes.SHARP}}, {bloonTypes.ZEBRA, new damageTypes[]{damageTypes.COLD, damageTypes.EXPLODE}}, {bloonTypes.RAINBOW, new damageTypes[]{}}, {bloonTypes.CERAMIC, new damageTypes[]{}}, }; public bloonTypes bloonType; public bloonTypes startType; public bool camo; public bool regrow; public Bloon() { acceleration = 0.06f; accelerationY = 0.025f; } public override void SetDefaults() { this.bloonType = this.startType = (bloonTypes)Main.rand.Next(12); this.camo = Main.rand.NextBool(); this.regrow = Main.rand.NextBool(); npc.width = 28; npc.height = 36; npc.aiStyle = -1; npc.damage = bloonRBE[this.bloonType]; npc.friendly = false; npc.dontTakeDamageFromHostiles = true; } // Allows hitting the NPC with melee type weapons, even if it's friendly. public override bool? CanBeHitByItem(Player player, Item item) { return true; } // Same as the above but with projectiles. public override bool? CanBeHitByProjectile(Projectile projectile) { return projectile.friendly && projectile.owner < 255; } public override void HitEffect(int hitDirection, double damage) { for (int i = 0; i < damage; i++) { Terraria.Dust dust = Terraria.Dust.NewDustDirect(npc.position, npc.width, npc.height, 192, 0, 0f, 100, new Color(100, 100, 100, 100), 1f); dust.noGravity = true; } return; } public override void ModifyHitByItem(Player player, Item item, ref int damage, ref float knockback, ref bool crit) { int id = item.type; bool isModItem = item.modItem != null; } } }