diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..7feab7a1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*.cs] + +#use hard tabs for indentation +indent_style = tab +indent_size = 4 \ No newline at end of file diff --git a/AssPlayer.cs b/AssPlayer.cs index f6705dfb..3e363169 100644 --- a/AssPlayer.cs +++ b/AssPlayer.cs @@ -1,5 +1,4 @@ using AssortedCrazyThings.Base; -using AssortedCrazyThings.Buffs; using AssortedCrazyThings.Effects; using AssortedCrazyThings.Items; using AssortedCrazyThings.Items.Pets; @@ -20,812 +19,812 @@ namespace AssortedCrazyThings { - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - //[LegacyName("AssPlayer")] Maybe rename later - public sealed class AssPlayer : AssPlayerBase - { - public delegate void SlainBossDelegate(Player player, int type); - public static event SlainBossDelegate OnSlainBoss; //Runs on all sides - - public bool everburningCandleBuff = false; - public bool everburningCursedCandleBuff = false; - public bool everfrozenCandleBuff = false; - public bool everburningShadowflameCandleBuff = false; - - public bool teleportHome = false; - public bool canTeleportHome = false; - public const short TeleportHomeTimerMax = 600; //in seconds //10 ingame minutes - public short teleportHomeTimer = 0; //gets saved when you relog so you can't cheese it - - //TECHNICALLY NOT DEFENSE; YOU JUST GET 1 DAMAGE FROM EVERYTHING FOR A CERTAIN DURATION - public bool getDefense = false; - public bool canGetDefense = false; - public const short GetDefenseTimerMax = 600; //in seconds //10 ingame minutes - private const short GetDefenseDurationMax = 600; //in ticks //10 ingame seconds - public short getDefenseDuration = 0; - public short getDefenseTimer = 0; //gets saved when you relog so you can't cheese it - - private int lastSlainBossTimerSeconds = -1; //-1: never slain a boss, otherwise starts at 0 and counts - private int lastSlainBossTimerInternal = 0; //Used for incrementing the seconds timer - private int lastSlainBossType = 0; //Does not save - public bool HasBossSlainTimer => lastSlainBossTimerSeconds != -1; - - public bool needsNearbyEnemyNumber = false; - public int nearbyEnemyNumber = 0; //Impl of vanilla player.accThirdEyeNumber which works for all clients, shorter range - public int nearbyEnemyTimer = 0; - - //soul minion stuff - public bool soulMinion = false; - public Item tempSoulMinion = null; - public SoulType selectedSoulMinionType = SoulType.Dungeon; - - public bool slimePackMinion = false; - public byte selectedSlimePackMinionType = 0; - - public byte nextMagicSlimeSlingMinion = 0; - - //empowering buff stuff - public bool empoweringBuff = false; - private const short empoweringTimerMax = 60; //in seconds //one minute until it caps out (independent of buff duration) - private short empoweringTimer = 0; - public static float empoweringTotal = 0.5f; //this gets modified in AssWorld.PreUpdate() - public float empoweringStep = 0f; - - //enhanced hunter potion stuff - public bool enhancedHunterBuff = false; - - //cute slime spawn enable buff - public bool cuteSlimeSpawnEnable = false; - - public bool soulSaviorArmor = false; - - public bool wyvernCampfire = false; - - public bool droneControllerMinion = false; - - public const byte shieldDroneReductionMax = 35; - public const byte ShieldIncreaseAmount = 7; - public byte shieldDroneReduction = 0; //percentage * 100 - public float shieldDroneLerpVisual = 0; //percentage - - private bool drawEffectsCalledOnce = false; - - public bool mouseoveredDresser = false; - - /// - /// Bitfield. Use .HasFlag(DroneType.SomeType) to check if its there or not - /// - public DroneType droneControllerUnlocked = DroneType.None; - - /// - /// Contains the DroneType value - /// - public DroneType selectedDroneControllerMinionType = DroneType.BasicLaser; - - public override void ResetEffects() - { - everburningCandleBuff = false; - everburningCursedCandleBuff = false; - everfrozenCandleBuff = false; - everburningShadowflameCandleBuff = false; - teleportHome = false; - getDefense = false; - soulMinion = false; - tempSoulMinion = null; - slimePackMinion = false; - empoweringBuff = false; - enhancedHunterBuff = false; - cuteSlimeSpawnEnable = false; - soulSaviorArmor = false; - droneControllerMinion = false; - mouseoveredDresser = false; - - needsNearbyEnemyNumber = false; - } - - public bool RightClickPressed { get { return PlayerInput.Triggers.JustPressed.MouseRight; } } - - public bool RightClickReleased { get { return PlayerInput.Triggers.JustReleased.MouseRight; } } - - public bool LeftClickPressed { get { return PlayerInput.Triggers.JustPressed.MouseLeft; } } - - public bool LeftClickReleased { get { return PlayerInput.Triggers.JustReleased.MouseLeft; } } - - public override void SaveData(TagCompound tag) - { - tag.Add("teleportHomeWhenLowTimer", (int)teleportHomeTimer); - tag.Add("getDefenseTimer", (int)getDefenseTimer); - tag.Add("lastSlainBossTimerSeconds", (int)lastSlainBossTimerSeconds); - tag.Add("droneControllerUnlocked", (byte)droneControllerUnlocked); - } - - public override void LoadData(TagCompound tag) - { - teleportHomeTimer = (short)tag.GetInt("teleportHomeWhenLowTimer"); - getDefenseTimer = (short)tag.GetInt("getDefenseTimer"); - string timerKey = "lastSlainBossTimerSeconds"; - if (tag.ContainsKey(timerKey)) - { - lastSlainBossTimerSeconds = tag.GetInt("lastSlainBossTimerSeconds"); - } - droneControllerUnlocked = (DroneType)tag.GetByte("droneControllerUnlocked"); - } - - //TODO get rid of this, use manual packets since setting those values happens in a singular place - public override void clientClone(ModPlayer clientClone) - { - AssPlayer clone = clientClone as AssPlayer; - clone.shieldDroneReduction = shieldDroneReduction; - //Needs syncing because spawning drone parts depends on this serverside (See GeneralGlobalNPC.NPCLoot) - clone.droneControllerUnlocked = droneControllerUnlocked; - } - - public override void SendClientChanges(ModPlayer clientPlayer) - { - AssPlayer clone = clientPlayer as AssPlayer; - if (clone.shieldDroneReduction != shieldDroneReduction || - clone.droneControllerUnlocked != droneControllerUnlocked) - { - SendClientChangesPacket(); - } - } - - /// - /// Things that are sent to the server that are needed on-change - /// - public void SendClientChangesPacket(int toClient = -1, int ignoreClient = -1) - { - if (Main.netMode != NetmodeID.SinglePlayer) - { - ModPacket packet = Mod.GetPacket(); - packet.Write((byte)AssMessageType.ClientChangesAssPlayer); - packet.Write((byte)Player.whoAmI); - packet.Write((byte)shieldDroneReduction); - packet.Write((byte)droneControllerUnlocked); - packet.Send(toClient, ignoreClient); - } - } - - public override void SyncPlayer(int toWho, int fromWho, bool newPlayer) - { - ModPacket packet = Mod.GetPacket(); - packet.Write((byte)AssMessageType.SyncAssPlayer); - packet.Write((byte)Player.whoAmI); - - //Actual data here - packet.Write((byte)shieldDroneReduction); - packet.WriteVarInt(lastSlainBossTimerSeconds); - packet.WriteVarInt(lastSlainBossType); - - packet.Send(toWho, fromWho); - } - - public void ReceiveSyncPlayer(BinaryReader reader) - { - shieldDroneReduction = reader.ReadByte(); - lastSlainBossTimerSeconds = reader.ReadVarInt(); - lastSlainBossType = reader.ReadVarInt(); - } - - public override void OnEnterWorld(Player player) - { - SendClientChangesPacket(); - } - - /// - /// Resets the empowering timer from the Empowering Buff, spawns dust, sends sync - /// - public void ResetEmpoweringTimer(bool fromServer = false) - { - if (empoweringBuff && !Player.HasBuff(BuffID.ShadowDodge)) - { - for (int i = 0; i < empoweringTimer; i++) - { - Dust dust = Dust.NewDustPerfect(Player.Center, 135, new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-3f, 3f)) + (new Vector2(Main.rand.Next(-1, 1), Main.rand.Next(-1, 1)) * ((6 * empoweringTimer) / empoweringTimerMax)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); - dust.noLight = true; - dust.noGravity = true; - dust.fadeIn = Main.rand.NextFloat(1f, 2.3f); - } - empoweringTimer = 0; - - if (Main.netMode == NetmodeID.MultiplayerClient && !fromServer) - { - ModPacket packet = Mod.GetPacket(); - packet.Write((byte)AssMessageType.ResetEmpoweringTimerpvp); - packet.Write((byte)Player.whoAmI); - packet.Send(); //send to server - } - } - } - - /// - /// Decreases damage based on current shield level from the Shield Drone, spawns dust - /// - /// - public void DecreaseDroneShield(ref int damage) - { - if (shieldDroneReduction > 0) - { - for (int i = 0; i < shieldDroneReduction / 2; i++) - { - Dust dust = Dust.NewDustPerfect(Player.Center, 135, new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-3f, 3f)) + new Vector2(Main.rand.Next(-1, 1), Main.rand.Next(-1, 1)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); - dust.noLight = true; - dust.noGravity = true; - dust.fadeIn = Main.rand.NextFloat(1f, 2.3f); - } - - damage = (int)(damage * ((100 - shieldDroneReduction) / 100f)); - if (Main.netMode != NetmodeID.Server && Main.myPlayer == Player.whoAmI) shieldDroneReduction -= ShieldIncreaseAmount; //since this is only set clientside by the projectile and synced by packets - } - } - - /// - /// Sets the isTemp on the projectile so it behaves differently - /// - private void PreSyncSoulTemp(Projectile proj) - { - if (!ContentConfig.Instance.Bosses) - { - return; - } - - if (proj.ModProjectile is CompanionDungeonSoulMinionBase soul) - { - soul.isTemp = true; - } - } - - /// - /// Spawns the temporary soul when wearing the accessory that allows it - /// - private void SpawnSoulTemp() - { - if (!ContentConfig.Instance.Bosses) - { - return; - } - - if (tempSoulMinion != null && !tempSoulMinion.IsAir && Player.whoAmI == Main.myPlayer) - { - bool checkIfAlive = false; - int spawnedType = Main.hardMode ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int spawnedDamage = Main.hardMode ? (int)(EverhallowedLantern.BaseDmg * 1.1f * 2f) : ((EverhallowedLantern.BaseDmg / 2 - 1) * 2); - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].active && Main.projectile[i].owner == Player.whoAmI && Main.projectile[i].type == spawnedType) - { - if (Main.projectile[i].minionSlots == 0f) //criteria for temp, is set by isTemp - { - checkIfAlive = true; - break; - } - } - } - - if (!checkIfAlive) - { - AssUtils.NewProjectile(Player.GetProjectileSource_Item(tempSoulMinion), Player.Center.X, Player.Center.Y, -Player.velocity.X, Player.velocity.Y - 6f, spawnedType, spawnedDamage, EverhallowedLantern.BaseKB, preSync: PreSyncSoulTemp); - } - } - } - - /// - /// Upon Soul Harvester death, convert all inert souls in inventory - /// - public void ConvertInertSoulsInventory() - { - if (!ContentConfig.Instance.Bosses) - { - return; - } - - //this gets called once on server side for all players, and then each player calls it on itself client side - int tempStackCount; - int itemTypeOld = ModContent.ItemType(); - int itemTypeNew = ModContent.ItemType(); //version that is used in crafting - - Item[][] inventoryArray = { Player.inventory, Player.bank.item, Player.bank2.item, Player.bank3.item, Player.bank4.item }; //go though player inv - for (int y = 0; y < inventoryArray.Length; y++) - { - for (int e = 0; e < inventoryArray[y].Length; e++) - { - Item item = inventoryArray[y][e]; - if (item.type == itemTypeOld) //find inert soul - { - tempStackCount = item.stack; - item.SetDefaults(itemTypeNew); //override with awakened - item.stack = tempStackCount; - } - } - } - - //trash slot - Item trashItem = Player.trashItem; - if (trashItem.type == itemTypeOld) - { - tempStackCount = trashItem.stack; - trashItem.SetDefaults(itemTypeNew); - trashItem.stack = tempStackCount; - } - - //mouse item - Item mouseItem = Main.mouseItem; - if (Main.netMode != NetmodeID.Server && mouseItem.type == itemTypeOld) - { - tempStackCount = mouseItem.stack; - mouseItem.SetDefaults(itemTypeNew); - mouseItem.stack = tempStackCount; - } - } - - private void UpdateTeleportHomeWhenLow() - { - //this code runs even when the accessory is not equipped - canTeleportHome = teleportHomeTimer <= 0; - - if (!canTeleportHome && Main.GameUpdateCount % 60 == 59) - { - teleportHomeTimer--; - } - } - - private void UpdateGetDefenseWhenLow() - { - //this code runs even when the accessory is not equipped - canGetDefense = getDefenseTimer <= 0; - - if (!canGetDefense && Main.GameUpdateCount % 60 == 59) - { - getDefenseTimer--; - } - - if (getDefenseDuration != 0) - { - getDefenseDuration--; - } - } - - /// - /// Sets some variables related to the Empowering Buff - /// - private void Empower() - { - if (empoweringBuff) - { - if (Main.GameUpdateCount % 60 == 0) - { - if (empoweringTimer < empoweringTimerMax) - { - empoweringTimer++; - empoweringStep = (empoweringTimer * empoweringTotal) / empoweringTimerMax; - } - } - } - else - { - empoweringStep = 0f; - empoweringTimer = 0; - } - } - - private bool GetDefense(double damage) - { - if (getDefense) - { - if (canGetDefense) - { - Player.statLife += (int)damage; - Player.AddBuff(BuffID.RapidHealing, 600); - CombatText.NewText(Player.getRect(), CombatText.HealLife, "Defense increased"); - - getDefenseTimer = GetDefenseTimerMax; - getDefenseDuration = GetDefenseDurationMax; - return false; - } - } - return true; - } - - private bool TeleportHome(double damage) - { - if (teleportHome) - { - if (canTeleportHome && Player.whoAmI == Main.myPlayer) - { - Player.RemoveAllGrapplingHooks(); - - //inserted before player.Spawn() - Player.statLife += (int)damage; - - Player.Spawn(PlayerSpawnContext.RecallFromItem); - for (int i = 0; i < 70; i++) - { - Dust.NewDust(Player.position, Player.width, Player.height, 15, 0f, 0f, 150, default(Color), 1.5f); - } - //end - - Player.AddBuff(BuffID.RapidHealing, 300, false); - - NetMessage.SendData(MessageID.PlayerControls, number: Player.whoAmI); - - teleportHomeTimer = TeleportHomeTimerMax; - return false; - } - } - return true; - } - - private void ApplyCandleDebuffs(Entity victim) - { - if (victim is NPC npc) - { - if (everburningCandleBuff) npc.AddBuff(BuffID.OnFire, 120); - if (everburningCursedCandleBuff) npc.AddBuff(BuffID.CursedInferno, 120); - if (everfrozenCandleBuff) npc.AddBuff(BuffID.Frostburn, 120); - if (everburningShadowflameCandleBuff) npc.AddBuff(BuffID.ShadowFlame, 60); - } - //else if (victim is Player) - } - - #region CircleUI - - /// - /// Contains a list of CircleUIHandlers that are used in CircleUIStart/End in Mod - /// - public List CircleUIList; - - public override void Initialize() - { - teleportHome = false; - teleportHomeTimer = 0; - getDefense = false; - getDefenseDuration = 0; - getDefenseTimer = 0; - lastSlainBossTimerSeconds = -1; - tempSoulMinion = null; - selectedSoulMinionType = SoulType.Dungeon; - selectedSlimePackMinionType = 0; - nextMagicSlimeSlingMinion = 0; - empoweringTimer = 0; - empoweringStep = 0f; - shieldDroneReduction = 0; - shieldDroneLerpVisual = 0; - drawEffectsCalledOnce = false; - - //needs to call new List() since Initialize() is called per player in the player select screen - CircleUIList = new List(); - - if (ContentConfig.Instance.Weapons) - { - CircleUIList.AddRange(new List - { - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => true, - uiConf: SlimeHandlerKnapsack.GetUIConf, - onUIStart: () => selectedSlimePackMinionType, - onUIEnd: delegate - { - selectedSlimePackMinionType = (byte)CircleUI.returned; - AssUtils.UIText("Selected: " + (selectedSlimePackMinionType == 0 ? "Default" : (selectedSlimePackMinionType == 1 ? "Assorted" : "Spiked")), CombatText.HealLife); - }, - triggerLeft: false - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => true, - uiConf: DroneController.GetUIConf, - onUIStart: delegate - { - if (Utils.IsPowerOfTwo((int)selectedDroneControllerMinionType)) - { - return (int)Math.Log((int)selectedDroneControllerMinionType, 2); - } - return 0; - }, - onUIEnd: delegate - { - selectedDroneControllerMinionType = (DroneType)(byte)Math.Pow(2, CircleUI.returned); - AssUtils.UIText("Selected: " + DroneController.GetDroneData(selectedDroneControllerMinionType).Name, CombatText.HealLife); - }, - triggerLeft: false - )} - ); - } - - if (ContentConfig.Instance.Bosses) - { - CircleUIList.Add(new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => true, - uiConf: EverhallowedLantern.GetUIConf, - onUIStart: delegate - { - if (Utils.IsPowerOfTwo((int)selectedSoulMinionType)) - { - return (int)Math.Log((int)selectedSoulMinionType, 2); - } - return 0; - }, - onUIEnd: delegate - { - selectedSoulMinionType = (SoulType)(byte)Math.Pow(2, CircleUI.returned); - AssUtils.UIText("Selected: " + EverhallowedLantern.GetSoulData(selectedSoulMinionType).Name, CombatText.HealLife); - }, - triggerLeft: false - )); - } - - // after filling the list, set the trigger list - for (int i = 0; i < CircleUIList.Count; i++) - { - CircleUIList[i].AddTriggers(); - } - } - #endregion - - /// - /// Get proper SpriteEffects flags based on player status - /// - private static SpriteEffects GetSpriteEffects(Player player) - { - if (player.gravDir == 1f) - { - if (player.direction == 1) - { - return SpriteEffects.None; - } - else - { - return SpriteEffects.FlipHorizontally; - } - } - else - { - if (player.direction == 1) - { - return SpriteEffects.FlipVertically; - } - else - { - return SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically; - } - } - } - - public void SlainBoss(int type) - { - lastSlainBossTimerSeconds = 0; - lastSlainBossType = type; - - OnSlainBoss?.Invoke(Player, type); - - if (Main.netMode == NetmodeID.Server) - { - ModPacket packet = Mod.GetPacket(); - packet.Write((byte)AssMessageType.SlainBoss); - packet.WriteVarInt(lastSlainBossType); - packet.Send(Player.whoAmI); - } - } - - public bool HasSlainBossSecondsAgo(int timeInSeconds) - { - return HasBossSlainTimer && lastSlainBossTimerSeconds < timeInSeconds; - } - - public void UpdateSlainBossTimer() - { - if (HasBossSlainTimer) - { - lastSlainBossTimerInternal++; - if (lastSlainBossTimerInternal >= 60) - { - lastSlainBossTimerInternal = 0; - - lastSlainBossTimerSeconds++; - } - } - } - - public void UpdateNearbyEnemies() - { - float distSQ = 600 * 600; - if (nearbyEnemyTimer == 0) - { - nearbyEnemyNumber = 0; - nearbyEnemyTimer = 15; - for (int l = 0; l < Main.maxNPCs; l++) - { - NPC npc = Main.npc[l]; - if (npc.active && !npc.friendly && npc.damage > 0 && npc.lifeMax > 5 && !npc.dontCountMe && (npc.Center - Player.Center).LengthSquared() < distSQ) - { - nearbyEnemyNumber++; - } - } - } - else - { - nearbyEnemyTimer--; - } - } - - public override void DrawEffects(PlayerDrawSet drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) - { - Player drawPlayer = drawInfo.drawPlayer; - if (!drawEffectsCalledOnce) - { - drawEffectsCalledOnce = true; - } - else - { - return; - } - if (Main.gameMenu) return; - - //Other code - - //if (!PlayerLayer.MiscEffectsBack.visible) return; - - if (shieldDroneReduction > 0) - { - Color outer = Color.White; - Color inner = new Color(0x03, 0xFE, 0xFE); - - float ratio = shieldDroneReduction / 100f; - if (shieldDroneLerpVisual < ratio) - { - shieldDroneLerpVisual += 0.01f; - } - if (shieldDroneLerpVisual > ratio) shieldDroneLerpVisual = ratio; - - outer *= shieldDroneLerpVisual; - inner *= shieldDroneLerpVisual; - Lighting.AddLight(drawPlayer.Center, inner.ToVector3()); - - float alpha = (255 - drawPlayer.immuneAlpha) / 255f; - outer *= alpha; - inner *= alpha; - Effect shader = ShaderManager.SetupCircleEffect(new Vector2((int)drawPlayer.Center.X, (int)drawPlayer.Center.Y + drawPlayer.gfxOffY), 2 * 16, outer, inner); - - ShaderManager.ApplyToScreenOnce(Main.spriteBatch, shader); - } - } - - public override void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit) - { - DecreaseDroneShield(ref damage); - - ResetEmpoweringTimer(); - - SpawnSoulTemp(); - } - - public override void ModifyHitByNPC(NPC npc, ref int damage, ref bool crit) - { - DecreaseDroneShield(ref damage); - - ResetEmpoweringTimer(); - - SpawnSoulTemp(); - } - - public override void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit) - { - if (!Main.rand.NextBool(5)) return; - ApplyCandleDebuffs(target); - } - - public override void ModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (!Main.rand.NextBool(5)) return; - if (proj.minion && !Main.rand.NextBool(5)) return; - ApplyCandleDebuffs(target); - } - - public override void ModifyHitPvp(Item item, Player target, ref int damage, ref bool crit) - { - //ApplyCandleDebuffs(target); - AssPlayer assPlayer = target.GetModPlayer(); - assPlayer.ResetEmpoweringTimer(); - - assPlayer.SpawnSoulTemp(); - } - - public override void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit) - { - //ApplyCandleDebuffs(target); - AssPlayer assPlayer = target.GetModPlayer(); - assPlayer.ResetEmpoweringTimer(); - - assPlayer.SpawnSoulTemp(); - } - - public override void ModifyWeaponDamage(Item item, ref StatModifier damage) - { - if (empoweringBuff && !item.CountsAsClass(DamageClass.Summon) && item.damage > 0) damage += empoweringStep; //summon damage gets handled in EmpoweringBuffGlobalProjectile - } - - public override void ModifyWeaponCrit(Item item, ref float crit) - { - crit += 10 * empoweringStep; - } - - public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) - { - //getDefense before teleportHome (so you don't teleport BEFORE you gain the defense) - - if (!GetDefense(damage)) return false; - - if (!TeleportHome(damage)) return false; - - return base.PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource); - } - - public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) - { - if (getDefenseDuration != 0) damage = 1; - - DecreaseDroneShield(ref damage); - - if (wyvernCampfire && damageSource.SourceProjectileType == ProjectileID.HarpyFeather) - { - hitDirection = 0; //this cancels knockback - } - - return base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource); - } - - public override void CatchFish(FishingAttempt attempt, ref int itemDrop, ref int npcSpawn, ref AdvancedPopupRequest sonar, ref Vector2 sonarPosition) - { - bool inWater = !attempt.inHoney && !attempt.inLava; - - if (attempt.waterTilesCount < attempt.waterNeededToFish) - { - return; - } - - if (ContentConfig.Instance.OtherPets) - { - //Match Zephyr Fish conditions - if (attempt.legendary && !attempt.crate && inWater) - { - if (((int)(Player.Center.X / 16) < Main.maxTilesX * 0.08f || (int)(Player.Center.X / 16) > Main.maxTilesX * 0.92f) /*&& Main.rand.Next(1) == 0*/) //10 times more likely than zephyr fish makes it about as rare as reaver shark - { - itemDrop = ModContent.ItemType(); - return; - } - } - } - } - - public override void PostUpdateBuffs() - { - UpdateTeleportHomeWhenLow(); - - UpdateGetDefenseWhenLow(); - - Empower(); - - UpdateSlainBossTimer(); - } - - public override void PreUpdate() - { - if (Main.netMode != NetmodeID.Server) - { - if (drawEffectsCalledOnce) - { - drawEffectsCalledOnce = false; - } - - if (Main.myPlayer == Player.whoAmI && ContentConfig.Instance.Weapons) - { - if (Player.ownedProjectileCounts[DroneController.GetDroneData(DroneType.Shield).ProjType] < 1) shieldDroneReduction = 0; - } - } - - UpdateNearbyEnemies(); - } - } + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + //[LegacyName("AssPlayer")] Maybe rename later + public sealed class AssPlayer : AssPlayerBase + { + public delegate void SlainBossDelegate(Player player, int type); + public static event SlainBossDelegate OnSlainBoss; //Runs on all sides + + public bool everburningCandleBuff = false; + public bool everburningCursedCandleBuff = false; + public bool everfrozenCandleBuff = false; + public bool everburningShadowflameCandleBuff = false; + + public bool teleportHome = false; + public bool canTeleportHome = false; + public const short TeleportHomeTimerMax = 600; //in seconds //10 ingame minutes + public short teleportHomeTimer = 0; //gets saved when you relog so you can't cheese it + + //TECHNICALLY NOT DEFENSE; YOU JUST GET 1 DAMAGE FROM EVERYTHING FOR A CERTAIN DURATION + public bool getDefense = false; + public bool canGetDefense = false; + public const short GetDefenseTimerMax = 600; //in seconds //10 ingame minutes + private const short GetDefenseDurationMax = 600; //in ticks //10 ingame seconds + public short getDefenseDuration = 0; + public short getDefenseTimer = 0; //gets saved when you relog so you can't cheese it + + private int lastSlainBossTimerSeconds = -1; //-1: never slain a boss, otherwise starts at 0 and counts + private int lastSlainBossTimerInternal = 0; //Used for incrementing the seconds timer + private int lastSlainBossType = 0; //Does not save + public bool HasBossSlainTimer => lastSlainBossTimerSeconds != -1; + + public bool needsNearbyEnemyNumber = false; + public int nearbyEnemyNumber = 0; //Impl of vanilla player.accThirdEyeNumber which works for all clients, shorter range + public int nearbyEnemyTimer = 0; + + //soul minion stuff + public bool soulMinion = false; + public Item tempSoulMinion = null; + public SoulType selectedSoulMinionType = SoulType.Dungeon; + + public bool slimePackMinion = false; + public byte selectedSlimePackMinionType = 0; + + public byte nextMagicSlimeSlingMinion = 0; + + //empowering buff stuff + public bool empoweringBuff = false; + private const short empoweringTimerMax = 60; //in seconds //one minute until it caps out (independent of buff duration) + private short empoweringTimer = 0; + public static float empoweringTotal = 0.5f; //this gets modified in AssWorld.PreUpdate() + public float empoweringStep = 0f; + + //enhanced hunter potion stuff + public bool enhancedHunterBuff = false; + + //cute slime spawn enable buff + public bool cuteSlimeSpawnEnable = false; + + public bool soulSaviorArmor = false; + + public bool wyvernCampfire = false; + + public bool droneControllerMinion = false; + + public const byte shieldDroneReductionMax = 35; + public const byte ShieldIncreaseAmount = 7; + public byte shieldDroneReduction = 0; //percentage * 100 + public float shieldDroneLerpVisual = 0; //percentage + + private bool drawEffectsCalledOnce = false; + + public bool mouseoveredDresser = false; + + /// + /// Bitfield. Use .HasFlag(DroneType.SomeType) to check if its there or not + /// + public DroneType droneControllerUnlocked = DroneType.None; + + /// + /// Contains the DroneType value + /// + public DroneType selectedDroneControllerMinionType = DroneType.BasicLaser; + + public override void ResetEffects() + { + everburningCandleBuff = false; + everburningCursedCandleBuff = false; + everfrozenCandleBuff = false; + everburningShadowflameCandleBuff = false; + teleportHome = false; + getDefense = false; + soulMinion = false; + tempSoulMinion = null; + slimePackMinion = false; + empoweringBuff = false; + enhancedHunterBuff = false; + cuteSlimeSpawnEnable = false; + soulSaviorArmor = false; + droneControllerMinion = false; + mouseoveredDresser = false; + + needsNearbyEnemyNumber = false; + } + + public bool RightClickPressed { get { return PlayerInput.Triggers.JustPressed.MouseRight; } } + + public bool RightClickReleased { get { return PlayerInput.Triggers.JustReleased.MouseRight; } } + + public bool LeftClickPressed { get { return PlayerInput.Triggers.JustPressed.MouseLeft; } } + + public bool LeftClickReleased { get { return PlayerInput.Triggers.JustReleased.MouseLeft; } } + + public override void SaveData(TagCompound tag) + { + tag.Add("teleportHomeWhenLowTimer", (int)teleportHomeTimer); + tag.Add("getDefenseTimer", (int)getDefenseTimer); + tag.Add("lastSlainBossTimerSeconds", (int)lastSlainBossTimerSeconds); + tag.Add("droneControllerUnlocked", (byte)droneControllerUnlocked); + } + + public override void LoadData(TagCompound tag) + { + teleportHomeTimer = (short)tag.GetInt("teleportHomeWhenLowTimer"); + getDefenseTimer = (short)tag.GetInt("getDefenseTimer"); + string timerKey = "lastSlainBossTimerSeconds"; + if (tag.ContainsKey(timerKey)) + { + lastSlainBossTimerSeconds = tag.GetInt("lastSlainBossTimerSeconds"); + } + droneControllerUnlocked = (DroneType)tag.GetByte("droneControllerUnlocked"); + } + + //TODO get rid of this, use manual packets since setting those values happens in a singular place + public override void clientClone(ModPlayer clientClone) + { + AssPlayer clone = clientClone as AssPlayer; + clone.shieldDroneReduction = shieldDroneReduction; + //Needs syncing because spawning drone parts depends on this serverside (See GeneralGlobalNPC.NPCLoot) + clone.droneControllerUnlocked = droneControllerUnlocked; + } + + public override void SendClientChanges(ModPlayer clientPlayer) + { + AssPlayer clone = clientPlayer as AssPlayer; + if (clone.shieldDroneReduction != shieldDroneReduction || + clone.droneControllerUnlocked != droneControllerUnlocked) + { + SendClientChangesPacket(); + } + } + + /// + /// Things that are sent to the server that are needed on-change + /// + public void SendClientChangesPacket(int toClient = -1, int ignoreClient = -1) + { + if (Main.netMode != NetmodeID.SinglePlayer) + { + ModPacket packet = Mod.GetPacket(); + packet.Write((byte)AssMessageType.ClientChangesAssPlayer); + packet.Write((byte)Player.whoAmI); + packet.Write((byte)shieldDroneReduction); + packet.Write((byte)droneControllerUnlocked); + packet.Send(toClient, ignoreClient); + } + } + + public override void SyncPlayer(int toWho, int fromWho, bool newPlayer) + { + ModPacket packet = Mod.GetPacket(); + packet.Write((byte)AssMessageType.SyncAssPlayer); + packet.Write((byte)Player.whoAmI); + + //Actual data here + packet.Write((byte)shieldDroneReduction); + packet.WriteVarInt(lastSlainBossTimerSeconds); + packet.WriteVarInt(lastSlainBossType); + + packet.Send(toWho, fromWho); + } + + public void ReceiveSyncPlayer(BinaryReader reader) + { + shieldDroneReduction = reader.ReadByte(); + lastSlainBossTimerSeconds = reader.ReadVarInt(); + lastSlainBossType = reader.ReadVarInt(); + } + + public override void OnEnterWorld(Player player) + { + SendClientChangesPacket(); + } + + /// + /// Resets the empowering timer from the Empowering Buff, spawns dust, sends sync + /// + public void ResetEmpoweringTimer(bool fromServer = false) + { + if (empoweringBuff && !Player.HasBuff(BuffID.ShadowDodge)) + { + for (int i = 0; i < empoweringTimer; i++) + { + Dust dust = Dust.NewDustPerfect(Player.Center, 135, new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-3f, 3f)) + (new Vector2(Main.rand.Next(-1, 1), Main.rand.Next(-1, 1)) * ((6 * empoweringTimer) / empoweringTimerMax)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); + dust.noLight = true; + dust.noGravity = true; + dust.fadeIn = Main.rand.NextFloat(1f, 2.3f); + } + empoweringTimer = 0; + + if (Main.netMode == NetmodeID.MultiplayerClient && !fromServer) + { + ModPacket packet = Mod.GetPacket(); + packet.Write((byte)AssMessageType.ResetEmpoweringTimerpvp); + packet.Write((byte)Player.whoAmI); + packet.Send(); //send to server + } + } + } + + /// + /// Decreases damage based on current shield level from the Shield Drone, spawns dust + /// + /// + public void DecreaseDroneShield(ref int damage) + { + if (shieldDroneReduction > 0) + { + for (int i = 0; i < shieldDroneReduction / 2; i++) + { + Dust dust = Dust.NewDustPerfect(Player.Center, 135, new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-3f, 3f)) + new Vector2(Main.rand.Next(-1, 1), Main.rand.Next(-1, 1)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); + dust.noLight = true; + dust.noGravity = true; + dust.fadeIn = Main.rand.NextFloat(1f, 2.3f); + } + + damage = (int)(damage * ((100 - shieldDroneReduction) / 100f)); + if (Main.netMode != NetmodeID.Server && Main.myPlayer == Player.whoAmI) shieldDroneReduction -= ShieldIncreaseAmount; //since this is only set clientside by the projectile and synced by packets + } + } + + /// + /// Sets the isTemp on the projectile so it behaves differently + /// + private void PreSyncSoulTemp(Projectile proj) + { + if (!ContentConfig.Instance.Bosses) + { + return; + } + + if (proj.ModProjectile is CompanionDungeonSoulMinionBase soul) + { + soul.isTemp = true; + } + } + + /// + /// Spawns the temporary soul when wearing the accessory that allows it + /// + private void SpawnSoulTemp() + { + if (!ContentConfig.Instance.Bosses) + { + return; + } + + if (tempSoulMinion != null && !tempSoulMinion.IsAir && Player.whoAmI == Main.myPlayer) + { + bool checkIfAlive = false; + int spawnedType = Main.hardMode ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int spawnedDamage = Main.hardMode ? (int)(EverhallowedLantern.BaseDmg * 1.1f * 2f) : ((EverhallowedLantern.BaseDmg / 2 - 1) * 2); + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].active && Main.projectile[i].owner == Player.whoAmI && Main.projectile[i].type == spawnedType) + { + if (Main.projectile[i].minionSlots == 0f) //criteria for temp, is set by isTemp + { + checkIfAlive = true; + break; + } + } + } + + if (!checkIfAlive) + { + AssUtils.NewProjectile(Player.GetProjectileSource_Item(tempSoulMinion), Player.Center.X, Player.Center.Y, -Player.velocity.X, Player.velocity.Y - 6f, spawnedType, spawnedDamage, EverhallowedLantern.BaseKB, preSync: PreSyncSoulTemp); + } + } + } + + /// + /// Upon Soul Harvester death, convert all inert souls in inventory + /// + public void ConvertInertSoulsInventory() + { + if (!ContentConfig.Instance.Bosses) + { + return; + } + + //this gets called once on server side for all players, and then each player calls it on itself client side + int tempStackCount; + int itemTypeOld = ModContent.ItemType(); + int itemTypeNew = ModContent.ItemType(); //version that is used in crafting + + Item[][] inventoryArray = { Player.inventory, Player.bank.item, Player.bank2.item, Player.bank3.item, Player.bank4.item }; //go though player inv + for (int y = 0; y < inventoryArray.Length; y++) + { + for (int e = 0; e < inventoryArray[y].Length; e++) + { + Item item = inventoryArray[y][e]; + if (item.type == itemTypeOld) //find inert soul + { + tempStackCount = item.stack; + item.SetDefaults(itemTypeNew); //override with awakened + item.stack = tempStackCount; + } + } + } + + //trash slot + Item trashItem = Player.trashItem; + if (trashItem.type == itemTypeOld) + { + tempStackCount = trashItem.stack; + trashItem.SetDefaults(itemTypeNew); + trashItem.stack = tempStackCount; + } + + //mouse item + Item mouseItem = Main.mouseItem; + if (Main.netMode != NetmodeID.Server && mouseItem.type == itemTypeOld) + { + tempStackCount = mouseItem.stack; + mouseItem.SetDefaults(itemTypeNew); + mouseItem.stack = tempStackCount; + } + } + + private void UpdateTeleportHomeWhenLow() + { + //this code runs even when the accessory is not equipped + canTeleportHome = teleportHomeTimer <= 0; + + if (!canTeleportHome && Main.GameUpdateCount % 60 == 59) + { + teleportHomeTimer--; + } + } + + private void UpdateGetDefenseWhenLow() + { + //this code runs even when the accessory is not equipped + canGetDefense = getDefenseTimer <= 0; + + if (!canGetDefense && Main.GameUpdateCount % 60 == 59) + { + getDefenseTimer--; + } + + if (getDefenseDuration != 0) + { + getDefenseDuration--; + } + } + + /// + /// Sets some variables related to the Empowering Buff + /// + private void Empower() + { + if (empoweringBuff) + { + if (Main.GameUpdateCount % 60 == 0) + { + if (empoweringTimer < empoweringTimerMax) + { + empoweringTimer++; + empoweringStep = (empoweringTimer * empoweringTotal) / empoweringTimerMax; + } + } + } + else + { + empoweringStep = 0f; + empoweringTimer = 0; + } + } + + private bool GetDefense(double damage) + { + if (getDefense) + { + if (canGetDefense) + { + Player.statLife += (int)damage; + Player.AddBuff(BuffID.RapidHealing, 600); + CombatText.NewText(Player.getRect(), CombatText.HealLife, "Defense increased"); + + getDefenseTimer = GetDefenseTimerMax; + getDefenseDuration = GetDefenseDurationMax; + return false; + } + } + return true; + } + + private bool TeleportHome(double damage) + { + if (teleportHome) + { + if (canTeleportHome && Player.whoAmI == Main.myPlayer) + { + Player.RemoveAllGrapplingHooks(); + + //inserted before player.Spawn() + Player.statLife += (int)damage; + + Player.Spawn(PlayerSpawnContext.RecallFromItem); + for (int i = 0; i < 70; i++) + { + Dust.NewDust(Player.position, Player.width, Player.height, 15, 0f, 0f, 150, default(Color), 1.5f); + } + //end + + Player.AddBuff(BuffID.RapidHealing, 300, false); + + NetMessage.SendData(MessageID.PlayerControls, number: Player.whoAmI); + + teleportHomeTimer = TeleportHomeTimerMax; + return false; + } + } + return true; + } + + private void ApplyCandleDebuffs(Entity victim) + { + if (victim is NPC npc) + { + if (everburningCandleBuff) npc.AddBuff(BuffID.OnFire, 120); + if (everburningCursedCandleBuff) npc.AddBuff(BuffID.CursedInferno, 120); + if (everfrozenCandleBuff) npc.AddBuff(BuffID.Frostburn, 120); + if (everburningShadowflameCandleBuff) npc.AddBuff(BuffID.ShadowFlame, 60); + } + //else if (victim is Player) + } + + #region CircleUI + + /// + /// Contains a list of CircleUIHandlers that are used in CircleUIStart/End in Mod + /// + public List CircleUIList; + + public override void Initialize() + { + teleportHome = false; + teleportHomeTimer = 0; + getDefense = false; + getDefenseDuration = 0; + getDefenseTimer = 0; + lastSlainBossTimerSeconds = -1; + tempSoulMinion = null; + selectedSoulMinionType = SoulType.Dungeon; + selectedSlimePackMinionType = 0; + nextMagicSlimeSlingMinion = 0; + empoweringTimer = 0; + empoweringStep = 0f; + shieldDroneReduction = 0; + shieldDroneLerpVisual = 0; + drawEffectsCalledOnce = false; + + //needs to call new List() since Initialize() is called per player in the player select screen + CircleUIList = new List(); + + if (ContentConfig.Instance.Weapons) + { + CircleUIList.AddRange(new List + { + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => true, + uiConf: SlimeHandlerKnapsack.GetUIConf, + onUIStart: () => selectedSlimePackMinionType, + onUIEnd: delegate + { + selectedSlimePackMinionType = (byte)CircleUI.returned; + AssUtils.UIText("Selected: " + (selectedSlimePackMinionType == 0 ? "Default" : (selectedSlimePackMinionType == 1 ? "Assorted" : "Spiked")), CombatText.HealLife); + }, + triggerLeft: false + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => true, + uiConf: DroneController.GetUIConf, + onUIStart: delegate + { + if (Utils.IsPowerOfTwo((int)selectedDroneControllerMinionType)) + { + return (int)Math.Log((int)selectedDroneControllerMinionType, 2); + } + return 0; + }, + onUIEnd: delegate + { + selectedDroneControllerMinionType = (DroneType)(byte)Math.Pow(2, CircleUI.returned); + AssUtils.UIText("Selected: " + DroneController.GetDroneData(selectedDroneControllerMinionType).Name, CombatText.HealLife); + }, + triggerLeft: false + )} + ); + } + + if (ContentConfig.Instance.Bosses) + { + CircleUIList.Add(new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => true, + uiConf: EverhallowedLantern.GetUIConf, + onUIStart: delegate + { + if (Utils.IsPowerOfTwo((int)selectedSoulMinionType)) + { + return (int)Math.Log((int)selectedSoulMinionType, 2); + } + return 0; + }, + onUIEnd: delegate + { + selectedSoulMinionType = (SoulType)(byte)Math.Pow(2, CircleUI.returned); + AssUtils.UIText("Selected: " + EverhallowedLantern.GetSoulData(selectedSoulMinionType).Name, CombatText.HealLife); + }, + triggerLeft: false + )); + } + + // after filling the list, set the trigger list + for (int i = 0; i < CircleUIList.Count; i++) + { + CircleUIList[i].AddTriggers(); + } + } + #endregion + + /// + /// Get proper SpriteEffects flags based on player status + /// + private static SpriteEffects GetSpriteEffects(Player player) + { + if (player.gravDir == 1f) + { + if (player.direction == 1) + { + return SpriteEffects.None; + } + else + { + return SpriteEffects.FlipHorizontally; + } + } + else + { + if (player.direction == 1) + { + return SpriteEffects.FlipVertically; + } + else + { + return SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically; + } + } + } + + public void SlainBoss(int type) + { + lastSlainBossTimerSeconds = 0; + lastSlainBossType = type; + + OnSlainBoss?.Invoke(Player, type); + + if (Main.netMode == NetmodeID.Server) + { + ModPacket packet = Mod.GetPacket(); + packet.Write((byte)AssMessageType.SlainBoss); + packet.WriteVarInt(lastSlainBossType); + packet.Send(Player.whoAmI); + } + } + + public bool HasSlainBossSecondsAgo(int timeInSeconds) + { + return HasBossSlainTimer && lastSlainBossTimerSeconds < timeInSeconds; + } + + public void UpdateSlainBossTimer() + { + if (HasBossSlainTimer) + { + lastSlainBossTimerInternal++; + if (lastSlainBossTimerInternal >= 60) + { + lastSlainBossTimerInternal = 0; + + lastSlainBossTimerSeconds++; + } + } + } + + public void UpdateNearbyEnemies() + { + float distSQ = 600 * 600; + if (nearbyEnemyTimer == 0) + { + nearbyEnemyNumber = 0; + nearbyEnemyTimer = 15; + for (int l = 0; l < Main.maxNPCs; l++) + { + NPC npc = Main.npc[l]; + if (npc.active && !npc.friendly && npc.damage > 0 && npc.lifeMax > 5 && !npc.dontCountMe && (npc.Center - Player.Center).LengthSquared() < distSQ) + { + nearbyEnemyNumber++; + } + } + } + else + { + nearbyEnemyTimer--; + } + } + + public override void DrawEffects(PlayerDrawSet drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) + { + Player drawPlayer = drawInfo.drawPlayer; + if (!drawEffectsCalledOnce) + { + drawEffectsCalledOnce = true; + } + else + { + return; + } + if (Main.gameMenu) return; + + //Other code + + //if (!PlayerLayer.MiscEffectsBack.visible) return; + + if (shieldDroneReduction > 0) + { + Color outer = Color.White; + Color inner = new Color(0x03, 0xFE, 0xFE); + + float ratio = shieldDroneReduction / 100f; + if (shieldDroneLerpVisual < ratio) + { + shieldDroneLerpVisual += 0.01f; + } + if (shieldDroneLerpVisual > ratio) shieldDroneLerpVisual = ratio; + + outer *= shieldDroneLerpVisual; + inner *= shieldDroneLerpVisual; + Lighting.AddLight(drawPlayer.Center, inner.ToVector3()); + + float alpha = (255 - drawPlayer.immuneAlpha) / 255f; + outer *= alpha; + inner *= alpha; + Effect shader = ShaderManager.SetupCircleEffect(new Vector2((int)drawPlayer.Center.X, (int)drawPlayer.Center.Y + drawPlayer.gfxOffY), 2 * 16, outer, inner); + + ShaderManager.ApplyToScreenOnce(Main.spriteBatch, shader); + } + } + + public override void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit) + { + DecreaseDroneShield(ref damage); + + ResetEmpoweringTimer(); + + SpawnSoulTemp(); + } + + public override void ModifyHitByNPC(NPC npc, ref int damage, ref bool crit) + { + DecreaseDroneShield(ref damage); + + ResetEmpoweringTimer(); + + SpawnSoulTemp(); + } + + public override void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit) + { + if (!Main.rand.NextBool(5)) return; + ApplyCandleDebuffs(target); + } + + public override void ModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (!Main.rand.NextBool(5)) return; + if (proj.minion && !Main.rand.NextBool(5)) return; + ApplyCandleDebuffs(target); + } + + public override void ModifyHitPvp(Item item, Player target, ref int damage, ref bool crit) + { + //ApplyCandleDebuffs(target); + AssPlayer assPlayer = target.GetModPlayer(); + assPlayer.ResetEmpoweringTimer(); + + assPlayer.SpawnSoulTemp(); + } + + public override void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit) + { + //ApplyCandleDebuffs(target); + AssPlayer assPlayer = target.GetModPlayer(); + assPlayer.ResetEmpoweringTimer(); + + assPlayer.SpawnSoulTemp(); + } + + public override void ModifyWeaponDamage(Item item, ref StatModifier damage) + { + if (empoweringBuff && !item.CountsAsClass(DamageClass.Summon) && item.damage > 0) damage += empoweringStep; //summon damage gets handled in EmpoweringBuffGlobalProjectile + } + + public override void ModifyWeaponCrit(Item item, ref float crit) + { + crit += 10 * empoweringStep; + } + + public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) + { + //getDefense before teleportHome (so you don't teleport BEFORE you gain the defense) + + if (!GetDefense(damage)) return false; + + if (!TeleportHome(damage)) return false; + + return base.PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource); + } + + public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) + { + if (getDefenseDuration != 0) damage = 1; + + DecreaseDroneShield(ref damage); + + if (wyvernCampfire && damageSource.SourceProjectileType == ProjectileID.HarpyFeather) + { + hitDirection = 0; //this cancels knockback + } + + return base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource); + } + + public override void CatchFish(FishingAttempt attempt, ref int itemDrop, ref int npcSpawn, ref AdvancedPopupRequest sonar, ref Vector2 sonarPosition) + { + bool inWater = !attempt.inHoney && !attempt.inLava; + + if (attempt.waterTilesCount < attempt.waterNeededToFish) + { + return; + } + + if (ContentConfig.Instance.OtherPets) + { + //Match Zephyr Fish conditions + if (attempt.legendary && !attempt.crate && inWater) + { + if (((int)(Player.Center.X / 16) < Main.maxTilesX * 0.08f || (int)(Player.Center.X / 16) > Main.maxTilesX * 0.92f) /*&& Main.rand.Next(1) == 0*/) //10 times more likely than zephyr fish makes it about as rare as reaver shark + { + itemDrop = ModContent.ItemType(); + return; + } + } + } + } + + public override void PostUpdateBuffs() + { + UpdateTeleportHomeWhenLow(); + + UpdateGetDefenseWhenLow(); + + Empower(); + + UpdateSlainBossTimer(); + } + + public override void PreUpdate() + { + if (Main.netMode != NetmodeID.Server) + { + if (drawEffectsCalledOnce) + { + drawEffectsCalledOnce = false; + } + + if (Main.myPlayer == Player.whoAmI && ContentConfig.Instance.Weapons) + { + if (Player.ownedProjectileCounts[DroneController.GetDroneData(DroneType.Shield).ProjType] < 1) shieldDroneReduction = 0; + } + } + + UpdateNearbyEnemies(); + } + } } diff --git a/AssUISystem.cs b/AssUISystem.cs index 27ae78b6..026a1bdc 100644 --- a/AssUISystem.cs +++ b/AssUISystem.cs @@ -1,467 +1,466 @@ using AssortedCrazyThings.Base; using AssortedCrazyThings.Items; using AssortedCrazyThings.Items.PetAccessories; -using AssortedCrazyThings.Items.Placeable; using AssortedCrazyThings.UI; using Microsoft.Xna.Framework; using System.Collections.Generic; using Terraria; +using Terraria.Audio; using Terraria.Graphics; using Terraria.ID; using Terraria.ModLoader; using Terraria.UI; -using Terraria.Audio; namespace AssortedCrazyThings { - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - public class AssUISystem : AssSystem - { - /// - /// Zoom level, (for UIs). 0f == fully zoomed out, 1f == fully zoomed in - /// - public static Vector2 ZoomFactor; - - //UI stuff - internal static UserInterface CircleUIInterface; - internal static CircleUI CircleUI; - - internal static UserInterface HoverNPCUIInterface; - internal static HoverNPCUI HoverNPCUI; - - internal static UserInterface HarvesterEdgeUIInterface; - - internal static UserInterface EnhancedHunterUIInterface; - internal static EnhancedHunterUI EnhancedHunterUI; - - internal static UserInterface PetVanityUIInterface; - internal static PetVanityUI PetVanityUI; - - public override void PostSetupContent() - { - if (!Main.dedServ && Main.netMode != NetmodeID.Server) - { - CircleUI = new CircleUI(); - CircleUI.Activate(); - CircleUIInterface = new UserInterface(); - CircleUIInterface.SetState(CircleUI); - - HoverNPCUI = new HoverNPCUI(); - HoverNPCUI.Activate(); - HoverNPCUIInterface = new UserInterface(); - HoverNPCUIInterface.SetState(HoverNPCUI); - - if (ContentConfig.Instance.Bosses) - { - EnhancedHunterUI = new EnhancedHunterUI(); - EnhancedHunterUI.Activate(); - EnhancedHunterUIInterface = new UserInterface(); - EnhancedHunterUIInterface.SetState(EnhancedHunterUI); - } - - if (ContentConfig.Instance.CuteSlimes) - { - PetVanityUI = new PetVanityUI(); - PetVanityUI.Activate(); - PetVanityUIInterface = new UserInterface(); - PetVanityUIInterface.SetState(PetVanityUI); - } - } - } - - public override void Unload() - { - if (!Main.dedServ && Main.netMode != NetmodeID.Server) - { - CircleUIInterface = null; - CircleUI = null; - - HoverNPCUIInterface = null; - HoverNPCUI = null; - - HarvesterEdgeUIInterface = null; - - EnhancedHunterUIInterface = null; - EnhancedHunterUI = null; - - PetVanityUIInterface = null; - PetVanityUI = null; - - EnhancedHunterUI.arrowTexture = null; - PetVanityUI.redCrossTexture = null; - CircleUI.UIConf = null; - CircleUIHandler.TriggerListLeft.Clear(); - CircleUIHandler.TriggerListRight.Clear(); - } - } - - /// - /// Creates golden dust particles at the projectiles location with that type and LocalPlayer as owner. (Used for pets) - /// - private void PoofVisual(int projType) - { - int projIndex = -1; - //find first occurence of a player owned projectile - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].active) - { - if (Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == projType) - { - projIndex = i; - break; - } - } - } - - if (projIndex != -1) - { - Dust dust; - for (int i = 0; i < 14; i++) - { - dust = Dust.NewDustDirect(Main.projectile[projIndex].position, Main.projectile[projIndex].width, Main.projectile[projIndex].height, 204, Main.projectile[projIndex].velocity.X, Main.projectile[projIndex].velocity.Y, 0, new Color(255, 255, 255), 0.8f); - dust.noGravity = true; - dust.noLight = true; - } - } - } - - /// - /// Called when CircleUI starts - /// - private void CircleUIStart(int triggerType, bool triggerLeft = true, bool fromDresser = false) - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - PetPlayer pPlayer = Main.LocalPlayer.GetModPlayer(); - - //combine both lists of the players (split for organization and player load shenanigans) - List l = mPlayer.CircleUIList; - l.AddRange(pPlayer.CircleUIList); - - bool found = false; - for (int i = 0; i < l.Count; i++) - { - if (l[i].Condition()) - { - if (l[i].TriggerItem == triggerType) - { - if (l[i].TriggerLeft == triggerLeft) - { - CircleUI.UIConf = l[i].UIConf(); - CircleUI.currentSelected = l[i].OnUIStart(); - found = true; - break; - } - } - } - } - //extra things that happen - if (!found) - { - if (triggerType == ModContent.ItemType()) - { - AssUtils.UIText("No alt costumes found for" + (triggerLeft ? "" : " light") + " pet", CombatText.DamagedFriendly); - return; - } - } - - //Spawn UI - CircleUI.Start(triggerType, triggerLeft, fromDresser); - } - - /// - /// Called when CircleUI ends - /// - private void CircleUIEnd(bool triggerLeft = true) - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - if (CircleUI.returned != CircleUI.NONE && CircleUI.returned != CircleUI.currentSelected) - { - //if something returned AND if the returned thing isn't the same as the current one - - try - { - SoundEngine.PlaySound(SoundID.Item4.WithVolume(0.6f), Main.LocalPlayer.position); - } - catch - { - //No idea why but this threw errors one time - } - - List l = mPlayer.CircleUIList; - for (int i = 0; i < l.Count; i++) - { - if (l[i].Condition()) - { - if (l[i].TriggerItem == CircleUI.triggerItemType) - { - if (l[i].TriggerLeft == triggerLeft) - { - l[i].OnUIEnd(); - break; - } - } - } - } - //extra things that happen - if (CircleUI.triggerItemType == ModContent.ItemType()) - { - PoofVisual(CircleUI.UIConf.AdditionalInfo); - AssUtils.UIText("Selected: " + CircleUI.UIConf.Tooltips[CircleUI.returned], CombatText.HealLife); - } - } - - CircleUI.returned = CircleUI.NONE; - CircleUI.visible = false; - } - - /// - /// Called in UpdateUI - /// - private void UpdateCircleUI() - { - Player player = Main.LocalPlayer; - AssPlayer mPlayer = player.GetModPlayer(); - - int triggerType = player.HeldItem.type; - bool openWithDresser = mPlayer.mouseoveredDresser; - if (openWithDresser) - { - triggerType = ModContent.ItemType(); - } - bool? left = null; - if (mPlayer.LeftClickPressed && (CircleUIHandler.TriggerListLeft.Contains(triggerType) || openWithDresser)) - { - left = true; - } - else if (mPlayer.RightClickPressed && (CircleUIHandler.TriggerListRight.Contains(triggerType) || openWithDresser)) - { - left = false; - } - - if (left != null && AllowedToOpenUI()) CircleUIStart(triggerType, (bool)left, openWithDresser); - - if (CircleUI.visible) - { - left = null; - if (mPlayer.LeftClickReleased) - { - left = true; - } - else if (mPlayer.RightClickReleased) - { - left = false; - } - - if (left != null && left == CircleUI.openedWithLeft) CircleUIEnd((bool)left); - - if (CircleUI.triggerItemType != triggerType && !CircleUI.triggeredFromDresser) //cancel the UI when you switch items - { - CircleUI.returned = CircleUI.NONE; - CircleUI.visible = false; - } - } - } - - /// - /// Called in UpdateUI - /// - private void UpdatePetVanityUI() - { - Player player = Main.LocalPlayer; - AssPlayer mPlayer = player.GetModPlayer(); - PetPlayer pPlayer = player.GetModPlayer(); - - int itemType = player.HeldItem.type; - if (mPlayer.LeftClickPressed && AllowedToOpenUI() && PetAccessory.TryGetAccessoryFromItem(itemType, out PetAccessory petAccessory)) - { - if (petAccessory.HasAlts && pPlayer.HasValidSlimePet(out SlimePet slimePet) && - !slimePet.IsSlotTypeBlacklisted[(int)petAccessory.Slot]) - { - //Spawn UI - PetVanityUI.Start(petAccessory); - } - } - - if (!PetVanityUI.visible) - { - return; - } - - if (mPlayer.LeftClickReleased) - { - if (PetVanityUI.returned > PetVanityUI.NONE) - { - //if something returned AND if the returned thing isn't the same as the current one - - try - { - SoundEngine.PlaySound(SoundID.Item1, player.position); - } - catch - { - //No idea why but this threw errors one time - } - //UIText("Selected: " + PetVanityUI.petAccessory.AltTextureSuffixes[PetVanityUI.returned], CombatText.HealLife); - - PetVanityUI.petAccessory.AltTextureIndex = (byte)PetVanityUI.returned; - pPlayer.ToggleAccessory(PetVanityUI.petAccessory); - } - else if (PetVanityUI.hasEquipped && PetVanityUI.returned == PetVanityUI.NONE) - { - //hovered over the middle and had something equipped: take accessory away - pPlayer.DelAccessory(PetVanityUI.petAccessory); - } - //else if (returned == PetVanityUI.IGNORE) {nothing happens} - - PetVanityUI.returned = PetVanityUI.NONE; - PetVanityUI.visible = false; - } - - if (PetVanityUI.petAccessory.Type != itemType) //cancel the UI when you switch items - { - PetVanityUI.returned = PetVanityUI.NONE; - PetVanityUI.visible = false; - } - } - - private void UpdateHoverNPCUI(GameTime gameTime) - { - HoverNPCUI.Update(gameTime); - } - - private void UpdateEnhancedHunterUI(GameTime gameTime) - { - if (Main.LocalPlayer.GetModPlayer().enhancedHunterBuff) - { - EnhancedHunterUI.visible = true; - } - else - { - EnhancedHunterUI.visible = false; - } - EnhancedHunterUI?.Update(gameTime); - } - - public override void UpdateUI(GameTime gameTime) - { - UpdateCircleUI(); - UpdateHoverNPCUI(gameTime); - UpdateEnhancedHunterUI(gameTime); - UpdatePetVanityUI(); - } - - /// - /// Checks if LocalPlayer can open a UI - /// - private bool AllowedToOpenUI() - { - return Main.hasFocus && - !Main.gamePaused && - !Main.LocalPlayer.dead && - !Main.LocalPlayer.mouseInterface && - !Main.drawingPlayerChat && - !Main.editSign && - !Main.editChest && - !Main.blockInput && - !Main.mapFullscreen && - !Main.HoveringOverAnNPC && - Main.LocalPlayer.cursorItemIconID != -1 && - Main.LocalPlayer.talkNPC == -1 && - Main.LocalPlayer.itemTime == 0 && Main.LocalPlayer.itemAnimation == 0 && - !(Main.LocalPlayer.frozen || Main.LocalPlayer.webbed || Main.LocalPlayer.stoned); - } - - public override void ModifyInterfaceLayers(List layers) - { - int inventoryIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Hotbar")); - if (inventoryIndex != -1) - { - if (CircleUI.visible) - { - //remove the item icon when using the item while held outside the inventory - int mouseItemIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Item / NPC Head")); - if (mouseItemIndex != -1) layers.RemoveAt(mouseItemIndex); - layers.Insert(++inventoryIndex, new LegacyGameInterfaceLayer - ( - "ACT: Appearance Select", - delegate - { - CircleUIInterface.Draw(Main.spriteBatch, new GameTime()); - return true; - }, - InterfaceScaleType.UI) - ); - } - - if (PetVanityUI.visible && PetVanityUIInterface != null) - { - //remove the item icon when using the item while held outside the inventory - int mouseItemIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Item / NPC Head")); - if (mouseItemIndex != -1) layers.RemoveAt(mouseItemIndex); - layers.Insert(++inventoryIndex, new LegacyGameInterfaceLayer - ( - "ACT: Pet Vanity Select", - delegate - { - PetVanityUIInterface.Draw(Main.spriteBatch, new GameTime()); - return true; - }, - InterfaceScaleType.UI) - ); - } - } - - int mouseOverIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Over")); - if (mouseOverIndex != -1) - { - layers.Insert(++mouseOverIndex, new LegacyGameInterfaceLayer - ( - "ACT: NPC Mouse Over", - delegate - { - HoverNPCUIInterface.Draw(Main.spriteBatch, new GameTime()); - return true; - }, - InterfaceScaleType.UI) - ); - - if (EnhancedHunterUIInterface != null) - { - if (EnhancedHunterUI.visible) - { - layers.Insert(++mouseOverIndex, new LegacyGameInterfaceLayer - ( - "ACT: Enhanced Hunter", - delegate - { - EnhancedHunterUIInterface.Draw(Main.spriteBatch, new GameTime()); - return true; - }, - InterfaceScaleType.UI) - ); - } - } - - if (HarvesterEdgeUIInterface != null) - { - layers.Insert(++mouseOverIndex, new LegacyGameInterfaceLayer - ( - "ACT: Harvester Edge", - delegate - { - HarvesterEdgeUIInterface.Draw(Main.spriteBatch, new GameTime()); - return true; - }, - InterfaceScaleType.UI) - ); - } - } - } - - public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform) - { - ZoomFactor = Transform.Zoom - (Vector2.UnitX + Vector2.UnitY); - } - } + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + public class AssUISystem : AssSystem + { + /// + /// Zoom level, (for UIs). 0f == fully zoomed out, 1f == fully zoomed in + /// + public static Vector2 ZoomFactor; + + //UI stuff + internal static UserInterface CircleUIInterface; + internal static CircleUI CircleUI; + + internal static UserInterface HoverNPCUIInterface; + internal static HoverNPCUI HoverNPCUI; + + internal static UserInterface HarvesterEdgeUIInterface; + + internal static UserInterface EnhancedHunterUIInterface; + internal static EnhancedHunterUI EnhancedHunterUI; + + internal static UserInterface PetVanityUIInterface; + internal static PetVanityUI PetVanityUI; + + public override void PostSetupContent() + { + if (!Main.dedServ && Main.netMode != NetmodeID.Server) + { + CircleUI = new CircleUI(); + CircleUI.Activate(); + CircleUIInterface = new UserInterface(); + CircleUIInterface.SetState(CircleUI); + + HoverNPCUI = new HoverNPCUI(); + HoverNPCUI.Activate(); + HoverNPCUIInterface = new UserInterface(); + HoverNPCUIInterface.SetState(HoverNPCUI); + + if (ContentConfig.Instance.Bosses) + { + EnhancedHunterUI = new EnhancedHunterUI(); + EnhancedHunterUI.Activate(); + EnhancedHunterUIInterface = new UserInterface(); + EnhancedHunterUIInterface.SetState(EnhancedHunterUI); + } + + if (ContentConfig.Instance.CuteSlimes) + { + PetVanityUI = new PetVanityUI(); + PetVanityUI.Activate(); + PetVanityUIInterface = new UserInterface(); + PetVanityUIInterface.SetState(PetVanityUI); + } + } + } + + public override void Unload() + { + if (!Main.dedServ && Main.netMode != NetmodeID.Server) + { + CircleUIInterface = null; + CircleUI = null; + + HoverNPCUIInterface = null; + HoverNPCUI = null; + + HarvesterEdgeUIInterface = null; + + EnhancedHunterUIInterface = null; + EnhancedHunterUI = null; + + PetVanityUIInterface = null; + PetVanityUI = null; + + EnhancedHunterUI.arrowTexture = null; + PetVanityUI.redCrossTexture = null; + CircleUI.UIConf = null; + CircleUIHandler.TriggerListLeft.Clear(); + CircleUIHandler.TriggerListRight.Clear(); + } + } + + /// + /// Creates golden dust particles at the projectiles location with that type and LocalPlayer as owner. (Used for pets) + /// + private void PoofVisual(int projType) + { + int projIndex = -1; + //find first occurence of a player owned projectile + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].active) + { + if (Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == projType) + { + projIndex = i; + break; + } + } + } + + if (projIndex != -1) + { + Dust dust; + for (int i = 0; i < 14; i++) + { + dust = Dust.NewDustDirect(Main.projectile[projIndex].position, Main.projectile[projIndex].width, Main.projectile[projIndex].height, 204, Main.projectile[projIndex].velocity.X, Main.projectile[projIndex].velocity.Y, 0, new Color(255, 255, 255), 0.8f); + dust.noGravity = true; + dust.noLight = true; + } + } + } + + /// + /// Called when CircleUI starts + /// + private void CircleUIStart(int triggerType, bool triggerLeft = true, bool fromDresser = false) + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + PetPlayer pPlayer = Main.LocalPlayer.GetModPlayer(); + + //combine both lists of the players (split for organization and player load shenanigans) + List l = mPlayer.CircleUIList; + l.AddRange(pPlayer.CircleUIList); + + bool found = false; + for (int i = 0; i < l.Count; i++) + { + if (l[i].Condition()) + { + if (l[i].TriggerItem == triggerType) + { + if (l[i].TriggerLeft == triggerLeft) + { + CircleUI.UIConf = l[i].UIConf(); + CircleUI.currentSelected = l[i].OnUIStart(); + found = true; + break; + } + } + } + } + //extra things that happen + if (!found) + { + if (triggerType == ModContent.ItemType()) + { + AssUtils.UIText("No alt costumes found for" + (triggerLeft ? "" : " light") + " pet", CombatText.DamagedFriendly); + return; + } + } + + //Spawn UI + CircleUI.Start(triggerType, triggerLeft, fromDresser); + } + + /// + /// Called when CircleUI ends + /// + private void CircleUIEnd(bool triggerLeft = true) + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + if (CircleUI.returned != CircleUI.NONE && CircleUI.returned != CircleUI.currentSelected) + { + //if something returned AND if the returned thing isn't the same as the current one + + try + { + SoundEngine.PlaySound(SoundID.Item4.WithVolume(0.6f), Main.LocalPlayer.position); + } + catch + { + //No idea why but this threw errors one time + } + + List l = mPlayer.CircleUIList; + for (int i = 0; i < l.Count; i++) + { + if (l[i].Condition()) + { + if (l[i].TriggerItem == CircleUI.triggerItemType) + { + if (l[i].TriggerLeft == triggerLeft) + { + l[i].OnUIEnd(); + break; + } + } + } + } + //extra things that happen + if (CircleUI.triggerItemType == ModContent.ItemType()) + { + PoofVisual(CircleUI.UIConf.AdditionalInfo); + AssUtils.UIText("Selected: " + CircleUI.UIConf.Tooltips[CircleUI.returned], CombatText.HealLife); + } + } + + CircleUI.returned = CircleUI.NONE; + CircleUI.visible = false; + } + + /// + /// Called in UpdateUI + /// + private void UpdateCircleUI() + { + Player player = Main.LocalPlayer; + AssPlayer mPlayer = player.GetModPlayer(); + + int triggerType = player.HeldItem.type; + bool openWithDresser = mPlayer.mouseoveredDresser; + if (openWithDresser) + { + triggerType = ModContent.ItemType(); + } + bool? left = null; + if (mPlayer.LeftClickPressed && (CircleUIHandler.TriggerListLeft.Contains(triggerType) || openWithDresser)) + { + left = true; + } + else if (mPlayer.RightClickPressed && (CircleUIHandler.TriggerListRight.Contains(triggerType) || openWithDresser)) + { + left = false; + } + + if (left != null && AllowedToOpenUI()) CircleUIStart(triggerType, (bool)left, openWithDresser); + + if (CircleUI.visible) + { + left = null; + if (mPlayer.LeftClickReleased) + { + left = true; + } + else if (mPlayer.RightClickReleased) + { + left = false; + } + + if (left != null && left == CircleUI.openedWithLeft) CircleUIEnd((bool)left); + + if (CircleUI.triggerItemType != triggerType && !CircleUI.triggeredFromDresser) //cancel the UI when you switch items + { + CircleUI.returned = CircleUI.NONE; + CircleUI.visible = false; + } + } + } + + /// + /// Called in UpdateUI + /// + private void UpdatePetVanityUI() + { + Player player = Main.LocalPlayer; + AssPlayer mPlayer = player.GetModPlayer(); + PetPlayer pPlayer = player.GetModPlayer(); + + int itemType = player.HeldItem.type; + if (mPlayer.LeftClickPressed && AllowedToOpenUI() && PetAccessory.TryGetAccessoryFromItem(itemType, out PetAccessory petAccessory)) + { + if (petAccessory.HasAlts && pPlayer.HasValidSlimePet(out SlimePet slimePet) && + !slimePet.IsSlotTypeBlacklisted[(int)petAccessory.Slot]) + { + //Spawn UI + PetVanityUI.Start(petAccessory); + } + } + + if (!PetVanityUI.visible) + { + return; + } + + if (mPlayer.LeftClickReleased) + { + if (PetVanityUI.returned > PetVanityUI.NONE) + { + //if something returned AND if the returned thing isn't the same as the current one + + try + { + SoundEngine.PlaySound(SoundID.Item1, player.position); + } + catch + { + //No idea why but this threw errors one time + } + //UIText("Selected: " + PetVanityUI.petAccessory.AltTextureSuffixes[PetVanityUI.returned], CombatText.HealLife); + + PetVanityUI.petAccessory.AltTextureIndex = (byte)PetVanityUI.returned; + pPlayer.ToggleAccessory(PetVanityUI.petAccessory); + } + else if (PetVanityUI.hasEquipped && PetVanityUI.returned == PetVanityUI.NONE) + { + //hovered over the middle and had something equipped: take accessory away + pPlayer.DelAccessory(PetVanityUI.petAccessory); + } + //else if (returned == PetVanityUI.IGNORE) {nothing happens} + + PetVanityUI.returned = PetVanityUI.NONE; + PetVanityUI.visible = false; + } + + if (PetVanityUI.petAccessory.Type != itemType) //cancel the UI when you switch items + { + PetVanityUI.returned = PetVanityUI.NONE; + PetVanityUI.visible = false; + } + } + + private void UpdateHoverNPCUI(GameTime gameTime) + { + HoverNPCUI.Update(gameTime); + } + + private void UpdateEnhancedHunterUI(GameTime gameTime) + { + if (Main.LocalPlayer.GetModPlayer().enhancedHunterBuff) + { + EnhancedHunterUI.visible = true; + } + else + { + EnhancedHunterUI.visible = false; + } + EnhancedHunterUI?.Update(gameTime); + } + + public override void UpdateUI(GameTime gameTime) + { + UpdateCircleUI(); + UpdateHoverNPCUI(gameTime); + UpdateEnhancedHunterUI(gameTime); + UpdatePetVanityUI(); + } + + /// + /// Checks if LocalPlayer can open a UI + /// + private bool AllowedToOpenUI() + { + return Main.hasFocus && + !Main.gamePaused && + !Main.LocalPlayer.dead && + !Main.LocalPlayer.mouseInterface && + !Main.drawingPlayerChat && + !Main.editSign && + !Main.editChest && + !Main.blockInput && + !Main.mapFullscreen && + !Main.HoveringOverAnNPC && + Main.LocalPlayer.cursorItemIconID != -1 && + Main.LocalPlayer.talkNPC == -1 && + Main.LocalPlayer.itemTime == 0 && Main.LocalPlayer.itemAnimation == 0 && + !(Main.LocalPlayer.frozen || Main.LocalPlayer.webbed || Main.LocalPlayer.stoned); + } + + public override void ModifyInterfaceLayers(List layers) + { + int inventoryIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Hotbar")); + if (inventoryIndex != -1) + { + if (CircleUI.visible) + { + //remove the item icon when using the item while held outside the inventory + int mouseItemIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Item / NPC Head")); + if (mouseItemIndex != -1) layers.RemoveAt(mouseItemIndex); + layers.Insert(++inventoryIndex, new LegacyGameInterfaceLayer + ( + "ACT: Appearance Select", + delegate + { + CircleUIInterface.Draw(Main.spriteBatch, new GameTime()); + return true; + }, + InterfaceScaleType.UI) + ); + } + + if (PetVanityUI.visible && PetVanityUIInterface != null) + { + //remove the item icon when using the item while held outside the inventory + int mouseItemIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Item / NPC Head")); + if (mouseItemIndex != -1) layers.RemoveAt(mouseItemIndex); + layers.Insert(++inventoryIndex, new LegacyGameInterfaceLayer + ( + "ACT: Pet Vanity Select", + delegate + { + PetVanityUIInterface.Draw(Main.spriteBatch, new GameTime()); + return true; + }, + InterfaceScaleType.UI) + ); + } + } + + int mouseOverIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Over")); + if (mouseOverIndex != -1) + { + layers.Insert(++mouseOverIndex, new LegacyGameInterfaceLayer + ( + "ACT: NPC Mouse Over", + delegate + { + HoverNPCUIInterface.Draw(Main.spriteBatch, new GameTime()); + return true; + }, + InterfaceScaleType.UI) + ); + + if (EnhancedHunterUIInterface != null) + { + if (EnhancedHunterUI.visible) + { + layers.Insert(++mouseOverIndex, new LegacyGameInterfaceLayer + ( + "ACT: Enhanced Hunter", + delegate + { + EnhancedHunterUIInterface.Draw(Main.spriteBatch, new GameTime()); + return true; + }, + InterfaceScaleType.UI) + ); + } + } + + if (HarvesterEdgeUIInterface != null) + { + layers.Insert(++mouseOverIndex, new LegacyGameInterfaceLayer + ( + "ACT: Harvester Edge", + delegate + { + HarvesterEdgeUIInterface.Draw(Main.spriteBatch, new GameTime()); + return true; + }, + InterfaceScaleType.UI) + ); + } + } + } + + public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform) + { + ZoomFactor = Transform.Zoom - (Vector2.UnitX + Vector2.UnitY); + } + } } diff --git a/AssWorld.cs b/AssWorld.cs index e09b52f0..cae77032 100644 --- a/AssWorld.cs +++ b/AssWorld.cs @@ -4,242 +4,242 @@ using System.Collections.Generic; using System.IO; using Terraria; +using Terraria.Audio; +using Terraria.Chat; using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.IO; -using Terraria.Audio; -using Terraria.Chat; namespace AssortedCrazyThings { - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - public class AssWorld : AssSystem - { - //basically "if they were alive last update" - public bool megalodonAlive = false; - public bool miniocramAlive = false; - //"are they alive this update" - bool isMegalodonSpawned; - bool isMiniocramSpawned; - //static names, in case you want to change them later - public static string megalodonName = Megalodon.name; - public static string miniocramName = SpawnOfOcram.name; - public static string megalodonMessage = Megalodon.message; - public static string miniocramMessage = SpawnOfOcram.message; - //the megalodon messages are modified down below in the Disappear message - - //Soul stuff - public static bool downedHarvester; - - public static bool slimeRainSky = false; - - public override void OnWorldLoad() - { - downedHarvester = false; - } - - public override void SaveWorldData(TagCompound tag) - { - var downed = new List(); - if (downedHarvester) - { - downed.Add("harvester"); - } - - tag.Add("downed", downed); - } - - public override void LoadWorldData(TagCompound tag) - { - var downed = tag.GetList("downed"); - downedHarvester = downed.Contains("harvester"); - } - - public override void NetSend(BinaryWriter writer) - { - BitsByte flags = new BitsByte(); - flags[0] = downedHarvester; - writer.Write(flags); - - } - - public override void NetReceive(BinaryReader reader) - { - BitsByte flags = reader.ReadByte(); - downedHarvester = flags[0]; - } - - //small methods I made for myself to not make the code cluttered since I have to use these six times - public static void AwakeningMessage(string message, Vector2 pos = default(Vector2), int soundStyle = -1) - { - if (soundStyle != -1) SoundEngine.PlaySound(SoundID.Roar, pos, soundStyle); //soundStyle 2 for screech, 0 for regular roar - Message(message, new Color(175, 75, 255)); - } - - public static void Message(string message, Color color) - { - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(message, color); - } - else if (Main.netMode == NetmodeID.Server) - { - ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(message), color); - } - } - - public static void ToggleSlimeRainSky() - { - if (!Main.slimeRain && Main.netMode != NetmodeID.MultiplayerClient) - { - if (!slimeRainSky) - { - SkyManager.Instance.Activate("Slime", default(Vector2)); - CombatText.NewText(Main.LocalPlayer.getRect(), CombatText.HealLife, "Background Activated"); - slimeRainSky = true; - } - else - { - SkyManager.Instance.Deactivate("Slime"); - CombatText.NewText(Main.LocalPlayer.getRect(), CombatText.DamagedFriendly, "Background Deactivated"); - slimeRainSky = false; - } - } - } - - public static void DisableSlimeRainSky() - { - if (!Main.slimeRain && slimeRainSky && Main.netMode != NetmodeID.MultiplayerClient) - { - SkyManager.Instance.Deactivate("Slime"); - CombatText.NewText(Main.LocalPlayer.getRect(), CombatText.DamagedFriendly, "Background Deactivated"); - slimeRainSky = false; - } - } - - private void LimitSoulCount() - { - if (!ContentConfig.Instance.Bosses) - { - return; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Main.GameUpdateCount % 30 == 15 && NPC.CountNPCS(ModContent.NPCType()) > 10) //limit soul count in the world to 15 - { - short oldest = 200; - int timeleftmin = int.MaxValue; - for (short j = 0; j < Main.maxNPCs; j++) - { - NPC npc = Main.npc[j]; - if (npc.active && npc.type == ModContent.NPCType()) - { - if (npc.timeLeft < timeleftmin) - { - timeleftmin = npc.timeLeft; - oldest = j; - } - } - } - if (oldest != Main.maxNPCs) - { - NPC oldestnpc = Main.npc[oldest]; - oldestnpc.active = false; - oldestnpc.netUpdate = true; - if (Main.netMode == NetmodeID.Server && oldest < Main.maxNPCs) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, oldest); - } - //poof visual - for (int i = 0; i < 15; i++) - { - Dust dust = Dust.NewDustPerfect(oldestnpc.Center, 59, new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 1.5f)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); - dust.noLight = true; - dust.noGravity = true; - dust.fadeIn = Main.rand.NextFloat(0.1f, 0.6f); - } - } - } - } - } - - private void UpdateEmpoweringFactor() - { - if (NPC.downedPlantBoss && AssPlayer.empoweringTotal < 1f) - AssPlayer.empoweringTotal = 1f; - else if (Main.hardMode && AssPlayer.empoweringTotal < 0.75f) - AssPlayer.empoweringTotal = 0.75f; - } - - public override void ResetNearbyTileEffects() - { - Main.LocalPlayer.GetModPlayer().wyvernCampfire = false; - } - - public override void PostUpdateWorld() - { - CheckSpawns(); - } - - private void CheckSpawns() - { - if (!ContentConfig.Instance.HostileNPCs) - { - return; - } - - //this code is when I first started modding, terrible stuff - //those flags are checked for trueness each update - isMegalodonSpawned = false; - isMiniocramSpawned = false; - for (short j = 0; j < Main.maxNPCs; j++) - { - NPC npc = Main.npc[j]; - if (npc.active) - { - if (npc.TypeName == megalodonName && !isMegalodonSpawned) - { - isMegalodonSpawned = true; - //check if it wasnt alive in previous update - if (!megalodonAlive) - { - AwakeningMessage(megalodonMessage, npc.position, 0); - megalodonAlive = true; - } - } - if (npc.TypeName == miniocramName && !isMiniocramSpawned) - { - isMiniocramSpawned = true; - if (!miniocramAlive) - { - AwakeningMessage(miniocramMessage, npc.position, 0); - miniocramAlive = true; - } - } - } - } - //after this we know that either atleast one miniboss is active or not - //if alive, but not active, print disappear message - if (!isMegalodonSpawned && megalodonAlive) - { - megalodonAlive = false; - Message("The " + megalodonName + " disappeared... for now", new Color(175, 255, 175)); - } - if (!isMiniocramSpawned && miniocramAlive) - { - miniocramAlive = false; - Message("The " + miniocramName + " disappeared... for now", new Color(175, 255, 175)); - } - } - - public override void PreUpdateWorld() - { - LimitSoulCount(); - - UpdateEmpoweringFactor(); - } - } + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + public class AssWorld : AssSystem + { + //basically "if they were alive last update" + public bool megalodonAlive = false; + public bool miniocramAlive = false; + //"are they alive this update" + bool isMegalodonSpawned; + bool isMiniocramSpawned; + //static names, in case you want to change them later + public static string megalodonName = Megalodon.name; + public static string miniocramName = SpawnOfOcram.name; + public static string megalodonMessage = Megalodon.message; + public static string miniocramMessage = SpawnOfOcram.message; + //the megalodon messages are modified down below in the Disappear message + + //Soul stuff + public static bool downedHarvester; + + public static bool slimeRainSky = false; + + public override void OnWorldLoad() + { + downedHarvester = false; + } + + public override void SaveWorldData(TagCompound tag) + { + var downed = new List(); + if (downedHarvester) + { + downed.Add("harvester"); + } + + tag.Add("downed", downed); + } + + public override void LoadWorldData(TagCompound tag) + { + var downed = tag.GetList("downed"); + downedHarvester = downed.Contains("harvester"); + } + + public override void NetSend(BinaryWriter writer) + { + BitsByte flags = new BitsByte(); + flags[0] = downedHarvester; + writer.Write(flags); + + } + + public override void NetReceive(BinaryReader reader) + { + BitsByte flags = reader.ReadByte(); + downedHarvester = flags[0]; + } + + //small methods I made for myself to not make the code cluttered since I have to use these six times + public static void AwakeningMessage(string message, Vector2 pos = default(Vector2), int soundStyle = -1) + { + if (soundStyle != -1) SoundEngine.PlaySound(SoundID.Roar, pos, soundStyle); //soundStyle 2 for screech, 0 for regular roar + Message(message, new Color(175, 75, 255)); + } + + public static void Message(string message, Color color) + { + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(message, color); + } + else if (Main.netMode == NetmodeID.Server) + { + ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(message), color); + } + } + + public static void ToggleSlimeRainSky() + { + if (!Main.slimeRain && Main.netMode != NetmodeID.MultiplayerClient) + { + if (!slimeRainSky) + { + SkyManager.Instance.Activate("Slime", default(Vector2)); + CombatText.NewText(Main.LocalPlayer.getRect(), CombatText.HealLife, "Background Activated"); + slimeRainSky = true; + } + else + { + SkyManager.Instance.Deactivate("Slime"); + CombatText.NewText(Main.LocalPlayer.getRect(), CombatText.DamagedFriendly, "Background Deactivated"); + slimeRainSky = false; + } + } + } + + public static void DisableSlimeRainSky() + { + if (!Main.slimeRain && slimeRainSky && Main.netMode != NetmodeID.MultiplayerClient) + { + SkyManager.Instance.Deactivate("Slime"); + CombatText.NewText(Main.LocalPlayer.getRect(), CombatText.DamagedFriendly, "Background Deactivated"); + slimeRainSky = false; + } + } + + private void LimitSoulCount() + { + if (!ContentConfig.Instance.Bosses) + { + return; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Main.GameUpdateCount % 30 == 15 && NPC.CountNPCS(ModContent.NPCType()) > 10) //limit soul count in the world to 15 + { + short oldest = 200; + int timeleftmin = int.MaxValue; + for (short j = 0; j < Main.maxNPCs; j++) + { + NPC npc = Main.npc[j]; + if (npc.active && npc.type == ModContent.NPCType()) + { + if (npc.timeLeft < timeleftmin) + { + timeleftmin = npc.timeLeft; + oldest = j; + } + } + } + if (oldest != Main.maxNPCs) + { + NPC oldestnpc = Main.npc[oldest]; + oldestnpc.active = false; + oldestnpc.netUpdate = true; + if (Main.netMode == NetmodeID.Server && oldest < Main.maxNPCs) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, oldest); + } + //poof visual + for (int i = 0; i < 15; i++) + { + Dust dust = Dust.NewDustPerfect(oldestnpc.Center, 59, new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 1.5f)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); + dust.noLight = true; + dust.noGravity = true; + dust.fadeIn = Main.rand.NextFloat(0.1f, 0.6f); + } + } + } + } + } + + private void UpdateEmpoweringFactor() + { + if (NPC.downedPlantBoss && AssPlayer.empoweringTotal < 1f) + AssPlayer.empoweringTotal = 1f; + else if (Main.hardMode && AssPlayer.empoweringTotal < 0.75f) + AssPlayer.empoweringTotal = 0.75f; + } + + public override void ResetNearbyTileEffects() + { + Main.LocalPlayer.GetModPlayer().wyvernCampfire = false; + } + + public override void PostUpdateWorld() + { + CheckSpawns(); + } + + private void CheckSpawns() + { + if (!ContentConfig.Instance.HostileNPCs) + { + return; + } + + //this code is when I first started modding, terrible stuff + //those flags are checked for trueness each update + isMegalodonSpawned = false; + isMiniocramSpawned = false; + for (short j = 0; j < Main.maxNPCs; j++) + { + NPC npc = Main.npc[j]; + if (npc.active) + { + if (npc.TypeName == megalodonName && !isMegalodonSpawned) + { + isMegalodonSpawned = true; + //check if it wasnt alive in previous update + if (!megalodonAlive) + { + AwakeningMessage(megalodonMessage, npc.position, 0); + megalodonAlive = true; + } + } + if (npc.TypeName == miniocramName && !isMiniocramSpawned) + { + isMiniocramSpawned = true; + if (!miniocramAlive) + { + AwakeningMessage(miniocramMessage, npc.position, 0); + miniocramAlive = true; + } + } + } + } + //after this we know that either atleast one miniboss is active or not + //if alive, but not active, print disappear message + if (!isMegalodonSpawned && megalodonAlive) + { + megalodonAlive = false; + Message("The " + megalodonName + " disappeared... for now", new Color(175, 255, 175)); + } + if (!isMiniocramSpawned && miniocramAlive) + { + miniocramAlive = false; + Message("The " + miniocramName + " disappeared... for now", new Color(175, 255, 175)); + } + } + + public override void PreUpdateWorld() + { + LimitSoulCount(); + + UpdateEmpoweringFactor(); + } + } } diff --git a/AssortedCrazyThings.cs b/AssortedCrazyThings.cs index 617a4f71..7a2cc3ba 100644 --- a/AssortedCrazyThings.cs +++ b/AssortedCrazyThings.cs @@ -18,402 +18,402 @@ namespace AssortedCrazyThings { - class AssortedCrazyThings : Mod - { - //Soul item animated textures - public const int animatedSoulFrameCount = 6; - public static Asset[] animatedSoulTextures; - - /// - /// Soul NPC spawn blacklist - /// - public static int[] soulBuffBlacklist; - - /// - /// The cached type of the Harvester boss, 0 if not loaded - /// - public static int harvester; - /// - /// The cached type of the left talon of the Harvester boss, 0 if not loaded - /// - public static int harvesterTalonLeft; - /// - /// The cached type of the right talon of the Harvester boss, 0 if not loaded - /// - public static int harvesterTalonRight; - - //Mod Helpers compat - public static string GithubUserName { get { return "Werebearguy"; } } - public static string GithubProjectName { get { return "AssortedCrazyThings"; } } - - private void LoadSoulBuffBlacklist() - { - List tempList = new List - { - NPCID.Bee, - NPCID.BeeSmall, - NPCID.BlueSlime, - NPCID.BlazingWheel, - NPCID.EaterofWorldsHead, - NPCID.EaterofWorldsBody, - NPCID.EaterofWorldsTail, - NPCID.Creeper, - NPCID.GolemFistLeft, - NPCID.GolemFistRight, - NPCID.PlanterasHook, - NPCID.PlanterasTentacle, - NPCID.Probe, - NPCID.ServantofCthulhu, - NPCID.SlimeSpiked, - NPCID.SpikeBall, - NPCID.TheHungry, - NPCID.TheHungryII, - }; - - soulBuffBlacklist = tempList.ToArray(); - } - - /// - /// Assuming this is called after InitSoulBuffBlacklist. - /// Adds NPC types to soulBuffBlacklist manually - /// - private void AddToSoulBuffBlacklist() - { - if (!ContentConfig.Instance.Bosses) - { - return; - } - - //assuming this is called after InitSoulBuffBlacklist - List tempList = new List(soulBuffBlacklist) - { - ModContent.NPCType(), - ModContent.NPCType(), - }; - - soulBuffBlacklist = tempList.ToArray(); - Array.Sort(soulBuffBlacklist); - } - - /// - /// Fills isModdedWormBodyOrTail with types of modded NPCs which names are ending with Body or Tail (indicating they are part of something) - /// - private void LoadWormList() - { - List tempList = new List(); - - for (int i = Main.maxNPCTypes; i < NPCLoader.NPCCount; i++) - { - ModNPC modNPC = NPCLoader.GetNPC(i); - if (modNPC != null && (modNPC.GetType().Name.EndsWith("Body") || modNPC.GetType().Name.EndsWith("Tail"))) - { - tempList.Add(modNPC.NPC.type); - } - } - - AssUtils.isModdedWormBodyOrTail = tempList.ToArray(); - Array.Sort(AssUtils.isModdedWormBodyOrTail); - } - - private void LoadHarvesterTypes() - { - if (!ContentConfig.Instance.Bosses) - { - return; - } - - harvester = ModContent.NPCType(); - harvesterTalonLeft = ModContent.NPCType(); - harvesterTalonRight = ModContent.NPCType(); - } - - private void LoadMisc() - { - if (!Main.dedServ && ContentConfig.Instance.Bosses) - { - animatedSoulTextures = new Asset[2]; - - animatedSoulTextures[0] = Assets.Request("Items/CaughtDungeonSoulAnimated"); - animatedSoulTextures[1] = Assets.Request("Items/CaughtDungeonSoulFreedAnimated"); - } - } - - private void UnloadMisc() - { - animatedSoulTextures = null; - - PetEaterofWorldsBase.wormTypes = null; - - PetDestroyerBase.wormTypes = null; - } - - public override void Load() - { - ConfigurationSystem.Load(); - - ShaderManager.Load(); - - LoadHarvesterTypes(); - - LoadSoulBuffBlacklist(); - - LoadMisc(); - } - - public override void Unload() - { - ConfigurationSystem.Unload(); - - ShaderManager.Unload(); - - UnloadMisc(); - - GitgudData.Unload(); - - EverhallowedLantern.DoUnload(); - } - - public override void PostSetupContent() - { - //for things that have to be called after Load() because of Main.projFrames[projectile.type] calls (and similar) - LoadWormList(); - - GitgudData.Load(); - - DroneController.DoLoad(); - - EverhallowedLantern.DoLoad(); - - AddToSoulBuffBlacklist(); - - if (ContentConfig.Instance.DroppedPets) - { - PetEaterofWorldsBase.wormTypes = new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }; - - PetDestroyerBase.wormTypes = new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }; - } - } - - public override void AddRecipeGroups() - { - string any = Language.GetTextValue("LegacyMisc.37") + " "; - if (ContentConfig.Instance.CuteSlimes && ContentConfig.Instance.PlaceablesFunctional) - { - RecipeGroup.RegisterGroup("ACT:RegularCuteSlimes", new RecipeGroup(() => any + "Regular Bottled Slime", new int[] - { - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - })); - } - - RecipeGroup.RegisterGroup("ACT:EvilWood", new RecipeGroup(() => any + Lang.GetItemNameValue(ItemID.Ebonwood), new int[] - { - ItemID.Ebonwood, - ItemID.Shadewood - })); - - RecipeGroup.RegisterGroup("ACT:GoldPlatinum", new RecipeGroup(() => any + Lang.GetItemNameValue(ItemID.GoldBar), new int[] - { - ItemID.GoldBar, - ItemID.PlatinumBar - })); - - RecipeGroup.RegisterGroup("ACT:AdamantiteTitanium", new RecipeGroup(() => any + Lang.GetItemNameValue(ItemID.AdamantiteBar), new int[] - { - ItemID.AdamantiteBar, - ItemID.TitaniumBar - })); - - RecipeGroup.RegisterGroup("ACT:DemoniteCrimtane", new RecipeGroup(() => any + Lang.GetItemNameValue(ItemID.DemoniteBar), new int[] - { - ItemID.DemoniteBar, - ItemID.CrimtaneBar - })); - } - - public override void HandlePacket(BinaryReader reader, int whoAmI) - { - AssMessageType msgType = (AssMessageType)reader.ReadByte(); - byte playerNumber; - byte npcNumber; - AssPlayer aPlayer; - PetPlayer petPlayer; - byte changes; - byte index; - - switch (msgType) - { - case AssMessageType.SyncPlayerVanity: - playerNumber = reader.ReadByte(); - petPlayer = Main.player[playerNumber].GetModPlayer(); - //no "changes" packet - petPlayer.RecvSyncPlayerVanitySub(reader); - break; - case AssMessageType.ClientChangesVanity: - //client and server - //getmodplayer error - playerNumber = reader.ReadByte(); - petPlayer = Main.player[playerNumber].GetModPlayer(); - changes = reader.ReadByte(); - index = reader.ReadByte(); - petPlayer.RecvClientChangesPacketSub(reader, changes, index); - - //server transmits to others - if (Main.netMode == NetmodeID.Server) - { - petPlayer.SendClientChangesPacketSub(changes, index, toClient: -1, ignoreClient: playerNumber); - } - break; - case AssMessageType.SyncAssPlayer: - playerNumber = reader.ReadByte(); - aPlayer = Main.player[playerNumber].GetModPlayer(); - aPlayer.ReceiveSyncPlayer(reader); - break; - case AssMessageType.ClientChangesAssPlayer: - //client and server - //getmodplayer error - playerNumber = reader.ReadByte(); - aPlayer = Main.player[playerNumber].GetModPlayer(); - aPlayer.shieldDroneReduction = reader.ReadByte(); - aPlayer.droneControllerUnlocked = (DroneType)reader.ReadByte(); - - //server transmits to others - if (Main.netMode == NetmodeID.Server) - { - aPlayer.SendClientChangesPacket(toClient: -1, ignoreClient: playerNumber); - } - break; - case AssMessageType.ConvertInertSoulsInventory: - if (Main.netMode == NetmodeID.MultiplayerClient) - { - //convert souls in local inventory - aPlayer = Main.LocalPlayer.GetModPlayer(); - aPlayer.ConvertInertSoulsInventory(); - } - break; - case AssMessageType.GitgudLoadCounters: - if (Main.netMode == NetmodeID.Server) - { - GitgudData.RecvCounters(reader); - } - break; - case AssMessageType.GitgudChangeCounters: - if (Main.netMode == NetmodeID.MultiplayerClient) - { - //GitgudData.RecvReset(Main.myPlayer, reader); - GitgudData.RecvChangeCounter(reader); - } - break; - case AssMessageType.ResetEmpoweringTimerpvp: - //client and server - playerNumber = reader.ReadByte(); - aPlayer = Main.player[playerNumber].GetModPlayer(); - aPlayer.ResetEmpoweringTimer(fromServer: true); - - //server transmits to others - if (Main.netMode == NetmodeID.Server) - { - ModPacket packet = GetPacket(); - packet.Write((byte)AssMessageType.ResetEmpoweringTimerpvp); - packet.Write((byte)playerNumber); - packet.Send(playerNumber); //send to client - } - break; - case AssMessageType.WyvernCampfireKill: - npcNumber = reader.ReadByte(); - if (npcNumber < 0 || npcNumber >= Main.maxNPCs) break; - NPC npc = Main.npc[npcNumber]; - if (npc.type == NPCID.WyvernHead) - { - DungeonSoulBase.KillInstantly(npc); - if (npcNumber < Main.maxNPCs) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npcNumber); - } - } - else - { - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC other = Main.npc[k]; - if (other.active && other.type == NPCID.WyvernHead) - { - DungeonSoulBase.KillInstantly(other); - if (k < Main.maxNPCs) - { - NetMessage.SendData(MessageID.SyncNPC, number: k); - } - break; - } - } - } - break; - case AssMessageType.SlainBoss: - if (Main.netMode == NetmodeID.MultiplayerClient) - { - int type = reader.ReadVarInt(); - Main.LocalPlayer.GetModPlayer().SlainBoss(type); - } - break; - default: - Logger.Debug("Unknown Message type: " + msgType); - break; - } - } - - //Credit to jopojelly - /// - /// Makes alpha on .png textures actually properly rendered - /// - public static void PremultiplyTexture(Texture2D texture) - { - Color[] buffer = new Color[texture.Width * texture.Height]; - texture.GetData(buffer); - for (int i = 0; i < buffer.Length; i++) - { - buffer[i] = Color.FromNonPremultiplied(buffer[i].R, buffer[i].G, buffer[i].B, buffer[i].A); - } - texture.SetData(buffer); - } - } - - public enum AssMessageType : byte - { - ClientChangesVanity, - SyncPlayerVanity, - ClientChangesAssPlayer, - SyncAssPlayer, - ConvertInertSoulsInventory, - GitgudLoadCounters, - GitgudChangeCounters, - ResetEmpoweringTimerpvp, - WyvernCampfireKill, - SlainBoss - } - - public enum PetPlayerChanges : byte - { - None, - All, - Slots, - PetTypes - } + class AssortedCrazyThings : Mod + { + //Soul item animated textures + public const int animatedSoulFrameCount = 6; + public static Asset[] animatedSoulTextures; + + /// + /// Soul NPC spawn blacklist + /// + public static int[] soulBuffBlacklist; + + /// + /// The cached type of the Harvester boss, 0 if not loaded + /// + public static int harvester; + /// + /// The cached type of the left talon of the Harvester boss, 0 if not loaded + /// + public static int harvesterTalonLeft; + /// + /// The cached type of the right talon of the Harvester boss, 0 if not loaded + /// + public static int harvesterTalonRight; + + //Mod Helpers compat + public static string GithubUserName { get { return "Werebearguy"; } } + public static string GithubProjectName { get { return "AssortedCrazyThings"; } } + + private void LoadSoulBuffBlacklist() + { + List tempList = new List + { + NPCID.Bee, + NPCID.BeeSmall, + NPCID.BlueSlime, + NPCID.BlazingWheel, + NPCID.EaterofWorldsHead, + NPCID.EaterofWorldsBody, + NPCID.EaterofWorldsTail, + NPCID.Creeper, + NPCID.GolemFistLeft, + NPCID.GolemFistRight, + NPCID.PlanterasHook, + NPCID.PlanterasTentacle, + NPCID.Probe, + NPCID.ServantofCthulhu, + NPCID.SlimeSpiked, + NPCID.SpikeBall, + NPCID.TheHungry, + NPCID.TheHungryII, + }; + + soulBuffBlacklist = tempList.ToArray(); + } + + /// + /// Assuming this is called after InitSoulBuffBlacklist. + /// Adds NPC types to soulBuffBlacklist manually + /// + private void AddToSoulBuffBlacklist() + { + if (!ContentConfig.Instance.Bosses) + { + return; + } + + //assuming this is called after InitSoulBuffBlacklist + List tempList = new List(soulBuffBlacklist) + { + ModContent.NPCType(), + ModContent.NPCType(), + }; + + soulBuffBlacklist = tempList.ToArray(); + Array.Sort(soulBuffBlacklist); + } + + /// + /// Fills isModdedWormBodyOrTail with types of modded NPCs which names are ending with Body or Tail (indicating they are part of something) + /// + private void LoadWormList() + { + List tempList = new List(); + + for (int i = Main.maxNPCTypes; i < NPCLoader.NPCCount; i++) + { + ModNPC modNPC = NPCLoader.GetNPC(i); + if (modNPC != null && (modNPC.GetType().Name.EndsWith("Body") || modNPC.GetType().Name.EndsWith("Tail"))) + { + tempList.Add(modNPC.NPC.type); + } + } + + AssUtils.isModdedWormBodyOrTail = tempList.ToArray(); + Array.Sort(AssUtils.isModdedWormBodyOrTail); + } + + private void LoadHarvesterTypes() + { + if (!ContentConfig.Instance.Bosses) + { + return; + } + + harvester = ModContent.NPCType(); + harvesterTalonLeft = ModContent.NPCType(); + harvesterTalonRight = ModContent.NPCType(); + } + + private void LoadMisc() + { + if (!Main.dedServ && ContentConfig.Instance.Bosses) + { + animatedSoulTextures = new Asset[2]; + + animatedSoulTextures[0] = Assets.Request("Items/CaughtDungeonSoulAnimated"); + animatedSoulTextures[1] = Assets.Request("Items/CaughtDungeonSoulFreedAnimated"); + } + } + + private void UnloadMisc() + { + animatedSoulTextures = null; + + PetEaterofWorldsBase.wormTypes = null; + + PetDestroyerBase.wormTypes = null; + } + + public override void Load() + { + ConfigurationSystem.Load(); + + ShaderManager.Load(); + + LoadHarvesterTypes(); + + LoadSoulBuffBlacklist(); + + LoadMisc(); + } + + public override void Unload() + { + ConfigurationSystem.Unload(); + + ShaderManager.Unload(); + + UnloadMisc(); + + GitgudData.Unload(); + + EverhallowedLantern.DoUnload(); + } + + public override void PostSetupContent() + { + //for things that have to be called after Load() because of Main.projFrames[projectile.type] calls (and similar) + LoadWormList(); + + GitgudData.Load(); + + DroneController.DoLoad(); + + EverhallowedLantern.DoLoad(); + + AddToSoulBuffBlacklist(); + + if (ContentConfig.Instance.DroppedPets) + { + PetEaterofWorldsBase.wormTypes = new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }; + + PetDestroyerBase.wormTypes = new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }; + } + } + + public override void AddRecipeGroups() + { + string any = Language.GetTextValue("LegacyMisc.37") + " "; + if (ContentConfig.Instance.CuteSlimes && ContentConfig.Instance.PlaceablesFunctional) + { + RecipeGroup.RegisterGroup("ACT:RegularCuteSlimes", new RecipeGroup(() => any + "Regular Bottled Slime", new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + })); + } + + RecipeGroup.RegisterGroup("ACT:EvilWood", new RecipeGroup(() => any + Lang.GetItemNameValue(ItemID.Ebonwood), new int[] + { + ItemID.Ebonwood, + ItemID.Shadewood + })); + + RecipeGroup.RegisterGroup("ACT:GoldPlatinum", new RecipeGroup(() => any + Lang.GetItemNameValue(ItemID.GoldBar), new int[] + { + ItemID.GoldBar, + ItemID.PlatinumBar + })); + + RecipeGroup.RegisterGroup("ACT:AdamantiteTitanium", new RecipeGroup(() => any + Lang.GetItemNameValue(ItemID.AdamantiteBar), new int[] + { + ItemID.AdamantiteBar, + ItemID.TitaniumBar + })); + + RecipeGroup.RegisterGroup("ACT:DemoniteCrimtane", new RecipeGroup(() => any + Lang.GetItemNameValue(ItemID.DemoniteBar), new int[] + { + ItemID.DemoniteBar, + ItemID.CrimtaneBar + })); + } + + public override void HandlePacket(BinaryReader reader, int whoAmI) + { + AssMessageType msgType = (AssMessageType)reader.ReadByte(); + byte playerNumber; + byte npcNumber; + AssPlayer aPlayer; + PetPlayer petPlayer; + byte changes; + byte index; + + switch (msgType) + { + case AssMessageType.SyncPlayerVanity: + playerNumber = reader.ReadByte(); + petPlayer = Main.player[playerNumber].GetModPlayer(); + //no "changes" packet + petPlayer.RecvSyncPlayerVanitySub(reader); + break; + case AssMessageType.ClientChangesVanity: + //client and server + //getmodplayer error + playerNumber = reader.ReadByte(); + petPlayer = Main.player[playerNumber].GetModPlayer(); + changes = reader.ReadByte(); + index = reader.ReadByte(); + petPlayer.RecvClientChangesPacketSub(reader, changes, index); + + //server transmits to others + if (Main.netMode == NetmodeID.Server) + { + petPlayer.SendClientChangesPacketSub(changes, index, toClient: -1, ignoreClient: playerNumber); + } + break; + case AssMessageType.SyncAssPlayer: + playerNumber = reader.ReadByte(); + aPlayer = Main.player[playerNumber].GetModPlayer(); + aPlayer.ReceiveSyncPlayer(reader); + break; + case AssMessageType.ClientChangesAssPlayer: + //client and server + //getmodplayer error + playerNumber = reader.ReadByte(); + aPlayer = Main.player[playerNumber].GetModPlayer(); + aPlayer.shieldDroneReduction = reader.ReadByte(); + aPlayer.droneControllerUnlocked = (DroneType)reader.ReadByte(); + + //server transmits to others + if (Main.netMode == NetmodeID.Server) + { + aPlayer.SendClientChangesPacket(toClient: -1, ignoreClient: playerNumber); + } + break; + case AssMessageType.ConvertInertSoulsInventory: + if (Main.netMode == NetmodeID.MultiplayerClient) + { + //convert souls in local inventory + aPlayer = Main.LocalPlayer.GetModPlayer(); + aPlayer.ConvertInertSoulsInventory(); + } + break; + case AssMessageType.GitgudLoadCounters: + if (Main.netMode == NetmodeID.Server) + { + GitgudData.RecvCounters(reader); + } + break; + case AssMessageType.GitgudChangeCounters: + if (Main.netMode == NetmodeID.MultiplayerClient) + { + //GitgudData.RecvReset(Main.myPlayer, reader); + GitgudData.RecvChangeCounter(reader); + } + break; + case AssMessageType.ResetEmpoweringTimerpvp: + //client and server + playerNumber = reader.ReadByte(); + aPlayer = Main.player[playerNumber].GetModPlayer(); + aPlayer.ResetEmpoweringTimer(fromServer: true); + + //server transmits to others + if (Main.netMode == NetmodeID.Server) + { + ModPacket packet = GetPacket(); + packet.Write((byte)AssMessageType.ResetEmpoweringTimerpvp); + packet.Write((byte)playerNumber); + packet.Send(playerNumber); //send to client + } + break; + case AssMessageType.WyvernCampfireKill: + npcNumber = reader.ReadByte(); + if (npcNumber < 0 || npcNumber >= Main.maxNPCs) break; + NPC npc = Main.npc[npcNumber]; + if (npc.type == NPCID.WyvernHead) + { + DungeonSoulBase.KillInstantly(npc); + if (npcNumber < Main.maxNPCs) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npcNumber); + } + } + else + { + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC other = Main.npc[k]; + if (other.active && other.type == NPCID.WyvernHead) + { + DungeonSoulBase.KillInstantly(other); + if (k < Main.maxNPCs) + { + NetMessage.SendData(MessageID.SyncNPC, number: k); + } + break; + } + } + } + break; + case AssMessageType.SlainBoss: + if (Main.netMode == NetmodeID.MultiplayerClient) + { + int type = reader.ReadVarInt(); + Main.LocalPlayer.GetModPlayer().SlainBoss(type); + } + break; + default: + Logger.Debug("Unknown Message type: " + msgType); + break; + } + } + + //Credit to jopojelly + /// + /// Makes alpha on .png textures actually properly rendered + /// + public static void PremultiplyTexture(Texture2D texture) + { + Color[] buffer = new Color[texture.Width * texture.Height]; + texture.GetData(buffer); + for (int i = 0; i < buffer.Length; i++) + { + buffer[i] = Color.FromNonPremultiplied(buffer[i].R, buffer[i].G, buffer[i].B, buffer[i].A); + } + texture.SetData(buffer); + } + } + + public enum AssMessageType : byte + { + ClientChangesVanity, + SyncPlayerVanity, + ClientChangesAssPlayer, + SyncAssPlayer, + ConvertInertSoulsInventory, + GitgudLoadCounters, + GitgudChangeCounters, + ResetEmpoweringTimerpvp, + WyvernCampfireKill, + SlainBoss + } + + public enum PetPlayerChanges : byte + { + None, + All, + Slots, + PetTypes + } } diff --git a/Base/AssAI.cs b/Base/AssAI.cs index 922247a1..8fb8def4 100644 --- a/Base/AssAI.cs +++ b/Base/AssAI.cs @@ -7,1793 +7,1793 @@ namespace AssortedCrazyThings.Base { - /// - /// contains AI for stuff that only uses ai[], used with thing.aiStyle = -1 - /// - public static class AssAI - { - /// - /// Makes the projectile teleport if it is too far away from the given location - /// - public static bool TeleportIfTooFar(Projectile projectile, Vector2 desiredCenter, int distance = 2000) - { - if (projectile.DistanceSQ(desiredCenter) > distance * distance) - { - projectile.Center = desiredCenter; - if (Main.myPlayer == projectile.owner) projectile.netUpdate = true; - return true; - } - return false; - } - - /// - /// Finds target in range of relativeCenter. Returns index of target - /// - public static int FindTarget(Entity ent, Vector2 relativeCenter, float range, bool ignoreTiles = false) - { - int targetIndex = -1; - float distanceFromTarget = 10000000f; - Vector2 targetCenter = relativeCenter; - range *= range; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - if (npc.CanBeChasedBy()) - { - //Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height) - float between = Vector2.DistanceSquared(npc.Center, relativeCenter); - if ((between < range && Vector2.DistanceSquared(relativeCenter, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1) - { - if (ignoreTiles || Collision.CanHitLine(ent.position, ent.width, ent.height, npc.position, npc.width, npc.height)) - { - distanceFromTarget = between; - targetCenter = npc.Center; - targetIndex = k; - } - } - } - } - return distanceFromTarget < range ? targetIndex : -1; - } - - /// - /// Utility for minion AI that handles a custom stuck timer for when the X coordinate doesn't change for a given duration. - /// - /// The projectile - /// The X coordinate of the idle location (to not increment the timer when near that) - /// The timer - /// The maximum duration - /// Returns true if the timer overflows - public static bool HandleStuck(this Projectile projectile, float restingX, ref int stuckTimer, int stuckTimerMax) - { - if (projectile.position.X == projectile.oldPosition.X && Math.Abs(projectile.Center.X - restingX) >= 50) - { - stuckTimer++; - - if (stuckTimer >= stuckTimerMax) - { - stuckTimer = 0; - return true; - } - } - else - { - if (stuckTimer >= 2) - { - stuckTimer -= 2; - } - } - - return false; - } - - #region Flickerwick - public static void FlickerwickPetDraw(Projectile projectile, int frameCounterMaxFar, int frameCounterMaxClose) - { - projectile.LoopAnimation((projectile.velocity.Length() > 6f) ? frameCounterMaxFar : frameCounterMaxClose); - } - - /// - /// No use of ai[] or LocalAI[]. - /// Default offset is x = 30, y = -20 - /// - public static void FlickerwickPetAI(Projectile projectile, bool lightPet = true, bool lightDust = true, bool staticDirection = false, bool reverseSide = false, bool vanityPet = false, float veloXToRotationFactor = 1f, float veloSpeed = 1f, float lightFactor = 1f, Vector3 lightColor = default(Vector3), float offsetX = 0f, float offsetY = 0f) - { - //veloSpeed not bigger than veloDistanceChange * 0.5f - Player player = projectile.GetOwner(); - float veloDistanceChange = 2f; //6f - - int dir = player.direction; - if (staticDirection) - { - if (reverseSide) - { - dir = -1; - } - else - { - dir = 1; - } - } - else - { - if (reverseSide) - { - dir = -dir; - } - } - - //up and down bobbing - //projectile.localAI[0] += 1f; - //if (projectile.localAI[0] > 120f) - //{ - // projectile.localAI[0] = 0f; - //} - //value.Y += (float)Math.Cos((double)(projectile.localAI[0] * 0.05235988f)) * 2f; - - Vector2 dustOffset = new Vector2((projectile.spriteDirection == -1) ? -6 : -2, -20f).RotatedBy(projectile.rotation); - - Vector2 desiredCenterRelative = new Vector2(dir * (offsetX + 30), -20f + offsetY); - - projectile.direction = projectile.spriteDirection = dir; - - //if (reverseSide) - //{ - // desiredCenterRelative.X = -desiredCenterRelative.X; - // //value2.X = -value2.X; - // projectile.direction = -projectile.direction; - // projectile.spriteDirection = -projectile.spriteDirection; - //} - - if (lightDust && Main.rand.Next(24) == 0) - { - Dust dust = Dust.NewDustDirect(projectile.Center + dustOffset, 4, 4, 135, 0f, 0f, 100); - if (Main.rand.Next(3) != 0) - { - dust.noGravity = true; - dust.velocity.Y += -3f; - dust.noLight = true; - } - else if (Main.rand.Next(2) != 0) - { - dust.noLight = true; - } - dust.velocity *= 0.5f; - dust.velocity.Y += -0.9f; - dust.scale += 0.1f + Main.rand.NextFloat() * 0.6f; - dust.shader = GameShaders.Armor.GetSecondaryShader(Main.GetProjectileDesiredShader(projectile.whoAmI), player); - } - - if (lightPet) - { - if (lightColor == default(Vector3)) lightColor = new Vector3(0.3f, 0.5f, 1f); - //flickerwick is new Vector3(0.3f, 0.5f, 1f) - Vector3 vector = DelegateMethods.v3_1 = lightColor * lightFactor; - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * 6f, 20f, DelegateMethods.CastLightOpen); - Utils.PlotTileLine(projectile.Left, projectile.Right, 20f, DelegateMethods.CastLightOpen); - Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 40f, DelegateMethods.CastLightOpen); - Utils.PlotTileLine(player.Left, player.Right, 40f, DelegateMethods.CastLightOpen); - } - - Vector2 desiredCenter = player.MountedCenter + desiredCenterRelative; - Vector2 betweenDirection = desiredCenter - projectile.Center; - float betweenSQ = betweenDirection.LengthSquared(); - //if (between > 1000f) - //{ - // projectile.Center = player.Center + desiredCenterRelative; - //} - TeleportIfTooFar(projectile, desiredCenter, 1000); - if (betweenSQ < veloDistanceChange * veloDistanceChange) - { - projectile.velocity *= 0.25f; - } - if (betweenDirection != Vector2.Zero) - { - if (betweenSQ < (veloDistanceChange * 0.5f) * (veloDistanceChange * 0.5f)) - { - projectile.velocity = betweenDirection * veloSpeed; - } - else - { - projectile.velocity = betweenDirection * 0.1f * veloSpeed; - } - } - if (projectile.velocity.LengthSquared() > 6f * 6f) - { - float rotationVelo = projectile.velocity.X * 0.08f * veloXToRotationFactor + projectile.velocity.Y * projectile.spriteDirection * 0.02f; - if (Math.Abs(projectile.rotation - rotationVelo) >= 3.14159274f) - { - if (rotationVelo < projectile.rotation) - { - projectile.rotation -= 6.28318548f; - } - else - { - projectile.rotation += 6.28318548f; - } - } - float rotationAcc = 12f; - projectile.rotation = (projectile.rotation * (rotationAcc - 1f) + rotationVelo) / rotationAcc; - } - else - { - if (projectile.rotation > 3.14159274f) - { - projectile.rotation -= 6.28318548f; - } - if (projectile.rotation > -0.005f && projectile.rotation < 0.005f) - { - projectile.rotation = 0f; - } - else - { - projectile.rotation *= 0.96f; - } - } - } - #endregion - - #region EyeSpring - - /// - /// Almost proper working Eye Spring clone - /// - public static void EyeSpringAI(Projectile projectile, bool flyForever = false) - { - Player player = projectile.GetOwner(); - if (!player.active) - { - projectile.active = false; - } - else - { - bool flag = false; - bool flag2 = false; - bool flag3 = false; - bool flag4 = false; - int num = 85; - if (player.position.X + (float)(player.width / 2) < projectile.position.X + (float)(projectile.width / 2) - (float)num) - { - flag = true; - } - else if (player.position.X + (float)(player.width / 2) > projectile.position.X + (float)(projectile.width / 2) + (float)num) - { - flag2 = true; - } - if (projectile.ai[1] == 0f) - { - int num38 = 500; - if (player.rocketDelay2 > 0) - { - projectile.ai[0] = 1f; - } - Vector2 vector6 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num39 = player.position.X + (float)(player.width / 2) - vector6.X; - float num40 = player.position.Y + (float)(player.height / 2) - vector6.Y; - float num41 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); - if (num41 > 2000f) - { - TeleportIfTooFar(projectile, player.Center); - //projectile.position.X = player.position.X + (float)(player.width / 2) - (float)(projectile.width / 2); - //projectile.position.Y = player.position.Y + (float)(player.height / 2) - (float)(projectile.height / 2); - } - else if (num41 > (float)num38 || (Math.Abs(num40) > 300f) || flyForever) - { - projectile.ai[0] = 1f; - } - } - if (projectile.ai[0] != 0f) - { - float num42 = 0.2f; - int num43 = 200; - projectile.tileCollide = false; - Vector2 vector7 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num44 = player.position.X + (float)(player.width / 2) - vector7.X; - float num51 = player.position.Y + (float)(player.height / 2) - vector7.Y; - float num52 = (float)Math.Sqrt((double)(num44 * num44 + num51 * num51)); - float num53 = 10f; - //float num54 = num52; - if (num52 < (float)num43 && player.velocity.Y == 0f && projectile.position.Y + (float)projectile.height <= player.position.Y + (float)player.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - if (projectile.velocity.Y < -6f) - { - projectile.velocity.Y = -6f; - } - } - if (num52 < 60f) - { - num44 = projectile.velocity.X; - num51 = projectile.velocity.Y; - } - else - { - num52 = num53 / num52; - num44 *= num52; - num51 *= num52; - } - if (projectile.velocity.X < num44) - { - projectile.velocity.X += num42; - if (projectile.velocity.X < 0f) - { - projectile.velocity.X += num42 * 1.5f; - } - } - if (projectile.velocity.X > num44) - { - projectile.velocity.X -= num42; - if (projectile.velocity.X > 0f) - { - projectile.velocity.X -= num42 * 1.5f; - } - } - if (projectile.velocity.Y < num51) - { - projectile.velocity.Y += num42; - if (projectile.velocity.Y < 0f) - { - projectile.velocity.Y += num42 * 1.5f; - } - } - if (projectile.velocity.Y > num51) - { - projectile.velocity.Y -= num42; - if (projectile.velocity.Y > 0f) - { - projectile.velocity.Y -= num42 * 1.5f; - } - } - if ((double)projectile.velocity.X > 0.5) - { - projectile.spriteDirection = -1; - } - else if ((double)projectile.velocity.X < -0.5) - { - projectile.spriteDirection = 1; - } - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame < 6 || projectile.frame > 7) - { - projectile.frame = 6; - } - projectile.rotation = projectile.velocity.ToRotation() + 1.57f; - } - else - { - //Vector2 vector9 = Vector2.Zero; - if (projectile.ai[1] != 0f) - { - flag = false; - flag2 = false; - } - projectile.rotation = 0f; - projectile.tileCollide = true; - float num111 = 8f; - float num110 = 0.4f; - if (flag) - { - if (projectile.velocity.X > -3.5f) - { - projectile.velocity.X -= num110; - } - else - { - projectile.velocity.X -= num110 * 0.25f; - } - } - else if (flag2) - { - if (projectile.velocity.X < 3.5f) - { - projectile.velocity.X += num110; - } - else - { - projectile.velocity.X += num110 * 0.25f; - } - } - else - { - projectile.velocity.X *= 0.9f; - if (projectile.velocity.X >= 0f - num110 && projectile.velocity.X <= num110) - { - projectile.velocity.X = 0f; - } - } - if (flag | flag2) - { - int num112 = (int)(projectile.position.X + (float)(projectile.width / 2)) / 16; - int j = (int)(projectile.position.Y + (float)(projectile.height / 2)) / 16; - if (flag) - { - int num30 = num112; - num112 = num30 - 1; - } - if (flag2) - { - int num30 = num112; - num112 = num30 + 1; - } - num112 += (int)projectile.velocity.X; - if (WorldGen.SolidTile(num112, j)) - { - flag4 = true; - } - } - if (player.position.Y + player.height - 8f > projectile.position.Y + projectile.height) - { - flag3 = true; - } - if (projectile.frameCounter < 10) - { - flag4 = false; - } - //projectile.stepSpeed = 1f; - //projectile.gfxOffY = 0f; - //Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref stepSpeed, ref gfxOffY); - Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref projectile.stepSpeed, ref projectile.gfxOffY); - if (projectile.velocity.Y == 0f) - { - if (!flag3 && (projectile.velocity.X < 0f || projectile.velocity.X > 0f)) - { - int num113 = (int)(projectile.position.X + (projectile.width / 2)) / 16; - int j2 = (int)(projectile.position.Y + (projectile.height / 2)) / 16 + 1; - if (flag) - { - int num30 = num113; - num113 = num30 - 1; - } - if (flag2) - { - int num30 = num113; - num113 = num30 + 1; - } - WorldGen.SolidTile(num113, j2); - } - if (flag4) - { - int num114 = (int)(projectile.position.X + projectile.width / 2) / 16; - int num115 = (int)(projectile.position.Y + projectile.height) / 16 + 1; - if (WorldGen.SolidTile(num114, num115) || Main.tile[num114, num115].IsHalfBlock || Main.tile[num114, num115].Slope > 0) - { - try - { - num114 = (int)(projectile.position.X + projectile.width / 2) / 16; - num115 = (int)(projectile.position.Y + projectile.height / 2) / 16; - if (flag) - { - int num30 = num114; - num114 = num30 - 1; - } - if (flag2) - { - int num30 = num114; - num114 = num30 + 1; - } - num114 += (int)projectile.velocity.X; - if (!WorldGen.SolidTile(num114, num115 - 1) && !WorldGen.SolidTile(num114, num115 - 2)) - { - projectile.velocity.Y = -5.1f; - } - else if (!WorldGen.SolidTile(num114, num115 - 2)) - { - projectile.velocity.Y = -7.1f; - } - else if (WorldGen.SolidTile(num114, num115 - 5)) - { - projectile.velocity.Y = -11.1f; - } - else if (WorldGen.SolidTile(num114, num115 - 4)) - { - projectile.velocity.Y = -10.1f; - } - else - { - projectile.velocity.Y = -9.1f; - } - } - catch - { - projectile.velocity.Y = -9.1f; - } - } - } - } - if (projectile.velocity.X > num111) - { - projectile.velocity.X = num111; - } - if (projectile.velocity.X < 0f - num111) - { - projectile.velocity.X = 0f - num111; - } - if (projectile.velocity.X < 0f) - { - projectile.direction = -1; - } - if (projectile.velocity.X > 0f) - { - projectile.direction = 1; - } - if (projectile.velocity.X > num110 && flag2) - { - projectile.direction = 1; - } - if (projectile.velocity.X < 0f - num110 && flag) - { - projectile.direction = -1; - } - - - //fix cause im dumb and didnt copy ai code correctly - if (!flag && !flag2 && projectile.ai[0] == 0f) - { - projectile.direction = (player.Center - projectile.Center).X > 0 ? 1 : -1; - } - - - if (projectile.direction == -1) - { - projectile.spriteDirection = 1; - } - if (projectile.direction == 1) - { - projectile.spriteDirection = -1; - } - - if (projectile.velocity.Y == 0f) - { - if (projectile.frame > 5) - { - projectile.frameCounter = 0; - } - if (projectile.velocity.X == 0f) - { - int num116 = 3; - projectile.frameCounter++; - if (projectile.frameCounter < num116) - { - projectile.frame = 0; - } - else if (projectile.frameCounter < num116 * 2) - { - projectile.frame = 1; - } - else if (projectile.frameCounter < num116 * 3) - { - projectile.frame = 2; - } - else if (projectile.frameCounter < num116 * 4) - { - projectile.frame = 3; - } - else - { - projectile.frameCounter = num116 * 4; - } - } - else - { - projectile.velocity.X *= 0.8f; - projectile.frameCounter++; - int num117 = 3; - if (projectile.frameCounter < num117) - { - projectile.frame = 0; - } - else if (projectile.frameCounter < num117 * 2) - { - projectile.frame = 1; - } - else if (projectile.frameCounter < num117 * 3) - { - projectile.frame = 2; - } - else if (projectile.frameCounter < num117 * 4) - { - projectile.frame = 3; - } - else if (flag | flag2) - { - projectile.velocity.X *= 2f; - projectile.frame = 4; - projectile.velocity.Y = -6.1f; - projectile.frameCounter = 0; - int num30; - for (int num118 = 0; num118 < 4; num118 = num30 + 1) - { - /*int num119 = 0; Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + (float)projectile.height - 2f), projectile.width, 4, 5)*/ - ; - //Dust dust = Main.dust[num119]; - //dust.velocity += projectile.velocity; - //dust = Main.dust[num119]; - //dust.velocity *= 0.4f; - num30 = num118; - } - } - else - { - projectile.frameCounter = num117 * 4; - } - } - } - else if (projectile.velocity.Y < 0f) - { - projectile.frameCounter = 0; - projectile.frame = 5; - } - else - { - projectile.frame = 4; - projectile.frameCounter = 3; - } - projectile.velocity.Y += 0.4f; - if (projectile.velocity.Y > 10f) - { - projectile.velocity.Y = 10f; - } - } - } - } - #endregion - - #region Zephyrfish - public static void ZephyrfishDraw(Projectile projectile, int frameCounter = 5) - { - projectile.frameCounter++; - if (projectile.frameCounter > frameCounter) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) //3 - { - projectile.frame = 0; - } - } - - /// - /// Stays around a certain offset position around the parent. Does not use ai/localai - /// - public static void ZephyrfishAI(Projectile projectile, Entity parent = null, float velocityFactor = 1f, float sway = 1f, bool random = true, byte swapSides = 0, float offsetX = 0f, float offsetY = 0f) - { - //velocityFactor: - //kinda wonky, leave at 1f - - //sway: - //tells by how much increase/decrease the left/right sway of the idle pet - - //swapSides: - // 0: always behind - //-1: always left - // 1: always right - - //offsetX/Y - //offsetting the desired center the pet hovers around - - if (parent == null) parent = projectile.GetOwner(); - - Vector2 parentCenter = parent.Center; - if (parent is Player) - { - parentCenter = ((Player)parent).MountedCenter; - } - - float veloDelta = 0.3f; - projectile.tileCollide = false; //false - int someDistance = 100; - Vector2 between = parentCenter - projectile.Center; - - Vector2 desiredCenter = random ? new Vector2(Main.rand.Next(-10, 21), Main.rand.Next(-10, 21)) : Vector2.Zero; - - Vector2 offset = new Vector2(60f + offsetX, -60f + offsetY); - - if (swapSides == 1) - { - offset.X = -offset.X; - } - else if (swapSides == 0) - { - offset.X *= -parent.direction; - } - - //desiredCenter += new Vector2(60f * -player.direction, -60f); - between += desiredCenter + offset; - - TeleportIfTooFar(projectile, parentCenter + desiredCenter + offset); - - float distance = between.Length(); - //float magnitude = 6f; - if (distance < someDistance && parent.velocity.Y == 0f && projectile.position.Y + projectile.height <= parent.position.Y + parent.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - //projectile.ai[0] = 0; - if (projectile.velocity.Y < -6f) - { - projectile.velocity.Y = -6f; - } - } - float swayDistance = 50 * sway; - if (distance < swayDistance) //50 - { - if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.velocity *= 0.99f; - } - veloDelta = 0.01f; - } - else - { - if (distance < swayDistance * 2) //100 - { - veloDelta = 0.1f; - } - //between: 0.3f - if (distance > swayDistance * 6) //300 - { - veloDelta = 0.4f; - } - between.Normalize(); - between *= 6f; - between *= velocityFactor; - } - veloDelta *= velocityFactor; - if (projectile.velocity.X < between.X) - { - projectile.velocity.X += veloDelta; - if (veloDelta > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X += +veloDelta; - } - } - if (projectile.velocity.X > between.X) - { - projectile.velocity.X += -veloDelta; - if (veloDelta > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X += -veloDelta; - } - } - if (projectile.velocity.Y < between.Y) - { - projectile.velocity.Y += veloDelta; - if (veloDelta > 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y += veloDelta * 2f; - } - } - if (projectile.velocity.Y > between.Y) - { - projectile.velocity.Y += -veloDelta; - if (veloDelta > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y += -veloDelta * 2f; - } - } - projectile.manualDirectionChange = true; - if (projectile.velocity.X > 0.25f && projectile.direction == 1) - { - projectile.direction = -1; - } - else if (projectile.velocity.X < -0.25f && projectile.direction != 1) - { - projectile.direction = 1; - } - projectile.spriteDirection = projectile.direction; - - //fix, direction gets set automatically by "manualDirectionChange = false" projectiled on velocity.X - //if (projectile.velocity.X > 0.25f) - //{ - // projectile.ai[0] = -1; - //} - //else if (projectile.velocity.X < -0.25f) - //{ - // projectile.ai[0] = 1; - //} - //projectile.direction = (int)projectile.ai[0]; - //projectile.spriteDirection = projectile.direction; - projectile.rotation = projectile.velocity.X * 0.05f; - } - #endregion - - #region BabyEater - public static void BabyEaterDraw(Projectile projectile, int frameCounter = 6) - { - projectile.frameCounter++; - if (projectile.frameCounter > frameCounter) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) //2 - { - projectile.frame = 0; - } - } - - public static void BabyEaterAI(Projectile projectile, Entity parent = null, Vector2 originOffset = default(Vector2), float velocityFactor = 1f, float sway = 1f) - { - //velocityFactor: - //kinda wonky, leave at 1f - - //sway: - //tells by how much increase/decrease the left/right sway radius of the idle pet - - if (parent == null) parent = projectile.GetOwner(); - - if (!parent.active) - { - projectile.active = false; - return; - } - - Vector2 parentCenter = parent.Center; - if (parent is Player) - { - parentCenter = ((Player)parent).MountedCenter; - } - parentCenter += originOffset; - - float veloDelta = 0.1f; - projectile.tileCollide = false; - int someDistance = 300; - Vector2 between = parentCenter - projectile.Center; - float distance = between.Length(); - float magnitude = 7f; - - TeleportIfTooFar(projectile, parentCenter, 1380); - - if (distance < someDistance && parent.velocity.Y == 0f && projectile.position.Y + projectile.height <= parent.position.Y + parent.height + originOffset.Y && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - if (projectile.velocity.Y < -6f) - { - projectile.velocity.Y = -6f; - } - } - float swayDistance = 150f * sway; - if (distance < swayDistance) - { - if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.velocity *= 0.99f; - } - veloDelta = 0.01f; - if (between.X < -2f) - { - between.X = -2f; - } - if (between.X > 2f) - { - between.X = 2f; - } - if (between.Y < -2f) - { - between.Y = -2f; - } - if (between.Y > 2f) - { - between.Y = 2f; - } - } - else - { - if (distance > swayDistance * 2f) - { - veloDelta = 0.2f; - } - between.Normalize(); - between *= magnitude; - } - - veloDelta *= velocityFactor; - - if (Math.Abs(between.X) > Math.Abs(between.Y)) - { - if (projectile.velocity.X < between.X) - { - projectile.velocity.X += veloDelta; - if (veloDelta > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X += veloDelta; - } - } - if (projectile.velocity.X > between.X) - { - projectile.velocity.X += -veloDelta; - if (veloDelta > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X += -veloDelta; - } - } - } - if (Math.Abs(between.X) <= Math.Abs(between.Y) || veloDelta == 0.05f) - { - if (projectile.velocity.Y < between.Y) - { - projectile.velocity.Y += veloDelta; - if (veloDelta > 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y += veloDelta; - } - } - if (projectile.velocity.Y > between.Y) - { - projectile.velocity.Y += -veloDelta; - if (veloDelta > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y += -veloDelta; - } - } - } - projectile.rotation = projectile.velocity.ToRotation() - 1.57f; - } - #endregion - - #region StardustDragon - - - //ProjectileID.Sets. - //NeedsUUID = true; - //DontAttachHideToAlpha =true; - - //if minion = true: - //ProjectileID.Sets.MinionSacrificable[projectile.type] = false, cause the replacing code for worm minions is complicated - //damage set in NewProjectile/item - //scales in size with the amount of segments - public static void StardustDragonSetDefaults(Projectile projectile, int size = 24, bool minion = true, WormType wormType = WormType.None) - { - if (minion) - { - //if (projectile.type == 625 || projectile.type == 628) - //{ - // projectile.netImportant = true; - //} - if (wormType == WormType.Body1 || wormType == WormType.Body2) - { - projectile.minionSlots = 0.5f; - } - projectile.DamageType = DamageClass.Summon; - projectile.minion = true; - //projectile.hide = true; - projectile.netImportant = true; - } - projectile.Size = new Vector2(size); - projectile.penetrate = -1; - projectile.timeLeft *= 5; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.alpha = 255; - } - //wormTypes = new int[] {head, body1, body2, tail} //projectiletype - - //if minion = true: - //float scaleFactor = MathHelper.Clamp(projectile.localAI[0], 0f, 50f); - //projectile.scale = 1f + scaleFactor * 0.01f; - public static void StardustDragonAI(Projectile projectile, int[] wormTypes, int segmentDistance = 16) - { - Player player = projectile.GetOwner(); - - if (projectile.minion && (int)Main.time % 120 == 0) - { - projectile.netUpdate = true; - } - if (!player.active) - { - projectile.active = false; - return; - } - bool head = projectile.type == wormTypes[0]; - int defScaleFactor = 30; - //if (Main.rand.Next(30) == 0) - //{ - // int num1049 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 0, default(Color), 2f); - // Main.dust[num1049].noGravity = true; - // Main.dust[num1049].fadeIn = 2f; - // Point point4 = Main.dust[num1049].position.ToTileCoordinates(); - // if (WorldGen.InWorld(point4.X, point4.Y, 5) && WorldGen.SolidTile(point4.X, point4.Y)) - // { - // Main.dust[num1049].noLight = true; - // } - //} - - if (projectile.alpha > 0) - { - //for (int i = 0; i < 2; i++) - //{ - // int dust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 135, 0f, 0f, 100, default(Color), 2f); - // Main.dust[dust].noGravity = true; - // Main.dust[dust].noLight = true; - //} - projectile.alpha -= 42; - if (projectile.alpha < 0) - { - projectile.alpha = 0; - return; - } - } - - if (head) - { - Vector2 desiredCenter = player.Center; - int targetIndex = -1; - TeleportIfTooFar(projectile, desiredCenter); - if (projectile.minion) - { - float maxProjDistance = 490000f; - float maxPlayerDistance = 1000000f; - NPC ownerMinionAttackTargetNPC5 = projectile.OwnerMinionAttackTargetNPC; - if (ownerMinionAttackTargetNPC5 != null && ownerMinionAttackTargetNPC5.CanBeChasedBy()) - { - float distance1 = projectile.DistanceSQ(ownerMinionAttackTargetNPC5.Center); - if (distance1 < maxProjDistance * 2f) - { - targetIndex = ownerMinionAttackTargetNPC5.whoAmI; - } - } - if (targetIndex < 0) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy() && player.DistanceSQ(npc.Center) < maxPlayerDistance) - { - float distance2 = projectile.DistanceSQ(npc.Center); - if (distance2 < maxProjDistance) - { - targetIndex = i; - } - } - } - } - } - if (targetIndex != -1) - { - NPC npc = Main.npc[targetIndex]; - Vector2 betweenNPC = npc.Center - projectile.Center; - float veloFactor = 0.4f; - if (betweenNPC.Length() < 600f) - { - veloFactor = 0.6f; - } - if (betweenNPC.Length() < 300f) - { - veloFactor = 0.8f; - } - if (betweenNPC.Length() > npc.Size.Length() * 0.75f) - { - projectile.velocity += Vector2.Normalize(betweenNPC) * veloFactor * 1.5f; - if (Vector2.Dot(projectile.velocity, betweenNPC) < 0.25f) - { - projectile.velocity *= 0.8f; - } - } - float targetMagnitude = 30f; - if (projectile.velocity.Length() > targetMagnitude) - { - projectile.velocity = Vector2.Normalize(projectile.velocity) * targetMagnitude; - } - } - else - { - float idleVelo = 0.2f; - Vector2 betweenPlayer = desiredCenter - projectile.Center; - if (betweenPlayer.Length() < 200f) - { - idleVelo = 0.12f; - } - if (betweenPlayer.Length() < 140f) - { - idleVelo = 0.06f; - } - if (betweenPlayer.Length() > 100f) - { - if (Math.Abs(desiredCenter.X - projectile.Center.X) > 20f) - { - projectile.velocity.X += idleVelo * Math.Sign(desiredCenter.X - projectile.Center.X); - } - if (Math.Abs(desiredCenter.Y - projectile.Center.Y) > 10f) - { - projectile.velocity.Y += idleVelo * Math.Sign(desiredCenter.Y - projectile.Center.Y); - } - } - else if (projectile.velocity.Length() > 2f) - { - projectile.velocity *= 0.96f; - } - if (Math.Abs(projectile.velocity.Y) < 1f) - { - projectile.velocity.Y += -0.1f; - } - float idleMagnitude = 15f; - if (projectile.velocity.Length() > idleMagnitude) - { - projectile.velocity = Vector2.Normalize(projectile.velocity) * idleMagnitude; - } - } - projectile.rotation = projectile.velocity.ToRotation() + 1.57079637f; - int direction = projectile.direction; - projectile.direction = projectile.spriteDirection = (projectile.velocity.X > 0f) ? 1 : -1; - if (projectile.minion && direction != projectile.direction) - { - projectile.netUpdate = true; - } - float scaleFactor = MathHelper.Clamp(projectile.localAI[0], 0f, 50f); - if (!projectile.minion) scaleFactor = 0; - projectile.position = projectile.Center; - projectile.scale = 1f + scaleFactor * 0.01f; - projectile.width = projectile.height = (int)(defScaleFactor * projectile.scale); - projectile.Center = projectile.position; - } - else - { - Vector2 pCenter = Vector2.Zero; - float parentRotation = 0f; - float positionOffset = 0f; - float scaleOffset = 1f; - - //some custom syncing it seems like, when summoning/replacing it - if (projectile.ai[1] == 1f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - - Projectile parent = null; - for (short i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.owner == projectile.owner && proj.identity == (int)projectile.ai[0]/* && proj.type == projectile.type*/) - { - parent = proj; - break; - } - } - if (parent != null) - { - if (parent.active && (parent.type == wormTypes[0] || parent.type == wormTypes[1] || parent.type == wormTypes[2])) - { - pCenter = parent.Center; - //Vector2 velocity2 = parent.velocity; - parentRotation = parent.rotation; - scaleOffset = MathHelper.Clamp(parent.scale, 0f, 50f); - if (!projectile.minion) scaleOffset = 1; - positionOffset = segmentDistance; - parent.localAI[0] = projectile.localAI[0] + 1f; - if (parent.type != wormTypes[0]) - { - parent.localAI[1] = projectile.whoAmI; - } - if (projectile.owner == Main.myPlayer && parent.type == wormTypes[0] && projectile.type == wormTypes[3]) - { - parent.Kill(); - projectile.Kill(); - return; - } - } - - projectile.velocity = Vector2.Zero; - Vector2 newVelocity = pCenter - projectile.Center; - if (parentRotation != projectile.rotation) - { - float rotatedBy = MathHelper.WrapAngle(parentRotation - projectile.rotation); - newVelocity = newVelocity.RotatedBy(rotatedBy * 0.1f); - } - projectile.rotation = newVelocity.ToRotation() + 1.57079637f; - projectile.position = projectile.Center; - projectile.scale = scaleOffset; - projectile.width = projectile.height = (int)(defScaleFactor * projectile.scale); - projectile.Center = projectile.position; - if (newVelocity != Vector2.Zero) - { - projectile.Center = pCenter - Vector2.Normalize(newVelocity) * positionOffset * scaleOffset; - } - projectile.spriteDirection = (newVelocity.X > 0f) ? 1 : -1; - } - } - } - - #endregion - - public static void ModifiedGoldfishAI(NPC npc, float scareRange, bool faceAway = true) - { - if (npc.direction == 0) - { - npc.TargetClosest(); - } - if (npc.wet) - { - bool hasPlayer = false; - npc.TargetClosest(faceTarget: false); - Vector2 centerpos = npc.Center; - Player player = Main.player[npc.target]; - Vector2 playerpos = player.Center; - float distancex = playerpos.X - centerpos.X; - float distancey = playerpos.Y - centerpos.Y; - float distSQ = distancex * distancex + distancey * distancey; - if (player.wet && distSQ < scareRange * scareRange) - { - if (!player.dead) - { - hasPlayer = true; - } - } - if (!hasPlayer) - { - if (npc.collideX) - { - npc.velocity.X *= -1; - npc.direction *= -1; - npc.netUpdate = true; - } - if (npc.collideY) - { - npc.netUpdate = true; - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y) * -1f; - npc.directionY = -1; - npc.ai[0] = -1f; - } - else if (npc.velocity.Y < 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y); - npc.directionY = 1; - npc.ai[0] = 1f; - } - } - } - if (hasPlayer) //if target is in water - { - npc.TargetClosest(faceTarget: false); - npc.direction = (distancex >= 0f).ToDirectionInt(); - npc.directionY = (distancey >= 0f).ToDirectionInt(); - - if (faceAway) - { - npc.direction *= -1; - npc.directionY *= -1; - } - - npc.velocity.X += npc.direction * 0.1f; - npc.velocity.Y += npc.directionY * 0.1f; - - if (npc.velocity.X > 3f) - { - npc.velocity.X = 3f; - } - if (npc.velocity.X < -3f) - { - npc.velocity.X = -3f; - } - if (npc.velocity.Y > 2f) - { - npc.velocity.Y = 2f; - } - if (npc.velocity.Y < -2f) - { - npc.velocity.Y = -2f; - } - } - else - { - npc.velocity.X += npc.direction * 0.1f; - if (npc.velocity.X < -1f || npc.velocity.X > 1f) - { - npc.velocity.X *= 0.95f; - } - if (npc.ai[0] == -1f) - { - npc.velocity.Y -= 0.01f; - if (npc.velocity.Y < -0.3f) - { - npc.ai[0] = 1f; - } - } - else - { - npc.velocity.Y += 0.01f; - if (npc.velocity.Y > 0.3f) - { - npc.ai[0] = -1f; - } - } - int tileX = (int)npc.Center.X / 16; - int tileY = (int)npc.Center.Y / 16; - if (Framing.GetTileSafely(tileX, tileY - 1).LiquidAmount > 128) - { - if (Framing.GetTileSafely(tileX, tileY + 1).HasTile) - { - npc.ai[0] = -1f; - } - else if (Framing.GetTileSafely(tileX, tileY + 2).HasTile) - { - npc.ai[0] = -1f; - } - } - if (npc.velocity.Y > 0.4f || npc.velocity.Y < -0.4f) - { - npc.velocity.Y *= 0.95f; - } - } - } - else //not wet, frantically jump around - { - if (npc.velocity.Y == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.velocity.Y = Main.rand.Next(-50, -20) * 0.1f; - npc.velocity.X = Main.rand.Next(-20, 20) * 0.1f; - npc.netUpdate = true; - } - } - npc.velocity.Y += 0.3f; - if (npc.velocity.Y > 10f) - { - npc.velocity.Y = 10f; - } - npc.ai[0] = 1f; - } - npc.rotation = npc.velocity.Y * npc.direction * 0.1f; - if (npc.rotation < -0.2f) - { - npc.rotation = -0.2f; - } - if (npc.rotation > 0.2f) - { - npc.rotation = 0.2f; - } - } - - //TODO turn into usable method later - public static void PirateAI(Projectile Projectile) - { - // //Pirate AI related: - //public int State - //{ - // get => (int)Projectile.ai[0]; - // set => Projectile.ai[0] = value; - //} - - //public int Timer - //{ - // get => (int)Projectile.ai[1]; - // set => Projectile.ai[1] = value; - //} - - //public bool Idle => State == 0; - - //public bool Flying - //{ - // get => State == 1; - // set => State = value ? 1 : 0; - //} - - //public bool Attacking - //{ - // get => State == 2; - // set => State = value ? 2 : 0; - //} - int Timer = 0; - bool Idle = true; - bool Flying = false; - bool Attacking = false; - ////End Pirate AI - - Player player = Main.player[Projectile.owner]; - - int startAttackRange = 800; - float awayFromPlayerDistMax = 500f; - float awayFromPlayerDistYMax = 300f; - - Vector2 destination = player.Center; - destination.X -= (15 + player.width / 2) * player.direction; - destination.X -= Projectile.minionPos * 25 * player.direction; - - Projectile.shouldFallThrough = player.Bottom.Y - 12f > Projectile.Bottom.Y; - Projectile.friendly = false; - int timerReset = 0; - int attackFrameCount = 3; - int nextTimerValue = 5 * attackFrameCount; - int attackTarget = -1; - - bool defaultstate = Idle; - - static bool CustomEliminationCheck_Pirates(Entity otherEntity, int currentTarget) => true; - - if (defaultstate) - Projectile.Minion_FindTargetInRange(startAttackRange, ref attackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); - - if (Flying) - { - Projectile.tileCollide = false; - float velChange = 0.2f; - float toPlayerSpeed = 10f; - int maxLen = 200; - if (toPlayerSpeed < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - toPlayerSpeed = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - - Vector2 toPlayer = player.Center - Projectile.Center; - float len = toPlayer.Length(); - - AssAI.TeleportIfTooFar(Projectile, player.Center); - - if (len < maxLen && player.velocity.Y == 0f && Projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - //Reset back from flying - Flying = false; - Projectile.netUpdate = true; - if (Projectile.velocity.Y < -6f) - Projectile.velocity.Y = -6f; - } - - if (!(len < 60f)) - { - toPlayer.Normalize(); - toPlayer *= toPlayerSpeed; - if (Projectile.velocity.X < toPlayer.X) - { - Projectile.velocity.X += velChange; - if (Projectile.velocity.X < 0f) - Projectile.velocity.X += velChange * 1.5f; - } - - if (Projectile.velocity.X > toPlayer.X) - { - Projectile.velocity.X -= velChange; - if (Projectile.velocity.X > 0f) - Projectile.velocity.X -= velChange * 1.5f; - } - - if (Projectile.velocity.Y < toPlayer.Y) - { - Projectile.velocity.Y += velChange; - if (Projectile.velocity.Y < 0f) - Projectile.velocity.Y += velChange * 1.5f; - } - - if (Projectile.velocity.Y > toPlayer.Y) - { - Projectile.velocity.Y -= velChange; - if (Projectile.velocity.Y > 0f) - Projectile.velocity.Y -= velChange * 1.5f; - } - } - - if (Projectile.velocity.X != 0f) - Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X); - } - - if (Attacking && Timer < 0) - { - Projectile.friendly = false; - Timer += 1; - if (nextTimerValue >= 0) - { - Timer = 0; - Attacking = false; - Projectile.netUpdate = true; - return; - } - } - else if (Attacking) - { - //Attacking animation - Projectile.spriteDirection = -Projectile.direction; - Projectile.rotation = 0f; - - Projectile.friendly = true; - int startAttackFrame = 12; - bool hasJumpingAttackFrames = true; - int attackFrameNumber = (int)((float)nextTimerValue - Timer) / (nextTimerValue / attackFrameCount); - Projectile.frame = startAttackFrame + attackFrameNumber; - if (hasJumpingAttackFrames && Projectile.velocity.Y != 0f) - Projectile.frame += attackFrameCount; - - Projectile.velocity.Y += 0.4f; - if (Projectile.velocity.Y > 10f) - Projectile.velocity.Y = 10f; - - Timer -= 1; - if (Timer <= 0f) - { - if (timerReset <= 0) - { - Timer = 0; - Attacking = false; - Projectile.netUpdate = true; - return; - } - - Timer = -timerReset; - } - } - - if (attackTarget >= 0) - { - float maxDistance = startAttackRange; - float toTargetMaxDist = 20f; - - NPC npc = Main.npc[attackTarget]; - Vector2 targetCenter = npc.Center; - destination = targetCenter; - if (Projectile.IsInRangeOfMeOrMyOwner(npc, maxDistance, out float _, out float _, out bool _)) - { - Projectile.shouldFallThrough = npc.Center.Y > Projectile.Bottom.Y; - - bool flag11 = Projectile.velocity.Y == 0f; - if (Projectile.wet && Projectile.velocity.Y > 0f && !Projectile.shouldFallThrough) - flag11 = true; - - if (targetCenter.Y < Projectile.Center.Y - 30f && flag11) - { - float num25 = (targetCenter.Y - Projectile.Center.Y) * -1f; - float num26 = 0.4f; - float velY = (float)Math.Sqrt(num25 * 2f * num26); - if (velY > 26f) - velY = 26f; - - Projectile.velocity.Y = -velY; - } - - if (Vector2.Distance(Projectile.Center, destination) < toTargetMaxDist) - { - float len = Projectile.velocity.Length(); - if (len > 10f) - Projectile.velocity /= len / 10f; - - Attacking = true; - Timer = nextTimerValue; - Projectile.netUpdate = true; - Projectile.direction = (targetCenter.X - Projectile.Center.X > 0f).ToDirectionInt(); - } - } - } - - if (Idle && attackTarget < 0) - { - if (player.rocketDelay2 > 0) - { - Flying = true; - Projectile.netUpdate = true; - } - - Vector2 toPlayer = player.Center - Projectile.Center; - if (toPlayer.Length() > 2000f) - { - Projectile.Center = player.Center; - } - else if (toPlayer.Length() > awayFromPlayerDistMax || Math.Abs(toPlayer.Y) > awayFromPlayerDistYMax) - { - Flying = true; - Projectile.netUpdate = true; - if (Projectile.velocity.Y > 0f && toPlayer.Y < 0f) - Projectile.velocity.Y = 0f; - - if (Projectile.velocity.Y < 0f && toPlayer.Y > 0f) - Projectile.velocity.Y = 0f; - } - } - - if (Idle) - { - if (attackTarget < 0) - { - if (Projectile.Distance(player.Center) > 60f && Projectile.Distance(destination) > 60f && Math.Sign(destination.X - player.Center.X) != Math.Sign(Projectile.Center.X - player.Center.X)) - destination = player.Center; - - Rectangle rect = Utils.CenteredRectangle(destination, Projectile.Size); - for (int i = 0; i < 20; i++) - { - if (Collision.SolidCollision(rect.TopLeft(), rect.Width, rect.Height)) - break; - - rect.Y += 16; - destination.Y += 16f; - } - - Vector2 position = player.Center - Projectile.Size / 2f; - Vector2 postCollision = Collision.TileCollision(position, destination - player.Center, Projectile.width, Projectile.height); - destination = position + postCollision; - if (Projectile.Distance(destination) < 32f) - { - float distPlayerToDestination = player.Distance(destination); - if (player.Distance(Projectile.Center) < distPlayerToDestination) - destination = Projectile.Center; - } - - Vector2 fromDestToPlayer = player.Center - destination; - if (fromDestToPlayer.Length() > awayFromPlayerDistMax || Math.Abs(fromDestToPlayer.Y) > awayFromPlayerDistYMax) - { - Rectangle rect2 = Utils.CenteredRectangle(player.Center, Projectile.Size); - Vector2 fromPlayerToDest = destination - player.Center; - Vector2 topLeft = rect2.TopLeft(); - for (float i = 0f; i < 1f; i += 0.05f) - { - Vector2 newTopLeft = rect2.TopLeft() + fromPlayerToDest * i; - if (Collision.SolidCollision(rect2.TopLeft() + fromPlayerToDest * i, rect2.Width, rect2.Height)) - break; - - topLeft = newTopLeft; - } - - destination = topLeft + Projectile.Size / 2f; - } - } - - Projectile.tileCollide = true; - float velXChange = 0.5f; //0.5f - float velXChangeMargin = 4f; //4f - float velXChangeMax = 4f; //4f - float velXChangeSmall = 0.1f; - - if (attackTarget != -1) - { - velXChange = 0.4f; //1f - velXChangeMargin = 5f; //8f - velXChangeMax = 5f; //8f - } - - if (velXChangeMax < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - { - velXChangeMax = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - velXChange = 0.7f; - } - - int xOff = 0; - bool canJumpOverTiles = false; - float toDestinationX = destination.X - Projectile.Center.X; - Vector2 toDestination = destination - Projectile.Center; - if (Math.Abs(toDestinationX) > 5f) - { - if (toDestinationX < 0f) - { - xOff = -1; - if (Projectile.velocity.X > -velXChangeMargin) - Projectile.velocity.X -= velXChange; - else - Projectile.velocity.X -= velXChangeSmall; - } - else - { - xOff = 1; - if (Projectile.velocity.X < velXChangeMargin) - Projectile.velocity.X += velXChange; - else - Projectile.velocity.X += velXChangeSmall; - } - } - else - { - Projectile.velocity.X *= 0.9f; - if (Math.Abs(Projectile.velocity.X) < velXChange * 2f) - Projectile.velocity.X = 0f; - } - - bool tryJumping = Math.Abs(toDestination.X) >= 64f || (toDestination.Y <= -48f && Math.Abs(toDestination.X) >= 8f); - if (xOff != 0 && tryJumping) - { - int x = (int)Projectile.Center.X / 16; - int y = (int)Projectile.position.Y / 16; - x += xOff; - x += (int)Projectile.velocity.X; - for (int j = y; j < y + Projectile.height / 16 + 1; j++) - { - if (WorldGen.SolidTile(x, j)) - canJumpOverTiles = true; - } - } - - Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); - float nextVelocityY = Utils.GetLerpValue(0f, 100f, toDestination.Y, clamped: true) * Utils.GetLerpValue(-2f, -6f, Projectile.velocity.Y, clamped: true); - if (Projectile.velocity.Y == 0f && canJumpOverTiles) - { - for (int k = 0; k < 3; k++) - { - int num42 = (int)(Projectile.Center.X) / 16; - if (k == 0) - num42 = (int)Projectile.position.X / 16; - - if (k == 2) - num42 = (int)(Projectile.Right.X) / 16; - - int num43 = (int)(Projectile.Bottom.Y) / 16; - if (!WorldGen.SolidTile(num42, num43) && !Main.tile[num42, num43].IsHalfBlock && Main.tile[num42, num43].Slope <= 0 && (!TileID.Sets.Platforms[Main.tile[num42, num43].TileType] || !Main.tile[num42, num43].HasTile || Main.tile[num42, num43].IsActuated)) - continue; - - try - { - num42 = (int)(Projectile.Center.X) / 16; - num43 = (int)(Projectile.Center.Y) / 16; - num42 += xOff; - num42 += (int)Projectile.velocity.X; - if (!WorldGen.SolidTile(num42, num43 - 1) && !WorldGen.SolidTile(num42, num43 - 2)) - Projectile.velocity.Y = -5.1f; - else if (!WorldGen.SolidTile(num42, num43 - 2)) - Projectile.velocity.Y = -7.1f; - else if (WorldGen.SolidTile(num42, num43 - 5)) - Projectile.velocity.Y = -11.1f; - else if (WorldGen.SolidTile(num42, num43 - 4)) - Projectile.velocity.Y = -10.1f; - else - Projectile.velocity.Y = -9.1f; - } - catch - { - Projectile.velocity.Y = -9.1f; - } - } - - if (destination.Y - Projectile.Center.Y < -48f) - { - float height = destination.Y - Projectile.Center.Y; - height *= -1f; - if (height < 60f) - Projectile.velocity.Y = -6f; - else if (height < 80f) - Projectile.velocity.Y = -7f; - else if (height < 100f) - Projectile.velocity.Y = -8f; - else if (height < 120f) - Projectile.velocity.Y = -9f; - else if (height < 140f) - Projectile.velocity.Y = -10f; - else if (height < 160f) - Projectile.velocity.Y = -11f; - else if (height < 190f) - Projectile.velocity.Y = -12f; - else if (height < 210f) - Projectile.velocity.Y = -13f; - else if (height < 270f) - Projectile.velocity.Y = -14f; - else if (height < 310f) - Projectile.velocity.Y = -15f; - else - Projectile.velocity.Y = -16f; - } - - if (Projectile.wet && nextVelocityY == 0f) - Projectile.velocity.Y *= 2f; - } - - if (Projectile.velocity.X > velXChangeMax) - Projectile.velocity.X = velXChangeMax; - - if (Projectile.velocity.X < -velXChangeMax) - Projectile.velocity.X = -velXChangeMax; - - if (Projectile.velocity.X < 0f) - Projectile.direction = -1; - - if (Projectile.velocity.X > 0f) - Projectile.direction = 1; - - if (Projectile.velocity.X == 0f) - Projectile.direction = (player.Center.X > Projectile.Center.X).ToDirectionInt(); - - if (Projectile.velocity.X > velXChange && xOff == 1) - Projectile.direction = 1; - - if (Projectile.velocity.X < -velXChange && xOff == -1) - Projectile.direction = -1; - - Projectile.spriteDirection = -Projectile.direction; - - Projectile.velocity.Y += 0.4f + nextVelocityY * 1f; - if (Projectile.velocity.Y > 10f) - { - Projectile.velocity.Y = 10f; - } - } - - #region default animations - /* + /// + /// contains AI for stuff that only uses ai[], used with thing.aiStyle = -1 + /// + public static class AssAI + { + /// + /// Makes the projectile teleport if it is too far away from the given location + /// + public static bool TeleportIfTooFar(Projectile projectile, Vector2 desiredCenter, int distance = 2000) + { + if (projectile.DistanceSQ(desiredCenter) > distance * distance) + { + projectile.Center = desiredCenter; + if (Main.myPlayer == projectile.owner) projectile.netUpdate = true; + return true; + } + return false; + } + + /// + /// Finds target in range of relativeCenter. Returns index of target + /// + public static int FindTarget(Entity ent, Vector2 relativeCenter, float range, bool ignoreTiles = false) + { + int targetIndex = -1; + float distanceFromTarget = 10000000f; + Vector2 targetCenter = relativeCenter; + range *= range; + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + if (npc.CanBeChasedBy()) + { + //Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height) + float between = Vector2.DistanceSquared(npc.Center, relativeCenter); + if ((between < range && Vector2.DistanceSquared(relativeCenter, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1) + { + if (ignoreTiles || Collision.CanHitLine(ent.position, ent.width, ent.height, npc.position, npc.width, npc.height)) + { + distanceFromTarget = between; + targetCenter = npc.Center; + targetIndex = k; + } + } + } + } + return distanceFromTarget < range ? targetIndex : -1; + } + + /// + /// Utility for minion AI that handles a custom stuck timer for when the X coordinate doesn't change for a given duration. + /// + /// The projectile + /// The X coordinate of the idle location (to not increment the timer when near that) + /// The timer + /// The maximum duration + /// Returns true if the timer overflows + public static bool HandleStuck(this Projectile projectile, float restingX, ref int stuckTimer, int stuckTimerMax) + { + if (projectile.position.X == projectile.oldPosition.X && Math.Abs(projectile.Center.X - restingX) >= 50) + { + stuckTimer++; + + if (stuckTimer >= stuckTimerMax) + { + stuckTimer = 0; + return true; + } + } + else + { + if (stuckTimer >= 2) + { + stuckTimer -= 2; + } + } + + return false; + } + + #region Flickerwick + public static void FlickerwickPetDraw(Projectile projectile, int frameCounterMaxFar, int frameCounterMaxClose) + { + projectile.LoopAnimation((projectile.velocity.Length() > 6f) ? frameCounterMaxFar : frameCounterMaxClose); + } + + /// + /// No use of ai[] or LocalAI[]. + /// Default offset is x = 30, y = -20 + /// + public static void FlickerwickPetAI(Projectile projectile, bool lightPet = true, bool lightDust = true, bool staticDirection = false, bool reverseSide = false, bool vanityPet = false, float veloXToRotationFactor = 1f, float veloSpeed = 1f, float lightFactor = 1f, Vector3 lightColor = default(Vector3), float offsetX = 0f, float offsetY = 0f) + { + //veloSpeed not bigger than veloDistanceChange * 0.5f + Player player = projectile.GetOwner(); + float veloDistanceChange = 2f; //6f + + int dir = player.direction; + if (staticDirection) + { + if (reverseSide) + { + dir = -1; + } + else + { + dir = 1; + } + } + else + { + if (reverseSide) + { + dir = -dir; + } + } + + //up and down bobbing + //projectile.localAI[0] += 1f; + //if (projectile.localAI[0] > 120f) + //{ + // projectile.localAI[0] = 0f; + //} + //value.Y += (float)Math.Cos((double)(projectile.localAI[0] * 0.05235988f)) * 2f; + + Vector2 dustOffset = new Vector2((projectile.spriteDirection == -1) ? -6 : -2, -20f).RotatedBy(projectile.rotation); + + Vector2 desiredCenterRelative = new Vector2(dir * (offsetX + 30), -20f + offsetY); + + projectile.direction = projectile.spriteDirection = dir; + + //if (reverseSide) + //{ + // desiredCenterRelative.X = -desiredCenterRelative.X; + // //value2.X = -value2.X; + // projectile.direction = -projectile.direction; + // projectile.spriteDirection = -projectile.spriteDirection; + //} + + if (lightDust && Main.rand.Next(24) == 0) + { + Dust dust = Dust.NewDustDirect(projectile.Center + dustOffset, 4, 4, 135, 0f, 0f, 100); + if (Main.rand.Next(3) != 0) + { + dust.noGravity = true; + dust.velocity.Y += -3f; + dust.noLight = true; + } + else if (Main.rand.Next(2) != 0) + { + dust.noLight = true; + } + dust.velocity *= 0.5f; + dust.velocity.Y += -0.9f; + dust.scale += 0.1f + Main.rand.NextFloat() * 0.6f; + dust.shader = GameShaders.Armor.GetSecondaryShader(Main.GetProjectileDesiredShader(projectile.whoAmI), player); + } + + if (lightPet) + { + if (lightColor == default(Vector3)) lightColor = new Vector3(0.3f, 0.5f, 1f); + //flickerwick is new Vector3(0.3f, 0.5f, 1f) + Vector3 vector = DelegateMethods.v3_1 = lightColor * lightFactor; + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * 6f, 20f, DelegateMethods.CastLightOpen); + Utils.PlotTileLine(projectile.Left, projectile.Right, 20f, DelegateMethods.CastLightOpen); + Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 40f, DelegateMethods.CastLightOpen); + Utils.PlotTileLine(player.Left, player.Right, 40f, DelegateMethods.CastLightOpen); + } + + Vector2 desiredCenter = player.MountedCenter + desiredCenterRelative; + Vector2 betweenDirection = desiredCenter - projectile.Center; + float betweenSQ = betweenDirection.LengthSquared(); + //if (between > 1000f) + //{ + // projectile.Center = player.Center + desiredCenterRelative; + //} + TeleportIfTooFar(projectile, desiredCenter, 1000); + if (betweenSQ < veloDistanceChange * veloDistanceChange) + { + projectile.velocity *= 0.25f; + } + if (betweenDirection != Vector2.Zero) + { + if (betweenSQ < (veloDistanceChange * 0.5f) * (veloDistanceChange * 0.5f)) + { + projectile.velocity = betweenDirection * veloSpeed; + } + else + { + projectile.velocity = betweenDirection * 0.1f * veloSpeed; + } + } + if (projectile.velocity.LengthSquared() > 6f * 6f) + { + float rotationVelo = projectile.velocity.X * 0.08f * veloXToRotationFactor + projectile.velocity.Y * projectile.spriteDirection * 0.02f; + if (Math.Abs(projectile.rotation - rotationVelo) >= 3.14159274f) + { + if (rotationVelo < projectile.rotation) + { + projectile.rotation -= 6.28318548f; + } + else + { + projectile.rotation += 6.28318548f; + } + } + float rotationAcc = 12f; + projectile.rotation = (projectile.rotation * (rotationAcc - 1f) + rotationVelo) / rotationAcc; + } + else + { + if (projectile.rotation > 3.14159274f) + { + projectile.rotation -= 6.28318548f; + } + if (projectile.rotation > -0.005f && projectile.rotation < 0.005f) + { + projectile.rotation = 0f; + } + else + { + projectile.rotation *= 0.96f; + } + } + } + #endregion + + #region EyeSpring + + /// + /// Almost proper working Eye Spring clone + /// + public static void EyeSpringAI(Projectile projectile, bool flyForever = false) + { + Player player = projectile.GetOwner(); + if (!player.active) + { + projectile.active = false; + } + else + { + bool flag = false; + bool flag2 = false; + bool flag3 = false; + bool flag4 = false; + int num = 85; + if (player.position.X + (float)(player.width / 2) < projectile.position.X + (float)(projectile.width / 2) - (float)num) + { + flag = true; + } + else if (player.position.X + (float)(player.width / 2) > projectile.position.X + (float)(projectile.width / 2) + (float)num) + { + flag2 = true; + } + if (projectile.ai[1] == 0f) + { + int num38 = 500; + if (player.rocketDelay2 > 0) + { + projectile.ai[0] = 1f; + } + Vector2 vector6 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + float num39 = player.position.X + (float)(player.width / 2) - vector6.X; + float num40 = player.position.Y + (float)(player.height / 2) - vector6.Y; + float num41 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); + if (num41 > 2000f) + { + TeleportIfTooFar(projectile, player.Center); + //projectile.position.X = player.position.X + (float)(player.width / 2) - (float)(projectile.width / 2); + //projectile.position.Y = player.position.Y + (float)(player.height / 2) - (float)(projectile.height / 2); + } + else if (num41 > (float)num38 || (Math.Abs(num40) > 300f) || flyForever) + { + projectile.ai[0] = 1f; + } + } + if (projectile.ai[0] != 0f) + { + float num42 = 0.2f; + int num43 = 200; + projectile.tileCollide = false; + Vector2 vector7 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + float num44 = player.position.X + (float)(player.width / 2) - vector7.X; + float num51 = player.position.Y + (float)(player.height / 2) - vector7.Y; + float num52 = (float)Math.Sqrt((double)(num44 * num44 + num51 * num51)); + float num53 = 10f; + //float num54 = num52; + if (num52 < (float)num43 && player.velocity.Y == 0f && projectile.position.Y + (float)projectile.height <= player.position.Y + (float)player.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } + if (num52 < 60f) + { + num44 = projectile.velocity.X; + num51 = projectile.velocity.Y; + } + else + { + num52 = num53 / num52; + num44 *= num52; + num51 *= num52; + } + if (projectile.velocity.X < num44) + { + projectile.velocity.X += num42; + if (projectile.velocity.X < 0f) + { + projectile.velocity.X += num42 * 1.5f; + } + } + if (projectile.velocity.X > num44) + { + projectile.velocity.X -= num42; + if (projectile.velocity.X > 0f) + { + projectile.velocity.X -= num42 * 1.5f; + } + } + if (projectile.velocity.Y < num51) + { + projectile.velocity.Y += num42; + if (projectile.velocity.Y < 0f) + { + projectile.velocity.Y += num42 * 1.5f; + } + } + if (projectile.velocity.Y > num51) + { + projectile.velocity.Y -= num42; + if (projectile.velocity.Y > 0f) + { + projectile.velocity.Y -= num42 * 1.5f; + } + } + if ((double)projectile.velocity.X > 0.5) + { + projectile.spriteDirection = -1; + } + else if ((double)projectile.velocity.X < -0.5) + { + projectile.spriteDirection = 1; + } + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame < 6 || projectile.frame > 7) + { + projectile.frame = 6; + } + projectile.rotation = projectile.velocity.ToRotation() + 1.57f; + } + else + { + //Vector2 vector9 = Vector2.Zero; + if (projectile.ai[1] != 0f) + { + flag = false; + flag2 = false; + } + projectile.rotation = 0f; + projectile.tileCollide = true; + float num111 = 8f; + float num110 = 0.4f; + if (flag) + { + if (projectile.velocity.X > -3.5f) + { + projectile.velocity.X -= num110; + } + else + { + projectile.velocity.X -= num110 * 0.25f; + } + } + else if (flag2) + { + if (projectile.velocity.X < 3.5f) + { + projectile.velocity.X += num110; + } + else + { + projectile.velocity.X += num110 * 0.25f; + } + } + else + { + projectile.velocity.X *= 0.9f; + if (projectile.velocity.X >= 0f - num110 && projectile.velocity.X <= num110) + { + projectile.velocity.X = 0f; + } + } + if (flag | flag2) + { + int num112 = (int)(projectile.position.X + (float)(projectile.width / 2)) / 16; + int j = (int)(projectile.position.Y + (float)(projectile.height / 2)) / 16; + if (flag) + { + int num30 = num112; + num112 = num30 - 1; + } + if (flag2) + { + int num30 = num112; + num112 = num30 + 1; + } + num112 += (int)projectile.velocity.X; + if (WorldGen.SolidTile(num112, j)) + { + flag4 = true; + } + } + if (player.position.Y + player.height - 8f > projectile.position.Y + projectile.height) + { + flag3 = true; + } + if (projectile.frameCounter < 10) + { + flag4 = false; + } + //projectile.stepSpeed = 1f; + //projectile.gfxOffY = 0f; + //Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref stepSpeed, ref gfxOffY); + Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref projectile.stepSpeed, ref projectile.gfxOffY); + if (projectile.velocity.Y == 0f) + { + if (!flag3 && (projectile.velocity.X < 0f || projectile.velocity.X > 0f)) + { + int num113 = (int)(projectile.position.X + (projectile.width / 2)) / 16; + int j2 = (int)(projectile.position.Y + (projectile.height / 2)) / 16 + 1; + if (flag) + { + int num30 = num113; + num113 = num30 - 1; + } + if (flag2) + { + int num30 = num113; + num113 = num30 + 1; + } + WorldGen.SolidTile(num113, j2); + } + if (flag4) + { + int num114 = (int)(projectile.position.X + projectile.width / 2) / 16; + int num115 = (int)(projectile.position.Y + projectile.height) / 16 + 1; + if (WorldGen.SolidTile(num114, num115) || Main.tile[num114, num115].IsHalfBlock || Main.tile[num114, num115].Slope > 0) + { + try + { + num114 = (int)(projectile.position.X + projectile.width / 2) / 16; + num115 = (int)(projectile.position.Y + projectile.height / 2) / 16; + if (flag) + { + int num30 = num114; + num114 = num30 - 1; + } + if (flag2) + { + int num30 = num114; + num114 = num30 + 1; + } + num114 += (int)projectile.velocity.X; + if (!WorldGen.SolidTile(num114, num115 - 1) && !WorldGen.SolidTile(num114, num115 - 2)) + { + projectile.velocity.Y = -5.1f; + } + else if (!WorldGen.SolidTile(num114, num115 - 2)) + { + projectile.velocity.Y = -7.1f; + } + else if (WorldGen.SolidTile(num114, num115 - 5)) + { + projectile.velocity.Y = -11.1f; + } + else if (WorldGen.SolidTile(num114, num115 - 4)) + { + projectile.velocity.Y = -10.1f; + } + else + { + projectile.velocity.Y = -9.1f; + } + } + catch + { + projectile.velocity.Y = -9.1f; + } + } + } + } + if (projectile.velocity.X > num111) + { + projectile.velocity.X = num111; + } + if (projectile.velocity.X < 0f - num111) + { + projectile.velocity.X = 0f - num111; + } + if (projectile.velocity.X < 0f) + { + projectile.direction = -1; + } + if (projectile.velocity.X > 0f) + { + projectile.direction = 1; + } + if (projectile.velocity.X > num110 && flag2) + { + projectile.direction = 1; + } + if (projectile.velocity.X < 0f - num110 && flag) + { + projectile.direction = -1; + } + + + //fix cause im dumb and didnt copy ai code correctly + if (!flag && !flag2 && projectile.ai[0] == 0f) + { + projectile.direction = (player.Center - projectile.Center).X > 0 ? 1 : -1; + } + + + if (projectile.direction == -1) + { + projectile.spriteDirection = 1; + } + if (projectile.direction == 1) + { + projectile.spriteDirection = -1; + } + + if (projectile.velocity.Y == 0f) + { + if (projectile.frame > 5) + { + projectile.frameCounter = 0; + } + if (projectile.velocity.X == 0f) + { + int num116 = 3; + projectile.frameCounter++; + if (projectile.frameCounter < num116) + { + projectile.frame = 0; + } + else if (projectile.frameCounter < num116 * 2) + { + projectile.frame = 1; + } + else if (projectile.frameCounter < num116 * 3) + { + projectile.frame = 2; + } + else if (projectile.frameCounter < num116 * 4) + { + projectile.frame = 3; + } + else + { + projectile.frameCounter = num116 * 4; + } + } + else + { + projectile.velocity.X *= 0.8f; + projectile.frameCounter++; + int num117 = 3; + if (projectile.frameCounter < num117) + { + projectile.frame = 0; + } + else if (projectile.frameCounter < num117 * 2) + { + projectile.frame = 1; + } + else if (projectile.frameCounter < num117 * 3) + { + projectile.frame = 2; + } + else if (projectile.frameCounter < num117 * 4) + { + projectile.frame = 3; + } + else if (flag | flag2) + { + projectile.velocity.X *= 2f; + projectile.frame = 4; + projectile.velocity.Y = -6.1f; + projectile.frameCounter = 0; + int num30; + for (int num118 = 0; num118 < 4; num118 = num30 + 1) + { + /*int num119 = 0; Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + (float)projectile.height - 2f), projectile.width, 4, 5)*/ + ; + //Dust dust = Main.dust[num119]; + //dust.velocity += projectile.velocity; + //dust = Main.dust[num119]; + //dust.velocity *= 0.4f; + num30 = num118; + } + } + else + { + projectile.frameCounter = num117 * 4; + } + } + } + else if (projectile.velocity.Y < 0f) + { + projectile.frameCounter = 0; + projectile.frame = 5; + } + else + { + projectile.frame = 4; + projectile.frameCounter = 3; + } + projectile.velocity.Y += 0.4f; + if (projectile.velocity.Y > 10f) + { + projectile.velocity.Y = 10f; + } + } + } + } + #endregion + + #region Zephyrfish + public static void ZephyrfishDraw(Projectile projectile, int frameCounter = 5) + { + projectile.frameCounter++; + if (projectile.frameCounter > frameCounter) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) //3 + { + projectile.frame = 0; + } + } + + /// + /// Stays around a certain offset position around the parent. Does not use ai/localai + /// + public static void ZephyrfishAI(Projectile projectile, Entity parent = null, float velocityFactor = 1f, float sway = 1f, bool random = true, byte swapSides = 0, float offsetX = 0f, float offsetY = 0f) + { + //velocityFactor: + //kinda wonky, leave at 1f + + //sway: + //tells by how much increase/decrease the left/right sway of the idle pet + + //swapSides: + // 0: always behind + //-1: always left + // 1: always right + + //offsetX/Y + //offsetting the desired center the pet hovers around + + if (parent == null) parent = projectile.GetOwner(); + + Vector2 parentCenter = parent.Center; + if (parent is Player) + { + parentCenter = ((Player)parent).MountedCenter; + } + + float veloDelta = 0.3f; + projectile.tileCollide = false; //false + int someDistance = 100; + Vector2 between = parentCenter - projectile.Center; + + Vector2 desiredCenter = random ? new Vector2(Main.rand.Next(-10, 21), Main.rand.Next(-10, 21)) : Vector2.Zero; + + Vector2 offset = new Vector2(60f + offsetX, -60f + offsetY); + + if (swapSides == 1) + { + offset.X = -offset.X; + } + else if (swapSides == 0) + { + offset.X *= -parent.direction; + } + + //desiredCenter += new Vector2(60f * -player.direction, -60f); + between += desiredCenter + offset; + + TeleportIfTooFar(projectile, parentCenter + desiredCenter + offset); + + float distance = between.Length(); + //float magnitude = 6f; + if (distance < someDistance && parent.velocity.Y == 0f && projectile.position.Y + projectile.height <= parent.position.Y + parent.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + //projectile.ai[0] = 0; + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } + float swayDistance = 50 * sway; + if (distance < swayDistance) //50 + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.99f; + } + veloDelta = 0.01f; + } + else + { + if (distance < swayDistance * 2) //100 + { + veloDelta = 0.1f; + } + //between: 0.3f + if (distance > swayDistance * 6) //300 + { + veloDelta = 0.4f; + } + between.Normalize(); + between *= 6f; + between *= velocityFactor; + } + veloDelta *= velocityFactor; + if (projectile.velocity.X < between.X) + { + projectile.velocity.X += veloDelta; + if (veloDelta > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X += +veloDelta; + } + } + if (projectile.velocity.X > between.X) + { + projectile.velocity.X += -veloDelta; + if (veloDelta > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X += -veloDelta; + } + } + if (projectile.velocity.Y < between.Y) + { + projectile.velocity.Y += veloDelta; + if (veloDelta > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y += veloDelta * 2f; + } + } + if (projectile.velocity.Y > between.Y) + { + projectile.velocity.Y += -veloDelta; + if (veloDelta > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y += -veloDelta * 2f; + } + } + projectile.manualDirectionChange = true; + if (projectile.velocity.X > 0.25f && projectile.direction == 1) + { + projectile.direction = -1; + } + else if (projectile.velocity.X < -0.25f && projectile.direction != 1) + { + projectile.direction = 1; + } + projectile.spriteDirection = projectile.direction; + + //fix, direction gets set automatically by "manualDirectionChange = false" projectiled on velocity.X + //if (projectile.velocity.X > 0.25f) + //{ + // projectile.ai[0] = -1; + //} + //else if (projectile.velocity.X < -0.25f) + //{ + // projectile.ai[0] = 1; + //} + //projectile.direction = (int)projectile.ai[0]; + //projectile.spriteDirection = projectile.direction; + projectile.rotation = projectile.velocity.X * 0.05f; + } + #endregion + + #region BabyEater + public static void BabyEaterDraw(Projectile projectile, int frameCounter = 6) + { + projectile.frameCounter++; + if (projectile.frameCounter > frameCounter) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) //2 + { + projectile.frame = 0; + } + } + + public static void BabyEaterAI(Projectile projectile, Entity parent = null, Vector2 originOffset = default(Vector2), float velocityFactor = 1f, float sway = 1f) + { + //velocityFactor: + //kinda wonky, leave at 1f + + //sway: + //tells by how much increase/decrease the left/right sway radius of the idle pet + + if (parent == null) parent = projectile.GetOwner(); + + if (!parent.active) + { + projectile.active = false; + return; + } + + Vector2 parentCenter = parent.Center; + if (parent is Player) + { + parentCenter = ((Player)parent).MountedCenter; + } + parentCenter += originOffset; + + float veloDelta = 0.1f; + projectile.tileCollide = false; + int someDistance = 300; + Vector2 between = parentCenter - projectile.Center; + float distance = between.Length(); + float magnitude = 7f; + + TeleportIfTooFar(projectile, parentCenter, 1380); + + if (distance < someDistance && parent.velocity.Y == 0f && projectile.position.Y + projectile.height <= parent.position.Y + parent.height + originOffset.Y && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } + float swayDistance = 150f * sway; + if (distance < swayDistance) + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.99f; + } + veloDelta = 0.01f; + if (between.X < -2f) + { + between.X = -2f; + } + if (between.X > 2f) + { + between.X = 2f; + } + if (between.Y < -2f) + { + between.Y = -2f; + } + if (between.Y > 2f) + { + between.Y = 2f; + } + } + else + { + if (distance > swayDistance * 2f) + { + veloDelta = 0.2f; + } + between.Normalize(); + between *= magnitude; + } + + veloDelta *= velocityFactor; + + if (Math.Abs(between.X) > Math.Abs(between.Y)) + { + if (projectile.velocity.X < between.X) + { + projectile.velocity.X += veloDelta; + if (veloDelta > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X += veloDelta; + } + } + if (projectile.velocity.X > between.X) + { + projectile.velocity.X += -veloDelta; + if (veloDelta > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X += -veloDelta; + } + } + } + if (Math.Abs(between.X) <= Math.Abs(between.Y) || veloDelta == 0.05f) + { + if (projectile.velocity.Y < between.Y) + { + projectile.velocity.Y += veloDelta; + if (veloDelta > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y += veloDelta; + } + } + if (projectile.velocity.Y > between.Y) + { + projectile.velocity.Y += -veloDelta; + if (veloDelta > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y += -veloDelta; + } + } + } + projectile.rotation = projectile.velocity.ToRotation() - 1.57f; + } + #endregion + + #region StardustDragon + + + //ProjectileID.Sets. + //NeedsUUID = true; + //DontAttachHideToAlpha =true; + + //if minion = true: + //ProjectileID.Sets.MinionSacrificable[projectile.type] = false, cause the replacing code for worm minions is complicated + //damage set in NewProjectile/item + //scales in size with the amount of segments + public static void StardustDragonSetDefaults(Projectile projectile, int size = 24, bool minion = true, WormType wormType = WormType.None) + { + if (minion) + { + //if (projectile.type == 625 || projectile.type == 628) + //{ + // projectile.netImportant = true; + //} + if (wormType == WormType.Body1 || wormType == WormType.Body2) + { + projectile.minionSlots = 0.5f; + } + projectile.DamageType = DamageClass.Summon; + projectile.minion = true; + //projectile.hide = true; + projectile.netImportant = true; + } + projectile.Size = new Vector2(size); + projectile.penetrate = -1; + projectile.timeLeft *= 5; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.alpha = 255; + } + //wormTypes = new int[] {head, body1, body2, tail} //projectiletype + + //if minion = true: + //float scaleFactor = MathHelper.Clamp(projectile.localAI[0], 0f, 50f); + //projectile.scale = 1f + scaleFactor * 0.01f; + public static void StardustDragonAI(Projectile projectile, int[] wormTypes, int segmentDistance = 16) + { + Player player = projectile.GetOwner(); + + if (projectile.minion && (int)Main.time % 120 == 0) + { + projectile.netUpdate = true; + } + if (!player.active) + { + projectile.active = false; + return; + } + bool head = projectile.type == wormTypes[0]; + int defScaleFactor = 30; + //if (Main.rand.Next(30) == 0) + //{ + // int num1049 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 0, default(Color), 2f); + // Main.dust[num1049].noGravity = true; + // Main.dust[num1049].fadeIn = 2f; + // Point point4 = Main.dust[num1049].position.ToTileCoordinates(); + // if (WorldGen.InWorld(point4.X, point4.Y, 5) && WorldGen.SolidTile(point4.X, point4.Y)) + // { + // Main.dust[num1049].noLight = true; + // } + //} + + if (projectile.alpha > 0) + { + //for (int i = 0; i < 2; i++) + //{ + // int dust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 135, 0f, 0f, 100, default(Color), 2f); + // Main.dust[dust].noGravity = true; + // Main.dust[dust].noLight = true; + //} + projectile.alpha -= 42; + if (projectile.alpha < 0) + { + projectile.alpha = 0; + return; + } + } + + if (head) + { + Vector2 desiredCenter = player.Center; + int targetIndex = -1; + TeleportIfTooFar(projectile, desiredCenter); + if (projectile.minion) + { + float maxProjDistance = 490000f; + float maxPlayerDistance = 1000000f; + NPC ownerMinionAttackTargetNPC5 = projectile.OwnerMinionAttackTargetNPC; + if (ownerMinionAttackTargetNPC5 != null && ownerMinionAttackTargetNPC5.CanBeChasedBy()) + { + float distance1 = projectile.DistanceSQ(ownerMinionAttackTargetNPC5.Center); + if (distance1 < maxProjDistance * 2f) + { + targetIndex = ownerMinionAttackTargetNPC5.whoAmI; + } + } + if (targetIndex < 0) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy() && player.DistanceSQ(npc.Center) < maxPlayerDistance) + { + float distance2 = projectile.DistanceSQ(npc.Center); + if (distance2 < maxProjDistance) + { + targetIndex = i; + } + } + } + } + } + if (targetIndex != -1) + { + NPC npc = Main.npc[targetIndex]; + Vector2 betweenNPC = npc.Center - projectile.Center; + float veloFactor = 0.4f; + if (betweenNPC.Length() < 600f) + { + veloFactor = 0.6f; + } + if (betweenNPC.Length() < 300f) + { + veloFactor = 0.8f; + } + if (betweenNPC.Length() > npc.Size.Length() * 0.75f) + { + projectile.velocity += Vector2.Normalize(betweenNPC) * veloFactor * 1.5f; + if (Vector2.Dot(projectile.velocity, betweenNPC) < 0.25f) + { + projectile.velocity *= 0.8f; + } + } + float targetMagnitude = 30f; + if (projectile.velocity.Length() > targetMagnitude) + { + projectile.velocity = Vector2.Normalize(projectile.velocity) * targetMagnitude; + } + } + else + { + float idleVelo = 0.2f; + Vector2 betweenPlayer = desiredCenter - projectile.Center; + if (betweenPlayer.Length() < 200f) + { + idleVelo = 0.12f; + } + if (betweenPlayer.Length() < 140f) + { + idleVelo = 0.06f; + } + if (betweenPlayer.Length() > 100f) + { + if (Math.Abs(desiredCenter.X - projectile.Center.X) > 20f) + { + projectile.velocity.X += idleVelo * Math.Sign(desiredCenter.X - projectile.Center.X); + } + if (Math.Abs(desiredCenter.Y - projectile.Center.Y) > 10f) + { + projectile.velocity.Y += idleVelo * Math.Sign(desiredCenter.Y - projectile.Center.Y); + } + } + else if (projectile.velocity.Length() > 2f) + { + projectile.velocity *= 0.96f; + } + if (Math.Abs(projectile.velocity.Y) < 1f) + { + projectile.velocity.Y += -0.1f; + } + float idleMagnitude = 15f; + if (projectile.velocity.Length() > idleMagnitude) + { + projectile.velocity = Vector2.Normalize(projectile.velocity) * idleMagnitude; + } + } + projectile.rotation = projectile.velocity.ToRotation() + 1.57079637f; + int direction = projectile.direction; + projectile.direction = projectile.spriteDirection = (projectile.velocity.X > 0f) ? 1 : -1; + if (projectile.minion && direction != projectile.direction) + { + projectile.netUpdate = true; + } + float scaleFactor = MathHelper.Clamp(projectile.localAI[0], 0f, 50f); + if (!projectile.minion) scaleFactor = 0; + projectile.position = projectile.Center; + projectile.scale = 1f + scaleFactor * 0.01f; + projectile.width = projectile.height = (int)(defScaleFactor * projectile.scale); + projectile.Center = projectile.position; + } + else + { + Vector2 pCenter = Vector2.Zero; + float parentRotation = 0f; + float positionOffset = 0f; + float scaleOffset = 1f; + + //some custom syncing it seems like, when summoning/replacing it + if (projectile.ai[1] == 1f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + + Projectile parent = null; + for (short i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.owner == projectile.owner && proj.identity == (int)projectile.ai[0]/* && proj.type == projectile.type*/) + { + parent = proj; + break; + } + } + if (parent != null) + { + if (parent.active && (parent.type == wormTypes[0] || parent.type == wormTypes[1] || parent.type == wormTypes[2])) + { + pCenter = parent.Center; + //Vector2 velocity2 = parent.velocity; + parentRotation = parent.rotation; + scaleOffset = MathHelper.Clamp(parent.scale, 0f, 50f); + if (!projectile.minion) scaleOffset = 1; + positionOffset = segmentDistance; + parent.localAI[0] = projectile.localAI[0] + 1f; + if (parent.type != wormTypes[0]) + { + parent.localAI[1] = projectile.whoAmI; + } + if (projectile.owner == Main.myPlayer && parent.type == wormTypes[0] && projectile.type == wormTypes[3]) + { + parent.Kill(); + projectile.Kill(); + return; + } + } + + projectile.velocity = Vector2.Zero; + Vector2 newVelocity = pCenter - projectile.Center; + if (parentRotation != projectile.rotation) + { + float rotatedBy = MathHelper.WrapAngle(parentRotation - projectile.rotation); + newVelocity = newVelocity.RotatedBy(rotatedBy * 0.1f); + } + projectile.rotation = newVelocity.ToRotation() + 1.57079637f; + projectile.position = projectile.Center; + projectile.scale = scaleOffset; + projectile.width = projectile.height = (int)(defScaleFactor * projectile.scale); + projectile.Center = projectile.position; + if (newVelocity != Vector2.Zero) + { + projectile.Center = pCenter - Vector2.Normalize(newVelocity) * positionOffset * scaleOffset; + } + projectile.spriteDirection = (newVelocity.X > 0f) ? 1 : -1; + } + } + } + + #endregion + + public static void ModifiedGoldfishAI(NPC npc, float scareRange, bool faceAway = true) + { + if (npc.direction == 0) + { + npc.TargetClosest(); + } + if (npc.wet) + { + bool hasPlayer = false; + npc.TargetClosest(faceTarget: false); + Vector2 centerpos = npc.Center; + Player player = Main.player[npc.target]; + Vector2 playerpos = player.Center; + float distancex = playerpos.X - centerpos.X; + float distancey = playerpos.Y - centerpos.Y; + float distSQ = distancex * distancex + distancey * distancey; + if (player.wet && distSQ < scareRange * scareRange) + { + if (!player.dead) + { + hasPlayer = true; + } + } + if (!hasPlayer) + { + if (npc.collideX) + { + npc.velocity.X *= -1; + npc.direction *= -1; + npc.netUpdate = true; + } + if (npc.collideY) + { + npc.netUpdate = true; + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = Math.Abs(npc.velocity.Y) * -1f; + npc.directionY = -1; + npc.ai[0] = -1f; + } + else if (npc.velocity.Y < 0f) + { + npc.velocity.Y = Math.Abs(npc.velocity.Y); + npc.directionY = 1; + npc.ai[0] = 1f; + } + } + } + if (hasPlayer) //if target is in water + { + npc.TargetClosest(faceTarget: false); + npc.direction = (distancex >= 0f).ToDirectionInt(); + npc.directionY = (distancey >= 0f).ToDirectionInt(); + + if (faceAway) + { + npc.direction *= -1; + npc.directionY *= -1; + } + + npc.velocity.X += npc.direction * 0.1f; + npc.velocity.Y += npc.directionY * 0.1f; + + if (npc.velocity.X > 3f) + { + npc.velocity.X = 3f; + } + if (npc.velocity.X < -3f) + { + npc.velocity.X = -3f; + } + if (npc.velocity.Y > 2f) + { + npc.velocity.Y = 2f; + } + if (npc.velocity.Y < -2f) + { + npc.velocity.Y = -2f; + } + } + else + { + npc.velocity.X += npc.direction * 0.1f; + if (npc.velocity.X < -1f || npc.velocity.X > 1f) + { + npc.velocity.X *= 0.95f; + } + if (npc.ai[0] == -1f) + { + npc.velocity.Y -= 0.01f; + if (npc.velocity.Y < -0.3f) + { + npc.ai[0] = 1f; + } + } + else + { + npc.velocity.Y += 0.01f; + if (npc.velocity.Y > 0.3f) + { + npc.ai[0] = -1f; + } + } + int tileX = (int)npc.Center.X / 16; + int tileY = (int)npc.Center.Y / 16; + if (Framing.GetTileSafely(tileX, tileY - 1).LiquidAmount > 128) + { + if (Framing.GetTileSafely(tileX, tileY + 1).HasTile) + { + npc.ai[0] = -1f; + } + else if (Framing.GetTileSafely(tileX, tileY + 2).HasTile) + { + npc.ai[0] = -1f; + } + } + if (npc.velocity.Y > 0.4f || npc.velocity.Y < -0.4f) + { + npc.velocity.Y *= 0.95f; + } + } + } + else //not wet, frantically jump around + { + if (npc.velocity.Y == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.velocity.Y = Main.rand.Next(-50, -20) * 0.1f; + npc.velocity.X = Main.rand.Next(-20, 20) * 0.1f; + npc.netUpdate = true; + } + } + npc.velocity.Y += 0.3f; + if (npc.velocity.Y > 10f) + { + npc.velocity.Y = 10f; + } + npc.ai[0] = 1f; + } + npc.rotation = npc.velocity.Y * npc.direction * 0.1f; + if (npc.rotation < -0.2f) + { + npc.rotation = -0.2f; + } + if (npc.rotation > 0.2f) + { + npc.rotation = 0.2f; + } + } + + //TODO turn into usable method later + public static void PirateAI(Projectile Projectile) + { + // //Pirate AI related: + //public int State + //{ + // get => (int)Projectile.ai[0]; + // set => Projectile.ai[0] = value; + //} + + //public int Timer + //{ + // get => (int)Projectile.ai[1]; + // set => Projectile.ai[1] = value; + //} + + //public bool Idle => State == 0; + + //public bool Flying + //{ + // get => State == 1; + // set => State = value ? 1 : 0; + //} + + //public bool Attacking + //{ + // get => State == 2; + // set => State = value ? 2 : 0; + //} + int Timer = 0; + bool Idle = true; + bool Flying = false; + bool Attacking = false; + ////End Pirate AI + + Player player = Main.player[Projectile.owner]; + + int startAttackRange = 800; + float awayFromPlayerDistMax = 500f; + float awayFromPlayerDistYMax = 300f; + + Vector2 destination = player.Center; + destination.X -= (15 + player.width / 2) * player.direction; + destination.X -= Projectile.minionPos * 25 * player.direction; + + Projectile.shouldFallThrough = player.Bottom.Y - 12f > Projectile.Bottom.Y; + Projectile.friendly = false; + int timerReset = 0; + int attackFrameCount = 3; + int nextTimerValue = 5 * attackFrameCount; + int attackTarget = -1; + + bool defaultstate = Idle; + + static bool CustomEliminationCheck_Pirates(Entity otherEntity, int currentTarget) => true; + + if (defaultstate) + Projectile.Minion_FindTargetInRange(startAttackRange, ref attackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); + + if (Flying) + { + Projectile.tileCollide = false; + float velChange = 0.2f; + float toPlayerSpeed = 10f; + int maxLen = 200; + if (toPlayerSpeed < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + toPlayerSpeed = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + + Vector2 toPlayer = player.Center - Projectile.Center; + float len = toPlayer.Length(); + + AssAI.TeleportIfTooFar(Projectile, player.Center); + + if (len < maxLen && player.velocity.Y == 0f && Projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + //Reset back from flying + Flying = false; + Projectile.netUpdate = true; + if (Projectile.velocity.Y < -6f) + Projectile.velocity.Y = -6f; + } + + if (!(len < 60f)) + { + toPlayer.Normalize(); + toPlayer *= toPlayerSpeed; + if (Projectile.velocity.X < toPlayer.X) + { + Projectile.velocity.X += velChange; + if (Projectile.velocity.X < 0f) + Projectile.velocity.X += velChange * 1.5f; + } + + if (Projectile.velocity.X > toPlayer.X) + { + Projectile.velocity.X -= velChange; + if (Projectile.velocity.X > 0f) + Projectile.velocity.X -= velChange * 1.5f; + } + + if (Projectile.velocity.Y < toPlayer.Y) + { + Projectile.velocity.Y += velChange; + if (Projectile.velocity.Y < 0f) + Projectile.velocity.Y += velChange * 1.5f; + } + + if (Projectile.velocity.Y > toPlayer.Y) + { + Projectile.velocity.Y -= velChange; + if (Projectile.velocity.Y > 0f) + Projectile.velocity.Y -= velChange * 1.5f; + } + } + + if (Projectile.velocity.X != 0f) + Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X); + } + + if (Attacking && Timer < 0) + { + Projectile.friendly = false; + Timer += 1; + if (nextTimerValue >= 0) + { + Timer = 0; + Attacking = false; + Projectile.netUpdate = true; + return; + } + } + else if (Attacking) + { + //Attacking animation + Projectile.spriteDirection = -Projectile.direction; + Projectile.rotation = 0f; + + Projectile.friendly = true; + int startAttackFrame = 12; + bool hasJumpingAttackFrames = true; + int attackFrameNumber = (int)((float)nextTimerValue - Timer) / (nextTimerValue / attackFrameCount); + Projectile.frame = startAttackFrame + attackFrameNumber; + if (hasJumpingAttackFrames && Projectile.velocity.Y != 0f) + Projectile.frame += attackFrameCount; + + Projectile.velocity.Y += 0.4f; + if (Projectile.velocity.Y > 10f) + Projectile.velocity.Y = 10f; + + Timer -= 1; + if (Timer <= 0f) + { + if (timerReset <= 0) + { + Timer = 0; + Attacking = false; + Projectile.netUpdate = true; + return; + } + + Timer = -timerReset; + } + } + + if (attackTarget >= 0) + { + float maxDistance = startAttackRange; + float toTargetMaxDist = 20f; + + NPC npc = Main.npc[attackTarget]; + Vector2 targetCenter = npc.Center; + destination = targetCenter; + if (Projectile.IsInRangeOfMeOrMyOwner(npc, maxDistance, out float _, out float _, out bool _)) + { + Projectile.shouldFallThrough = npc.Center.Y > Projectile.Bottom.Y; + + bool flag11 = Projectile.velocity.Y == 0f; + if (Projectile.wet && Projectile.velocity.Y > 0f && !Projectile.shouldFallThrough) + flag11 = true; + + if (targetCenter.Y < Projectile.Center.Y - 30f && flag11) + { + float num25 = (targetCenter.Y - Projectile.Center.Y) * -1f; + float num26 = 0.4f; + float velY = (float)Math.Sqrt(num25 * 2f * num26); + if (velY > 26f) + velY = 26f; + + Projectile.velocity.Y = -velY; + } + + if (Vector2.Distance(Projectile.Center, destination) < toTargetMaxDist) + { + float len = Projectile.velocity.Length(); + if (len > 10f) + Projectile.velocity /= len / 10f; + + Attacking = true; + Timer = nextTimerValue; + Projectile.netUpdate = true; + Projectile.direction = (targetCenter.X - Projectile.Center.X > 0f).ToDirectionInt(); + } + } + } + + if (Idle && attackTarget < 0) + { + if (player.rocketDelay2 > 0) + { + Flying = true; + Projectile.netUpdate = true; + } + + Vector2 toPlayer = player.Center - Projectile.Center; + if (toPlayer.Length() > 2000f) + { + Projectile.Center = player.Center; + } + else if (toPlayer.Length() > awayFromPlayerDistMax || Math.Abs(toPlayer.Y) > awayFromPlayerDistYMax) + { + Flying = true; + Projectile.netUpdate = true; + if (Projectile.velocity.Y > 0f && toPlayer.Y < 0f) + Projectile.velocity.Y = 0f; + + if (Projectile.velocity.Y < 0f && toPlayer.Y > 0f) + Projectile.velocity.Y = 0f; + } + } + + if (Idle) + { + if (attackTarget < 0) + { + if (Projectile.Distance(player.Center) > 60f && Projectile.Distance(destination) > 60f && Math.Sign(destination.X - player.Center.X) != Math.Sign(Projectile.Center.X - player.Center.X)) + destination = player.Center; + + Rectangle rect = Utils.CenteredRectangle(destination, Projectile.Size); + for (int i = 0; i < 20; i++) + { + if (Collision.SolidCollision(rect.TopLeft(), rect.Width, rect.Height)) + break; + + rect.Y += 16; + destination.Y += 16f; + } + + Vector2 position = player.Center - Projectile.Size / 2f; + Vector2 postCollision = Collision.TileCollision(position, destination - player.Center, Projectile.width, Projectile.height); + destination = position + postCollision; + if (Projectile.Distance(destination) < 32f) + { + float distPlayerToDestination = player.Distance(destination); + if (player.Distance(Projectile.Center) < distPlayerToDestination) + destination = Projectile.Center; + } + + Vector2 fromDestToPlayer = player.Center - destination; + if (fromDestToPlayer.Length() > awayFromPlayerDistMax || Math.Abs(fromDestToPlayer.Y) > awayFromPlayerDistYMax) + { + Rectangle rect2 = Utils.CenteredRectangle(player.Center, Projectile.Size); + Vector2 fromPlayerToDest = destination - player.Center; + Vector2 topLeft = rect2.TopLeft(); + for (float i = 0f; i < 1f; i += 0.05f) + { + Vector2 newTopLeft = rect2.TopLeft() + fromPlayerToDest * i; + if (Collision.SolidCollision(rect2.TopLeft() + fromPlayerToDest * i, rect2.Width, rect2.Height)) + break; + + topLeft = newTopLeft; + } + + destination = topLeft + Projectile.Size / 2f; + } + } + + Projectile.tileCollide = true; + float velXChange = 0.5f; //0.5f + float velXChangeMargin = 4f; //4f + float velXChangeMax = 4f; //4f + float velXChangeSmall = 0.1f; + + if (attackTarget != -1) + { + velXChange = 0.4f; //1f + velXChangeMargin = 5f; //8f + velXChangeMax = 5f; //8f + } + + if (velXChangeMax < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + { + velXChangeMax = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + velXChange = 0.7f; + } + + int xOff = 0; + bool canJumpOverTiles = false; + float toDestinationX = destination.X - Projectile.Center.X; + Vector2 toDestination = destination - Projectile.Center; + if (Math.Abs(toDestinationX) > 5f) + { + if (toDestinationX < 0f) + { + xOff = -1; + if (Projectile.velocity.X > -velXChangeMargin) + Projectile.velocity.X -= velXChange; + else + Projectile.velocity.X -= velXChangeSmall; + } + else + { + xOff = 1; + if (Projectile.velocity.X < velXChangeMargin) + Projectile.velocity.X += velXChange; + else + Projectile.velocity.X += velXChangeSmall; + } + } + else + { + Projectile.velocity.X *= 0.9f; + if (Math.Abs(Projectile.velocity.X) < velXChange * 2f) + Projectile.velocity.X = 0f; + } + + bool tryJumping = Math.Abs(toDestination.X) >= 64f || (toDestination.Y <= -48f && Math.Abs(toDestination.X) >= 8f); + if (xOff != 0 && tryJumping) + { + int x = (int)Projectile.Center.X / 16; + int y = (int)Projectile.position.Y / 16; + x += xOff; + x += (int)Projectile.velocity.X; + for (int j = y; j < y + Projectile.height / 16 + 1; j++) + { + if (WorldGen.SolidTile(x, j)) + canJumpOverTiles = true; + } + } + + Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); + float nextVelocityY = Utils.GetLerpValue(0f, 100f, toDestination.Y, clamped: true) * Utils.GetLerpValue(-2f, -6f, Projectile.velocity.Y, clamped: true); + if (Projectile.velocity.Y == 0f && canJumpOverTiles) + { + for (int k = 0; k < 3; k++) + { + int num42 = (int)(Projectile.Center.X) / 16; + if (k == 0) + num42 = (int)Projectile.position.X / 16; + + if (k == 2) + num42 = (int)(Projectile.Right.X) / 16; + + int num43 = (int)(Projectile.Bottom.Y) / 16; + if (!WorldGen.SolidTile(num42, num43) && !Main.tile[num42, num43].IsHalfBlock && Main.tile[num42, num43].Slope <= 0 && (!TileID.Sets.Platforms[Main.tile[num42, num43].TileType] || !Main.tile[num42, num43].HasTile || Main.tile[num42, num43].IsActuated)) + continue; + + try + { + num42 = (int)(Projectile.Center.X) / 16; + num43 = (int)(Projectile.Center.Y) / 16; + num42 += xOff; + num42 += (int)Projectile.velocity.X; + if (!WorldGen.SolidTile(num42, num43 - 1) && !WorldGen.SolidTile(num42, num43 - 2)) + Projectile.velocity.Y = -5.1f; + else if (!WorldGen.SolidTile(num42, num43 - 2)) + Projectile.velocity.Y = -7.1f; + else if (WorldGen.SolidTile(num42, num43 - 5)) + Projectile.velocity.Y = -11.1f; + else if (WorldGen.SolidTile(num42, num43 - 4)) + Projectile.velocity.Y = -10.1f; + else + Projectile.velocity.Y = -9.1f; + } + catch + { + Projectile.velocity.Y = -9.1f; + } + } + + if (destination.Y - Projectile.Center.Y < -48f) + { + float height = destination.Y - Projectile.Center.Y; + height *= -1f; + if (height < 60f) + Projectile.velocity.Y = -6f; + else if (height < 80f) + Projectile.velocity.Y = -7f; + else if (height < 100f) + Projectile.velocity.Y = -8f; + else if (height < 120f) + Projectile.velocity.Y = -9f; + else if (height < 140f) + Projectile.velocity.Y = -10f; + else if (height < 160f) + Projectile.velocity.Y = -11f; + else if (height < 190f) + Projectile.velocity.Y = -12f; + else if (height < 210f) + Projectile.velocity.Y = -13f; + else if (height < 270f) + Projectile.velocity.Y = -14f; + else if (height < 310f) + Projectile.velocity.Y = -15f; + else + Projectile.velocity.Y = -16f; + } + + if (Projectile.wet && nextVelocityY == 0f) + Projectile.velocity.Y *= 2f; + } + + if (Projectile.velocity.X > velXChangeMax) + Projectile.velocity.X = velXChangeMax; + + if (Projectile.velocity.X < -velXChangeMax) + Projectile.velocity.X = -velXChangeMax; + + if (Projectile.velocity.X < 0f) + Projectile.direction = -1; + + if (Projectile.velocity.X > 0f) + Projectile.direction = 1; + + if (Projectile.velocity.X == 0f) + Projectile.direction = (player.Center.X > Projectile.Center.X).ToDirectionInt(); + + if (Projectile.velocity.X > velXChange && xOff == 1) + Projectile.direction = 1; + + if (Projectile.velocity.X < -velXChange && xOff == -1) + Projectile.direction = -1; + + Projectile.spriteDirection = -Projectile.direction; + + Projectile.velocity.Y += 0.4f + nextVelocityY * 1f; + if (Projectile.velocity.Y > 10f) + { + Projectile.velocity.Y = 10f; + } + } + + #region default animations + /* if (Flying) { //Flying animation @@ -1848,477 +1848,477 @@ public static void PirateAI(Projectile Projectile) } } */ - #endregion - } - - //TODO turn into usable method later - public static void VampFrogAI(Projectile Projectile) - { - // //VampFrog AI related: - //public int State - //{ - // get => (int)Projectile.ai[0]; - // set => Projectile.ai[0] = value; - //} - - //public int Timer - //{ - // get => (int)Projectile.ai[1]; - // set => Projectile.ai[1] = value; - //} - - //public bool Idle => State == 0; - - //public bool Flying - //{ - // get => State == 1; - // set => State = value ? 1 : 0; - //} - - //public bool Attacking - //{ - // get => State == 2; - // set => State = value ? 2 : 0; - //} - int Timer = 0; - bool Idle = true; - bool Flying = false; - bool Attacking = false; - ////End VampFrog AI - - Player player = Main.player[Projectile.owner]; - - int startAttackRange = 800; - float awayFromPlayerDistMax = 500f; - float awayFromPlayerDistYMax = 300f; - - Vector2 destination = player.Center; - destination.X -= (35 + player.width / 2) * player.direction; - destination.X -= Projectile.minionPos * 40 * player.direction; - - Projectile.shouldFallThrough = player.Bottom.Y - 12f > Projectile.Bottom.Y; - Projectile.friendly = false; - int timerReset = 0; - int attackFrameCount = 4; - int nextTimerValue = 5 * attackFrameCount; - int attackTarget = -1; - - Projectile.friendly = true; - timerReset = 60; - - bool defaultstate = Idle; - - static bool CustomEliminationCheck_Pirates(Entity otherEntity, int currentTarget) => true; - - if (defaultstate) - Projectile.Minion_FindTargetInRange(startAttackRange, ref attackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); - - if (Flying) - { - Projectile.tileCollide = false; - float velChange = 0.2f; - float toPlayerSpeed = 10f; - int maxLen = 200; - if (toPlayerSpeed < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - toPlayerSpeed = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - - Vector2 toPlayer = player.Center - Projectile.Center; - float len = toPlayer.Length(); - - AssAI.TeleportIfTooFar(Projectile, player.Center); - - if (len < maxLen && player.velocity.Y == 0f && Projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - //Reset back from flying - Flying = false; - Projectile.netUpdate = true; - if (Projectile.velocity.Y < -6f) - Projectile.velocity.Y = -6f; - } - - if (!(len < 60f)) - { - toPlayer.Normalize(); - toPlayer *= toPlayerSpeed; - if (Projectile.velocity.X < toPlayer.X) - { - Projectile.velocity.X += velChange; - if (Projectile.velocity.X < 0f) - Projectile.velocity.X += velChange * 1.5f; - } - - if (Projectile.velocity.X > toPlayer.X) - { - Projectile.velocity.X -= velChange; - if (Projectile.velocity.X > 0f) - Projectile.velocity.X -= velChange * 1.5f; - } - - if (Projectile.velocity.Y < toPlayer.Y) - { - Projectile.velocity.Y += velChange; - if (Projectile.velocity.Y < 0f) - Projectile.velocity.Y += velChange * 1.5f; - } - - if (Projectile.velocity.Y > toPlayer.Y) - { - Projectile.velocity.Y -= velChange; - if (Projectile.velocity.Y > 0f) - Projectile.velocity.Y -= velChange * 1.5f; - } - } - - if (Projectile.velocity.X != 0f) - Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X); - } - - if (Attacking && Timer < 0) - { - Projectile.friendly = false; - Timer += 1; - if (nextTimerValue >= 0) - { - Timer = 0; - Attacking = false; - Projectile.netUpdate = true; - return; - } - } - else if (Attacking) - { - //Attacking animation - Projectile.spriteDirection = -Projectile.direction; - Projectile.rotation = 0f; - - float num22 = ((float)nextTimerValue - Timer) / (float)nextTimerValue; - if ((double)num22 > 0.25 && (double)num22 < 0.75) - Projectile.friendly = true; - - int num23 = (int)(num22 * 5f); - if (num23 > 2) - num23 = 4 - num23; - - if (Projectile.velocity.Y != 0f) - Projectile.frame = 21 + num23; - else - Projectile.frame = 18 + num23; - - if (Projectile.velocity.Y == 0f) - Projectile.velocity.X *= 0.8f; - - Projectile.velocity.Y += 0.4f; - if (Projectile.velocity.Y > 10f) - Projectile.velocity.Y = 10f; - - Timer -= 1; - if (Timer <= 0f) - { - if (timerReset <= 0) - { - Timer = 0; - Attacking = false; - Projectile.netUpdate = true; - return; - } - - Timer = -timerReset; - } - } - - if (attackTarget >= 0) - { - float maxDistance = startAttackRange; - float toTargetMaxDist = 50f; - - NPC npc = Main.npc[attackTarget]; - Vector2 targetCenter = npc.Center; - destination = targetCenter; - if (Projectile.IsInRangeOfMeOrMyOwner(npc, maxDistance, out float _, out float _, out bool _)) - { - Projectile.shouldFallThrough = npc.Center.Y > Projectile.Bottom.Y; - - bool flag11 = Projectile.velocity.Y == 0f; - if (Projectile.wet && Projectile.velocity.Y > 0f && !Projectile.shouldFallThrough) - flag11 = true; - - if (targetCenter.Y < Projectile.Center.Y - 30f && flag11) - { - float num25 = (targetCenter.Y - Projectile.Center.Y) * -1f; - float num26 = 0.4f; - float velY = (float)Math.Sqrt(num25 * 2f * num26); - if (velY > 26f) - velY = 26f; - - Projectile.velocity.Y = -velY; - } - - if (Vector2.Distance(Projectile.Center, destination) < toTargetMaxDist) - { - float len = Projectile.velocity.Length(); - if (len > 10f) - Projectile.velocity /= len / 10f; - - Attacking = true; - Timer = nextTimerValue; - Projectile.netUpdate = true; - Projectile.direction = (targetCenter.X - Projectile.Center.X > 0f).ToDirectionInt(); - } - } - - int dir = 1; - if (targetCenter.X - Projectile.Center.X < 0f) - dir = -1; - - destination.X += 20 * -dir; - } - - if (Idle && attackTarget < 0) - { - if (player.rocketDelay2 > 0) - { - Flying = true; - Projectile.netUpdate = true; - } - - Vector2 toPlayer = player.Center - Projectile.Center; - if (toPlayer.Length() > 2000f) - { - Projectile.Center = player.Center; - } - else if (toPlayer.Length() > awayFromPlayerDistMax || Math.Abs(toPlayer.Y) > awayFromPlayerDistYMax) - { - Flying = true; - Projectile.netUpdate = true; - if (Projectile.velocity.Y > 0f && toPlayer.Y < 0f) - Projectile.velocity.Y = 0f; - - if (Projectile.velocity.Y < 0f && toPlayer.Y > 0f) - Projectile.velocity.Y = 0f; - } - } - - if (Idle) - { - if (attackTarget < 0) - { - if (Projectile.Distance(player.Center) > 60f && Projectile.Distance(destination) > 60f && Math.Sign(destination.X - player.Center.X) != Math.Sign(Projectile.Center.X - player.Center.X)) - destination = player.Center; - - Rectangle rect = Utils.CenteredRectangle(destination, Projectile.Size); - for (int i = 0; i < 20; i++) - { - if (Collision.SolidCollision(rect.TopLeft(), rect.Width, rect.Height)) - break; - - rect.Y += 16; - destination.Y += 16f; - } - - Vector2 position = player.Center - Projectile.Size / 2f; - Vector2 postCollision = Collision.TileCollision(position, destination - player.Center, Projectile.width, Projectile.height); - destination = position + postCollision; - if (Projectile.Distance(destination) < 32f) - { - float distPlayerToDestination = player.Distance(destination); - if (player.Distance(Projectile.Center) < distPlayerToDestination) - destination = Projectile.Center; - } - - Vector2 fromDestToPlayer = player.Center - destination; - if (fromDestToPlayer.Length() > awayFromPlayerDistMax || Math.Abs(fromDestToPlayer.Y) > awayFromPlayerDistYMax) - { - Rectangle rect2 = Utils.CenteredRectangle(player.Center, Projectile.Size); - Vector2 fromPlayerToDest = destination - player.Center; - Vector2 topLeft = rect2.TopLeft(); - for (float i = 0f; i < 1f; i += 0.05f) - { - Vector2 newTopLeft = rect2.TopLeft() + fromPlayerToDest * i; - if (Collision.SolidCollision(rect2.TopLeft() + fromPlayerToDest * i, rect2.Width, rect2.Height)) - break; - - topLeft = newTopLeft; - } - - destination = topLeft + Projectile.Size / 2f; - } - } - - Projectile.tileCollide = true; - float velXChange = 0.5f; //0.5f - float velXChangeMargin = 4f; //4f - float velXChangeMax = 4f; //4f - float velXChangeSmall = 0.1f; - - if (attackTarget != -1) - { - velXChange = 0.7f; - velXChangeMargin = 6f; - velXChangeMax = 6f; - } - - if (velXChangeMax < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - { - velXChangeMax = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - velXChange = 0.7f; - } - - int xOff = 0; - bool canJumpOverTiles = false; - float toDestinationX = destination.X - Projectile.Center.X; - Vector2 toDestination = destination - Projectile.Center; - if (Math.Abs(toDestinationX) > 5f) - { - if (toDestinationX < 0f) - { - xOff = -1; - if (Projectile.velocity.X > -velXChangeMargin) - Projectile.velocity.X -= velXChange; - else - Projectile.velocity.X -= velXChangeSmall; - } - else - { - xOff = 1; - if (Projectile.velocity.X < velXChangeMargin) - Projectile.velocity.X += velXChange; - else - Projectile.velocity.X += velXChangeSmall; - } - - bool shouldJumpOverTiles = true; - - if (attackTarget == -1) - shouldJumpOverTiles = false; - - if (shouldJumpOverTiles) - canJumpOverTiles = true; - } - else - { - Projectile.velocity.X *= 0.9f; - if (Math.Abs(Projectile.velocity.X) < velXChange * 2f) - Projectile.velocity.X = 0f; - } - - bool tryJumping = Math.Abs(toDestination.X) >= 64f || (toDestination.Y <= -48f && Math.Abs(toDestination.X) >= 8f); - if (xOff != 0 && tryJumping) - { - int x = (int)Projectile.Center.X / 16; - int y = (int)Projectile.position.Y / 16; - x += xOff; - x += (int)Projectile.velocity.X; - for (int j = y; j < y + Projectile.height / 16 + 1; j++) - { - if (WorldGen.SolidTile(x, j)) - canJumpOverTiles = true; - } - } - - Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); - float nextVelocityY = Utils.GetLerpValue(0f, 100f, toDestination.Y, clamped: true) * Utils.GetLerpValue(-2f, -6f, Projectile.velocity.Y, clamped: true); - if (Projectile.velocity.Y == 0f && canJumpOverTiles) - { - for (int k = 0; k < 3; k++) - { - int num42 = (int)(Projectile.Center.X) / 16; - if (k == 0) - num42 = (int)Projectile.position.X / 16; - - if (k == 2) - num42 = (int)(Projectile.Right.X) / 16; - - int num43 = (int)(Projectile.Bottom.Y) / 16; - if (!WorldGen.SolidTile(num42, num43) && !Main.tile[num42, num43].IsHalfBlock && Main.tile[num42, num43].Slope <= 0 && (!TileID.Sets.Platforms[Main.tile[num42, num43].TileType] || !Main.tile[num42, num43].HasTile || Main.tile[num42, num43].IsActuated)) - continue; - - try - { - num42 = (int)(Projectile.Center.X) / 16; - num43 = (int)(Projectile.Center.Y) / 16; - num42 += xOff; - num42 += (int)Projectile.velocity.X; - if (!WorldGen.SolidTile(num42, num43 - 1) && !WorldGen.SolidTile(num42, num43 - 2)) - Projectile.velocity.Y = -5.1f; - else if (!WorldGen.SolidTile(num42, num43 - 2)) - Projectile.velocity.Y = -7.1f; - else if (WorldGen.SolidTile(num42, num43 - 5)) - Projectile.velocity.Y = -11.1f; - else if (WorldGen.SolidTile(num42, num43 - 4)) - Projectile.velocity.Y = -10.1f; - else - Projectile.velocity.Y = -9.1f; - } - catch - { - Projectile.velocity.Y = -9.1f; - } - } - - if (destination.Y - Projectile.Center.Y < -48f) - { - float height = destination.Y - Projectile.Center.Y; - height *= -1f; - if (height < 60f) - Projectile.velocity.Y = -6f; - else if (height < 80f) - Projectile.velocity.Y = -7f; - else if (height < 100f) - Projectile.velocity.Y = -8f; - else if (height < 120f) - Projectile.velocity.Y = -9f; - else if (height < 140f) - Projectile.velocity.Y = -10f; - else if (height < 160f) - Projectile.velocity.Y = -11f; - else if (height < 190f) - Projectile.velocity.Y = -12f; - else if (height < 210f) - Projectile.velocity.Y = -13f; - else if (height < 270f) - Projectile.velocity.Y = -14f; - else if (height < 310f) - Projectile.velocity.Y = -15f; - else - Projectile.velocity.Y = -16f; - } - - if (Projectile.wet && nextVelocityY == 0f) - Projectile.velocity.Y *= 2f; - } - - if (Projectile.velocity.X > velXChangeMax) - Projectile.velocity.X = velXChangeMax; - - if (Projectile.velocity.X < -velXChangeMax) - Projectile.velocity.X = -velXChangeMax; - - if (Projectile.velocity.X < 0f) - Projectile.direction = -1; - - if (Projectile.velocity.X > 0f) - Projectile.direction = 1; - - if (Projectile.velocity.X == 0f) - Projectile.direction = (player.Center.X > Projectile.Center.X).ToDirectionInt(); - - if (Projectile.velocity.X > velXChange && xOff == 1) - Projectile.direction = 1; - - if (Projectile.velocity.X < -velXChange && xOff == -1) - Projectile.direction = -1; - - Projectile.spriteDirection = -Projectile.direction; - - Projectile.velocity.Y += 0.4f + nextVelocityY * 1f; - if (Projectile.velocity.Y > 10f) - { - Projectile.velocity.Y = 10f; - } - } - - #region default animations - /* + #endregion + } + + //TODO turn into usable method later + public static void VampFrogAI(Projectile Projectile) + { + // //VampFrog AI related: + //public int State + //{ + // get => (int)Projectile.ai[0]; + // set => Projectile.ai[0] = value; + //} + + //public int Timer + //{ + // get => (int)Projectile.ai[1]; + // set => Projectile.ai[1] = value; + //} + + //public bool Idle => State == 0; + + //public bool Flying + //{ + // get => State == 1; + // set => State = value ? 1 : 0; + //} + + //public bool Attacking + //{ + // get => State == 2; + // set => State = value ? 2 : 0; + //} + int Timer = 0; + bool Idle = true; + bool Flying = false; + bool Attacking = false; + ////End VampFrog AI + + Player player = Main.player[Projectile.owner]; + + int startAttackRange = 800; + float awayFromPlayerDistMax = 500f; + float awayFromPlayerDistYMax = 300f; + + Vector2 destination = player.Center; + destination.X -= (35 + player.width / 2) * player.direction; + destination.X -= Projectile.minionPos * 40 * player.direction; + + Projectile.shouldFallThrough = player.Bottom.Y - 12f > Projectile.Bottom.Y; + Projectile.friendly = false; + int timerReset = 0; + int attackFrameCount = 4; + int nextTimerValue = 5 * attackFrameCount; + int attackTarget = -1; + + Projectile.friendly = true; + timerReset = 60; + + bool defaultstate = Idle; + + static bool CustomEliminationCheck_Pirates(Entity otherEntity, int currentTarget) => true; + + if (defaultstate) + Projectile.Minion_FindTargetInRange(startAttackRange, ref attackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); + + if (Flying) + { + Projectile.tileCollide = false; + float velChange = 0.2f; + float toPlayerSpeed = 10f; + int maxLen = 200; + if (toPlayerSpeed < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + toPlayerSpeed = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + + Vector2 toPlayer = player.Center - Projectile.Center; + float len = toPlayer.Length(); + + AssAI.TeleportIfTooFar(Projectile, player.Center); + + if (len < maxLen && player.velocity.Y == 0f && Projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + //Reset back from flying + Flying = false; + Projectile.netUpdate = true; + if (Projectile.velocity.Y < -6f) + Projectile.velocity.Y = -6f; + } + + if (!(len < 60f)) + { + toPlayer.Normalize(); + toPlayer *= toPlayerSpeed; + if (Projectile.velocity.X < toPlayer.X) + { + Projectile.velocity.X += velChange; + if (Projectile.velocity.X < 0f) + Projectile.velocity.X += velChange * 1.5f; + } + + if (Projectile.velocity.X > toPlayer.X) + { + Projectile.velocity.X -= velChange; + if (Projectile.velocity.X > 0f) + Projectile.velocity.X -= velChange * 1.5f; + } + + if (Projectile.velocity.Y < toPlayer.Y) + { + Projectile.velocity.Y += velChange; + if (Projectile.velocity.Y < 0f) + Projectile.velocity.Y += velChange * 1.5f; + } + + if (Projectile.velocity.Y > toPlayer.Y) + { + Projectile.velocity.Y -= velChange; + if (Projectile.velocity.Y > 0f) + Projectile.velocity.Y -= velChange * 1.5f; + } + } + + if (Projectile.velocity.X != 0f) + Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X); + } + + if (Attacking && Timer < 0) + { + Projectile.friendly = false; + Timer += 1; + if (nextTimerValue >= 0) + { + Timer = 0; + Attacking = false; + Projectile.netUpdate = true; + return; + } + } + else if (Attacking) + { + //Attacking animation + Projectile.spriteDirection = -Projectile.direction; + Projectile.rotation = 0f; + + float num22 = ((float)nextTimerValue - Timer) / (float)nextTimerValue; + if ((double)num22 > 0.25 && (double)num22 < 0.75) + Projectile.friendly = true; + + int num23 = (int)(num22 * 5f); + if (num23 > 2) + num23 = 4 - num23; + + if (Projectile.velocity.Y != 0f) + Projectile.frame = 21 + num23; + else + Projectile.frame = 18 + num23; + + if (Projectile.velocity.Y == 0f) + Projectile.velocity.X *= 0.8f; + + Projectile.velocity.Y += 0.4f; + if (Projectile.velocity.Y > 10f) + Projectile.velocity.Y = 10f; + + Timer -= 1; + if (Timer <= 0f) + { + if (timerReset <= 0) + { + Timer = 0; + Attacking = false; + Projectile.netUpdate = true; + return; + } + + Timer = -timerReset; + } + } + + if (attackTarget >= 0) + { + float maxDistance = startAttackRange; + float toTargetMaxDist = 50f; + + NPC npc = Main.npc[attackTarget]; + Vector2 targetCenter = npc.Center; + destination = targetCenter; + if (Projectile.IsInRangeOfMeOrMyOwner(npc, maxDistance, out float _, out float _, out bool _)) + { + Projectile.shouldFallThrough = npc.Center.Y > Projectile.Bottom.Y; + + bool flag11 = Projectile.velocity.Y == 0f; + if (Projectile.wet && Projectile.velocity.Y > 0f && !Projectile.shouldFallThrough) + flag11 = true; + + if (targetCenter.Y < Projectile.Center.Y - 30f && flag11) + { + float num25 = (targetCenter.Y - Projectile.Center.Y) * -1f; + float num26 = 0.4f; + float velY = (float)Math.Sqrt(num25 * 2f * num26); + if (velY > 26f) + velY = 26f; + + Projectile.velocity.Y = -velY; + } + + if (Vector2.Distance(Projectile.Center, destination) < toTargetMaxDist) + { + float len = Projectile.velocity.Length(); + if (len > 10f) + Projectile.velocity /= len / 10f; + + Attacking = true; + Timer = nextTimerValue; + Projectile.netUpdate = true; + Projectile.direction = (targetCenter.X - Projectile.Center.X > 0f).ToDirectionInt(); + } + } + + int dir = 1; + if (targetCenter.X - Projectile.Center.X < 0f) + dir = -1; + + destination.X += 20 * -dir; + } + + if (Idle && attackTarget < 0) + { + if (player.rocketDelay2 > 0) + { + Flying = true; + Projectile.netUpdate = true; + } + + Vector2 toPlayer = player.Center - Projectile.Center; + if (toPlayer.Length() > 2000f) + { + Projectile.Center = player.Center; + } + else if (toPlayer.Length() > awayFromPlayerDistMax || Math.Abs(toPlayer.Y) > awayFromPlayerDistYMax) + { + Flying = true; + Projectile.netUpdate = true; + if (Projectile.velocity.Y > 0f && toPlayer.Y < 0f) + Projectile.velocity.Y = 0f; + + if (Projectile.velocity.Y < 0f && toPlayer.Y > 0f) + Projectile.velocity.Y = 0f; + } + } + + if (Idle) + { + if (attackTarget < 0) + { + if (Projectile.Distance(player.Center) > 60f && Projectile.Distance(destination) > 60f && Math.Sign(destination.X - player.Center.X) != Math.Sign(Projectile.Center.X - player.Center.X)) + destination = player.Center; + + Rectangle rect = Utils.CenteredRectangle(destination, Projectile.Size); + for (int i = 0; i < 20; i++) + { + if (Collision.SolidCollision(rect.TopLeft(), rect.Width, rect.Height)) + break; + + rect.Y += 16; + destination.Y += 16f; + } + + Vector2 position = player.Center - Projectile.Size / 2f; + Vector2 postCollision = Collision.TileCollision(position, destination - player.Center, Projectile.width, Projectile.height); + destination = position + postCollision; + if (Projectile.Distance(destination) < 32f) + { + float distPlayerToDestination = player.Distance(destination); + if (player.Distance(Projectile.Center) < distPlayerToDestination) + destination = Projectile.Center; + } + + Vector2 fromDestToPlayer = player.Center - destination; + if (fromDestToPlayer.Length() > awayFromPlayerDistMax || Math.Abs(fromDestToPlayer.Y) > awayFromPlayerDistYMax) + { + Rectangle rect2 = Utils.CenteredRectangle(player.Center, Projectile.Size); + Vector2 fromPlayerToDest = destination - player.Center; + Vector2 topLeft = rect2.TopLeft(); + for (float i = 0f; i < 1f; i += 0.05f) + { + Vector2 newTopLeft = rect2.TopLeft() + fromPlayerToDest * i; + if (Collision.SolidCollision(rect2.TopLeft() + fromPlayerToDest * i, rect2.Width, rect2.Height)) + break; + + topLeft = newTopLeft; + } + + destination = topLeft + Projectile.Size / 2f; + } + } + + Projectile.tileCollide = true; + float velXChange = 0.5f; //0.5f + float velXChangeMargin = 4f; //4f + float velXChangeMax = 4f; //4f + float velXChangeSmall = 0.1f; + + if (attackTarget != -1) + { + velXChange = 0.7f; + velXChangeMargin = 6f; + velXChangeMax = 6f; + } + + if (velXChangeMax < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + { + velXChangeMax = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + velXChange = 0.7f; + } + + int xOff = 0; + bool canJumpOverTiles = false; + float toDestinationX = destination.X - Projectile.Center.X; + Vector2 toDestination = destination - Projectile.Center; + if (Math.Abs(toDestinationX) > 5f) + { + if (toDestinationX < 0f) + { + xOff = -1; + if (Projectile.velocity.X > -velXChangeMargin) + Projectile.velocity.X -= velXChange; + else + Projectile.velocity.X -= velXChangeSmall; + } + else + { + xOff = 1; + if (Projectile.velocity.X < velXChangeMargin) + Projectile.velocity.X += velXChange; + else + Projectile.velocity.X += velXChangeSmall; + } + + bool shouldJumpOverTiles = true; + + if (attackTarget == -1) + shouldJumpOverTiles = false; + + if (shouldJumpOverTiles) + canJumpOverTiles = true; + } + else + { + Projectile.velocity.X *= 0.9f; + if (Math.Abs(Projectile.velocity.X) < velXChange * 2f) + Projectile.velocity.X = 0f; + } + + bool tryJumping = Math.Abs(toDestination.X) >= 64f || (toDestination.Y <= -48f && Math.Abs(toDestination.X) >= 8f); + if (xOff != 0 && tryJumping) + { + int x = (int)Projectile.Center.X / 16; + int y = (int)Projectile.position.Y / 16; + x += xOff; + x += (int)Projectile.velocity.X; + for (int j = y; j < y + Projectile.height / 16 + 1; j++) + { + if (WorldGen.SolidTile(x, j)) + canJumpOverTiles = true; + } + } + + Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); + float nextVelocityY = Utils.GetLerpValue(0f, 100f, toDestination.Y, clamped: true) * Utils.GetLerpValue(-2f, -6f, Projectile.velocity.Y, clamped: true); + if (Projectile.velocity.Y == 0f && canJumpOverTiles) + { + for (int k = 0; k < 3; k++) + { + int num42 = (int)(Projectile.Center.X) / 16; + if (k == 0) + num42 = (int)Projectile.position.X / 16; + + if (k == 2) + num42 = (int)(Projectile.Right.X) / 16; + + int num43 = (int)(Projectile.Bottom.Y) / 16; + if (!WorldGen.SolidTile(num42, num43) && !Main.tile[num42, num43].IsHalfBlock && Main.tile[num42, num43].Slope <= 0 && (!TileID.Sets.Platforms[Main.tile[num42, num43].TileType] || !Main.tile[num42, num43].HasTile || Main.tile[num42, num43].IsActuated)) + continue; + + try + { + num42 = (int)(Projectile.Center.X) / 16; + num43 = (int)(Projectile.Center.Y) / 16; + num42 += xOff; + num42 += (int)Projectile.velocity.X; + if (!WorldGen.SolidTile(num42, num43 - 1) && !WorldGen.SolidTile(num42, num43 - 2)) + Projectile.velocity.Y = -5.1f; + else if (!WorldGen.SolidTile(num42, num43 - 2)) + Projectile.velocity.Y = -7.1f; + else if (WorldGen.SolidTile(num42, num43 - 5)) + Projectile.velocity.Y = -11.1f; + else if (WorldGen.SolidTile(num42, num43 - 4)) + Projectile.velocity.Y = -10.1f; + else + Projectile.velocity.Y = -9.1f; + } + catch + { + Projectile.velocity.Y = -9.1f; + } + } + + if (destination.Y - Projectile.Center.Y < -48f) + { + float height = destination.Y - Projectile.Center.Y; + height *= -1f; + if (height < 60f) + Projectile.velocity.Y = -6f; + else if (height < 80f) + Projectile.velocity.Y = -7f; + else if (height < 100f) + Projectile.velocity.Y = -8f; + else if (height < 120f) + Projectile.velocity.Y = -9f; + else if (height < 140f) + Projectile.velocity.Y = -10f; + else if (height < 160f) + Projectile.velocity.Y = -11f; + else if (height < 190f) + Projectile.velocity.Y = -12f; + else if (height < 210f) + Projectile.velocity.Y = -13f; + else if (height < 270f) + Projectile.velocity.Y = -14f; + else if (height < 310f) + Projectile.velocity.Y = -15f; + else + Projectile.velocity.Y = -16f; + } + + if (Projectile.wet && nextVelocityY == 0f) + Projectile.velocity.Y *= 2f; + } + + if (Projectile.velocity.X > velXChangeMax) + Projectile.velocity.X = velXChangeMax; + + if (Projectile.velocity.X < -velXChangeMax) + Projectile.velocity.X = -velXChangeMax; + + if (Projectile.velocity.X < 0f) + Projectile.direction = -1; + + if (Projectile.velocity.X > 0f) + Projectile.direction = 1; + + if (Projectile.velocity.X == 0f) + Projectile.direction = (player.Center.X > Projectile.Center.X).ToDirectionInt(); + + if (Projectile.velocity.X > velXChange && xOff == 1) + Projectile.direction = 1; + + if (Projectile.velocity.X < -velXChange && xOff == -1) + Projectile.direction = -1; + + Projectile.spriteDirection = -Projectile.direction; + + Projectile.velocity.Y += 0.4f + nextVelocityY * 1f; + if (Projectile.velocity.Y > 10f) + { + Projectile.velocity.Y = 10f; + } + } + + #region default animations + /* if (Flying) { //Flying animation @@ -2400,16 +2400,16 @@ public static void VampFrogAI(Projectile Projectile) } } */ - #endregion - } - } - - public enum WormType : byte - { - None = 0, - Head = 1, - Body1 = 2, - Body2 = 3, - Tail = 4 - } + #endregion + } + } + + public enum WormType : byte + { + None = 0, + Head = 1, + Body1 = 2, + Body2 = 3, + Tail = 4 + } } diff --git a/Base/AssExtensions.cs b/Base/AssExtensions.cs index dc395e7f..feab309f 100644 --- a/Base/AssExtensions.cs +++ b/Base/AssExtensions.cs @@ -3,211 +3,211 @@ namespace AssortedCrazyThings.Base { - /// - /// contains Extensions for some basic tasks - /// - public static class AssExtensions - { - /// - /// Returns the average value between the RGB (ignoring A) - /// - public static float GetAverage(this Color color) - { - return (color.R + color.G + color.B) / 3f; - } - - /// - /// Returns the Player that owns the given projectile. Only use if you are certain an owner exists and it is a player - /// - public static Player GetOwner(this Projectile proj) - { - return Main.player[proj.owner]; - } - - /// - /// Copy of vanilla code for spawning a single pet and setting buffTime. Gives random velocity at spawn - /// - /// - /// - /// - /// - /// - public static void AssSpawnPetIfNeededAndSetTime(this Player player, int buffIndex, ref bool petBool, int petProjID, int buffTimeToGive = 18000) - { - player.buffTime[buffIndex] = buffTimeToGive; - player.AssSpawnPetIfNeeded(ref petBool, petProjID, buffIndex); - } - - /// - /// Player.HasItem + checks all banks - /// - /// - /// - /// - public static bool HasItemWithBanks(this Player player, int type) - { - if (player.HasItem(type)) return true; - - Item[][] inventoryArray = { player.bank.item, player.bank2.item, player.bank3.item, player.bank4.item }; - for (int i = 0; i < inventoryArray.Length; i++) - { - Item[] inventory = inventoryArray[i]; - for (int j = 0; j < inventory.Length; j++) - { - Item item = inventory[j]; - if (type == item.type && item.stack > 0) return true; - } - } - - return false; - } - - /// - /// Checks if given item is present in the players inventory or equip slots - /// - public static bool ItemInInventoryOrEquipped(this Player player, Item item, bool ignoreVanity = false) - { - if (player.HasItem(item.type)) return true; - if (item.accessory || item.headSlot > 0 || item.bodySlot > 0 || item.legSlot > 0) - { - int maxLength = ignoreVanity ? 10 : player.armor.Length; - for (int i = 0; i < maxLength; i++) - { - if (player.armor[i].type == item.type) return true; - } - } - return false; - } - - /// - /// Copy of vanilla code for spawning a single pet. Gives random velocity at spawn - /// - /// - /// - /// - /// - public static void AssSpawnPetIfNeeded(this Player player, ref bool petBool, int petProjID, int buffIndex) - { - petBool = true; - if (player.ownedProjectileCounts[petProjID] > 0) - { - return; - } - - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center, -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2), petProjID, 0, 0f, player.whoAmI); - } - } - - public static void LoopAnimation(ref int frame, ref double frameCounter, int speed, int startFrame, int endFrame) - { - if (startFrame < 0) - { - startFrame = 0; - } - - if (frame < startFrame) - { - frame = startFrame; - } - else if (frame > endFrame) - { - frame = endFrame; - } - - frameCounter++; - if (frameCounter >= speed) - { - frameCounter = 0; - frame++; - if (frame > endFrame) - { - frame = startFrame; - } - } - } - - public static void LoopAnimationInt(ref int frame, ref int frameCounter, int speed, int startFrame, int endFrame) - { - if (startFrame < 0) - { - startFrame = 0; - } - - if (frame < startFrame) - { - frame = startFrame; - } - else if (frame > endFrame) - { - frame = endFrame; - } - - frameCounter++; - if (frameCounter >= speed) - { - frameCounter = 0; - frame++; - if (frame > endFrame) - { - frame = startFrame; - } - } - } - - /// - /// Loops through all frames in a set speed from top to bottom and repeats - /// - public static void LoopAnimation(this NPC npc, int frameHeight, int speed, int startFrame = 0, int endFrame = -1) - { - if (endFrame == -1) - { - endFrame = Main.npcFrameCount[npc.type] - 1; - } - - int frame = npc.frame.Y / frameHeight; - LoopAnimation(ref frame, ref npc.frameCounter, speed, startFrame, endFrame); - npc.frame.Y = frame * frameHeight; - } - - /// - /// Loops through all frames in a set speed from top to bottom and repeats - /// - public static void LoopAnimation(this Projectile proj, int speed, int startFrame = 0, int endFrame = -1) - { - if (endFrame == -1) - { - endFrame = Main.projFrames[proj.type] - 1; - } - - LoopAnimationInt(ref proj.frame, ref proj.frameCounter, speed, startFrame, endFrame); - } - - /// - /// Same as LoopAnimation, but stops at the last frame. Returns true if still animating - /// - public static bool WaterfallAnimation(this NPC npc, int frameHeight, int speed, int startFrame = 0, int endFrame = -1) - { - //If no endFrame specified: take last frame on the sheet, otherwise, endFrame - bool lastFrame = (endFrame == -1 && npc.frame.Y * frameHeight >= Main.npcFrameCount[npc.type] - 1) || (endFrame != -1); - - bool stillAnimating = !lastFrame; - if (stillAnimating) npc.LoopAnimation(frameHeight, speed, startFrame, endFrame); - return stillAnimating; - } - - /// - /// Same as LoopAnimation, but stops at the last frame. Returns true if still animating - /// - public static bool WaterfallAnimation(this Projectile proj, int speed, int startFrame = 0, int endFrame = -1) - { - //If no endFrame specified: take last frame on the sheet, otherwise, endFrame - bool lastFrame = (endFrame == -1 && proj.frame >= Main.projFrames[proj.type] - 1) || (endFrame != -1); - - bool stillAnimating = !lastFrame; - if (stillAnimating) proj.LoopAnimation(speed, startFrame, endFrame); - return stillAnimating; - } - } + /// + /// contains Extensions for some basic tasks + /// + public static class AssExtensions + { + /// + /// Returns the average value between the RGB (ignoring A) + /// + public static float GetAverage(this Color color) + { + return (color.R + color.G + color.B) / 3f; + } + + /// + /// Returns the Player that owns the given projectile. Only use if you are certain an owner exists and it is a player + /// + public static Player GetOwner(this Projectile proj) + { + return Main.player[proj.owner]; + } + + /// + /// Copy of vanilla code for spawning a single pet and setting buffTime. Gives random velocity at spawn + /// + /// + /// + /// + /// + /// + public static void AssSpawnPetIfNeededAndSetTime(this Player player, int buffIndex, ref bool petBool, int petProjID, int buffTimeToGive = 18000) + { + player.buffTime[buffIndex] = buffTimeToGive; + player.AssSpawnPetIfNeeded(ref petBool, petProjID, buffIndex); + } + + /// + /// Player.HasItem + checks all banks + /// + /// + /// + /// + public static bool HasItemWithBanks(this Player player, int type) + { + if (player.HasItem(type)) return true; + + Item[][] inventoryArray = { player.bank.item, player.bank2.item, player.bank3.item, player.bank4.item }; + for (int i = 0; i < inventoryArray.Length; i++) + { + Item[] inventory = inventoryArray[i]; + for (int j = 0; j < inventory.Length; j++) + { + Item item = inventory[j]; + if (type == item.type && item.stack > 0) return true; + } + } + + return false; + } + + /// + /// Checks if given item is present in the players inventory or equip slots + /// + public static bool ItemInInventoryOrEquipped(this Player player, Item item, bool ignoreVanity = false) + { + if (player.HasItem(item.type)) return true; + if (item.accessory || item.headSlot > 0 || item.bodySlot > 0 || item.legSlot > 0) + { + int maxLength = ignoreVanity ? 10 : player.armor.Length; + for (int i = 0; i < maxLength; i++) + { + if (player.armor[i].type == item.type) return true; + } + } + return false; + } + + /// + /// Copy of vanilla code for spawning a single pet. Gives random velocity at spawn + /// + /// + /// + /// + /// + public static void AssSpawnPetIfNeeded(this Player player, ref bool petBool, int petProjID, int buffIndex) + { + petBool = true; + if (player.ownedProjectileCounts[petProjID] > 0) + { + return; + } + + if (player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center, -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2), petProjID, 0, 0f, player.whoAmI); + } + } + + public static void LoopAnimation(ref int frame, ref double frameCounter, int speed, int startFrame, int endFrame) + { + if (startFrame < 0) + { + startFrame = 0; + } + + if (frame < startFrame) + { + frame = startFrame; + } + else if (frame > endFrame) + { + frame = endFrame; + } + + frameCounter++; + if (frameCounter >= speed) + { + frameCounter = 0; + frame++; + if (frame > endFrame) + { + frame = startFrame; + } + } + } + + public static void LoopAnimationInt(ref int frame, ref int frameCounter, int speed, int startFrame, int endFrame) + { + if (startFrame < 0) + { + startFrame = 0; + } + + if (frame < startFrame) + { + frame = startFrame; + } + else if (frame > endFrame) + { + frame = endFrame; + } + + frameCounter++; + if (frameCounter >= speed) + { + frameCounter = 0; + frame++; + if (frame > endFrame) + { + frame = startFrame; + } + } + } + + /// + /// Loops through all frames in a set speed from top to bottom and repeats + /// + public static void LoopAnimation(this NPC npc, int frameHeight, int speed, int startFrame = 0, int endFrame = -1) + { + if (endFrame == -1) + { + endFrame = Main.npcFrameCount[npc.type] - 1; + } + + int frame = npc.frame.Y / frameHeight; + LoopAnimation(ref frame, ref npc.frameCounter, speed, startFrame, endFrame); + npc.frame.Y = frame * frameHeight; + } + + /// + /// Loops through all frames in a set speed from top to bottom and repeats + /// + public static void LoopAnimation(this Projectile proj, int speed, int startFrame = 0, int endFrame = -1) + { + if (endFrame == -1) + { + endFrame = Main.projFrames[proj.type] - 1; + } + + LoopAnimationInt(ref proj.frame, ref proj.frameCounter, speed, startFrame, endFrame); + } + + /// + /// Same as LoopAnimation, but stops at the last frame. Returns true if still animating + /// + public static bool WaterfallAnimation(this NPC npc, int frameHeight, int speed, int startFrame = 0, int endFrame = -1) + { + //If no endFrame specified: take last frame on the sheet, otherwise, endFrame + bool lastFrame = (endFrame == -1 && npc.frame.Y * frameHeight >= Main.npcFrameCount[npc.type] - 1) || (endFrame != -1); + + bool stillAnimating = !lastFrame; + if (stillAnimating) npc.LoopAnimation(frameHeight, speed, startFrame, endFrame); + return stillAnimating; + } + + /// + /// Same as LoopAnimation, but stops at the last frame. Returns true if still animating + /// + public static bool WaterfallAnimation(this Projectile proj, int speed, int startFrame = 0, int endFrame = -1) + { + //If no endFrame specified: take last frame on the sheet, otherwise, endFrame + bool lastFrame = (endFrame == -1 && proj.frame >= Main.projFrames[proj.type] - 1) || (endFrame != -1); + + bool stillAnimating = !lastFrame; + if (stillAnimating) proj.LoopAnimation(speed, startFrame, endFrame); + return stillAnimating; + } + } } diff --git a/Base/AssUtils.cs b/Base/AssUtils.cs index 03e763a1..63c85a00 100644 --- a/Base/AssUtils.cs +++ b/Base/AssUtils.cs @@ -11,646 +11,646 @@ namespace AssortedCrazyThings.Base { - static class AssUtils - { - /// - /// The instance of the mod - /// - public static AssortedCrazyThings Instance => ModContent.GetInstance(); //just shorter writing AssUtils.Instance than AssortedCrazyThings.Instance - - /// - /// Types of modded NPCs which names are ending with Body or Tail - /// - public static int[] isModdedWormBodyOrTail; - - public static void Print(object o) - { - if (Main.netMode == NetmodeID.Server) - { - Console.WriteLine(o.ToString()); - } - - if (Main.netMode == NetmodeID.MultiplayerClient || Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(o.ToString()); - } - } - - public static void UIText(string str, Color color) - { - CombatText.NewText(Main.LocalPlayer.getRect(), color, str); - } - - public static Dust QuickDust(int dustType, Vector2 pos, Color color, Vector2 dustVelo = default(Vector2), int alpha = 0, float scale = 1f) - { - Dust dust = Dust.NewDustPerfect(pos, dustType, dustVelo, alpha, color, scale); - dust.position = pos; - dust.velocity = dustVelo; - dust.fadeIn = 1f; - dust.noLight = false; - dust.noGravity = true; - return dust; - } - - public static void QuickDustLine(int dustType, Vector2 start, Vector2 end, float splits, Color color = default(Color), Vector2 dustVelo = default(Vector2), int alpha = 0, float scale = 1f) - { - QuickDust(dustType, start, color, dustVelo); - float num = 1f / splits; - for (float num2 = 0f; num2 < 1f; num2 += num) - { - QuickDust(dustType, Vector2.Lerp(start, end, num2), color, dustVelo, alpha, scale); - } - } - - /// - /// Something similar to Dust.QuickDust - /// - public static Dust DrawDustAtPos(Vector2 pos, int dustType = 169) - { - //used for showing a position as a dust for debugging - Dust dust = QuickDust(dustType, pos, Color.White); - dust.noGravity = true; - dust.noLight = true; - return dust; - } - - public static void DrawSkeletronLikeArms(string texString, Vector2 selfPos, Vector2 centerPos, float selfPad = 0f, float centerPad = 0f, float direction = 0f) - { - DrawSkeletronLikeArms(ModContent.Request(texString).Value, selfPos, centerPos, selfPad, centerPad, direction); - } - - /// - /// Draws two "arms" originating from selfPos, "attached" at centerPos - /// - public static void DrawSkeletronLikeArms(Texture2D tex, Vector2 selfPos, Vector2 centerPos, float selfPad = 0f, float centerPad = 0f, float direction = 0f) - { - //with all float params = 0f, the arm will originate below the selfPos - //Pos parameters should be Entity.Center - //Pad parameters are actually just y offsets - //direction determines in what direction the elbow bends and by how much (-1 to 1 are preferred) - //if (tex == null) tex = Main.boneArmTexture; - Vector2 drawPos = selfPos; - drawPos += new Vector2(-5f * direction, selfPad); - centerPos.Y += -tex.Height / 2 + centerPad; - for (int i = 0; i < 2; i++) - { - float x = centerPos.X - drawPos.X; - float y = centerPos.Y - drawPos.Y; - float magnitude; - if (i == 0) //first arm piece starting at selfPos - { - x += -(100 + tex.Height) * direction; - y += 100 + tex.Width; - magnitude = (float)Math.Sqrt(x * x + y * y); - magnitude = tex.Height / 2 / magnitude; - drawPos.X += x * magnitude; - drawPos.Y += y * magnitude; - } - else //second arm piece - { - x += -(30 + tex.Width / 2) * direction; - y += 30 + tex.Height / 2; - magnitude = (float)Math.Sqrt(x * x + y * y); - magnitude = tex.Height / 2 / magnitude; - drawPos.X += x * magnitude; - drawPos.Y += y * magnitude; - } - float rotation = (float)Math.Atan2(y, x) - 1.57f; - Color color = Lighting.GetColor((int)drawPos.X / 16, (int)(drawPos.Y / 16f)); - Main.spriteBatch.Draw(tex, new Vector2(drawPos.X - Main.screenPosition.X, drawPos.Y - Main.screenPosition.Y), tex.Bounds, color, rotation, tex.Bounds.Size() / 2, 1f, SpriteEffects.None, 0f); - if (i == 0) - { - //padding for the second arm piece - drawPos.X += x * magnitude * 1.1f; - drawPos.Y += y * magnitude * 1.1f; - } - else if (Main.instance.IsActive) //not sure what this part does - { - drawPos.X += x * magnitude - 16f; - drawPos.Y += y * magnitude - 6f; - } - } - } - - public static void DrawTether(string texString, Vector2 start, Vector2 end) - { - DrawTether(ModContent.Request(texString).Value, start, end); - } - - //Credit to IDGCaptainRussia - /// - /// Draws a "connection" between two points - /// - public static void DrawTether(Texture2D tex, Vector2 start, Vector2 end) - { - Vector2 position = start; - Vector2 mountedCenter = end; - float num1 = tex.Height; - Vector2 vector2_4 = mountedCenter - position; - Vector2 vector2_4tt = mountedCenter - position; - float keepgoing = vector2_4tt.Length(); - Vector2 vector2t = vector2_4; - vector2t.Normalize(); - position -= vector2t * (num1 * 0.5f); - - float rotation = vector2_4.ToRotation() - 1.57f; - bool flag = true; - if (float.IsNaN(position.X) && float.IsNaN(position.Y)) - flag = false; - if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y)) - flag = false; - while (flag) - { - if (keepgoing <= -1) - { - flag = false; - } - else - { - Vector2 vector2_1 = vector2_4; - vector2_1.Normalize(); - position += vector2_1 * num1; - keepgoing -= num1; - vector2_4 = mountedCenter - position; - Color color2 = Lighting.GetColor((int)position.X / 16, (int)position.Y / 16); - color2 = new Color(color2.R, color2.G, color2.B, 255); - Main.spriteBatch.Draw(tex, position - Main.screenPosition, new Rectangle(0, 0, tex.Width, (int)Math.Min(num1, num1 + keepgoing)), color2, rotation, tex.Bounds.Size() / 2, 1f, SpriteEffects.None, 0.0f); - } - } - } - - /// - /// Combines two arrays (first + second in order) - /// - public static T[] ConcatArray(T[] first, T[] second) - { - T[] combined = new T[first.Length + second.Length]; - Array.Copy(first, combined, first.Length); - Array.Copy(second, 0, combined, first.Length, second.Length); - return combined; - } - - /// - /// Fills an array with a default value. - /// If array is null, creates one with the length specified. - /// Else, overrides each element with default value - /// - public static void FillWithDefault(ref T[] array, T def, int length = -1) - { - if (array == null) - { - if (length == -1) - throw new ArgumentOutOfRangeException("Array is null but length isn't specified"); - array = new T[length]; - } - else - { - length = array.Length; - } - - for (int i = 0; i < length; i++) - { - array[i] = def; - } - } - - /// - /// Fills a list with a default value. - /// If array is null, creates one with the length specified. - /// Else, overrides each element with default value - /// - public static void FillWithDefault(ref List list, T def, int length = -1) - { - if (list == null) - { - if (length == -1) - throw new ArgumentOutOfRangeException("List is null but length isn't specified"); - list = new List(length); - } - else - { - length = list.Count; - } - - for (int i = 0; i < length; i++) - { - list.Add(def); - } - } - - /// - /// Like NPC.AnyNPC, but checks for each type in the passed array. - /// If one exists, returns true - /// - public static bool AnyNPCs(int[] types) - { - //Like AnyNPCs but checks for an array - for (int i = 0; i < types.Length; i++) - { - if (NPC.AnyNPCs(types[i])) return true; - } - return false; - } - - /// - /// Like NPC.AnyNPC, but checks for each type in the passed list. - /// If one exists, returns true - /// - public static bool AnyNPCs(List types) - { - return AnyNPCs(types.ToArray()); - } - - /// - /// Like NPC.AnyNPC, but checks for custom condition (active already true). - /// If one exists, returns true - /// - public static bool AnyNPCs(Func condition) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && condition(Main.npc[i])) return true; - } - return false; - } - - /// - /// Counts all NPCs in the passed array - /// - public static int CountAllNPCs(int[] types) - { - int count = 0; - for (int i = 0; i < types.Length; i++) - { - count += NPC.CountNPCS(types[i]); - } - return count; - } - - /// - /// Counts all active projectiles of the given type, and of a given owner if specified - /// - public static int CountProjs(int type, int owner = -1) - { - int count = 0; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.type == type && - (owner < 0 || proj.owner == owner)) - { - count++; - } - } - return count; - } - - /// - /// Checks if given NPC is a worm body or tail - /// - public static bool IsWormBodyOrTail(NPC npc) - { - return npc.dontCountMe || Array.BinarySearch(isModdedWormBodyOrTail, npc.type) >= 0 || npc.type == NPCID.EaterofWorldsTail || npc.type == NPCID.EaterofWorldsBody/* || npc.realLife != -1*/; - } - - /// - /// Checks if player is in an evil biome (any of three) - /// - public static bool EvilBiome(Player player) - { - return player.ZoneCorrupt || player.ZoneCrimson || player.ZoneHallow; - } - - /// - /// Formats Main.time into a string representation with AM/PM - /// - public static string GetTimeAsString(bool accurate = true) - { - string suffix = "AM"; - double doubletime = Main.time; - if (!Main.dayTime) - { - doubletime += 54000.0; - } - doubletime = doubletime / 86400.0 * 24.0; - double wtf = 7.5; - doubletime = doubletime - wtf - 12.0; - if (doubletime < 0.0) - { - doubletime += 24.0; - } - if (doubletime >= 12.0) - { - suffix = "PM"; - } - int hours = (int)doubletime; - double doubleminutes = doubletime - hours; - doubleminutes = (int)(doubleminutes * 60.0); - string minutes = string.Concat(doubleminutes); - if (doubleminutes < 10.0) - { - minutes = "0" + minutes; - } - if (hours > 12) - { - hours -= 12; - } - if (hours == 0) - { - hours = 12; - } - if (!accurate) minutes = (!(doubleminutes < 30.0)) ? "30" : "00"; - return Language.GetTextValue("Game.Time", hours + ":" + minutes + " " + suffix); - } - - public static string GetMoonPhaseAsString(bool showNumber = false) - { - string suffix = ""; - if (showNumber) suffix = " (" + (Main.moonPhase + 1) + ")"; - string prefix = Lang.inter[102].Value + ": "; //can't seem to find "Moon Phase" in the lang files for GameUI - string value = ""; - string check = ""; - switch (Main.moonPhase) - { - case 0: - check = "FullMoon"; - break; - case 1: - check = "WaningGibbous"; - break; - case 2: - check = "ThirdQuarter"; - break; - case 3: - check = "WaningCrescent"; - break; - case 4: - check = "NewMoon"; - break; - case 5: - check = "WaxingCrescent"; - break; - case 6: - check = "FirstQuarter"; - break; - case 7: - check = "WaxingGibbous"; - break; - default: - break; - } - value = Language.GetTextValue("GameUI." + check); - if (value != "") return prefix + value + suffix; - return ""; - } - - /// - /// Alternative NewProjectile, automatically sets owner to Main.myPlayer. - /// Also doesn't take into account vanilla projectiles that set things like ai or timeLeft, so only use this for ModProjectiles. - /// Use preCreate if you want to spawn or not spawn the projectile based on the projectile itself. - /// Use preSync to set ai[0], ai[1] and other values - /// - public static int NewProjectile(IEntitySource source, Vector2 position, Vector2 velocity, int Type, int Damage, float Knockback, Func preCreate = null, Action preSync = null) - { - return NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, Type, Damage, Knockback, preCreate, preSync); - } - - /// - /// Alternative NewProjectile, automatically sets owner to Main.myPlayer. - /// Also doesn't take into account vanilla projectiles that set things like ai or timeLeft, so only use this for ModProjectiles. - /// Use preCreate if you want to spawn or not spawn the projectile based on the projectile itself. - /// Use preSync to set ai[0], ai[1] and other values - /// - public static int NewProjectile(IEntitySource source, float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float Knockback, Func preCreate = null, Action preSync = null) - { - if (preCreate != null) - { - Projectile test = new Projectile(); - test.SetDefaults(Type); - if (!preCreate(test)) return Main.maxProjectiles; - } - - int index = Main.maxProjectiles; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (!Main.projectile[i].active) - { - index = i; - break; - } - } - - if (index == Main.maxProjectiles) - index = Projectile.FindOldestProjectile(); - - int Owner = Main.myPlayer; - float ai0 = 0f; - float ai1 = 0f; - - Projectile projectile = Main.projectile[index]; - projectile.SetDefaults(Type); - projectile.position.X = X - projectile.width * 0.5f; - projectile.position.Y = Y - projectile.height * 0.5f; - projectile.owner = Owner; - projectile.velocity.X = SpeedX; - projectile.velocity.Y = SpeedY; - projectile.damage = Damage; - projectile.knockBack = Knockback; - projectile.identity = index; - projectile.gfxOffY = 0f; - projectile.stepSpeed = 1f; - projectile.wet = Collision.WetCollision(projectile.position, projectile.width, projectile.height); - if (projectile.ignoreWater) - { - projectile.wet = false; - } - projectile.honeyWet = Collision.honey; - Main.projectileIdentity[Owner, index] = index; - FindBannerToAssociateTo(source, projectile); - HandlePlayerStatModifiers(source, projectile); - projectile.ai[0] = ai0; - projectile.ai[1] = ai1; - if (Type > 0) - { - if (ProjectileID.Sets.NeedsUUID[Type]) - { - projectile.projUUID = projectile.identity; - } - } - - preSync?.Invoke(projectile); - - if (Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.SyncProjectile, number: index); - } - return index; - } - - /// - /// If you need immediate sync, usually necessary outside of Projectile.AI (as netUpdate is set to false before it's invoked) - /// - /// - public static void NetSync(this Projectile projectile) - { - if (Main.myPlayer == projectile.owner) - { - NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, projectile.whoAmI); - projectile.netSpam = 0; - projectile.netUpdate = false; - projectile.netUpdate2 = false; - } - } - - //Clone from vanilla since it's private - private static void FindBannerToAssociateTo(IEntitySource spawnSource, Projectile next) - { - EntitySource_Parent entitySource_Parent = spawnSource as EntitySource_Parent; - if (entitySource_Parent == null) - { - return; - } - - Projectile projectile = entitySource_Parent.Entity as Projectile; - if (projectile != null) - { - next.bannerIdToRespondTo = projectile.bannerIdToRespondTo; - return; - } - - NPC nPC = entitySource_Parent.Entity as NPC; - if (nPC != null) - { - next.bannerIdToRespondTo = Item.NPCtoBanner(nPC.BannerID()); - } - } - - //Clone from tml since it's private, may need updates, keep an eye out - private static void HandlePlayerStatModifiers(IEntitySource spawnSource, Projectile projectile) - { - if (spawnSource is EntitySource_ItemUse itemUseSource && itemUseSource.Entity is Player player) - { - projectile.CritChance += player.GetWeaponCrit(itemUseSource.Item); - projectile.ArmorPenetration += player.GetWeaponArmorPenetration(itemUseSource.Item); - } - } - - /// - /// Alternative, static version of npc.DropItemInstanced. Checks the playerCondition delegate before syncing/spawning the item - /// - public static void DropItemInstanced(NPC npc, Vector2 Position, Vector2 HitboxSize, int itemType, int itemStack = 1, Func condition = null, bool interactionRequired = true) - { - if (itemType > 0) - { - if (Main.netMode == NetmodeID.Server) - { - int item = Item.NewItem(npc.GetItemSource_Loot(), (int)Position.X, (int)Position.Y, (int)HitboxSize.X, (int)HitboxSize.Y, itemType, itemStack, true); - Main.timeItemSlotCannotBeReusedFor[item] = 54000; - for (int p = 0; p < Main.maxPlayers; p++) - { - if (Main.player[p].active && (npc.playerInteraction[p] || !interactionRequired)) - { - if (condition != null && condition(npc, Main.player[p]) || - condition == null) - NetMessage.SendData(MessageID.InstancedItem, p, -1, null, item); - } - } - Main.item[item].active = false; - } - else if (Main.netMode == NetmodeID.SinglePlayer) - { - if (condition != null && condition(npc, Main.LocalPlayer) || - condition == null) - Item.NewItem(npc.GetItemSource_Loot(), (int)Position.X, (int)Position.Y, (int)HitboxSize.X, (int)HitboxSize.Y, itemType, itemStack); - } - //npc.value = 0f; - } - } - - /// - /// Draws the _Highlight texture of this tile if it exists and can be drawn - /// - /// - /// - /// - /// - /// Color the tile is drawn with - /// - /// - public static void DrawTileHighlight(SpriteBatch spriteBatch, int i, int j, int type, Color color, Vector2 pos, Rectangle frame) - { - if (TileID.Sets.HasOutlines[type] && Collision.InTileBounds(i, j, Main.TileInteractionLX, Main.TileInteractionLY, Main.TileInteractionHX, Main.TileInteractionHY) && Main.SmartInteractTileCoords.Contains(new Point(i, j))) - { - int average = (int)color.GetAverage(); - bool selected = false; - if (Main.SmartInteractTileCoordsSelected.Contains(new Point(i, j))) - { - selected = true; - } - if (average > 10) - { - Texture2D outlineTexture = TextureAssets.HighlightMask[type].Value; - Color outlineColor; - if (selected) - { - outlineColor = new Color(average, average, average / 3, average); - } - else - { - outlineColor = new Color(average / 2, average / 2, average / 2, average); - } - - if (outlineTexture != null) - { - spriteBatch.Draw(outlineTexture, pos, frame, outlineColor, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); - } - } - } - } - - /// - /// Modify the velocity (that has the direction from position to targetPos) of something that is affected by gravity in a way that it will still reach targetPos - ///
Note: This might increase the length of velocity depending on how much correction was needed, use offsetCap to limit it.
- ///
- /// Starting location - /// Target location - /// Gravity applied to velocity.Y - /// Starting velocity - /// Amount of initial ticks that velocity should NOT be updated by gravity - /// Terminal velocity.Y - /// Multiplier for final correction to velocity. 1f == perfect, 0f == none - public static void ModifyVelocityForGravity(Vector2 position, Vector2 targetPos, in float gravity, ref Vector2 velocity, int ticksWithoutGravity = 0, float terminalCap = 16f, float factor = 1f, float offsetCap = 2.5f) - { - //Need to make the velocity + gravity hit targetPos.Y - //Keep horizontal velocity, correct vertical velocity to account for gravity - - Vector2 toTarget = targetPos - position; - int ticksToReachX = (int)(toTarget.X / velocity.X); //"Simulated time" it takes to reach target - - float traversedDistanceY = 0; - float traversedDistanceYNoGravity = 0; - float velocityYWithGravity = velocity.Y; - for (int i = 0; i < ticksToReachX; i++) - { - if (i >= ticksWithoutGravity) - { - velocityYWithGravity += gravity; - if (velocityYWithGravity > terminalCap) - { - velocityYWithGravity = terminalCap; - } - } - traversedDistanceY += velocityYWithGravity; - traversedDistanceYNoGravity += velocity.Y; - } - - float offsetY = traversedDistanceY - traversedDistanceYNoGravity; - - float velocityYOffset = offsetY / ticksToReachX; - - velocityYOffset = Math.Min(velocityYOffset, offsetCap); - - velocity.Y -= factor * velocityYOffset; - } - } + static class AssUtils + { + /// + /// The instance of the mod + /// + public static AssortedCrazyThings Instance => ModContent.GetInstance(); //just shorter writing AssUtils.Instance than AssortedCrazyThings.Instance + + /// + /// Types of modded NPCs which names are ending with Body or Tail + /// + public static int[] isModdedWormBodyOrTail; + + public static void Print(object o) + { + if (Main.netMode == NetmodeID.Server) + { + Console.WriteLine(o.ToString()); + } + + if (Main.netMode == NetmodeID.MultiplayerClient || Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(o.ToString()); + } + } + + public static void UIText(string str, Color color) + { + CombatText.NewText(Main.LocalPlayer.getRect(), color, str); + } + + public static Dust QuickDust(int dustType, Vector2 pos, Color color, Vector2 dustVelo = default(Vector2), int alpha = 0, float scale = 1f) + { + Dust dust = Dust.NewDustPerfect(pos, dustType, dustVelo, alpha, color, scale); + dust.position = pos; + dust.velocity = dustVelo; + dust.fadeIn = 1f; + dust.noLight = false; + dust.noGravity = true; + return dust; + } + + public static void QuickDustLine(int dustType, Vector2 start, Vector2 end, float splits, Color color = default(Color), Vector2 dustVelo = default(Vector2), int alpha = 0, float scale = 1f) + { + QuickDust(dustType, start, color, dustVelo); + float num = 1f / splits; + for (float num2 = 0f; num2 < 1f; num2 += num) + { + QuickDust(dustType, Vector2.Lerp(start, end, num2), color, dustVelo, alpha, scale); + } + } + + /// + /// Something similar to Dust.QuickDust + /// + public static Dust DrawDustAtPos(Vector2 pos, int dustType = 169) + { + //used for showing a position as a dust for debugging + Dust dust = QuickDust(dustType, pos, Color.White); + dust.noGravity = true; + dust.noLight = true; + return dust; + } + + public static void DrawSkeletronLikeArms(string texString, Vector2 selfPos, Vector2 centerPos, float selfPad = 0f, float centerPad = 0f, float direction = 0f) + { + DrawSkeletronLikeArms(ModContent.Request(texString).Value, selfPos, centerPos, selfPad, centerPad, direction); + } + + /// + /// Draws two "arms" originating from selfPos, "attached" at centerPos + /// + public static void DrawSkeletronLikeArms(Texture2D tex, Vector2 selfPos, Vector2 centerPos, float selfPad = 0f, float centerPad = 0f, float direction = 0f) + { + //with all float params = 0f, the arm will originate below the selfPos + //Pos parameters should be Entity.Center + //Pad parameters are actually just y offsets + //direction determines in what direction the elbow bends and by how much (-1 to 1 are preferred) + //if (tex == null) tex = Main.boneArmTexture; + Vector2 drawPos = selfPos; + drawPos += new Vector2(-5f * direction, selfPad); + centerPos.Y += -tex.Height / 2 + centerPad; + for (int i = 0; i < 2; i++) + { + float x = centerPos.X - drawPos.X; + float y = centerPos.Y - drawPos.Y; + float magnitude; + if (i == 0) //first arm piece starting at selfPos + { + x += -(100 + tex.Height) * direction; + y += 100 + tex.Width; + magnitude = (float)Math.Sqrt(x * x + y * y); + magnitude = tex.Height / 2 / magnitude; + drawPos.X += x * magnitude; + drawPos.Y += y * magnitude; + } + else //second arm piece + { + x += -(30 + tex.Width / 2) * direction; + y += 30 + tex.Height / 2; + magnitude = (float)Math.Sqrt(x * x + y * y); + magnitude = tex.Height / 2 / magnitude; + drawPos.X += x * magnitude; + drawPos.Y += y * magnitude; + } + float rotation = (float)Math.Atan2(y, x) - 1.57f; + Color color = Lighting.GetColor((int)drawPos.X / 16, (int)(drawPos.Y / 16f)); + Main.spriteBatch.Draw(tex, new Vector2(drawPos.X - Main.screenPosition.X, drawPos.Y - Main.screenPosition.Y), tex.Bounds, color, rotation, tex.Bounds.Size() / 2, 1f, SpriteEffects.None, 0f); + if (i == 0) + { + //padding for the second arm piece + drawPos.X += x * magnitude * 1.1f; + drawPos.Y += y * magnitude * 1.1f; + } + else if (Main.instance.IsActive) //not sure what this part does + { + drawPos.X += x * magnitude - 16f; + drawPos.Y += y * magnitude - 6f; + } + } + } + + public static void DrawTether(string texString, Vector2 start, Vector2 end) + { + DrawTether(ModContent.Request(texString).Value, start, end); + } + + //Credit to IDGCaptainRussia + /// + /// Draws a "connection" between two points + /// + public static void DrawTether(Texture2D tex, Vector2 start, Vector2 end) + { + Vector2 position = start; + Vector2 mountedCenter = end; + float num1 = tex.Height; + Vector2 vector2_4 = mountedCenter - position; + Vector2 vector2_4tt = mountedCenter - position; + float keepgoing = vector2_4tt.Length(); + Vector2 vector2t = vector2_4; + vector2t.Normalize(); + position -= vector2t * (num1 * 0.5f); + + float rotation = vector2_4.ToRotation() - 1.57f; + bool flag = true; + if (float.IsNaN(position.X) && float.IsNaN(position.Y)) + flag = false; + if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y)) + flag = false; + while (flag) + { + if (keepgoing <= -1) + { + flag = false; + } + else + { + Vector2 vector2_1 = vector2_4; + vector2_1.Normalize(); + position += vector2_1 * num1; + keepgoing -= num1; + vector2_4 = mountedCenter - position; + Color color2 = Lighting.GetColor((int)position.X / 16, (int)position.Y / 16); + color2 = new Color(color2.R, color2.G, color2.B, 255); + Main.spriteBatch.Draw(tex, position - Main.screenPosition, new Rectangle(0, 0, tex.Width, (int)Math.Min(num1, num1 + keepgoing)), color2, rotation, tex.Bounds.Size() / 2, 1f, SpriteEffects.None, 0.0f); + } + } + } + + /// + /// Combines two arrays (first + second in order) + /// + public static T[] ConcatArray(T[] first, T[] second) + { + T[] combined = new T[first.Length + second.Length]; + Array.Copy(first, combined, first.Length); + Array.Copy(second, 0, combined, first.Length, second.Length); + return combined; + } + + /// + /// Fills an array with a default value. + /// If array is null, creates one with the length specified. + /// Else, overrides each element with default value + /// + public static void FillWithDefault(ref T[] array, T def, int length = -1) + { + if (array == null) + { + if (length == -1) + throw new ArgumentOutOfRangeException("Array is null but length isn't specified"); + array = new T[length]; + } + else + { + length = array.Length; + } + + for (int i = 0; i < length; i++) + { + array[i] = def; + } + } + + /// + /// Fills a list with a default value. + /// If array is null, creates one with the length specified. + /// Else, overrides each element with default value + /// + public static void FillWithDefault(ref List list, T def, int length = -1) + { + if (list == null) + { + if (length == -1) + throw new ArgumentOutOfRangeException("List is null but length isn't specified"); + list = new List(length); + } + else + { + length = list.Count; + } + + for (int i = 0; i < length; i++) + { + list.Add(def); + } + } + + /// + /// Like NPC.AnyNPC, but checks for each type in the passed array. + /// If one exists, returns true + /// + public static bool AnyNPCs(int[] types) + { + //Like AnyNPCs but checks for an array + for (int i = 0; i < types.Length; i++) + { + if (NPC.AnyNPCs(types[i])) return true; + } + return false; + } + + /// + /// Like NPC.AnyNPC, but checks for each type in the passed list. + /// If one exists, returns true + /// + public static bool AnyNPCs(List types) + { + return AnyNPCs(types.ToArray()); + } + + /// + /// Like NPC.AnyNPC, but checks for custom condition (active already true). + /// If one exists, returns true + /// + public static bool AnyNPCs(Func condition) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && condition(Main.npc[i])) return true; + } + return false; + } + + /// + /// Counts all NPCs in the passed array + /// + public static int CountAllNPCs(int[] types) + { + int count = 0; + for (int i = 0; i < types.Length; i++) + { + count += NPC.CountNPCS(types[i]); + } + return count; + } + + /// + /// Counts all active projectiles of the given type, and of a given owner if specified + /// + public static int CountProjs(int type, int owner = -1) + { + int count = 0; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.type == type && + (owner < 0 || proj.owner == owner)) + { + count++; + } + } + return count; + } + + /// + /// Checks if given NPC is a worm body or tail + /// + public static bool IsWormBodyOrTail(NPC npc) + { + return npc.dontCountMe || Array.BinarySearch(isModdedWormBodyOrTail, npc.type) >= 0 || npc.type == NPCID.EaterofWorldsTail || npc.type == NPCID.EaterofWorldsBody/* || npc.realLife != -1*/; + } + + /// + /// Checks if player is in an evil biome (any of three) + /// + public static bool EvilBiome(Player player) + { + return player.ZoneCorrupt || player.ZoneCrimson || player.ZoneHallow; + } + + /// + /// Formats Main.time into a string representation with AM/PM + /// + public static string GetTimeAsString(bool accurate = true) + { + string suffix = "AM"; + double doubletime = Main.time; + if (!Main.dayTime) + { + doubletime += 54000.0; + } + doubletime = doubletime / 86400.0 * 24.0; + double wtf = 7.5; + doubletime = doubletime - wtf - 12.0; + if (doubletime < 0.0) + { + doubletime += 24.0; + } + if (doubletime >= 12.0) + { + suffix = "PM"; + } + int hours = (int)doubletime; + double doubleminutes = doubletime - hours; + doubleminutes = (int)(doubleminutes * 60.0); + string minutes = string.Concat(doubleminutes); + if (doubleminutes < 10.0) + { + minutes = "0" + minutes; + } + if (hours > 12) + { + hours -= 12; + } + if (hours == 0) + { + hours = 12; + } + if (!accurate) minutes = (!(doubleminutes < 30.0)) ? "30" : "00"; + return Language.GetTextValue("Game.Time", hours + ":" + minutes + " " + suffix); + } + + public static string GetMoonPhaseAsString(bool showNumber = false) + { + string suffix = ""; + if (showNumber) suffix = " (" + (Main.moonPhase + 1) + ")"; + string prefix = Lang.inter[102].Value + ": "; //can't seem to find "Moon Phase" in the lang files for GameUI + string value = ""; + string check = ""; + switch (Main.moonPhase) + { + case 0: + check = "FullMoon"; + break; + case 1: + check = "WaningGibbous"; + break; + case 2: + check = "ThirdQuarter"; + break; + case 3: + check = "WaningCrescent"; + break; + case 4: + check = "NewMoon"; + break; + case 5: + check = "WaxingCrescent"; + break; + case 6: + check = "FirstQuarter"; + break; + case 7: + check = "WaxingGibbous"; + break; + default: + break; + } + value = Language.GetTextValue("GameUI." + check); + if (value != "") return prefix + value + suffix; + return ""; + } + + /// + /// Alternative NewProjectile, automatically sets owner to Main.myPlayer. + /// Also doesn't take into account vanilla projectiles that set things like ai or timeLeft, so only use this for ModProjectiles. + /// Use preCreate if you want to spawn or not spawn the projectile based on the projectile itself. + /// Use preSync to set ai[0], ai[1] and other values + /// + public static int NewProjectile(IEntitySource source, Vector2 position, Vector2 velocity, int Type, int Damage, float Knockback, Func preCreate = null, Action preSync = null) + { + return NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, Type, Damage, Knockback, preCreate, preSync); + } + + /// + /// Alternative NewProjectile, automatically sets owner to Main.myPlayer. + /// Also doesn't take into account vanilla projectiles that set things like ai or timeLeft, so only use this for ModProjectiles. + /// Use preCreate if you want to spawn or not spawn the projectile based on the projectile itself. + /// Use preSync to set ai[0], ai[1] and other values + /// + public static int NewProjectile(IEntitySource source, float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float Knockback, Func preCreate = null, Action preSync = null) + { + if (preCreate != null) + { + Projectile test = new Projectile(); + test.SetDefaults(Type); + if (!preCreate(test)) return Main.maxProjectiles; + } + + int index = Main.maxProjectiles; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!Main.projectile[i].active) + { + index = i; + break; + } + } + + if (index == Main.maxProjectiles) + index = Projectile.FindOldestProjectile(); + + int Owner = Main.myPlayer; + float ai0 = 0f; + float ai1 = 0f; + + Projectile projectile = Main.projectile[index]; + projectile.SetDefaults(Type); + projectile.position.X = X - projectile.width * 0.5f; + projectile.position.Y = Y - projectile.height * 0.5f; + projectile.owner = Owner; + projectile.velocity.X = SpeedX; + projectile.velocity.Y = SpeedY; + projectile.damage = Damage; + projectile.knockBack = Knockback; + projectile.identity = index; + projectile.gfxOffY = 0f; + projectile.stepSpeed = 1f; + projectile.wet = Collision.WetCollision(projectile.position, projectile.width, projectile.height); + if (projectile.ignoreWater) + { + projectile.wet = false; + } + projectile.honeyWet = Collision.honey; + Main.projectileIdentity[Owner, index] = index; + FindBannerToAssociateTo(source, projectile); + HandlePlayerStatModifiers(source, projectile); + projectile.ai[0] = ai0; + projectile.ai[1] = ai1; + if (Type > 0) + { + if (ProjectileID.Sets.NeedsUUID[Type]) + { + projectile.projUUID = projectile.identity; + } + } + + preSync?.Invoke(projectile); + + if (Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.SyncProjectile, number: index); + } + return index; + } + + /// + /// If you need immediate sync, usually necessary outside of Projectile.AI (as netUpdate is set to false before it's invoked) + /// + /// + public static void NetSync(this Projectile projectile) + { + if (Main.myPlayer == projectile.owner) + { + NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, projectile.whoAmI); + projectile.netSpam = 0; + projectile.netUpdate = false; + projectile.netUpdate2 = false; + } + } + + //Clone from vanilla since it's private + private static void FindBannerToAssociateTo(IEntitySource spawnSource, Projectile next) + { + EntitySource_Parent entitySource_Parent = spawnSource as EntitySource_Parent; + if (entitySource_Parent == null) + { + return; + } + + Projectile projectile = entitySource_Parent.Entity as Projectile; + if (projectile != null) + { + next.bannerIdToRespondTo = projectile.bannerIdToRespondTo; + return; + } + + NPC nPC = entitySource_Parent.Entity as NPC; + if (nPC != null) + { + next.bannerIdToRespondTo = Item.NPCtoBanner(nPC.BannerID()); + } + } + + //Clone from tml since it's private, may need updates, keep an eye out + private static void HandlePlayerStatModifiers(IEntitySource spawnSource, Projectile projectile) + { + if (spawnSource is EntitySource_ItemUse itemUseSource && itemUseSource.Entity is Player player) + { + projectile.CritChance += player.GetWeaponCrit(itemUseSource.Item); + projectile.ArmorPenetration += player.GetWeaponArmorPenetration(itemUseSource.Item); + } + } + + /// + /// Alternative, static version of npc.DropItemInstanced. Checks the playerCondition delegate before syncing/spawning the item + /// + public static void DropItemInstanced(NPC npc, Vector2 Position, Vector2 HitboxSize, int itemType, int itemStack = 1, Func condition = null, bool interactionRequired = true) + { + if (itemType > 0) + { + if (Main.netMode == NetmodeID.Server) + { + int item = Item.NewItem(npc.GetItemSource_Loot(), (int)Position.X, (int)Position.Y, (int)HitboxSize.X, (int)HitboxSize.Y, itemType, itemStack, true); + Main.timeItemSlotCannotBeReusedFor[item] = 54000; + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && (npc.playerInteraction[p] || !interactionRequired)) + { + if (condition != null && condition(npc, Main.player[p]) || + condition == null) + NetMessage.SendData(MessageID.InstancedItem, p, -1, null, item); + } + } + Main.item[item].active = false; + } + else if (Main.netMode == NetmodeID.SinglePlayer) + { + if (condition != null && condition(npc, Main.LocalPlayer) || + condition == null) + Item.NewItem(npc.GetItemSource_Loot(), (int)Position.X, (int)Position.Y, (int)HitboxSize.X, (int)HitboxSize.Y, itemType, itemStack); + } + //npc.value = 0f; + } + } + + /// + /// Draws the _Highlight texture of this tile if it exists and can be drawn + /// + /// + /// + /// + /// + /// Color the tile is drawn with + /// + /// + public static void DrawTileHighlight(SpriteBatch spriteBatch, int i, int j, int type, Color color, Vector2 pos, Rectangle frame) + { + if (TileID.Sets.HasOutlines[type] && Collision.InTileBounds(i, j, Main.TileInteractionLX, Main.TileInteractionLY, Main.TileInteractionHX, Main.TileInteractionHY) && Main.SmartInteractTileCoords.Contains(new Point(i, j))) + { + int average = (int)color.GetAverage(); + bool selected = false; + if (Main.SmartInteractTileCoordsSelected.Contains(new Point(i, j))) + { + selected = true; + } + if (average > 10) + { + Texture2D outlineTexture = TextureAssets.HighlightMask[type].Value; + Color outlineColor; + if (selected) + { + outlineColor = new Color(average, average, average / 3, average); + } + else + { + outlineColor = new Color(average / 2, average / 2, average / 2, average); + } + + if (outlineTexture != null) + { + spriteBatch.Draw(outlineTexture, pos, frame, outlineColor, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + } + } + } + } + + /// + /// Modify the velocity (that has the direction from position to targetPos) of something that is affected by gravity in a way that it will still reach targetPos + ///
Note: This might increase the length of velocity depending on how much correction was needed, use offsetCap to limit it.
+ ///
+ /// Starting location + /// Target location + /// Gravity applied to velocity.Y + /// Starting velocity + /// Amount of initial ticks that velocity should NOT be updated by gravity + /// Terminal velocity.Y + /// Multiplier for final correction to velocity. 1f == perfect, 0f == none + public static void ModifyVelocityForGravity(Vector2 position, Vector2 targetPos, in float gravity, ref Vector2 velocity, int ticksWithoutGravity = 0, float terminalCap = 16f, float factor = 1f, float offsetCap = 2.5f) + { + //Need to make the velocity + gravity hit targetPos.Y + //Keep horizontal velocity, correct vertical velocity to account for gravity + + Vector2 toTarget = targetPos - position; + int ticksToReachX = (int)(toTarget.X / velocity.X); //"Simulated time" it takes to reach target + + float traversedDistanceY = 0; + float traversedDistanceYNoGravity = 0; + float velocityYWithGravity = velocity.Y; + for (int i = 0; i < ticksToReachX; i++) + { + if (i >= ticksWithoutGravity) + { + velocityYWithGravity += gravity; + if (velocityYWithGravity > terminalCap) + { + velocityYWithGravity = terminalCap; + } + } + traversedDistanceY += velocityYWithGravity; + traversedDistanceYNoGravity += velocity.Y; + } + + float offsetY = traversedDistanceY - traversedDistanceYNoGravity; + + float velocityYOffset = offsetY / ticksToReachX; + + velocityYOffset = Math.Min(velocityYOffset, offsetCap); + + velocity.Y -= factor * velocityYOffset; + } + } } diff --git a/Base/Data/ModTypeIdentity.cs b/Base/Data/ModTypeIdentity.cs index d116a8c9..b39203d9 100644 --- a/Base/Data/ModTypeIdentity.cs +++ b/Base/Data/ModTypeIdentity.cs @@ -7,17 +7,17 @@ namespace AssortedCrazyThings.Base.Data ///
You will need "public static readonly Func DESERIALIZER = Load;" in inheriting classes
/// public abstract class ModTypeIdentity : TagSerializable - { + { public string ModName { get; private set; } public string Name { get; private set; } - public ModTypeIdentity(string modName, string name) - { + public ModTypeIdentity(string modName, string name) + { ModName = modName; Name = name; - } + } - public override string ToString() => "ModName: " + ModName + "; Name: " + Name; + public override string ToString() => "ModName: " + ModName + "; Name: " + Name; public virtual TagCompound SerializeData() { diff --git a/Base/Data/PetAccessoryIdentity.cs b/Base/Data/PetAccessoryIdentity.cs index 98afb8fd..7fb6e80b 100644 --- a/Base/Data/PetAccessoryIdentity.cs +++ b/Base/Data/PetAccessoryIdentity.cs @@ -3,12 +3,12 @@ namespace AssortedCrazyThings.Base.Data { - public class PetAccessoryIdentity : ModTypeIdentity, TagSerializable - { + public class PetAccessoryIdentity : ModTypeIdentity, TagSerializable + { public byte AltTextureIndex { get; set; } - public PetAccessoryIdentity(string modName, string name, byte altTextureIndex) : base(modName, name) - { + public PetAccessoryIdentity(string modName, string name, byte altTextureIndex) : base(modName, name) + { AltTextureIndex = altTextureIndex; } diff --git a/Base/DrawLayers/CrazyBundleOfAssortedBalloonsLayer.cs b/Base/DrawLayers/CrazyBundleOfAssortedBalloonsLayer.cs index 483c2726..3646dba0 100644 --- a/Base/DrawLayers/CrazyBundleOfAssortedBalloonsLayer.cs +++ b/Base/DrawLayers/CrazyBundleOfAssortedBalloonsLayer.cs @@ -9,69 +9,69 @@ namespace AssortedCrazyThings.Base.DrawLayers { - [Content(ContentType.Accessories)] - public class CrazyBundleOfAssortedBalloonsLayer : AssPlayerLayer - { - private Asset balloonTexture; + [Content(ContentType.Accessories)] + public class CrazyBundleOfAssortedBalloonsLayer : AssPlayerLayer + { + private Asset balloonTexture; - public override void Load() - { - if (!Main.dedServ) - { - balloonTexture = Mod.Assets.Request("Items/Accessories/Useful/CrazyBundleOfAssortedBalloons_Balloon_Proper"); - } - } + public override void Load() + { + if (!Main.dedServ) + { + balloonTexture = Mod.Assets.Request("Items/Accessories/Useful/CrazyBundleOfAssortedBalloons_Balloon_Proper"); + } + } - public override void Unload() - { - balloonTexture = null; - } + public override void Unload() + { + balloonTexture = null; + } - public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead) - { - return false; - } + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + if (drawInfo.shadow != 0f || drawPlayer.dead) + { + return false; + } - return drawPlayer.balloon == Mod.GetEquipSlot(nameof(CrazyBundleOfAssortedBalloons), EquipType.Balloon); - } + return drawPlayer.balloon == Mod.GetEquipSlot(nameof(CrazyBundleOfAssortedBalloons), EquipType.Balloon); + } - public override Position GetDefaultPosition() - { - return new AfterParent(PlayerDrawLayers.BalloonAcc); - } + public override Position GetDefaultPosition() + { + return new AfterParent(PlayerDrawLayers.BalloonAcc); + } - protected override void Draw(ref PlayerDrawSet drawInfo) - { - //Since it's supposed to replace the Autoload texture, the regular _Balloon is just blank - Player drawPlayer = drawInfo.drawPlayer; + protected override void Draw(ref PlayerDrawSet drawInfo) + { + //Since it's supposed to replace the Autoload texture, the regular _Balloon is just blank + Player drawPlayer = drawInfo.drawPlayer; - int frameY = (Main.hasFocus && (!Main.ingameOptionsWindow || !Main.autoPause)) ? (DateTime.Now.Millisecond % 800 / 200) : 0; - Vector2 handOffset = Main.OffsetsPlayerOffhand[drawPlayer.bodyFrame.Y / 56]; - if (drawPlayer.direction != 1) - { - handOffset.X = drawPlayer.width - handOffset.X; - } + int frameY = (Main.hasFocus && (!Main.ingameOptionsWindow || !Main.autoPause)) ? (DateTime.Now.Millisecond % 800 / 200) : 0; + Vector2 handOffset = Main.OffsetsPlayerOffhand[drawPlayer.bodyFrame.Y / 56]; + if (drawPlayer.direction != 1) + { + handOffset.X = drawPlayer.width - handOffset.X; + } - if (drawPlayer.gravDir != 1f) - { - handOffset.Y -= drawPlayer.height; - } + if (drawPlayer.gravDir != 1f) + { + handOffset.Y -= drawPlayer.height; + } - Vector2 offset = new Vector2(0f, 8f) + new Vector2(0f, 6f); - offset += new Vector2(0f, -drawPlayer.bodyFrame.Height / 3); //Added so it's higher - Vector2 position = drawInfo.Position - Main.screenPosition + handOffset * new Vector2(1f, drawPlayer.gravDir) + new Vector2(0f, drawPlayer.height - drawPlayer.bodyFrame.Height) + offset; - position = position.Floor(); + Vector2 offset = new Vector2(0f, 8f) + new Vector2(0f, 6f); + offset += new Vector2(0f, -drawPlayer.bodyFrame.Height / 3); //Added so it's higher + Vector2 position = drawInfo.Position - Main.screenPosition + handOffset * new Vector2(1f, drawPlayer.gravDir) + new Vector2(0f, drawPlayer.height - drawPlayer.bodyFrame.Height) + offset; + position = position.Floor(); - Rectangle frame = balloonTexture.Frame(1, 4, 0, frameY); - Vector2 origin = new Vector2(26 + drawPlayer.direction * 4, 28f + drawPlayer.gravDir * 6f); - DrawData data = new DrawData(balloonTexture.Value, position, frame, drawInfo.colorArmorBody, drawPlayer.bodyRotation, origin, 1f, drawInfo.playerEffect, 0) - { - shader = drawInfo.cBalloon - }; - drawInfo.DrawDataCache.Add(data); - } - } + Rectangle frame = balloonTexture.Frame(1, 4, 0, frameY); + Vector2 origin = new Vector2(26 + drawPlayer.direction * 4, 28f + drawPlayer.gravDir * 6f); + DrawData data = new DrawData(balloonTexture.Value, position, frame, drawInfo.colorArmorBody, drawPlayer.bodyRotation, origin, 1f, drawInfo.playerEffect, 0) + { + shader = drawInfo.cBalloon + }; + drawInfo.DrawDataCache.Add(data); + } + } } diff --git a/Base/DrawLayers/HarvesterWingsLayer.cs b/Base/DrawLayers/HarvesterWingsLayer.cs index 5b57cf3b..28f0abca 100644 --- a/Base/DrawLayers/HarvesterWingsLayer.cs +++ b/Base/DrawLayers/HarvesterWingsLayer.cs @@ -8,88 +8,88 @@ namespace AssortedCrazyThings.Base.DrawLayers { - [Content(ContentType.Bosses)] - public class HarvesterWingsLayer : AssPlayerLayer - { - private Asset wingAsset; - private Asset glowAsset; + [Content(ContentType.Bosses)] + public class HarvesterWingsLayer : AssPlayerLayer + { + private Asset wingAsset; + private Asset glowAsset; - public override void Load() - { - if (!Main.dedServ) - { - string common = "Items/Accessories/Useful/HarvesterWings_Wings"; - wingAsset = Mod.Assets.Request(common + "_Proper"); - glowAsset = Mod.Assets.Request(common + "_Glowmask"); - } - } + public override void Load() + { + if (!Main.dedServ) + { + string common = "Items/Accessories/Useful/HarvesterWings_Wings"; + wingAsset = Mod.Assets.Request(common + "_Proper"); + glowAsset = Mod.Assets.Request(common + "_Glowmask"); + } + } - public override void Unload() - { - wingAsset = null; - glowAsset = null; - } + public override void Unload() + { + wingAsset = null; + glowAsset = null; + } - public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (drawPlayer.dead) - { - return false; - } + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + if (drawPlayer.dead) + { + return false; + } - return drawInfo.drawPlayer.wings == Mod.GetEquipSlot(nameof(HarvesterWings), EquipType.Wings); - } + return drawInfo.drawPlayer.wings == Mod.GetEquipSlot(nameof(HarvesterWings), EquipType.Wings); + } - public override Position GetDefaultPosition() - { - return new AfterParent(PlayerDrawLayers.Wings); - } + public override Position GetDefaultPosition() + { + return new AfterParent(PlayerDrawLayers.Wings); + } - protected override void Draw(ref PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; + protected override void Draw(ref PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; - Asset asset = wingAsset; + Asset asset = wingAsset; - Vector2 directions = drawPlayer.Directions; - Vector2 offset = new Vector2(0f, 7f); + Vector2 directions = drawPlayer.Directions; + Vector2 offset = new Vector2(0f, 7f); - //bonus bobbing - Rectangle bobFrame = drawInfo.drawPlayer.bodyFrame; - offset += Main.OffsetsPlayerHeadgear[bobFrame.Y / bobFrame.Height] * drawPlayer.gravDir; + //bonus bobbing + Rectangle bobFrame = drawInfo.drawPlayer.bodyFrame; + offset += Main.OffsetsPlayerHeadgear[bobFrame.Y / bobFrame.Height] * drawPlayer.gravDir; - Vector2 position = drawInfo.Position - Main.screenPosition + new Vector2(drawPlayer.width / 2, drawPlayer.height - drawPlayer.bodyFrame.Height / 2) + offset; + Vector2 position = drawInfo.Position - Main.screenPosition + new Vector2(drawPlayer.width / 2, drawPlayer.height - drawPlayer.bodyFrame.Height / 2) + offset; - int num11 = -5; - int num12 = -7; - int numFrames = HarvesterWings.NumFrames; + int num11 = -5; + int num12 = -7; + int numFrames = HarvesterWings.NumFrames; - Color color = drawInfo.colorArmorBody; + Color color = drawInfo.colorArmorBody; - position += new Vector2(num12 - 9, num11 + 2) * directions; - position = position.Floor(); - int totalHeight = asset.Height(); - int totalWidth = asset.Width(); - Rectangle frame = new Rectangle(0, totalHeight / numFrames * drawPlayer.wingFrame, totalWidth, totalHeight / numFrames); - Vector2 origin = new Vector2(totalWidth / 2, totalHeight / numFrames / 2); - float bodyRotation = drawPlayer.bodyRotation; - SpriteEffects playerEffect = drawInfo.playerEffect; - Texture2D texture = asset.Value; - DrawData data = new DrawData(texture, position, frame, color, (float)bodyRotation, origin, 1f, playerEffect, 0) - { - shader = drawInfo.cWings - }; - drawInfo.DrawDataCache.Add(data); + position += new Vector2(num12 - 9, num11 + 2) * directions; + position = position.Floor(); + int totalHeight = asset.Height(); + int totalWidth = asset.Width(); + Rectangle frame = new Rectangle(0, totalHeight / numFrames * drawPlayer.wingFrame, totalWidth, totalHeight / numFrames); + Vector2 origin = new Vector2(totalWidth / 2, totalHeight / numFrames / 2); + float bodyRotation = drawPlayer.bodyRotation; + SpriteEffects playerEffect = drawInfo.playerEffect; + Texture2D texture = asset.Value; + DrawData data = new DrawData(texture, position, frame, color, (float)bodyRotation, origin, 1f, playerEffect, 0) + { + shader = drawInfo.cWings + }; + drawInfo.DrawDataCache.Add(data); - asset = glowAsset; - texture = asset.Value; - color = drawPlayer.GetImmuneAlpha(Color.White, drawInfo.shadow); - data = new DrawData(texture, position, frame, color, (float)bodyRotation, origin, 1f, playerEffect, 0) - { - shader = drawInfo.cWings - }; - drawInfo.DrawDataCache.Add(data); - } - } + asset = glowAsset; + texture = asset.Value; + color = drawPlayer.GetImmuneAlpha(Color.White, drawInfo.shadow); + data = new DrawData(texture, position, frame, color, (float)bodyRotation, origin, 1f, playerEffect, 0) + { + shader = drawInfo.cWings + }; + drawInfo.DrawDataCache.Add(data); + } + } } diff --git a/Base/DrawLayers/SlimeHandlerKnapsackLayer.cs b/Base/DrawLayers/SlimeHandlerKnapsackLayer.cs index dab41fe9..93a90a47 100644 --- a/Base/DrawLayers/SlimeHandlerKnapsackLayer.cs +++ b/Base/DrawLayers/SlimeHandlerKnapsackLayer.cs @@ -8,52 +8,52 @@ namespace AssortedCrazyThings.Base.DrawLayers { - [Content(ContentType.Weapons)] - public class SlimeHandlerKnapsackLayer : AssPlayerLayer - { - private Asset knapsackTexture; - - public override void Load() - { - if (!Main.dedServ) - { - knapsackTexture = Mod.Assets.Request("Items/Weapons/SlimeHandlerKnapsack_Back"); - } - } - - public override void Unload() - { - knapsackTexture = null; - } - - public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead) - { - return false; - } - - return (drawPlayer.wings == 0 || drawPlayer.velocity.Y == 0f) && drawInfo.drawPlayer.HeldItem?.type == ModContent.ItemType(); - } - - public override Position GetDefaultPosition() - { - return new AfterParent(PlayerDrawLayers.Backpacks); - } - - protected override void Draw(ref PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - - Texture2D texture = knapsackTexture.Value; - - Vector2 offset = new Vector2(0f, 8f); - Vector2 position = drawInfo.Position - Main.screenPosition + drawPlayer.bodyPosition + new Vector2(drawPlayer.width / 2, drawPlayer.height - drawPlayer.bodyFrame.Height / 2) + new Vector2(0f, -4f) + offset; - position = position.Floor(); - - DrawData drawData = new DrawData(texture, position, drawPlayer.bodyFrame, drawInfo.colorArmorBody, drawPlayer.bodyRotation, drawInfo.bodyVect, 1f, drawInfo.playerEffect, 0); - drawInfo.DrawDataCache.Add(drawData); - } - } + [Content(ContentType.Weapons)] + public class SlimeHandlerKnapsackLayer : AssPlayerLayer + { + private Asset knapsackTexture; + + public override void Load() + { + if (!Main.dedServ) + { + knapsackTexture = Mod.Assets.Request("Items/Weapons/SlimeHandlerKnapsack_Back"); + } + } + + public override void Unload() + { + knapsackTexture = null; + } + + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + if (drawInfo.shadow != 0f || drawPlayer.dead) + { + return false; + } + + return (drawPlayer.wings == 0 || drawPlayer.velocity.Y == 0f) && drawInfo.drawPlayer.HeldItem?.type == ModContent.ItemType(); + } + + public override Position GetDefaultPosition() + { + return new AfterParent(PlayerDrawLayers.Backpacks); + } + + protected override void Draw(ref PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + + Texture2D texture = knapsackTexture.Value; + + Vector2 offset = new Vector2(0f, 8f); + Vector2 position = drawInfo.Position - Main.screenPosition + drawPlayer.bodyPosition + new Vector2(drawPlayer.width / 2, drawPlayer.height - drawPlayer.bodyFrame.Height / 2) + new Vector2(0f, -4f) + offset; + position = position.Floor(); + + DrawData drawData = new DrawData(texture, position, drawPlayer.bodyFrame, drawInfo.colorArmorBody, drawPlayer.bodyRotation, drawInfo.bodyVect, 1f, drawInfo.playerEffect, 0); + drawInfo.DrawDataCache.Add(drawData); + } + } } diff --git a/Base/DrawLayers/SwarmDrawLayer.cs b/Base/DrawLayers/SwarmDrawLayer.cs index e41a08ea..6f9a34fb 100644 --- a/Base/DrawLayers/SwarmDrawLayer.cs +++ b/Base/DrawLayers/SwarmDrawLayer.cs @@ -6,64 +6,64 @@ namespace AssortedCrazyThings.Base.DrawLayers { - /// - /// These layers have to get created manually, they are loaded in SwarmDrawSet - /// - [Autoload(false)] //AssPlayerLayer already has false, but just for clarity - public sealed class SwarmDrawLayer : AssPlayerLayer - { - private readonly string name; - public override string Name => name; + /// + /// These layers have to get created manually, they are loaded in SwarmDrawSet + /// + [Autoload(false)] //AssPlayerLayer already has false, but just for clarity + public sealed class SwarmDrawLayer : AssPlayerLayer + { + private readonly string name; + public override string Name => name; - /// - /// No parameterless constructor needed since Autoload is false - /// - public SwarmDrawLayer(string name, bool front, Func getDrawSet) - { - //Important to assign name based on the instance so they won't count as duplicates - this.name = $"{name}_{(front ? "Front" : "Back")}"; - this.front = front; - this.getDrawSet = getDrawSet; - } + /// + /// No parameterless constructor needed since Autoload is false + /// + public SwarmDrawLayer(string name, bool front, Func getDrawSet) + { + //Important to assign name based on the instance so they won't count as duplicates + this.name = $"{name}_{(front ? "Front" : "Back")}"; + this.front = front; + this.getDrawSet = getDrawSet; + } - public bool front; + public bool front; - public Func getDrawSet; + public Func getDrawSet; - public sealed override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (getDrawSet == null || drawInfo.shadow != 0f || drawPlayer.dead) - { - return false; - } + public sealed override bool GetDefaultVisibility(PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + if (getDrawSet == null || drawInfo.shadow != 0f || drawPlayer.dead) + { + return false; + } - return getDrawSet.Invoke(drawPlayer.GetModPlayer())?.Active ?? false; - } + return getDrawSet.Invoke(drawPlayer.GetModPlayer())?.Active ?? false; + } - public sealed override Position GetDefaultPosition() - { - return front ? new AfterParent(PlayerDrawLayers.BeetleBuff) : new BeforeParent(PlayerDrawLayers.JimsCloak); - } + public sealed override Position GetDefaultPosition() + { + return front ? new AfterParent(PlayerDrawLayers.BeetleBuff) : new BeforeParent(PlayerDrawLayers.JimsCloak); + } - protected sealed override void Draw(ref PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; + protected sealed override void Draw(ref PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; - var set = getDrawSet?.Invoke(drawInfo.drawPlayer.GetModPlayer()); + var set = getDrawSet?.Invoke(drawInfo.drawPlayer.GetModPlayer()); - if (set == null || !set.Active) - { - return; - } + if (set == null || !set.Active) + { + return; + } - //First draw the trails - var datas = set.TrailToDrawDatas(drawInfo, front); - drawInfo.DrawDataCache.AddRange(datas); + //First draw the trails + var datas = set.TrailToDrawDatas(drawInfo, front); + drawInfo.DrawDataCache.AddRange(datas); - //Then the actual thing - datas = set.ToDrawDatas(drawInfo, front); - drawInfo.DrawDataCache.AddRange(datas); - } - } + //Then the actual thing + datas = set.ToDrawDatas(drawInfo, front); + drawInfo.DrawDataCache.AddRange(datas); + } + } } diff --git a/Base/Handlers/SpawnedNPCHandler/SpawnedNPCSystem.cs b/Base/Handlers/SpawnedNPCHandler/SpawnedNPCSystem.cs index 6d30bfe2..046e91b3 100644 --- a/Base/Handlers/SpawnedNPCHandler/SpawnedNPCSystem.cs +++ b/Base/Handlers/SpawnedNPCHandler/SpawnedNPCSystem.cs @@ -1,56 +1,55 @@ using Microsoft.Xna.Framework; using System.Collections.Generic; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Base.Handlers.SpawnedNPCHandler { - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - internal class SpawnedNPCSystem : AssSystem - { - private int prevCount; - private HashSet prevIdentities; + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + internal class SpawnedNPCSystem : AssSystem + { + private int prevCount; + private HashSet prevIdentities; - public delegate void SpawnedNPCDelegate(NPC npc); - public static event SpawnedNPCDelegate OnSpawnedNPC; + public delegate void SpawnedNPCDelegate(NPC npc); + public static event SpawnedNPCDelegate OnSpawnedNPC; - public override void OnWorldLoad() - { - prevCount = Main.maxNPCs; //Set to max so that on first tick, if NPCs already exist, it doesn't trigger - prevIdentities = new HashSet(); - } + public override void OnWorldLoad() + { + prevCount = Main.maxNPCs; //Set to max so that on first tick, if NPCs already exist, it doesn't trigger + prevIdentities = new HashSet(); + } - public override void Unload() - { - prevIdentities = null; - } + public override void Unload() + { + prevIdentities = null; + } - public override void PostUpdateNPCs() - { - //Runs on all sides - int curCount = 0; - HashSet currIdentities = new HashSet(); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.active) - { - curCount++; - currIdentities.Add(new Point(i, npc.type)); - } - } + public override void PostUpdateNPCs() + { + //Runs on all sides + int curCount = 0; + HashSet currIdentities = new HashSet(); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active) + { + curCount++; + currIdentities.Add(new Point(i, npc.type)); + } + } - if (prevCount < curCount) - { - currIdentities.ExceptWith(prevIdentities); //Multiple can spawn in the same tick - foreach (var identity in currIdentities) - { - OnSpawnedNPC?.Invoke(Main.npc[identity.X]); - } - } + if (prevCount < curCount) + { + currIdentities.ExceptWith(prevIdentities); //Multiple can spawn in the same tick + foreach (var identity in currIdentities) + { + OnSpawnedNPC?.Invoke(Main.npc[identity.X]); + } + } - prevCount = curCount; - prevIdentities = currIdentities; - } - } + prevCount = curCount; + prevIdentities = currIdentities; + } + } } diff --git a/Base/Handlers/UnreplaceableMinionWith0SlotsHandler/UnreplaceableMinionWith0SlotsModPlayer.cs b/Base/Handlers/UnreplaceableMinionWith0SlotsHandler/UnreplaceableMinionWith0SlotsModPlayer.cs index a4234606..f582401d 100644 --- a/Base/Handlers/UnreplaceableMinionWith0SlotsHandler/UnreplaceableMinionWith0SlotsModPlayer.cs +++ b/Base/Handlers/UnreplaceableMinionWith0SlotsHandler/UnreplaceableMinionWith0SlotsModPlayer.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Base.Handlers.UnreplaceableMinionWith0SlotsHandler { diff --git a/Base/Handlers/UnreplaceableMinionWith0SlotsHandler/UnreplaceableMinionWith0SlotsSystem.cs b/Base/Handlers/UnreplaceableMinionWith0SlotsHandler/UnreplaceableMinionWith0SlotsSystem.cs index 32863533..68efbcdb 100644 --- a/Base/Handlers/UnreplaceableMinionWith0SlotsHandler/UnreplaceableMinionWith0SlotsSystem.cs +++ b/Base/Handlers/UnreplaceableMinionWith0SlotsHandler/UnreplaceableMinionWith0SlotsSystem.cs @@ -2,30 +2,30 @@ namespace AssortedCrazyThings.Base.Handlers.UnreplaceableMinionWith0SlotsHandler { - //Taken with permission from billybobmcbo - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - public class UnreplaceableMinionWith0SlotsSystem : AssSystem + //Taken with permission from billybobmcbo + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + public class UnreplaceableMinionWith0SlotsSystem : AssSystem { private static HashSet Minions; - public static bool Add(int type) - { - return Minions.Add(type); - } + public static bool Add(int type) + { + return Minions.Add(type); + } - public static bool Exists(int type) - { - return Minions.Contains(type); - } + public static bool Exists(int type) + { + return Minions.Contains(type); + } - public override void OnModLoad() - { + public override void OnModLoad() + { Minions = new HashSet(); - } + } - public override void Unload() - { + public override void Unload() + { Minions = null; } - } + } } diff --git a/Base/ModSupport/OtherModCalls.cs b/Base/ModSupport/OtherModCalls.cs index d9d9c40e..8f5c09cd 100644 --- a/Base/ModSupport/OtherModCalls.cs +++ b/Base/ModSupport/OtherModCalls.cs @@ -13,30 +13,30 @@ namespace AssortedCrazyThings.Base.ModSupport { - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - public class OtherModCalls : AssSystem - { - public override void PostSetupContent() - { - //https://forums.terraria.org/index.php?threads/boss-checklist-in-game-progression-checklist.50668/ - if (ContentConfig.Instance.Bosses && ModLoader.TryGetMod("BossChecklist", out Mod bossChecklist)) - { - //5.1f means just after skeletron - if (bossChecklist.Version >= new Version(1, 3, 1)) - { - List collection = new List() - { - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - }; + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + public class OtherModCalls : AssSystem + { + public override void PostSetupContent() + { + //https://forums.terraria.org/index.php?threads/boss-checklist-in-game-progression-checklist.50668/ + if (ContentConfig.Instance.Bosses && ModLoader.TryGetMod("BossChecklist", out Mod bossChecklist)) + { + //5.1f means just after skeletron + if (bossChecklist.Version >= new Version(1, 3, 1)) + { + List collection = new List() + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + }; - int summonItem = ModContent.ItemType(); + int summonItem = ModContent.ItemType(); - //TODO harvester, include 15 x ModContent.ItemType() in loot but dont spawn it + //TODO harvester, include 15 x ModContent.ItemType() in loot but dont spawn it - /* + /* * "AddBoss", args[1] as Mod, // Mod args[2] as string, // Boss Name @@ -50,57 +50,57 @@ public override void PostSetupContent() InterpretObjectAsStringFunction(args[10]), // Despawn message args[11] as Action // Custom Drawing */ - bossChecklist.Call( - "AddBoss", - Mod, - Harvester.name, - AssortedCrazyThings.harvester, - 5.1f, - (Func)(() => AssWorld.downedHarvester), - (Func)(() => true), - collection, - summonItem, - $"Enter the dungeon for the first time, or use a [i:{summonItem}] in the dungeon" - ); - } - } + bossChecklist.Call( + "AddBoss", + Mod, + Harvester.name, + AssortedCrazyThings.harvester, + 5.1f, + (Func)(() => AssWorld.downedHarvester), + (Func)(() => true), + collection, + summonItem, + $"Enter the dungeon for the first time, or use a [i:{summonItem}] in the dungeon" + ); + } + } - if (ModLoader.TryGetMod("SummonersAssociation", out Mod summonersAssociation) && summonersAssociation.Version > new Version(0, 4, 1)) - { - if (ContentConfig.Instance.Bosses) - { - int soulBuff = ModContent.BuffType(); - summonersAssociation.Call("AddMinionInfo", ModContent.ItemType(), soulBuff, ModContent.ProjectileType()); + if (ModLoader.TryGetMod("SummonersAssociation", out Mod summonersAssociation) && summonersAssociation.Version > new Version(0, 4, 1)) + { + if (ContentConfig.Instance.Bosses) + { + int soulBuff = ModContent.BuffType(); + summonersAssociation.Call("AddMinionInfo", ModContent.ItemType(), soulBuff, ModContent.ProjectileType()); - summonersAssociation.Call("AddMinionInfo", ModContent.ItemType(), soulBuff, new List - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); - } + summonersAssociation.Call("AddMinionInfo", ModContent.ItemType(), soulBuff, new List + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }); + } - if (ContentConfig.Instance.Weapons) - { - List slimes = new List() - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - }; - - summonersAssociation.Call("AddMinionInfo", ModContent.ItemType(), ModContent.BuffType(), slimes); + if (ContentConfig.Instance.Weapons) + { + List slimes = new List() + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + }; - List drones = new List(); - foreach (var drone in DroneController.DataList) - { - drones.Add(drone.ProjType); - } + summonersAssociation.Call("AddMinionInfo", ModContent.ItemType(), ModContent.BuffType(), slimes); - summonersAssociation.Call("AddMinionInfo", ModContent.ItemType(), ModContent.BuffType(), drones); - } - } - } - } + List drones = new List(); + foreach (var drone in DroneController.DataList) + { + drones.Add(drone.ProjType); + } + + summonersAssociation.Call("AddMinionInfo", ModContent.ItemType(), ModContent.BuffType(), drones); + } + } + } + } } diff --git a/Base/SlimeHugs/SlimeHug.cs b/Base/SlimeHugs/SlimeHug.cs index 96bab679..2e53c129 100644 --- a/Base/SlimeHugs/SlimeHug.cs +++ b/Base/SlimeHugs/SlimeHug.cs @@ -6,75 +6,75 @@ namespace AssortedCrazyThings.Base.SlimeHugs { - [Content(ContentType.CuteSlimes)] - [Autoload(false)] - public abstract class SlimeHug : ModType, ICloneable, IComparable - { - public virtual int HugDuration => 120; + [Content(ContentType.CuteSlimes)] + [Autoload(false)] + public abstract class SlimeHug : ModType, ICloneable, IComparable + { + public virtual int HugDuration => 120; - public virtual int HugEmote => EmoteID.EmotionLove; + public virtual int HugEmote => EmoteID.EmotionLove; - public virtual int HugEmoteDuration => 120; + public virtual int HugEmoteDuration => 120; - public virtual int PreHugEmote => -1; + public virtual int PreHugEmote => -1; - public virtual int PreHugEmoteDuration => 60; + public virtual int PreHugEmoteDuration => 60; - protected virtual int Cooldown => 60 * 60 * 10; //10 minutes + protected virtual int Cooldown => 60 * 60 * 10; //10 minutes - public int Type { get; internal set; } + public int Type { get; internal set; } - public int CooldownTimer { get; private set; } + public int CooldownTimer { get; private set; } - protected override void Register() - { - Type = SlimeHugLoader.Register(this); - } + protected override void Register() + { + Type = SlimeHugLoader.Register(this); + } - /// - /// Brings the hug closer to triggering. Returns true if ready - /// - internal bool HandleCooldown() - { - if (CooldownTimer < Cooldown) - { - CooldownTimer++; - } - return CooldownTimer == Cooldown; - } + /// + /// Brings the hug closer to triggering. Returns true if ready + /// + internal bool HandleCooldown() + { + if (CooldownTimer < Cooldown) + { + CooldownTimer++; + } + return CooldownTimer == Cooldown; + } - /// - /// Resets the cooldown - /// - internal void ApplyCooldown() - { - CooldownTimer = 0; - } + /// + /// Resets the cooldown + /// + internal void ApplyCooldown() + { + CooldownTimer = 0; + } - /// - /// Allows customizing under which conditions this (ready) hug should be applied - /// - public virtual bool IsAvailable(CuteSlimeBaseProj slime, PetPlayer petPlayer) - { - return true; - } + /// + /// Allows customizing under which conditions this (ready) hug should be applied + /// + public virtual bool IsAvailable(CuteSlimeBaseProj slime, PetPlayer petPlayer) + { + return true; + } - /// - /// Allows customizing where the slime will be positioned during a hug - /// - public virtual Vector2 GetHugOffset(CuteSlimeBaseProj slime, PetPlayer petPlayer) - { - return default; - } + /// + /// Allows customizing where the slime will be positioned during a hug + /// + public virtual Vector2 GetHugOffset(CuteSlimeBaseProj slime, PetPlayer petPlayer) + { + return default; + } - public object Clone() - { - return MemberwiseClone(); - } + public object Clone() + { + return MemberwiseClone(); + } - public int CompareTo(SlimeHug other) - { - return Cooldown.CompareTo(other.Cooldown); - } - } + public int CompareTo(SlimeHug other) + { + return Cooldown.CompareTo(other.Cooldown); + } + } } diff --git a/Base/SlimeHugs/SlimeHugAle.cs b/Base/SlimeHugs/SlimeHugAle.cs index a83c4920..75aa4528 100644 --- a/Base/SlimeHugs/SlimeHugAle.cs +++ b/Base/SlimeHugs/SlimeHugAle.cs @@ -5,19 +5,19 @@ namespace AssortedCrazyThings.Base.SlimeHugs { - public class SlimeHugAle : SlimeHug - { - protected override int Cooldown => 60 * 60 * 2; - - public override int HugEmote => EmoteID.EmotionLove; + public class SlimeHugAle : SlimeHug + { + protected override int Cooldown => 60 * 60 * 2; - public override int PreHugEmoteDuration => 40; + public override int HugEmote => EmoteID.EmotionLove; - public override int PreHugEmote => EmoteID.ItemAle; + public override int PreHugEmoteDuration => 40; - public override bool IsAvailable(CuteSlimeBaseProj slime, PetPlayer petPlayer) - { - return petPlayer.Player.HeldItem.type == ModContent.ItemType(); - } - } + public override int PreHugEmote => EmoteID.ItemAle; + + public override bool IsAvailable(CuteSlimeBaseProj slime, PetPlayer petPlayer) + { + return petPlayer.Player.HeldItem.type == ModContent.ItemType(); + } + } } diff --git a/Base/SlimeHugs/SlimeHugIdle.cs b/Base/SlimeHugs/SlimeHugIdle.cs index b5e8ea25..02bfbebd 100644 --- a/Base/SlimeHugs/SlimeHugIdle.cs +++ b/Base/SlimeHugs/SlimeHugIdle.cs @@ -1,7 +1,7 @@ namespace AssortedCrazyThings.Base.SlimeHugs { - public class SlimeHugIdle : SlimeHug - { - protected override int Cooldown => 60 * 60 * 10; - } + public class SlimeHugIdle : SlimeHug + { + protected override int Cooldown => 60 * 60 * 10; + } } diff --git a/Base/SlimeHugs/SlimeHugLoader.cs b/Base/SlimeHugs/SlimeHugLoader.cs index bcb450fa..bde1321d 100644 --- a/Base/SlimeHugs/SlimeHugLoader.cs +++ b/Base/SlimeHugs/SlimeHugLoader.cs @@ -3,21 +3,21 @@ namespace AssortedCrazyThings.Base.SlimeHugs { - public static class SlimeHugLoader /*: Loader*/ - { + public static class SlimeHugLoader /*: Loader*/ + { private static List list; internal static List List - { - get - { + { + get + { if (list == null) - { + { list = new List(); - } + } return list; - } - } + } + } public static int Register(SlimeHug obj) { @@ -43,5 +43,5 @@ internal static void Unload() { List.Clear(); } - } + } } diff --git a/Base/SlimeHugs/SlimeHugThunder.cs b/Base/SlimeHugs/SlimeHugThunder.cs index 651e28a7..9630ee21 100644 --- a/Base/SlimeHugs/SlimeHugThunder.cs +++ b/Base/SlimeHugs/SlimeHugThunder.cs @@ -5,31 +5,31 @@ namespace AssortedCrazyThings.Base.SlimeHugs { - public class SlimeHugThunder : SlimeHug - { - protected override int Cooldown => 60 * 60 * 2; + public class SlimeHugThunder : SlimeHug + { + protected override int Cooldown => 60 * 60 * 2; - public override int HugEmote => EmoteID.EmoteSadness; + public override int HugEmote => EmoteID.EmoteSadness; - public override int PreHugEmoteDuration => 40; + public override int PreHugEmoteDuration => 40; - public override int PreHugEmote => Graveyard ? EmoteID.ItemTombstone : Storm ? EmoteID.WeatherStorming : -1; + public override int PreHugEmote => Graveyard ? EmoteID.ItemTombstone : Storm ? EmoteID.WeatherStorming : -1; - public override bool IsAvailable(CuteSlimeBaseProj slime, PetPlayer petPlayer) - { - return petPlayer.Player.position.Y < Main.rockLayer * 16.0 && Main.atmo == 1f && - (Storm || Graveyard); - } + public override bool IsAvailable(CuteSlimeBaseProj slime, PetPlayer petPlayer) + { + return petPlayer.Player.position.Y < Main.rockLayer * 16.0 && Main.atmo == 1f && + (Storm || Graveyard); + } - public override Vector2 GetHugOffset(CuteSlimeBaseProj slime, PetPlayer petPlayer) - { - //Shaking left/right - return new Vector2((petPlayer.slimeHugTimer / 3 % 2 == 0).ToDirectionInt() * 0.8f, 0); - } + public override Vector2 GetHugOffset(CuteSlimeBaseProj slime, PetPlayer petPlayer) + { + //Shaking left/right + return new Vector2((petPlayer.slimeHugTimer / 3 % 2 == 0).ToDirectionInt() * 0.8f, 0); + } - //TODO Untested - public static bool Storm => Main.IsItStorming; + //TODO Untested + public static bool Storm => Main.IsItStorming; - public static bool Graveyard => Main.GraveyardVisualIntensity >= 0.9f; - } + public static bool Graveyard => Main.GraveyardVisualIntensity >= 0.9f; + } } diff --git a/Base/SlimePets.cs b/Base/SlimePets.cs index d7335f7c..714976e7 100644 --- a/Base/SlimePets.cs +++ b/Base/SlimePets.cs @@ -1,277 +1,277 @@ +using AssortedCrazyThings.Base.SlimeHugs; using AssortedCrazyThings.Items.PetAccessories; using AssortedCrazyThings.NPCs.CuteSlimes; +using AssortedCrazyThings.Projectiles.Pets.CuteSlimes; using System; using System.Collections.Generic; using Terraria; -using Terraria.ModLoader; using Terraria.ID; -using AssortedCrazyThings.Projectiles.Pets.CuteSlimes; -using AssortedCrazyThings.Base.SlimeHugs; +using Terraria.ModLoader; using Terraria.ModLoader.Utilities; namespace AssortedCrazyThings.Base { - [Content(ContentType.CuteSlimes)] - public class SlimePets : AssSystem - { - /// - /// Contains every slime pet - /// - internal static List slimePetList; - - /// - /// Look-up table where the key is proj ID and it returns the corresponding SlimePet - /// - private static Dictionary slimePetsByProj; - - /// - /// For the Cute Slime Statue, non-biome ones only - /// - public static List slimePetRegularNPCs; - - /// - /// For the Jellied Ale bufftip - /// - public static List> slimePetNPCsEnumToNames; - - /// - /// To increase cute slime spawns when mods are present and its used with Jellied Ale - /// - public static float spawnIncreaseBasedOnOtherModNPCs = 0f; - - /// - /// Used in CuteSlimeSpawnEnableBuff.ModifyTooltips - /// Since SpawnCondition is unresponsive, implement the conditions manually - /// - public static bool CanSpawn(Player player, SpawnConditionType type) - { - switch (type) - { - case SpawnConditionType.Overworld: - return Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && !AssUtils.EvilBiome(player); - case SpawnConditionType.Desert: - return Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && player.ZoneDesert && !AssUtils.EvilBiome(player); - case SpawnConditionType.Tundra: - return Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && player.ZoneSnow/* && !AssUtils.EvilBiome(player)*/; - case SpawnConditionType.Jungle: - return Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && player.ZoneJungle/* && !AssUtils.EvilBiome(player)*/; - case SpawnConditionType.Underground: - return Main.hardMode && player.ZoneDirtLayerHeight && player.townNPCs < 3f && !AssUtils.EvilBiome(player); - case SpawnConditionType.Hell: - return player.ZoneUnderworldHeight && player.townNPCs < 3f/* && !AssUtils.EvilBiome(player)*/; - case SpawnConditionType.Corruption: - return player.ZoneOverworldHeight && Main.hardMode && (!Main.bloodMoon ? player.ZoneCorrupt : player.ZoneCrimson); - case SpawnConditionType.Crimson: - return player.ZoneOverworldHeight && Main.hardMode && (!Main.bloodMoon ? player.ZoneCrimson : player.ZoneCorrupt); - case SpawnConditionType.Hallow: - return Main.hardMode && !player.ZoneOverworldHeight && player.ZoneHallow && !(player.ZoneCorrupt || player.ZoneCrimson); - case SpawnConditionType.Dungeon: - return player.ZoneDungeon && player.townNPCs < 3f && !AssUtils.EvilBiome(player); - case SpawnConditionType.Xmas: - return Main.xMas && Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && !AssUtils.EvilBiome(player); - default: - return false; - } - } - - /// - /// Used in CuteSlimeSpawnChance, returns the spawn chance based on the SpawnConditionType - /// - public static float GetSpawnChance(Player player, SpawnConditionType type = SpawnConditionType.None) - { - switch (type) - { - case SpawnConditionType.Overworld: - return player.townNPCs < 3f && !AssUtils.EvilBiome(player) ? SpawnCondition.OverworldDaySlime.Chance * 0.0075f : 0f; - case SpawnConditionType.Desert: - return player.townNPCs < 3f && !AssUtils.EvilBiome(player) ? SpawnCondition.OverworldDayDesert.Chance * 0.12f : 0f; - case SpawnConditionType.Tundra: - return player.townNPCs < 3f && player.ZoneSnow ? SpawnCondition.OverworldDaySlime.Chance * 0.06f : 0f; - case SpawnConditionType.Jungle: - return player.townNPCs < 3f && Main.dayTime ? SpawnCondition.SurfaceJungle.Chance * 0.06f : 0f; - case SpawnConditionType.Underground: - return player.townNPCs < 3f && !AssUtils.EvilBiome(player) && Main.hardMode && player.ZoneDirtLayerHeight ? 0.015f : 0f; - case SpawnConditionType.Hell: - return player.townNPCs < 3f ? SpawnCondition.Underworld.Chance * 0.015f : 0f; - case SpawnConditionType.Corruption: - return Main.hardMode && player.ZoneOverworldHeight ? (!Main.bloodMoon ? SpawnCondition.Corruption.Chance * 0.025f : SpawnCondition.Crimson.Chance * 0.025f) : 0f; - case SpawnConditionType.Crimson: - return Main.hardMode && player.ZoneOverworldHeight ? (!Main.bloodMoon ? SpawnCondition.Crimson.Chance * 0.025f : SpawnCondition.Corruption.Chance * 0.025f) : 0f; - case SpawnConditionType.Hallow: - return Main.hardMode && player.ZoneHallow && !(player.ZoneCorrupt || player.ZoneCrimson) && !player.ZoneOverworldHeight ? 0.015f : 0f; - case SpawnConditionType.Dungeon: - return player.townNPCs < 3f && !AssUtils.EvilBiome(player) ? SpawnCondition.DungeonNormal.Chance * 0.025f : 0f; - case SpawnConditionType.Xmas: - return player.townNPCs < 3f && !AssUtils.EvilBiome(player) && Main.xMas ? SpawnCondition.OverworldDaySlime.Chance * 0.05f : 0f; - default: - return 1f; - } - } - - /// - /// Used in ModNPC.SpawnChance. Short way of specifying a spawn chance - /// - public static float CuteSlimeSpawnChance(NPCSpawnInfo spawnInfo, SpawnConditionType type, float customFactor = 1f) - { - //AssUtils.Print("spawn chance at " + (Main.netMode == NetmodeID.Server ? "Server" : "Client")); - float spawnChance = GetSpawnChance(spawnInfo.Player, type) * customFactor; - if (AssUtils.AnyNPCs(x => x.ModNPC is CuteSlimeBaseNPC)) spawnChance *= 0.5f; - //AssUtils.Print(spawnChance); - if (ContentConfig.Instance.CuteSlimesPotionOnly) - { - if (spawnInfo.Player.GetModPlayer().cuteSlimeSpawnEnable) - { - //if flag active and potion, spawn normally - //AssUtils.Print("potiononly and has potion"); - return spawnChance * 1.2f * (1f + spawnIncreaseBasedOnOtherModNPCs); - } - //AssUtils.Print("potiononly and has no potion"); - //if flag active and no potion, don't spawn - return 0f; - } - else - { - if (spawnInfo.Player.GetModPlayer().cuteSlimeSpawnEnable) - { - //if no flag and potion active, spawn with higher chance - //AssUtils.Print("no potiononly and has potion"); - return spawnChance * 3 * 1.2f * (1f + spawnIncreaseBasedOnOtherModNPCs); - } - //AssUtils.Print("no potiononly and has no potion"); - //if no flag and no potion, spawn normally - return spawnChance; - } - } - - public override void OnModLoad() - { - LoadPets(); - - PetAccessory.RegisterAccessories(); - } - - private static void LoadPets() - { - slimePetList = new List(); - slimePetsByProj = new Dictionary(); - //in all these lists, insert stuff in alphabetic order please - - Array enumArray = Enum.GetValues(typeof(SpawnConditionType)); - - AssUtils.FillWithDefault(ref slimePetNPCsEnumToNames, null, enumArray.Length); - slimePetNPCsEnumToNames[(int)SpawnConditionType.Overworld] = new List() { "Black", "Blue", "Green", "Pink", "Purple", "Rainbow", "Red", "Yellow" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Desert] = new List() { "Sand" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Tundra] = new List() { "Ice" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Jungle] = new List() { "Jungle" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Underground] = new List() { "Toxic" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Hell] = new List() { "Lava" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Corruption] = new List() { "Corrupt" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Crimson] = new List() { "Crimson" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Hallow] = new List() { "Illuminant" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Dungeon] = new List() { "Dungeon" }; - slimePetNPCsEnumToNames[(int)SpawnConditionType.Xmas] = new List() { "Xmas" }; - - slimePetRegularNPCs = new List - { - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType() - }; - - //start list - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType(), - postAdditionSlot: (byte)SlotType.Hat - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType(), - postAdditionSlot: (byte)SlotType.Hat - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType(), - postAdditionSlot: (byte)SlotType.Hat - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType(), - postAdditionSlot: (byte)SlotType.Body, - carried: true, - accessory: true - )); - Add(SlimePet.NewSlimePet - ( - type: ModContent.ProjectileType() - )); - - /* + [Content(ContentType.CuteSlimes)] + public class SlimePets : AssSystem + { + /// + /// Contains every slime pet + /// + internal static List slimePetList; + + /// + /// Look-up table where the key is proj ID and it returns the corresponding SlimePet + /// + private static Dictionary slimePetsByProj; + + /// + /// For the Cute Slime Statue, non-biome ones only + /// + public static List slimePetRegularNPCs; + + /// + /// For the Jellied Ale bufftip + /// + public static List> slimePetNPCsEnumToNames; + + /// + /// To increase cute slime spawns when mods are present and its used with Jellied Ale + /// + public static float spawnIncreaseBasedOnOtherModNPCs = 0f; + + /// + /// Used in CuteSlimeSpawnEnableBuff.ModifyTooltips + /// Since SpawnCondition is unresponsive, implement the conditions manually + /// + public static bool CanSpawn(Player player, SpawnConditionType type) + { + switch (type) + { + case SpawnConditionType.Overworld: + return Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && !AssUtils.EvilBiome(player); + case SpawnConditionType.Desert: + return Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && player.ZoneDesert && !AssUtils.EvilBiome(player); + case SpawnConditionType.Tundra: + return Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && player.ZoneSnow/* && !AssUtils.EvilBiome(player)*/; + case SpawnConditionType.Jungle: + return Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && player.ZoneJungle/* && !AssUtils.EvilBiome(player)*/; + case SpawnConditionType.Underground: + return Main.hardMode && player.ZoneDirtLayerHeight && player.townNPCs < 3f && !AssUtils.EvilBiome(player); + case SpawnConditionType.Hell: + return player.ZoneUnderworldHeight && player.townNPCs < 3f/* && !AssUtils.EvilBiome(player)*/; + case SpawnConditionType.Corruption: + return player.ZoneOverworldHeight && Main.hardMode && (!Main.bloodMoon ? player.ZoneCorrupt : player.ZoneCrimson); + case SpawnConditionType.Crimson: + return player.ZoneOverworldHeight && Main.hardMode && (!Main.bloodMoon ? player.ZoneCrimson : player.ZoneCorrupt); + case SpawnConditionType.Hallow: + return Main.hardMode && !player.ZoneOverworldHeight && player.ZoneHallow && !(player.ZoneCorrupt || player.ZoneCrimson); + case SpawnConditionType.Dungeon: + return player.ZoneDungeon && player.townNPCs < 3f && !AssUtils.EvilBiome(player); + case SpawnConditionType.Xmas: + return Main.xMas && Main.dayTime && player.ZoneOverworldHeight && player.townNPCs < 3f && !AssUtils.EvilBiome(player); + default: + return false; + } + } + + /// + /// Used in CuteSlimeSpawnChance, returns the spawn chance based on the SpawnConditionType + /// + public static float GetSpawnChance(Player player, SpawnConditionType type = SpawnConditionType.None) + { + switch (type) + { + case SpawnConditionType.Overworld: + return player.townNPCs < 3f && !AssUtils.EvilBiome(player) ? SpawnCondition.OverworldDaySlime.Chance * 0.0075f : 0f; + case SpawnConditionType.Desert: + return player.townNPCs < 3f && !AssUtils.EvilBiome(player) ? SpawnCondition.OverworldDayDesert.Chance * 0.12f : 0f; + case SpawnConditionType.Tundra: + return player.townNPCs < 3f && player.ZoneSnow ? SpawnCondition.OverworldDaySlime.Chance * 0.06f : 0f; + case SpawnConditionType.Jungle: + return player.townNPCs < 3f && Main.dayTime ? SpawnCondition.SurfaceJungle.Chance * 0.06f : 0f; + case SpawnConditionType.Underground: + return player.townNPCs < 3f && !AssUtils.EvilBiome(player) && Main.hardMode && player.ZoneDirtLayerHeight ? 0.015f : 0f; + case SpawnConditionType.Hell: + return player.townNPCs < 3f ? SpawnCondition.Underworld.Chance * 0.015f : 0f; + case SpawnConditionType.Corruption: + return Main.hardMode && player.ZoneOverworldHeight ? (!Main.bloodMoon ? SpawnCondition.Corruption.Chance * 0.025f : SpawnCondition.Crimson.Chance * 0.025f) : 0f; + case SpawnConditionType.Crimson: + return Main.hardMode && player.ZoneOverworldHeight ? (!Main.bloodMoon ? SpawnCondition.Crimson.Chance * 0.025f : SpawnCondition.Corruption.Chance * 0.025f) : 0f; + case SpawnConditionType.Hallow: + return Main.hardMode && player.ZoneHallow && !(player.ZoneCorrupt || player.ZoneCrimson) && !player.ZoneOverworldHeight ? 0.015f : 0f; + case SpawnConditionType.Dungeon: + return player.townNPCs < 3f && !AssUtils.EvilBiome(player) ? SpawnCondition.DungeonNormal.Chance * 0.025f : 0f; + case SpawnConditionType.Xmas: + return player.townNPCs < 3f && !AssUtils.EvilBiome(player) && Main.xMas ? SpawnCondition.OverworldDaySlime.Chance * 0.05f : 0f; + default: + return 1f; + } + } + + /// + /// Used in ModNPC.SpawnChance. Short way of specifying a spawn chance + /// + public static float CuteSlimeSpawnChance(NPCSpawnInfo spawnInfo, SpawnConditionType type, float customFactor = 1f) + { + //AssUtils.Print("spawn chance at " + (Main.netMode == NetmodeID.Server ? "Server" : "Client")); + float spawnChance = GetSpawnChance(spawnInfo.Player, type) * customFactor; + if (AssUtils.AnyNPCs(x => x.ModNPC is CuteSlimeBaseNPC)) spawnChance *= 0.5f; + //AssUtils.Print(spawnChance); + if (ContentConfig.Instance.CuteSlimesPotionOnly) + { + if (spawnInfo.Player.GetModPlayer().cuteSlimeSpawnEnable) + { + //if flag active and potion, spawn normally + //AssUtils.Print("potiononly and has potion"); + return spawnChance * 1.2f * (1f + spawnIncreaseBasedOnOtherModNPCs); + } + //AssUtils.Print("potiononly and has no potion"); + //if flag active and no potion, don't spawn + return 0f; + } + else + { + if (spawnInfo.Player.GetModPlayer().cuteSlimeSpawnEnable) + { + //if no flag and potion active, spawn with higher chance + //AssUtils.Print("no potiononly and has potion"); + return spawnChance * 3 * 1.2f * (1f + spawnIncreaseBasedOnOtherModNPCs); + } + //AssUtils.Print("no potiononly and has no potion"); + //if no flag and no potion, spawn normally + return spawnChance; + } + } + + public override void OnModLoad() + { + LoadPets(); + + PetAccessory.RegisterAccessories(); + } + + private static void LoadPets() + { + slimePetList = new List(); + slimePetsByProj = new Dictionary(); + //in all these lists, insert stuff in alphabetic order please + + Array enumArray = Enum.GetValues(typeof(SpawnConditionType)); + + AssUtils.FillWithDefault(ref slimePetNPCsEnumToNames, null, enumArray.Length); + slimePetNPCsEnumToNames[(int)SpawnConditionType.Overworld] = new List() { "Black", "Blue", "Green", "Pink", "Purple", "Rainbow", "Red", "Yellow" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Desert] = new List() { "Sand" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Tundra] = new List() { "Ice" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Jungle] = new List() { "Jungle" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Underground] = new List() { "Toxic" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Hell] = new List() { "Lava" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Corruption] = new List() { "Corrupt" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Crimson] = new List() { "Crimson" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Hallow] = new List() { "Illuminant" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Dungeon] = new List() { "Dungeon" }; + slimePetNPCsEnumToNames[(int)SpawnConditionType.Xmas] = new List() { "Xmas" }; + + slimePetRegularNPCs = new List + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + + //start list + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType(), + postAdditionSlot: (byte)SlotType.Hat + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType(), + postAdditionSlot: (byte)SlotType.Hat + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType(), + postAdditionSlot: (byte)SlotType.Hat + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType(), + postAdditionSlot: (byte)SlotType.Body, + carried: true, + accessory: true + )); + Add(SlimePet.NewSlimePet + ( + type: ModContent.ProjectileType() + )); + + /* Add(SlimePet.NewSlimePet ( type: ModContent.ProjectileType(), @@ -294,153 +294,153 @@ private static void LoadPets() * The things listed there are defaults (besides the name and color), so you can omit those if the pet is basic */ - //end list, don't write anything new after this line - - CreateMap(); - } - - public static void Add(SlimePet aSlimePet) - { - for (int i = 0; i < slimePetList.Count; i++) - { - SlimePet slimePet = slimePetList[i]; - if (slimePet.Name == aSlimePet.Name) - throw new Exception("Added Pet '" + aSlimePet.Name + "' already exists"); - } - - slimePetList.Add(aSlimePet); - } - - public override void PostSetupContent() - { - int actcount = 0; - foreach (var item in AssUtils.Instance.GetContent()) - { - actcount++; - } - - int vanillaCount = NPCID.Count; - int diff = NPCLoader.NPCCount - vanillaCount - actcount; - - spawnIncreaseBasedOnOtherModNPCs = diff / (float)vanillaCount; - } - - public override void Unload() - { - UnloadPets(); - - PetAccessory.UnloadAccessories(); - - SlimeHugLoader.Unload(); - } - - private static void UnloadPets() - { - slimePetList = null; - slimePetsByProj = null; - slimePetNPCsEnumToNames = null; - spawnIncreaseBasedOnOtherModNPCs = 0f; - } - - /// - /// Called after Load. Indexes the slime pets - /// - public static void CreateMap() - { - for (int i = 0; i < slimePetList.Count; i++) - { - SlimePet slimePet = slimePetList[i]; - slimePetsByProj[slimePet.Type] = slimePet; - } - } - - /// - /// Used to access the slime pet from just the projectile type - /// - public static bool TryGetPetFromProj(int type, out SlimePet slimePet) - { - return slimePetsByProj.TryGetValue(type, out slimePet); - } - } - - public enum SpawnConditionType : byte - { - None, - Overworld, - Desert, - Tundra, - Jungle, - Underground, - Hell, - Corruption, - Crimson, - Hallow, - Dungeon, - Xmas - } - - /// - /// Contains data about a slime pet - /// - public class SlimePet - { - public string Name { private set; get; } - public int Type { private set; get; } - public byte PreAdditionSlot { private set; get; } - public byte PostAdditionSlot { private set; get; } - public bool[] IsSlotTypeBlacklisted { private set; get; } - - public SlimePet(string name, byte preAdditionSlot = 0, byte postAdditionSlot = 0, List isSlotTypeBlacklisted = null) - { - Name = name; - Type = AssUtils.Instance.Find(name).Type; - if (Type == 0) throw new Exception("Pet projectile called '" + name + "' doesn't exist, are you sure you spelled it correctly?"); - PreAdditionSlot = preAdditionSlot; - PostAdditionSlot = postAdditionSlot; - - if (isSlotTypeBlacklisted != null) - { - if (isSlotTypeBlacklisted.Count != Enum.GetValues(typeof(SlotType)).Length - 1) - throw new Exception("'isSlotTypeBlacklisted' is longer than the amount of accessory slot types"); - else - { - IsSlotTypeBlacklisted = new bool[5]; - IsSlotTypeBlacklisted[(int)SlotType.None] = false; //maybe for later - IsSlotTypeBlacklisted[1] = isSlotTypeBlacklisted[0]; - IsSlotTypeBlacklisted[2] = isSlotTypeBlacklisted[1]; - IsSlotTypeBlacklisted[3] = isSlotTypeBlacklisted[2]; - IsSlotTypeBlacklisted[4] = isSlotTypeBlacklisted[3]; - } - } - else - { - IsSlotTypeBlacklisted = new bool[5]; //all false - } - } - - /// - /// "Sort of" constructor, compresses each blacklist field into a list - /// - public static SlimePet NewSlimePet(string name, byte preAdditionSlot = 0, byte postAdditionSlot = 0, - bool body = false, bool hat = false, bool carried = false, bool accessory = false) - { - List isSlotTypeBlacklisted = new List() { body, hat, carried, accessory }; - - return new SlimePet(name, preAdditionSlot, postAdditionSlot, isSlotTypeBlacklisted); - } - - public static SlimePet NewSlimePet(int type, byte preAdditionSlot = 0, byte postAdditionSlot = 0, - bool body = false, bool hat = false, bool carried = false, bool accessory = false) - { - return NewSlimePet(ModContent.GetModProjectile(type).Name, preAdditionSlot, postAdditionSlot, body, hat, carried, accessory); - } - - public override string ToString() - { - return "Name: " + Name - + "; Type: " + Type - + "; PreAdditionSlot: " + ((SlotType)PreAdditionSlot).ToString() - + "; PostAdditionSlot: " + ((SlotType)PostAdditionSlot).ToString(); - } - } + //end list, don't write anything new after this line + + CreateMap(); + } + + public static void Add(SlimePet aSlimePet) + { + for (int i = 0; i < slimePetList.Count; i++) + { + SlimePet slimePet = slimePetList[i]; + if (slimePet.Name == aSlimePet.Name) + throw new Exception("Added Pet '" + aSlimePet.Name + "' already exists"); + } + + slimePetList.Add(aSlimePet); + } + + public override void PostSetupContent() + { + int actcount = 0; + foreach (var item in AssUtils.Instance.GetContent()) + { + actcount++; + } + + int vanillaCount = NPCID.Count; + int diff = NPCLoader.NPCCount - vanillaCount - actcount; + + spawnIncreaseBasedOnOtherModNPCs = diff / (float)vanillaCount; + } + + public override void Unload() + { + UnloadPets(); + + PetAccessory.UnloadAccessories(); + + SlimeHugLoader.Unload(); + } + + private static void UnloadPets() + { + slimePetList = null; + slimePetsByProj = null; + slimePetNPCsEnumToNames = null; + spawnIncreaseBasedOnOtherModNPCs = 0f; + } + + /// + /// Called after Load. Indexes the slime pets + /// + public static void CreateMap() + { + for (int i = 0; i < slimePetList.Count; i++) + { + SlimePet slimePet = slimePetList[i]; + slimePetsByProj[slimePet.Type] = slimePet; + } + } + + /// + /// Used to access the slime pet from just the projectile type + /// + public static bool TryGetPetFromProj(int type, out SlimePet slimePet) + { + return slimePetsByProj.TryGetValue(type, out slimePet); + } + } + + public enum SpawnConditionType : byte + { + None, + Overworld, + Desert, + Tundra, + Jungle, + Underground, + Hell, + Corruption, + Crimson, + Hallow, + Dungeon, + Xmas + } + + /// + /// Contains data about a slime pet + /// + public class SlimePet + { + public string Name { private set; get; } + public int Type { private set; get; } + public byte PreAdditionSlot { private set; get; } + public byte PostAdditionSlot { private set; get; } + public bool[] IsSlotTypeBlacklisted { private set; get; } + + public SlimePet(string name, byte preAdditionSlot = 0, byte postAdditionSlot = 0, List isSlotTypeBlacklisted = null) + { + Name = name; + Type = AssUtils.Instance.Find(name).Type; + if (Type == 0) throw new Exception("Pet projectile called '" + name + "' doesn't exist, are you sure you spelled it correctly?"); + PreAdditionSlot = preAdditionSlot; + PostAdditionSlot = postAdditionSlot; + + if (isSlotTypeBlacklisted != null) + { + if (isSlotTypeBlacklisted.Count != Enum.GetValues(typeof(SlotType)).Length - 1) + throw new Exception("'isSlotTypeBlacklisted' is longer than the amount of accessory slot types"); + else + { + IsSlotTypeBlacklisted = new bool[5]; + IsSlotTypeBlacklisted[(int)SlotType.None] = false; //maybe for later + IsSlotTypeBlacklisted[1] = isSlotTypeBlacklisted[0]; + IsSlotTypeBlacklisted[2] = isSlotTypeBlacklisted[1]; + IsSlotTypeBlacklisted[3] = isSlotTypeBlacklisted[2]; + IsSlotTypeBlacklisted[4] = isSlotTypeBlacklisted[3]; + } + } + else + { + IsSlotTypeBlacklisted = new bool[5]; //all false + } + } + + /// + /// "Sort of" constructor, compresses each blacklist field into a list + /// + public static SlimePet NewSlimePet(string name, byte preAdditionSlot = 0, byte postAdditionSlot = 0, + bool body = false, bool hat = false, bool carried = false, bool accessory = false) + { + List isSlotTypeBlacklisted = new List() { body, hat, carried, accessory }; + + return new SlimePet(name, preAdditionSlot, postAdditionSlot, isSlotTypeBlacklisted); + } + + public static SlimePet NewSlimePet(int type, byte preAdditionSlot = 0, byte postAdditionSlot = 0, + bool body = false, bool hat = false, bool carried = false, bool accessory = false) + { + return NewSlimePet(ModContent.GetModProjectile(type).Name, preAdditionSlot, postAdditionSlot, body, hat, carried, accessory); + } + + public override string ToString() + { + return "Name: " + Name + + "; Type: " + Type + + "; PreAdditionSlot: " + ((SlotType)PreAdditionSlot).ToString() + + "; PostAdditionSlot: " + ((SlotType)PostAdditionSlot).ToString(); + } + } } diff --git a/Base/SwarmDraw/FairySwarmDraw/FairySwarmDrawSet.cs b/Base/SwarmDraw/FairySwarmDraw/FairySwarmDrawSet.cs index 130af287..520bce87 100644 --- a/Base/SwarmDraw/FairySwarmDraw/FairySwarmDrawSet.cs +++ b/Base/SwarmDraw/FairySwarmDraw/FairySwarmDrawSet.cs @@ -2,25 +2,25 @@ namespace AssortedCrazyThings.Base.SwarmDraw.FairySwarmDraw { - [Content(ContentType.DroppedPets)] - public class FairySwarmDrawSet : SwarmDrawSet - { - public FairySwarmDrawSet() : base("FairySwarmDrawSet", new List() - { - new FairySwarmDrawUnit(0), - new FairySwarmDrawUnit(1), - new FairySwarmDrawUnit(2), - new FairySwarmDrawUnit(0), - new FairySwarmDrawUnit(1), - new FairySwarmDrawUnit(2) - }) - { + [Content(ContentType.DroppedPets)] + public class FairySwarmDrawSet : SwarmDrawSet + { + public FairySwarmDrawSet() : base("FairySwarmDrawSet", new List() + { + new FairySwarmDrawUnit(0), + new FairySwarmDrawUnit(1), + new FairySwarmDrawUnit(2), + new FairySwarmDrawUnit(0), + new FairySwarmDrawUnit(1), + new FairySwarmDrawUnit(2) + }) + { - } + } - public override SwarmDrawSet GetDrawSet(SwarmDrawPlayer sdPlayer) - { - return sdPlayer.fairySwarmDrawSet; - } - } + public override SwarmDrawSet GetDrawSet(SwarmDrawPlayer sdPlayer) + { + return sdPlayer.fairySwarmDrawSet; + } + } } diff --git a/Base/SwarmDraw/FairySwarmDraw/FairySwarmDrawUnit.cs b/Base/SwarmDraw/FairySwarmDraw/FairySwarmDrawUnit.cs index b3fc0b0a..d2a036a0 100644 --- a/Base/SwarmDraw/FairySwarmDraw/FairySwarmDrawUnit.cs +++ b/Base/SwarmDraw/FairySwarmDraw/FairySwarmDrawUnit.cs @@ -6,159 +6,159 @@ namespace AssortedCrazyThings.Base.SwarmDraw.FairySwarmDraw { - public class FairySwarmDrawUnit : SwarmDrawUnit - { - private const string name = "AssortedCrazyThings/Base/SwarmDraw/FairySwarmDraw/FairySwarm_"; - - public int TexIndex { get; private set; } - - public FairySwarmDrawUnit(int index) : - base(ModContent.Request(name + index), 4, 5, 16, ModContent.Request(name + index + "_Glow")) - { - TexIndex = index; - } - - public override int GetShader(PlayerDrawSet drawInfo) - { - return drawInfo.drawPlayer.cPet; - } - - public override void Animate() - { - int baseSpeed = FrameSpeed; - baseSpeed -= (int)(Math.Abs(vel.X) + Math.Abs(vel.Y)); - AssExtensions.LoopAnimationInt(ref frame, ref frameCounter, baseSpeed, 0, FrameCount - 1); - } - - public override void OnSpawn() - { - base.OnSpawn(); - - Front = TexIndex % 2 == 0; - - vel *= 0.8f; - } - - public override void AI(Vector2 center) - { - //if (pos.X > MaxDistanceX || pos.X < -MaxDistanceX) - //{ - // vel.X *= -1; - // Front = !Front; - //} - - //if (pos.Y > MaxDistanceY || pos.Y < -MaxDistanceY) - //{ - // vel.Y *= -1; - // Front = !Front; - //} - float velocityFactor = 1f; - float sway = 0.2f; - float veloDelta = 0.1f; - Vector2 between = -pos; - float distance = between.LengthSquared(); - float magnitude = 7f; - - float swayDistance = 150f * sway; - float veloLimitClose = 2f; - if (distance < swayDistance * swayDistance) - { - if (Math.Abs(vel.X) > veloLimitClose || Math.Abs(vel.Y) > veloLimitClose) - { - vel *= 0.99f; - } - veloDelta = 0.01f; - if (between.X < -veloLimitClose) - { - between.X = -veloLimitClose; - } - if (between.X > veloLimitClose) - { - between.X = veloLimitClose; - } - if (between.Y < -veloLimitClose) - { - between.Y = -veloLimitClose; - } - if (between.Y > veloLimitClose) - { - between.Y = veloLimitClose; - } - } - else - { - if (distance > swayDistance * 2f * swayDistance * 2f) - { - veloDelta = 0.2f; - } - between.Normalize(); - between *= magnitude; - } - - veloDelta *= velocityFactor; - - if (Math.Abs(between.X) > Math.Abs(between.Y)) - { - if (vel.X < between.X) - { - vel.X += veloDelta; - if (veloDelta > 0.05f && vel.X < 0f) - { - vel.X += veloDelta; - } - } - if (vel.X > between.X) - { - vel.X += -veloDelta; - if (veloDelta > 0.05f && vel.X > 0f) - { - vel.X += -veloDelta; - } - } - } - if (Math.Abs(between.X) <= Math.Abs(between.Y) || veloDelta == 0.05f) - { - if (vel.Y < between.Y) - { - vel.Y += veloDelta; - if (veloDelta > 0.05f && vel.Y < 0f) - { - vel.Y += veloDelta; - } - } - if (vel.Y > between.Y) - { - vel.Y += -veloDelta; - if (veloDelta > 0.05f && vel.Y > 0f) - { - vel.Y += -veloDelta; - } - } - } - - rot = vel.X * 0.1f; - - //Useless - //Vector3 color = default; - //switch (TexIndex) - //{ - // case 0: - // color = new Vector3(255, 103, 175); - // break; - // case 1: - // color = new Vector3(103, 205, 255); - // break; - // case 2: - // color = new Vector3(103, 255, 183); - // break; - // default: - // break; - //} - - //if (color != default) - //{ - // Lighting.AddLight(pos + center, color * (0.5f / 255)); - //} - } - } + public class FairySwarmDrawUnit : SwarmDrawUnit + { + private const string name = "AssortedCrazyThings/Base/SwarmDraw/FairySwarmDraw/FairySwarm_"; + + public int TexIndex { get; private set; } + + public FairySwarmDrawUnit(int index) : + base(ModContent.Request(name + index), 4, 5, 16, ModContent.Request(name + index + "_Glow")) + { + TexIndex = index; + } + + public override int GetShader(PlayerDrawSet drawInfo) + { + return drawInfo.drawPlayer.cPet; + } + + public override void Animate() + { + int baseSpeed = FrameSpeed; + baseSpeed -= (int)(Math.Abs(vel.X) + Math.Abs(vel.Y)); + AssExtensions.LoopAnimationInt(ref frame, ref frameCounter, baseSpeed, 0, FrameCount - 1); + } + + public override void OnSpawn() + { + base.OnSpawn(); + + Front = TexIndex % 2 == 0; + + vel *= 0.8f; + } + + public override void AI(Vector2 center) + { + //if (pos.X > MaxDistanceX || pos.X < -MaxDistanceX) + //{ + // vel.X *= -1; + // Front = !Front; + //} + + //if (pos.Y > MaxDistanceY || pos.Y < -MaxDistanceY) + //{ + // vel.Y *= -1; + // Front = !Front; + //} + float velocityFactor = 1f; + float sway = 0.2f; + float veloDelta = 0.1f; + Vector2 between = -pos; + float distance = between.LengthSquared(); + float magnitude = 7f; + + float swayDistance = 150f * sway; + float veloLimitClose = 2f; + if (distance < swayDistance * swayDistance) + { + if (Math.Abs(vel.X) > veloLimitClose || Math.Abs(vel.Y) > veloLimitClose) + { + vel *= 0.99f; + } + veloDelta = 0.01f; + if (between.X < -veloLimitClose) + { + between.X = -veloLimitClose; + } + if (between.X > veloLimitClose) + { + between.X = veloLimitClose; + } + if (between.Y < -veloLimitClose) + { + between.Y = -veloLimitClose; + } + if (between.Y > veloLimitClose) + { + between.Y = veloLimitClose; + } + } + else + { + if (distance > swayDistance * 2f * swayDistance * 2f) + { + veloDelta = 0.2f; + } + between.Normalize(); + between *= magnitude; + } + + veloDelta *= velocityFactor; + + if (Math.Abs(between.X) > Math.Abs(between.Y)) + { + if (vel.X < between.X) + { + vel.X += veloDelta; + if (veloDelta > 0.05f && vel.X < 0f) + { + vel.X += veloDelta; + } + } + if (vel.X > between.X) + { + vel.X += -veloDelta; + if (veloDelta > 0.05f && vel.X > 0f) + { + vel.X += -veloDelta; + } + } + } + if (Math.Abs(between.X) <= Math.Abs(between.Y) || veloDelta == 0.05f) + { + if (vel.Y < between.Y) + { + vel.Y += veloDelta; + if (veloDelta > 0.05f && vel.Y < 0f) + { + vel.Y += veloDelta; + } + } + if (vel.Y > between.Y) + { + vel.Y += -veloDelta; + if (veloDelta > 0.05f && vel.Y > 0f) + { + vel.Y += -veloDelta; + } + } + } + + rot = vel.X * 0.1f; + + //Useless + //Vector3 color = default; + //switch (TexIndex) + //{ + // case 0: + // color = new Vector3(255, 103, 175); + // break; + // case 1: + // color = new Vector3(103, 205, 255); + // break; + // case 2: + // color = new Vector3(103, 255, 183); + // break; + // default: + // break; + //} + + //if (color != default) + //{ + // Lighting.AddLight(pos + center, color * (0.5f / 255)); + //} + } + } } diff --git a/Base/SwarmDraw/SwarmDrawPlayer.cs b/Base/SwarmDraw/SwarmDrawPlayer.cs index 009fca74..7bc33962 100644 --- a/Base/SwarmDraw/SwarmDrawPlayer.cs +++ b/Base/SwarmDraw/SwarmDrawPlayer.cs @@ -1,74 +1,74 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using AssortedCrazyThings.Projectiles.Pets; -using AssortedCrazyThings.Base.SwarmDraw.FairySwarmDraw; +using AssortedCrazyThings.Base.SwarmDraw.FairySwarmDraw; using AssortedCrazyThings.Base.SwarmDraw.SwarmofCthulhuDraw; +using AssortedCrazyThings.Projectiles.Pets; using Microsoft.Xna.Framework; using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; namespace AssortedCrazyThings.Base.SwarmDraw { - //TODO unhardcode this when both a better tml loader comes along and more swarm draw sets exist - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - public class SwarmDrawPlayer : AssPlayerBase - { - public static void HandleDrawSet(ref SwarmDrawSet set, Func gen, bool condition, Vector2 center) - { - if (condition) - { - if (set == null) - { - set = gen(); - } + //TODO unhardcode this when both a better tml loader comes along and more swarm draw sets exist + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + public class SwarmDrawPlayer : AssPlayerBase + { + public static void HandleDrawSet(ref SwarmDrawSet set, Func gen, bool condition, Vector2 center) + { + if (condition) + { + if (set == null) + { + set = gen(); + } - if (set == null) - { - return; - } + if (set == null) + { + return; + } - if (!set.Active) - { - set.Activate(); - } + if (!set.Active) + { + set.Activate(); + } - set.Update(center); - } - else if (set != null) - { - set.Deactivate(); - } - } + set.Update(center); + } + else if (set != null) + { + set.Deactivate(); + } + } - public SwarmDrawSet fairySwarmDrawSet; + public SwarmDrawSet fairySwarmDrawSet; - public SwarmDrawSet swarmofCthulhuDrawSet; + public SwarmDrawSet swarmofCthulhuDrawSet; - public override void Initialize() - { - fairySwarmDrawSet = null; - swarmofCthulhuDrawSet = null; - } + public override void Initialize() + { + fairySwarmDrawSet = null; + swarmofCthulhuDrawSet = null; + } - public override void PostUpdate() - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void PostUpdate() + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (ContentConfig.Instance.DroppedPets) - { - HandleDrawSet(ref fairySwarmDrawSet, - SwarmDrawSet.New, - Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0, - Player.Center); + if (ContentConfig.Instance.DroppedPets) + { + HandleDrawSet(ref fairySwarmDrawSet, + SwarmDrawSet.New, + Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0, + Player.Center); - HandleDrawSet(ref swarmofCthulhuDrawSet, - SwarmDrawSet.New, - Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0, - Player.Center); - } - } - } + HandleDrawSet(ref swarmofCthulhuDrawSet, + SwarmDrawSet.New, + Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0, + Player.Center); + } + } + } } diff --git a/Base/SwarmDraw/SwarmDrawSet.cs b/Base/SwarmDraw/SwarmDrawSet.cs index a0a7d391..877362fb 100644 --- a/Base/SwarmDraw/SwarmDrawSet.cs +++ b/Base/SwarmDraw/SwarmDrawSet.cs @@ -8,118 +8,118 @@ namespace AssortedCrazyThings.Base.SwarmDraw { - /// - /// This class works as follows: - /// Classes extending from it create a parameterless constructor which fullfills this classes constructor. - /// The PlayerDrawLayers added here have to NOT be autoloaded, they'll get added through ILoadable.Load automatically. - /// Those instances are fetched on the SwarmDrawPlayer and cloned (so players don't share data between eachother) - /// - [Autoload(false, Side = ModSide.Client)] - public abstract class SwarmDrawSet : ILoadable, ICloneable - { - private bool firstTick = true; - - public bool Active { get; private set; } - - public int Count => Units.Count; - - public List Units { get; private set; } - - public List Layers { get; private set; } - - public SwarmDrawSet(string name, List units) - { - Units = units; - - Layers = new List() - { - new SwarmDrawLayer(name, true, GetDrawSet), - new SwarmDrawLayer(name, false, GetDrawSet) - }; - } - - void ILoadable.Load(Mod mod) - { - foreach (var layer in Layers) - { - mod.AddContent(layer); - } - } - - void ILoadable.Unload() - { - Layers?.Clear(); - Layers = null; - } - - public abstract SwarmDrawSet GetDrawSet(SwarmDrawPlayer sdPlayer); - - public object Clone() - { - var clone = (SwarmDrawSet)MemberwiseClone(); - - //Need to reinitialize the list with cloned data - clone.Units = new List(Units.Select(u => (SwarmDrawUnit)u.Clone())); - return clone; - } - - public void Update(Vector2 center) - { - if (!Active) - { - return; - } - - if (firstTick) - { - firstTick = false; - - foreach (var unit in Units) - { - unit.OnSpawn(); - } - } - - foreach (var unit in Units) - { - unit.Update(center); - } - } - - public void Activate() - { - Active = true; - firstTick = true; - } - - public void Deactivate() - { - Active = false; - } - - public List ToDrawDatas(PlayerDrawSet drawInfo, bool front) - { - var data = new List(); - foreach (var unit in Units) - { - data.AddRange(unit.ToDrawDatas(drawInfo, front)); - } - return data; - } - - public List TrailToDrawDatas(PlayerDrawSet drawInfo, bool front) - { - var data = new List(); - foreach (var unit in Units) - { - data.AddRange(unit.TrailToDrawDatas(drawInfo, front)); - } - return data; - } - - public static T New() where T : SwarmDrawSet - { - return (T)ModContent.GetInstance().Clone(); - } - } + /// + /// This class works as follows: + /// Classes extending from it create a parameterless constructor which fullfills this classes constructor. + /// The PlayerDrawLayers added here have to NOT be autoloaded, they'll get added through ILoadable.Load automatically. + /// Those instances are fetched on the SwarmDrawPlayer and cloned (so players don't share data between eachother) + /// + [Autoload(false, Side = ModSide.Client)] + public abstract class SwarmDrawSet : ILoadable, ICloneable + { + private bool firstTick = true; + + public bool Active { get; private set; } + + public int Count => Units.Count; + + public List Units { get; private set; } + + public List Layers { get; private set; } + + public SwarmDrawSet(string name, List units) + { + Units = units; + + Layers = new List() + { + new SwarmDrawLayer(name, true, GetDrawSet), + new SwarmDrawLayer(name, false, GetDrawSet) + }; + } + + void ILoadable.Load(Mod mod) + { + foreach (var layer in Layers) + { + mod.AddContent(layer); + } + } + + void ILoadable.Unload() + { + Layers?.Clear(); + Layers = null; + } + + public abstract SwarmDrawSet GetDrawSet(SwarmDrawPlayer sdPlayer); + + public object Clone() + { + var clone = (SwarmDrawSet)MemberwiseClone(); + + //Need to reinitialize the list with cloned data + clone.Units = new List(Units.Select(u => (SwarmDrawUnit)u.Clone())); + return clone; + } + + public void Update(Vector2 center) + { + if (!Active) + { + return; + } + + if (firstTick) + { + firstTick = false; + + foreach (var unit in Units) + { + unit.OnSpawn(); + } + } + + foreach (var unit in Units) + { + unit.Update(center); + } + } + + public void Activate() + { + Active = true; + firstTick = true; + } + + public void Deactivate() + { + Active = false; + } + + public List ToDrawDatas(PlayerDrawSet drawInfo, bool front) + { + var data = new List(); + foreach (var unit in Units) + { + data.AddRange(unit.ToDrawDatas(drawInfo, front)); + } + return data; + } + + public List TrailToDrawDatas(PlayerDrawSet drawInfo, bool front) + { + var data = new List(); + foreach (var unit in Units) + { + data.AddRange(unit.TrailToDrawDatas(drawInfo, front)); + } + return data; + } + + public static T New() where T : SwarmDrawSet + { + return (T)ModContent.GetInstance().Clone(); + } + } } diff --git a/Base/SwarmDraw/SwarmDrawUnit.cs b/Base/SwarmDraw/SwarmDrawUnit.cs index 6f10934a..e8fdfad1 100644 --- a/Base/SwarmDraw/SwarmDrawUnit.cs +++ b/Base/SwarmDraw/SwarmDrawUnit.cs @@ -1,283 +1,283 @@ -using Terraria; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using System; using System.Collections.Generic; -using ReLogic.Content; +using Terraria; using Terraria.DataStructures; namespace AssortedCrazyThings.Base.SwarmDraw { - public abstract class SwarmDrawUnit : ICloneable - { - public Asset Asset { get; protected set; } + public abstract class SwarmDrawUnit : ICloneable + { + public Asset Asset { get; protected set; } - public Asset TrailAsset { get; protected set; } + public Asset TrailAsset { get; protected set; } - public int FrameCount { get; protected set; } - public int FrameSpeed { get; protected set; } + public int FrameCount { get; protected set; } + public int FrameSpeed { get; protected set; } - protected int frameCounter; - protected int frame; + protected int frameCounter; + protected int frame; - public bool Front { get; protected set; } + public bool Front { get; protected set; } - public bool HasTrail => OldPos.Length > 0; + public bool HasTrail => OldPos.Length > 0; - //Trail parts can also be front/back when switching, don't want to switch the entire trail all at once - public bool[] OldFront { get; protected set; } + //Trail parts can also be front/back when switching, don't want to switch the entire trail all at once + public bool[] OldFront { get; protected set; } - public int[] OldFrame { get; protected set; } + public int[] OldFrame { get; protected set; } - protected Vector2 pos; + protected Vector2 pos; - public Vector2[] OldPos { get; protected set; } + public Vector2[] OldPos { get; protected set; } - protected int dir = 1; + protected int dir = 1; - public int[] OldDir { get; protected set; } + public int[] OldDir { get; protected set; } - protected float rot; + protected float rot; - public float[] OldRot { get; protected set; } + public float[] OldRot { get; protected set; } - protected Vector2 oldVel; + protected Vector2 oldVel; - protected Vector2 vel; + protected Vector2 vel; - /// - /// If direction should be automatically set based on velocity. Occurs after AI - /// - public virtual bool AutoDirection => true; - - /// - /// If layer should be automatically changed based on X-velocity change. Occurs after AI - /// - public virtual bool AutoLayerX => true; + /// + /// If direction should be automatically set based on velocity. Occurs after AI + /// + public virtual bool AutoDirection => true; + + /// + /// If layer should be automatically changed based on X-velocity change. Occurs after AI + /// + public virtual bool AutoLayerX => true; - public SwarmDrawUnit(Asset asset, int frameCount, int frameSpeed, int trailLength = 0, Asset trailAsset = null) - { - Asset = asset; - FrameCount = frameCount; - FrameSpeed = frameSpeed; - - OldFront = new bool[trailLength]; - OldFrame = new int[trailLength]; - OldPos = new Vector2[trailLength]; - OldDir = new int[trailLength]; - OldRot = new float[trailLength]; + public SwarmDrawUnit(Asset asset, int frameCount, int frameSpeed, int trailLength = 0, Asset trailAsset = null) + { + Asset = asset; + FrameCount = frameCount; + FrameSpeed = frameSpeed; + + OldFront = new bool[trailLength]; + OldFrame = new int[trailLength]; + OldPos = new Vector2[trailLength]; + OldDir = new int[trailLength]; + OldRot = new float[trailLength]; - TrailAsset = trailAsset ?? Asset; - } - - public object Clone() - { - var clone = (SwarmDrawUnit)MemberwiseClone(); - int trailLength = OldFront.Length; - - //Need to reinitialize the arrays - clone.OldFront = new bool[trailLength]; - clone.OldFrame = new int[trailLength]; - clone.OldPos = new Vector2[trailLength]; - clone.OldDir = new int[trailLength]; - clone.OldRot = new float[trailLength]; - Array.Copy(OldFront, clone.OldFront, trailLength); - Array.Copy(OldFrame, clone.OldFrame, trailLength); - Array.Copy(OldPos, clone.OldPos, trailLength); - Array.Copy(OldDir, clone.OldDir, trailLength); - Array.Copy(OldRot, clone.OldRot, trailLength); - return clone; - } - - public virtual int GetShader(PlayerDrawSet drawInfo) - { - return 0; - } - - public virtual Color GetColor(PlayerDrawSet drawInfo) - { - return Color.White; - } - - public virtual float GetScale(PlayerDrawSet drawInfo) - { - return 1f; - } - - public virtual void Animate() - { - AssExtensions.LoopAnimationInt(ref frame, ref frameCounter, FrameSpeed, 0, FrameCount - 1); - } - - public virtual void AI(Vector2 center) - { - - } - - /// - /// Runs whenever the swarm is enabled. Acts as a Reset after initial spawn too - /// - public virtual void OnSpawn() - { - if (!AutoLayerX) - { - Front = Main.rand.NextBool(); - } - - pos = Vector2.Zero; - - vel = Main.rand.NextVector2Unit(); - if (Math.Abs(vel.X) < 0.1f || Math.Abs(vel.Y) < 0.1f) - { - //Prevent too horizontal/vertical movement - vel.RotatedBy(MathHelper.TwoPi / 12); - } - - frame = Main.rand.Next(FrameCount); - frameCounter = Main.rand.Next(FrameSpeed); - - if (!AutoDirection) - { - dir = Main.rand.NextBool().ToDirectionInt(); - } - - for (int i = 0; i < OldPos.Length; i++) - { - OldFront[i] = Front; - OldFrame[i] = frame; - OldPos[i] = pos; - OldDir[i] = dir; - OldRot[i] = rot; - } - } - - public void Update(Vector2 center) - { - Animate(); - - if (AutoDirection) - { - dir = (vel.X > 0).ToDirectionInt(); - } - - AI(center); - - pos += vel; - - if (AutoLayerX) - { - if (Math.Sign(oldVel.X) != Math.Sign(vel.X)) - { - Front = !Front; - } - } - - if (HasTrail) - { - //Shift elements one to the right - for (int i = OldPos.Length - 1; i > 0; i--) - { - OldFront[i] = OldFront[i - 1]; - OldFrame[i] = OldFrame[i - 1]; - OldPos[i] = OldPos[i - 1]; - OldDir[i] = OldDir[i - 1]; - OldRot[i] = OldRot[i - 1]; - } - - //Fill leftmost element with current value - OldFront[0] = Front; - OldFrame[0] = frame; - OldPos[0] = pos; - OldDir[0] = dir; - OldRot[0] = rot; - } - - oldVel = vel; - } - - public List ToDrawDatas(PlayerDrawSet drawInfo, bool front) - { - var datas = new List(); - if (front != Front) - { - return datas; - } - - GetDrawDataParams(drawInfo, out Texture2D texture, out Vector2 position, out Rectangle bounds, out Color color, out float rotation, out float scale, out SpriteEffects effects); - - datas.Add(ToDrawData(drawInfo, texture, position, bounds, color, rotation, bounds.Size() / 2, scale, effects)); - return datas; - } - - public List TrailToDrawDatas(PlayerDrawSet drawInfo, bool front) - { - List datas = new List(); - if (!HasTrail) - { - return datas; - } - - for (int i = 0; i < OldPos.Length; i++) - { - if (front != OldFront[i]) - { - //If a front data is needed but this trail part is not front, - //Of if a back data is needed but this trail part is front, continue - continue; - } - - GetDrawDataParams(drawInfo, out Texture2D texture, out Vector2 position, out Rectangle bounds, out Color color, out float rotation, out float scale, out SpriteEffects effects, i); - - var data = ToDrawData(drawInfo, texture, position, bounds, color, rotation, bounds.Size() / 2, scale, effects); - datas.Add(data); - } - - return datas; - } - - private void GetDrawDataParams(PlayerDrawSet drawInfo, out Texture2D texture, out Vector2 position, out Rectangle bounds, out Color color, out float rotation, out float scale, out SpriteEffects effects, int trailIndex = -1) - { - bool trail = trailIndex > -1; - - int realFrame = trail ? OldFrame[trailIndex] : frame; - Vector2 realPos = trail ? OldPos[trailIndex] : pos; - int realDir = trail ? OldDir[trailIndex] : dir; - float realRot = trail ? OldRot[trailIndex] : rot; - - texture = (trail ? TrailAsset : Asset).Value; - bounds = texture.Frame(1, FrameCount, frameY: realFrame); - - effects = realDir == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - const SpriteEffects flipVertically = SpriteEffects.FlipVertically; - if (drawInfo.playerEffect.HasFlag(flipVertically)) - { - effects |= flipVertically; - } - Player drawPlayer = drawInfo.drawPlayer; - position = realPos + drawInfo.Position - Main.screenPosition + drawPlayer.bodyPosition + drawPlayer.Size / 2; - - float factor = 1f; - if (trail) - { - int trailCount = OldPos.Length; - factor = (float)(trailCount - trailIndex) / trailCount; - } - - color = GetColor(drawInfo) * factor; - - rotation = realRot; - - scale = GetScale(drawInfo) * factor; - } - - public DrawData ToDrawData(PlayerDrawSet drawInfo, Texture2D texture, Vector2 position, Rectangle? sourceRect, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effect) - { - //position = position.Floor(); //Makes it worse when idle - return new DrawData(texture, position, sourceRect, color, rotation, origin, scale, effect, 0) - { - ignorePlayerRotation = true, - shader = GetShader(drawInfo) - }; - } - } + TrailAsset = trailAsset ?? Asset; + } + + public object Clone() + { + var clone = (SwarmDrawUnit)MemberwiseClone(); + int trailLength = OldFront.Length; + + //Need to reinitialize the arrays + clone.OldFront = new bool[trailLength]; + clone.OldFrame = new int[trailLength]; + clone.OldPos = new Vector2[trailLength]; + clone.OldDir = new int[trailLength]; + clone.OldRot = new float[trailLength]; + Array.Copy(OldFront, clone.OldFront, trailLength); + Array.Copy(OldFrame, clone.OldFrame, trailLength); + Array.Copy(OldPos, clone.OldPos, trailLength); + Array.Copy(OldDir, clone.OldDir, trailLength); + Array.Copy(OldRot, clone.OldRot, trailLength); + return clone; + } + + public virtual int GetShader(PlayerDrawSet drawInfo) + { + return 0; + } + + public virtual Color GetColor(PlayerDrawSet drawInfo) + { + return Color.White; + } + + public virtual float GetScale(PlayerDrawSet drawInfo) + { + return 1f; + } + + public virtual void Animate() + { + AssExtensions.LoopAnimationInt(ref frame, ref frameCounter, FrameSpeed, 0, FrameCount - 1); + } + + public virtual void AI(Vector2 center) + { + + } + + /// + /// Runs whenever the swarm is enabled. Acts as a Reset after initial spawn too + /// + public virtual void OnSpawn() + { + if (!AutoLayerX) + { + Front = Main.rand.NextBool(); + } + + pos = Vector2.Zero; + + vel = Main.rand.NextVector2Unit(); + if (Math.Abs(vel.X) < 0.1f || Math.Abs(vel.Y) < 0.1f) + { + //Prevent too horizontal/vertical movement + vel.RotatedBy(MathHelper.TwoPi / 12); + } + + frame = Main.rand.Next(FrameCount); + frameCounter = Main.rand.Next(FrameSpeed); + + if (!AutoDirection) + { + dir = Main.rand.NextBool().ToDirectionInt(); + } + + for (int i = 0; i < OldPos.Length; i++) + { + OldFront[i] = Front; + OldFrame[i] = frame; + OldPos[i] = pos; + OldDir[i] = dir; + OldRot[i] = rot; + } + } + + public void Update(Vector2 center) + { + Animate(); + + if (AutoDirection) + { + dir = (vel.X > 0).ToDirectionInt(); + } + + AI(center); + + pos += vel; + + if (AutoLayerX) + { + if (Math.Sign(oldVel.X) != Math.Sign(vel.X)) + { + Front = !Front; + } + } + + if (HasTrail) + { + //Shift elements one to the right + for (int i = OldPos.Length - 1; i > 0; i--) + { + OldFront[i] = OldFront[i - 1]; + OldFrame[i] = OldFrame[i - 1]; + OldPos[i] = OldPos[i - 1]; + OldDir[i] = OldDir[i - 1]; + OldRot[i] = OldRot[i - 1]; + } + + //Fill leftmost element with current value + OldFront[0] = Front; + OldFrame[0] = frame; + OldPos[0] = pos; + OldDir[0] = dir; + OldRot[0] = rot; + } + + oldVel = vel; + } + + public List ToDrawDatas(PlayerDrawSet drawInfo, bool front) + { + var datas = new List(); + if (front != Front) + { + return datas; + } + + GetDrawDataParams(drawInfo, out Texture2D texture, out Vector2 position, out Rectangle bounds, out Color color, out float rotation, out float scale, out SpriteEffects effects); + + datas.Add(ToDrawData(drawInfo, texture, position, bounds, color, rotation, bounds.Size() / 2, scale, effects)); + return datas; + } + + public List TrailToDrawDatas(PlayerDrawSet drawInfo, bool front) + { + List datas = new List(); + if (!HasTrail) + { + return datas; + } + + for (int i = 0; i < OldPos.Length; i++) + { + if (front != OldFront[i]) + { + //If a front data is needed but this trail part is not front, + //Of if a back data is needed but this trail part is front, continue + continue; + } + + GetDrawDataParams(drawInfo, out Texture2D texture, out Vector2 position, out Rectangle bounds, out Color color, out float rotation, out float scale, out SpriteEffects effects, i); + + var data = ToDrawData(drawInfo, texture, position, bounds, color, rotation, bounds.Size() / 2, scale, effects); + datas.Add(data); + } + + return datas; + } + + private void GetDrawDataParams(PlayerDrawSet drawInfo, out Texture2D texture, out Vector2 position, out Rectangle bounds, out Color color, out float rotation, out float scale, out SpriteEffects effects, int trailIndex = -1) + { + bool trail = trailIndex > -1; + + int realFrame = trail ? OldFrame[trailIndex] : frame; + Vector2 realPos = trail ? OldPos[trailIndex] : pos; + int realDir = trail ? OldDir[trailIndex] : dir; + float realRot = trail ? OldRot[trailIndex] : rot; + + texture = (trail ? TrailAsset : Asset).Value; + bounds = texture.Frame(1, FrameCount, frameY: realFrame); + + effects = realDir == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + const SpriteEffects flipVertically = SpriteEffects.FlipVertically; + if (drawInfo.playerEffect.HasFlag(flipVertically)) + { + effects |= flipVertically; + } + Player drawPlayer = drawInfo.drawPlayer; + position = realPos + drawInfo.Position - Main.screenPosition + drawPlayer.bodyPosition + drawPlayer.Size / 2; + + float factor = 1f; + if (trail) + { + int trailCount = OldPos.Length; + factor = (float)(trailCount - trailIndex) / trailCount; + } + + color = GetColor(drawInfo) * factor; + + rotation = realRot; + + scale = GetScale(drawInfo) * factor; + } + + public DrawData ToDrawData(PlayerDrawSet drawInfo, Texture2D texture, Vector2 position, Rectangle? sourceRect, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effect) + { + //position = position.Floor(); //Makes it worse when idle + return new DrawData(texture, position, sourceRect, color, rotation, origin, scale, effect, 0) + { + ignorePlayerRotation = true, + shader = GetShader(drawInfo) + }; + } + } } diff --git a/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhuDrawSet.cs b/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhuDrawSet.cs index 92ba54fc..18576888 100644 --- a/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhuDrawSet.cs +++ b/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhuDrawSet.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Base.SwarmDraw.SwarmofCthulhuDraw { - [Content(ContentType.DroppedPets)] - public class SwarmofCthulhuDrawSet : SwarmDrawSet - { - public SwarmofCthulhuDrawSet() : base("SwarmofCthulhuDrawSet", new List() - { - new SwarmofCthulhuDrawUnit(), - new SwarmofCthulhuDrawUnit(), - new SwarmofCthulhuDrawUnit(), - }) - { + [Content(ContentType.DroppedPets)] + public class SwarmofCthulhuDrawSet : SwarmDrawSet + { + public SwarmofCthulhuDrawSet() : base("SwarmofCthulhuDrawSet", new List() + { + new SwarmofCthulhuDrawUnit(), + new SwarmofCthulhuDrawUnit(), + new SwarmofCthulhuDrawUnit(), + }) + { - } + } - public override SwarmDrawSet GetDrawSet(SwarmDrawPlayer sdPlayer) - { - return sdPlayer.swarmofCthulhuDrawSet; - } - } + public override SwarmDrawSet GetDrawSet(SwarmDrawPlayer sdPlayer) + { + return sdPlayer.swarmofCthulhuDrawSet; + } + } } diff --git a/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhuDrawUnit.cs b/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhuDrawUnit.cs index 2357cb50..adb2974a 100644 --- a/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhuDrawUnit.cs +++ b/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhuDrawUnit.cs @@ -7,124 +7,124 @@ namespace AssortedCrazyThings.Base.SwarmDraw.SwarmofCthulhuDraw { - public class SwarmofCthulhuDrawUnit : SwarmDrawUnit - { - private const string name = "AssortedCrazyThings/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhu"; + public class SwarmofCthulhuDrawUnit : SwarmDrawUnit + { + private const string name = "AssortedCrazyThings/Base/SwarmDraw/SwarmofCthulhuDraw/SwarmofCthulhu"; - public SwarmofCthulhuDrawUnit() : - base(ModContent.Request(name), 4, 6, 0, null) - { + public SwarmofCthulhuDrawUnit() : + base(ModContent.Request(name), 4, 6, 0, null) + { - } + } - public override int GetShader(PlayerDrawSet drawInfo) - { - return drawInfo.drawPlayer.cPet; - } + public override int GetShader(PlayerDrawSet drawInfo) + { + return drawInfo.drawPlayer.cPet; + } - public override Color GetColor(PlayerDrawSet drawInfo) - { - return drawInfo.colorArmorBody; - } + public override Color GetColor(PlayerDrawSet drawInfo) + { + return drawInfo.colorArmorBody; + } - public override void OnSpawn() - { - base.OnSpawn(); + public override void OnSpawn() + { + base.OnSpawn(); - vel *= 0.6f; - } + vel *= 0.6f; + } - public override void AI(Vector2 center) - { - float velocityFactor = 1f; - float sway = 0.25f; - float veloDelta = 0.1f; - Vector2 between = -pos; - float distance = between.LengthSquared(); - float magnitude = 7f; + public override void AI(Vector2 center) + { + float velocityFactor = 1f; + float sway = 0.25f; + float veloDelta = 0.1f; + Vector2 between = -pos; + float distance = between.LengthSquared(); + float magnitude = 7f; - float swayDistance = 150f * sway; - float veloLimitClose = 1.8f; - if (distance < swayDistance * swayDistance) - { - if (Math.Abs(vel.X) > veloLimitClose || Math.Abs(vel.Y) > veloLimitClose) - { - vel *= 0.99f; - } - veloDelta = 0.01f; - if (between.X < -veloLimitClose) - { - between.X = -veloLimitClose; - } - if (between.X > veloLimitClose) - { - between.X = veloLimitClose; - } - if (between.Y < -veloLimitClose) - { - between.Y = -veloLimitClose; - } - if (between.Y > veloLimitClose) - { - between.Y = veloLimitClose; - } - } - else - { - if (distance > swayDistance * 2f * swayDistance * 2f) - { - veloDelta = 0.2f; - } - between.Normalize(); - between *= magnitude; - } + float swayDistance = 150f * sway; + float veloLimitClose = 1.8f; + if (distance < swayDistance * swayDistance) + { + if (Math.Abs(vel.X) > veloLimitClose || Math.Abs(vel.Y) > veloLimitClose) + { + vel *= 0.99f; + } + veloDelta = 0.01f; + if (between.X < -veloLimitClose) + { + between.X = -veloLimitClose; + } + if (between.X > veloLimitClose) + { + between.X = veloLimitClose; + } + if (between.Y < -veloLimitClose) + { + between.Y = -veloLimitClose; + } + if (between.Y > veloLimitClose) + { + between.Y = veloLimitClose; + } + } + else + { + if (distance > swayDistance * 2f * swayDistance * 2f) + { + veloDelta = 0.2f; + } + between.Normalize(); + between *= magnitude; + } - veloDelta *= velocityFactor; + veloDelta *= velocityFactor; - if (Math.Abs(between.X) > Math.Abs(between.Y)) - { - if (vel.X < between.X) - { - vel.X += veloDelta; - if (veloDelta > 0.05f && vel.X < 0f) - { - vel.X += veloDelta; - } - } - if (vel.X > between.X) - { - vel.X += -veloDelta; - if (veloDelta > 0.05f && vel.X > 0f) - { - vel.X += -veloDelta; - } - } - } - if (Math.Abs(between.X) <= Math.Abs(between.Y) || veloDelta == 0.05f) - { - if (vel.Y < between.Y) - { - vel.Y += veloDelta; - if (veloDelta > 0.05f && vel.Y < 0f) - { - vel.Y += veloDelta; - } - } - if (vel.Y > between.Y) - { - vel.Y += -veloDelta; - if (veloDelta > 0.05f && vel.Y > 0f) - { - vel.Y += -veloDelta; - } - } - } + if (Math.Abs(between.X) > Math.Abs(between.Y)) + { + if (vel.X < between.X) + { + vel.X += veloDelta; + if (veloDelta > 0.05f && vel.X < 0f) + { + vel.X += veloDelta; + } + } + if (vel.X > between.X) + { + vel.X += -veloDelta; + if (veloDelta > 0.05f && vel.X > 0f) + { + vel.X += -veloDelta; + } + } + } + if (Math.Abs(between.X) <= Math.Abs(between.Y) || veloDelta == 0.05f) + { + if (vel.Y < between.Y) + { + vel.Y += veloDelta; + if (veloDelta > 0.05f && vel.Y < 0f) + { + vel.Y += veloDelta; + } + } + if (vel.Y > between.Y) + { + vel.Y += -veloDelta; + if (veloDelta > 0.05f && vel.Y > 0f) + { + vel.Y += -veloDelta; + } + } + } - rot = vel.ToRotation() - 0; - if (dir == 1) - { - rot -= MathHelper.Pi; - } - } - } + rot = vel.ToRotation() - 0; + if (dir == 1) + { + rot -= MathHelper.Pi; + } + } + } } diff --git a/BossBars/HarvesterBossBar.cs b/BossBars/HarvesterBossBar.cs index 80ae30f9..3f4048eb 100644 --- a/BossBars/HarvesterBossBar.cs +++ b/BossBars/HarvesterBossBar.cs @@ -1,55 +1,55 @@ -using Microsoft.Xna.Framework; +using AssortedCrazyThings.NPCs.DungeonBird; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.GameContent; -using Terraria.ModLoader; using Terraria.GameContent.UI.BigProgressBar; -using AssortedCrazyThings.NPCs.DungeonBird; +using Terraria.ModLoader; namespace AssortedCrazyThings.BossBars { - //Special health bar because the revive stage needs progression representation - public class HarvesterBossBar : ModBossBar - { - private int bossHeadIndex = -1; - - public override Asset GetIconTexture(ref Rectangle? iconFrame) - { - if (bossHeadIndex != -1) - { - return TextureAssets.NpcHeadBoss[bossHeadIndex]; - } - return null; - } - - public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) - { - NPC npc = Main.npc[info.npcIndexToAimAt]; - if (!npc.active) - { - return false; - } - - bossHeadIndex = npc.GetBossHeadTextureIndex(); - lifePercent = Utils.Clamp(npc.life / (float)npc.lifeMax, 0f, 1f); - shieldPercent = 0f; - - if (npc.ModNPC is Harvester harvester) - { - if (!harvester.IsReviving) - { - return base.ModifyInfo(ref info, ref lifePercent, ref shieldPercent); - } - - lifePercent = 0f; - - var stats = harvester.GetAIStats(); - shieldPercent = Utils.Clamp(harvester.ReviveProgress / Harvester.Revive_Duration, 0f, 1f); - shieldPercent = Utils.Remap(shieldPercent, 0f, 1f, Harvester.Revive_MinHP, stats.MaxHP); - } - - return true; - } - } + //Special health bar because the revive stage needs progression representation + public class HarvesterBossBar : ModBossBar + { + private int bossHeadIndex = -1; + + public override Asset GetIconTexture(ref Rectangle? iconFrame) + { + if (bossHeadIndex != -1) + { + return TextureAssets.NpcHeadBoss[bossHeadIndex]; + } + return null; + } + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float lifePercent, ref float shieldPercent) + { + NPC npc = Main.npc[info.npcIndexToAimAt]; + if (!npc.active) + { + return false; + } + + bossHeadIndex = npc.GetBossHeadTextureIndex(); + lifePercent = Utils.Clamp(npc.life / (float)npc.lifeMax, 0f, 1f); + shieldPercent = 0f; + + if (npc.ModNPC is Harvester harvester) + { + if (!harvester.IsReviving) + { + return base.ModifyInfo(ref info, ref lifePercent, ref shieldPercent); + } + + lifePercent = 0f; + + var stats = harvester.GetAIStats(); + shieldPercent = Utils.Clamp(harvester.ReviveProgress / Harvester.Revive_Duration, 0f, 1f); + shieldPercent = Utils.Remap(shieldPercent, 0f, 1f, Harvester.Revive_MinHP, stats.MaxHP); + } + + return true; + } + } } diff --git a/Buffs/CompanionDungeonSoulMinionBuff.cs b/Buffs/CompanionDungeonSoulMinionBuff.cs index ae77fc47..c6b842a3 100644 --- a/Buffs/CompanionDungeonSoulMinionBuff.cs +++ b/Buffs/CompanionDungeonSoulMinionBuff.cs @@ -6,73 +6,73 @@ namespace AssortedCrazyThings.Buffs { - [Content(ContentType.Bosses)] - public class CompanionDungeonSoulMinionBuff : AssBuff - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Companion Soul Minion"); - Description.SetDefault("A friendly Soul is fighting for you"); - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - } + [Content(ContentType.Bosses)] + public class CompanionDungeonSoulMinionBuff : AssBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Companion Soul Minion"); + Description.SetDefault("A friendly Soul is fighting for you"); + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + } - private int SumOfSoulCounts(Player player) - { - int sum = 0; - foreach (SoulType type in Enum.GetValues(typeof(SoulType))) - { - if (type != SoulType.None) - { - sum += player.ownedProjectileCounts[EverhallowedLantern.GetSoulData(type).ProjType]; - } - } + private int SumOfSoulCounts(Player player) + { + int sum = 0; + foreach (SoulType type in Enum.GetValues(typeof(SoulType))) + { + if (type != SoulType.None) + { + sum += player.ownedProjectileCounts[EverhallowedLantern.GetSoulData(type).ProjType]; + } + } - sum += player.ownedProjectileCounts[ModContent.ProjectileType()]; - return sum; - } + sum += player.ownedProjectileCounts[ModContent.ProjectileType()]; + return sum; + } - public override void Update(Player player, ref int buffIndex) - { - AssPlayer modPlayer = player.GetModPlayer(); - if (SumOfSoulCounts(player) > 0) - { - modPlayer.soulMinion = true; - } - if (!modPlayer.soulMinion) - { - player.DelBuff(buffIndex); - buffIndex--; - } - else - { - player.buffTime[buffIndex] = 18000; - } - } + public override void Update(Player player, ref int buffIndex) + { + AssPlayer modPlayer = player.GetModPlayer(); + if (SumOfSoulCounts(player) > 0) + { + modPlayer.soulMinion = true; + } + if (!modPlayer.soulMinion) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - int ownedCount; - foreach (SoulType type in Enum.GetValues(typeof(SoulType))) - { - if (type != SoulType.None) - { - SoulData data = EverhallowedLantern.GetSoulData(type); - ownedCount = Main.LocalPlayer.ownedProjectileCounts[data.ProjType]; - if (ownedCount > 0) - { - string name = data.Name; - int startIndex = name.IndexOf("Soul"); - name = name.Insert(startIndex + 4, "s"); - tip += "\n" + name + " : " + ownedCount; - } - } - } - ownedCount = Main.LocalPlayer.ownedProjectileCounts[ModContent.ProjectileType()]; - if (ownedCount > 0) - { - tip += "\n" + "Tiny Dungeon Souls: " + ownedCount; - } - } - } + public override void ModifyBuffTip(ref string tip, ref int rare) + { + int ownedCount; + foreach (SoulType type in Enum.GetValues(typeof(SoulType))) + { + if (type != SoulType.None) + { + SoulData data = EverhallowedLantern.GetSoulData(type); + ownedCount = Main.LocalPlayer.ownedProjectileCounts[data.ProjType]; + if (ownedCount > 0) + { + string name = data.Name; + int startIndex = name.IndexOf("Soul"); + name = name.Insert(startIndex + 4, "s"); + tip += "\n" + name + " : " + ownedCount; + } + } + } + ownedCount = Main.LocalPlayer.ownedProjectileCounts[ModContent.ProjectileType()]; + if (ownedCount > 0) + { + tip += "\n" + "Tiny Dungeon Souls: " + ownedCount; + } + } + } } diff --git a/Buffs/CuteSlimeSpawnEnableBuff.cs b/Buffs/CuteSlimeSpawnEnableBuff.cs index 072bf14f..e545f5d2 100644 --- a/Buffs/CuteSlimeSpawnEnableBuff.cs +++ b/Buffs/CuteSlimeSpawnEnableBuff.cs @@ -5,43 +5,43 @@ namespace AssortedCrazyThings.Buffs { - [Content(ContentType.CuteSlimes)] - public class CuteSlimeSpawnEnableBuff : AssBuff - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Jellied Ale"); - Description.SetDefault("Your perception of slimes is a bit off..."); - } + [Content(ContentType.CuteSlimes)] + public class CuteSlimeSpawnEnableBuff : AssBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Jellied Ale"); + Description.SetDefault("Your perception of slimes is a bit off..."); + } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - string canSpawn = "\nCute Slimes that can spawn: "; - string suffix = "None"; + public override void ModifyBuffTip(ref string tip, ref int rare) + { + string canSpawn = "\nCute Slimes that can spawn: "; + string suffix = "None"; - foreach (SpawnConditionType type in Enum.GetValues(typeof(SpawnConditionType))) - { - if (SlimePets.CanSpawn(Main.LocalPlayer, type)) - { - List nameList = SlimePets.slimePetNPCsEnumToNames[(int)type]; - if (nameList != null) - { - if (suffix == "None") suffix = "\n"; - for (int i = 0; i < nameList.Count; i++) - { - suffix += nameList[i]; - if (i < nameList.Count - 1) suffix += ", "; //if not last element, add a comma - else suffix += "\n"; //if last element, add line break - } - } - } - } - tip += canSpawn + suffix; - } + foreach (SpawnConditionType type in Enum.GetValues(typeof(SpawnConditionType))) + { + if (SlimePets.CanSpawn(Main.LocalPlayer, type)) + { + List nameList = SlimePets.slimePetNPCsEnumToNames[(int)type]; + if (nameList != null) + { + if (suffix == "None") suffix = "\n"; + for (int i = 0; i < nameList.Count; i++) + { + suffix += nameList[i]; + if (i < nameList.Count - 1) suffix += ", "; //if not last element, add a comma + else suffix += "\n"; //if last element, add line break + } + } + } + } + tip += canSpawn + suffix; + } - public override void Update(Player player, ref int buffIndex) - { - player.GetModPlayer().cuteSlimeSpawnEnable = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.GetModPlayer().cuteSlimeSpawnEnable = true; + } + } } diff --git a/Buffs/DroneControllerBuff.cs b/Buffs/DroneControllerBuff.cs index 70992261..832541ba 100644 --- a/Buffs/DroneControllerBuff.cs +++ b/Buffs/DroneControllerBuff.cs @@ -4,49 +4,49 @@ namespace AssortedCrazyThings.Buffs { - [Content(ContentType.Weapons)] - public class DroneControllerBuff : AssBuff - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Drone Controller"); - Description.SetDefault("Command a swarm of drones"); - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - } + [Content(ContentType.Weapons)] + public class DroneControllerBuff : AssBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Drone Controller"); + Description.SetDefault("Command a swarm of drones"); + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - AssPlayer modPlayer = player.GetModPlayer(); - if (DroneController.SumOfSummonedDrones(player) > 0) - { - modPlayer.droneControllerMinion = true; - } - if (!modPlayer.droneControllerMinion) - { - player.DelBuff(buffIndex); - buffIndex--; - } - else - { - player.buffTime[buffIndex] = 18000; - } - } + public override void Update(Player player, ref int buffIndex) + { + AssPlayer modPlayer = player.GetModPlayer(); + if (DroneController.SumOfSummonedDrones(player) > 0) + { + modPlayer.droneControllerMinion = true; + } + if (!modPlayer.droneControllerMinion) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - foreach (DroneType type in Enum.GetValues(typeof(DroneType))) - { - if (type != DroneType.None) - { - DroneData data = DroneController.GetDroneData(type); - int ownedCount = Main.LocalPlayer.ownedProjectileCounts[data.ProjType]; - if (ownedCount > 0) - { - tip += "\n" + data.Name + "s : " + ownedCount; - } - } - } - } - } + public override void ModifyBuffTip(ref string tip, ref int rare) + { + foreach (DroneType type in Enum.GetValues(typeof(DroneType))) + { + if (type != DroneType.None) + { + DroneData data = DroneController.GetDroneData(type); + int ownedCount = Main.LocalPlayer.ownedProjectileCounts[data.ProjType]; + if (ownedCount > 0) + { + tip += "\n" + data.Name + "s : " + ownedCount; + } + } + } + } + } } diff --git a/Buffs/EmpoweringBuff.cs b/Buffs/EmpoweringBuff.cs index fe3168a3..095111a5 100644 --- a/Buffs/EmpoweringBuff.cs +++ b/Buffs/EmpoweringBuff.cs @@ -2,25 +2,25 @@ namespace AssortedCrazyThings.Buffs { - [Content(ContentType.Bosses)] - public class EmpoweringBuff : AssBuff - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Empowering"); - Description.SetDefault("You get stronger the longer you don't receive damage"); - } + [Content(ContentType.Bosses)] + public class EmpoweringBuff : AssBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Empowering"); + Description.SetDefault("You get stronger the longer you don't receive damage"); + } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - string add = "\nIncreased Damage: " + (int)(mPlayer.empoweringStep * 100) + "%"; - tip += add; - } + public override void ModifyBuffTip(ref string tip, ref int rare) + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + string add = "\nIncreased Damage: " + (int)(mPlayer.empoweringStep * 100) + "%"; + tip += add; + } - public override void Update(Player player, ref int buffIndex) - { - player.GetModPlayer().empoweringBuff = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.GetModPlayer().empoweringBuff = true; + } + } } diff --git a/Buffs/EnhancedHunterBuff.cs b/Buffs/EnhancedHunterBuff.cs index 2a0b325f..ff2804c1 100644 --- a/Buffs/EnhancedHunterBuff.cs +++ b/Buffs/EnhancedHunterBuff.cs @@ -1,21 +1,20 @@ using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Buffs { - [Content(ContentType.Bosses)] - public class EnhancedHunterBuff : AssBuff - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Enhanced Hunter"); - Description.SetDefault("Shows the location of enemies outside your vision range"); - } + [Content(ContentType.Bosses)] + public class EnhancedHunterBuff : AssBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Enhanced Hunter"); + Description.SetDefault("Shows the location of enemies outside your vision range"); + } - public override void Update(Player player, ref int buffIndex) - { - player.GetModPlayer().enhancedHunterBuff = true; - player.detectCreature = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.GetModPlayer().enhancedHunterBuff = true; + player.detectCreature = true; + } + } } diff --git a/Buffs/GoblinUnderlingBuff.cs b/Buffs/GoblinUnderlingBuff.cs index 7f5beaec..d129fe4e 100644 --- a/Buffs/GoblinUnderlingBuff.cs +++ b/Buffs/GoblinUnderlingBuff.cs @@ -4,33 +4,33 @@ namespace AssortedCrazyThings.Buffs { - [Content(ContentType.Weapons)] - public class GoblinUnderlingBuff : AssBuff - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Goblin Underling"); - Description.SetDefault("A loyal goblin underling is fighting for you"); - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - } + [Content(ContentType.Weapons)] + public class GoblinUnderlingBuff : AssBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Goblin Underling"); + Description.SetDefault("A loyal goblin underling is fighting for you"); + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - GoblinUnderlingPlayer modPlayer = player.GetModPlayer(); - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) - { - modPlayer.hasMinion = true; - } - if (!modPlayer.hasMinion) - { - player.DelBuff(buffIndex); - buffIndex--; - } - else - { - player.buffTime[buffIndex] = 18000; - } - } - } + public override void Update(Player player, ref int buffIndex) + { + GoblinUnderlingPlayer modPlayer = player.GetModPlayer(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + modPlayer.hasMinion = true; + } + if (!modPlayer.hasMinion) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } } diff --git a/Buffs/NPCs/Bosses/DungeonBird/BabyHarvesterBuff.cs b/Buffs/NPCs/Bosses/DungeonBird/BabyHarvesterBuff.cs index 3df25b3c..65182fc7 100644 --- a/Buffs/NPCs/Bosses/DungeonBird/BabyHarvesterBuff.cs +++ b/Buffs/NPCs/Bosses/DungeonBird/BabyHarvesterBuff.cs @@ -1,120 +1,120 @@ -using Microsoft.Xna.Framework.Graphics; +using AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.ID; -using Microsoft.Xna.Framework; -using AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird; +using Terraria.ModLoader; namespace AssortedCrazyThings.Buffs.NPCs.Bosses.DungeonBird { - [Content(ContentType.Bosses)] - public class BabyHarvesterBuff : AssBuff - { - public const int FrameCount = 3; - - private static Asset sheetAsset; - - private const string dummy = "REPLACEME"; - - public override void SetStaticDefaults() - { - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - - Main.debuff[Type] = true; - BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; - - DisplayName.SetDefault("Ominous Bird"); - Description.SetDefault(dummy); - - if (!Main.dedServ) - { - sheetAsset = ModContent.Request(Texture + "_Sheet"); - } - } - - public override void Unload() - { - sheetAsset = null; - } - - public override void ModifyBuffTip(ref string tip, ref int rare) - { - if (!TryGetBabyHarvester(out BabyHarvesterProj babyHarvester)) - { - tip = tip.Replace(dummy, ""); - return; - } - - int tier = babyHarvester.Tier; - string toReplaceWith; - if (tier == 1) - { - toReplaceWith = "What's this bird doing?"; - } - else if (tier == 2) - { - toReplaceWith = "I wonder if it will keep growing"; - } - else - { - toReplaceWith = "I'm not sure it should keep eating..."; - } - tip = tip.Replace(dummy, toReplaceWith); - - var numSouls = babyHarvester.SoulsEaten; - if (numSouls > 0) - { - tip += $"\nThe bird has absorbed {babyHarvester.SoulsEaten} souls"; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, int buffIndex, ref BuffDrawParams drawParams) - { - if (!TryGetBabyHarvester(out BabyHarvesterProj babyHarvester)) - { - return false; - } - - Texture2D ourTexture = sheetAsset.Value; - - int frameY = babyHarvester.Tier - 1; - Rectangle ourSourceRectangle = ourTexture.Frame(verticalFrames: FrameCount, frameY: frameY); - - drawParams.Texture = ourTexture; - drawParams.SourceRectangle = ourSourceRectangle; - - return true; - } - - public override void Update(Player player, ref int buffIndex) - { - if (TryGetBabyHarvester(out BabyHarvesterProj babyHarvester)) - { - if (babyHarvester.PlayerOwner == player.whoAmI) - { - player.buffTime[buffIndex] = 2; - } - } - } - - private static bool TryGetBabyHarvester(out BabyHarvesterProj babyHarvester) - { - babyHarvester = null; - if (!BabyHarvesterHandler.TryFindBabyHarvester(out Projectile proj, out _)) - { - return false; - } - - if (!(proj.ModProjectile is BabyHarvesterProj babyHarvester2 && babyHarvester2.HasValidPlayerOwner)) - { - return false; - } - - babyHarvester = babyHarvester2; - return true; - } - } + [Content(ContentType.Bosses)] + public class BabyHarvesterBuff : AssBuff + { + public const int FrameCount = 3; + + private static Asset sheetAsset; + + private const string dummy = "REPLACEME"; + + public override void SetStaticDefaults() + { + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + + Main.debuff[Type] = true; + BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; + + DisplayName.SetDefault("Ominous Bird"); + Description.SetDefault(dummy); + + if (!Main.dedServ) + { + sheetAsset = ModContent.Request(Texture + "_Sheet"); + } + } + + public override void Unload() + { + sheetAsset = null; + } + + public override void ModifyBuffTip(ref string tip, ref int rare) + { + if (!TryGetBabyHarvester(out BabyHarvesterProj babyHarvester)) + { + tip = tip.Replace(dummy, ""); + return; + } + + int tier = babyHarvester.Tier; + string toReplaceWith; + if (tier == 1) + { + toReplaceWith = "What's this bird doing?"; + } + else if (tier == 2) + { + toReplaceWith = "I wonder if it will keep growing"; + } + else + { + toReplaceWith = "I'm not sure it should keep eating..."; + } + tip = tip.Replace(dummy, toReplaceWith); + + var numSouls = babyHarvester.SoulsEaten; + if (numSouls > 0) + { + tip += $"\nThe bird has absorbed {babyHarvester.SoulsEaten} souls"; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, int buffIndex, ref BuffDrawParams drawParams) + { + if (!TryGetBabyHarvester(out BabyHarvesterProj babyHarvester)) + { + return false; + } + + Texture2D ourTexture = sheetAsset.Value; + + int frameY = babyHarvester.Tier - 1; + Rectangle ourSourceRectangle = ourTexture.Frame(verticalFrames: FrameCount, frameY: frameY); + + drawParams.Texture = ourTexture; + drawParams.SourceRectangle = ourSourceRectangle; + + return true; + } + + public override void Update(Player player, ref int buffIndex) + { + if (TryGetBabyHarvester(out BabyHarvesterProj babyHarvester)) + { + if (babyHarvester.PlayerOwner == player.whoAmI) + { + player.buffTime[buffIndex] = 2; + } + } + } + + private static bool TryGetBabyHarvester(out BabyHarvesterProj babyHarvester) + { + babyHarvester = null; + if (!BabyHarvesterHandler.TryFindBabyHarvester(out Projectile proj, out _)) + { + return false; + } + + if (!(proj.ModProjectile is BabyHarvesterProj babyHarvester2 && babyHarvester2.HasValidPlayerOwner)) + { + return false; + } + + babyHarvester = babyHarvester2; + return true; + } + } } diff --git a/Buffs/Pets/AbeeminationBuff.cs b/Buffs/Pets/AbeeminationBuff.cs index 5f9bd7ee..f8fab4ea 100644 --- a/Buffs/Pets/AbeeminationBuff.cs +++ b/Buffs/Pets/AbeeminationBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class AbeeminationBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class AbeeminationBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().Abeemination; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().Abeemination; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Abeemination"); - Description.SetDefault("An Abeemination is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Abeemination"); + Description.SetDefault("An Abeemination is following you"); + } + } } diff --git a/Buffs/Pets/AlienHornetBuff.cs b/Buffs/Pets/AlienHornetBuff.cs index c09ca6b2..2c3de276 100644 --- a/Buffs/Pets/AlienHornetBuff.cs +++ b/Buffs/Pets/AlienHornetBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class AlienHornetBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class AlienHornetBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().AlienHornet; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().AlienHornet; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Alien Hornet"); - Description.SetDefault("An Alien Hornet is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Alien Hornet"); + Description.SetDefault("An Alien Hornet is following you"); + } + } } diff --git a/Buffs/Pets/AnimatedTomeBuff.cs b/Buffs/Pets/AnimatedTomeBuff.cs index 03db58b4..851a6e26 100644 --- a/Buffs/Pets/AnimatedTomeBuff.cs +++ b/Buffs/Pets/AnimatedTomeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class AnimatedTomeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class AnimatedTomeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().AnimatedTome; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().AnimatedTome; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Animated Tome"); - Description.SetDefault("An animated tome is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Animated Tome"); + Description.SetDefault("An animated tome is following you"); + } + } } diff --git a/Buffs/Pets/AnomalocarisBuff.cs b/Buffs/Pets/AnomalocarisBuff.cs index 45026bcd..5d9c2800 100644 --- a/Buffs/Pets/AnomalocarisBuff.cs +++ b/Buffs/Pets/AnomalocarisBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class AnomalocarisBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class AnomalocarisBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetAnomalocaris; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetAnomalocaris; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Anomalocaris"); - Description.SetDefault("A little Anomalocaris is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Anomalocaris"); + Description.SetDefault("A little Anomalocaris is following you"); + } + } } diff --git a/Buffs/Pets/BabyCrimeraBuff.cs b/Buffs/Pets/BabyCrimeraBuff.cs index 9e34ddd6..6822a628 100644 --- a/Buffs/Pets/BabyCrimeraBuff.cs +++ b/Buffs/Pets/BabyCrimeraBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class BabyCrimeraBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class BabyCrimeraBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().BabyCrimera; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().BabyCrimera; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Baby Crimera"); - Description.SetDefault("A little Crimera is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Baby Crimera"); + Description.SetDefault("A little Crimera is following you"); + } + } } diff --git a/Buffs/Pets/BabyIchorStickerBuff.cs b/Buffs/Pets/BabyIchorStickerBuff.cs index 08378498..71a26e5f 100644 --- a/Buffs/Pets/BabyIchorStickerBuff.cs +++ b/Buffs/Pets/BabyIchorStickerBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class BabyIchorStickerBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class BabyIchorStickerBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().BabyIchorSticker; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().BabyIchorSticker; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Lil' Ichy"); - Description.SetDefault("A baby Ichor Sticker is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Lil' Ichy"); + Description.SetDefault("A baby Ichor Sticker is following you"); + } + } } diff --git a/Buffs/Pets/BabyOcramBuff.cs b/Buffs/Pets/BabyOcramBuff.cs index 9fa0abc9..0314ba9c 100644 --- a/Buffs/Pets/BabyOcramBuff.cs +++ b/Buffs/Pets/BabyOcramBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] - public class BabyOcramBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] + public class BabyOcramBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().BabyOcram; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().BabyOcram; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Baby Ocram"); - Description.SetDefault("What could have been now follows you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Baby Ocram"); + Description.SetDefault("What could have been now follows you"); + } + } } diff --git a/Buffs/Pets/BrainofConfusionBuff.cs b/Buffs/Pets/BrainofConfusionBuff.cs index fc5265d3..8700aa46 100644 --- a/Buffs/Pets/BrainofConfusionBuff.cs +++ b/Buffs/Pets/BrainofConfusionBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class BrainofConfusionBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class BrainofConfusionBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().BrainofConfusion; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().BrainofConfusion; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Brain of Confusion"); - Description.SetDefault("A Brain of Confusion is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Brain of Confusion"); + Description.SetDefault("A Brain of Confusion is following you"); + } + } } diff --git a/Buffs/Pets/ChunkySlimeBuff.cs b/Buffs/Pets/ChunkySlimeBuff.cs index 3e087351..1e92b65f 100644 --- a/Buffs/Pets/ChunkySlimeBuff.cs +++ b/Buffs/Pets/ChunkySlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class ChunkySlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class ChunkySlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().ChunkySlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().ChunkySlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Chunky"); - Description.SetDefault("Chunky is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Chunky"); + Description.SetDefault("Chunky is following you"); + } + } } diff --git a/Buffs/Pets/ChunkyandMeatballBuff.cs b/Buffs/Pets/ChunkyandMeatballBuff.cs index 23dfc22d..f2e49c98 100644 --- a/Buffs/Pets/ChunkyandMeatballBuff.cs +++ b/Buffs/Pets/ChunkyandMeatballBuff.cs @@ -4,38 +4,38 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class ChunkyandMeatballBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class ChunkyandMeatballBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().ChunkyandMeatball; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().ChunkyandMeatball; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Chunky and Meatball"); - Description.SetDefault("Two reunited brothers are following you"); - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Chunky and Meatball"); + Description.SetDefault("Two reunited brothers are following you"); + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - PetBool(player) = true; - if (player.whoAmI == Main.myPlayer) - { - int chunky = ModContent.ProjectileType(); - bool chunkyNotSpawned = player.ownedProjectileCounts[chunky] <= 0; - int meatball = ModContent.ProjectileType(); - bool meatballNotSpawned = player.ownedProjectileCounts[meatball] <= 0; - if (chunkyNotSpawned) - { - Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Top.Y - 6f, player.direction * 0.75f, -0.5f, chunky, 0, 0f, player.whoAmI); - } - if (meatballNotSpawned) - { - Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Bottom.Y + 6f, player.direction * 0.75f, 0.5f, meatball, 0, 0f, player.whoAmI); - } - } - } - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + PetBool(player) = true; + if (player.whoAmI == Main.myPlayer) + { + int chunky = ModContent.ProjectileType(); + bool chunkyNotSpawned = player.ownedProjectileCounts[chunky] <= 0; + int meatball = ModContent.ProjectileType(); + bool meatballNotSpawned = player.ownedProjectileCounts[meatball] <= 0; + if (chunkyNotSpawned) + { + Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Top.Y - 6f, player.direction * 0.75f, -0.5f, chunky, 0, 0f, player.whoAmI); + } + if (meatballNotSpawned) + { + Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Bottom.Y + 6f, player.direction * 0.75f, 0.5f, meatball, 0, 0f, player.whoAmI); + } + } + } + } } diff --git a/Buffs/Pets/CompanionDungeonSoulPetBuff.cs b/Buffs/Pets/CompanionDungeonSoulPetBuff.cs index 17950f3d..b121f814 100644 --- a/Buffs/Pets/CompanionDungeonSoulPetBuff.cs +++ b/Buffs/Pets/CompanionDungeonSoulPetBuff.cs @@ -4,20 +4,20 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.Bosses)] - public class CompanionDungeonSoulPetBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.Bosses)] + public class CompanionDungeonSoulPetBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().SoulLightPet; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().SoulLightPet; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Companion Soul"); - Description.SetDefault("A friendly Dungeon Soul is following you" - + "\nLight pet slot"); - Main.vanityPet[Type] = false; - Main.lightPet[Type] = true; - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Companion Soul"); + Description.SetDefault("A friendly Dungeon Soul is following you" + + "\nLight pet slot"); + Main.vanityPet[Type] = false; + Main.lightPet[Type] = true; + } + } } diff --git a/Buffs/Pets/CompanionDungeonSoulPetBuff2.cs b/Buffs/Pets/CompanionDungeonSoulPetBuff2.cs index 3e78676b..8fd55a19 100644 --- a/Buffs/Pets/CompanionDungeonSoulPetBuff2.cs +++ b/Buffs/Pets/CompanionDungeonSoulPetBuff2.cs @@ -4,20 +4,20 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.Bosses)] - public class CompanionDungeonSoulPetBuff2 : SimplePetBuffBase - { - public override string Texture => "AssortedCrazyThings/Buffs/Pets/CompanionDungeonSoulPetBuff"; + [Content(ContentType.Bosses)] + public class CompanionDungeonSoulPetBuff2 : SimplePetBuffBase + { + public override string Texture => "AssortedCrazyThings/Buffs/Pets/CompanionDungeonSoulPetBuff"; - public override int PetType => ModContent.ProjectileType(); + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().SoulLightPet2; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().SoulLightPet2; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Companion Soul"); - Description.SetDefault("A friendly Dungeon Soul is following you" - + "\nPet slot"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Companion Soul"); + Description.SetDefault("A friendly Dungeon Soul is following you" + + "\nPet slot"); + } + } } diff --git a/Buffs/Pets/CursedSkullBuff.cs b/Buffs/Pets/CursedSkullBuff.cs index 49e006c7..096d63c4 100644 --- a/Buffs/Pets/CursedSkullBuff.cs +++ b/Buffs/Pets/CursedSkullBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class CursedSkullBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CursedSkullBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CursedSkull; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CursedSkull; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cursed Skull"); - Description.SetDefault("It won't curse you, I promise"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cursed Skull"); + Description.SetDefault("It won't curse you, I promise"); + } + } } diff --git a/Buffs/Pets/CuteGastropodBuff.cs b/Buffs/Pets/CuteGastropodBuff.cs index 89c030ac..9de2c949 100644 --- a/Buffs/Pets/CuteGastropodBuff.cs +++ b/Buffs/Pets/CuteGastropodBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.CuteSlimes)] - public class CuteGastropodBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.CuteSlimes)] + public class CuteGastropodBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteGastropod; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteGastropod; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Gastropod"); - Description.SetDefault("A cute Gastropod is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Gastropod"); + Description.SetDefault("A cute Gastropod is following you"); + } + } } diff --git a/Buffs/Pets/CuteLamiaPetBuff.cs b/Buffs/Pets/CuteLamiaPetBuff.cs index e0f620fa..ae4b2364 100644 --- a/Buffs/Pets/CuteLamiaPetBuff.cs +++ b/Buffs/Pets/CuteLamiaPetBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class CuteLamiaPetBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class CuteLamiaPetBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteLamiaPet; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteLamiaPet; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Small Snake"); - Description.SetDefault("A small snake is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Small Snake"); + Description.SetDefault("A small snake is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeBlackBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeBlackBuff.cs index 241dd7ac..2edc7351 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeBlackBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeBlackBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeBlackBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeBlackBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeBlack; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeBlack; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Black Slime"); - Description.SetDefault("A cute black slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Black Slime"); + Description.SetDefault("A cute black slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeBlueBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeBlueBuff.cs index e5e0ba49..691cec68 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeBlueBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeBlueBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeBlueBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeBlueBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeBlue; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeBlue; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Blue Slime"); - Description.SetDefault("A cute blue slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Blue Slime"); + Description.SetDefault("A cute blue slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeBuffBase.cs b/Buffs/Pets/CuteSlimes/CuteSlimeBuffBase.cs index 244dfd98..046a2165 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeBuffBase.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeBuffBase.cs @@ -1,8 +1,8 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - [Content(ContentType.CuteSlimes)] - public abstract class CuteSlimeBuffBase : SimplePetBuffBase - { + [Content(ContentType.CuteSlimes)] + public abstract class CuteSlimeBuffBase : SimplePetBuffBase + { - } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeCorruptBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeCorruptBuff.cs index 10fadd12..c2a45cbb 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeCorruptBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeCorruptBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeCorruptBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeCorruptBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeCorrupt; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeCorrupt; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Corrupt Slime"); - Description.SetDefault("A cute corrupt slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Corrupt Slime"); + Description.SetDefault("A cute corrupt slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeCrimsonBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeCrimsonBuff.cs index 22efa78f..5747bc5c 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeCrimsonBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeCrimsonBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeCrimsonBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeCrimsonBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeCrimson; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeCrimson; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Crimson Slime"); - Description.SetDefault("A cute crimson slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Crimson Slime"); + Description.SetDefault("A cute crimson slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeDungeonBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeDungeonBuff.cs index e881c56c..c49d510a 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeDungeonBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeDungeonBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeDungeonBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeDungeonBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeDungeon; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeDungeon; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Dungeon Slime"); - Description.SetDefault("A cute dungeon slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Dungeon Slime"); + Description.SetDefault("A cute dungeon slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeGreenBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeGreenBuff.cs index eada116a..bae33a2b 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeGreenBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeGreenBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeGreenBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeGreenBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeGreen; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeGreen; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Green Slime"); - Description.SetDefault("A cute green slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Green Slime"); + Description.SetDefault("A cute green slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeIceBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeIceBuff.cs index 348aa3e3..c49ee090 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeIceBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeIceBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeIceBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeIceBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeIce; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeIce; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Ice Slime"); - Description.SetDefault("A cute ice slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Ice Slime"); + Description.SetDefault("A cute ice slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeIlluminantBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeIlluminantBuff.cs index feea3380..3493bb02 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeIlluminantBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeIlluminantBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeIlluminantBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeIlluminantBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeIlluminant; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeIlluminant; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Illumimant Slime"); - Description.SetDefault("A cute illumimant slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Illumimant Slime"); + Description.SetDefault("A cute illumimant slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeJungleBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeJungleBuff.cs index 45186919..fb5051e2 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeJungleBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeJungleBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeJungleBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeJungleBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeJungle; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeJungle; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Jungle Slime"); - Description.SetDefault("A cute jungle slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Jungle Slime"); + Description.SetDefault("A cute jungle slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeLavaBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeLavaBuff.cs index 4ac06650..84ae2760 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeLavaBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeLavaBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeLavaBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeLavaBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeLava; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeLava; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Lava Slime"); - Description.SetDefault("A cute lava slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Lava Slime"); + Description.SetDefault("A cute lava slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimePinkBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimePinkBuff.cs index 33a0c641..ae5a3f9c 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimePinkBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimePinkBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimePinkBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimePinkBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePink; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePink; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Pink Slime"); - Description.SetDefault("A cute pink slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Pink Slime"); + Description.SetDefault("A cute pink slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimePrincessBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimePrincessBuff.cs index 6e3b9021..77e84c1a 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimePrincessBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimePrincessBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimePrincessBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimePrincessBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePrincess; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePrincess; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Princess Slime"); - Description.SetDefault("A cute princess slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Princess Slime"); + Description.SetDefault("A cute princess slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimePurpleBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimePurpleBuff.cs index 070f2f82..2f83491c 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimePurpleBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimePurpleBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimePurpleBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimePurpleBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePurple; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePurple; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Purple Slime"); - Description.SetDefault("A cute purple slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Purple Slime"); + Description.SetDefault("A cute purple slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeQueenBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeQueenBuff.cs index 25486968..1eb92301 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeQueenBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeQueenBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - [Content(ContentType.CuteSlimes)] - public class CuteSlimeQueenBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.CuteSlimes)] + public class CuteSlimeQueenBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeQueen; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeQueen; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Queen Slime"); - Description.SetDefault("A cute royal slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Queen Slime"); + Description.SetDefault("A cute royal slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeRainbowBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeRainbowBuff.cs index 220224de..603f6cef 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeRainbowBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeRainbowBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeRainbowBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeRainbowBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeRainbow; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeRainbow; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Rainbow Slime"); - Description.SetDefault("A cute rainbow slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Rainbow Slime"); + Description.SetDefault("A cute rainbow slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeRedBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeRedBuff.cs index 8e47bca3..ee96b89a 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeRedBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeRedBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeRedBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeRedBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeRed; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeRed; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Red Slime"); - Description.SetDefault("A cute red slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Red Slime"); + Description.SetDefault("A cute red slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeSandBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeSandBuff.cs index 950d13ea..8a22bd7e 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeSandBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeSandBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeSandBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeSandBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeSand; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeSand; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Sand Slime"); - Description.SetDefault("A cute sand slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Sand Slime"); + Description.SetDefault("A cute sand slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeToxicBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeToxicBuff.cs index 4fc0abce..290d7148 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeToxicBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeToxicBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeToxicBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeToxicBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeToxic; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeToxic; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Toxic Slime"); - Description.SetDefault("A cute toxic slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Toxic Slime"); + Description.SetDefault("A cute toxic slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeXmasBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeXmasBuff.cs index c1b6c9e9..be19c7b7 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeXmasBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeXmasBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeXmasBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeXmasBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeXmas; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeXmas; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Christmas Slime"); - Description.SetDefault("A cute christmas slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Christmas Slime"); + Description.SetDefault("A cute christmas slime is following you"); + } + } } diff --git a/Buffs/Pets/CuteSlimes/CuteSlimeYellowBuff.cs b/Buffs/Pets/CuteSlimes/CuteSlimeYellowBuff.cs index e247632f..d7f6785e 100644 --- a/Buffs/Pets/CuteSlimes/CuteSlimeYellowBuff.cs +++ b/Buffs/Pets/CuteSlimes/CuteSlimeYellowBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets.CuteSlimes { - public class CuteSlimeYellowBuff : CuteSlimeBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class CuteSlimeYellowBuff : CuteSlimeBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeYellow; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeYellow; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Cute Yellow Slime"); - Description.SetDefault("A cute yellow slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Cute Yellow Slime"); + Description.SetDefault("A cute yellow slime is following you"); + } + } } diff --git a/Buffs/Pets/DemonHeartBuff.cs b/Buffs/Pets/DemonHeartBuff.cs index 16e137ae..05fbdadb 100644 --- a/Buffs/Pets/DemonHeartBuff.cs +++ b/Buffs/Pets/DemonHeartBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class DemonHeartBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class DemonHeartBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().DemonHeart; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().DemonHeart; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Demon Heart"); - Description.SetDefault("A Demon Heart is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Demon Heart"); + Description.SetDefault("A Demon Heart is following you"); + } + } } diff --git a/Buffs/Pets/DetachedHungryBuff.cs b/Buffs/Pets/DetachedHungryBuff.cs index a0f47006..e2e1e3e7 100644 --- a/Buffs/Pets/DetachedHungryBuff.cs +++ b/Buffs/Pets/DetachedHungryBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class DetachedHungryBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class DetachedHungryBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().DetachedHungry; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().DetachedHungry; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Detached Hungry"); - Description.SetDefault("You might be the next meal..."); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Detached Hungry"); + Description.SetDefault("You might be the next meal..."); + } + } } diff --git a/Buffs/Pets/DocileDemonEyeBuff.cs b/Buffs/Pets/DocileDemonEyeBuff.cs index b5c17d9c..f8a46b04 100644 --- a/Buffs/Pets/DocileDemonEyeBuff.cs +++ b/Buffs/Pets/DocileDemonEyeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class DocileDemonEyeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class DocileDemonEyeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().DocileDemonEye; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().DocileDemonEye; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Docile Demon Eye"); - Description.SetDefault("A Demon Eye is following you" - + "\nChange its appearance with a Demon Eye Contact Case"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Docile Demon Eye"); + Description.SetDefault("A Demon Eye is following you" + + "\nChange its appearance with a Demon Eye Contact Case"); + } + } } diff --git a/Buffs/Pets/DrumstickElementalBuff.cs b/Buffs/Pets/DrumstickElementalBuff.cs index a4cb2726..f39e2913 100644 --- a/Buffs/Pets/DrumstickElementalBuff.cs +++ b/Buffs/Pets/DrumstickElementalBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class DrumstickElementalBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class DrumstickElementalBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().DrumstickElemental; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().DrumstickElemental; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Drumstick Elemental"); - Description.SetDefault("Dinner is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Drumstick Elemental"); + Description.SetDefault("Dinner is following you"); + } + } } diff --git a/Buffs/Pets/DynamiteBunnyBuff.cs b/Buffs/Pets/DynamiteBunnyBuff.cs index 0c328062..51352c3d 100644 --- a/Buffs/Pets/DynamiteBunnyBuff.cs +++ b/Buffs/Pets/DynamiteBunnyBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class DynamiteBunnyBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class DynamiteBunnyBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().DynamiteBunny; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().DynamiteBunny; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Dynamite Bunny"); - Description.SetDefault("A little Dynamite Bunny is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Dynamite Bunny"); + Description.SetDefault("A little Dynamite Bunny is following you"); + } + } } diff --git a/Buffs/Pets/EnchantedSwordBuff.cs b/Buffs/Pets/EnchantedSwordBuff.cs index 128709bb..ae8a2345 100644 --- a/Buffs/Pets/EnchantedSwordBuff.cs +++ b/Buffs/Pets/EnchantedSwordBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class EnchantedSwordBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class EnchantedSwordBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().EnchantedSword; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().EnchantedSword; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Enchanted Sword"); - Description.SetDefault("The Enchanted Sword watches over you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Enchanted Sword"); + Description.SetDefault("The Enchanted Sword watches over you"); + } + } } diff --git a/Buffs/Pets/FailureSlimeBuff.cs b/Buffs/Pets/FailureSlimeBuff.cs index 45908bf6..148f1887 100644 --- a/Buffs/Pets/FailureSlimeBuff.cs +++ b/Buffs/Pets/FailureSlimeBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class FailureSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class FailureSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().FailureSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().FailureSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Failure Slime"); - Description.SetDefault("A strange creature is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Failure Slime"); + Description.SetDefault("A strange creature is following you"); + } + } } diff --git a/Buffs/Pets/FairySlimeBuff.cs b/Buffs/Pets/FairySlimeBuff.cs index 1fb902da..6d6c0b7d 100644 --- a/Buffs/Pets/FairySlimeBuff.cs +++ b/Buffs/Pets/FairySlimeBuff.cs @@ -4,19 +4,19 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.FriendlyNPCs)] - public class FairySlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.FriendlyNPCs)] + public class FairySlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().FairySlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().FairySlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Fairy Slime"); - Description.SetDefault("A Fairy Slime is following you"); - Main.buffNoTimeDisplay[Type] = true; - Main.vanityPet[Type] = true; - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Fairy Slime"); + Description.SetDefault("A Fairy Slime is following you"); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } + } } diff --git a/Buffs/Pets/FairySwarmBuff.cs b/Buffs/Pets/FairySwarmBuff.cs index 32dd1692..3429d88a 100644 --- a/Buffs/Pets/FairySwarmBuff.cs +++ b/Buffs/Pets/FairySwarmBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class FairySwarmBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class FairySwarmBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().FairySwarm; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().FairySwarm; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Fairy Swarm"); - Description.SetDefault("A Fairy Swarm is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Fairy Swarm"); + Description.SetDefault("A Fairy Swarm is following you"); + } + } } diff --git a/Buffs/Pets/GhostMartianBuff.cs b/Buffs/Pets/GhostMartianBuff.cs index c89c0a5d..13612193 100644 --- a/Buffs/Pets/GhostMartianBuff.cs +++ b/Buffs/Pets/GhostMartianBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class GhostMartianBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class GhostMartianBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().GhostMartian; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().GhostMartian; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Ghost Martian"); - Description.SetDefault("A vengeful invader's ghost is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Ghost Martian"); + Description.SetDefault("A vengeful invader's ghost is following you"); + } + } } diff --git a/Buffs/Pets/GobletBuff.cs b/Buffs/Pets/GobletBuff.cs index 0262349e..d7fb4768 100644 --- a/Buffs/Pets/GobletBuff.cs +++ b/Buffs/Pets/GobletBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class GobletBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class GobletBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().Goblet; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().Goblet; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Goblet"); - Description.SetDefault("A tiny Goblin is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Goblet"); + Description.SetDefault("A tiny Goblin is following you"); + } + } } diff --git a/Buffs/Pets/HornedSlimeBuff.cs b/Buffs/Pets/HornedSlimeBuff.cs index 03d0ddc6..f0c35582 100644 --- a/Buffs/Pets/HornedSlimeBuff.cs +++ b/Buffs/Pets/HornedSlimeBuff.cs @@ -4,19 +4,19 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class HornedSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class HornedSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().HornedSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().HornedSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Horned Slime"); - Description.SetDefault("A Horned Slime is following you"); - Main.buffNoTimeDisplay[Type] = true; - Main.vanityPet[Type] = true; - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Horned Slime"); + Description.SetDefault("A Horned Slime is following you"); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } + } } diff --git a/Buffs/Pets/IlluminantSlimeBuff.cs b/Buffs/Pets/IlluminantSlimeBuff.cs index 947e26b8..89e7104a 100644 --- a/Buffs/Pets/IlluminantSlimeBuff.cs +++ b/Buffs/Pets/IlluminantSlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class IlluminantSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class IlluminantSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().IlluminantSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().IlluminantSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Illuminant Slime"); - Description.SetDefault("An Illuminant Slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Illuminant Slime"); + Description.SetDefault("An Illuminant Slime is following you"); + } + } } diff --git a/Buffs/Pets/JoyousSlimeBuff.cs b/Buffs/Pets/JoyousSlimeBuff.cs index 4813f510..b633911f 100644 --- a/Buffs/Pets/JoyousSlimeBuff.cs +++ b/Buffs/Pets/JoyousSlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.FriendlyNPCs)] - public class JoyousSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.FriendlyNPCs)] + public class JoyousSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().JoyousSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().JoyousSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Joyous Slime"); - Description.SetDefault("A Joyous Slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Joyous Slime"); + Description.SetDefault("A Joyous Slime is following you"); + } + } } diff --git a/Buffs/Pets/LifelikeMechanicalFrogBuff.cs b/Buffs/Pets/LifelikeMechanicalFrogBuff.cs index fea94385..717829d6 100644 --- a/Buffs/Pets/LifelikeMechanicalFrogBuff.cs +++ b/Buffs/Pets/LifelikeMechanicalFrogBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class LifelikeMechanicalFrogBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class LifelikeMechanicalFrogBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().LifelikeMechanicalFrog; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().LifelikeMechanicalFrog; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Lifelike Mechanical Frog"); - Description.SetDefault("Whatever happened to this frog at the anvil is a mystery"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Lifelike Mechanical Frog"); + Description.SetDefault("Whatever happened to this frog at the anvil is a mystery"); + } + } } diff --git a/Buffs/Pets/LilWrapsBuff.cs b/Buffs/Pets/LilWrapsBuff.cs index e576077d..2433fb7d 100644 --- a/Buffs/Pets/LilWrapsBuff.cs +++ b/Buffs/Pets/LilWrapsBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class LilWrapsBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class LilWrapsBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().LilWraps; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().LilWraps; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Lil' Wraps"); - Description.SetDefault("A Mummy is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Lil' Wraps"); + Description.SetDefault("A Mummy is following you"); + } + } } diff --git a/Buffs/Pets/MeatballSlimeBuff.cs b/Buffs/Pets/MeatballSlimeBuff.cs index 374c6ecf..f40e2ac4 100644 --- a/Buffs/Pets/MeatballSlimeBuff.cs +++ b/Buffs/Pets/MeatballSlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class MeatballSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class MeatballSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().MeatballSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().MeatballSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Meatball"); - Description.SetDefault("Meatball is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Meatball"); + Description.SetDefault("Meatball is following you"); + } + } } diff --git a/Buffs/Pets/MetroidPetBuff.cs b/Buffs/Pets/MetroidPetBuff.cs index 9789c9ae..32833ba1 100644 --- a/Buffs/Pets/MetroidPetBuff.cs +++ b/Buffs/Pets/MetroidPetBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class MetroidPetBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class MetroidPetBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().MetroidPet; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().MetroidPet; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Metroid"); - Description.SetDefault("A space parasite is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Metroid"); + Description.SetDefault("A space parasite is following you"); + } + } } diff --git a/Buffs/Pets/MiniAntlionBuff.cs b/Buffs/Pets/MiniAntlionBuff.cs index ed718b61..e6eecb87 100644 --- a/Buffs/Pets/MiniAntlionBuff.cs +++ b/Buffs/Pets/MiniAntlionBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class MiniAntlionBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class MiniAntlionBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().MiniAntlion; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().MiniAntlion; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Baby Antlion"); - Description.SetDefault("A Baby Antlion is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Baby Antlion"); + Description.SetDefault("A Baby Antlion is following you"); + } + } } diff --git a/Buffs/Pets/MiniMegalodonBuff.cs b/Buffs/Pets/MiniMegalodonBuff.cs index 736cd249..1b45523f 100644 --- a/Buffs/Pets/MiniMegalodonBuff.cs +++ b/Buffs/Pets/MiniMegalodonBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] - public class MiniMegalodonBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] + public class MiniMegalodonBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().MiniMegalodon; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().MiniMegalodon; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Mini Megalodon"); - Description.SetDefault("It recognizes your strength...for now"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Mini Megalodon"); + Description.SetDefault("It recognizes your strength...for now"); + } + } } diff --git a/Buffs/Pets/NumberMuncherBuff.cs b/Buffs/Pets/NumberMuncherBuff.cs index 3adcaf97..cd74b0c2 100644 --- a/Buffs/Pets/NumberMuncherBuff.cs +++ b/Buffs/Pets/NumberMuncherBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class NumberMuncherBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class NumberMuncherBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().NumberMuncher; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().NumberMuncher; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Number Muncher"); - Description.SetDefault("An educated amphibian is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Number Muncher"); + Description.SetDefault("An educated amphibian is following you"); + } + } } diff --git a/Buffs/Pets/OceanSlimeBuff.cs b/Buffs/Pets/OceanSlimeBuff.cs index 091b2921..c198ffd3 100644 --- a/Buffs/Pets/OceanSlimeBuff.cs +++ b/Buffs/Pets/OceanSlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class OceanSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class OceanSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().OceanSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().OceanSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Ocean Slime"); - Description.SetDefault("A Ocean Slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Ocean Slime"); + Description.SetDefault("A Ocean Slime is following you"); + } + } } diff --git a/Buffs/Pets/PetCultistBuff.cs b/Buffs/Pets/PetCultistBuff.cs index 9743c8bb..bd772786 100644 --- a/Buffs/Pets/PetCultistBuff.cs +++ b/Buffs/Pets/PetCultistBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class PetCultistBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetCultistBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetCultist; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetCultist; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Dwarf Cultist"); - Description.SetDefault("A tiny Cultist is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Dwarf Cultist"); + Description.SetDefault("A tiny Cultist is following you"); + } + } } diff --git a/Buffs/Pets/PetDestroyerBuff.cs b/Buffs/Pets/PetDestroyerBuff.cs index b78faa70..6eb4e169 100644 --- a/Buffs/Pets/PetDestroyerBuff.cs +++ b/Buffs/Pets/PetDestroyerBuff.cs @@ -5,28 +5,28 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class PetDestroyerBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetDestroyerBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetDestroyer; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetDestroyer; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Tiny Destroyer"); - Description.SetDefault("A tiny Destroyer and two tiny Probes are following you"); - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Tiny Destroyer"); + Description.SetDefault("A tiny Destroyer and two tiny Probes are following you"); + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - PetBool(player) = true; - bool petProjectileNotSpawned = player.ownedProjectileCounts[PetType] <= 0; - if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) - { - PetDestroyerItem.Spawn(player, buffIndex: buffIndex); - } - } - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + PetBool(player) = true; + bool petProjectileNotSpawned = player.ownedProjectileCounts[PetType] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + PetDestroyerItem.Spawn(player, buffIndex: buffIndex); + } + } + } } diff --git a/Buffs/Pets/PetEaterofWorldsBuff.cs b/Buffs/Pets/PetEaterofWorldsBuff.cs index c2e1e999..1fe9996a 100644 --- a/Buffs/Pets/PetEaterofWorldsBuff.cs +++ b/Buffs/Pets/PetEaterofWorldsBuff.cs @@ -5,28 +5,28 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class PetEaterofWorldsBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetEaterofWorldsBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetEaterofWorlds; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetEaterofWorlds; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Tiny Eater of Worlds"); - Description.SetDefault("A tiny Eater of Worlds is following you"); - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Tiny Eater of Worlds"); + Description.SetDefault("A tiny Eater of Worlds is following you"); + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - PetBool(player) = true; - bool petProjectileNotSpawned = player.ownedProjectileCounts[PetType] <= 0; - if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) - { - PetEaterofWorldsItem.Spawn(player, buffIndex: buffIndex); - } - } - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + PetBool(player) = true; + bool petProjectileNotSpawned = player.ownedProjectileCounts[PetType] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + PetEaterofWorldsItem.Spawn(player, buffIndex: buffIndex); + } + } + } } diff --git a/Buffs/Pets/PetFishronBuff.cs b/Buffs/Pets/PetFishronBuff.cs index 5ceec37a..00d09821 100644 --- a/Buffs/Pets/PetFishronBuff.cs +++ b/Buffs/Pets/PetFishronBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class PetFishronBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetFishronBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetFishron; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetFishron; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Fishron"); - Description.SetDefault("A Fishron is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Fishron"); + Description.SetDefault("A Fishron is following you"); + } + } } diff --git a/Buffs/Pets/PetGoldfishBuff.cs b/Buffs/Pets/PetGoldfishBuff.cs index d82dd13a..4c35bbf6 100644 --- a/Buffs/Pets/PetGoldfishBuff.cs +++ b/Buffs/Pets/PetGoldfishBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class PetGoldfishBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetGoldfishBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetGoldfish; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetGoldfish; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Possessed Goldfish"); - Description.SetDefault("A possessed goldfish is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Possessed Goldfish"); + Description.SetDefault("A possessed goldfish is following you"); + } + } } diff --git a/Buffs/Pets/PetGolemHeadBuff.cs b/Buffs/Pets/PetGolemHeadBuff.cs index 93f895f5..e6fb77d1 100644 --- a/Buffs/Pets/PetGolemHeadBuff.cs +++ b/Buffs/Pets/PetGolemHeadBuff.cs @@ -4,18 +4,18 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class PetGolemHeadBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetGolemHeadBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetGolemHead; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetGolemHead; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Replica Golem Head"); - Description.SetDefault("A Replica Golem Head watches over you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Replica Golem Head"); + Description.SetDefault("A Replica Golem Head watches over you"); + } + } } diff --git a/Buffs/Pets/PetHarvesterBuff.cs b/Buffs/Pets/PetHarvesterBuff.cs index 58dd67c2..1e76e393 100644 --- a/Buffs/Pets/PetHarvesterBuff.cs +++ b/Buffs/Pets/PetHarvesterBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.Bosses)] - public class PetHarvesterBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.Bosses)] + public class PetHarvesterBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetHarvester; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetHarvester; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Stubborn Bird"); - Description.SetDefault("A stubborn bird is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Stubborn Bird"); + Description.SetDefault("A stubborn bird is following you"); + } + } } diff --git a/Buffs/Pets/PetMoonBuff.cs b/Buffs/Pets/PetMoonBuff.cs index e847b95a..116b69a3 100644 --- a/Buffs/Pets/PetMoonBuff.cs +++ b/Buffs/Pets/PetMoonBuff.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class PetMoonBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetMoonBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetMoon; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetMoon; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Personal Moon"); - Description.SetDefault("A small moon is providing you with constant moonlight"); - Main.vanityPet[Type] = false; - Main.lightPet[Type] = true; - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Personal Moon"); + Description.SetDefault("A small moon is providing you with constant moonlight"); + Main.vanityPet[Type] = false; + Main.lightPet[Type] = true; + } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - tip += "\n" + AssUtils.GetMoonPhaseAsString(); - } - } + public override void ModifyBuffTip(ref string tip, ref int rare) + { + tip += "\n" + AssUtils.GetMoonPhaseAsString(); + } + } } diff --git a/Buffs/Pets/PetPlanteraBuff.cs b/Buffs/Pets/PetPlanteraBuff.cs index db5e2560..dafd546f 100644 --- a/Buffs/Pets/PetPlanteraBuff.cs +++ b/Buffs/Pets/PetPlanteraBuff.cs @@ -5,30 +5,30 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class PetPlanteraBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetPlanteraBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetPlantera; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetPlantera; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Plantera Sprout"); - Description.SetDefault("A Plantera Sprout is following you"); - Main.buffNoTimeDisplay[Type] = true; - Main.vanityPet[Type] = true; - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Plantera Sprout"); + Description.SetDefault("A Plantera Sprout is following you"); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - PetBool(player) = true; - bool petProjectileNotSpawned = player.ownedProjectileCounts[PetType] <= 0; - if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) - { - PetPlanteraItem.Spawn(player, buffIndex: buffIndex); - } - } - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + PetBool(player) = true; + bool petProjectileNotSpawned = player.ownedProjectileCounts[PetType] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + PetPlanteraItem.Spawn(player, buffIndex: buffIndex); + } + } + } } diff --git a/Buffs/Pets/PetQueenSlimeBuff.cs b/Buffs/Pets/PetQueenSlimeBuff.cs index b52697cd..08937e74 100644 --- a/Buffs/Pets/PetQueenSlimeBuff.cs +++ b/Buffs/Pets/PetQueenSlimeBuff.cs @@ -1,49 +1,48 @@ using AssortedCrazyThings.Projectiles.Pets; using Terraria; -using Terraria.DataStructures; using Terraria.ModLoader; namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class PetQueenSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetQueenSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetQueenSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetQueenSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Playful Slimelings"); - Description.SetDefault("A trio of slimelings is following you"); - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Playful Slimelings"); + Description.SetDefault("A trio of slimelings is following you"); + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - PetBool(player) = true; - if (player.whoAmI == Main.myPlayer) - { - int air = ModContent.ProjectileType(); - var spawnSource = player.GetProjectileSource_Buff(buffIndex); - if (player.ownedProjectileCounts[air] <= 0) - { - Projectile.NewProjectile(spawnSource, player.Center.X, player.Center.Y, 0, -0.5f, air, 0, 0f, player.whoAmI); - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + PetBool(player) = true; + if (player.whoAmI == Main.myPlayer) + { + int air = ModContent.ProjectileType(); + var spawnSource = player.GetProjectileSource_Buff(buffIndex); + if (player.ownedProjectileCounts[air] <= 0) + { + Projectile.NewProjectile(spawnSource, player.Center.X, player.Center.Y, 0, -0.5f, air, 0, 0f, player.whoAmI); + } - int ground1 = ModContent.ProjectileType(); - if (player.ownedProjectileCounts[ground1] <= 0) - { - Projectile.NewProjectile(spawnSource, player.Center.X - 20f, player.Center.Y, player.direction * -0.75f, 0f, ground1, 0, 0f, player.whoAmI); + int ground1 = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[ground1] <= 0) + { + Projectile.NewProjectile(spawnSource, player.Center.X - 20f, player.Center.Y, player.direction * -0.75f, 0f, ground1, 0, 0f, player.whoAmI); - } + } - int ground2 = ModContent.ProjectileType(); - if (player.ownedProjectileCounts[ground2] <= 0) - { - Projectile.NewProjectile(spawnSource, player.Center.X + 20f, player.Center.Y, player.direction * 0.75f, 0, ground2, 0, 0f, player.whoAmI); - } - } - } - } + int ground2 = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[ground2] <= 0) + { + Projectile.NewProjectile(spawnSource, player.Center.X + 20f, player.Center.Y, player.direction * 0.75f, 0, ground2, 0, 0f, player.whoAmI); + } + } + } + } } diff --git a/Buffs/Pets/PetSunBuff.cs b/Buffs/Pets/PetSunBuff.cs index a947feee..c546ef62 100644 --- a/Buffs/Pets/PetSunBuff.cs +++ b/Buffs/Pets/PetSunBuff.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class PetSunBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetSunBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetSun; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetSun; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Personal Sun"); - Description.SetDefault("A small sun is providing you with constant sunlight"); - Main.vanityPet[Type] = false; - Main.lightPet[Type] = true; - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Personal Sun"); + Description.SetDefault("A small sun is providing you with constant sunlight"); + Main.vanityPet[Type] = false; + Main.lightPet[Type] = true; + } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - tip += "\n" + AssUtils.GetTimeAsString(); - } - } + public override void ModifyBuffTip(ref string tip, ref int rare) + { + tip += "\n" + AssUtils.GetTimeAsString(); + } + } } diff --git a/Buffs/Pets/PetSunMoonBuff.cs b/Buffs/Pets/PetSunMoonBuff.cs index f03afaeb..6bb95ec6 100644 --- a/Buffs/Pets/PetSunMoonBuff.cs +++ b/Buffs/Pets/PetSunMoonBuff.cs @@ -5,42 +5,42 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class PetSunMoonBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetSunMoonBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetSun; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PetSun; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Personal Sun and Moon"); - Description.SetDefault("A small sun and moon are providing you with constant light" - + "\n'No adverse gravitational effects will happen'"); - Main.vanityPet[Type] = false; - Main.lightPet[Type] = true; - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Personal Sun and Moon"); + Description.SetDefault("A small sun and moon are providing you with constant light" + + "\n'No adverse gravitational effects will happen'"); + Main.vanityPet[Type] = false; + Main.lightPet[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - PetPlayer petPlayer = player.GetModPlayer(); - petPlayer.PetSun = true; - petPlayer.PetMoon = true; - if (player.whoAmI == Main.myPlayer) - { - int sun = ModContent.ProjectileType(); - bool moreThanOneSun = player.ownedProjectileCounts[sun] > 0; - int moon = ModContent.ProjectileType(); - bool moreThanOneMoon = player.ownedProjectileCounts[moon] > 0; - if (!moreThanOneSun) Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.position.X + (player.width / 2), player.position.Y + (player.height / 3), 0f, 0f, sun, 0, 0f, player.whoAmI); - if (!moreThanOneMoon) Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.position.X + (player.width / 2), player.position.Y + (player.height / 3), 0f, 0f, moon, 0, 0f, player.whoAmI); - } - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + PetPlayer petPlayer = player.GetModPlayer(); + petPlayer.PetSun = true; + petPlayer.PetMoon = true; + if (player.whoAmI == Main.myPlayer) + { + int sun = ModContent.ProjectileType(); + bool moreThanOneSun = player.ownedProjectileCounts[sun] > 0; + int moon = ModContent.ProjectileType(); + bool moreThanOneMoon = player.ownedProjectileCounts[moon] > 0; + if (!moreThanOneSun) Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.position.X + (player.width / 2), player.position.Y + (player.height / 3), 0f, 0f, sun, 0, 0f, player.whoAmI); + if (!moreThanOneMoon) Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.position.X + (player.width / 2), player.position.Y + (player.height / 3), 0f, 0f, moon, 0, 0f, player.whoAmI); + } + } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - tip += "\n" + AssUtils.GetMoonPhaseAsString(); - tip += "\n" + AssUtils.GetTimeAsString(); - } - } + public override void ModifyBuffTip(ref string tip, ref int rare) + { + tip += "\n" + AssUtils.GetMoonPhaseAsString(); + tip += "\n" + AssUtils.GetTimeAsString(); + } + } } diff --git a/Buffs/Pets/PigronataBuff.cs b/Buffs/Pets/PigronataBuff.cs index 7b67b55c..8ad0beaa 100644 --- a/Buffs/Pets/PigronataBuff.cs +++ b/Buffs/Pets/PigronataBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class PigronataBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class PigronataBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().Pigronata; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().Pigronata; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Pigronata"); - Description.SetDefault("A Pigronata is thankful that you did not bust it"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Pigronata"); + Description.SetDefault("A Pigronata is thankful that you did not bust it"); + } + } } diff --git a/Buffs/Pets/PrinceSlimeBuff.cs b/Buffs/Pets/PrinceSlimeBuff.cs index aef32eab..310c7c7f 100644 --- a/Buffs/Pets/PrinceSlimeBuff.cs +++ b/Buffs/Pets/PrinceSlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class PrinceSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PrinceSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().PrinceSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().PrinceSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Prince Slime"); - Description.SetDefault("A Prince Slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Prince Slime"); + Description.SetDefault("A Prince Slime is following you"); + } + } } diff --git a/Buffs/Pets/QueenLarvaBuff.cs b/Buffs/Pets/QueenLarvaBuff.cs index db9e7cbc..f2a4d6ea 100644 --- a/Buffs/Pets/QueenLarvaBuff.cs +++ b/Buffs/Pets/QueenLarvaBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class QueenLarvaBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class QueenLarvaBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().QueenLarva; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().QueenLarva; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Queen Larva"); - Description.SetDefault("A Queen Bee Larva is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Queen Larva"); + Description.SetDefault("A Queen Bee Larva is following you"); + } + } } diff --git a/Buffs/Pets/RainbowSlimeBuff.cs b/Buffs/Pets/RainbowSlimeBuff.cs index 67b10d8d..7a4b61e6 100644 --- a/Buffs/Pets/RainbowSlimeBuff.cs +++ b/Buffs/Pets/RainbowSlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class RainbowSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class RainbowSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().RainbowSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().RainbowSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Rainbow Slime"); - Description.SetDefault("A Rainbow Slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Rainbow Slime"); + Description.SetDefault("A Rainbow Slime is following you"); + } + } } diff --git a/Buffs/Pets/SimplePetBuffBase.cs b/Buffs/Pets/SimplePetBuffBase.cs index 03d0e2b3..c3d88cec 100644 --- a/Buffs/Pets/SimplePetBuffBase.cs +++ b/Buffs/Pets/SimplePetBuffBase.cs @@ -3,35 +3,35 @@ namespace AssortedCrazyThings.Buffs.Pets { - /// - /// Base class for simple pet buffs with one projectile. Defaults to a regular pet (not light pet) - /// - [Content(ContentType.OtherPets)] //Give it to the base class, as it covers most pets - public abstract class SimplePetBuffBase : AssBuff - { - public abstract ref bool PetBool(Player player); + /// + /// Base class for simple pet buffs with one projectile. Defaults to a regular pet (not light pet) + /// + [Content(ContentType.OtherPets)] //Give it to the base class, as it covers most pets + public abstract class SimplePetBuffBase : AssBuff + { + public abstract ref bool PetBool(Player player); - public abstract int PetType { get; } + public abstract int PetType { get; } - public sealed override void SetStaticDefaults() - { - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - Main.vanityPet[Type] = true; + public sealed override void SetStaticDefaults() + { + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; - SafeSetDefaults(); - } + SafeSetDefaults(); + } - public virtual void SafeSetDefaults() - { + public virtual void SafeSetDefaults() + { - } + } - //No sealed, in case manual summoning needs to take place - public override void Update(Player player, ref int buffIndex) - { - //This only works for simple one-projectile pets - player.AssSpawnPetIfNeededAndSetTime(buffIndex, ref PetBool(player), PetType); - } - } + //No sealed, in case manual summoning needs to take place + public override void Update(Player player, ref int buffIndex) + { + //This only works for simple one-projectile pets + player.AssSpawnPetIfNeededAndSetTime(buffIndex, ref PetBool(player), PetType); + } + } } diff --git a/Buffs/Pets/SkeletronHandBuff.cs b/Buffs/Pets/SkeletronHandBuff.cs index df81706b..0cc5932d 100644 --- a/Buffs/Pets/SkeletronHandBuff.cs +++ b/Buffs/Pets/SkeletronHandBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class SkeletronHandBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class SkeletronHandBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().SkeletronHand; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().SkeletronHand; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Skeletron's Spare Hand"); - Description.SetDefault("Skeletron's Hand is attached to you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Skeletron's Spare Hand"); + Description.SetDefault("Skeletron's Hand is attached to you"); + } + } } diff --git a/Buffs/Pets/SkeletronPrimeHandBuff.cs b/Buffs/Pets/SkeletronPrimeHandBuff.cs index 37cc569e..7d90caea 100644 --- a/Buffs/Pets/SkeletronPrimeHandBuff.cs +++ b/Buffs/Pets/SkeletronPrimeHandBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class SkeletronPrimeHandBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class SkeletronPrimeHandBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().SkeletronPrimeHand; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().SkeletronPrimeHand; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Skeletron Prime's Spare Hand"); - Description.SetDefault("Skeletron Prime's Hand is attached to you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Skeletron Prime's Spare Hand"); + Description.SetDefault("Skeletron Prime's Hand is attached to you"); + } + } } diff --git a/Buffs/Pets/StingSlimeBuff.cs b/Buffs/Pets/StingSlimeBuff.cs index a412e3f7..9ed655c4 100644 --- a/Buffs/Pets/StingSlimeBuff.cs +++ b/Buffs/Pets/StingSlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class StingSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class StingSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().StingSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().StingSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Sting Slime"); - Description.SetDefault("A Sting Slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Sting Slime"); + Description.SetDefault("A Sting Slime is following you"); + } + } } diff --git a/Buffs/Pets/StrangeRobotBuff.cs b/Buffs/Pets/StrangeRobotBuff.cs index 04d994ab..1f9fcc89 100644 --- a/Buffs/Pets/StrangeRobotBuff.cs +++ b/Buffs/Pets/StrangeRobotBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class StrangeRobotBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class StrangeRobotBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().StrangeRobot; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().StrangeRobot; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Strange Robot"); - Description.SetDefault("A strange robot is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Strange Robot"); + Description.SetDefault("A strange robot is following you"); + } + } } diff --git a/Buffs/Pets/SuspiciousNuggetBuff.cs b/Buffs/Pets/SuspiciousNuggetBuff.cs index 5b2e996c..0bc3cb19 100644 --- a/Buffs/Pets/SuspiciousNuggetBuff.cs +++ b/Buffs/Pets/SuspiciousNuggetBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class SuspiciousNuggetBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class SuspiciousNuggetBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().SuspiciousNugget; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().SuspiciousNugget; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Suspicious Nugget"); - Description.SetDefault("A Suspicious Nugget is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Suspicious Nugget"); + Description.SetDefault("A Suspicious Nugget is following you"); + } + } } diff --git a/Buffs/Pets/SwarmofCthulhuBuff.cs b/Buffs/Pets/SwarmofCthulhuBuff.cs index 1921c84c..db1c746c 100644 --- a/Buffs/Pets/SwarmofCthulhuBuff.cs +++ b/Buffs/Pets/SwarmofCthulhuBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class SwarmofCthulhuBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class SwarmofCthulhuBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().SwarmofCthulhu; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().SwarmofCthulhu; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Swarm of Cthulhu"); - Description.SetDefault("A Swarm of Cthulhu is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Swarm of Cthulhu"); + Description.SetDefault("A Swarm of Cthulhu is following you"); + } + } } diff --git a/Buffs/Pets/TinyTwinsBuff.cs b/Buffs/Pets/TinyTwinsBuff.cs index f002774a..b87ab91a 100644 --- a/Buffs/Pets/TinyTwinsBuff.cs +++ b/Buffs/Pets/TinyTwinsBuff.cs @@ -4,38 +4,38 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class TinyTwinsBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class TinyTwinsBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().TinyTwins; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().TinyTwins; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Tiny Twins"); - Description.SetDefault("The Twins are watching you"); - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Tiny Twins"); + Description.SetDefault("The Twins are watching you"); + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - PetBool(player) = true; - if (player.whoAmI == Main.myPlayer) - { - int spaz = ModContent.ProjectileType(); - if (player.ownedProjectileCounts[spaz] <= 0) - { - Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.position.X + (player.width / 2), player.position.Y + (player.height / 2), -player.direction, 0f, spaz, 0, 0f, player.whoAmI); + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + PetBool(player) = true; + if (player.whoAmI == Main.myPlayer) + { + int spaz = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[spaz] <= 0) + { + Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.position.X + (player.width / 2), player.position.Y + (player.height / 2), -player.direction, 0f, spaz, 0, 0f, player.whoAmI); - } + } - int reti = ModContent.ProjectileType(); - if (player.ownedProjectileCounts[reti] <= 0) - { - Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.position.X + (player.width / 2), player.position.Y, -player.direction, 0f, reti, 0, 0f, player.whoAmI); - } - } - } - } + int reti = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[reti] <= 0) + { + Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.position.X + (player.width / 2), player.position.Y, -player.direction, 0f, reti, 0, 0f, player.whoAmI); + } + } + } + } } diff --git a/Buffs/Pets/TorchGodLightPetBuff.cs b/Buffs/Pets/TorchGodLightPetBuff.cs index e7f6ae7f..8ace3aa6 100644 --- a/Buffs/Pets/TorchGodLightPetBuff.cs +++ b/Buffs/Pets/TorchGodLightPetBuff.cs @@ -5,33 +5,33 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class TorchGodLightPetBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class TorchGodLightPetBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().TorchGodLightPet; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().TorchGodLightPet; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Godly Torch"); - Description.SetDefault("'Your torch placement has been deemed unnecessary. I will do it correctly.'"); - Main.vanityPet[Type] = false; - Main.lightPet[Type] = true; - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Godly Torch"); + Description.SetDefault("'Your torch placement has been deemed unnecessary. I will do it correctly.'"); + Main.vanityPet[Type] = false; + Main.lightPet[Type] = true; + } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - base.ModifyBuffTip(ref tip, ref rare); + public override void ModifyBuffTip(ref string tip, ref int rare) + { + base.ModifyBuffTip(ref tip, ref rare); - if (!Main.SmartCursorIsUsed) - { - tip += "\nEnable 'Smart Cursor' to automatically place torches"; - } + if (!Main.SmartCursorIsUsed) + { + tip += "\nEnable 'Smart Cursor' to automatically place torches"; + } - if (!Main.LocalPlayer.HasItem(ItemID.Torch)) - { - tip += "\nNo normal torches found to place"; - } - } - } + if (!Main.LocalPlayer.HasItem(ItemID.Torch)) + { + tip += "\nNo normal torches found to place"; + } + } + } } diff --git a/Buffs/Pets/TorturedSoulBuff.cs b/Buffs/Pets/TorturedSoulBuff.cs index 7781566f..66af10df 100644 --- a/Buffs/Pets/TorturedSoulBuff.cs +++ b/Buffs/Pets/TorturedSoulBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class TorturedSoulBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class TorturedSoulBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().TorturedSoul; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().TorturedSoul; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Tortured Soul"); - Description.SetDefault("Shouldn't have been so greedy, eh?"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Tortured Soul"); + Description.SetDefault("Shouldn't have been so greedy, eh?"); + } + } } diff --git a/Buffs/Pets/TrueObservingEyeBuff.cs b/Buffs/Pets/TrueObservingEyeBuff.cs index a76fef4a..1454c1b7 100644 --- a/Buffs/Pets/TrueObservingEyeBuff.cs +++ b/Buffs/Pets/TrueObservingEyeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class TrueObservingEyeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class TrueObservingEyeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().TrueObservingEye; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().TrueObservingEye; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("True Observing Eye"); - Description.SetDefault("A tiny True Eye of Cthulhu is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("True Observing Eye"); + Description.SetDefault("A tiny True Eye of Cthulhu is following you"); + } + } } diff --git a/Buffs/Pets/TurtleSlimeBuff.cs b/Buffs/Pets/TurtleSlimeBuff.cs index 4335d71a..5abba62e 100644 --- a/Buffs/Pets/TurtleSlimeBuff.cs +++ b/Buffs/Pets/TurtleSlimeBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.HostileNPCs)] - public class TurtleSlimeBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class TurtleSlimeBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().TurtleSlime; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().TurtleSlime; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Turtle Slime"); - Description.SetDefault("A Turtle Slime is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Turtle Slime"); + Description.SetDefault("A Turtle Slime is following you"); + } + } } diff --git a/Buffs/Pets/VampireBatBuff.cs b/Buffs/Pets/VampireBatBuff.cs index 5c2624f2..9f2e48a5 100644 --- a/Buffs/Pets/VampireBatBuff.cs +++ b/Buffs/Pets/VampireBatBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class VampireBatBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class VampireBatBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().VampireBat; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().VampireBat; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Vampire Bat"); - Description.SetDefault("A particularly dashing vampire is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Vampire Bat"); + Description.SetDefault("A particularly dashing vampire is following you"); + } + } } diff --git a/Buffs/Pets/WallFragmentBuff.cs b/Buffs/Pets/WallFragmentBuff.cs index 8842edde..227ace3a 100644 --- a/Buffs/Pets/WallFragmentBuff.cs +++ b/Buffs/Pets/WallFragmentBuff.cs @@ -4,46 +4,46 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.DroppedPets)] - public class WallFragmentBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class WallFragmentBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().WallFragment; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().WallFragment; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Wall Fragment"); - Description.SetDefault("Several fragments of the Wall are following you"); - Main.buffNoTimeDisplay[Type] = true; - Main.vanityPet[Type] = true; - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Wall Fragment"); + Description.SetDefault("Several fragments of the Wall are following you"); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - PetBool(player) = true; - if (player.whoAmI == Main.myPlayer) - { - int eye1 = ModContent.ProjectileType(); - if (player.ownedProjectileCounts[eye1] <= 0) - { - Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Top.Y - 6f, player.direction * 0.75f, -0.5f, eye1, 0, 0f, player.whoAmI, 0f, 0f); - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + PetBool(player) = true; + if (player.whoAmI == Main.myPlayer) + { + int eye1 = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[eye1] <= 0) + { + Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Top.Y - 6f, player.direction * 0.75f, -0.5f, eye1, 0, 0f, player.whoAmI, 0f, 0f); + } - int mouth = ModContent.ProjectileType(); - if (player.ownedProjectileCounts[mouth] <= 0) - { - Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Center.Y, player.direction, 0f, mouth, 0, 0f, player.whoAmI, 0f, 0f); + int mouth = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[mouth] <= 0) + { + Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Center.Y, player.direction, 0f, mouth, 0, 0f, player.whoAmI, 0f, 0f); - } + } - int eye2 = ModContent.ProjectileType(); - if (player.ownedProjectileCounts[eye2] <= 0) - { - Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Bottom.Y + 6f, player.direction * 0.75f, 0.5f, eye2, 0, 0f, player.whoAmI, 0f, 0f); - } - } - } - } + int eye2 = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[eye2] <= 0) + { + Projectile.NewProjectile(player.GetProjectileSource_Buff(buffIndex), player.Center.X, player.Bottom.Y + 6f, player.direction * 0.75f, 0.5f, eye2, 0, 0f, player.whoAmI, 0f, 0f); + } + } + } + } } diff --git a/Buffs/Pets/YoungHarpyBuff.cs b/Buffs/Pets/YoungHarpyBuff.cs index 4aef517d..58aa2e82 100644 --- a/Buffs/Pets/YoungHarpyBuff.cs +++ b/Buffs/Pets/YoungHarpyBuff.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Buffs.Pets { - [Content(ContentType.FriendlyNPCs)] - public class YoungHarpyBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.FriendlyNPCs)] + public class YoungHarpyBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().YoungHarpy; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().YoungHarpy; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Young Harpy"); - Description.SetDefault("A young Harpy is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Young Harpy"); + Description.SetDefault("A young Harpy is following you"); + } + } } diff --git a/Buffs/Pets/YoungWyvernBuff.cs b/Buffs/Pets/YoungWyvernBuff.cs index c7e25df2..f034bbc2 100644 --- a/Buffs/Pets/YoungWyvernBuff.cs +++ b/Buffs/Pets/YoungWyvernBuff.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Buffs.Pets { - public class YoungWyvernBuff : SimplePetBuffBase - { - public override int PetType => ModContent.ProjectileType(); + public class YoungWyvernBuff : SimplePetBuffBase + { + public override int PetType => ModContent.ProjectileType(); - public override ref bool PetBool(Player player) => ref player.GetModPlayer().YoungWyvern; + public override ref bool PetBool(Player player) => ref player.GetModPlayer().YoungWyvern; - public override void SafeSetDefaults() - { - DisplayName.SetDefault("Young Wyvern"); - Description.SetDefault("A young Wyvern is following you"); - } - } + public override void SafeSetDefaults() + { + DisplayName.SetDefault("Young Wyvern"); + Description.SetDefault("A young Wyvern is following you"); + } + } } diff --git a/Buffs/SlimePackMinionBuff.cs b/Buffs/SlimePackMinionBuff.cs index 1e326f22..d6019d04 100644 --- a/Buffs/SlimePackMinionBuff.cs +++ b/Buffs/SlimePackMinionBuff.cs @@ -4,41 +4,41 @@ namespace AssortedCrazyThings.Buffs { - [Content(ContentType.Weapons)] - public class SlimePackMinionBuff : AssBuff - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slime"); - Description.SetDefault("A friendly Slime from your Knapsack is fighting for you"); - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - } + [Content(ContentType.Weapons)] + public class SlimePackMinionBuff : AssBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slime"); + Description.SetDefault("A friendly Slime from your Knapsack is fighting for you"); + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + } - private int SumOfSlimePackCounts(Player player) - { - int sum = player.ownedProjectileCounts[ModContent.ProjectileType()]; - sum += player.ownedProjectileCounts[ModContent.ProjectileType()]; - sum += player.ownedProjectileCounts[ModContent.ProjectileType()]; - return sum; - } + private int SumOfSlimePackCounts(Player player) + { + int sum = player.ownedProjectileCounts[ModContent.ProjectileType()]; + sum += player.ownedProjectileCounts[ModContent.ProjectileType()]; + sum += player.ownedProjectileCounts[ModContent.ProjectileType()]; + return sum; + } - public override void Update(Player player, ref int buffIndex) - { - AssPlayer modPlayer = player.GetModPlayer(); - if (SumOfSlimePackCounts(player) > 0) - { - modPlayer.slimePackMinion = true; - } - if (!modPlayer.slimePackMinion) - { - player.DelBuff(buffIndex); - buffIndex--; - } - else - { - player.buffTime[buffIndex] = 18000; - } - } - } + public override void Update(Player player, ref int buffIndex) + { + AssPlayer modPlayer = player.GetModPlayer(); + if (SumOfSlimePackCounts(player) > 0) + { + modPlayer.slimePackMinion = true; + } + if (!modPlayer.slimePackMinion) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } } diff --git a/Buffs/SoulBuff.cs b/Buffs/SoulBuff.cs index ffd02ef5..9c920f29 100644 --- a/Buffs/SoulBuff.cs +++ b/Buffs/SoulBuff.cs @@ -3,20 +3,20 @@ namespace AssortedCrazyThings.Buffs { - [Content(ContentType.Bosses)] - public class SoulBuff : AssBuff - { - public override string Texture => "AssortedCrazyThings/Empty"; + [Content(ContentType.Bosses)] + public class SoulBuff : AssBuff + { + public override string Texture => "AssortedCrazyThings/Empty"; - public override void SetStaticDefaults() - { - //purely on the NPC side, so no name or texture required - Main.buffNoTimeDisplay[Type] = true; - } + public override void SetStaticDefaults() + { + //purely on the NPC side, so no name or texture required + Main.buffNoTimeDisplay[Type] = true; + } - public override void Update(NPC npc, ref int buffIndex) - { - npc.GetGlobalNPC().shouldSoulDrop = true; - } - } + public override void Update(NPC npc, ref int buffIndex) + { + npc.GetGlobalNPC().shouldSoulDrop = true; + } + } } \ No newline at end of file diff --git a/Buffs/StarRodBuff.cs b/Buffs/StarRodBuff.cs index 4b18b319..27e5d28f 100644 --- a/Buffs/StarRodBuff.cs +++ b/Buffs/StarRodBuff.cs @@ -3,21 +3,21 @@ namespace AssortedCrazyThings.Buffs { - //Not just visual (like campfires), server needs to know it exists - [Content(ContentType.PlaceablesFunctional)] - public class StarRodBuff : AssBuff - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star Rod"); - Description.SetDefault("Falling Stars will land closer to you"); - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - } + //Not just visual (like campfires), server needs to know it exists + [Content(ContentType.PlaceablesFunctional)] + public class StarRodBuff : AssBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Star Rod"); + Description.SetDefault("Falling Stars will land closer to you"); + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - player.GetModPlayer().starRodTileWorking = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.GetModPlayer().starRodTileWorking = true; + } + } } diff --git a/Buffs/WyvernCampfireGlobalBuff.cs b/Buffs/WyvernCampfireGlobalBuff.cs index c47a66a1..c431ac5c 100644 --- a/Buffs/WyvernCampfireGlobalBuff.cs +++ b/Buffs/WyvernCampfireGlobalBuff.cs @@ -3,19 +3,19 @@ namespace AssortedCrazyThings.Buffs { - [Content(ContentType.PlaceablesFunctional)] - public class WyvernCampfireGlobalBuff : AssGlobalBuff - { - //Tells you its effects in the regular campfire buff (which the wyvern campfire applies) - //Logic handled in WyvernCampfireTile.NearbyEffects and AssWorld.ResetNearbyTileEffects - public override void ModifyBuffTip(int type, ref string tip, ref int rare) - { - if (type == BuffID.Campfire && Main.LocalPlayer.GetModPlayer().wyvernCampfire) - { - tip += "\nWyvern Campfire nearby" + - "\nYou are protected from Wyverns" + - "\nHarpy feathers don't knock you away"; - } - } - } + [Content(ContentType.PlaceablesFunctional)] + public class WyvernCampfireGlobalBuff : AssGlobalBuff + { + //Tells you its effects in the regular campfire buff (which the wyvern campfire applies) + //Logic handled in WyvernCampfireTile.NearbyEffects and AssWorld.ResetNearbyTileEffects + public override void ModifyBuffTip(int type, ref string tip, ref int rare) + { + if (type == BuffID.Campfire && Main.LocalPlayer.GetModPlayer().wyvernCampfire) + { + tip += "\nWyvern Campfire nearby" + + "\nYou are protected from Wyverns" + + "\nHarpy feathers don't knock you away"; + } + } + } } diff --git a/Config.cs b/Config.cs index 92e9072a..e3e040bb 100644 --- a/Config.cs +++ b/Config.cs @@ -85,14 +85,14 @@ public class ContentConfig : ServerConfigBase [Label("Placeables (functional)")] public bool PlaceablesFunctional { get; set; } - [ReloadRequired] - [DefaultValue(true)] - [BackgroundColor(194, 147, 227)] - [Tooltip("Placeable decorative tiles and objects")] - [Label("Placeables (decorative)")] - public bool PlaceablesDecorative { get; set; } - - [ReloadRequired] + [ReloadRequired] + [DefaultValue(true)] + [BackgroundColor(194, 147, 227)] + [Tooltip("Placeable decorative tiles and objects")] + [Label("Placeables (decorative)")] + public bool PlaceablesDecorative { get; set; } + + [ReloadRequired] [DefaultValue(true)] [BackgroundColor(194, 147, 227)] [Tooltip("Armor with stats")] @@ -143,7 +143,7 @@ public class ContentConfig : ServerConfigBase public bool Hint => true; public override void OnChanged() - { + { //Inverted, sets a flag if toggle is false FilterFlags = ContentType.Always; @@ -208,7 +208,7 @@ public override void OnChanged() FilterFlags |= ContentType.BossConsolation; } } - } + } [Label("Client Config")] public class ClientConfig : ModConfig @@ -241,7 +241,7 @@ public class ClientConfig : ModConfig [Tooltip("Control how often this minion will display dialogue (in percent). 0 for off")] public int SatchelofGoodiesChatterFreq { get; set; } - internal bool SatchelofGoodiesDialogueDisabled => SatchelofGoodiesChatterFreq == 0; + internal bool SatchelofGoodiesDialogueDisabled => SatchelofGoodiesChatterFreq == 0; [Header("Hint: To go to the server config containing feature toggles, press the '>' arrow in the bottom right")] [Label("Hint")] diff --git a/ConfigurationBaseClasses.cs b/ConfigurationBaseClasses.cs index c46d3f69..ddb4cb4d 100644 --- a/ConfigurationBaseClasses.cs +++ b/ConfigurationBaseClasses.cs @@ -2,84 +2,84 @@ namespace AssortedCrazyThings { - //Add all the tml base classes used here to ConfigurationSystem.GetInvalidTypes - [Autoload(false)] - public abstract class AssItem : ModItem - { + //Add all the tml base classes used here to ConfigurationSystem.GetInvalidTypes + [Autoload(false)] + public abstract class AssItem : ModItem + { - } + } - [Autoload(false)] - public abstract class AssProjectile : ModProjectile - { + [Autoload(false)] + public abstract class AssProjectile : ModProjectile + { - } + } - [Autoload(false)] - public abstract class AssBuff : ModBuff - { + [Autoload(false)] + public abstract class AssBuff : ModBuff + { - } + } - [Autoload(false)] - public abstract class AssNPC : ModNPC - { + [Autoload(false)] + public abstract class AssNPC : ModNPC + { - } + } - [Autoload(false)] - public abstract class AssTile : ModTile - { + [Autoload(false)] + public abstract class AssTile : ModTile + { - } + } - [Autoload(false)] - public abstract class AssPlayerLayer : PlayerDrawLayer - { + [Autoload(false)] + public abstract class AssPlayerLayer : PlayerDrawLayer + { - } + } - [Autoload(false)] - public abstract class AssPlayerBase : ModPlayer - { + [Autoload(false)] + public abstract class AssPlayerBase : ModPlayer + { - } + } - [Autoload(false)] - public abstract class AssSystem : ModSystem - { + [Autoload(false)] + public abstract class AssSystem : ModSystem + { - } + } - //ModGore, ModDust + //ModGore, ModDust - [Autoload(false)] - public abstract class AssGlobalNPC : GlobalNPC - { + [Autoload(false)] + public abstract class AssGlobalNPC : GlobalNPC + { - } + } - [Autoload(false)] - public abstract class AssGlobalBuff : GlobalBuff - { + [Autoload(false)] + public abstract class AssGlobalBuff : GlobalBuff + { - } + } - [Autoload(false)] - public abstract class AssGlobalProjectile : GlobalProjectile - { + [Autoload(false)] + public abstract class AssGlobalProjectile : GlobalProjectile + { - } + } - [Autoload(false)] - public abstract class AssGlobalItem : GlobalItem - { + [Autoload(false)] + public abstract class AssGlobalItem : GlobalItem + { - } + } - [Autoload(false)] - public abstract class AssGlobalTile : GlobalTile - { + [Autoload(false)] + public abstract class AssGlobalTile : GlobalTile + { - } + } } diff --git a/ConfigurationSystem.cs b/ConfigurationSystem.cs index 32f6b493..d41c5521 100644 --- a/ConfigurationSystem.cs +++ b/ConfigurationSystem.cs @@ -1,9 +1,9 @@ -using System; -using System.Linq; +using AssortedCrazyThings.Base; +using System; using System.Collections.Generic; -using Terraria.ModLoader; +using System.Linq; using Terraria; -using AssortedCrazyThings.Base; +using Terraria.ModLoader; namespace AssortedCrazyThings { @@ -18,25 +18,25 @@ public static class ConfigurationSystem //Cannot be a ModSystem since that load /// /// For use on generic content that should be always loaded except when everything is disabled /// - public const ContentType AllFlags = - ContentType.Bosses | - ContentType.CuteSlimes | - ContentType.HostileNPCs | - ContentType.FriendlyNPCs | - ContentType.DroppedPets | - ContentType.OtherPets | - ContentType.Weapons | - ContentType.Tools | - ContentType.PlaceablesFunctional | + public const ContentType AllFlags = + ContentType.Bosses | + ContentType.CuteSlimes | + ContentType.HostileNPCs | + ContentType.FriendlyNPCs | + ContentType.DroppedPets | + ContentType.OtherPets | + ContentType.Weapons | + ContentType.Tools | + ContentType.PlaceablesFunctional | ContentType.PlaceablesDecorative | ContentType.Armor | - ContentType.VanityArmor | - ContentType.Accessories | - ContentType.VanityAccessories | - ContentType.BossConsolation; + ContentType.VanityArmor | + ContentType.Accessories | + ContentType.VanityAccessories | + ContentType.BossConsolation; public static void Load() - { + { Mod mod = AssUtils.Instance; //Maybe change it to support all loaded mod assemblies NonLoadedNames = new(); NonLoadedNamesByType = new(); @@ -82,16 +82,16 @@ public static void Load() } if (instance is ModType modTypeInstance) - { - string name = modTypeInstance.Name; - NonLoadedNames.Add(name, reasons); + { + string name = modTypeInstance.Name; + NonLoadedNames.Add(name, reasons); if (!NonLoadedNamesByType.ContainsKey(reasons)) - { + { NonLoadedNamesByType[reasons] = new List(); } - NonLoadedNamesByType[reasons].Add(name); + NonLoadedNamesByType[reasons].Add(name); } } @@ -99,7 +99,7 @@ public static void Load() } private static Type[] GetInvalidTypes() - { + { return new Type[] { typeof(ModItem), @@ -119,37 +119,37 @@ private static Type[] GetInvalidTypes() } private static void CheckInvalidInheritance(Type type) - { + { //Detect misuse of tml types that have an existing Ass base class if (!typeof(ILoadable).IsAssignableFrom(type)) - { + { return; - } + } var baseType = type.BaseType; if (baseType != null && Array.IndexOf(InvalidTypes, baseType) > -1) - { + { throw new Exception($"{type} inherits from {baseType}, which is not permitted. Use the base classes in ConfigurationBaseClasses.cs"); } - } + } - private static ContentType FindContentFilterReasons(ContentAttribute content) - { + private static ContentType FindContentFilterReasons(ContentAttribute content) + { //Bitwise "and" results in the overlap, representing the flags that caused the content to be filtered var flags = ContentConfig.Instance.FilterFlags & content.ContentType; if (content.NeedsAllToFilter && flags != content.ContentType) - { + { //If the content needs a full match return ContentType.Always; - } + } return flags; } - public static void Unload() - { + public static void Unload() + { NonLoadedNames?.Clear(); NonLoadedNames = null; @@ -160,27 +160,27 @@ public static void Unload() } public static string ContentTypeToString(ContentType contentType) - { + { if (!ExactlyOneFlagSet(contentType)) - { + { string concat = string.Empty; foreach (ContentType flag in Enum.GetValues(typeof(ContentType))) - { + { if (flag != ContentType.Always && contentType.HasFlag(flag)) - { + { concat += ContentTypeToString(flag) + "/"; } - } + } return concat[0..^1]; } - return contentType switch - { - ContentType.Always => string.Empty, - ContentType.Bosses => "Bosses", + return contentType switch + { + ContentType.Always => string.Empty, + ContentType.Bosses => "Bosses", ContentType.CuteSlimes => "Cute Slimes", ContentType.HostileNPCs => "Hostile NPCs", - ContentType.FriendlyNPCs => "Friendly NPCs", + ContentType.FriendlyNPCs => "Friendly NPCs", ContentType.DroppedPets => "Dropped Pets", ContentType.OtherPets => "Other Pets", ContentType.Weapons => "Weapons", @@ -193,7 +193,7 @@ public static string ContentTypeToString(ContentType contentType) ContentType.VanityAccessories => "Vanity Accessories", ContentType.BossConsolation => "Boss Consolation Items", _ => string.Empty, - }; + }; } public static bool ExactlyOneFlagSet(ContentType contentType) @@ -210,7 +210,7 @@ public static bool LoadSide(ModSide side) [Flags] public enum ContentType : int - { + { Always = 0 << 0, Bosses = 1 << 1, CuteSlimes = 1 << 2, diff --git a/Dusts/GlitterDust.cs b/Dusts/GlitterDust.cs index ed61e876..fdbddfdb 100644 --- a/Dusts/GlitterDust.cs +++ b/Dusts/GlitterDust.cs @@ -4,38 +4,38 @@ namespace AssortedCrazyThings.Dusts { - /// - /// Clone of dust type 15/57/58 - /// - public abstract class GlitterDustBase : ModDust - { - public override void OnSpawn(Dust dust) - { - //dust.velocity *= 0.4f; - dust.noGravity = true; - dust.noLight = true; - //dust.scale *= 1.5f; - } + /// + /// Clone of dust type 15/57/58 + /// + public abstract class GlitterDustBase : ModDust + { + public override void OnSpawn(Dust dust) + { + //dust.velocity *= 0.4f; + dust.noGravity = true; + dust.noLight = true; + //dust.scale *= 1.5f; + } - public override bool Update(Dust dust) - { - dust.position += dust.velocity; - dust.rotation += dust.velocity.X * 0.15f; - dust.scale *= 0.99f; - if (dust.scale < 0.5f) - { - dust.active = false; - } - return false; - } + public override bool Update(Dust dust) + { + dust.position += dust.velocity; + dust.rotation += dust.velocity.X * 0.15f; + dust.scale *= 0.99f; + if (dust.scale < 0.5f) + { + dust.active = false; + } + return false; + } - public override Color? GetAlpha(Dust dust, Color lightColor) - { - return Color.White * ((255f - dust.alpha) / 255f); - } - } + public override Color? GetAlpha(Dust dust, Color lightColor) + { + return Color.White * ((255f - dust.alpha) / 255f); + } + } - public class GlitterDust15 : GlitterDustBase { } - public class GlitterDust57 : GlitterDustBase { } - public class GlitterDust58 : GlitterDustBase { } + public class GlitterDust15 : GlitterDustBase { } + public class GlitterDust57 : GlitterDustBase { } + public class GlitterDust58 : GlitterDustBase { } } diff --git a/Effects/ShaderManager.cs b/Effects/ShaderManager.cs index 3ba693f1..7d6bc465 100644 --- a/Effects/ShaderManager.cs +++ b/Effects/ShaderManager.cs @@ -7,75 +7,75 @@ namespace AssortedCrazyThings.Effects { - /// - /// Responsible for dealing with shaders - /// - public static class ShaderManager - { - public static Effect CircleEffect { get; private set; } + /// + /// Responsible for dealing with shaders + /// + public static class ShaderManager + { + public static Effect CircleEffect { get; private set; } - public static Effect SetupCircleEffect(Vector2 center, int radius, Color edgeColor, Color bodyBolor = default) - { - Effect circle = CircleEffect; - if (circle != null) - { - circle.Parameters["ScreenPos"].SetValue(Main.screenPosition); - circle.Parameters["ScreenDim"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight)); - circle.Parameters["EntCenter"].SetValue(center); - circle.Parameters["EdgeColor"].SetValue(edgeColor.ToVector4()); - circle.Parameters["BodyColor"].SetValue((bodyBolor == default ? Color.Transparent : bodyBolor).ToVector4()); - circle.Parameters["Radius"].SetValue(radius); - circle.Parameters["HpPercent"].SetValue(1f); - circle.Parameters["ShrinkResistScale"].SetValue(1f / 24f); - } - return circle; - } + public static Effect SetupCircleEffect(Vector2 center, int radius, Color edgeColor, Color bodyBolor = default) + { + Effect circle = CircleEffect; + if (circle != null) + { + circle.Parameters["ScreenPos"].SetValue(Main.screenPosition); + circle.Parameters["ScreenDim"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight)); + circle.Parameters["EntCenter"].SetValue(center); + circle.Parameters["EdgeColor"].SetValue(edgeColor.ToVector4()); + circle.Parameters["BodyColor"].SetValue((bodyBolor == default ? Color.Transparent : bodyBolor).ToVector4()); + circle.Parameters["Radius"].SetValue(radius); + circle.Parameters["HpPercent"].SetValue(1f); + circle.Parameters["ShrinkResistScale"].SetValue(1f / 24f); + } + return circle; + } - public static void ApplyToScreenOnce(SpriteBatch spriteBatch, Effect effect, bool restore = true) - { - if (effect == null) return; + public static void ApplyToScreenOnce(SpriteBatch spriteBatch, Effect effect, bool restore = true) + { + if (effect == null) return; - //Apply the shader to the spritebatch from now on - StartEffectOnSpriteBatch(spriteBatch, effect); + //Apply the shader to the spritebatch from now on + StartEffectOnSpriteBatch(spriteBatch, effect); - DrawEmptyCanvasToScreen(spriteBatch); + DrawEmptyCanvasToScreen(spriteBatch); - //Normally you want to apply the shader once, and restore. This is for when you repeatedly apply a different effect without restoring vanilla - if (restore) - { - //Stop applying the shader, continue normal behavior - RestoreVanillaSpriteBatchSettings(spriteBatch); - } - } + //Normally you want to apply the shader once, and restore. This is for when you repeatedly apply a different effect without restoring vanilla + if (restore) + { + //Stop applying the shader, continue normal behavior + RestoreVanillaSpriteBatchSettings(spriteBatch); + } + } - public static void StartEffectOnSpriteBatch(SpriteBatch spriteBatch, Effect effect) - { - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix); - } + public static void StartEffectOnSpriteBatch(SpriteBatch spriteBatch, Effect effect) + { + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix); + } - public static void DrawEmptyCanvasToScreen(SpriteBatch spriteBatch) - { - Main.spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Transparent); - } + public static void DrawEmptyCanvasToScreen(SpriteBatch spriteBatch) + { + Main.spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Transparent); + } - public static void RestoreVanillaSpriteBatchSettings(SpriteBatch spriteBatch) - { - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - } + public static void RestoreVanillaSpriteBatchSettings(SpriteBatch spriteBatch) + { + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } - public static void Load() - { - if (Main.netMode != NetmodeID.Server) - { - CircleEffect = AssUtils.Instance.Assets.Request("Effects/CircleShader/Circle").Value; - } - } + public static void Load() + { + if (Main.netMode != NetmodeID.Server) + { + CircleEffect = AssUtils.Instance.Assets.Request("Effects/CircleShader/Circle").Value; + } + } - public static void Unload() - { - CircleEffect = null; - } - } + public static void Unload() + { + CircleEffect = null; + } + } } diff --git a/GitGudPlayer.cs b/GitGudPlayer.cs index e221f63f..62268380 100644 --- a/GitGudPlayer.cs +++ b/GitGudPlayer.cs @@ -34,917 +34,917 @@ namespace AssortedCrazyThings { - /// - /// Holds static functions and data related to the Gitgud accessories - /// - public class GitgudData - { - /// - /// Holds the data of all Gitgud Accessories, and a list of counters per player - /// - private static GitgudData[] DataList; //Left as null if disabled via config - /// - /// Name for the delete message - /// - public Func ItemNameFunc { set; get; } - /// - /// Boss name for tooltip - /// - public string BossName { set; get; } - /// - /// Buff immunity while boss is alive - /// - public int BuffType { private set; get; } - /// - /// Buff name for tooltip - /// - public Func BuffNameFunc { private set; get; } - /// - /// Dropped gitgud item - /// - public int ItemType { private set; get; } - /// - /// Boss type (usually only one, can be multiple for worms) - /// - public int[] BossTypeList { private set; get; } - /// - /// NPCs that deal damage during the boss fight (boss minions) (includes the boss itself by default) - /// - public int[] NPCTypeList { private set; get; } - /// - /// Projectiles that deal damage during the boss fight - /// - public int[] ProjTypeList { private set; get; } - /// - /// Threshold, after which the item drops - /// - public byte CounterMax { private set; get; } - /// - /// Percentage by which the damage gets reduced - /// - public float Reduction { private set; get; } - public Func CustomCountCondition { get; private set; } - /// - /// Invasion name, unused - /// - public string Invasion { private set; get; } - /// - /// Invasion in progress, ignore the lists for damage reduction - /// - public Func InvasionBool { private set; get; } - - //255 long - /// - /// The bool that is set by the wearing accessory - /// - public BitArray Accessory { private set; get; } - /// - /// number of times player died to the boss - /// - public byte[] Counter { private set; get; } - - public GitgudData(int itemType, int buffType, - int[] bossTypeList, int[] nPCTypeList, int[] projTypeList, byte counterMax, float reduction, Func customCountCondition, string invasion, Func invasionBool) - { - ItemType = itemType; - ItemNameFunc = () => Lang.GetItemNameValue(itemType); - BuffType = buffType; - BuffNameFunc = () => Lang.GetBuffName(buffType); - BossTypeList = bossTypeList; - - NPC npc = ContentSamples.NpcsByNetId[bossTypeList[0]]; - BossName = npc.GetFullNetName().ToString(); - if (bossTypeList.Length > 1) - { - for (int i = 1; i < bossTypeList.Length; i++) - { - npc = ContentSamples.NpcsByNetId[bossTypeList[i]]; - string name = npc.GetFullNetName().ToString(); - if (!BossName.Contains(name)) - { - BossName += " or " + name; - } - } - } - - if (nPCTypeList == null) nPCTypeList = new int[1]; - if (projTypeList == null) projTypeList = new int[1]; - - NPCTypeList = AssUtils.ConcatArray(nPCTypeList, bossTypeList); - ProjTypeList = projTypeList; - CounterMax = counterMax; - Reduction = reduction; - CustomCountCondition = customCountCondition ?? ((NPC npc) => true); - Invasion = invasion; - InvasionBool = invasionBool ?? (() => false); - - Array.Sort(BossTypeList); - Array.Sort(NPCTypeList); - Array.Sort(ProjTypeList); - - Counter = new byte[255]; - Accessory = new BitArray(255); - } - - public override string ToString() - { - return ItemNameFunc(); - } - - public static void Add(int buffType, - int[] bossTypeList, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func customCountCondition = null, string invasion = "", Func invasionBool = null) where T : ModItem - { - Add(ModContent.ItemType(), buffType, bossTypeList, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool); - } - - public static void Add(int itemType, int buffType, - int[] bossTypeList, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func customCountCondition = null, string invasion = "", Func invasionBool = null) - { - if (itemType < 0 || itemType >= ItemLoader.ItemCount) throw new Exception("not a valid item type"); - - DataList[DataList.Length - 1] = new GitgudData(itemType, buffType, bossTypeList, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool); - Array.Resize(ref DataList, DataList.Length + 1); - } - - public static void Add(int buffType, - int bossType, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func customCountCondition = null, string invasion = "", Func invasionBool = null) where T : ModItem - { - Add(ModContent.ItemType(), buffType, new int[] { bossType }, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool); - } - - public static void Add(int itemType, int buffType, - int bossType, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func customCountCondition = null, string invasion = "", Func invasionBool = null) - { - Add(itemType,buffType, new int[] { bossType }, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool); - } - - /// - /// Called in Reset and RecvChangeCounter. Deletes the item from the inventory, trash slot, mouse item, and accessories - /// - private static void DeleteItemFromInventory(Player player, int index) - { - GitgudData data = DataList[index]; - int itemType = data.ItemType; - string itemName = data.ItemNameFunc(); - - bool deleted = false; - - Item[][] inventoryArray = { player.inventory, player.bank.item, player.bank2.item, player.bank3.item, player.bank4.item, player.armor }; //go though player inv - for (int y = 0; y < inventoryArray.Length; y++) - { - for (int e = 0; e < inventoryArray[y].Length; e++) - { - if (inventoryArray[y][e].type == itemType) //find gitgud item - { - inventoryArray[y][e].TurnToAir(); - deleted = true; - } - } - } - - //trash slot - if (player.trashItem.type == itemType) - { - player.trashItem.TurnToAir(); - deleted = true; - } - - //mouse item - if (Main.netMode != NetmodeID.Server && Main.myPlayer == player.whoAmI && Main.mouseItem.type == itemType) - { - Main.mouseItem.TurnToAir(); - deleted = true; - } - - if (deleted && Main.myPlayer == player.whoAmI) - { - Main.NewText("You won't be needing the " + itemName + " anymore...", new Color(255, 175, 0)); - } - } - - /// - /// Sets the counter on both the DataList and the players respective field - /// - private static void SetCounter(int whoAmI, int index, byte value, bool packet = false) - { - DataList[index].Counter[whoAmI] = value; - GitGudPlayer gPlayer = Main.player[whoAmI].GetModPlayer(); - switch (index) - { - case 0: - gPlayer.kingSlimeGitgudCounter = value; - break; - case 1: - gPlayer.eyeOfCthulhuGitgudCounter = value; - break; - case 2: - gPlayer.brainOfCthulhuGitgudCounter = value; - break; - case 3: - gPlayer.eaterOfWorldsGitgudCounter = value; - break; - case 4: - gPlayer.queenBeeGitgudCounter = value; - break; - case 5: - gPlayer.skeletronGitgudCounter = value; - break; - case 6: - gPlayer.wallOfFleshGitgudCounter = value; - break; - //HARDMODE - case 7: - gPlayer.queenSlimeGitgudCounter = value; - break; - case 8: - gPlayer.destroyerGitgudCounter = value; - break; - case 9: - gPlayer.twinsGitgudCounter = value; - break; - case 10: - gPlayer.skeletronPrimeGitgudCounter = value; - break; - case 11: - gPlayer.planteraGitgudCounter = value; - break; - case 12: - gPlayer.empressOfLightGitgudCounter = value; - break; - case 13: - gPlayer.golemGitgudCounter = value; - break; - case 14: - gPlayer.dukeFishronGitgudCounter = value; - break; - case 15: - gPlayer.lunaticCultistGitgudCounter = value; - break; - case 16: - gPlayer.moonLordGitgudCounter = value; - break; - //INVASIONS - //case 17: - // gPlayer.pirateInvasionGitgudCounter = value; - // break; - default: //shouldn't get there hopefully - if (packet) AssUtils.Instance.Logger.Warn("Received unspecified GitgudReset Packet " + index); - else throw new Exception("Unspecified index in the gitgud array " + index); - break; - } - } - - /// - /// Used in GitgudItem.ModifyTooltips - /// - public static bool GetDataFromItemType(int type, out GitgudData data) - { - data = null; - if (DataList != null) - { - for (int i = 0; i < DataList.Length; i++) - { - if (DataList[i].ItemType == type) - { - data = DataList[i]; - } - } - } - return data != null; - } - - /// - /// Called in LoadCounters - /// - public static void SendCounters(int whoAmI) - { - if (DataList != null) - { - //Length is synced on both sides anyway - ModPacket packet = AssUtils.Instance.GetPacket(); - packet.Write((byte)AssMessageType.GitgudLoadCounters); - packet.Write((byte)whoAmI); - for (int i = 0; i < DataList.Length; i++) - { - packet.Write((byte)DataList[i].Counter[whoAmI]); - } - packet.Send(); - } - } - - /// - /// Called in Mod.HandlePacket. Reads the whole list when the player joins to synchronize - /// - public static void RecvCounters(BinaryReader reader) - { - if (DataList != null) - { - //Length is synced on both sides anyway - int whoAmI = reader.ReadByte(); - byte[] tempArray = new byte[DataList.Length]; - for (int i = 0; i < DataList.Length; i++) //probably unnecessary but idk - { - tempArray[i] = reader.ReadByte(); - } - for (int i = 0; i < DataList.Length; i++) - { - //DataList[i].Counter[whoAmI] = tempArray[i]; - SetCounter(whoAmI, i, tempArray[i], true); - } - } - } - - /// - /// Called in Mod.HandlePacket - /// - public static void RecvChangeCounter(BinaryReader reader) - { - if (DataList != null && Main.netMode == NetmodeID.MultiplayerClient) - { - int whoAmI = Main.LocalPlayer.whoAmI; - int index = reader.ReadByte(); - byte value = reader.ReadByte(); - //DataList[index].Counter[whoAmI] = value; - SetCounter(whoAmI, index, value, true); - if (value == 0) DeleteItemFromInventory(Main.player[whoAmI], index); - //AssUtils.Print("recv changecounter from server with " + whoAmI + " " + index + " " + value); - } - } - - /// - /// Called in IncreaseCounters and Reset. Serverside - /// - private static void SendChangeCounter(int whoAmI, int index, byte value) - { - if (DataList != null && Main.netMode == NetmodeID.Server) - { - //Length is synced on both sides anyway - ModPacket packet = AssUtils.Instance.GetPacket(); - packet.Write((byte)AssMessageType.GitgudChangeCounters); - packet.Write((byte)index); - packet.Write((byte)value); - packet.Send(toClient: whoAmI); - //AssUtils.Print("send changecounter from server with " + whoAmI + " " + index + " " + value); - } - } - - /// - /// Called in GeneralGlobalNPC.NPCLoot. Sends all participating players a reset packet - /// - public static void Reset(NPC npc) - { - //Single and Server only - if (DataList != null) - { - for (int j = 0; j < Main.maxPlayers; j++) - { - Player player = Main.player[j]; - if (player.active && npc.playerInteraction[j]) //playerInteraction is only accurate in single and server - { - for (int i = 0; i < DataList.Length; i++) - { - //resets even when all but one player is dead and boss is defeated - GitgudData data = DataList[i]; - bool canReset = Array.BinarySearch(data.BossTypeList, npc.type) > -1; - - if (canReset && data.CustomCountCondition(npc)) - { - DeleteItemFromInventory(player, i); - - //only send a packet if necessary - if (data.Counter[j] != 0) - { - //DataList[i].Counter[j] = 0; - SetCounter(j, i, 0); - SendChangeCounter(j, i, 0); - } - } - } - } - } - } - } - - /// - /// Called in OnRespawn, spawns the item if the counter was overflown. Not clientside (not even sure myself at this point) - /// - public static void SpawnItem(Player player) - { - if (DataList != null) - { - for (int i = 0; i < DataList.Length; i++) - { - GitgudData data = DataList[i]; - if (data.Counter[player.whoAmI] >= data.CounterMax) - { - //DataList[i].Counter[player.whoAmI] = 0; - SetCounter(player.whoAmI, i, 0); - if (!player.HasItem(data.ItemType) && !data.Accessory[player.whoAmI]) - { - int spawnX = Main.spawnTileX - 1; - int spawnY = Main.spawnTileY - 1; - if (player.SpawnX != -1 && player.SpawnY != -1) - { - spawnX = player.SpawnX; - spawnY = player.SpawnY; - } - Item.NewItem(new EntitySource_WorldEvent(), new Vector2(spawnX, spawnY) * 16, data.ItemType); - } - } - } - } - } - - /// - /// Called in PostUpdateEquips - /// - public static void ApplyBuffImmune(Player player) - { - if (DataList != null) - { - for (int i = 0; i < DataList.Length; i++) - { - GitgudData data = DataList[i]; - if (data.Accessory[player.whoAmI] && data.BuffType != -1 && AssUtils.AnyNPCs(data.BossTypeList)) - { - player.buffImmune[data.BuffType] = true; - } - } - } - } - - /// - /// Called in PreKill, checks what NPCs are alive, then increases the counter by 1 - /// - public static void IncreaseCounters(int whoAmI) - { - if (DataList != null) - { - bool[] increasedFor = new bool[DataList.Length]; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - if (npc.active && npc.playerInteraction[whoAmI]) //playerInteraction is only accurate in single and server - { - for (int i = 0; i < DataList.Length; i++) - { - GitgudData data = DataList[i]; - if (!increasedFor[i] && Array.BinarySearch(data.BossTypeList, npc.type) > -1) - { - //AssUtils.Print("increased counter of " + whoAmI + " from " + DataList[i].Counter[whoAmI] + " to " + (DataList[i].Counter[whoAmI] + 1)); - //DataList[i].Counter[whoAmI]++; - byte value = (byte)(data.Counter[whoAmI] + 1); - SetCounter(whoAmI, i, value); - SendChangeCounter(whoAmI, i, value); - increasedFor[i] = true; - } - } - } - } - } - } - - /// - /// Called in ModifyHitByNPC - /// - public static void ReduceDamageNPC(int whoAmI, int npcType, ref int damage) - { - if (DataList != null) - { - for (int i = 0; i < DataList.Length; i++) - { - GitgudData data = DataList[i]; - if (data.Accessory[whoAmI]) - { - //only reduce damage if accessory worn and (either an invasion is going on or a boss alive) - if (data.InvasionBool() || - (Array.BinarySearch(data.NPCTypeList, npcType) > -1 && AssUtils.AnyNPCs(data.BossTypeList))) - { - damage = (int)(damage * (1 - data.Reduction)); - return; - } - } - } - } - } - - /// - /// Called in ModifyHitByProjectile - /// - public static void ReduceDamageProj(int whoAmI, int projType, ref int damage) - { - if (DataList != null) - { - for (int i = 0; i < DataList.Length; i++) - { - GitgudData data = DataList[i]; - if (data.Accessory[whoAmI]) - { - //only reduce damage if accessory worn and (either an invasion is going on or a boss alive) - if (data.InvasionBool() || - (Array.BinarySearch(data.ProjTypeList, projType) > -1 && AssUtils.AnyNPCs(data.BossTypeList))) - { - damage = (int)(damage * (1 - data.Reduction)); - return; - } - } - } - } - } - - /// - /// Called in PostUpdateEquips. Updates the DataList with if the accessories are worn - /// - public static void UpdateAccessories(int whoAmI, BitArray accessories) - { - if (DataList != null) - { - if (accessories.Length != DataList.Length) throw new Exception("Number of gitgud accessory bools don't match with the registered gitgud items"); - for (int i = 0; i < accessories.Length; i++) //has to have the same order as DataList - { - DataList[i].Accessory[whoAmI] = accessories[i]; - } - } - } - - /// - /// Called in OnEnterWorld, Sets up the counters in the DataList for each accessory. Clientside - /// - public static void LoadCounters(int whoAmI, byte[] counters) - { - if (DataList != null) - { - if (counters.Length != DataList.Length) throw new Exception("Number of gitgud counters don't match with the registered gitgud counters"); - for (int i = 0; i < counters.Length; i++) //has to have the same order as DataList - { - DataList[i].Counter[whoAmI] = counters[i]; - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - { - SendCounters(whoAmI); - } - } - } - - /// - /// Called in Mod.PostSetupContent. Basically a RegisterItems() - /// - /// - public static void Load() - { - if (!ContentConfig.Instance.BossConsolation) - { - return; - } - - DataList = new GitgudData[1]; - - RegisterItems(); - - //since Add always increases the array size by one, it will make it so the last element is null - Array.Resize(ref DataList, DataList.Length - 1); - if (DataList.Length == 0) DataList = null; - } - - /// - /// Called in Mod.Unload - /// - public static void Unload() - { - DataList = null; - } - - private static bool OtherTwinDead(NPC npc) - { - if (npc.type == NPCID.Retinazer) - { - return !NPC.AnyNPCs(NPCID.Spazmatism); - } - else - { - return !NPC.AnyNPCs(NPCID.Retinazer); - } - } - - /// - /// Fills the DataList with data for each accessory - /// - private static void RegisterItems() - { - Add( - -1, - NPCID.KingSlime, - nPCTypeList: new int[] { NPCID.BlueSlime }, - projTypeList: new int[] { ProjectileID.SpikedSlimeSpike }); - Add( - -1, - NPCID.EyeofCthulhu, - nPCTypeList: new int[] { NPCID.ServantofCthulhu }); - Add( - BuffID.Slow, - NPCID.BrainofCthulhu, - nPCTypeList: new int[] { NPCID.Creeper }); - Add( - BuffID.Weak, - new int[] { NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail, NPCID.EaterofWorldsHead }, - nPCTypeList: new int[] { NPCID.VileSpit }, - customCountCondition: (NPC npc) => npc.boss); - Add( - BuffID.Poisoned, - NPCID.QueenBee, - nPCTypeList: new int[] { NPCID.Bee, NPCID.BeeSmall }, - projTypeList: new int[] { ProjectileID.Stinger }); - Add( - BuffID.Bleeding, - NPCID.SkeletronHead, - nPCTypeList: new int[] { NPCID.SkeletronHand }, - projTypeList: new int[] { ProjectileID.Skull }); - Add( - -1, - NPCID.WallofFlesh, - nPCTypeList: new int[] { NPCID.WallofFleshEye }, - projTypeList: new int[] { ProjectileID.EyeLaser }); - - //HARDMODE - Add( - -1, - NPCID.QueenSlimeBoss, - nPCTypeList: new int[] { NPCID.QueenSlimeMinionBlue, NPCID.QueenSlimeMinionPink, NPCID.QueenSlimeMinionPurple }, - projTypeList: new int[] { ProjectileID.QueenSlimeGelAttack, ProjectileID.QueenSlimeSmash, ProjectileID.QueenSlimeMinionBlueSpike, ProjectileID.QueenSlimeMinionPinkBall }); - Add( - -1, - NPCID.TheDestroyer, - nPCTypeList: new int[] { NPCID.TheDestroyerBody, NPCID.TheDestroyerTail, NPCID.Probe }, - projTypeList: new int[] { ProjectileID.PinkLaser }); - Add( - BuffID.CursedInferno, - new int[] { NPCID.Retinazer, NPCID.Spazmatism }, - projTypeList: new int[] { ProjectileID.EyeLaser, ProjectileID.CursedFlameHostile, ProjectileID.EyeFire }, - customCountCondition: OtherTwinDead); - Add( - -1, - NPCID.SkeletronPrime, - nPCTypeList: new int[] { NPCID.PrimeCannon, NPCID.PrimeLaser, NPCID.PrimeSaw, NPCID.PrimeVice, }, - projTypeList: new int[] { ProjectileID.DeathLaser, ProjectileID.BombSkeletronPrime, }); - Add( - BuffID.Poisoned, - NPCID.Plantera, - nPCTypeList: new int[] { NPCID.PlanterasHook, NPCID.PlanterasTentacle }, - projTypeList: new int[] { ProjectileID.ThornBall, ProjectileID.SeedPlantera, ProjectileID.PoisonSeedPlantera }); - Add( - -1, - NPCID.HallowBoss, - //TODO confirm 872, 873, 919, 923, 924 minus HallowBossDeathAurora (874) spawn - projTypeList: new int[] { ProjectileID.HallowBossLastingRainbow, ProjectileID.HallowBossRainbowStreak, ProjectileID.FairyQueenLance, ProjectileID.FairyQueenSunDance, ProjectileID.FairyQueenHymn, }); - Add( - BuffID.OnFire, - NPCID.Golem, - nPCTypeList: new int[] { NPCID.GolemFistLeft, NPCID.GolemFistRight, NPCID.GolemHead, NPCID.GolemHeadFree }, - projTypeList: new int[] { ProjectileID.Fireball, ProjectileID.EyeBeam }); - Add( - -1, - NPCID.DukeFishron, - nPCTypeList: new int[] { NPCID.DetonatingBubble, NPCID.Sharkron, NPCID.Sharkron2 }, - projTypeList: new int[] { ProjectileID.Sharknado, ProjectileID.SharknadoBolt, ProjectileID.Cthulunado }); - Add( - BuffID.OnFire, - NPCID.CultistBoss, - nPCTypeList: new int[] { NPCID.AncientCultistSquidhead,/* NPCID.CultistBossClone,*/ }, - projTypeList: new int[] { ProjectileID.CultistBossIceMist, ProjectileID.CultistBossLightningOrb, ProjectileID.CultistBossLightningOrbArc, ProjectileID.CultistBossFireBall, ProjectileID.CultistBossFireBallClone }); - Add( - -1, - new int[] { NPCID.MoonLordHead, NPCID.MoonLordCore }, - nPCTypeList: new int[] { NPCID.MoonLordFreeEye,/* NPCID.MoonLordHand, NPCID.MoonLordHead, NPCID.MoonLordLeechBlob */}, //don't deal any damage - projTypeList: new int[] { ProjectileID.PhantasmalEye, ProjectileID.PhantasmalSphere, ProjectileID.PhantasmalDeathray, ProjectileID.PhantasmalBolt }); - //INVASIONS - //Add( - // "", -1, - // NPCID.PirateShip, - // reduction: 0.10f, - // invasion: "The Pirate Invasion", - // invasionBool: ()=> (Main.invasionType == InvasionID.PirateInvasion)); - - //Add( - // , , - // , - // , - // ); - // Last two optional (if boss is super basic, but I can't think of one) - } - } - - [Content(ContentType.BossConsolation)] - public class GitGudPlayer : AssPlayerBase - { - public Func gitgudAccessories; - - public byte kingSlimeGitgudCounter = 0; - public bool kingSlimeGitgud = false; - - public byte eyeOfCthulhuGitgudCounter = 0; - public bool eyeOfCthulhuGitgud = false; - - public byte brainOfCthulhuGitgudCounter = 0; - public bool brainOfCthulhuGitgud = false; - - public byte eaterOfWorldsGitgudCounter = 0; - public bool eaterOfWorldsGitgud = false; - - public byte queenBeeGitgudCounter = 0; - public bool queenBeeGitgud = false; - - public byte skeletronGitgudCounter = 0; - public bool skeletronGitgud = false; - - public byte wallOfFleshGitgudCounter = 0; - public bool wallOfFleshGitgud = false; - - //HARDMODE - - public byte queenSlimeGitgudCounter = 0; - public bool queenSlimeGitgud = false; - - public byte destroyerGitgudCounter = 0; - public bool destroyerGitgud = false; - - public byte twinsGitgudCounter = 0; - public bool twinsGitgud = false; - - public byte skeletronPrimeGitgudCounter = 0; - public bool skeletronPrimeGitgud = false; - - public byte planteraGitgudCounter = 0; - public bool planteraGitgud = false; - - public byte empressOfLightGitgudCounter = 0; - public bool empressOfLightGitgud = false; - - public byte golemGitgudCounter = 0; - public bool golemGitgud = false; - - public byte dukeFishronGitgudCounter = 0; - public bool dukeFishronGitgud = false; - - public byte lunaticCultistGitgudCounter = 0; - public bool lunaticCultistGitgud = false; - - public byte moonLordGitgudCounter = 0; - public bool moonLordGitgud = false; - - //INVASIONS - - //public byte pirateInvasionGitgudCounter = 0; - //public bool pirateInvasionGitgud = false; - - public override void ResetEffects() - { - kingSlimeGitgud = false; - eyeOfCthulhuGitgud = false; - brainOfCthulhuGitgud = false; - eaterOfWorldsGitgud = false; - queenBeeGitgud = false; - skeletronGitgud = false; - wallOfFleshGitgud = false; - queenSlimeGitgud = false; - destroyerGitgud = false; - twinsGitgud = false; - skeletronPrimeGitgud = false; - planteraGitgud = false; - empressOfLightGitgud = false; - golemGitgud = false; - dukeFishronGitgud = false; - lunaticCultistGitgud = false; - moonLordGitgud = false; - //pirateInvasionGitgud = false; - } - - public override void Initialize() - { - gitgudAccessories = new Func(() => new BitArray(new bool[] - { - kingSlimeGitgud, - eyeOfCthulhuGitgud, - brainOfCthulhuGitgud, - eaterOfWorldsGitgud, - queenBeeGitgud, - skeletronGitgud, - wallOfFleshGitgud, - queenSlimeGitgud, - destroyerGitgud, - twinsGitgud, - skeletronPrimeGitgud, - planteraGitgud, - empressOfLightGitgud, - golemGitgud, - dukeFishronGitgud, - lunaticCultistGitgud, - moonLordGitgud, + /// + /// Holds static functions and data related to the Gitgud accessories + /// + public class GitgudData + { + /// + /// Holds the data of all Gitgud Accessories, and a list of counters per player + /// + private static GitgudData[] DataList; //Left as null if disabled via config + /// + /// Name for the delete message + /// + public Func ItemNameFunc { set; get; } + /// + /// Boss name for tooltip + /// + public string BossName { set; get; } + /// + /// Buff immunity while boss is alive + /// + public int BuffType { private set; get; } + /// + /// Buff name for tooltip + /// + public Func BuffNameFunc { private set; get; } + /// + /// Dropped gitgud item + /// + public int ItemType { private set; get; } + /// + /// Boss type (usually only one, can be multiple for worms) + /// + public int[] BossTypeList { private set; get; } + /// + /// NPCs that deal damage during the boss fight (boss minions) (includes the boss itself by default) + /// + public int[] NPCTypeList { private set; get; } + /// + /// Projectiles that deal damage during the boss fight + /// + public int[] ProjTypeList { private set; get; } + /// + /// Threshold, after which the item drops + /// + public byte CounterMax { private set; get; } + /// + /// Percentage by which the damage gets reduced + /// + public float Reduction { private set; get; } + public Func CustomCountCondition { get; private set; } + /// + /// Invasion name, unused + /// + public string Invasion { private set; get; } + /// + /// Invasion in progress, ignore the lists for damage reduction + /// + public Func InvasionBool { private set; get; } + + //255 long + /// + /// The bool that is set by the wearing accessory + /// + public BitArray Accessory { private set; get; } + /// + /// number of times player died to the boss + /// + public byte[] Counter { private set; get; } + + public GitgudData(int itemType, int buffType, + int[] bossTypeList, int[] nPCTypeList, int[] projTypeList, byte counterMax, float reduction, Func customCountCondition, string invasion, Func invasionBool) + { + ItemType = itemType; + ItemNameFunc = () => Lang.GetItemNameValue(itemType); + BuffType = buffType; + BuffNameFunc = () => Lang.GetBuffName(buffType); + BossTypeList = bossTypeList; + + NPC npc = ContentSamples.NpcsByNetId[bossTypeList[0]]; + BossName = npc.GetFullNetName().ToString(); + if (bossTypeList.Length > 1) + { + for (int i = 1; i < bossTypeList.Length; i++) + { + npc = ContentSamples.NpcsByNetId[bossTypeList[i]]; + string name = npc.GetFullNetName().ToString(); + if (!BossName.Contains(name)) + { + BossName += " or " + name; + } + } + } + + if (nPCTypeList == null) nPCTypeList = new int[1]; + if (projTypeList == null) projTypeList = new int[1]; + + NPCTypeList = AssUtils.ConcatArray(nPCTypeList, bossTypeList); + ProjTypeList = projTypeList; + CounterMax = counterMax; + Reduction = reduction; + CustomCountCondition = customCountCondition ?? ((NPC npc) => true); + Invasion = invasion; + InvasionBool = invasionBool ?? (() => false); + + Array.Sort(BossTypeList); + Array.Sort(NPCTypeList); + Array.Sort(ProjTypeList); + + Counter = new byte[255]; + Accessory = new BitArray(255); + } + + public override string ToString() + { + return ItemNameFunc(); + } + + public static void Add(int buffType, + int[] bossTypeList, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func customCountCondition = null, string invasion = "", Func invasionBool = null) where T : ModItem + { + Add(ModContent.ItemType(), buffType, bossTypeList, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool); + } + + public static void Add(int itemType, int buffType, + int[] bossTypeList, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func customCountCondition = null, string invasion = "", Func invasionBool = null) + { + if (itemType < 0 || itemType >= ItemLoader.ItemCount) throw new Exception("not a valid item type"); + + DataList[DataList.Length - 1] = new GitgudData(itemType, buffType, bossTypeList, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool); + Array.Resize(ref DataList, DataList.Length + 1); + } + + public static void Add(int buffType, + int bossType, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func customCountCondition = null, string invasion = "", Func invasionBool = null) where T : ModItem + { + Add(ModContent.ItemType(), buffType, new int[] { bossType }, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool); + } + + public static void Add(int itemType, int buffType, + int bossType, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func customCountCondition = null, string invasion = "", Func invasionBool = null) + { + Add(itemType, buffType, new int[] { bossType }, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool); + } + + /// + /// Called in Reset and RecvChangeCounter. Deletes the item from the inventory, trash slot, mouse item, and accessories + /// + private static void DeleteItemFromInventory(Player player, int index) + { + GitgudData data = DataList[index]; + int itemType = data.ItemType; + string itemName = data.ItemNameFunc(); + + bool deleted = false; + + Item[][] inventoryArray = { player.inventory, player.bank.item, player.bank2.item, player.bank3.item, player.bank4.item, player.armor }; //go though player inv + for (int y = 0; y < inventoryArray.Length; y++) + { + for (int e = 0; e < inventoryArray[y].Length; e++) + { + if (inventoryArray[y][e].type == itemType) //find gitgud item + { + inventoryArray[y][e].TurnToAir(); + deleted = true; + } + } + } + + //trash slot + if (player.trashItem.type == itemType) + { + player.trashItem.TurnToAir(); + deleted = true; + } + + //mouse item + if (Main.netMode != NetmodeID.Server && Main.myPlayer == player.whoAmI && Main.mouseItem.type == itemType) + { + Main.mouseItem.TurnToAir(); + deleted = true; + } + + if (deleted && Main.myPlayer == player.whoAmI) + { + Main.NewText("You won't be needing the " + itemName + " anymore...", new Color(255, 175, 0)); + } + } + + /// + /// Sets the counter on both the DataList and the players respective field + /// + private static void SetCounter(int whoAmI, int index, byte value, bool packet = false) + { + DataList[index].Counter[whoAmI] = value; + GitGudPlayer gPlayer = Main.player[whoAmI].GetModPlayer(); + switch (index) + { + case 0: + gPlayer.kingSlimeGitgudCounter = value; + break; + case 1: + gPlayer.eyeOfCthulhuGitgudCounter = value; + break; + case 2: + gPlayer.brainOfCthulhuGitgudCounter = value; + break; + case 3: + gPlayer.eaterOfWorldsGitgudCounter = value; + break; + case 4: + gPlayer.queenBeeGitgudCounter = value; + break; + case 5: + gPlayer.skeletronGitgudCounter = value; + break; + case 6: + gPlayer.wallOfFleshGitgudCounter = value; + break; + //HARDMODE + case 7: + gPlayer.queenSlimeGitgudCounter = value; + break; + case 8: + gPlayer.destroyerGitgudCounter = value; + break; + case 9: + gPlayer.twinsGitgudCounter = value; + break; + case 10: + gPlayer.skeletronPrimeGitgudCounter = value; + break; + case 11: + gPlayer.planteraGitgudCounter = value; + break; + case 12: + gPlayer.empressOfLightGitgudCounter = value; + break; + case 13: + gPlayer.golemGitgudCounter = value; + break; + case 14: + gPlayer.dukeFishronGitgudCounter = value; + break; + case 15: + gPlayer.lunaticCultistGitgudCounter = value; + break; + case 16: + gPlayer.moonLordGitgudCounter = value; + break; + //INVASIONS + //case 17: + // gPlayer.pirateInvasionGitgudCounter = value; + // break; + default: //shouldn't get there hopefully + if (packet) AssUtils.Instance.Logger.Warn("Received unspecified GitgudReset Packet " + index); + else throw new Exception("Unspecified index in the gitgud array " + index); + break; + } + } + + /// + /// Used in GitgudItem.ModifyTooltips + /// + public static bool GetDataFromItemType(int type, out GitgudData data) + { + data = null; + if (DataList != null) + { + for (int i = 0; i < DataList.Length; i++) + { + if (DataList[i].ItemType == type) + { + data = DataList[i]; + } + } + } + return data != null; + } + + /// + /// Called in LoadCounters + /// + public static void SendCounters(int whoAmI) + { + if (DataList != null) + { + //Length is synced on both sides anyway + ModPacket packet = AssUtils.Instance.GetPacket(); + packet.Write((byte)AssMessageType.GitgudLoadCounters); + packet.Write((byte)whoAmI); + for (int i = 0; i < DataList.Length; i++) + { + packet.Write((byte)DataList[i].Counter[whoAmI]); + } + packet.Send(); + } + } + + /// + /// Called in Mod.HandlePacket. Reads the whole list when the player joins to synchronize + /// + public static void RecvCounters(BinaryReader reader) + { + if (DataList != null) + { + //Length is synced on both sides anyway + int whoAmI = reader.ReadByte(); + byte[] tempArray = new byte[DataList.Length]; + for (int i = 0; i < DataList.Length; i++) //probably unnecessary but idk + { + tempArray[i] = reader.ReadByte(); + } + for (int i = 0; i < DataList.Length; i++) + { + //DataList[i].Counter[whoAmI] = tempArray[i]; + SetCounter(whoAmI, i, tempArray[i], true); + } + } + } + + /// + /// Called in Mod.HandlePacket + /// + public static void RecvChangeCounter(BinaryReader reader) + { + if (DataList != null && Main.netMode == NetmodeID.MultiplayerClient) + { + int whoAmI = Main.LocalPlayer.whoAmI; + int index = reader.ReadByte(); + byte value = reader.ReadByte(); + //DataList[index].Counter[whoAmI] = value; + SetCounter(whoAmI, index, value, true); + if (value == 0) DeleteItemFromInventory(Main.player[whoAmI], index); + //AssUtils.Print("recv changecounter from server with " + whoAmI + " " + index + " " + value); + } + } + + /// + /// Called in IncreaseCounters and Reset. Serverside + /// + private static void SendChangeCounter(int whoAmI, int index, byte value) + { + if (DataList != null && Main.netMode == NetmodeID.Server) + { + //Length is synced on both sides anyway + ModPacket packet = AssUtils.Instance.GetPacket(); + packet.Write((byte)AssMessageType.GitgudChangeCounters); + packet.Write((byte)index); + packet.Write((byte)value); + packet.Send(toClient: whoAmI); + //AssUtils.Print("send changecounter from server with " + whoAmI + " " + index + " " + value); + } + } + + /// + /// Called in GeneralGlobalNPC.NPCLoot. Sends all participating players a reset packet + /// + public static void Reset(NPC npc) + { + //Single and Server only + if (DataList != null) + { + for (int j = 0; j < Main.maxPlayers; j++) + { + Player player = Main.player[j]; + if (player.active && npc.playerInteraction[j]) //playerInteraction is only accurate in single and server + { + for (int i = 0; i < DataList.Length; i++) + { + //resets even when all but one player is dead and boss is defeated + GitgudData data = DataList[i]; + bool canReset = Array.BinarySearch(data.BossTypeList, npc.type) > -1; + + if (canReset && data.CustomCountCondition(npc)) + { + DeleteItemFromInventory(player, i); + + //only send a packet if necessary + if (data.Counter[j] != 0) + { + //DataList[i].Counter[j] = 0; + SetCounter(j, i, 0); + SendChangeCounter(j, i, 0); + } + } + } + } + } + } + } + + /// + /// Called in OnRespawn, spawns the item if the counter was overflown. Not clientside (not even sure myself at this point) + /// + public static void SpawnItem(Player player) + { + if (DataList != null) + { + for (int i = 0; i < DataList.Length; i++) + { + GitgudData data = DataList[i]; + if (data.Counter[player.whoAmI] >= data.CounterMax) + { + //DataList[i].Counter[player.whoAmI] = 0; + SetCounter(player.whoAmI, i, 0); + if (!player.HasItem(data.ItemType) && !data.Accessory[player.whoAmI]) + { + int spawnX = Main.spawnTileX - 1; + int spawnY = Main.spawnTileY - 1; + if (player.SpawnX != -1 && player.SpawnY != -1) + { + spawnX = player.SpawnX; + spawnY = player.SpawnY; + } + Item.NewItem(new EntitySource_WorldEvent(), new Vector2(spawnX, spawnY) * 16, data.ItemType); + } + } + } + } + } + + /// + /// Called in PostUpdateEquips + /// + public static void ApplyBuffImmune(Player player) + { + if (DataList != null) + { + for (int i = 0; i < DataList.Length; i++) + { + GitgudData data = DataList[i]; + if (data.Accessory[player.whoAmI] && data.BuffType != -1 && AssUtils.AnyNPCs(data.BossTypeList)) + { + player.buffImmune[data.BuffType] = true; + } + } + } + } + + /// + /// Called in PreKill, checks what NPCs are alive, then increases the counter by 1 + /// + public static void IncreaseCounters(int whoAmI) + { + if (DataList != null) + { + bool[] increasedFor = new bool[DataList.Length]; + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + if (npc.active && npc.playerInteraction[whoAmI]) //playerInteraction is only accurate in single and server + { + for (int i = 0; i < DataList.Length; i++) + { + GitgudData data = DataList[i]; + if (!increasedFor[i] && Array.BinarySearch(data.BossTypeList, npc.type) > -1) + { + //AssUtils.Print("increased counter of " + whoAmI + " from " + DataList[i].Counter[whoAmI] + " to " + (DataList[i].Counter[whoAmI] + 1)); + //DataList[i].Counter[whoAmI]++; + byte value = (byte)(data.Counter[whoAmI] + 1); + SetCounter(whoAmI, i, value); + SendChangeCounter(whoAmI, i, value); + increasedFor[i] = true; + } + } + } + } + } + } + + /// + /// Called in ModifyHitByNPC + /// + public static void ReduceDamageNPC(int whoAmI, int npcType, ref int damage) + { + if (DataList != null) + { + for (int i = 0; i < DataList.Length; i++) + { + GitgudData data = DataList[i]; + if (data.Accessory[whoAmI]) + { + //only reduce damage if accessory worn and (either an invasion is going on or a boss alive) + if (data.InvasionBool() || + (Array.BinarySearch(data.NPCTypeList, npcType) > -1 && AssUtils.AnyNPCs(data.BossTypeList))) + { + damage = (int)(damage * (1 - data.Reduction)); + return; + } + } + } + } + } + + /// + /// Called in ModifyHitByProjectile + /// + public static void ReduceDamageProj(int whoAmI, int projType, ref int damage) + { + if (DataList != null) + { + for (int i = 0; i < DataList.Length; i++) + { + GitgudData data = DataList[i]; + if (data.Accessory[whoAmI]) + { + //only reduce damage if accessory worn and (either an invasion is going on or a boss alive) + if (data.InvasionBool() || + (Array.BinarySearch(data.ProjTypeList, projType) > -1 && AssUtils.AnyNPCs(data.BossTypeList))) + { + damage = (int)(damage * (1 - data.Reduction)); + return; + } + } + } + } + } + + /// + /// Called in PostUpdateEquips. Updates the DataList with if the accessories are worn + /// + public static void UpdateAccessories(int whoAmI, BitArray accessories) + { + if (DataList != null) + { + if (accessories.Length != DataList.Length) throw new Exception("Number of gitgud accessory bools don't match with the registered gitgud items"); + for (int i = 0; i < accessories.Length; i++) //has to have the same order as DataList + { + DataList[i].Accessory[whoAmI] = accessories[i]; + } + } + } + + /// + /// Called in OnEnterWorld, Sets up the counters in the DataList for each accessory. Clientside + /// + public static void LoadCounters(int whoAmI, byte[] counters) + { + if (DataList != null) + { + if (counters.Length != DataList.Length) throw new Exception("Number of gitgud counters don't match with the registered gitgud counters"); + for (int i = 0; i < counters.Length; i++) //has to have the same order as DataList + { + DataList[i].Counter[whoAmI] = counters[i]; + } + + if (Main.netMode == NetmodeID.MultiplayerClient) + { + SendCounters(whoAmI); + } + } + } + + /// + /// Called in Mod.PostSetupContent. Basically a RegisterItems() + /// + /// + public static void Load() + { + if (!ContentConfig.Instance.BossConsolation) + { + return; + } + + DataList = new GitgudData[1]; + + RegisterItems(); + + //since Add always increases the array size by one, it will make it so the last element is null + Array.Resize(ref DataList, DataList.Length - 1); + if (DataList.Length == 0) DataList = null; + } + + /// + /// Called in Mod.Unload + /// + public static void Unload() + { + DataList = null; + } + + private static bool OtherTwinDead(NPC npc) + { + if (npc.type == NPCID.Retinazer) + { + return !NPC.AnyNPCs(NPCID.Spazmatism); + } + else + { + return !NPC.AnyNPCs(NPCID.Retinazer); + } + } + + /// + /// Fills the DataList with data for each accessory + /// + private static void RegisterItems() + { + Add( + -1, + NPCID.KingSlime, + nPCTypeList: new int[] { NPCID.BlueSlime }, + projTypeList: new int[] { ProjectileID.SpikedSlimeSpike }); + Add( + -1, + NPCID.EyeofCthulhu, + nPCTypeList: new int[] { NPCID.ServantofCthulhu }); + Add( + BuffID.Slow, + NPCID.BrainofCthulhu, + nPCTypeList: new int[] { NPCID.Creeper }); + Add( + BuffID.Weak, + new int[] { NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail, NPCID.EaterofWorldsHead }, + nPCTypeList: new int[] { NPCID.VileSpit }, + customCountCondition: (NPC npc) => npc.boss); + Add( + BuffID.Poisoned, + NPCID.QueenBee, + nPCTypeList: new int[] { NPCID.Bee, NPCID.BeeSmall }, + projTypeList: new int[] { ProjectileID.Stinger }); + Add( + BuffID.Bleeding, + NPCID.SkeletronHead, + nPCTypeList: new int[] { NPCID.SkeletronHand }, + projTypeList: new int[] { ProjectileID.Skull }); + Add( + -1, + NPCID.WallofFlesh, + nPCTypeList: new int[] { NPCID.WallofFleshEye }, + projTypeList: new int[] { ProjectileID.EyeLaser }); + + //HARDMODE + Add( + -1, + NPCID.QueenSlimeBoss, + nPCTypeList: new int[] { NPCID.QueenSlimeMinionBlue, NPCID.QueenSlimeMinionPink, NPCID.QueenSlimeMinionPurple }, + projTypeList: new int[] { ProjectileID.QueenSlimeGelAttack, ProjectileID.QueenSlimeSmash, ProjectileID.QueenSlimeMinionBlueSpike, ProjectileID.QueenSlimeMinionPinkBall }); + Add( + -1, + NPCID.TheDestroyer, + nPCTypeList: new int[] { NPCID.TheDestroyerBody, NPCID.TheDestroyerTail, NPCID.Probe }, + projTypeList: new int[] { ProjectileID.PinkLaser }); + Add( + BuffID.CursedInferno, + new int[] { NPCID.Retinazer, NPCID.Spazmatism }, + projTypeList: new int[] { ProjectileID.EyeLaser, ProjectileID.CursedFlameHostile, ProjectileID.EyeFire }, + customCountCondition: OtherTwinDead); + Add( + -1, + NPCID.SkeletronPrime, + nPCTypeList: new int[] { NPCID.PrimeCannon, NPCID.PrimeLaser, NPCID.PrimeSaw, NPCID.PrimeVice, }, + projTypeList: new int[] { ProjectileID.DeathLaser, ProjectileID.BombSkeletronPrime, }); + Add( + BuffID.Poisoned, + NPCID.Plantera, + nPCTypeList: new int[] { NPCID.PlanterasHook, NPCID.PlanterasTentacle }, + projTypeList: new int[] { ProjectileID.ThornBall, ProjectileID.SeedPlantera, ProjectileID.PoisonSeedPlantera }); + Add( + -1, + NPCID.HallowBoss, + //TODO confirm 872, 873, 919, 923, 924 minus HallowBossDeathAurora (874) spawn + projTypeList: new int[] { ProjectileID.HallowBossLastingRainbow, ProjectileID.HallowBossRainbowStreak, ProjectileID.FairyQueenLance, ProjectileID.FairyQueenSunDance, ProjectileID.FairyQueenHymn, }); + Add( + BuffID.OnFire, + NPCID.Golem, + nPCTypeList: new int[] { NPCID.GolemFistLeft, NPCID.GolemFistRight, NPCID.GolemHead, NPCID.GolemHeadFree }, + projTypeList: new int[] { ProjectileID.Fireball, ProjectileID.EyeBeam }); + Add( + -1, + NPCID.DukeFishron, + nPCTypeList: new int[] { NPCID.DetonatingBubble, NPCID.Sharkron, NPCID.Sharkron2 }, + projTypeList: new int[] { ProjectileID.Sharknado, ProjectileID.SharknadoBolt, ProjectileID.Cthulunado }); + Add( + BuffID.OnFire, + NPCID.CultistBoss, + nPCTypeList: new int[] { NPCID.AncientCultistSquidhead,/* NPCID.CultistBossClone,*/ }, + projTypeList: new int[] { ProjectileID.CultistBossIceMist, ProjectileID.CultistBossLightningOrb, ProjectileID.CultistBossLightningOrbArc, ProjectileID.CultistBossFireBall, ProjectileID.CultistBossFireBallClone }); + Add( + -1, + new int[] { NPCID.MoonLordHead, NPCID.MoonLordCore }, + nPCTypeList: new int[] { NPCID.MoonLordFreeEye,/* NPCID.MoonLordHand, NPCID.MoonLordHead, NPCID.MoonLordLeechBlob */}, //don't deal any damage + projTypeList: new int[] { ProjectileID.PhantasmalEye, ProjectileID.PhantasmalSphere, ProjectileID.PhantasmalDeathray, ProjectileID.PhantasmalBolt }); + //INVASIONS + //Add( + // "", -1, + // NPCID.PirateShip, + // reduction: 0.10f, + // invasion: "The Pirate Invasion", + // invasionBool: ()=> (Main.invasionType == InvasionID.PirateInvasion)); + + //Add( + // , , + // , + // , + // ); + // Last two optional (if boss is super basic, but I can't think of one) + } + } + + [Content(ContentType.BossConsolation)] + public class GitGudPlayer : AssPlayerBase + { + public Func gitgudAccessories; + + public byte kingSlimeGitgudCounter = 0; + public bool kingSlimeGitgud = false; + + public byte eyeOfCthulhuGitgudCounter = 0; + public bool eyeOfCthulhuGitgud = false; + + public byte brainOfCthulhuGitgudCounter = 0; + public bool brainOfCthulhuGitgud = false; + + public byte eaterOfWorldsGitgudCounter = 0; + public bool eaterOfWorldsGitgud = false; + + public byte queenBeeGitgudCounter = 0; + public bool queenBeeGitgud = false; + + public byte skeletronGitgudCounter = 0; + public bool skeletronGitgud = false; + + public byte wallOfFleshGitgudCounter = 0; + public bool wallOfFleshGitgud = false; + + //HARDMODE + + public byte queenSlimeGitgudCounter = 0; + public bool queenSlimeGitgud = false; + + public byte destroyerGitgudCounter = 0; + public bool destroyerGitgud = false; + + public byte twinsGitgudCounter = 0; + public bool twinsGitgud = false; + + public byte skeletronPrimeGitgudCounter = 0; + public bool skeletronPrimeGitgud = false; + + public byte planteraGitgudCounter = 0; + public bool planteraGitgud = false; + + public byte empressOfLightGitgudCounter = 0; + public bool empressOfLightGitgud = false; + + public byte golemGitgudCounter = 0; + public bool golemGitgud = false; + + public byte dukeFishronGitgudCounter = 0; + public bool dukeFishronGitgud = false; + + public byte lunaticCultistGitgudCounter = 0; + public bool lunaticCultistGitgud = false; + + public byte moonLordGitgudCounter = 0; + public bool moonLordGitgud = false; + + //INVASIONS + + //public byte pirateInvasionGitgudCounter = 0; + //public bool pirateInvasionGitgud = false; + + public override void ResetEffects() + { + kingSlimeGitgud = false; + eyeOfCthulhuGitgud = false; + brainOfCthulhuGitgud = false; + eaterOfWorldsGitgud = false; + queenBeeGitgud = false; + skeletronGitgud = false; + wallOfFleshGitgud = false; + queenSlimeGitgud = false; + destroyerGitgud = false; + twinsGitgud = false; + skeletronPrimeGitgud = false; + planteraGitgud = false; + empressOfLightGitgud = false; + golemGitgud = false; + dukeFishronGitgud = false; + lunaticCultistGitgud = false; + moonLordGitgud = false; + //pirateInvasionGitgud = false; + } + + public override void Initialize() + { + gitgudAccessories = new Func(() => new BitArray(new bool[] + { + kingSlimeGitgud, + eyeOfCthulhuGitgud, + brainOfCthulhuGitgud, + eaterOfWorldsGitgud, + queenBeeGitgud, + skeletronGitgud, + wallOfFleshGitgud, + queenSlimeGitgud, + destroyerGitgud, + twinsGitgud, + skeletronPrimeGitgud, + planteraGitgud, + empressOfLightGitgud, + golemGitgud, + dukeFishronGitgud, + lunaticCultistGitgud, + moonLordGitgud, //pirateInvasionGitgud, } - )); - } - - //no need for syncplayer because the server handles the item drop stuff - - public override void SaveData(TagCompound tag) - { - tag.Add("kingSlimeGitgudCounter", (byte)kingSlimeGitgudCounter); - tag.Add("eyeOfCthulhuGitgudCounter", (byte)eyeOfCthulhuGitgudCounter); - tag.Add("brainOfCthulhuGitgudCounter", (byte)brainOfCthulhuGitgudCounter); - tag.Add("eaterOfWorldsGitgudCounter", (byte)eaterOfWorldsGitgudCounter); - tag.Add("queenBeeGitgudCounter", (byte)queenBeeGitgudCounter); - tag.Add("skeletronGitgudCounter", (byte)skeletronGitgudCounter); - tag.Add("wallOfFleshGitgudCounter", (byte)wallOfFleshGitgudCounter); - tag.Add("queenSlimeGitgudCounter", (byte)queenSlimeGitgudCounter); - tag.Add("destroyerGitgudCounter", (byte)destroyerGitgudCounter); - tag.Add("twinsGitgudCounter", (byte)twinsGitgudCounter); - tag.Add("skeletronPrimeGitgudCounter", (byte)skeletronPrimeGitgudCounter); - tag.Add("planteraGitgudCounter", (byte)planteraGitgudCounter); - tag.Add("empressOfLightGitgudCounter", (byte)empressOfLightGitgudCounter); - tag.Add("golemGitgudCounter", (byte)golemGitgudCounter); - tag.Add("dukeFishronGitgudCounter", (byte)dukeFishronGitgudCounter); - tag.Add("lunaticCultistGitgudCounter", (byte)lunaticCultistGitgudCounter); - tag.Add("moonLordGitgudCounter", (byte)moonLordGitgudCounter); - //tag.Add("pirateInvasionGitgudCounter", (byte)pirateInvasionGitgudCounter); - } - - public override void LoadData(TagCompound tag) - { - kingSlimeGitgudCounter = tag.GetByte("kingSlimeGitgudCounter"); - eyeOfCthulhuGitgudCounter = tag.GetByte("eyeOfCthulhuGitgudCounter"); - brainOfCthulhuGitgudCounter = tag.GetByte("brainOfCthulhuGitgudCounter"); - eaterOfWorldsGitgudCounter = tag.GetByte("eaterOfWorldsGitgudCounter"); - queenBeeGitgudCounter = tag.GetByte("queenBeeGitgudCounter"); - skeletronGitgudCounter = tag.GetByte("skeletronGitgudCounter"); - wallOfFleshGitgudCounter = tag.GetByte("wallOfFleshGitgudCounter"); - queenSlimeGitgudCounter = tag.GetByte("queenSlimeGitgudCounter"); - destroyerGitgudCounter = tag.GetByte("destroyerGitgudCounter"); - twinsGitgudCounter = tag.GetByte("twinsGitgudCounter"); - skeletronPrimeGitgudCounter = tag.GetByte("skeletronPrimeGitgudCounter"); - planteraGitgudCounter = tag.GetByte("planteraGitgudCounter"); - empressOfLightGitgudCounter = tag.GetByte("empressOfLightGitgudCounter"); - golemGitgudCounter = tag.GetByte("golemGitgudCounter"); - dukeFishronGitgudCounter = tag.GetByte("dukeFishronGitgudCounter"); - lunaticCultistGitgudCounter = tag.GetByte("lunaticCultistGitgudCounter"); - moonLordGitgudCounter = tag.GetByte("moonLordGitgudCounter"); - //pirateInvasionGitgudCounter = tag.GetByte("pirateInvasionGitgudCounter"); - } - - public override void ModifyHitByNPC(NPC npc, ref int damage, ref bool crit) - { - GitgudData.ReduceDamageNPC(Player.whoAmI, npc.type, ref damage); - } - - public override void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit) - { - GitgudData.ReduceDamageProj(Player.whoAmI, proj.type, ref damage); - } - - public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) - { - GitgudData.IncreaseCounters(Player.whoAmI); - - return true; - } - - public override void OnEnterWorld(Player player) - { - GitgudData.LoadCounters(player.whoAmI, new byte[] - { - kingSlimeGitgudCounter, - eyeOfCthulhuGitgudCounter, - brainOfCthulhuGitgudCounter, - eaterOfWorldsGitgudCounter, - queenBeeGitgudCounter, - skeletronGitgudCounter, - wallOfFleshGitgudCounter, - queenSlimeGitgudCounter, - destroyerGitgudCounter, - twinsGitgudCounter, - skeletronPrimeGitgudCounter, - planteraGitgudCounter, - empressOfLightGitgudCounter, - golemGitgudCounter, - dukeFishronGitgudCounter, - lunaticCultistGitgudCounter, - moonLordGitgudCounter, + )); + } + + //no need for syncplayer because the server handles the item drop stuff + + public override void SaveData(TagCompound tag) + { + tag.Add("kingSlimeGitgudCounter", (byte)kingSlimeGitgudCounter); + tag.Add("eyeOfCthulhuGitgudCounter", (byte)eyeOfCthulhuGitgudCounter); + tag.Add("brainOfCthulhuGitgudCounter", (byte)brainOfCthulhuGitgudCounter); + tag.Add("eaterOfWorldsGitgudCounter", (byte)eaterOfWorldsGitgudCounter); + tag.Add("queenBeeGitgudCounter", (byte)queenBeeGitgudCounter); + tag.Add("skeletronGitgudCounter", (byte)skeletronGitgudCounter); + tag.Add("wallOfFleshGitgudCounter", (byte)wallOfFleshGitgudCounter); + tag.Add("queenSlimeGitgudCounter", (byte)queenSlimeGitgudCounter); + tag.Add("destroyerGitgudCounter", (byte)destroyerGitgudCounter); + tag.Add("twinsGitgudCounter", (byte)twinsGitgudCounter); + tag.Add("skeletronPrimeGitgudCounter", (byte)skeletronPrimeGitgudCounter); + tag.Add("planteraGitgudCounter", (byte)planteraGitgudCounter); + tag.Add("empressOfLightGitgudCounter", (byte)empressOfLightGitgudCounter); + tag.Add("golemGitgudCounter", (byte)golemGitgudCounter); + tag.Add("dukeFishronGitgudCounter", (byte)dukeFishronGitgudCounter); + tag.Add("lunaticCultistGitgudCounter", (byte)lunaticCultistGitgudCounter); + tag.Add("moonLordGitgudCounter", (byte)moonLordGitgudCounter); + //tag.Add("pirateInvasionGitgudCounter", (byte)pirateInvasionGitgudCounter); + } + + public override void LoadData(TagCompound tag) + { + kingSlimeGitgudCounter = tag.GetByte("kingSlimeGitgudCounter"); + eyeOfCthulhuGitgudCounter = tag.GetByte("eyeOfCthulhuGitgudCounter"); + brainOfCthulhuGitgudCounter = tag.GetByte("brainOfCthulhuGitgudCounter"); + eaterOfWorldsGitgudCounter = tag.GetByte("eaterOfWorldsGitgudCounter"); + queenBeeGitgudCounter = tag.GetByte("queenBeeGitgudCounter"); + skeletronGitgudCounter = tag.GetByte("skeletronGitgudCounter"); + wallOfFleshGitgudCounter = tag.GetByte("wallOfFleshGitgudCounter"); + queenSlimeGitgudCounter = tag.GetByte("queenSlimeGitgudCounter"); + destroyerGitgudCounter = tag.GetByte("destroyerGitgudCounter"); + twinsGitgudCounter = tag.GetByte("twinsGitgudCounter"); + skeletronPrimeGitgudCounter = tag.GetByte("skeletronPrimeGitgudCounter"); + planteraGitgudCounter = tag.GetByte("planteraGitgudCounter"); + empressOfLightGitgudCounter = tag.GetByte("empressOfLightGitgudCounter"); + golemGitgudCounter = tag.GetByte("golemGitgudCounter"); + dukeFishronGitgudCounter = tag.GetByte("dukeFishronGitgudCounter"); + lunaticCultistGitgudCounter = tag.GetByte("lunaticCultistGitgudCounter"); + moonLordGitgudCounter = tag.GetByte("moonLordGitgudCounter"); + //pirateInvasionGitgudCounter = tag.GetByte("pirateInvasionGitgudCounter"); + } + + public override void ModifyHitByNPC(NPC npc, ref int damage, ref bool crit) + { + GitgudData.ReduceDamageNPC(Player.whoAmI, npc.type, ref damage); + } + + public override void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit) + { + GitgudData.ReduceDamageProj(Player.whoAmI, proj.type, ref damage); + } + + public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) + { + GitgudData.IncreaseCounters(Player.whoAmI); + + return true; + } + + public override void OnEnterWorld(Player player) + { + GitgudData.LoadCounters(player.whoAmI, new byte[] + { + kingSlimeGitgudCounter, + eyeOfCthulhuGitgudCounter, + brainOfCthulhuGitgudCounter, + eaterOfWorldsGitgudCounter, + queenBeeGitgudCounter, + skeletronGitgudCounter, + wallOfFleshGitgudCounter, + queenSlimeGitgudCounter, + destroyerGitgudCounter, + twinsGitgudCounter, + skeletronPrimeGitgudCounter, + planteraGitgudCounter, + empressOfLightGitgudCounter, + golemGitgudCounter, + dukeFishronGitgudCounter, + lunaticCultistGitgudCounter, + moonLordGitgudCounter, //pirateInvasionGitgudCounter, }); - //TODO has to send to server! - } - - public override void PostUpdateEquips() - { - GitgudData.UpdateAccessories(Player.whoAmI, gitgudAccessories()); - GitgudData.ApplyBuffImmune(Player); - //AssUtils.Print(GitgudData.DataList.Length); - } - - public override void OnRespawn(Player player) - { - GitgudData.SpawnItem(player); - } - } + //TODO has to send to server! + } + + public override void PostUpdateEquips() + { + GitgudData.UpdateAccessories(Player.whoAmI, gitgudAccessories()); + GitgudData.ApplyBuffImmune(Player); + //AssUtils.Print(GitgudData.DataList.Length); + } + + public override void OnRespawn(Player player) + { + GitgudData.SpawnItem(player); + } + } } diff --git a/Gores/PaperGore.cs b/Gores/PaperGore.cs index b48933d4..dc2cd1c1 100644 --- a/Gores/PaperGore.cs +++ b/Gores/PaperGore.cs @@ -1,5 +1,3 @@ -using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.DataStructures; using Terraria.ID; diff --git a/Gores/PaperScrapGore.cs b/Gores/PaperScrapGore.cs index b1ec1863..63ffd4f1 100644 --- a/Gores/PaperScrapGore.cs +++ b/Gores/PaperScrapGore.cs @@ -9,13 +9,13 @@ namespace AssortedCrazyThings.Gores { public class PaperScrapGore : ModGore { - public override void SetStaticDefaults() - { + public override void SetStaticDefaults() + { GoreID.Sets.DisappearSpeedAlpha[Type] = 10; GoreID.Sets.DisappearSpeed[Type] = 7; } - public override void OnSpawn(Gore gore) + public override void OnSpawn(Gore gore) { gore.velocity += new Vector2(Main.rand.NextFloat() - 0.5f, Main.rand.NextFloat() * MathHelper.TwoPi); gore.Frame = new SpriteFrame(1, 8, 0, (byte)Main.rand.Next(8)); @@ -23,8 +23,8 @@ public override void OnSpawn(Gore gore) //UpdateType = 910; } - public override bool Update(Gore gore) - { + public override bool Update(Gore gore) + { if (++gore.frameCounter >= 8 && gore.velocity.Y > 0.2f) { gore.frameCounter = 0; @@ -36,7 +36,7 @@ public override bool Update(Gore gore) Gore_UpdateLeaf(gore, 0.2f); return false; - } + } public static void Gore_UpdateLeaf(Gore gore, float windFactor = 1f, bool disappearOnPositiveY = true) { @@ -99,7 +99,7 @@ public static void Gore_UpdateLeaf(Gore gore, float windFactor = 1f, bool disapp { gore.velocity.Y = 0.1f; if (disappearOnPositiveY) - { + { gore.timeLeft = 0; gore.alpha += 20; } diff --git a/Items/Accessories/AccessoryBase.cs b/Items/Accessories/AccessoryBase.cs index e378eab8..55897893 100644 --- a/Items/Accessories/AccessoryBase.cs +++ b/Items/Accessories/AccessoryBase.cs @@ -2,20 +2,20 @@ namespace AssortedCrazyThings.Items.Accessories { - [Content(ContentType.Accessories)] - public abstract class AccessoryBase : AssItem - { - public sealed override void SetDefaults() - { - SafeSetDefaults(); + [Content(ContentType.Accessories)] + public abstract class AccessoryBase : AssItem + { + public sealed override void SetDefaults() + { + SafeSetDefaults(); - Item.accessory = true; - Item.canBePlacedInVanityRegardlessOfConditions = true; - } + Item.accessory = true; + Item.canBePlacedInVanityRegardlessOfConditions = true; + } - public virtual void SafeSetDefaults() - { + public virtual void SafeSetDefaults() + { - } - } + } + } } diff --git a/Items/Accessories/Useful/BottledDreams.cs b/Items/Accessories/Useful/BottledDreams.cs index 678ea230..6f5a9b83 100644 --- a/Items/Accessories/Useful/BottledDreams.cs +++ b/Items/Accessories/Useful/BottledDreams.cs @@ -4,31 +4,31 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [AutoloadEquip(EquipType.Waist)] - public class BottledDreams : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Dreams"); - Tooltip.SetDefault("Allows the holder to double jump"); - } + [AutoloadEquip(EquipType.Waist)] + public class BottledDreams : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Dreams"); + Tooltip.SetDefault("Allows the holder to double jump"); + } - public override void SafeSetDefaults() - { - Item.width = 20; - Item.height = 26; - Item.value = Item.sellPrice(silver: 10); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 20; + Item.height = 26; + Item.value = Item.sellPrice(silver: 10); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.hasJumpOption_Unicorn = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.hasJumpOption_Unicorn = true; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Bottle, 1).AddIngredient(ItemID.PixieDust, 10).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Bottle, 1).AddIngredient(ItemID.PixieDust, 10).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Useful/CrazyBundleOfAssortedBalloons.cs b/Items/Accessories/Useful/CrazyBundleOfAssortedBalloons.cs index 050990d8..da5cf5f1 100644 --- a/Items/Accessories/Useful/CrazyBundleOfAssortedBalloons.cs +++ b/Items/Accessories/Useful/CrazyBundleOfAssortedBalloons.cs @@ -5,47 +5,47 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [AutoloadEquip(EquipType.Balloon)] - public class CrazyBundleOfAssortedBalloons : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Crazy Bundle of Assorted Balloons"); - Tooltip.SetDefault("It's got all kinds of effects"); - } + [AutoloadEquip(EquipType.Balloon)] + public class CrazyBundleOfAssortedBalloons : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Crazy Bundle of Assorted Balloons"); + Tooltip.SetDefault("It's got all kinds of effects"); + } - public override void SafeSetDefaults() - { - Item.width = 46; - Item.height = 42; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 46; + Item.height = 42; + Item.value = 0; + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.noFallDmg = true; - player.jumpBoost = true; - player.hasJumpOption_Cloud = true; - player.hasJumpOption_Sandstorm = true; - player.hasJumpOption_Blizzard = true; - player.hasJumpOption_Fart = true; - player.hasJumpOption_Sail = true; - player.hasJumpOption_Unicorn = true; - player.honeyCombItem = Item; - if (!player.HasBuff(BuffID.StarInBottle)) - { - player.manaRegenBonus += 2; - } - Lighting.AddLight(player.Center, 0.7f, 1.3f, 1.6f); - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.noFallDmg = true; + player.jumpBoost = true; + player.hasJumpOption_Cloud = true; + player.hasJumpOption_Sandstorm = true; + player.hasJumpOption_Blizzard = true; + player.hasJumpOption_Fart = true; + player.hasJumpOption_Sail = true; + player.hasJumpOption_Unicorn = true; + player.honeyCombItem = Item; + if (!player.HasBuff(BuffID.StarInBottle)) + { + player.manaRegenBonus += 2; + } + Lighting.AddLight(player.Center, 0.7f, 1.3f, 1.6f); + } - /* + /* * Massive bundle + Bipolar (+ Star) + Star Wisp + Cobballoon + Retinazer + Spaz + Bundled Party + Balloon Animal */ - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddIngredient(ItemID.PartyBundleOfBalloonsAccessory).AddIngredient(ItemID.PartyBalloonAnimal).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddIngredient(ItemID.PartyBundleOfBalloonsAccessory).AddIngredient(ItemID.PartyBalloonAnimal).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Useful/EverburningCandelabra.cs b/Items/Accessories/Useful/EverburningCandelabra.cs index e5782c8d..d6befe7b 100644 --- a/Items/Accessories/Useful/EverburningCandelabra.cs +++ b/Items/Accessories/Useful/EverburningCandelabra.cs @@ -1,37 +1,36 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Accessories.Useful { - public class EverburningCandelabra : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Everburning Candelabra"); - Tooltip.SetDefault("Applies various forms of fire damage to all attacks"); - } + public class EverburningCandelabra : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Everburning Candelabra"); + Tooltip.SetDefault("Applies various forms of fire damage to all attacks"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - Item.value = Item.sellPrice(gold: 13); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + Item.value = Item.sellPrice(gold: 13); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - AssPlayer mPlayer = player.GetModPlayer(); - mPlayer.everburningCandleBuff = true; - mPlayer.everburningShadowflameCandleBuff = true; - mPlayer.everfrozenCandleBuff = true; - mPlayer.everburningCursedCandleBuff = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + AssPlayer mPlayer = player.GetModPlayer(); + mPlayer.everburningCandleBuff = true; + mPlayer.everburningShadowflameCandleBuff = true; + mPlayer.everfrozenCandleBuff = true; + mPlayer.everburningCursedCandleBuff = true; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient().AddIngredient().AddIngredient().AddIngredient().AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient().AddIngredient().AddIngredient().AddIngredient().AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Useful/EverburningCandle.cs b/Items/Accessories/Useful/EverburningCandle.cs index 42f7280e..e79c9a6b 100644 --- a/Items/Accessories/Useful/EverburningCandle.cs +++ b/Items/Accessories/Useful/EverburningCandle.cs @@ -1,38 +1,37 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Accessories.Useful { - public class EverburningCandle : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Everburning Candle"); - Tooltip.SetDefault("Applies fire damage to all attacks"); - } + public class EverburningCandle : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Everburning Candle"); + Tooltip.SetDefault("Applies fire damage to all attacks"); + } - public override void SafeSetDefaults() - { - Item.width = 24; - Item.height = 22; - Item.value = Item.sellPrice(0, 2, 41, 0); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 24; + Item.height = 22; + Item.value = Item.sellPrice(0, 2, 41, 0); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().everburningCandleBuff = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().everburningCandleBuff = true; + } - public override void AddRecipes() - { - CreateRecipe(1) - .AddIngredient(ItemID.WaterCandle, 1) //1s - .AddIngredient(ItemID.MagmaStone, 1) //2g - .AddIngredient(ItemID.SoulofLight, 20) //2s * 20 - .AddTile(TileID.TinkerersWorkbench) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1) + .AddIngredient(ItemID.WaterCandle, 1) //1s + .AddIngredient(ItemID.MagmaStone, 1) //2g + .AddIngredient(ItemID.SoulofLight, 20) //2s * 20 + .AddTile(TileID.TinkerersWorkbench) + .Register(); + } + } } diff --git a/Items/Accessories/Useful/EverburningCursedCandle.cs b/Items/Accessories/Useful/EverburningCursedCandle.cs index 23990406..8580b438 100644 --- a/Items/Accessories/Useful/EverburningCursedCandle.cs +++ b/Items/Accessories/Useful/EverburningCursedCandle.cs @@ -3,35 +3,35 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - public class EverburningCursedCandle : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Everburning Cursed Candle"); - Tooltip.SetDefault("Applies cursed fire damage to all attacks"); - } + public class EverburningCursedCandle : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Everburning Cursed Candle"); + Tooltip.SetDefault("Applies cursed fire damage to all attacks"); + } - public override void SafeSetDefaults() - { - Item.width = 24; - Item.height = 22; - Item.value = Item.sellPrice(0, 2, 1, 0); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 24; + Item.height = 22; + Item.value = Item.sellPrice(0, 2, 1, 0); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().everburningCursedCandleBuff = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().everburningCursedCandleBuff = true; + } - public override void AddRecipes() - { - CreateRecipe(1) - .AddIngredient(ItemID.WaterCandle, 1) //1s - .AddIngredient(ItemID.CursedFlame, 20) //8s * 20 - .AddIngredient(ItemID.SoulofNight, 20) //2s * 20 - .AddTile(TileID.TinkerersWorkbench) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1) + .AddIngredient(ItemID.WaterCandle, 1) //1s + .AddIngredient(ItemID.CursedFlame, 20) //8s * 20 + .AddIngredient(ItemID.SoulofNight, 20) //2s * 20 + .AddTile(TileID.TinkerersWorkbench) + .Register(); + } + } } diff --git a/Items/Accessories/Useful/EverburningShadowflameCandle.cs b/Items/Accessories/Useful/EverburningShadowflameCandle.cs index f2d59c9d..94d3524c 100644 --- a/Items/Accessories/Useful/EverburningShadowflameCandle.cs +++ b/Items/Accessories/Useful/EverburningShadowflameCandle.cs @@ -1,38 +1,37 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Accessories.Useful { - public class EverburningShadowflameCandle : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Everburning Shadowflame Candle"); - Tooltip.SetDefault("Applies shadowflame damage to all attacks"); - } + public class EverburningShadowflameCandle : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Everburning Shadowflame Candle"); + Tooltip.SetDefault("Applies shadowflame damage to all attacks"); + } - public override void SafeSetDefaults() - { - Item.width = 24; - Item.height = 22; - Item.value = Item.sellPrice(0, 1, 41, 0); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 24; + Item.height = 22; + Item.value = Item.sellPrice(0, 1, 41, 0); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().everburningShadowflameCandleBuff = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().everburningShadowflameCandleBuff = true; + } - public override void AddRecipes() - { - CreateRecipe(1) - .AddIngredient(ItemID.WaterCandle, 1) //1s - .AddIngredient(ItemID.AncientBattleArmorMaterial, 1) //Forbidden fragment //1g - .AddIngredient(ItemID.SoulofNight, 20) //2s * 20 - .AddTile(TileID.TinkerersWorkbench) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1) + .AddIngredient(ItemID.WaterCandle, 1) //1s + .AddIngredient(ItemID.AncientBattleArmorMaterial, 1) //Forbidden fragment //1g + .AddIngredient(ItemID.SoulofNight, 20) //2s * 20 + .AddTile(TileID.TinkerersWorkbench) + .Register(); + } + } } diff --git a/Items/Accessories/Useful/EverfrozenCandle.cs b/Items/Accessories/Useful/EverfrozenCandle.cs index 35234103..a3ed8308 100644 --- a/Items/Accessories/Useful/EverfrozenCandle.cs +++ b/Items/Accessories/Useful/EverfrozenCandle.cs @@ -1,38 +1,37 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Accessories.Useful { - public class EverfrozenCandle : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Everfrozen Candle"); - Tooltip.SetDefault("Applies frostburn damage to all attacks"); - } + public class EverfrozenCandle : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Everfrozen Candle"); + Tooltip.SetDefault("Applies frostburn damage to all attacks"); + } - public override void SafeSetDefaults() - { - Item.width = 24; - Item.height = 22; - Item.value = Item.sellPrice(0, 1, 41, 0); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 24; + Item.height = 22; + Item.value = Item.sellPrice(0, 1, 41, 0); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().everfrozenCandleBuff = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().everfrozenCandleBuff = true; + } - public override void AddRecipes() - { - CreateRecipe(1) - .AddIngredient(ItemID.WaterCandle, 1) //1s - .AddIngredient(ItemID.FrostCore, 1) //1g - .AddIngredient(ItemID.SoulofLight, 20) //2s * 20 - .AddTile(TileID.TinkerersWorkbench) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1) + .AddIngredient(ItemID.WaterCandle, 1) //1s + .AddIngredient(ItemID.FrostCore, 1) //1g + .AddIngredient(ItemID.SoulofLight, 20) //2s * 20 + .AddTile(TileID.TinkerersWorkbench) + .Register(); + } + } } diff --git a/Items/Accessories/Useful/FestiveMirror.cs b/Items/Accessories/Useful/FestiveMirror.cs index 38be7f20..55b4843b 100644 --- a/Items/Accessories/Useful/FestiveMirror.cs +++ b/Items/Accessories/Useful/FestiveMirror.cs @@ -1,35 +1,34 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Accessories.Useful { - public class FestiveMirror : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Festive Mirror"); - Tooltip.SetDefault("Provides immunity to Chilled, Frozen, and Stoned"); - } + public class FestiveMirror : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Festive Mirror"); + Tooltip.SetDefault("Provides immunity to Chilled, Frozen, and Stoned"); + } - public override void SafeSetDefaults() - { - Item.width = 26; - Item.height = 32; - Item.value = Item.sellPrice(gold: 3); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 26; + Item.height = 32; + Item.value = Item.sellPrice(gold: 3); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.buffImmune[BuffID.Chilled] = true; //Immunity to Chilled debuff. - player.buffImmune[BuffID.Frozen] = true; //Immunity to Frozen debuff. - player.buffImmune[BuffID.Stoned] = true; //Immunity to Stoned debuff. - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.buffImmune[BuffID.Chilled] = true; //Immunity to Chilled debuff. + player.buffImmune[BuffID.Frozen] = true; //Immunity to Frozen debuff. + player.buffImmune[BuffID.Stoned] = true; //Immunity to Stoned debuff. + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.HandWarmer, 1).AddIngredient(ItemID.PocketMirror, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.HandWarmer, 1).AddIngredient(ItemID.PocketMirror, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Useful/HarvesterWings.cs b/Items/Accessories/Useful/HarvesterWings.cs index 016da2be..b4d6148a 100644 --- a/Items/Accessories/Useful/HarvesterWings.cs +++ b/Items/Accessories/Useful/HarvesterWings.cs @@ -8,117 +8,117 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [Content(ContentType.Bosses)] - [AutoloadEquip(EquipType.Wings)] //Dummy texture, non-4 frame wings need custom drawing - public class HarvesterWings : AccessoryBase - { - //Mirror of wing type 43, item ID 4754 (Grox The Great's Wings) - public const int NumFrames = 7; + [Content(ContentType.Bosses)] + [AutoloadEquip(EquipType.Wings)] //Dummy texture, non-4 frame wings need custom drawing + public class HarvesterWings : AccessoryBase + { + //Mirror of wing type 43, item ID 4754 (Grox The Great's Wings) + public const int NumFrames = 7; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Harvester Wings"); - Tooltip.SetDefault("Allows flight and slow fall" + - "\nIncreases your max number of minions" + - "\n5% increased summon damage"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Harvester Wings"); + Tooltip.SetDefault("Allows flight and slow fall" + + "\nIncreases your max number of minions" + + "\n5% increased summon damage"); - ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(95, 6.5f, 1.35f); - } + ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(95, 6.5f, 1.35f); + } - public override void SafeSetDefaults() - { - Item.width = 30; - Item.height = 32; - Item.value = Item.sellPrice(gold: 1); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 30; + Item.height = 32; + Item.value = Item.sellPrice(gold: 1); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetDamage(DamageClass.Summon) += 0.05f; - player.maxMinions++; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetDamage(DamageClass.Summon) += 0.05f; + player.maxMinions++; + } - public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) - { - ascentWhenFalling = 0.25f; - ascentWhenRising = 0.15f; - maxCanAscendMultiplier = 0.4f; - maxAscentMultiplier = 2f; - constantAscend = 0.12f; - } + public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) + { + ascentWhenFalling = 0.25f; + ascentWhenRising = 0.15f; + maxCanAscendMultiplier = 0.4f; + maxAscentMultiplier = 2f; + constantAscend = 0.12f; + } - public override bool WingUpdate(Player player, bool inUse) - { - if (inUse || player.jump > 0) - { - int endFrame = 6 + 1; - int startFrame = 1; - int frameSpeed = 3; - player.wingFrameCounter++; - if (player.wingFrameCounter > frameSpeed) - { - player.wingFrame++; - player.wingFrameCounter = 0; - if (player.wingFrame >= endFrame) - { - player.wingFrame = startFrame; - } - } - } - else if (player.velocity.Y != 0f) - { - player.wingFrame = 1; - } - else - { - player.wingFrame = 0; - } + public override bool WingUpdate(Player player, bool inUse) + { + if (inUse || player.jump > 0) + { + int endFrame = 6 + 1; + int startFrame = 1; + int frameSpeed = 3; + player.wingFrameCounter++; + if (player.wingFrameCounter > frameSpeed) + { + player.wingFrame++; + player.wingFrameCounter = 0; + if (player.wingFrame >= endFrame) + { + player.wingFrame = startFrame; + } + } + } + else if (player.velocity.Y != 0f) + { + player.wingFrame = 1; + } + else + { + player.wingFrame = 0; + } - if (inUse) - { - bool isFlapFrame = player.wingFrame == 4; + if (inUse) + { + bool isFlapFrame = player.wingFrame == 4; - if (isFlapFrame) - { - if (!player.flapSound) - { - SoundEngine.PlaySound(SoundID.Item32, player.position); - } + if (isFlapFrame) + { + if (!player.flapSound) + { + SoundEngine.PlaySound(SoundID.Item32, player.position); + } - player.flapSound = true; - } - else - { - player.flapSound = false; - } - } + player.flapSound = true; + } + else + { + player.flapSound = false; + } + } - if (player.velocity.Y != 0 && player.wingFrame != 0) - { - if (Main.rand.NextBool(3)) - { - int dustOffsetX = -16 - player.direction * 30; - int dustOffsetY = -16; - int dustIndex = Dust.NewDust(new Vector2(player.Center.X + dustOffsetX, player.Center.Y + dustOffsetY), 40, 30, 135, 0f, 0f, 0, default(Color), 1.5f); - Dust dust = Main.dust[dustIndex]; - dust.noGravity = true; - dust.noLight = true; - dust.velocity *= 0.3f; - if (Main.rand.NextBool(5)) - { - dust.fadeIn = 1f; - } - dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); - } - } + if (player.velocity.Y != 0 && player.wingFrame != 0) + { + if (Main.rand.NextBool(3)) + { + int dustOffsetX = -16 - player.direction * 30; + int dustOffsetY = -16; + int dustIndex = Dust.NewDust(new Vector2(player.Center.X + dustOffsetX, player.Center.Y + dustOffsetY), 40, 30, 135, 0f, 0f, 0, default(Color), 1.5f); + Dust dust = Main.dust[dustIndex]; + dust.noGravity = true; + dust.noLight = true; + dust.velocity *= 0.3f; + if (Main.rand.NextBool(5)) + { + dust.fadeIn = 1f; + } + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + } + } - return true; - } + return true; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Bone, 25).AddIngredient(ItemID.SoulofFlight, 10).AddIngredient(ModContent.ItemType(), 10).AddIngredient(ModContent.ItemType(), 2).AddTile(TileID.MythrilAnvil).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Bone, 25).AddIngredient(ItemID.SoulofFlight, 10).AddIngredient(ModContent.ItemType(), 10).AddIngredient(ModContent.ItemType(), 2).AddTile(TileID.MythrilAnvil).Register(); + } + } } diff --git a/Items/Accessories/Useful/MassiveBundleOfBalloons.cs b/Items/Accessories/Useful/MassiveBundleOfBalloons.cs index 16697dde..92f732bd 100644 --- a/Items/Accessories/Useful/MassiveBundleOfBalloons.cs +++ b/Items/Accessories/Useful/MassiveBundleOfBalloons.cs @@ -4,41 +4,41 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [AutoloadEquip(EquipType.Balloon)] - public class MassiveBundleOfBalloons : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Massive Bundle of Balloons"); - Tooltip.SetDefault("Allows you to jump six more times" - + "\nNegates fall damage and increases jump height" - + "\nReleases bees when damaged"); - } + [AutoloadEquip(EquipType.Balloon)] + public class MassiveBundleOfBalloons : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Massive Bundle of Balloons"); + Tooltip.SetDefault("Allows you to jump six more times" + + "\nNegates fall damage and increases jump height" + + "\nReleases bees when damaged"); + } - public override void SafeSetDefaults() - { - Item.width = 46; - Item.height = 42; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 46; + Item.height = 42; + Item.value = 0; + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.noFallDmg = true; - player.jumpBoost = true; - player.hasJumpOption_Cloud = true; - player.hasJumpOption_Sandstorm = true; - player.hasJumpOption_Blizzard = true; - player.hasJumpOption_Fart = true; - player.hasJumpOption_Sail = true; - player.hasJumpOption_Unicorn = true; - player.honeyCombItem = Item; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.noFallDmg = true; + player.jumpBoost = true; + player.hasJumpOption_Cloud = true; + player.hasJumpOption_Sandstorm = true; + player.hasJumpOption_Blizzard = true; + player.hasJumpOption_Fart = true; + player.hasJumpOption_Sail = true; + player.hasJumpOption_Unicorn = true; + player.honeyCombItem = Item; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.LuckyHorseshoe, 1).AddIngredient(ItemID.BundleofBalloons, 1).AddIngredient(ItemID.HoneyBalloon, 1).AddIngredient(ItemID.FartInABalloon, 1).AddIngredient(ItemID.SharkronBalloon, 1).AddIngredient().AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.LuckyHorseshoe, 1).AddIngredient(ItemID.BundleofBalloons, 1).AddIngredient(ItemID.HoneyBalloon, 1).AddIngredient(ItemID.FartInABalloon, 1).AddIngredient(ItemID.SharkronBalloon, 1).AddIngredient().AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Useful/SigilItemBase.cs b/Items/Accessories/Useful/SigilItemBase.cs index 264e97e7..b90cb55d 100644 --- a/Items/Accessories/Useful/SigilItemBase.cs +++ b/Items/Accessories/Useful/SigilItemBase.cs @@ -4,41 +4,41 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - //TODO extend functionality regarding cooldown tooltips - [Content(ContentType.Bosses)] - public abstract class SigilItemBase : AccessoryBase - { - public sealed override void SetStaticDefaults() - { - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 6)); - ItemID.Sets.AnimatesAsSoul[Item.type] = true; + //TODO extend functionality regarding cooldown tooltips + [Content(ContentType.Bosses)] + public abstract class SigilItemBase : AccessoryBase + { + public sealed override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 6)); + ItemID.Sets.AnimatesAsSoul[Item.type] = true; - ItemID.Sets.ItemNoGravity[Item.type] = true; + ItemID.Sets.ItemNoGravity[Item.type] = true; - SafeSetStaticDefaults(); - } + SafeSetStaticDefaults(); + } - public virtual void SafeSetStaticDefaults() - { + public virtual void SafeSetStaticDefaults() + { - } + } - public override void SafeSetDefaults() - { - Item.width = 26; - Item.height = 28; - Item.value = Item.sellPrice(0, 1, 0, 0); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 26; + Item.height = 28; + Item.value = Item.sellPrice(0, 1, 0, 0); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - //4 - if (4 * player.statLife < player.statLifeMax2) - { - player.GetModPlayer().tempSoulMinion = Item; - } - player.maxMinions++; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + //4 + if (4 * player.statLife < player.statLifeMax2) + { + player.GetModPlayer().tempSoulMinion = Item; + } + player.maxMinions++; + } + } } diff --git a/Items/Accessories/Useful/SigilOfEmergency.cs b/Items/Accessories/Useful/SigilOfEmergency.cs index e1c22edd..568cb04a 100644 --- a/Items/Accessories/Useful/SigilOfEmergency.cs +++ b/Items/Accessories/Useful/SigilOfEmergency.cs @@ -2,31 +2,31 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - public class SigilOfEmergency : SigilItemBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Sigil of Emergency"); - Tooltip.SetDefault("Summons a temporary minion to help you upon reaching critical health" + - "\nIncreases your max number of minions"); - } + public class SigilOfEmergency : SigilItemBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Sigil of Emergency"); + Tooltip.SetDefault("Summons a temporary minion to help you upon reaching critical health" + + "\nIncreases your max number of minions"); + } - public override void SafeSetDefaults() - { - Item.width = 26; - Item.height = 28; - Item.value = Item.sellPrice(0, 1, 0, 0); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 26; + Item.height = 28; + Item.value = Item.sellPrice(0, 1, 0, 0); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - //4 - if (4 * player.statLife < player.statLifeMax2) - { - player.GetModPlayer().tempSoulMinion = Item; - } - player.maxMinions++; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + //4 + if (4 * player.statLife < player.statLifeMax2) + { + player.GetModPlayer().tempSoulMinion = Item; + } + player.maxMinions++; + } + } } diff --git a/Items/Accessories/Useful/SigilOfLastStand.cs b/Items/Accessories/Useful/SigilOfLastStand.cs index ab159fc3..99d8980b 100644 --- a/Items/Accessories/Useful/SigilOfLastStand.cs +++ b/Items/Accessories/Useful/SigilOfLastStand.cs @@ -7,149 +7,149 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - public class SigilOfLastStand : SigilItemBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Sigil of Last Stand"); - Tooltip.SetDefault("Combines the effects of Sigil of Retreat and Sigil of Pain Suppression" - + "\nHas a cooldown of " + (AssPlayer.TeleportHomeTimerMax / 60) + " minutes"); - } - - public override void SafeSetDefaults() - { - Item.width = 30; - Item.height = 30; - Item.value = Item.sellPrice(0, 2, 0, 0); - Item.rare = -11; - } - - public override void ModifyTooltips(List tooltips) - { - //tooltip based off of the teleport ability - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - - bool inVanitySlot = false; - - for (int i = 0; i < tooltips.Count; i++) - { - if (tooltips[i].Name == "SocialDesc") - { - inVanitySlot = true; - tooltips[i].Text = "Cooldown will go down while in social slot"; - break; - } - } - - int insertIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); - if (insertIndex == -1) insertIndex = tooltips.Count; - - if (!inVanitySlot) - { - for (int i = 0; i < tooltips.Count; i++) - { - if (tooltips[i].Name == "Tooltip1") - { - insertIndex = i + 1; //it inserts "left" of where it found the index (without +1), so everything else get pushed one up - break; - } - } - } - - if (Main.LocalPlayer.ItemInInventoryOrEquipped(Item)) - { - if (mPlayer.canTeleportHome && mPlayer.canGetDefense) - { - tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready to use")); - } - - if (!mPlayer.canGetDefense) - { - //create animating "..." effect after the Ready line - string dots = ""; - int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90 - - for (int i = 0; i < dotCount; i++) - { - dots += "."; - } - - string timeName; - if (mPlayer.getDefenseTimer > 60) //more than 1 minute - { - if (mPlayer.getDefenseTimer > 90) //more than 1:30 minutes because of round - { - timeName = " minutes"; - } - else - { - timeName = " minute"; - } - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Ready2", "Pain supression: Ready again in " + Math.Round(mPlayer.getDefenseTimer / 60f) + timeName + dots)); - } - else - { - if (mPlayer.getDefenseTimer > 1) //more than 1 second - { - timeName = " seconds"; - } - else - { - timeName = " second"; - } - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Ready2", "Pain supression: Ready again in " + mPlayer.getDefenseTimer + timeName + dots)); - } - } - - if (!mPlayer.canTeleportHome) - { - //create animating "..." effect after the Ready line - string dots = ""; - int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90 - - for (int i = 0; i < dotCount; i++) - { - dots += "."; - } - - string timeName; - if (mPlayer.teleportHomeTimer > 60) //more than 1 minute - { - if (mPlayer.teleportHomeTimer > 90) //more than 1:30 minutes because of round - { - timeName = " minutes"; - } - else - { - timeName = " minute"; - } - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Ready1", "Retreat: Ready again in " + Math.Round(mPlayer.teleportHomeTimer / 60f) + timeName + dots)); - } - else - { - if (mPlayer.teleportHomeTimer > 1) //more than 1 second - { - timeName = " seconds"; - } - else - { - timeName = " second"; - } - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Ready1", "Retreat: Ready again in " + mPlayer.teleportHomeTimer + timeName + dots)); - } - } - } - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().getDefense = true; - player.GetModPlayer().teleportHome = true; - } - - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddTile(TileID.MythrilAnvil).Register(); - } - } + public class SigilOfLastStand : SigilItemBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Sigil of Last Stand"); + Tooltip.SetDefault("Combines the effects of Sigil of Retreat and Sigil of Pain Suppression" + + "\nHas a cooldown of " + (AssPlayer.TeleportHomeTimerMax / 60) + " minutes"); + } + + public override void SafeSetDefaults() + { + Item.width = 30; + Item.height = 30; + Item.value = Item.sellPrice(0, 2, 0, 0); + Item.rare = -11; + } + + public override void ModifyTooltips(List tooltips) + { + //tooltip based off of the teleport ability + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + + bool inVanitySlot = false; + + for (int i = 0; i < tooltips.Count; i++) + { + if (tooltips[i].Name == "SocialDesc") + { + inVanitySlot = true; + tooltips[i].Text = "Cooldown will go down while in social slot"; + break; + } + } + + int insertIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); + if (insertIndex == -1) insertIndex = tooltips.Count; + + if (!inVanitySlot) + { + for (int i = 0; i < tooltips.Count; i++) + { + if (tooltips[i].Name == "Tooltip1") + { + insertIndex = i + 1; //it inserts "left" of where it found the index (without +1), so everything else get pushed one up + break; + } + } + } + + if (Main.LocalPlayer.ItemInInventoryOrEquipped(Item)) + { + if (mPlayer.canTeleportHome && mPlayer.canGetDefense) + { + tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready to use")); + } + + if (!mPlayer.canGetDefense) + { + //create animating "..." effect after the Ready line + string dots = ""; + int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90 + + for (int i = 0; i < dotCount; i++) + { + dots += "."; + } + + string timeName; + if (mPlayer.getDefenseTimer > 60) //more than 1 minute + { + if (mPlayer.getDefenseTimer > 90) //more than 1:30 minutes because of round + { + timeName = " minutes"; + } + else + { + timeName = " minute"; + } + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Ready2", "Pain supression: Ready again in " + Math.Round(mPlayer.getDefenseTimer / 60f) + timeName + dots)); + } + else + { + if (mPlayer.getDefenseTimer > 1) //more than 1 second + { + timeName = " seconds"; + } + else + { + timeName = " second"; + } + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Ready2", "Pain supression: Ready again in " + mPlayer.getDefenseTimer + timeName + dots)); + } + } + + if (!mPlayer.canTeleportHome) + { + //create animating "..." effect after the Ready line + string dots = ""; + int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90 + + for (int i = 0; i < dotCount; i++) + { + dots += "."; + } + + string timeName; + if (mPlayer.teleportHomeTimer > 60) //more than 1 minute + { + if (mPlayer.teleportHomeTimer > 90) //more than 1:30 minutes because of round + { + timeName = " minutes"; + } + else + { + timeName = " minute"; + } + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Ready1", "Retreat: Ready again in " + Math.Round(mPlayer.teleportHomeTimer / 60f) + timeName + dots)); + } + else + { + if (mPlayer.teleportHomeTimer > 1) //more than 1 second + { + timeName = " seconds"; + } + else + { + timeName = " second"; + } + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Ready1", "Retreat: Ready again in " + mPlayer.teleportHomeTimer + timeName + dots)); + } + } + } + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().getDefense = true; + player.GetModPlayer().teleportHome = true; + } + + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddTile(TileID.MythrilAnvil).Register(); + } + } } diff --git a/Items/Accessories/Useful/SigilOfPainSuppression.cs b/Items/Accessories/Useful/SigilOfPainSuppression.cs index 6db334fe..d9664b92 100644 --- a/Items/Accessories/Useful/SigilOfPainSuppression.cs +++ b/Items/Accessories/Useful/SigilOfPainSuppression.cs @@ -6,103 +6,103 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - public class SigilOfPainSuppression : SigilItemBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Sigil of Pain Suppression"); - Tooltip.SetDefault("Drastically increases your defense when you are at critically low health" - + "\nHas a cooldown of " + (AssPlayer.GetDefenseTimerMax / 60) + " minutes"); - } + public class SigilOfPainSuppression : SigilItemBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Sigil of Pain Suppression"); + Tooltip.SetDefault("Drastically increases your defense when you are at critically low health" + + "\nHas a cooldown of " + (AssPlayer.GetDefenseTimerMax / 60) + " minutes"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 26; - Item.value = Item.sellPrice(0, 1, 0, 0); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 26; + Item.value = Item.sellPrice(0, 1, 0, 0); + Item.rare = -11; + } - public override void ModifyTooltips(List tooltips) - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + public override void ModifyTooltips(List tooltips) + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - bool inVanitySlot = false; + bool inVanitySlot = false; - for (int i = 0; i < tooltips.Count; i++) - { - if (tooltips[i].Name == "SocialDesc") - { - inVanitySlot = true; - tooltips[i].Text = "Cooldown will go down while in social slot"; - break; - } - } + for (int i = 0; i < tooltips.Count; i++) + { + if (tooltips[i].Name == "SocialDesc") + { + inVanitySlot = true; + tooltips[i].Text = "Cooldown will go down while in social slot"; + break; + } + } - int insertIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); - if (insertIndex == -1) insertIndex = tooltips.Count; + int insertIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); + if (insertIndex == -1) insertIndex = tooltips.Count; - if (!inVanitySlot) - { - for (int i = 0; i < tooltips.Count; i++) - { - if (tooltips[i].Name == "Tooltip1") - { - insertIndex = i + 1; //it inserts "left" of where it found the index (without +1), so everything else get pushed one up - break; - } - } - } + if (!inVanitySlot) + { + for (int i = 0; i < tooltips.Count; i++) + { + if (tooltips[i].Name == "Tooltip1") + { + insertIndex = i + 1; //it inserts "left" of where it found the index (without +1), so everything else get pushed one up + break; + } + } + } - if (Main.LocalPlayer.ItemInInventoryOrEquipped(Item)) - { - if (mPlayer.canGetDefense) - { - tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready to use")); - } - else - { - //create animating "..." effect after the Ready line - string dots = ""; - int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90 + if (Main.LocalPlayer.ItemInInventoryOrEquipped(Item)) + { + if (mPlayer.canGetDefense) + { + tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready to use")); + } + else + { + //create animating "..." effect after the Ready line + string dots = ""; + int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90 - for (int i = 0; i < dotCount; i++) - { - dots += "."; - } + for (int i = 0; i < dotCount; i++) + { + dots += "."; + } - string timeName; - if (mPlayer.getDefenseTimer > 60) //more than 1 minute - { - if (mPlayer.getDefenseTimer > 90) //more than 1:30 minutes because of round - { - timeName = " minutes"; - } - else - { - timeName = " minute"; - } - tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready again in " + Math.Round(mPlayer.getDefenseTimer / 60f) + timeName + dots)); - } - else - { - if (mPlayer.getDefenseTimer > 1) //more than 1 second - { - timeName = " seconds"; - } - else - { - timeName = " second"; - } - tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready again in " + mPlayer.getDefenseTimer + timeName + dots)); - } - } - } - } + string timeName; + if (mPlayer.getDefenseTimer > 60) //more than 1 minute + { + if (mPlayer.getDefenseTimer > 90) //more than 1:30 minutes because of round + { + timeName = " minutes"; + } + else + { + timeName = " minute"; + } + tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready again in " + Math.Round(mPlayer.getDefenseTimer / 60f) + timeName + dots)); + } + else + { + if (mPlayer.getDefenseTimer > 1) //more than 1 second + { + timeName = " seconds"; + } + else + { + timeName = " second"; + } + tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready again in " + mPlayer.getDefenseTimer + timeName + dots)); + } + } + } + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().getDefense = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().getDefense = true; + } + } } diff --git a/Items/Accessories/Useful/SigilOfRetreat.cs b/Items/Accessories/Useful/SigilOfRetreat.cs index 04fd0feb..6f8a09d3 100644 --- a/Items/Accessories/Useful/SigilOfRetreat.cs +++ b/Items/Accessories/Useful/SigilOfRetreat.cs @@ -6,103 +6,103 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - public class SigilOfRetreat : SigilItemBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Sigil of Retreat"); - Tooltip.SetDefault("Teleports you home when health is dangerously low" - + "\nHas a cooldown of " + (AssPlayer.TeleportHomeTimerMax / 60) + " minutes"); - } + public class SigilOfRetreat : SigilItemBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Sigil of Retreat"); + Tooltip.SetDefault("Teleports you home when health is dangerously low" + + "\nHas a cooldown of " + (AssPlayer.TeleportHomeTimerMax / 60) + " minutes"); + } - public override void SafeSetDefaults() - { - Item.width = 26; - Item.height = 24; - Item.value = Item.sellPrice(0, 1, 0, 0); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 26; + Item.height = 24; + Item.value = Item.sellPrice(0, 1, 0, 0); + Item.rare = -11; + } - public override void ModifyTooltips(List tooltips) - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + public override void ModifyTooltips(List tooltips) + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - bool inVanitySlot = false; + bool inVanitySlot = false; - for (int i = 0; i < tooltips.Count; i++) - { - if (tooltips[i].Name == "SocialDesc") - { - inVanitySlot = true; - tooltips[i].Text = "Cooldown will go down while in social slot"; - break; - } - } + for (int i = 0; i < tooltips.Count; i++) + { + if (tooltips[i].Name == "SocialDesc") + { + inVanitySlot = true; + tooltips[i].Text = "Cooldown will go down while in social slot"; + break; + } + } - int insertIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); - if (insertIndex == -1) insertIndex = tooltips.Count; + int insertIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); + if (insertIndex == -1) insertIndex = tooltips.Count; - if (!inVanitySlot) - { - for (int i = 0; i < tooltips.Count; i++) - { - if (tooltips[i].Name == "Tooltip1") - { - insertIndex = i + 1; //it inserts "left" of where it found the index (without +1), so everything else get pushed one up - break; - } - } - } + if (!inVanitySlot) + { + for (int i = 0; i < tooltips.Count; i++) + { + if (tooltips[i].Name == "Tooltip1") + { + insertIndex = i + 1; //it inserts "left" of where it found the index (without +1), so everything else get pushed one up + break; + } + } + } - if (Main.LocalPlayer.ItemInInventoryOrEquipped(Item)) - { - if (mPlayer.canTeleportHome) - { - tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready to use")); - } - else - { - //create animating "..." effect after the Ready line - string dots = ""; - int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90 + if (Main.LocalPlayer.ItemInInventoryOrEquipped(Item)) + { + if (mPlayer.canTeleportHome) + { + tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready to use")); + } + else + { + //create animating "..." effect after the Ready line + string dots = ""; + int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90 - for (int i = 0; i < dotCount; i++) - { - dots += "."; - } + for (int i = 0; i < dotCount; i++) + { + dots += "."; + } - string timeName; - if (mPlayer.teleportHomeTimer > 60) //more than 1 minute - { - if (mPlayer.teleportHomeTimer > 90) //more than 1:30 minutes because of round - { - timeName = " minutes"; - } - else - { - timeName = " minute"; - } - tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready again in " + Math.Round(mPlayer.teleportHomeTimer / 60f) + timeName + dots)); - } - else - { - if (mPlayer.teleportHomeTimer > 1) //more than 1 second - { - timeName = " seconds"; - } - else - { - timeName = " second"; - } - tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready again in " + mPlayer.teleportHomeTimer + timeName + dots)); - } - } - } - } + string timeName; + if (mPlayer.teleportHomeTimer > 60) //more than 1 minute + { + if (mPlayer.teleportHomeTimer > 90) //more than 1:30 minutes because of round + { + timeName = " minutes"; + } + else + { + timeName = " minute"; + } + tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready again in " + Math.Round(mPlayer.teleportHomeTimer / 60f) + timeName + dots)); + } + else + { + if (mPlayer.teleportHomeTimer > 1) //more than 1 second + { + timeName = " seconds"; + } + else + { + timeName = " second"; + } + tooltips.Insert(insertIndex, new TooltipLine(Mod, "Ready", "Ready again in " + mPlayer.teleportHomeTimer + timeName + dots)); + } + } + } + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().teleportHome = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().teleportHome = true; + } + } } diff --git a/Items/Accessories/Useful/SlipperySoles.cs b/Items/Accessories/Useful/SlipperySoles.cs index ff24e68d..8836173b 100644 --- a/Items/Accessories/Useful/SlipperySoles.cs +++ b/Items/Accessories/Useful/SlipperySoles.cs @@ -4,28 +4,28 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [AutoloadEquip(EquipType.Shoes)] - public class SlipperySoles : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slippery Soles"); - Tooltip.SetDefault("You slip and slide on all blocks"); - } - public override void SafeSetDefaults() - { - Item.width = 20; - Item.height = 28; - Item.value = 0; - Item.rare = -11; - } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.slippy2 = true; - } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.FrozenSlimeBlock, 2).AddIngredient(ItemID.Leather, 2).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + [AutoloadEquip(EquipType.Shoes)] + public class SlipperySoles : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slippery Soles"); + Tooltip.SetDefault("You slip and slide on all blocks"); + } + public override void SafeSetDefaults() + { + Item.width = 20; + Item.height = 28; + Item.value = 0; + Item.rare = -11; + } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.slippy2 = true; + } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.FrozenSlimeBlock, 2).AddIngredient(ItemID.Leather, 2).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } \ No newline at end of file diff --git a/Items/Accessories/Useful/SolesOfFireAndIce.cs b/Items/Accessories/Useful/SolesOfFireAndIce.cs index 2b8e467d..a2f0b0d0 100644 --- a/Items/Accessories/Useful/SolesOfFireAndIce.cs +++ b/Items/Accessories/Useful/SolesOfFireAndIce.cs @@ -4,33 +4,33 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [AutoloadEquip(EquipType.Shoes)] - public class SolesOfFireAndIce : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Soles of Fire and Ice"); - Tooltip.SetDefault("Allows you to walk on water, lava, and thin ice"); - } + [AutoloadEquip(EquipType.Shoes)] + public class SolesOfFireAndIce : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soles of Fire and Ice"); + Tooltip.SetDefault("Allows you to walk on water, lava, and thin ice"); + } - public override void SafeSetDefaults() - { - Item.width = 20; - Item.height = 28; - Item.value = Item.sellPrice(gold: 10); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 20; + Item.height = 28; + Item.value = Item.sellPrice(gold: 10); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.fireWalk = true; - player.waterWalk = true; - player.iceSkate = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.fireWalk = true; + player.waterWalk = true; + player.iceSkate = true; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.LavaWaders, 1).AddIngredient(ItemID.IceSkates, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.LavaWaders, 1).AddIngredient(ItemID.IceSkates, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Useful/StarInABalloon.cs b/Items/Accessories/Useful/StarInABalloon.cs index c642e317..0580a67f 100644 --- a/Items/Accessories/Useful/StarInABalloon.cs +++ b/Items/Accessories/Useful/StarInABalloon.cs @@ -4,37 +4,37 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [AutoloadEquip(EquipType.Balloon)] - public class StarInABalloon : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star in a Balloon"); - Tooltip.SetDefault("Increased mana regeneration and jump height"); - } + [AutoloadEquip(EquipType.Balloon)] + public class StarInABalloon : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Star in a Balloon"); + Tooltip.SetDefault("Increased mana regeneration and jump height"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = Item.sellPrice(silver: 5); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = Item.sellPrice(silver: 5); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - //player.manaRegenDelayBonus++; - //player.manaRegenBonus += 25; - if (!player.HasBuff(BuffID.StarInBottle)) - { - player.manaRegenBonus += 2; - } - player.jumpBoost = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + //player.manaRegenDelayBonus++; + //player.manaRegenBonus += 25; + if (!player.HasBuff(BuffID.StarInBottle)) + { + player.manaRegenBonus += 2; + } + player.jumpBoost = true; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.StarinaBottle, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.StarinaBottle, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Useful/StarWispBalloon.cs b/Items/Accessories/Useful/StarWispBalloon.cs index 6ae554ff..9b373e72 100644 --- a/Items/Accessories/Useful/StarWispBalloon.cs +++ b/Items/Accessories/Useful/StarWispBalloon.cs @@ -4,39 +4,39 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [AutoloadEquip(EquipType.Balloon)] - public class StarWispBalloon : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star Wisp Balloon"); - Tooltip.SetDefault("Increased mana regeneration and jump height" + - "\nGlows in the dark"); - } + [AutoloadEquip(EquipType.Balloon)] + public class StarWispBalloon : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Star Wisp Balloon"); + Tooltip.SetDefault("Increased mana regeneration and jump height" + + "\nGlows in the dark"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - //player.manaRegenDelayBonus++; - //player.manaRegenBonus += 25; - if (!player.HasBuff(BuffID.StarInBottle)) - { - player.manaRegenBonus += 2; - } - player.jumpBoost = true; - Lighting.AddLight(player.Center, 0.7f, 1.3f, 1.6f); - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + //player.manaRegenDelayBonus++; + //player.manaRegenBonus += 25; + if (!player.HasBuff(BuffID.StarInBottle)) + { + player.manaRegenBonus += 2; + } + player.jumpBoost = true; + Lighting.AddLight(player.Center, 0.7f, 1.3f, 1.6f); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient().AddIngredient().AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient().AddIngredient().AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Useful/WispInABalloon.cs b/Items/Accessories/Useful/WispInABalloon.cs index bd7a1dcc..30db95ef 100644 --- a/Items/Accessories/Useful/WispInABalloon.cs +++ b/Items/Accessories/Useful/WispInABalloon.cs @@ -4,32 +4,32 @@ namespace AssortedCrazyThings.Items.Accessories.Useful { - [AutoloadEquip(EquipType.Balloon)] - public class WispInABalloon : AccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wisp in a Balloon"); - Tooltip.SetDefault("Glows in the dark and increases jump height"); - } + [AutoloadEquip(EquipType.Balloon)] + public class WispInABalloon : AccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wisp in a Balloon"); + Tooltip.SetDefault("Glows in the dark and increases jump height"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = Item.sellPrice(gold: 5); - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = Item.sellPrice(gold: 5); + Item.rare = -11; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.jumpBoost = true; - Lighting.AddLight(player.Center, 0.7f, 1.3f, 1.6f); - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.jumpBoost = true; + Lighting.AddLight(player.Center, 0.7f, 1.3f, 1.6f); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.WispinaBottle, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.WispinaBottle, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/Cobballoon.cs b/Items/Accessories/Vanity/Cobballoon.cs index 033343a1..08b05634 100644 --- a/Items/Accessories/Vanity/Cobballoon.cs +++ b/Items/Accessories/Vanity/Cobballoon.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class Cobballoon : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cobballoon"); - Tooltip.SetDefault("'A clump of stones that manages to float, much to your confusion'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class Cobballoon : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cobballoon"); + Tooltip.SetDefault("'A clump of stones that manages to float, much to your confusion'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.StoneBlock, 25).AddIngredient(ItemID.WhiteString, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.StoneBlock, 25).AddIngredient(ItemID.WhiteString, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/EyelloonRetinazer.cs b/Items/Accessories/Vanity/EyelloonRetinazer.cs index 8819f2fe..853df3a2 100644 --- a/Items/Accessories/Vanity/EyelloonRetinazer.cs +++ b/Items/Accessories/Vanity/EyelloonRetinazer.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class EyelloonRetinazer : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Retinazer Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class EyelloonRetinazer : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Retinazer Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.SoulofSight, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.SoulofSight, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/GreenEyelloon.cs b/Items/Accessories/Vanity/GreenEyelloon.cs index 473e4027..69906ff0 100644 --- a/Items/Accessories/Vanity/GreenEyelloon.cs +++ b/Items/Accessories/Vanity/GreenEyelloon.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class GreenEyelloon : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Green Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class GreenEyelloon : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Green Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/GreenEyelloonFractured.cs b/Items/Accessories/Vanity/GreenEyelloonFractured.cs index f6e1bf65..6daef01b 100644 --- a/Items/Accessories/Vanity/GreenEyelloonFractured.cs +++ b/Items/Accessories/Vanity/GreenEyelloonFractured.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class GreenEyelloonFractured : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Green Toothy Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class GreenEyelloonFractured : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Green Toothy Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/GreenEyelloonMetal.cs b/Items/Accessories/Vanity/GreenEyelloonMetal.cs index 467f4482..6f671ad3 100644 --- a/Items/Accessories/Vanity/GreenEyelloonMetal.cs +++ b/Items/Accessories/Vanity/GreenEyelloonMetal.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class GreenEyelloonMetal : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Green Metal Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class GreenEyelloonMetal : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Green Metal Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/GreenEyelloonMetalFractured.cs b/Items/Accessories/Vanity/GreenEyelloonMetalFractured.cs index dde4b48a..232e39db 100644 --- a/Items/Accessories/Vanity/GreenEyelloonMetalFractured.cs +++ b/Items/Accessories/Vanity/GreenEyelloonMetalFractured.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class GreenEyelloonMetalFractured : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Green Metal Toothy Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class GreenEyelloonMetalFractured : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Green Metal Toothy Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/PurpleEyelloon.cs b/Items/Accessories/Vanity/PurpleEyelloon.cs index 6fd3166f..7893395f 100644 --- a/Items/Accessories/Vanity/PurpleEyelloon.cs +++ b/Items/Accessories/Vanity/PurpleEyelloon.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class PurpleEyelloon : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Purple Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class PurpleEyelloon : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Purple Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/PurpleEyelloonFractured.cs b/Items/Accessories/Vanity/PurpleEyelloonFractured.cs index 3a115f1c..fb30f4f0 100644 --- a/Items/Accessories/Vanity/PurpleEyelloonFractured.cs +++ b/Items/Accessories/Vanity/PurpleEyelloonFractured.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class PurpleEyelloonFractured : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Purple Toothy Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class PurpleEyelloonFractured : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Purple Toothy Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/PurpleEyelloonMetal.cs b/Items/Accessories/Vanity/PurpleEyelloonMetal.cs index 1ee3f123..64d50f38 100644 --- a/Items/Accessories/Vanity/PurpleEyelloonMetal.cs +++ b/Items/Accessories/Vanity/PurpleEyelloonMetal.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class PurpleEyelloonMetal : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Purple Metal Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class PurpleEyelloonMetal : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Purple Metal Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/PurpleEyelloonMetalFractured.cs b/Items/Accessories/Vanity/PurpleEyelloonMetalFractured.cs index f3b69274..0d13f50b 100644 --- a/Items/Accessories/Vanity/PurpleEyelloonMetalFractured.cs +++ b/Items/Accessories/Vanity/PurpleEyelloonMetalFractured.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class PurpleEyelloonMetalFractured : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Purple Metal Toothy Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class PurpleEyelloonMetalFractured : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Purple Metal Toothy Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/RedEyelloon.cs b/Items/Accessories/Vanity/RedEyelloon.cs index a780a6f3..4459cc01 100644 --- a/Items/Accessories/Vanity/RedEyelloon.cs +++ b/Items/Accessories/Vanity/RedEyelloon.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class RedEyelloon : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Red Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class RedEyelloon : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Red Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/RedEyelloonFractured.cs b/Items/Accessories/Vanity/RedEyelloonFractured.cs index 814a0094..deed5752 100644 --- a/Items/Accessories/Vanity/RedEyelloonFractured.cs +++ b/Items/Accessories/Vanity/RedEyelloonFractured.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class RedEyelloonFractured : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Red Toothy Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class RedEyelloonFractured : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Red Toothy Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/RedEyelloonMetal.cs b/Items/Accessories/Vanity/RedEyelloonMetal.cs index e0302873..36de931f 100644 --- a/Items/Accessories/Vanity/RedEyelloonMetal.cs +++ b/Items/Accessories/Vanity/RedEyelloonMetal.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class RedEyelloonMetal : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Red Metal Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class RedEyelloonMetal : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Red Metal Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/RedEyelloonMetalFractured.cs b/Items/Accessories/Vanity/RedEyelloonMetalFractured.cs index b215745e..2ca46923 100644 --- a/Items/Accessories/Vanity/RedEyelloonMetalFractured.cs +++ b/Items/Accessories/Vanity/RedEyelloonMetalFractured.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class RedEyelloonMetalFractured : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Red Metal Toothy Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class RedEyelloonMetalFractured : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Red Metal Toothy Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/Vanity/SpazmatismEyelloon.cs b/Items/Accessories/Vanity/SpazmatismEyelloon.cs index 28353c7b..68a3785a 100644 --- a/Items/Accessories/Vanity/SpazmatismEyelloon.cs +++ b/Items/Accessories/Vanity/SpazmatismEyelloon.cs @@ -3,26 +3,26 @@ namespace AssortedCrazyThings.Items.Accessories.Vanity { - [AutoloadEquip(EquipType.Balloon)] - public class SpazmatismEyelloon : VanityAccessoryBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Spazmatism Eye-lloon"); - Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); - } + [AutoloadEquip(EquipType.Balloon)] + public class SpazmatismEyelloon : VanityAccessoryBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spazmatism Eye-lloon"); + Tooltip.SetDefault("'A Demon Eye balloon, for your Demon Eye needs!'"); + } - public override void SafeSetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.value = 0; - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.width = 18; + Item.height = 32; + Item.value = 0; + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.SoulofSight, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Lens, 1).AddIngredient(ItemID.SoulofSight, 1).AddIngredient(ItemID.ShinyRedBalloon, 1).AddTile(TileID.TinkerersWorkbench).Register(); + } + } } diff --git a/Items/Accessories/VanityAccessoryBase.cs b/Items/Accessories/VanityAccessoryBase.cs index 5d20a34f..8ae36f09 100644 --- a/Items/Accessories/VanityAccessoryBase.cs +++ b/Items/Accessories/VanityAccessoryBase.cs @@ -1,8 +1,8 @@ namespace AssortedCrazyThings.Items.Accessories { - [Content(ContentType.VanityAccessories)] - public abstract class VanityAccessoryBase : AccessoryBase - { + [Content(ContentType.VanityAccessories)] + public abstract class VanityAccessoryBase : AccessoryBase + { - } + } } diff --git a/Items/Armor/SoulSaviorHeaddress.cs b/Items/Armor/SoulSaviorHeaddress.cs index 2c4095c7..758040f0 100644 --- a/Items/Armor/SoulSaviorHeaddress.cs +++ b/Items/Armor/SoulSaviorHeaddress.cs @@ -5,51 +5,51 @@ namespace AssortedCrazyThings.Items.Armor { - [Content(ContentType.Bosses)] - [AutoloadEquip(EquipType.Head)] - public class SoulSaviorHeaddress : AssItem - { - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); - DisplayName.SetDefault("Soul Savior Headdress"); - Tooltip.SetDefault("Increases minion damage by 10%" - + "\nIncreases your max number of minions"); - } + [Content(ContentType.Bosses)] + [AutoloadEquip(EquipType.Head)] + public class SoulSaviorHeaddress : AssItem + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + DisplayName.SetDefault("Soul Savior Headdress"); + Tooltip.SetDefault("Increases minion damage by 10%" + + "\nIncreases your max number of minions"); + } - public override void SetDefaults() - { - Item.width = 32; - Item.height = 28; - Item.value = Item.sellPrice(gold: 2, silver: 80); - Item.rare = -11; - Item.defense = 14; - } + public override void SetDefaults() + { + Item.width = 32; + Item.height = 28; + Item.value = Item.sellPrice(gold: 2, silver: 80); + Item.rare = -11; + Item.defense = 14; + } - public override void UpdateEquip(Player player) - { - player.maxMinions++; - player.GetDamage(DamageClass.Summon) += 0.1f; - } + public override void UpdateEquip(Player player) + { + player.maxMinions++; + player.GetDamage(DamageClass.Summon) += 0.1f; + } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) + { + return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + } - public override void UpdateArmorSet(Player player) - { - Lighting.AddLight(player.Center, new Vector3(0.05f, 0.05f, 0.15f)); + public override void UpdateArmorSet(Player player) + { + Lighting.AddLight(player.Center, new Vector3(0.05f, 0.05f, 0.15f)); - AssPlayer mPlayer = player.GetModPlayer(); - mPlayer.soulSaviorArmor = true; + AssPlayer mPlayer = player.GetModPlayer(); + mPlayer.soulSaviorArmor = true; - StatModifier summoner = player.GetDamage(DamageClass.Summon); - float factor = summoner.ApplyTo(player.maxMinions / 10f); + StatModifier summoner = player.GetDamage(DamageClass.Summon); + float factor = summoner.ApplyTo(player.maxMinions / 10f); - player.thorns = factor; + player.thorns = factor; - /* + /* * HOW IT WORKS: thorns = 1f means that 100% of the damage an NPC does is reflected (absolute) (ONLY CONTACT DAMAGE) * aka if a zombie with 14 damage attacks you in your armor, you receive 1 damage (since you have 44 defense) but the * zombie receives 14 damage back @@ -64,15 +64,15 @@ public override void UpdateArmorSet(Player player) * and harvester wings) */ - player.setBonus = "Reflects 10% contact damage per available minion slot" - + "\nReflected damage further increased by effects that increase minion damage" - + "\nCurrent reflected damage: " + (int)(factor * 100) + "%" - + "\nMinions summoned by the Everhallowed Lantern become 'empowered' and gain 30% more damage"; - } + player.setBonus = "Reflects 10% contact damage per available minion slot" + + "\nReflected damage further increased by effects that increase minion damage" + + "\nCurrent reflected damage: " + (int)(factor * 100) + "%" + + "\nMinions summoned by the Everhallowed Lantern become 'empowered' and gain 30% more damage"; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.Ectoplasm, 3).AddIngredient(ModContent.ItemType(), 16).AddTile(TileID.MythrilAnvil).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.Ectoplasm, 3).AddIngredient(ModContent.ItemType(), 16).AddTile(TileID.MythrilAnvil).Register(); + } + } } diff --git a/Items/Armor/SoulSaviorPlate.cs b/Items/Armor/SoulSaviorPlate.cs index dfec0312..9d19c735 100644 --- a/Items/Armor/SoulSaviorPlate.cs +++ b/Items/Armor/SoulSaviorPlate.cs @@ -4,36 +4,36 @@ namespace AssortedCrazyThings.Items.Armor { - [Content(ContentType.Bosses)] - [AutoloadEquip(EquipType.Body)] - public class SoulSaviorPlate : AssItem - { - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); - DisplayName.SetDefault("Soul Savior Breastplate"); - Tooltip.SetDefault("Increases minion damage by 10%" - + "\nIncreases your max number of minions by 2"); - } + [Content(ContentType.Bosses)] + [AutoloadEquip(EquipType.Body)] + public class SoulSaviorPlate : AssItem + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + DisplayName.SetDefault("Soul Savior Breastplate"); + Tooltip.SetDefault("Increases minion damage by 10%" + + "\nIncreases your max number of minions by 2"); + } - public override void SetDefaults() - { - Item.width = 28; - Item.height = 22; - Item.value = Item.sellPrice(gold: 3, silver: 70); - Item.rare = -11; - Item.defense = 18; - } + public override void SetDefaults() + { + Item.width = 28; + Item.height = 22; + Item.value = Item.sellPrice(gold: 3, silver: 70); + Item.rare = -11; + Item.defense = 18; + } - public override void UpdateEquip(Player player) - { - player.maxMinions += 2; - player.GetDamage(DamageClass.Summon) += 0.1f; - } + public override void UpdateEquip(Player player) + { + player.maxMinions += 2; + player.GetDamage(DamageClass.Summon) += 0.1f; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.Ectoplasm, 4).AddIngredient(ModContent.ItemType(), 24).AddTile(TileID.MythrilAnvil).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.Ectoplasm, 4).AddIngredient(ModContent.ItemType(), 24).AddTile(TileID.MythrilAnvil).Register(); + } + } } diff --git a/Items/Armor/SoulSaviorPlatePlayer.cs b/Items/Armor/SoulSaviorPlatePlayer.cs index fff53f24..85a7052f 100644 --- a/Items/Armor/SoulSaviorPlatePlayer.cs +++ b/Items/Armor/SoulSaviorPlatePlayer.cs @@ -4,16 +4,16 @@ namespace AssortedCrazyThings.Items.Armor { - [Content(ContentType.Bosses)] - public class SoulSaviorPlatePlayer : AssPlayerBase - { - public override void ModifyDrawInfo(ref PlayerDrawSet drawInfo) - { - int bodyType = Mod.GetEquipSlot(nameof(SoulSaviorPlate), EquipType.Body); - if (drawInfo.drawPlayer.body == bodyType) - { - drawInfo.bodyGlowColor = Color.White; - } - } - } + [Content(ContentType.Bosses)] + public class SoulSaviorPlatePlayer : AssPlayerBase + { + public override void ModifyDrawInfo(ref PlayerDrawSet drawInfo) + { + int bodyType = Mod.GetEquipSlot(nameof(SoulSaviorPlate), EquipType.Body); + if (drawInfo.drawPlayer.body == bodyType) + { + drawInfo.bodyGlowColor = Color.White; + } + } + } } diff --git a/Items/Armor/SoulSaviorRobe.cs b/Items/Armor/SoulSaviorRobe.cs index 65fba0ce..3793890c 100644 --- a/Items/Armor/SoulSaviorRobe.cs +++ b/Items/Armor/SoulSaviorRobe.cs @@ -4,41 +4,41 @@ namespace AssortedCrazyThings.Items.Armor { - [Content(ContentType.Bosses)] - [AutoloadEquip(EquipType.Legs)] - public class SoulSaviorRobe : AssItem - { - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); - DisplayName.SetDefault("Soul Savior Robe"); - Tooltip.SetDefault("Increases minion damage by 10%" - + "\nIncreases your max number of minions"); - } + [Content(ContentType.Bosses)] + [AutoloadEquip(EquipType.Legs)] + public class SoulSaviorRobe : AssItem + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + DisplayName.SetDefault("Soul Savior Robe"); + Tooltip.SetDefault("Increases minion damage by 10%" + + "\nIncreases your max number of minions"); + } - public override void SetDefaults() - { - Item.width = 24; - Item.height = 14; - Item.value = Item.sellPrice(gold: 2, silver: 60); - Item.rare = -11; - Item.defense = 12; - } + public override void SetDefaults() + { + Item.width = 24; + Item.height = 14; + Item.value = Item.sellPrice(gold: 2, silver: 60); + Item.rare = -11; + Item.defense = 12; + } - public override void UpdateEquip(Player player) - { - player.maxMinions++; - player.GetDamage(DamageClass.Summon) += 0.1f; - } + public override void UpdateEquip(Player player) + { + player.maxMinions++; + player.GetDamage(DamageClass.Summon) += 0.1f; + } - public override void EquipFrameEffects(Player player, EquipType type) - { - player.shoe = 0; - } + public override void EquipFrameEffects(Player player, EquipType type) + { + player.shoe = 0; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.Ectoplasm, 3).AddIngredient(ModContent.ItemType(), 12).AddTile(TileID.MythrilAnvil).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.Ectoplasm, 3).AddIngredient(ModContent.ItemType(), 12).AddTile(TileID.MythrilAnvil).Register(); + } + } } diff --git a/Items/CaughtDungeonSoul.cs b/Items/CaughtDungeonSoul.cs index bef58e57..172b7df0 100644 --- a/Items/CaughtDungeonSoul.cs +++ b/Items/CaughtDungeonSoul.cs @@ -8,61 +8,61 @@ namespace AssortedCrazyThings.Items { - [Content(ContentType.Bosses)] - public class CaughtDungeonSoul : CaughtDungeonSoulBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Loose Dungeon Soul"); - Tooltip.SetDefault("'An inert soul caught by a net'" - + "\nAwakened in your inventory when " + Harvester.name + " is defeated"); - // ticksperframe, frameCount - //Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 4)); - //ItemID.Sets.AnimatesAsSoul[Item.type] = true; + [Content(ContentType.Bosses)] + public class CaughtDungeonSoul : CaughtDungeonSoulBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Loose Dungeon Soul"); + Tooltip.SetDefault("'An inert soul caught by a net'" + + "\nAwakened in your inventory when " + Harvester.name + " is defeated"); + // ticksperframe, frameCount + //Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 4)); + //ItemID.Sets.AnimatesAsSoul[Item.type] = true; - ItemID.Sets.ItemNoGravity[Item.type] = true; - } + ItemID.Sets.ItemNoGravity[Item.type] = true; + } - public override void SafeSetDefaults() - { - frame2CounterCount = 6; - animatedTextureSelect = 0; - Item.useStyle = ItemUseStyleID.Swing; - Item.autoReuse = true; - Item.useTurn = true; - Item.useAnimation = 15; - Item.useTime = 10; - Item.consumable = true; - Item.noUseGraphic = true; - Item.makeNPC = (short)ModContent.NPCType(); - } + public override void SafeSetDefaults() + { + frame2CounterCount = 6; + animatedTextureSelect = 0; + Item.useStyle = ItemUseStyleID.Swing; + Item.autoReuse = true; + Item.useTurn = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.consumable = true; + Item.noUseGraphic = true; + Item.makeNPC = (short)ModContent.NPCType(); + } - public static bool CanUseCondition() - { - return BabyHarvesterHandler.TryFindBabyHarvester(out _, out _); - } + public static bool CanUseCondition() + { + return BabyHarvesterHandler.TryFindBabyHarvester(out _, out _); + } - public override bool CanUseItem(Player player) - { - return CanUseCondition(); - } + public override bool CanUseItem(Player player) + { + return CanUseCondition(); + } - public override void ModifyTooltips(List tooltips) - { - if (CanUseCondition()) - { - // Can use item - tooltips.Add(new TooltipLine(Mod, "MakeNPC", "Use it to spawn a soul for the Soul Harvester to eat") - { - OverrideColor = new Color(35, 200, 254) - }); - } - else - { - // Can not use item - TooltipLine consumable = tooltips.Find(line => line.Name == "Consumable"); - if (consumable != null) tooltips.Remove(consumable); - } - } - } + public override void ModifyTooltips(List tooltips) + { + if (CanUseCondition()) + { + // Can use item + tooltips.Add(new TooltipLine(Mod, "MakeNPC", "Use it to spawn a soul for the Soul Harvester to eat") + { + OverrideColor = new Color(35, 200, 254) + }); + } + else + { + // Can not use item + TooltipLine consumable = tooltips.Find(line => line.Name == "Consumable"); + if (consumable != null) tooltips.Remove(consumable); + } + } + } } diff --git a/Items/CaughtDungeonSoulBase.cs b/Items/CaughtDungeonSoulBase.cs index acf33c84..845eab0f 100644 --- a/Items/CaughtDungeonSoulBase.cs +++ b/Items/CaughtDungeonSoulBase.cs @@ -3,104 +3,103 @@ using ReLogic.Content; using System; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items { - [Content(ContentType.Bosses)] - public abstract class CaughtDungeonSoulBase : AssItem - { - protected int animatedTextureSelect; - private int sincounter; - float sinY = -10f; - protected int frame2CounterCount; - private int frame2Counter; - private int frame2; - - //public override bool CloneNewInstances - //{ - // get - // { - // return true; - // } - //} - - public sealed override void SetDefaults() - { - Item.width = 14; - Item.height = 24; - Item.maxStack = 999; - Item.value = Item.sellPrice(copper: 50); - Item.rare = -11; - Item.color = Color.White; - - SafeSetDefaults(); - } - - public virtual void SafeSetDefaults() - { - - } - - public override void PostUpdate() - { - Animate(); - sincounter = sincounter > 120 ? 0 : sincounter + 1; - sinY = (float)((Math.Sin((sincounter / 120f) * MathHelper.TwoPi) - 1) * 10); - - Lighting.AddLight(Item.Center, new Vector3(0.15f, 0.15f, 0.35f)); - } - - public void Animate() - { - if (frame2CounterCount <= 0) - { - return; - } - - frame2Counter++; - if (frame2Counter >= frame2CounterCount) - { - frame2++; - frame2Counter = 0; - if (frame2 >= AssortedCrazyThings.animatedSoulFrameCount) - { - frame2 = 0; - } - } - } - - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - if (frame2CounterCount <= 0) - { - return true; - } - - return false; - } - - //draw only in world, not in inventory - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - if (frame2CounterCount <= 0) - { - return; - } - - lightColor = Item.GetAlpha(lightColor) * 0.99f; //1f is opaque - lightColor.R = Math.Max(lightColor.R, (byte)200); //100 for dark - lightColor.G = Math.Max(lightColor.G, (byte)200); - lightColor.B = Math.Max(lightColor.B, (byte)200); - - SpriteEffects effects = SpriteEffects.None; - Asset asset = AssortedCrazyThings.animatedSoulTextures[animatedTextureSelect]; - Texture2D image = asset.Value; - Rectangle bounds = image.Frame(1, AssortedCrazyThings.animatedSoulFrameCount, frameY: frame2); - - Vector2 stupidOffset = new Vector2(Item.width / 2, Item.height - 10f + sinY); - - Main.spriteBatch.Draw(image, Item.position - Main.screenPosition + stupidOffset, bounds, lightColor, rotation, bounds.Size() / 2, scale, effects, 0f); - } - } + [Content(ContentType.Bosses)] + public abstract class CaughtDungeonSoulBase : AssItem + { + protected int animatedTextureSelect; + private int sincounter; + float sinY = -10f; + protected int frame2CounterCount; + private int frame2Counter; + private int frame2; + + //public override bool CloneNewInstances + //{ + // get + // { + // return true; + // } + //} + + public sealed override void SetDefaults() + { + Item.width = 14; + Item.height = 24; + Item.maxStack = 999; + Item.value = Item.sellPrice(copper: 50); + Item.rare = -11; + Item.color = Color.White; + + SafeSetDefaults(); + } + + public virtual void SafeSetDefaults() + { + + } + + public override void PostUpdate() + { + Animate(); + sincounter = sincounter > 120 ? 0 : sincounter + 1; + sinY = (float)((Math.Sin((sincounter / 120f) * MathHelper.TwoPi) - 1) * 10); + + Lighting.AddLight(Item.Center, new Vector3(0.15f, 0.15f, 0.35f)); + } + + public void Animate() + { + if (frame2CounterCount <= 0) + { + return; + } + + frame2Counter++; + if (frame2Counter >= frame2CounterCount) + { + frame2++; + frame2Counter = 0; + if (frame2 >= AssortedCrazyThings.animatedSoulFrameCount) + { + frame2 = 0; + } + } + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + if (frame2CounterCount <= 0) + { + return true; + } + + return false; + } + + //draw only in world, not in inventory + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + if (frame2CounterCount <= 0) + { + return; + } + + lightColor = Item.GetAlpha(lightColor) * 0.99f; //1f is opaque + lightColor.R = Math.Max(lightColor.R, (byte)200); //100 for dark + lightColor.G = Math.Max(lightColor.G, (byte)200); + lightColor.B = Math.Max(lightColor.B, (byte)200); + + SpriteEffects effects = SpriteEffects.None; + Asset asset = AssortedCrazyThings.animatedSoulTextures[animatedTextureSelect]; + Texture2D image = asset.Value; + Rectangle bounds = image.Frame(1, AssortedCrazyThings.animatedSoulFrameCount, frameY: frame2); + + Vector2 stupidOffset = new Vector2(Item.width / 2, Item.height - 10f + sinY); + + Main.spriteBatch.Draw(image, Item.position - Main.screenPosition + stupidOffset, bounds, lightColor, rotation, bounds.Size() / 2, scale, effects, 0f); + } + } } diff --git a/Items/CaughtDungeonSoulFreed.cs b/Items/CaughtDungeonSoulFreed.cs index 406705a1..d4d9adb7 100644 --- a/Items/CaughtDungeonSoulFreed.cs +++ b/Items/CaughtDungeonSoulFreed.cs @@ -1,34 +1,33 @@ using AssortedCrazyThings.NPCs.DungeonBird; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items { - //the one actually used in recipes - [Content(ContentType.Bosses)] - public class CaughtDungeonSoulFreed : CaughtDungeonSoulBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Freed Dungeon Soul"); - Tooltip.SetDefault("Awakened by defeating the " + Harvester.name); - ItemID.Sets.ItemIconPulse[Item.type] = true; - ItemID.Sets.ItemNoGravity[Item.type] = true; - } + //the one actually used in recipes + [Content(ContentType.Bosses)] + public class CaughtDungeonSoulFreed : CaughtDungeonSoulBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Freed Dungeon Soul"); + Tooltip.SetDefault("Awakened by defeating the " + Harvester.name); + ItemID.Sets.ItemIconPulse[Item.type] = true; + ItemID.Sets.ItemNoGravity[Item.type] = true; + } - public override void SafeSetDefaults() - { - frame2CounterCount = 4; - animatedTextureSelect = 1; - } + public override void SafeSetDefaults() + { + frame2CounterCount = 4; + animatedTextureSelect = 1; + } - //hardmode recipe - public override void AddRecipes() - { - Recipe recipe = CreateRecipe(1).AddIngredient(ItemID.BorealWoodCandle, 1).AddIngredient(this, 15).AddTile(TileID.CrystalBall); - recipe.ReplaceResult(ItemID.WaterCandle); - recipe.Register(); - } - } + //hardmode recipe + public override void AddRecipes() + { + Recipe recipe = CreateRecipe(1).AddIngredient(ItemID.BorealWoodCandle, 1).AddIngredient(this, 15).AddTile(TileID.CrystalBall); + recipe.ReplaceResult(ItemID.WaterCandle); + recipe.Register(); + } + } } diff --git a/Items/ChunkyandMeatball.cs b/Items/ChunkyandMeatball.cs index e0ebb41c..c82ce892 100644 --- a/Items/ChunkyandMeatball.cs +++ b/Items/ChunkyandMeatball.cs @@ -2,34 +2,34 @@ namespace AssortedCrazyThings.Items { - [Content(ContentType.HostileNPCs)] - public abstract class ChunkyandMeatballItem : AssItem - { - public override void SetDefaults() - { - Item.maxStack = 999; - Item.width = 22; - Item.height = 22; - Item.value = Item.sellPrice(silver: 2); - Item.rare = -11; - } - } + [Content(ContentType.HostileNPCs)] + public abstract class ChunkyandMeatballItem : AssItem + { + public override void SetDefaults() + { + Item.maxStack = 999; + Item.width = 22; + Item.height = 22; + Item.value = Item.sellPrice(silver: 2); + Item.rare = -11; + } + } - public class ChunkysEyeItem : ChunkyandMeatballItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Chunky's Eye"); - Tooltip.SetDefault("'Find Meatball's Eye and combine the two at a Demon Altar'"); - } - } + public class ChunkysEyeItem : ChunkyandMeatballItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Chunky's Eye"); + Tooltip.SetDefault("'Find Meatball's Eye and combine the two at a Demon Altar'"); + } + } - public class MeatballsEyeItem : ChunkyandMeatballItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Meatball's Eye"); - Tooltip.SetDefault("'Find Chunky's Eye and combine the two at a Demon Altar'"); - } - } + public class MeatballsEyeItem : ChunkyandMeatballItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Meatball's Eye"); + Tooltip.SetDefault("'Find Chunky's Eye and combine the two at a Demon Altar'"); + } + } } diff --git a/Items/Consumables/CuteSlimeSpawnEnableFlask.cs b/Items/Consumables/CuteSlimeSpawnEnableFlask.cs index 8c0bd2bb..d231a4c9 100644 --- a/Items/Consumables/CuteSlimeSpawnEnableFlask.cs +++ b/Items/Consumables/CuteSlimeSpawnEnableFlask.cs @@ -7,51 +7,51 @@ namespace AssortedCrazyThings.Items.Consumables { - [Content(ContentType.CuteSlimes)] - public class CuteSlimeSpawnEnableFlask : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Jellied Ale"); + [Content(ContentType.CuteSlimes)] + public class CuteSlimeSpawnEnableFlask : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Jellied Ale"); - ItemID.Sets.DrinkParticleColors[Item.type] = new Color[3] { - new Color(13, 106, 137), - new Color(10, 176, 230), - new Color(146, 229, 255) - }; - } + ItemID.Sets.DrinkParticleColors[Item.type] = new Color[3] { + new Color(13, 106, 137), + new Color(10, 176, 230), + new Color(146, 229, 255) + }; + } - public override void ModifyTooltips(List tooltips) - { - string tooltip = "You will see Cute Slimes more often for a short time"; - if (ContentConfig.Instance.CuteSlimesPotionOnly) - { - tooltip = "Allows you to see Cute Slimes for a short time"; - } - tooltips.Add(new TooltipLine(Mod, "Tooltip", tooltip)); - } + public override void ModifyTooltips(List tooltips) + { + string tooltip = "You will see Cute Slimes more often for a short time"; + if (ContentConfig.Instance.CuteSlimesPotionOnly) + { + tooltip = "Allows you to see Cute Slimes for a short time"; + } + tooltips.Add(new TooltipLine(Mod, "Tooltip", tooltip)); + } - public override void SetDefaults() - { - //item.CloneDefaults(ItemID.Silk); - Item.width = 20; - Item.height = 28; - Item.useStyle = ItemUseStyleID.DrinkLiquid; - Item.useAnimation = 17; - Item.useTime = 17; - Item.useTurn = true; - Item.UseSound = SoundID.Item3; - Item.maxStack = 30; - Item.consumable = true; - Item.buffTime = 5 * 60 * 60; - Item.buffType = ModContent.BuffType(); - Item.rare = -11; - Item.value = Item.sellPrice(copper: 20); - } + public override void SetDefaults() + { + //item.CloneDefaults(ItemID.Silk); + Item.width = 20; + Item.height = 28; + Item.useStyle = ItemUseStyleID.DrinkLiquid; + Item.useAnimation = 17; + Item.useTime = 17; + Item.useTurn = true; + Item.UseSound = SoundID.Item3; + Item.maxStack = 30; + Item.consumable = true; + Item.buffTime = 5 * 60 * 60; + Item.buffType = ModContent.BuffType(); + Item.rare = -11; + Item.value = Item.sellPrice(copper: 20); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Ale, 1).AddIngredient(ItemID.Gel, 1).AddTile(TileID.Kegs).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Ale, 1).AddIngredient(ItemID.Gel, 1).AddTile(TileID.Kegs).Register(); + } + } } diff --git a/Items/Consumables/EmpowermentFlask.cs b/Items/Consumables/EmpowermentFlask.cs index aa474b30..4172e069 100644 --- a/Items/Consumables/EmpowermentFlask.cs +++ b/Items/Consumables/EmpowermentFlask.cs @@ -6,43 +6,43 @@ namespace AssortedCrazyThings.Items.Consumables { - [Content(ContentType.Bosses)] - public class EmpowermentFlask : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Empowerment Flask"); - Tooltip.SetDefault("Incrementally increases damage dealt over time" - + "\nBonus resets upon taking damage" - + "\n(Summon damage only increases marginally)"); + [Content(ContentType.Bosses)] + public class EmpowermentFlask : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Empowerment Flask"); + Tooltip.SetDefault("Incrementally increases damage dealt over time" + + "\nBonus resets upon taking damage" + + "\n(Summon damage only increases marginally)"); - ItemID.Sets.DrinkParticleColors[Item.type] = new Color[3] { - new Color(13, 106, 137), - new Color(10, 176, 230), - new Color(146, 229, 255) - }; - } + ItemID.Sets.DrinkParticleColors[Item.type] = new Color[3] { + new Color(13, 106, 137), + new Color(10, 176, 230), + new Color(146, 229, 255) + }; + } - public override void SetDefaults() - { - Item.width = 20; - Item.height = 30; - Item.useStyle = ItemUseStyleID.DrinkLiquid; - Item.useAnimation = 17; - Item.useTime = 17; - Item.useTurn = true; - Item.UseSound = SoundID.Item3; - Item.maxStack = 30; - Item.consumable = true; - Item.buffTime = 2 * 60 * 60; - Item.buffType = ModContent.BuffType(); - Item.rare = -11; - Item.value = Item.sellPrice(silver: 2); - } + public override void SetDefaults() + { + Item.width = 20; + Item.height = 30; + Item.useStyle = ItemUseStyleID.DrinkLiquid; + Item.useAnimation = 17; + Item.useTime = 17; + Item.useTurn = true; + Item.UseSound = SoundID.Item3; + Item.maxStack = 30; + Item.consumable = true; + Item.buffTime = 2 * 60 * 60; + Item.buffType = ModContent.BuffType(); + Item.rare = -11; + Item.value = Item.sellPrice(silver: 2); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.BottledWater, 1).AddIngredient(ModContent.ItemType(), 3).AddIngredient(ItemID.Bone, 10).AddTile(TileID.Bottles).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.BottledWater, 1).AddIngredient(ModContent.ItemType(), 3).AddIngredient(ItemID.Bone, 10).AddTile(TileID.Bottles).Register(); + } + } } diff --git a/Items/Consumables/EnhancedHunterPotion.cs b/Items/Consumables/EnhancedHunterPotion.cs index feabb90a..c393da75 100644 --- a/Items/Consumables/EnhancedHunterPotion.cs +++ b/Items/Consumables/EnhancedHunterPotion.cs @@ -6,43 +6,43 @@ namespace AssortedCrazyThings.Items.Consumables { - [Content(ContentType.Bosses)] - public class EnhancedHunterPotion : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Enhanced Hunter Potion"); - Tooltip.SetDefault("Shows the location of enemies" - + "\nAdditionally, shows the location of enemies outside your vision range" - + "\nRange is roughly one screen in each direction"); + [Content(ContentType.Bosses)] + public class EnhancedHunterPotion : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Enhanced Hunter Potion"); + Tooltip.SetDefault("Shows the location of enemies" + + "\nAdditionally, shows the location of enemies outside your vision range" + + "\nRange is roughly one screen in each direction"); - ItemID.Sets.DrinkParticleColors[Item.type] = new Color[3] { - new Color(13, 106, 137), - new Color(10, 176, 230), - new Color(146, 229, 255) - }; - } + ItemID.Sets.DrinkParticleColors[Item.type] = new Color[3] { + new Color(13, 106, 137), + new Color(10, 176, 230), + new Color(146, 229, 255) + }; + } - public override void SetDefaults() - { - Item.width = 20; - Item.height = 28; - Item.useStyle = ItemUseStyleID.DrinkLiquid; - Item.useAnimation = 17; - Item.useTime = 17; - Item.useTurn = true; - Item.UseSound = SoundID.Item3; - Item.maxStack = 30; - Item.consumable = true; - Item.buffTime = 5 * 60 * 60; - Item.buffType = ModContent.BuffType(); - Item.rare = -11; - Item.value = Item.sellPrice(silver: 3); - } + public override void SetDefaults() + { + Item.width = 20; + Item.height = 28; + Item.useStyle = ItemUseStyleID.DrinkLiquid; + Item.useAnimation = 17; + Item.useTime = 17; + Item.useTurn = true; + Item.UseSound = SoundID.Item3; + Item.maxStack = 30; + Item.consumable = true; + Item.buffTime = 5 * 60 * 60; + Item.buffType = ModContent.BuffType(); + Item.rare = -11; + Item.value = Item.sellPrice(silver: 3); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.HunterPotion, 1).AddIngredient(ItemID.PixieDust, 1).AddIngredient(ModContent.ItemType(), 1).AddTile(TileID.Bottles).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.HunterPotion, 1).AddIngredient(ItemID.PixieDust, 1).AddIngredient(ModContent.ItemType(), 1).AddTile(TileID.Bottles).Register(); + } + } } diff --git a/Items/Consumables/HarvesterTreasureBag.cs b/Items/Consumables/HarvesterTreasureBag.cs index d9c51e3a..b7bed982 100644 --- a/Items/Consumables/HarvesterTreasureBag.cs +++ b/Items/Consumables/HarvesterTreasureBag.cs @@ -1,5 +1,4 @@ using AssortedCrazyThings.Items.VanityArmor; -using AssortedCrazyThings.NPCs.DungeonBird; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -9,123 +8,123 @@ namespace AssortedCrazyThings.Items.Consumables { - [Content(ContentType.Bosses)] - public class HarvesterTreasureBag : AssItem - { - //Sets the associated NPC this treasure bag is dropped from - public override int BossBagNPC => AssortedCrazyThings.harvester; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Treasure Bag"); - Tooltip.SetDefault("{$CommonItemTooltip.RightClickToOpen}"); //References a language key that says "Right Click To Open" in the language of the game - - ItemID.Sets.BossBag[Type] = true; //This set is one that every boss bag should have, it, for example, lets our boss bag drop dev armor.. - ItemID.Sets.PreHardmodeLikeBossBag[Type] = true; //..But this set ensures that dev armor will only be dropped on special world seeds, since that's the behavior of pre-hardmode boss bags. - } - - public override void SetDefaults() - { - Item.maxStack = 999; - Item.consumable = true; - Item.width = 24; - Item.height = 24; - Item.rare = ItemRarityID.Purple; - Item.expert = true; - } - - public override bool CanRightClick() - { - return true; - } - - public override void OpenBossBag(Player player) - { - var source = player.GetItemSource_OpenItem(Type); - //We have to replicate the expert drops from Harvester here via QuickSpawnItem - player.QuickSpawnItem(source, ItemID.Bone, Main.rand.Next(40, 61)); - player.QuickSpawnItem(source, ModContent.ItemType()); - - if (ContentConfig.Instance.VanityArmor && Main.rand.NextBool(7)) - { - player.QuickSpawnItem(source, ModContent.ItemType()); - } - } - - //Below is code for the visuals - - public override Color? GetAlpha(Color lightColor) - { - //Makes sure the dropped bag is always visible - return Color.Lerp(lightColor, Color.White, 0.4f); - } - - public override void PostUpdate() - { - //Spawn some light and dust - Lighting.AddLight(Item.Center, Color.White.ToVector3() * 0.4f); - - if (Item.timeSinceItemSpawned % 12 == 0) - { - Vector2 center = Item.Center + new Vector2(0f, Item.height * -0.1f); - - //This creates a randomly rotated vector of length 1, which gets it's components multiplied by the parameters - Vector2 direction = Main.rand.NextVector2CircularEdge(Item.width * 0.6f, Item.height * 0.6f); - float distance = 0.3f + Main.rand.NextFloat() * 0.5f; - Vector2 velocity = new Vector2(0f, -Main.rand.NextFloat() * 0.3f - 1.5f); - - Dust dust = Dust.NewDustPerfect(center + direction * distance, DustID.SilverFlame, velocity); - dust.scale = 0.5f; - dust.fadeIn = 1.1f; - dust.noGravity = true; - dust.noLight = true; - dust.alpha = 0; - } - } - - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - //Draw the periodic glow effect - Texture2D texture = TextureAssets.Item[Item.type].Value; - - Rectangle frame; - if (Main.itemAnimations[Item.type] != null) - { - frame = Main.itemAnimations[Item.type].GetFrame(texture, Main.itemFrameCounter[whoAmI]); - } - else - { - frame = texture.Frame(); - } - - Vector2 frameOrigin = frame.Size() / 2f; - Vector2 offset = new Vector2(Item.width / 2 - frameOrigin.X, Item.height - frame.Height); - Vector2 drawPos = Item.position - Main.screenPosition + frameOrigin + offset; - - float time = Main.GlobalTimeWrappedHourly; - float timer = Item.timeSinceItemSpawned / 240f + time * 0.04f; - - time %= 4f; - time /= 2f; - if (time >= 1f) - { - time = 2f - time; - } - time = time * 0.5f + 0.5f; - - for (float i = 0f; i < 1f; i += 0.25f) - { - float radians = (i + timer) * MathHelper.TwoPi; - spriteBatch.Draw(texture, drawPos + new Vector2(0f, 8f).RotatedBy(radians) * time, frame, new Color(90, 70, 255, 50), rotation, frameOrigin, scale, SpriteEffects.None, 0); - } - - for (float i = 0f; i < 1f; i += 0.34f) - { - float radians = (i + timer) * MathHelper.TwoPi; - spriteBatch.Draw(texture, drawPos + new Vector2(0f, 4f).RotatedBy(radians) * time, frame, new Color(140, 120, 255, 77), rotation, frameOrigin, scale, SpriteEffects.None, 0); - } - - return true; - } - } + [Content(ContentType.Bosses)] + public class HarvesterTreasureBag : AssItem + { + //Sets the associated NPC this treasure bag is dropped from + public override int BossBagNPC => AssortedCrazyThings.harvester; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Treasure Bag"); + Tooltip.SetDefault("{$CommonItemTooltip.RightClickToOpen}"); //References a language key that says "Right Click To Open" in the language of the game + + ItemID.Sets.BossBag[Type] = true; //This set is one that every boss bag should have, it, for example, lets our boss bag drop dev armor.. + ItemID.Sets.PreHardmodeLikeBossBag[Type] = true; //..But this set ensures that dev armor will only be dropped on special world seeds, since that's the behavior of pre-hardmode boss bags. + } + + public override void SetDefaults() + { + Item.maxStack = 999; + Item.consumable = true; + Item.width = 24; + Item.height = 24; + Item.rare = ItemRarityID.Purple; + Item.expert = true; + } + + public override bool CanRightClick() + { + return true; + } + + public override void OpenBossBag(Player player) + { + var source = player.GetItemSource_OpenItem(Type); + //We have to replicate the expert drops from Harvester here via QuickSpawnItem + player.QuickSpawnItem(source, ItemID.Bone, Main.rand.Next(40, 61)); + player.QuickSpawnItem(source, ModContent.ItemType()); + + if (ContentConfig.Instance.VanityArmor && Main.rand.NextBool(7)) + { + player.QuickSpawnItem(source, ModContent.ItemType()); + } + } + + //Below is code for the visuals + + public override Color? GetAlpha(Color lightColor) + { + //Makes sure the dropped bag is always visible + return Color.Lerp(lightColor, Color.White, 0.4f); + } + + public override void PostUpdate() + { + //Spawn some light and dust + Lighting.AddLight(Item.Center, Color.White.ToVector3() * 0.4f); + + if (Item.timeSinceItemSpawned % 12 == 0) + { + Vector2 center = Item.Center + new Vector2(0f, Item.height * -0.1f); + + //This creates a randomly rotated vector of length 1, which gets it's components multiplied by the parameters + Vector2 direction = Main.rand.NextVector2CircularEdge(Item.width * 0.6f, Item.height * 0.6f); + float distance = 0.3f + Main.rand.NextFloat() * 0.5f; + Vector2 velocity = new Vector2(0f, -Main.rand.NextFloat() * 0.3f - 1.5f); + + Dust dust = Dust.NewDustPerfect(center + direction * distance, DustID.SilverFlame, velocity); + dust.scale = 0.5f; + dust.fadeIn = 1.1f; + dust.noGravity = true; + dust.noLight = true; + dust.alpha = 0; + } + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + //Draw the periodic glow effect + Texture2D texture = TextureAssets.Item[Item.type].Value; + + Rectangle frame; + if (Main.itemAnimations[Item.type] != null) + { + frame = Main.itemAnimations[Item.type].GetFrame(texture, Main.itemFrameCounter[whoAmI]); + } + else + { + frame = texture.Frame(); + } + + Vector2 frameOrigin = frame.Size() / 2f; + Vector2 offset = new Vector2(Item.width / 2 - frameOrigin.X, Item.height - frame.Height); + Vector2 drawPos = Item.position - Main.screenPosition + frameOrigin + offset; + + float time = Main.GlobalTimeWrappedHourly; + float timer = Item.timeSinceItemSpawned / 240f + time * 0.04f; + + time %= 4f; + time /= 2f; + if (time >= 1f) + { + time = 2f - time; + } + time = time * 0.5f + 0.5f; + + for (float i = 0f; i < 1f; i += 0.25f) + { + float radians = (i + timer) * MathHelper.TwoPi; + spriteBatch.Draw(texture, drawPos + new Vector2(0f, 8f).RotatedBy(radians) * time, frame, new Color(90, 70, 255, 50), rotation, frameOrigin, scale, SpriteEffects.None, 0); + } + + for (float i = 0f; i < 1f; i += 0.34f) + { + float radians = (i + timer) * MathHelper.TwoPi; + spriteBatch.Draw(texture, drawPos + new Vector2(0f, 4f).RotatedBy(radians) * time, frame, new Color(140, 120, 255, 77), rotation, frameOrigin, scale, SpriteEffects.None, 0); + } + + return true; + } + } } diff --git a/Items/DesiccatedLeather.cs b/Items/DesiccatedLeather.cs index 73f71266..c69b64a6 100644 --- a/Items/DesiccatedLeather.cs +++ b/Items/DesiccatedLeather.cs @@ -1,24 +1,23 @@ using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items { - [Content(ContentType.Bosses)] - public class DesiccatedLeather : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Desiccated Leather"); - Tooltip.SetDefault("'It's dry, sticky, and smells horrible'"); - } - public override void SetDefaults() - { - Item.maxStack = 999; - Item.width = 22; - Item.height = 22; - Item.rare = -11; - Item.value = Item.sellPrice(silver: 50); - } - } + [Content(ContentType.Bosses)] + public class DesiccatedLeather : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Desiccated Leather"); + Tooltip.SetDefault("'It's dry, sticky, and smells horrible'"); + } + public override void SetDefaults() + { + Item.maxStack = 999; + Item.width = 22; + Item.height = 22; + Item.rare = -11; + Item.value = Item.sellPrice(silver: 50); + } + } } diff --git a/Items/DisabledGlobalItem.cs b/Items/DisabledGlobalItem.cs index 896ab990..0e086dab 100644 --- a/Items/DisabledGlobalItem.cs +++ b/Items/DisabledGlobalItem.cs @@ -5,32 +5,32 @@ namespace AssortedCrazyThings.Items { - //Responsible for showing why an item was unloaded/disabled - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - public class DisabledGlobalItem : AssGlobalItem - { - public override bool AppliesToEntity(Item entity, bool lateInstantiation) - { - //Needs the item to be instantiated (ModItem assigned) before applying global - return lateInstantiation && entity.ModItem is UnloadedItem; - } + //Responsible for showing why an item was unloaded/disabled + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + public class DisabledGlobalItem : AssGlobalItem + { + public override bool AppliesToEntity(Item entity, bool lateInstantiation) + { + //Needs the item to be instantiated (ModItem assigned) before applying global + return lateInstantiation && entity.ModItem is UnloadedItem; + } - public override void ModifyTooltips(Item item, List tooltips) - { - if (item.ModItem is not UnloadedItem unloadedItem) - { - return; - } + public override void ModifyTooltips(Item item, List tooltips) + { + if (item.ModItem is not UnloadedItem unloadedItem) + { + return; + } - if (unloadedItem.ModName != Mod.Name) - { - return; - } + if (unloadedItem.ModName != Mod.Name) + { + return; + } - if (ConfigurationSystem.NonLoadedNames.TryGetValue(unloadedItem.ItemName, out ContentType type)) - { - tooltips.Add(new TooltipLine(Mod, "UnloadedSource", $"Disabled by the '{ConfigurationSystem.ContentTypeToString(type)}' config setting")); - } - } - } + if (ConfigurationSystem.NonLoadedNames.TryGetValue(unloadedItem.ItemName, out ContentType type)) + { + tooltips.Add(new TooltipLine(Mod, "UnloadedSource", $"Disabled by the '{ConfigurationSystem.ContentTypeToString(type)}' config setting")); + } + } + } } diff --git a/Items/DroneUnlockables/DroneParts.cs b/Items/DroneUnlockables/DroneParts.cs index 54593f35..6fe48170 100644 --- a/Items/DroneUnlockables/DroneParts.cs +++ b/Items/DroneUnlockables/DroneParts.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.DroneUnlockables { - [Content(ContentType.Weapons)] - public class DroneParts : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Drone Parts"); - Tooltip.SetDefault("'These parts could be repurposed...'"); - } + [Content(ContentType.Weapons)] + public class DroneParts : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Drone Parts"); + Tooltip.SetDefault("'These parts could be repurposed...'"); + } - public override void SetDefaults() - { - Item.maxStack = 999; - Item.rare = -11; - Item.width = 26; - Item.height = 24; - Item.value = Item.sellPrice(silver: 50); - } - } + public override void SetDefaults() + { + Item.maxStack = 999; + Item.rare = -11; + Item.width = 26; + Item.height = 24; + Item.value = Item.sellPrice(silver: 50); + } + } } diff --git a/Items/DroneUnlockables/DroneUnlockable.cs b/Items/DroneUnlockables/DroneUnlockable.cs index 4a333ccd..0087b9e2 100644 --- a/Items/DroneUnlockables/DroneUnlockable.cs +++ b/Items/DroneUnlockables/DroneUnlockable.cs @@ -6,162 +6,162 @@ namespace AssortedCrazyThings.Items.DroneUnlockables { - [Content(ContentType.Weapons)] - public abstract class DroneUnlockable : AssItem - { - public override void SetDefaults() - { - Item.maxStack = 999; - Item.rare = -11; - Item.width = 26; - Item.height = 24; - Item.consumable = true; - Item.maxStack = 1; - Item.UseSound = SoundID.Item4; - Item.useTime = 30; - Item.useAnimation = 30; - Item.useStyle = ItemUseStyleID.HoldUp; - Item.value = Item.sellPrice(silver: 50); - } - - public override void ModifyTooltips(List tooltips) - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - string tooltip = DroneController.GetDroneData(UnlockedType).Name + " for the Drone Controller"; - if (!mPlayer.droneControllerUnlocked.HasFlag(UnlockedType)) - { - tooltip = "Unlocks the " + tooltip; - } - else - { - tooltip = "Already unlocked " + tooltip; - } - tooltips.Add(new TooltipLine(Mod, "Unlocks", tooltip)); - } - - public abstract DroneType UnlockedType { get; } - - public override bool CanUseItem(Player player) - { - if (Main.netMode != NetmodeID.Server && Main.myPlayer == player.whoAmI) - { - AssPlayer mPlayer = player.GetModPlayer(); - if (!mPlayer.droneControllerUnlocked.HasFlag(UnlockedType)) - { - return true; - } - } - return false; - } - - public override bool? UseItem(Player player) - { - if (Main.netMode != NetmodeID.Server && Main.myPlayer == player.whoAmI) - { - player.GetModPlayer().droneControllerUnlocked |= UnlockedType; - Main.NewText("Unlocked: " + DroneController.GetDroneData(UnlockedType).Name, CombatText.HealLife); - } - return true; - } - - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType()).Register(); - } - } - - //public class DroneRecipe : ModRecipe - //{ - // public DroneType UnlockedType; - - // public DroneRecipe(Mod mod, DroneType unlockedType) : base(mod) - // { - // UnlockedType = unlockedType; - // } - - // public override bool RecipeAvailable() - // { - // return !Main.LocalPlayer.GetModPlayer().droneControllerUnlocked.HasFlag(UnlockedType); - // } - //} - - public class DroneUnlockableBasicLaserDrone : DroneUnlockable - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Basic Laser Drone Components"); - } - - public override DroneType UnlockedType - { - get - { - return DroneType.BasicLaser; - } - } - } - - public class DroneUnlockableHeavyLaserDrone : DroneUnlockable - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Heavy Laser Drone Components"); - } - - public override DroneType UnlockedType - { - get - { - return DroneType.HeavyLaser; - } - } - } - - public class DroneUnlockableMissileDrone : DroneUnlockable - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Missile Drone Components"); - } - - public override DroneType UnlockedType - { - get - { - return DroneType.Missile; - } - } - } - - public class DroneUnlockableHealingDrone : DroneUnlockable - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Healing Drone Components"); - } - - public override DroneType UnlockedType - { - get - { - return DroneType.Healing; - } - } - } - - public class DroneUnlockableShieldDrone : DroneUnlockable - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shield Drone Components"); - } - - public override DroneType UnlockedType - { - get - { - return DroneType.Shield; - } - } - } + [Content(ContentType.Weapons)] + public abstract class DroneUnlockable : AssItem + { + public override void SetDefaults() + { + Item.maxStack = 999; + Item.rare = -11; + Item.width = 26; + Item.height = 24; + Item.consumable = true; + Item.maxStack = 1; + Item.UseSound = SoundID.Item4; + Item.useTime = 30; + Item.useAnimation = 30; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.value = Item.sellPrice(silver: 50); + } + + public override void ModifyTooltips(List tooltips) + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + string tooltip = DroneController.GetDroneData(UnlockedType).Name + " for the Drone Controller"; + if (!mPlayer.droneControllerUnlocked.HasFlag(UnlockedType)) + { + tooltip = "Unlocks the " + tooltip; + } + else + { + tooltip = "Already unlocked " + tooltip; + } + tooltips.Add(new TooltipLine(Mod, "Unlocks", tooltip)); + } + + public abstract DroneType UnlockedType { get; } + + public override bool CanUseItem(Player player) + { + if (Main.netMode != NetmodeID.Server && Main.myPlayer == player.whoAmI) + { + AssPlayer mPlayer = player.GetModPlayer(); + if (!mPlayer.droneControllerUnlocked.HasFlag(UnlockedType)) + { + return true; + } + } + return false; + } + + public override bool? UseItem(Player player) + { + if (Main.netMode != NetmodeID.Server && Main.myPlayer == player.whoAmI) + { + player.GetModPlayer().droneControllerUnlocked |= UnlockedType; + Main.NewText("Unlocked: " + DroneController.GetDroneData(UnlockedType).Name, CombatText.HealLife); + } + return true; + } + + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType()).Register(); + } + } + + //public class DroneRecipe : ModRecipe + //{ + // public DroneType UnlockedType; + + // public DroneRecipe(Mod mod, DroneType unlockedType) : base(mod) + // { + // UnlockedType = unlockedType; + // } + + // public override bool RecipeAvailable() + // { + // return !Main.LocalPlayer.GetModPlayer().droneControllerUnlocked.HasFlag(UnlockedType); + // } + //} + + public class DroneUnlockableBasicLaserDrone : DroneUnlockable + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Basic Laser Drone Components"); + } + + public override DroneType UnlockedType + { + get + { + return DroneType.BasicLaser; + } + } + } + + public class DroneUnlockableHeavyLaserDrone : DroneUnlockable + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heavy Laser Drone Components"); + } + + public override DroneType UnlockedType + { + get + { + return DroneType.HeavyLaser; + } + } + } + + public class DroneUnlockableMissileDrone : DroneUnlockable + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Missile Drone Components"); + } + + public override DroneType UnlockedType + { + get + { + return DroneType.Missile; + } + } + } + + public class DroneUnlockableHealingDrone : DroneUnlockable + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Healing Drone Components"); + } + + public override DroneType UnlockedType + { + get + { + return DroneType.Healing; + } + } + } + + public class DroneUnlockableShieldDrone : DroneUnlockable + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shield Drone Components"); + } + + public override DroneType UnlockedType + { + get + { + return DroneType.Shield; + } + } + } } diff --git a/Items/EverburningGlobalItem.cs b/Items/EverburningGlobalItem.cs index d8ccda29..ecc24b7d 100644 --- a/Items/EverburningGlobalItem.cs +++ b/Items/EverburningGlobalItem.cs @@ -6,108 +6,108 @@ namespace AssortedCrazyThings.Items { - [Content(ContentType.Accessories)] - public class EverburningGlobalItem : AssGlobalItem - { - public override bool InstancePerEntity => false; + [Content(ContentType.Accessories)] + public class EverburningGlobalItem : AssGlobalItem + { + public override bool InstancePerEntity => false; - public override GlobalItem Clone(Item item, Item itemClone) - { - EverburningGlobalItem myClone = (EverburningGlobalItem)base.Clone(item, itemClone); - return myClone; - } + public override GlobalItem Clone(Item item, Item itemClone) + { + EverburningGlobalItem myClone = (EverburningGlobalItem)base.Clone(item, itemClone); + return myClone; + } - public override bool CanUseItem(Item item, Player player) - { - //IS ACTUALLY CALLED EVERY TICK WHENEVER YOU USE THE ITEM ON THE SERVER; BUT ONLY ONCE ON THE CLIENT - AssPlayer mPlayer = player.GetModPlayer(); + public override bool CanUseItem(Item item, Player player) + { + //IS ACTUALLY CALLED EVERY TICK WHENEVER YOU USE THE ITEM ON THE SERVER; BUT ONLY ONCE ON THE CLIENT + AssPlayer mPlayer = player.GetModPlayer(); - if (!player.CCed && (mPlayer.everburningCandleBuff || mPlayer.everfrozenCandleBuff || mPlayer.everburningShadowflameCandleBuff || mPlayer.everburningCursedCandleBuff)) - { - if (item.damage >= 0) - { - if (item.CountsAsClass(DamageClass.Summon)) - { - //TODO do something with auto-fire boomerangs - if (item.shoot > ProjectileID.None && item.shootSpeed > 0) - { - ShootCandleDust(item, mPlayer); - } - } + if (!player.CCed && (mPlayer.everburningCandleBuff || mPlayer.everfrozenCandleBuff || mPlayer.everburningShadowflameCandleBuff || mPlayer.everburningCursedCandleBuff)) + { + if (item.damage >= 0) + { + if (item.CountsAsClass(DamageClass.Summon)) + { + //TODO do something with auto-fire boomerangs + if (item.shoot > ProjectileID.None && item.shootSpeed > 0) + { + ShootCandleDust(item, mPlayer); + } + } - else if (item.CountsAsClass(DamageClass.Ranged)) - { - if (player.HasAmmo(item, true)) - { - ShootCandleDust(item, mPlayer); - } - } + else if (item.CountsAsClass(DamageClass.Ranged)) + { + if (player.HasAmmo(item, true)) + { + ShootCandleDust(item, mPlayer); + } + } - else if (item.CountsAsClass(DamageClass.Magic) && item.mana <= player.statMana) - { - ShootCandleDust(item, mPlayer); - } + else if (item.CountsAsClass(DamageClass.Magic) && item.mana <= player.statMana) + { + ShootCandleDust(item, mPlayer); + } - else if (item.CountsAsClass(DamageClass.Throwing)) - { - ShootCandleDust(item, mPlayer); - } - } - } - return true; - } + else if (item.CountsAsClass(DamageClass.Throwing)) + { + ShootCandleDust(item, mPlayer); + } + } + } + return true; + } - private void SpawnMeleeDust(int type, Color color, Rectangle hitbox, Player player) - { - //6 is the default fire particle type - if (player.HeldItem.damage >= 0) - { - Dust dust = Dust.NewDustDirect(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, type, player.velocity.X * 0.2f + (player.direction * 3), player.velocity.Y * 0.2f, 100, color, 2f); - dust.noGravity = true; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - } + private void SpawnMeleeDust(int type, Color color, Rectangle hitbox, Player player) + { + //6 is the default fire particle type + if (player.HeldItem.damage >= 0) + { + Dust dust = Dust.NewDustDirect(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, type, player.velocity.X * 0.2f + (player.direction * 3), player.velocity.Y * 0.2f, 100, color, 2f); + dust.noGravity = true; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + } - private void ShootCandleDust(Item item, AssPlayer mPlayer) - { - Player player = mPlayer.Player; - Vector2 cm = new Vector2(Main.MouseWorld.X - player.Center.X, Main.MouseWorld.Y - player.Center.Y); - float rand = Main.rand.NextFloat(0.7f, 1.3f); - float velox = ((cm.X * item.shootSpeed * rand) / cm.Length());// rand makes it so it has different velocity factor (how far it flies) - float veloy = ((cm.Y * item.shootSpeed * rand) / cm.Length()); - Vector2 velo = new Vector2(velox, veloy); - Vector2 pos = new Vector2(player.Center.X, player.Center.Y + 8f); + private void ShootCandleDust(Item item, AssPlayer mPlayer) + { + Player player = mPlayer.Player; + Vector2 cm = new Vector2(Main.MouseWorld.X - player.Center.X, Main.MouseWorld.Y - player.Center.Y); + float rand = Main.rand.NextFloat(0.7f, 1.3f); + float velox = ((cm.X * item.shootSpeed * rand) / cm.Length());// rand makes it so it has different velocity factor (how far it flies) + float veloy = ((cm.Y * item.shootSpeed * rand) / cm.Length()); + Vector2 velo = new Vector2(velox, veloy); + Vector2 pos = new Vector2(player.Center.X, player.Center.Y + 8f); - //reduce but not prevent spam from boomerang related weapons or modded damage classes - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 2) - Projectile.NewProjectile(player.GetProjectileSource_Item(item), pos, velo + player.velocity, ModContent.ProjectileType(), 0, 0f, player.whoAmI); - } + //reduce but not prevent spam from boomerang related weapons or modded damage classes + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 2) + Projectile.NewProjectile(player.GetProjectileSource_Item(item), pos, velo + player.velocity, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + } - public override void MeleeEffects(Item item, Player player, Rectangle hitbox) - { - AssPlayer mPlayer = player.GetModPlayer(); - if (mPlayer.everburningCandleBuff) - { - Color color = new Color(255, 255, 255); - SpawnMeleeDust(6, color, hitbox, player); - } - if (mPlayer.everburningCursedCandleBuff) - { - Color color = new Color(255, 255, 255); //(196, 255, 0); - SpawnMeleeDust(75, color, hitbox, player); - } - if (mPlayer.everfrozenCandleBuff) - { - Color color = new Color(255, 255, 255); - SpawnMeleeDust(59, color, hitbox, player); - } - if (mPlayer.everburningShadowflameCandleBuff) - { - Color color = new Color(196, 0, 255); - SpawnMeleeDust(62, color, hitbox, player); - } - //type 64 is ichor - } - } + public override void MeleeEffects(Item item, Player player, Rectangle hitbox) + { + AssPlayer mPlayer = player.GetModPlayer(); + if (mPlayer.everburningCandleBuff) + { + Color color = new Color(255, 255, 255); + SpawnMeleeDust(6, color, hitbox, player); + } + if (mPlayer.everburningCursedCandleBuff) + { + Color color = new Color(255, 255, 255); //(196, 255, 0); + SpawnMeleeDust(75, color, hitbox, player); + } + if (mPlayer.everfrozenCandleBuff) + { + Color color = new Color(255, 255, 255); + SpawnMeleeDust(59, color, hitbox, player); + } + if (mPlayer.everburningShadowflameCandleBuff) + { + Color color = new Color(196, 0, 255); + SpawnMeleeDust(62, color, hitbox, player); + } + //type 64 is ichor + } + } } diff --git a/Items/Fun/CraftOfMiners.cs b/Items/Fun/CraftOfMiners.cs index 10a75e62..65331f7e 100644 --- a/Items/Fun/CraftOfMiners.cs +++ b/Items/Fun/CraftOfMiners.cs @@ -4,41 +4,41 @@ namespace AssortedCrazyThings.Items.Fun { - [Content(ContentType.Weapons | ContentType.Tools)] - public class CraftOfMiners : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Craft of Miners"); - Tooltip.SetDefault("'Use those fists of yours to tear through any blocks in your way'" - + "\n[c/44942e:'Dedicated to Anonymous']"); - } + [Content(ContentType.Weapons | ContentType.Tools)] + public class CraftOfMiners : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Craft of Miners"); + Tooltip.SetDefault("'Use those fists of yours to tear through any blocks in your way'" + + "\n[c/44942e:'Dedicated to Anonymous']"); + } - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.ShroomiteDiggingClaw); - Item.damage = 13; - Item.useAnimation = 3; - Item.useTime = 3; - Item.value = Item.sellPrice(gold: 5); - Item.rare = -11; - Item.noUseGraphic = true; - } + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.ShroomiteDiggingClaw); + Item.damage = 13; + Item.useAnimation = 3; + Item.useTime = 3; + Item.value = Item.sellPrice(gold: 5); + Item.rare = -11; + Item.noUseGraphic = true; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.ShroomiteDiggingClaw, 5).AddTile(TileID.CrystalBall).Register(); - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.ShroomiteDiggingClaw, 5).AddTile(TileID.CrystalBall).Register(); + } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(10)) - { - Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f); - Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f); - Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f); - Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f); - } - } - } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (Main.rand.NextBool(10)) + { + Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f); + Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f); + Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f); + Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f); + } + } + } } diff --git a/Items/Fun/GuideVoodoorang.cs b/Items/Fun/GuideVoodoorang.cs index da45e6f1..1f799b54 100644 --- a/Items/Fun/GuideVoodoorang.cs +++ b/Items/Fun/GuideVoodoorang.cs @@ -5,67 +5,67 @@ namespace AssortedCrazyThings.Items.Fun { - [Content(ContentType.Weapons)] - public class GuideVoodoorang : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Guide Voodoorang"); - Tooltip.SetDefault("'Why are you like this?'"); - } + [Content(ContentType.Weapons)] + public class GuideVoodoorang : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Guide Voodoorang"); + Tooltip.SetDefault("'Why are you like this?'"); + } - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.WoodenBoomerang); - Item.width = 22; - Item.height = 30; - Item.rare = -11; + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.WoodenBoomerang); + Item.width = 22; + Item.height = 30; + Item.rare = -11; - Item.value = Item.sellPrice(silver: 2); - Item.shoot = ModContent.ProjectileType(); - } + Item.value = Item.sellPrice(silver: 2); + Item.shoot = ModContent.ProjectileType(); + } - public override bool CanUseItem(Player player) - { - // Ensures no more than one boomerang can be thrown out - return player.ownedProjectileCounts[Item.shoot] < 1; - } + public override bool CanUseItem(Player player) + { + // Ensures no more than one boomerang can be thrown out + return player.ownedProjectileCounts[Item.shoot] < 1; + } - public override void PostUpdate() - { - if (Item.lavaWet) - { - if (Main.netMode != NetmodeID.MultiplayerClient && !NPC.AnyNPCs(NPCID.WallofFlesh)) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.active && npc.type == NPCID.Guide) - { - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, i, 9999f, 10f, -npc.direction); - } - npc.StrikeNPCNoInteraction(9999, 10f, -npc.direction); - NPC.SpawnWOF(Item.position); + public override void PostUpdate() + { + if (Item.lavaWet) + { + if (Main.netMode != NetmodeID.MultiplayerClient && !NPC.AnyNPCs(NPCID.WallofFlesh)) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active && npc.type == NPCID.Guide) + { + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, i, 9999f, 10f, -npc.direction); + } + npc.StrikeNPCNoInteraction(9999, 10f, -npc.direction); + NPC.SpawnWOF(Item.position); - byte plr = Player.FindClosest(Item.position, Item.width, Item.height); - Player player = Main.player[plr]; - Item.NewItem(player.GetItemSource_Misc(-1), player.getRect(), ModContent.ItemType()); + byte plr = Player.FindClosest(Item.position, Item.width, Item.height); + Player player = Main.player[plr]; + Item.NewItem(player.GetItemSource_Misc(-1), player.getRect(), ModContent.ItemType()); - //despawns upon wof spawn - Item.TurnToAir(); - NetMessage.SendData(MessageID.SyncItem, number: Item.whoAmI); - return; - } - } - } - } - } + //despawns upon wof spawn + Item.TurnToAir(); + NetMessage.SendData(MessageID.SyncItem, number: Item.whoAmI); + return; + } + } + } + } + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.GuideVoodooDoll).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.GuideVoodooDoll).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Fun/InfinityRocket.cs b/Items/Fun/InfinityRocket.cs index 87609803..7c07b138 100644 --- a/Items/Fun/InfinityRocket.cs +++ b/Items/Fun/InfinityRocket.cs @@ -3,31 +3,31 @@ namespace AssortedCrazyThings.Items.Fun { - [Content(ContentType.Weapons)] - public class InfinityRocket : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Infinity Rocket"); - Tooltip.SetDefault("'It seriously never ends!'"); - } + [Content(ContentType.Weapons)] + public class InfinityRocket : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Infinity Rocket"); + Tooltip.SetDefault("'It seriously never ends!'"); + } - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.EndlessMusketPouch); - Item.ammo = AmmoID.Rocket; - Item.rare = -11; - Item.shoot = ProjectileID.None; - Item.damage = 40; - Item.UseSound = SoundID.Item11; - //item.shoot = ProjectileID.RocketII; - Item.value = Item.sellPrice(gold: 4); + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.EndlessMusketPouch); + Item.ammo = AmmoID.Rocket; + Item.rare = -11; + Item.shoot = ProjectileID.None; + Item.damage = 40; + Item.UseSound = SoundID.Item11; + //item.shoot = ProjectileID.RocketII; + Item.value = Item.sellPrice(gold: 4); - } + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.RocketI, 3996).AddTile(TileID.CrystalBall).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.RocketI, 3996).AddTile(TileID.CrystalBall).Register(); + } + } } diff --git a/Items/Fun/StarForge.cs b/Items/Fun/StarForge.cs index b30b72ca..e6acbed2 100644 --- a/Items/Fun/StarForge.cs +++ b/Items/Fun/StarForge.cs @@ -3,30 +3,30 @@ namespace AssortedCrazyThings.Items.Fun { - [Content(ContentType.Weapons)] - public class StarForge : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star Forge"); - Tooltip.SetDefault("'An endless supply of the cosmos'"); - } + [Content(ContentType.Weapons)] + public class StarForge : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Star Forge"); + Tooltip.SetDefault("'An endless supply of the cosmos'"); + } - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.FallenStar); - Item.maxStack = 1; - Item.consumable = false; - Item.value = Item.sellPrice(0, 25, 0, 0); - Item.rare = -11; - } + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.FallenStar); + Item.maxStack = 1; + Item.consumable = false; + Item.value = Item.sellPrice(0, 25, 0, 0); + Item.rare = -11; + } - public override void AddRecipes() - { - CreateRecipe(1). - AddIngredient(ItemID.FallenStar, 500) - .AddTile(TileID.Anvils) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1). + AddIngredient(ItemID.FallenStar, 500) + .AddTile(TileID.Anvils) + .Register(); + } + } } diff --git a/Items/Gitgud/BrainOfCthulhuGitgud.cs b/Items/Gitgud/BrainOfCthulhuGitgud.cs index 80bd7f64..efd16fee 100644 --- a/Items/Gitgud/BrainOfCthulhuGitgud.cs +++ b/Items/Gitgud/BrainOfCthulhuGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class BrainOfCthulhuGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Insanity-B-Gone"); - } + public class BrainOfCthulhuGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Insanity-B-Gone"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().brainOfCthulhuGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().brainOfCthulhuGitgud = true; + } + } } diff --git a/Items/Gitgud/DestroyerGitgud.cs b/Items/Gitgud/DestroyerGitgud.cs index 8dc9b8f0..36a72e03 100644 --- a/Items/Gitgud/DestroyerGitgud.cs +++ b/Items/Gitgud/DestroyerGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class DestroyerGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Metal Dreamcatcher"); - } + public class DestroyerGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Metal Dreamcatcher"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().destroyerGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().destroyerGitgud = true; + } + } } diff --git a/Items/Gitgud/DukeFishronGitgud.cs b/Items/Gitgud/DukeFishronGitgud.cs index e4259304..de9173fe 100644 --- a/Items/Gitgud/DukeFishronGitgud.cs +++ b/Items/Gitgud/DukeFishronGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class DukeFishronGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("White Hook"); - } + public class DukeFishronGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("White Hook"); + } - public override void SafeSetDefaults() - { - Item.width = 12; - Item.height = 22; - } + public override void SafeSetDefaults() + { + Item.width = 12; + Item.height = 22; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().dukeFishronGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().dukeFishronGitgud = true; + } + } } diff --git a/Items/Gitgud/EaterOfWorldsGitgud.cs b/Items/Gitgud/EaterOfWorldsGitgud.cs index 9c15d009..feb7ca16 100644 --- a/Items/Gitgud/EaterOfWorldsGitgud.cs +++ b/Items/Gitgud/EaterOfWorldsGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class EaterOfWorldsGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Toy Seagull"); - } + public class EaterOfWorldsGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Toy Seagull"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().eaterOfWorldsGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().eaterOfWorldsGitgud = true; + } + } } diff --git a/Items/Gitgud/EmpressOfLightGitgud.cs b/Items/Gitgud/EmpressOfLightGitgud.cs index cf08a5bf..d485f480 100644 --- a/Items/Gitgud/EmpressOfLightGitgud.cs +++ b/Items/Gitgud/EmpressOfLightGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class EmpressOfLightGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Well-Worn Boots of Stomping"); - } + public class EmpressOfLightGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Well-Worn Boots of Stomping"); + } - public override void SafeSetDefaults() - { - Item.width = 30; - Item.height = 24; - } + public override void SafeSetDefaults() + { + Item.width = 30; + Item.height = 24; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().empressOfLightGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().empressOfLightGitgud = true; + } + } } diff --git a/Items/Gitgud/EyeOfCthulhuGitgud.cs b/Items/Gitgud/EyeOfCthulhuGitgud.cs index e25e5b09..0bda40d2 100644 --- a/Items/Gitgud/EyeOfCthulhuGitgud.cs +++ b/Items/Gitgud/EyeOfCthulhuGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class EyeOfCthulhuGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Broken Lens"); - } + public class EyeOfCthulhuGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Broken Lens"); + } - public override void SafeSetDefaults() - { - Item.width = 16; - Item.height = 20; - } + public override void SafeSetDefaults() + { + Item.width = 16; + Item.height = 20; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().eyeOfCthulhuGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().eyeOfCthulhuGitgud = true; + } + } } diff --git a/Items/Gitgud/GitgudItem.cs b/Items/Gitgud/GitgudItem.cs index 922a21f3..5e817b65 100644 --- a/Items/Gitgud/GitgudItem.cs +++ b/Items/Gitgud/GitgudItem.cs @@ -5,51 +5,51 @@ namespace AssortedCrazyThings.Items.Gitgud { - /// - /// Serves as a base for all gitgud items - /// - [Content(ContentType.BossConsolation)] - public abstract class GitgudItem : AssItem - { - public override void ModifyTooltips(List tooltips) - { - if (GitgudData.GetDataFromItemType(Item.type, out GitgudData data) && - tooltips.FindIndex(l => l.Name == "Social") == -1) - { - int insertIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); - if (insertIndex == -1) insertIndex = tooltips.Count; - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Desc", "Consolation Prize")); - string reduced = "" + Math.Round(data.Reduction * 100) + "% reduced damage taken " + (data.Invasion != "" ? "during " + data.Invasion : "from " + data.BossName); - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Reduced", reduced)); - if (data.BuffType != -1) - { - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "BuffImmune", "Immunity to '" + data.BuffNameFunc() + "' while " + data.BossName + (data.BossName.Contains(" or ") ? " are" : " is") + " alive")); - } + /// + /// Serves as a base for all gitgud items + /// + [Content(ContentType.BossConsolation)] + public abstract class GitgudItem : AssItem + { + public override void ModifyTooltips(List tooltips) + { + if (GitgudData.GetDataFromItemType(Item.type, out GitgudData data) && + tooltips.FindIndex(l => l.Name == "Social") == -1) + { + int insertIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); + if (insertIndex == -1) insertIndex = tooltips.Count; + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Desc", "Consolation Prize")); + string reduced = "" + Math.Round(data.Reduction * 100) + "% reduced damage taken " + (data.Invasion != "" ? "during " + data.Invasion : "from " + data.BossName); + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Reduced", reduced)); + if (data.BuffType != -1) + { + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "BuffImmune", "Immunity to '" + data.BuffNameFunc() + "' while " + data.BossName + (data.BossName.Contains(" or ") ? " are" : " is") + " alive")); + } - if (!(data.Accessory[Main.myPlayer] || Main.LocalPlayer.HasItem(Item.type) || Main.LocalPlayer.trashItem.type == Item.type)) - { - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Count", "Times died: " + data.Counter[Main.myPlayer] + "/" + data.CounterMax)); - } - tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Gitgud", "[c/E180CE:'git gud']")); - } - } + if (!(data.Accessory[Main.myPlayer] || Main.LocalPlayer.HasItem(Item.type) || Main.LocalPlayer.trashItem.type == Item.type)) + { + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Count", "Times died: " + data.Counter[Main.myPlayer] + "/" + data.CounterMax)); + } + tooltips.Insert(insertIndex++, new TooltipLine(Mod, "Gitgud", "[c/E180CE:'git gud']")); + } + } - public sealed override void SetDefaults() - { - Item.value = Item.sellPrice(copper: 1); - Item.rare = -1; - Item.maxStack = 1; - Item.accessory = true; + public sealed override void SetDefaults() + { + Item.value = Item.sellPrice(copper: 1); + Item.rare = -1; + Item.maxStack = 1; + Item.accessory = true; - //item.width = 32; - //item.height = 32; + //item.width = 32; + //item.height = 32; - SafeSetDefaults(); - } + SafeSetDefaults(); + } - public virtual void SafeSetDefaults() - { + public virtual void SafeSetDefaults() + { - } - } + } + } } diff --git a/Items/Gitgud/GolemGitgud.cs b/Items/Gitgud/GolemGitgud.cs index 625b90c2..c85bfc22 100644 --- a/Items/Gitgud/GolemGitgud.cs +++ b/Items/Gitgud/GolemGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class GolemGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rechargeable Solar Battery"); - } + public class GolemGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rechargeable Solar Battery"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().golemGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().golemGitgud = true; + } + } } diff --git a/Items/Gitgud/KingSlimeGitgud.cs b/Items/Gitgud/KingSlimeGitgud.cs index 2c2bde2e..30490449 100644 --- a/Items/Gitgud/KingSlimeGitgud.cs +++ b/Items/Gitgud/KingSlimeGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class KingSlimeGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slime Inquisition Notice"); - } + public class KingSlimeGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slime Inquisition Notice"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().kingSlimeGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().kingSlimeGitgud = true; + } + } } diff --git a/Items/Gitgud/LunaticCultistGitgud.cs b/Items/Gitgud/LunaticCultistGitgud.cs index ddb98c6a..f7928490 100644 --- a/Items/Gitgud/LunaticCultistGitgud.cs +++ b/Items/Gitgud/LunaticCultistGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class LunaticCultistGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Notice of Occupational Termination"); - } + public class LunaticCultistGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Notice of Occupational Termination"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().lunaticCultistGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().lunaticCultistGitgud = true; + } + } } diff --git a/Items/Gitgud/MoonLordGitgud.cs b/Items/Gitgud/MoonLordGitgud.cs index b55a55db..c1686fcc 100644 --- a/Items/Gitgud/MoonLordGitgud.cs +++ b/Items/Gitgud/MoonLordGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class MoonLordGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bright Side of the Moon"); - } + public class MoonLordGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bright Side of the Moon"); + } - public override void SafeSetDefaults() - { - Item.width = 30; - Item.height = 30; - } + public override void SafeSetDefaults() + { + Item.width = 30; + Item.height = 30; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().moonLordGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().moonLordGitgud = true; + } + } } diff --git a/Items/Gitgud/PlanteraGitgud.cs b/Items/Gitgud/PlanteraGitgud.cs index b870e7b5..d316892d 100644 --- a/Items/Gitgud/PlanteraGitgud.cs +++ b/Items/Gitgud/PlanteraGitgud.cs @@ -3,23 +3,23 @@ namespace AssortedCrazyThings.Items.Gitgud { - [LegacyName("GreenThumb")] - public class PlanteraGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Green Thumb"); - } + [LegacyName("GreenThumb")] + public class PlanteraGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Green Thumb"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().planteraGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().planteraGitgud = true; + } + } } diff --git a/Items/Gitgud/QueenBeeGitgud.cs b/Items/Gitgud/QueenBeeGitgud.cs index 6f60f62c..70b511c6 100644 --- a/Items/Gitgud/QueenBeeGitgud.cs +++ b/Items/Gitgud/QueenBeeGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class QueenBeeGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Honey Thimble"); - } + public class QueenBeeGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Honey Thimble"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().queenBeeGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().queenBeeGitgud = true; + } + } } diff --git a/Items/Gitgud/QueenSlimeGitgud.cs b/Items/Gitgud/QueenSlimeGitgud.cs index c9a17d73..5234e75d 100644 --- a/Items/Gitgud/QueenSlimeGitgud.cs +++ b/Items/Gitgud/QueenSlimeGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class QueenSlimeGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sparkling Cupcake"); - } + public class QueenSlimeGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sparkling Cupcake"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().queenSlimeGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().queenSlimeGitgud = true; + } + } } diff --git a/Items/Gitgud/SkeletronGitgud.cs b/Items/Gitgud/SkeletronGitgud.cs index 9af786ec..82ba9c0c 100644 --- a/Items/Gitgud/SkeletronGitgud.cs +++ b/Items/Gitgud/SkeletronGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class SkeletronGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Carton of Soy Milk"); - } + public class SkeletronGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Carton of Soy Milk"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().skeletronGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().skeletronGitgud = true; + } + } } diff --git a/Items/Gitgud/SkeletronPrimeGitgud.cs b/Items/Gitgud/SkeletronPrimeGitgud.cs index d1acae50..88fa1808 100644 --- a/Items/Gitgud/SkeletronPrimeGitgud.cs +++ b/Items/Gitgud/SkeletronPrimeGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class SkeletronPrimeGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Clock Set Ten Years Ahead"); - } + public class SkeletronPrimeGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Clock Set Ten Years Ahead"); + } - public override void SafeSetDefaults() - { - Item.width = 30; - Item.height = 30; - } + public override void SafeSetDefaults() + { + Item.width = 30; + Item.height = 30; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().skeletronPrimeGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().skeletronPrimeGitgud = true; + } + } } diff --git a/Items/Gitgud/TwinsGitgud.cs b/Items/Gitgud/TwinsGitgud.cs index 19f86299..27b4df7e 100644 --- a/Items/Gitgud/TwinsGitgud.cs +++ b/Items/Gitgud/TwinsGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class TwinsGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Metal Contact Lens"); - } + public class TwinsGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Metal Contact Lens"); + } - public override void SafeSetDefaults() - { - Item.width = 16; - Item.height = 20; - } + public override void SafeSetDefaults() + { + Item.width = 16; + Item.height = 20; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().twinsGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().twinsGitgud = true; + } + } } diff --git a/Items/Gitgud/WallOfFleshGitgud.cs b/Items/Gitgud/WallOfFleshGitgud.cs index af49442f..6bbfa198 100644 --- a/Items/Gitgud/WallOfFleshGitgud.cs +++ b/Items/Gitgud/WallOfFleshGitgud.cs @@ -2,22 +2,22 @@ namespace AssortedCrazyThings.Items.Gitgud { - public class WallOfFleshGitgud : GitgudItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wall of Flesh Voodoo Doll"); - } + public class WallOfFleshGitgud : GitgudItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wall of Flesh Voodoo Doll"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; - } + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.GetModPlayer().wallOfFleshGitgud = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().wallOfFleshGitgud = true; + } + } } diff --git a/Items/IdolOfDecay.cs b/Items/IdolOfDecay.cs index f9b165f8..62067187 100644 --- a/Items/IdolOfDecay.cs +++ b/Items/IdolOfDecay.cs @@ -5,57 +5,57 @@ namespace AssortedCrazyThings.Items { - [Content(ContentType.Bosses)] - public class IdolOfDecay : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Idol Of Decay"); - Tooltip.SetDefault("Summons " + Harvester.name + "'s final form in the dungeon" - + "\nUnlimited uses!"); + [Content(ContentType.Bosses)] + public class IdolOfDecay : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Idol Of Decay"); + Tooltip.SetDefault("Summons " + Harvester.name + "'s final form in the dungeon" + + "\nUnlimited uses!"); - Terraria.GameContent.Creative.CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; - ItemID.Sets.SortingPriorityBossSpawns[Type] = 12; // This helps sort inventory know that this is a boss summoning Item. - } + Terraria.GameContent.Creative.CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; + ItemID.Sets.SortingPriorityBossSpawns[Type] = 12; // This helps sort inventory know that this is a boss summoning Item. + } - public override void SetDefaults() - { - Item.width = 32; - Item.height = 28; - Item.maxStack = 1; - Item.rare = -11; - Item.useAnimation = 45; - Item.useTime = 45; - Item.useStyle = ItemUseStyleID.HoldUp; - Item.value = Item.sellPrice(silver: 5); - Item.UseSound = SoundID.Item44; - } + public override void SetDefaults() + { + Item.width = 32; + Item.height = 28; + Item.maxStack = 1; + Item.rare = -11; + Item.useAnimation = 45; + Item.useTime = 45; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.value = Item.sellPrice(silver: 5); + Item.UseSound = SoundID.Item44; + } - public override bool CanUseItem(Player player) - { - return !BabyHarvesterHandler.TryFindBabyHarvester(out _, out _) && !NPC.AnyNPCs(AssortedCrazyThings.harvester) && BabyHarvesterHandler.ValidPlayer(player); - } + public override bool CanUseItem(Player player) + { + return !BabyHarvesterHandler.TryFindBabyHarvester(out _, out _) && !NPC.AnyNPCs(AssortedCrazyThings.harvester) && BabyHarvesterHandler.ValidPlayer(player); + } - public override bool? UseItem(Player player) - { - if (player.whoAmI == Main.myPlayer) - { - int type = AssortedCrazyThings.harvester; + public override bool? UseItem(Player player) + { + if (player.whoAmI == Main.myPlayer) + { + int type = AssortedCrazyThings.harvester; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // If the player is not in multiplayer, spawn directly - NPC.SpawnOnPlayer(player.whoAmI, type); - } - else - { - // If the player is in multiplayer, request a spawn - // This will only work if NPCID.Sets.MPAllowedEnemies[type] is true, which we set in MinionBossBody - NetMessage.SendData(MessageID.SpawnBoss, number: player.whoAmI, number2: type); - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // If the player is not in multiplayer, spawn directly + NPC.SpawnOnPlayer(player.whoAmI, type); + } + else + { + // If the player is in multiplayer, request a spawn + // This will only work if NPCID.Sets.MPAllowedEnemies[type] is true, which we set in MinionBossBody + NetMessage.SendData(MessageID.SpawnBoss, number: player.whoAmI, number2: type); + } + } - return true; - } - } + return true; + } + } } diff --git a/Items/KnittingSet.cs b/Items/KnittingSet.cs index 599e7861..81780b06 100644 --- a/Items/KnittingSet.cs +++ b/Items/KnittingSet.cs @@ -3,27 +3,27 @@ namespace AssortedCrazyThings.Items { - [Content(ContentType.CuteSlimes)] - public class KnittingSet : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Knitting Set"); - Tooltip.SetDefault("'A set of tools used in crafting cute clothing and accessories'"); - } + [Content(ContentType.CuteSlimes)] + public class KnittingSet : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Knitting Set"); + Tooltip.SetDefault("'A set of tools used in crafting cute clothing and accessories'"); + } - public override void SetDefaults() - { - Item.maxStack = 999; - Item.width = 22; - Item.height = 22; - Item.rare = -11; - Item.value = Item.sellPrice(silver: 30); - } + public override void SetDefaults() + { + Item.maxStack = 999; + Item.width = 22; + Item.height = 22; + Item.rare = -11; + Item.value = Item.sellPrice(silver: 30); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Silk, 15).AddTile(TileID.Loom).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Silk, 15).AddTile(TileID.Loom).Register(); + } + } } diff --git a/Items/PetAccessories/PetAccessoryClass.cs b/Items/PetAccessories/PetAccessoryClass.cs index 143fbcb5..f8505679 100644 --- a/Items/PetAccessories/PetAccessoryClass.cs +++ b/Items/PetAccessories/PetAccessoryClass.cs @@ -10,329 +10,329 @@ namespace AssortedCrazyThings.Items.PetAccessories { - //Add new classes here in alphabetic order - - public class PetAccessoryBowtie : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Bowtie"); - Tooltip.SetDefault("'A soft bowtie for your cute slime to wear on her chest'"); - } - } - - public class PetAccessoryBunnyEars : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Bunny Ears"); - Tooltip.SetDefault("'A pair of Easter bunny ears for your cute slime to wear on her head'"); - } - } - - public class PetAccessoryBunnySuit : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Bunny Suit"); - Tooltip.SetDefault("'A bunny(?) costume for your cute slime to wear on her chest'"); - } - } - - public class PetAccessoryCrown : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Crown"); - Tooltip.SetDefault("'A regal crown for your cute slime to wear on her head'"); - } - } - - public class PetAccessoryMetalHelmet : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Knight's Helmet"); - Tooltip.SetDefault("'A plush knight's helmet for your cute slime to wear on her head'"); - } - } - - public class PetAccessoryKitchenKnife : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Kitchen Knife"); - Tooltip.SetDefault("'A plush kitchen knife for your cute slime to carry'"); - } - } - - public class PetAccessoryHairBow : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Hair Bow"); - Tooltip.SetDefault("'A large bow for your cute slime to wear on her head'"); - } - } - - public class PetAccessoryMittens : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Mittens"); - Tooltip.SetDefault("'Warm mittens for your cute slime's hands'"); - } - } - - public class PetAccessoryPartyHat : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Party Hat"); - Tooltip.SetDefault("'A party hat for your cute slime to wear on her head'"); - } - } - - public class PetAccessorySlimeHead : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Head Slime"); - Tooltip.SetDefault("'A slime plush that sits on your cute slime's head'"); - } - } - - public class PetAccessoryStaff : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Staff"); - Tooltip.SetDefault("'A plush staff for your cute slime to carry'"); - } - } - - public class PetAccessorySwallowedKey : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Swallowed Key"); - Tooltip.SetDefault("'A plush key for your cute slime to...carry?'"); - } - - protected override bool UseDefaultRecipe => false; - - protected override void SafeAddRecipes() - { - Recipe recipe = Mod.CreateRecipe(ItemID.GoldenKey); - recipe.AddIngredient(ModContent.ItemType()); - recipe.Register(); - } - } - - public class PetAccessoryTophat : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Top Hat"); - Tooltip.SetDefault("'A classy top hat for your cute slime to wear on her head'"); - } - } - - public class PetAccessoryToyBreastplate : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Knight's Breastplate"); - Tooltip.SetDefault("'A plush knight's breastplate for your cute slime to wear on her body'"); - } - } - - public class PetAccessoryToyShield : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Knight's Shield"); - Tooltip.SetDefault("'A plush knight's shield for your cute slime to carry'"); - } - } - - public class PetAccessoryToyMace : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Paladin's Mace"); - Tooltip.SetDefault("'A plush paladin's mace for your cute slime to carry'"); - } - } - - public class PetAccessoryToySpear : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Spartan's Spear"); - Tooltip.SetDefault("'A plush warrior's spear for your cute slime to carry'"); - } - } - - public class PetAccessoryToySword : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Knight's Sword"); - Tooltip.SetDefault("'A plush knight's sword for your cute slime to carry'"); - } - } - - public class PetAccessoryWizardHat : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Wizard Hat"); - Tooltip.SetDefault("'A brown wizard's hat for your cute slime to wear on her head'"); - } - } - - public class PetAccessoryXmasHat : PetAccessoryItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Santa Hat"); - Tooltip.SetDefault("'A festive hat for your cute slime to wear on hear head'"); - } - } - - /// - /// The type of pet vanity it is. Used for rendering, has separate lists - /// - public enum SlotType : byte - { - None = 0, //reserved - Body = 1, - Hat = 2, - Carried = 3, - Accessory = 4 - - //for Carried, it's actually only the front facing hand. For something like gloves or dual wielding, use Accessory instead - - //also, keep the sprite dimensions the same as the cute slimes - - //also they will be rendered in this order aswell (means that Carried can overlap with Body) - - //Each slot can have up to 255 accessories (total of 1020) - } - - /// - /// Contains data about all pet vanity accessories - /// - [Autoload(false)] - public class PetAccessory : ModType - { - private static Dictionary> petAccessoriesByType; - private static Dictionary> petAccessoryIdsByType; - - /// - /// Look-up table where the key is item ID and it returns the corresponding PetAccessory - /// - private static Dictionary petAccessoriesByItem; - - /// - /// Contains all pet vanity accessories - /// - private static List petAccessoryList; - - /// - /// Unique ID for this accessory (unique in the scope of a single SlotType) - /// - public byte ID { private set; get; } //The internal ID of the accessory - - private readonly string _name; - public override string Name => _name; //The item name associated with the accessory - - public int Type { private set; get; } //The item type associated with the accessory - - public SlotType Slot { private set; get; } - - private byte _altTextureIndex; - /// - /// Index for AltTextureSuffixes. No private setter, since it is set directly when used - /// - public byte AltTextureIndex - { - set => _altTextureIndex = value; - get => Utils.Clamp(_altTextureIndex, (byte)0, (byte)(AltTextureSuffixes.Count - 1)); - } - - public Vector2 Offset { private set; get; } - public bool PreDraw { private set; get; } - public byte Alpha { private set; get; } - public float Opacity => (255 - Alpha) / 255f; - public bool UseNoHair { private set; get; } - - /// - /// For deciding if it has a UI or not - /// - public bool HasAlts => AltTextureSuffixes.Count > 0; - - /// - /// For UI tooltips - /// - public List AltTextureSuffixes { private set; get; } - - /// - /// For UI only, the _Draw{number} stuff is done manually - /// - public List> AltTextures { private set; get; } - - public PetAccessory(SlotType slot, string name, float offsetX = 0f, float offsetY = 0f, bool preDraw = false, byte alpha = 0, bool useNoHair = false, List altTextures = null) - { - _name = "PetAccessory" + name; - if (!AssUtils.Instance.TryFind(Name, out ModItem modItem)) - { - throw new Exception($"Item called '{Name}' doesn't exist, are you sure you spelled it correctly?"); - } - - if (slot == SlotType.None) - { - throw new Exception($"Pet Accessory '{Name}' cannot have {nameof(SlotType.None)} as the slot!"); - } - Slot = slot; - Type = modItem.Type; - - AltTextureIndex = 0; - - Offset = new Vector2(offsetX, offsetY); - PreDraw = preDraw; - Alpha = alpha; - UseNoHair = useNoHair; - - AltTextureSuffixes = new List(); - if (altTextures != null && altTextures.Count > 0) - { - AltTextureSuffixes.AddRange(altTextures); - } - //add icons for UI - AltTextures = new List>(AltTextureSuffixes.Count); - for (int i = 0; i < AltTextureSuffixes.Count; i++) - { - AltTextures.Add(Main.dedServ ? null : AssUtils.Instance.Assets.Request("Items/PetAccessories/" + Name + AltTextureSuffixes[i])); - } - } - - /// - /// Has to be static so we can decide when to load it (has to be after content from this mod finished loading) - /// - public static void RegisterAccessories() - { - petAccessoriesByType = new Dictionary>(); - petAccessoryIdsByType = new Dictionary>(); - petAccessoriesByItem = new Dictionary(); - - petAccessoryList = new List(); - - //------------------------------------------------------------------- - //------------ADD PET ACCESSORY PROPERTIES HERE---------------------- - //------------------------------------------------------------------- - /* + //Add new classes here in alphabetic order + + public class PetAccessoryBowtie : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Bowtie"); + Tooltip.SetDefault("'A soft bowtie for your cute slime to wear on her chest'"); + } + } + + public class PetAccessoryBunnyEars : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Bunny Ears"); + Tooltip.SetDefault("'A pair of Easter bunny ears for your cute slime to wear on her head'"); + } + } + + public class PetAccessoryBunnySuit : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Bunny Suit"); + Tooltip.SetDefault("'A bunny(?) costume for your cute slime to wear on her chest'"); + } + } + + public class PetAccessoryCrown : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Crown"); + Tooltip.SetDefault("'A regal crown for your cute slime to wear on her head'"); + } + } + + public class PetAccessoryMetalHelmet : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Knight's Helmet"); + Tooltip.SetDefault("'A plush knight's helmet for your cute slime to wear on her head'"); + } + } + + public class PetAccessoryKitchenKnife : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Kitchen Knife"); + Tooltip.SetDefault("'A plush kitchen knife for your cute slime to carry'"); + } + } + + public class PetAccessoryHairBow : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Hair Bow"); + Tooltip.SetDefault("'A large bow for your cute slime to wear on her head'"); + } + } + + public class PetAccessoryMittens : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Mittens"); + Tooltip.SetDefault("'Warm mittens for your cute slime's hands'"); + } + } + + public class PetAccessoryPartyHat : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Party Hat"); + Tooltip.SetDefault("'A party hat for your cute slime to wear on her head'"); + } + } + + public class PetAccessorySlimeHead : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Head Slime"); + Tooltip.SetDefault("'A slime plush that sits on your cute slime's head'"); + } + } + + public class PetAccessoryStaff : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Staff"); + Tooltip.SetDefault("'A plush staff for your cute slime to carry'"); + } + } + + public class PetAccessorySwallowedKey : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Swallowed Key"); + Tooltip.SetDefault("'A plush key for your cute slime to...carry?'"); + } + + protected override bool UseDefaultRecipe => false; + + protected override void SafeAddRecipes() + { + Recipe recipe = Mod.CreateRecipe(ItemID.GoldenKey); + recipe.AddIngredient(ModContent.ItemType()); + recipe.Register(); + } + } + + public class PetAccessoryTophat : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Top Hat"); + Tooltip.SetDefault("'A classy top hat for your cute slime to wear on her head'"); + } + } + + public class PetAccessoryToyBreastplate : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Knight's Breastplate"); + Tooltip.SetDefault("'A plush knight's breastplate for your cute slime to wear on her body'"); + } + } + + public class PetAccessoryToyShield : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Knight's Shield"); + Tooltip.SetDefault("'A plush knight's shield for your cute slime to carry'"); + } + } + + public class PetAccessoryToyMace : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Paladin's Mace"); + Tooltip.SetDefault("'A plush paladin's mace for your cute slime to carry'"); + } + } + + public class PetAccessoryToySpear : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Spartan's Spear"); + Tooltip.SetDefault("'A plush warrior's spear for your cute slime to carry'"); + } + } + + public class PetAccessoryToySword : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Knight's Sword"); + Tooltip.SetDefault("'A plush knight's sword for your cute slime to carry'"); + } + } + + public class PetAccessoryWizardHat : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Wizard Hat"); + Tooltip.SetDefault("'A brown wizard's hat for your cute slime to wear on her head'"); + } + } + + public class PetAccessoryXmasHat : PetAccessoryItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Santa Hat"); + Tooltip.SetDefault("'A festive hat for your cute slime to wear on hear head'"); + } + } + + /// + /// The type of pet vanity it is. Used for rendering, has separate lists + /// + public enum SlotType : byte + { + None = 0, //reserved + Body = 1, + Hat = 2, + Carried = 3, + Accessory = 4 + + //for Carried, it's actually only the front facing hand. For something like gloves or dual wielding, use Accessory instead + + //also, keep the sprite dimensions the same as the cute slimes + + //also they will be rendered in this order aswell (means that Carried can overlap with Body) + + //Each slot can have up to 255 accessories (total of 1020) + } + + /// + /// Contains data about all pet vanity accessories + /// + [Autoload(false)] + public class PetAccessory : ModType + { + private static Dictionary> petAccessoriesByType; + private static Dictionary> petAccessoryIdsByType; + + /// + /// Look-up table where the key is item ID and it returns the corresponding PetAccessory + /// + private static Dictionary petAccessoriesByItem; + + /// + /// Contains all pet vanity accessories + /// + private static List petAccessoryList; + + /// + /// Unique ID for this accessory (unique in the scope of a single SlotType) + /// + public byte ID { private set; get; } //The internal ID of the accessory + + private readonly string _name; + public override string Name => _name; //The item name associated with the accessory + + public int Type { private set; get; } //The item type associated with the accessory + + public SlotType Slot { private set; get; } + + private byte _altTextureIndex; + /// + /// Index for AltTextureSuffixes. No private setter, since it is set directly when used + /// + public byte AltTextureIndex + { + set => _altTextureIndex = value; + get => Utils.Clamp(_altTextureIndex, (byte)0, (byte)(AltTextureSuffixes.Count - 1)); + } + + public Vector2 Offset { private set; get; } + public bool PreDraw { private set; get; } + public byte Alpha { private set; get; } + public float Opacity => (255 - Alpha) / 255f; + public bool UseNoHair { private set; get; } + + /// + /// For deciding if it has a UI or not + /// + public bool HasAlts => AltTextureSuffixes.Count > 0; + + /// + /// For UI tooltips + /// + public List AltTextureSuffixes { private set; get; } + + /// + /// For UI only, the _Draw{number} stuff is done manually + /// + public List> AltTextures { private set; get; } + + public PetAccessory(SlotType slot, string name, float offsetX = 0f, float offsetY = 0f, bool preDraw = false, byte alpha = 0, bool useNoHair = false, List altTextures = null) + { + _name = "PetAccessory" + name; + if (!AssUtils.Instance.TryFind(Name, out ModItem modItem)) + { + throw new Exception($"Item called '{Name}' doesn't exist, are you sure you spelled it correctly?"); + } + + if (slot == SlotType.None) + { + throw new Exception($"Pet Accessory '{Name}' cannot have {nameof(SlotType.None)} as the slot!"); + } + Slot = slot; + Type = modItem.Type; + + AltTextureIndex = 0; + + Offset = new Vector2(offsetX, offsetY); + PreDraw = preDraw; + Alpha = alpha; + UseNoHair = useNoHair; + + AltTextureSuffixes = new List(); + if (altTextures != null && altTextures.Count > 0) + { + AltTextureSuffixes.AddRange(altTextures); + } + //add icons for UI + AltTextures = new List>(AltTextureSuffixes.Count); + for (int i = 0; i < AltTextureSuffixes.Count; i++) + { + AltTextures.Add(Main.dedServ ? null : AssUtils.Instance.Assets.Request("Items/PetAccessories/" + Name + AltTextureSuffixes[i])); + } + } + + /// + /// Has to be static so we can decide when to load it (has to be after content from this mod finished loading) + /// + public static void RegisterAccessories() + { + petAccessoriesByType = new Dictionary>(); + petAccessoryIdsByType = new Dictionary>(); + petAccessoriesByItem = new Dictionary(); + + petAccessoryList = new List(); + + //------------------------------------------------------------------- + //------------ADD PET ACCESSORY PROPERTIES HERE---------------------- + //------------------------------------------------------------------- + /* * How to: * - call Add() with the appropriate parameters * - The first object is the mod instance this PetAccessory belongs to. In our case, our mod. @@ -351,324 +351,324 @@ public static void RegisterAccessories() * * - if you want to remove certain accessories from being usable for the system, comment the Add() call out with // */ - Mod mod = AssUtils.Instance; - - //BODY SLOT ACCESSORIES GO HERE - //------------------------------------------------ - Add(mod, new PetAccessory(SlotType.Body, name: "Bowtie", altTextures: new List() { "Red", "Orange", "Gold", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Gray", "Black" })); - Add(mod, new PetAccessory(SlotType.Body, name: "ToyBreastplate", altTextures: new List() { "Iron", "Gold" })); - Add(mod, new PetAccessory(SlotType.Body, name: "BunnySuit", altTextures: new List() { "Black", "Orange", "Gold", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Gray", "Red"})); - - //HAT SLOT ACCESSORIES GO HERE - //------------------------------------------------ - Add(mod, new PetAccessory(SlotType.Hat, name: "Crown", altTextures: new List() { "Gold", "Platinum" })); - Add(mod, new PetAccessory(SlotType.Hat, name: "HairBow", altTextures: new List() { "Red", "Orange", "Gold", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Gray", "Black" })); - Add(mod, new PetAccessory(SlotType.Hat, name: "MetalHelmet", useNoHair: true, altTextures: new List() { "Iron", "Gold" })); - Add(mod, new PetAccessory(SlotType.Hat, name: "SlimeHead", alpha: 56, altTextures: new List() { "Blue", "Purple", "Pink", "Pinky", "Red", "Yellow", "Green", "Black" })); - Add(mod, new PetAccessory(SlotType.Hat, name: "WizardHat", useNoHair: true)); - Add(mod, new PetAccessory(SlotType.Hat, name: "XmasHat", useNoHair: true, altTextures: new List() { "Red", "Green" })); - Add(mod, new PetAccessory(SlotType.Hat, name: "BunnyEars", preDraw: true)); - Add(mod, new PetAccessory(SlotType.Hat, name: "Tophat")); - Add(mod, new PetAccessory(SlotType.Hat, name: "PartyHat")); - - - //CARRIED SLOT ACCESSORIES GO HERE - //------------------------------------------------ - Add(mod, new PetAccessory(SlotType.Carried, name: "KitchenKnife", preDraw: true, altTextures: new List() { "Iron", "Gold" })); - Add(mod, new PetAccessory(SlotType.Carried, name: "Staff", preDraw: true, altTextures: new List() { "Amethyst", "Sapphire", "Emerald", "Ruby", "Amber", "Topaz", "Diamond", "Magic" })); - Add(mod, new PetAccessory(SlotType.Carried, name: "ToyMace", preDraw: true, altTextures: new List() { "Iron", "Gold" })); - Add(mod, new PetAccessory(SlotType.Carried, name: "ToySpear", preDraw: true, altTextures: new List() { "Iron", "Gold" })); - Add(mod, new PetAccessory(SlotType.Carried, name: "ToySword", preDraw: true, altTextures: new List() { "Iron", "Gold" })); - - //ACCESSORY SLOT ACCESSORIES GO HERE - //------------------------------------------------ - Add(mod, new PetAccessory(SlotType.Accessory, name: "Mittens", altTextures: new List() { "Red", "Orange", "Gold", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Gray", "Black" })); - Add(mod, new PetAccessory(SlotType.Accessory, name: "SwallowedKey", preDraw: true)); - Add(mod, new PetAccessory(SlotType.Accessory, name: "ToyShield", altTextures: new List() { "Iron", "Gold" })); - - CreateMaps(); - } - - public static void UnloadAccessories() - { - petAccessoriesByType = null; - petAccessoryIdsByType = null; - petAccessoriesByItem = null; - - petAccessoryList = null; - } - - /// - /// Called after , creates a map of pet vanity accessory -> ID for each SlotType - /// - public static void CreateMaps() - { - foreach (SlotType slotType in Enum.GetValues(typeof(SlotType))) - { - if (slotType != SlotType.None) - { - List tempAccessoryList = petAccessoriesByType[slotType]; - - if (!petAccessoryIdsByType.ContainsKey(slotType)) - { - petAccessoryIdsByType[slotType] = new List(); - } - - List tempIdList = petAccessoryIdsByType[slotType]; - for (int i = 0; i < tempAccessoryList.Count; i++) - { - tempIdList.Add(tempAccessoryList[i].ID); - } - } - } - - for (int i = 0; i < petAccessoryList.Count; i++) - { - PetAccessory petAccessory = petAccessoryList[i]; - petAccessoriesByItem[petAccessory.Type] = petAccessory; - } - } - - /// - /// Add a new pet vanity accessory to the game - /// - public static void Add(Mod mod, PetAccessory aPetAccessory) - { - mod.AddContent(aPetAccessory); //Makes ModContent.GetInstance and .Mod work - } - - /// - /// Called in . - /// Used to retreive the pet vanity accessory in the current slot of that current ID - /// - public static PetAccessory GetAccessoryFromID(SlotType slotType, byte id) //if something has the id, it always has the slottype available - { - return petAccessoriesByType[slotType][petAccessoryIdsByType[slotType].IndexOf(id)]; - } - - /// - /// Returns the pet vanity accessory corresponding to the item type. - /// - public static bool TryGetAccessoryFromItem(int type, out PetAccessory petAccessory) //since item types are unique, just look up in the global list - { - if (!ContentConfig.Instance.CuteSlimes) - { - petAccessory = null; - return false; - } - - return petAccessoriesByItem.TryGetValue(type, out petAccessory); - } - - public bool IsSameAs(PetAccessory other) - { - return ID == other.ID && Slot == other.Slot; - } - - public override string ToString() - { - return "ID: " + ID - + "; Col: " + AltTextureIndex - + "; Slo: " + Slot - + "; Nam: " + Name - + "; Typ: " + Type - + "; Off: " + Offset - + "; Pre: " + (PreDraw ? "y" : "n") - + "; Alp: " + Alpha - + "; NoH: " + (UseNoHair ? "y" : "n") - + "; Alt: " + (HasAlts ? "y" : "n"); - } - - protected sealed override void Register() - { - SlotType slotType = this.Slot; - - if (!petAccessoriesByType.ContainsKey(slotType)) - { - petAccessoriesByType[slotType] = new List(); - } - - //everything fine - List petAccessories = petAccessoriesByType[slotType]; - petAccessoriesByType[slotType].Add(this); - this.ID = (byte)petAccessories.Count; //Assign ID post-adding (so 0 represents "no accessory") - - petAccessoryList.Add(this); - - ModTypeLookup.Register(this); //Makes ModType related ModContent methods work - } - - public sealed override void SetupContent() => SetStaticDefaults(); - } - - /// - /// Class that all vanity accessories inherit from. Provides the functionality. - /// Has a default recipe which can be changed - /// - [Content(ContentType.CuteSlimes)] - public abstract class PetAccessoryItem : AssItem - { - public override void SetDefaults() - { - Item.width = 28; - Item.height = 30; - Item.maxStack = 1; - Item.rare = -11; - Item.useAnimation = 16; - Item.useTime = 16; - Item.useStyle = ItemUseStyleID.HoldUp; - Item.UseSound = SoundID.Item1; - Item.consumable = false; - Item.value = Item.sellPrice(silver: 30); - } - - private string Enum2string(SlotType e) - { - switch (e) - { - case SlotType.Body: - return "Worn on the body"; - case SlotType.Hat: - return "Worn on the head"; - case SlotType.Carried: - return "Carried"; - case SlotType.Accessory: - return "Worn as an accessory"; - case SlotType.None: - default: - return "UNINTENDED BEHAVIOR, REPORT TO DEV! (" + e + ")"; - } - } - - public override void ModifyTooltips(List tooltips) - { - if (PetAccessory.TryGetAccessoryFromItem(Item.type, out PetAccessory petAccessory)) - { - tooltips.Add(new TooltipLine(Mod, "Slot", Enum2string(petAccessory.Slot))); - - Player player = Main.LocalPlayer; - PetPlayer pPlayer = player.GetModPlayer(); - - if (pPlayer.HasValidSlimePet(out SlimePet slimePet)) - { - if (slimePet.IsSlotTypeBlacklisted[(byte)petAccessory.Slot]) - { - tooltips.Add(new TooltipLine(Mod, "Blacklisted", "This accessory type is disabled for your particular slime")); - } - } - else if (player.HasItem(Item.type)) - { - tooltips.Add(new TooltipLine(Mod, "NoUse", "You have no summoned slime to equip this on") - { - OverrideColor = Color.OrangeRed - }); - } - } - else - { - tooltips.Add(new TooltipLine(Mod, "Disabled", "This accessory type is not registered for use by the devs")); - } - } - - protected virtual bool UseDefaultRecipe => true; - - public sealed override void AddRecipes() - { - if (UseDefaultRecipe) - { - Recipe recipe = CreateRecipe(); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.Loom); - recipe.Register(); - } - - SafeAddRecipes(); - } - - protected virtual void SafeAddRecipes() - { - - } - - public override bool AltFunctionUse(Player player) - { - return true; - } - - public override bool CanUseItem(Player player) - { - //item not registered - if (!PetAccessory.TryGetAccessoryFromItem(Item.type, out PetAccessory petAccessory)) return false; - - PetPlayer pPlayer = player.GetModPlayer(); - //no valid slime pet found - if (!pPlayer.HasValidSlimePet(out _)) return false; - - //if a right click, enable usage - if (player.altFunctionUse == 2) return true; - //if a left click and no alts, enable usage - else if (!petAccessory.HasAlts) return true; - //else disable (if it has alts when left clicked) - return false; - } - - public override bool? UseItem(Player player) - { - PetPlayer pPlayer = player.GetModPlayer(); - - if (pPlayer.slimePetIndex < 0) - { - return true; - } - - if (player.whoAmI == Main.myPlayer && player.itemTime == 0 && PetAccessory.TryGetAccessoryFromItem(Item.type, out PetAccessory petAccessory)) - { - bool shouldReset = false; - if (player.altFunctionUse == 2) //right click use - { - if (pPlayer.ThreeTimesUseTime()) //true after three right clicks in 60 ticks - { - shouldReset = true; - } - } - //else normal left click use - - if (pPlayer.HasValidSlimePet(out SlimePet slimePet)) - { - //only client side - if (Main.netMode != NetmodeID.Server) - { - if (shouldReset && player.altFunctionUse == 2) - { - if (pPlayer.HasPetAccessories) - { - Array.Copy(pPlayer.petAccessoriesBySlots, pPlayer.lastPetAccessoriesBySlots, pPlayer.petAccessoriesBySlots.Length); - pPlayer.petAccessoriesBySlots = new (byte, byte)[pPlayer.petAccessoriesBySlots.Length]; - } - else - { - Array.Copy(pPlayer.lastPetAccessoriesBySlots, pPlayer.petAccessoriesBySlots, pPlayer.lastPetAccessoriesBySlots.Length); - pPlayer.lastPetAccessoriesBySlots = new (byte, byte)[pPlayer.lastPetAccessoriesBySlots.Length]; - } - - Projectile projectile = Main.projectile[pPlayer.slimePetIndex]; - //"dust" originating from the center, forming a circle and going outwards - for (double angle = 0; angle < MathHelper.TwoPi; angle += Math.PI / 6) - { - Dust.NewDustPerfect(projectile.Center - new Vector2(0f, projectile.height / 4), 16, new Vector2((float)-Math.Cos(angle), (float)Math.Sin(angle)) * 1.2f, 0, new Color(255, 255, 255), 1.6f); - } - } - else if (player.altFunctionUse != 2) - { - if (!slimePet.IsSlotTypeBlacklisted[(int)petAccessory.Slot]) - { - pPlayer.ToggleAccessory(petAccessory); - } - } - } - } - } - return true; - } - } + Mod mod = AssUtils.Instance; + + //BODY SLOT ACCESSORIES GO HERE + //------------------------------------------------ + Add(mod, new PetAccessory(SlotType.Body, name: "Bowtie", altTextures: new List() { "Red", "Orange", "Gold", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Gray", "Black" })); + Add(mod, new PetAccessory(SlotType.Body, name: "ToyBreastplate", altTextures: new List() { "Iron", "Gold" })); + Add(mod, new PetAccessory(SlotType.Body, name: "BunnySuit", altTextures: new List() { "Black", "Orange", "Gold", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Gray", "Red" })); + + //HAT SLOT ACCESSORIES GO HERE + //------------------------------------------------ + Add(mod, new PetAccessory(SlotType.Hat, name: "Crown", altTextures: new List() { "Gold", "Platinum" })); + Add(mod, new PetAccessory(SlotType.Hat, name: "HairBow", altTextures: new List() { "Red", "Orange", "Gold", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Gray", "Black" })); + Add(mod, new PetAccessory(SlotType.Hat, name: "MetalHelmet", useNoHair: true, altTextures: new List() { "Iron", "Gold" })); + Add(mod, new PetAccessory(SlotType.Hat, name: "SlimeHead", alpha: 56, altTextures: new List() { "Blue", "Purple", "Pink", "Pinky", "Red", "Yellow", "Green", "Black" })); + Add(mod, new PetAccessory(SlotType.Hat, name: "WizardHat", useNoHair: true)); + Add(mod, new PetAccessory(SlotType.Hat, name: "XmasHat", useNoHair: true, altTextures: new List() { "Red", "Green" })); + Add(mod, new PetAccessory(SlotType.Hat, name: "BunnyEars", preDraw: true)); + Add(mod, new PetAccessory(SlotType.Hat, name: "Tophat")); + Add(mod, new PetAccessory(SlotType.Hat, name: "PartyHat")); + + + //CARRIED SLOT ACCESSORIES GO HERE + //------------------------------------------------ + Add(mod, new PetAccessory(SlotType.Carried, name: "KitchenKnife", preDraw: true, altTextures: new List() { "Iron", "Gold" })); + Add(mod, new PetAccessory(SlotType.Carried, name: "Staff", preDraw: true, altTextures: new List() { "Amethyst", "Sapphire", "Emerald", "Ruby", "Amber", "Topaz", "Diamond", "Magic" })); + Add(mod, new PetAccessory(SlotType.Carried, name: "ToyMace", preDraw: true, altTextures: new List() { "Iron", "Gold" })); + Add(mod, new PetAccessory(SlotType.Carried, name: "ToySpear", preDraw: true, altTextures: new List() { "Iron", "Gold" })); + Add(mod, new PetAccessory(SlotType.Carried, name: "ToySword", preDraw: true, altTextures: new List() { "Iron", "Gold" })); + + //ACCESSORY SLOT ACCESSORIES GO HERE + //------------------------------------------------ + Add(mod, new PetAccessory(SlotType.Accessory, name: "Mittens", altTextures: new List() { "Red", "Orange", "Gold", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Gray", "Black" })); + Add(mod, new PetAccessory(SlotType.Accessory, name: "SwallowedKey", preDraw: true)); + Add(mod, new PetAccessory(SlotType.Accessory, name: "ToyShield", altTextures: new List() { "Iron", "Gold" })); + + CreateMaps(); + } + + public static void UnloadAccessories() + { + petAccessoriesByType = null; + petAccessoryIdsByType = null; + petAccessoriesByItem = null; + + petAccessoryList = null; + } + + /// + /// Called after , creates a map of pet vanity accessory -> ID for each SlotType + /// + public static void CreateMaps() + { + foreach (SlotType slotType in Enum.GetValues(typeof(SlotType))) + { + if (slotType != SlotType.None) + { + List tempAccessoryList = petAccessoriesByType[slotType]; + + if (!petAccessoryIdsByType.ContainsKey(slotType)) + { + petAccessoryIdsByType[slotType] = new List(); + } + + List tempIdList = petAccessoryIdsByType[slotType]; + for (int i = 0; i < tempAccessoryList.Count; i++) + { + tempIdList.Add(tempAccessoryList[i].ID); + } + } + } + + for (int i = 0; i < petAccessoryList.Count; i++) + { + PetAccessory petAccessory = petAccessoryList[i]; + petAccessoriesByItem[petAccessory.Type] = petAccessory; + } + } + + /// + /// Add a new pet vanity accessory to the game + /// + public static void Add(Mod mod, PetAccessory aPetAccessory) + { + mod.AddContent(aPetAccessory); //Makes ModContent.GetInstance and .Mod work + } + + /// + /// Called in . + /// Used to retreive the pet vanity accessory in the current slot of that current ID + /// + public static PetAccessory GetAccessoryFromID(SlotType slotType, byte id) //if something has the id, it always has the slottype available + { + return petAccessoriesByType[slotType][petAccessoryIdsByType[slotType].IndexOf(id)]; + } + + /// + /// Returns the pet vanity accessory corresponding to the item type. + /// + public static bool TryGetAccessoryFromItem(int type, out PetAccessory petAccessory) //since item types are unique, just look up in the global list + { + if (!ContentConfig.Instance.CuteSlimes) + { + petAccessory = null; + return false; + } + + return petAccessoriesByItem.TryGetValue(type, out petAccessory); + } + + public bool IsSameAs(PetAccessory other) + { + return ID == other.ID && Slot == other.Slot; + } + + public override string ToString() + { + return "ID: " + ID + + "; Col: " + AltTextureIndex + + "; Slo: " + Slot + + "; Nam: " + Name + + "; Typ: " + Type + + "; Off: " + Offset + + "; Pre: " + (PreDraw ? "y" : "n") + + "; Alp: " + Alpha + + "; NoH: " + (UseNoHair ? "y" : "n") + + "; Alt: " + (HasAlts ? "y" : "n"); + } + + protected sealed override void Register() + { + SlotType slotType = this.Slot; + + if (!petAccessoriesByType.ContainsKey(slotType)) + { + petAccessoriesByType[slotType] = new List(); + } + + //everything fine + List petAccessories = petAccessoriesByType[slotType]; + petAccessoriesByType[slotType].Add(this); + this.ID = (byte)petAccessories.Count; //Assign ID post-adding (so 0 represents "no accessory") + + petAccessoryList.Add(this); + + ModTypeLookup.Register(this); //Makes ModType related ModContent methods work + } + + public sealed override void SetupContent() => SetStaticDefaults(); + } + + /// + /// Class that all vanity accessories inherit from. Provides the functionality. + /// Has a default recipe which can be changed + /// + [Content(ContentType.CuteSlimes)] + public abstract class PetAccessoryItem : AssItem + { + public override void SetDefaults() + { + Item.width = 28; + Item.height = 30; + Item.maxStack = 1; + Item.rare = -11; + Item.useAnimation = 16; + Item.useTime = 16; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.UseSound = SoundID.Item1; + Item.consumable = false; + Item.value = Item.sellPrice(silver: 30); + } + + private string Enum2string(SlotType e) + { + switch (e) + { + case SlotType.Body: + return "Worn on the body"; + case SlotType.Hat: + return "Worn on the head"; + case SlotType.Carried: + return "Carried"; + case SlotType.Accessory: + return "Worn as an accessory"; + case SlotType.None: + default: + return "UNINTENDED BEHAVIOR, REPORT TO DEV! (" + e + ")"; + } + } + + public override void ModifyTooltips(List tooltips) + { + if (PetAccessory.TryGetAccessoryFromItem(Item.type, out PetAccessory petAccessory)) + { + tooltips.Add(new TooltipLine(Mod, "Slot", Enum2string(petAccessory.Slot))); + + Player player = Main.LocalPlayer; + PetPlayer pPlayer = player.GetModPlayer(); + + if (pPlayer.HasValidSlimePet(out SlimePet slimePet)) + { + if (slimePet.IsSlotTypeBlacklisted[(byte)petAccessory.Slot]) + { + tooltips.Add(new TooltipLine(Mod, "Blacklisted", "This accessory type is disabled for your particular slime")); + } + } + else if (player.HasItem(Item.type)) + { + tooltips.Add(new TooltipLine(Mod, "NoUse", "You have no summoned slime to equip this on") + { + OverrideColor = Color.OrangeRed + }); + } + } + else + { + tooltips.Add(new TooltipLine(Mod, "Disabled", "This accessory type is not registered for use by the devs")); + } + } + + protected virtual bool UseDefaultRecipe => true; + + public sealed override void AddRecipes() + { + if (UseDefaultRecipe) + { + Recipe recipe = CreateRecipe(); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.Loom); + recipe.Register(); + } + + SafeAddRecipes(); + } + + protected virtual void SafeAddRecipes() + { + + } + + public override bool AltFunctionUse(Player player) + { + return true; + } + + public override bool CanUseItem(Player player) + { + //item not registered + if (!PetAccessory.TryGetAccessoryFromItem(Item.type, out PetAccessory petAccessory)) return false; + + PetPlayer pPlayer = player.GetModPlayer(); + //no valid slime pet found + if (!pPlayer.HasValidSlimePet(out _)) return false; + + //if a right click, enable usage + if (player.altFunctionUse == 2) return true; + //if a left click and no alts, enable usage + else if (!petAccessory.HasAlts) return true; + //else disable (if it has alts when left clicked) + return false; + } + + public override bool? UseItem(Player player) + { + PetPlayer pPlayer = player.GetModPlayer(); + + if (pPlayer.slimePetIndex < 0) + { + return true; + } + + if (player.whoAmI == Main.myPlayer && player.itemTime == 0 && PetAccessory.TryGetAccessoryFromItem(Item.type, out PetAccessory petAccessory)) + { + bool shouldReset = false; + if (player.altFunctionUse == 2) //right click use + { + if (pPlayer.ThreeTimesUseTime()) //true after three right clicks in 60 ticks + { + shouldReset = true; + } + } + //else normal left click use + + if (pPlayer.HasValidSlimePet(out SlimePet slimePet)) + { + //only client side + if (Main.netMode != NetmodeID.Server) + { + if (shouldReset && player.altFunctionUse == 2) + { + if (pPlayer.HasPetAccessories) + { + Array.Copy(pPlayer.petAccessoriesBySlots, pPlayer.lastPetAccessoriesBySlots, pPlayer.petAccessoriesBySlots.Length); + pPlayer.petAccessoriesBySlots = new (byte, byte)[pPlayer.petAccessoriesBySlots.Length]; + } + else + { + Array.Copy(pPlayer.lastPetAccessoriesBySlots, pPlayer.petAccessoriesBySlots, pPlayer.lastPetAccessoriesBySlots.Length); + pPlayer.lastPetAccessoriesBySlots = new (byte, byte)[pPlayer.lastPetAccessoriesBySlots.Length]; + } + + Projectile projectile = Main.projectile[pPlayer.slimePetIndex]; + //"dust" originating from the center, forming a circle and going outwards + for (double angle = 0; angle < MathHelper.TwoPi; angle += Math.PI / 6) + { + Dust.NewDustPerfect(projectile.Center - new Vector2(0f, projectile.height / 4), 16, new Vector2((float)-Math.Cos(angle), (float)Math.Sin(angle)) * 1.2f, 0, new Color(255, 255, 255), 1.6f); + } + } + else if (player.altFunctionUse != 2) + { + if (!slimePet.IsSlotTypeBlacklisted[(int)petAccessory.Slot]) + { + pPlayer.ToggleAccessory(petAccessory); + } + } + } + } + } + return true; + } + } } diff --git a/Items/Pets/AbeeminationItem.cs b/Items/Pets/AbeeminationItem.cs index 40165410..4454a280 100644 --- a/Items/Pets/AbeeminationItem.cs +++ b/Items/Pets/AbeeminationItem.cs @@ -6,28 +6,28 @@ namespace AssortedCrazyThings.Items.Pets { - public class AbeeminationItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class AbeeminationItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Abeemination"); - Tooltip.SetDefault("Summons a friendly Abeemination to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Abeemination"); + Tooltip.SetDefault("Summons a friendly Abeemination to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(gold: 2); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(gold: 2); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Abeemination, 1).AddIngredient(ItemID.LifeFruit, 1).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Abeemination, 1).AddIngredient(ItemID.LifeFruit, 1).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/AlienHornetItem.cs b/Items/Pets/AlienHornetItem.cs index db06f116..211cd2a9 100644 --- a/Items/Pets/AlienHornetItem.cs +++ b/Items/Pets/AlienHornetItem.cs @@ -1,33 +1,33 @@ +using AssortedCrazyThings.Buffs.Pets; +using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using AssortedCrazyThings.Buffs.Pets; -using AssortedCrazyThings.Projectiles.Pets; namespace AssortedCrazyThings.Items.Pets { - [LegacyName("AlienHornet")] - public class AlienHornetItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("AlienHornet")] + public class AlienHornetItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Vortex Nectar"); - Tooltip.SetDefault("Summons a friendly Alien Hornet to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Vortex Nectar"); + Tooltip.SetDefault("Summons a friendly Alien Hornet to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(gold: 5); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(gold: 5); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Nectar, 1).AddIngredient(ItemID.FragmentVortex, 10).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Nectar, 1).AddIngredient(ItemID.FragmentVortex, 10).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/AnimatedTomeItem.cs b/Items/Pets/AnimatedTomeItem.cs index f04f0a4c..be06664d 100644 --- a/Items/Pets/AnimatedTomeItem.cs +++ b/Items/Pets/AnimatedTomeItem.cs @@ -1,28 +1,28 @@ -using Terraria; -using Terraria.ModLoader; using AssortedCrazyThings.Buffs.Pets; using AssortedCrazyThings.Projectiles.Pets; +using Terraria; +using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - public class AnimatedTomeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class AnimatedTomeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Animated Tome"); - Tooltip.SetDefault("Summons a friendly Animated Tome to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Animated Tome"); + Tooltip.SetDefault("Summons a friendly Animated Tome to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/AnomalocarisItem.cs b/Items/Pets/AnomalocarisItem.cs index c83de270..96cb6ce9 100644 --- a/Items/Pets/AnomalocarisItem.cs +++ b/Items/Pets/AnomalocarisItem.cs @@ -5,26 +5,26 @@ namespace AssortedCrazyThings.Items.Pets { - public class AnomalocarisItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class AnomalocarisItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ornery Shrimp"); - Tooltip.SetDefault("Summons an Anomalocaris to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ornery Shrimp"); + Tooltip.SetDefault("Summons an Anomalocaris to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.width = 32; - Item.height = 32; + public override void SafeSetDefaults() + { + Item.width = 32; + Item.height = 32; - Item.rare = -11; - Item.value = Item.sellPrice(gold: 3); //Zephyr fish price - } - } + Item.rare = -11; + Item.value = Item.sellPrice(gold: 3); //Zephyr fish price + } + } } diff --git a/Items/Pets/BabyCrimeraItem.cs b/Items/Pets/BabyCrimeraItem.cs index 2f2ba1e4..58fbb4c7 100644 --- a/Items/Pets/BabyCrimeraItem.cs +++ b/Items/Pets/BabyCrimeraItem.cs @@ -6,28 +6,28 @@ namespace AssortedCrazyThings.Items.Pets { - [LegacyName("BabyCrimera")] - public class BabyCrimeraItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("BabyCrimera")] + public class BabyCrimeraItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Juicy Vertebrae"); - Tooltip.SetDefault("Summons a baby Crimera to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Juicy Vertebrae"); + Tooltip.SetDefault("Summons a baby Crimera to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 20); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 20); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Vertebrae, 10).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Vertebrae, 10).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/BabyIchorStickerItem.cs b/Items/Pets/BabyIchorStickerItem.cs index 9d9d8676..9b55f620 100644 --- a/Items/Pets/BabyIchorStickerItem.cs +++ b/Items/Pets/BabyIchorStickerItem.cs @@ -6,28 +6,28 @@ namespace AssortedCrazyThings.Items.Pets { - [LegacyName("BabyIchorSticker")] - public class BabyIchorStickerItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("BabyIchorSticker")] + public class BabyIchorStickerItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sleeping Ichor Sticker"); - Tooltip.SetDefault("Summons a Baby Ichor Sticker to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sleeping Ichor Sticker"); + Tooltip.SetDefault("Summons a Baby Ichor Sticker to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 45, copper: 30); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 45, copper: 30); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Vertebrae, 15).AddIngredient(ItemID.Ichor, 5).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Vertebrae, 15).AddIngredient(ItemID.Ichor, 5).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/BabyOcramItem.cs b/Items/Pets/BabyOcramItem.cs index e03dbea0..3f2e483a 100644 --- a/Items/Pets/BabyOcramItem.cs +++ b/Items/Pets/BabyOcramItem.cs @@ -5,24 +5,24 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] - [LegacyName("BabyOcram")] - public class BabyOcramItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] + [LegacyName("BabyOcram")] + public class BabyOcramItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Baby Ocram"); - Tooltip.SetDefault("Summons a miniature Ocram that follows you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Ocram"); + Tooltip.SetDefault("Summons a miniature Ocram that follows you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 60); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 60); + } + } } diff --git a/Items/Pets/BrainofConfusionItem.cs b/Items/Pets/BrainofConfusionItem.cs index 07b4bc4b..b7e558a7 100644 --- a/Items/Pets/BrainofConfusionItem.cs +++ b/Items/Pets/BrainofConfusionItem.cs @@ -1,27 +1,26 @@ using AssortedCrazyThings.Buffs.Pets; using AssortedCrazyThings.Projectiles.Pets; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - [LegacyName("BrainofConfusion")] - public class BrainofConfusionItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("BrainofConfusion")] + public class BrainofConfusionItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Brain of Confusion"); - Tooltip.SetDefault("Summons a Brain of Confusion to follow aimlessly behind you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brain of Confusion"); + Tooltip.SetDefault("Summons a Brain of Confusion to follow aimlessly behind you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + } + } } diff --git a/Items/Pets/ChunkyItem.cs b/Items/Pets/ChunkyItem.cs index 515bee1a..6a4c8b40 100644 --- a/Items/Pets/ChunkyItem.cs +++ b/Items/Pets/ChunkyItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - public class ChunkyItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class ChunkyItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Chunky"); - Tooltip.SetDefault("Summons Chunky to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Chunky"); + Tooltip.SetDefault("Summons Chunky to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/ChunkyandMeatballItem.cs b/Items/Pets/ChunkyandMeatballItem.cs index ae0d804c..454ae9bd 100644 --- a/Items/Pets/ChunkyandMeatballItem.cs +++ b/Items/Pets/ChunkyandMeatballItem.cs @@ -1,34 +1,34 @@ +using AssortedCrazyThings.Buffs.Pets; +using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using AssortedCrazyThings.Buffs.Pets; -using AssortedCrazyThings.Projectiles.Pets; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - [LegacyName("ChunkyandMeatball")] - public class ChunkyandMeatballItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + [LegacyName("ChunkyandMeatball")] + public class ChunkyandMeatballItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Chunky and Meatball"); - Tooltip.SetDefault("Summons a pair of inseperable brothers to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Chunky and Meatball"); + Tooltip.SetDefault("Summons a pair of inseperable brothers to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 4); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 4); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient().AddIngredient().AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient().AddIngredient().AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/CompanionDungeonSoulPetItem.cs b/Items/Pets/CompanionDungeonSoulPetItem.cs index 05a1a718..760c59df 100644 --- a/Items/Pets/CompanionDungeonSoulPetItem.cs +++ b/Items/Pets/CompanionDungeonSoulPetItem.cs @@ -8,47 +8,47 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.Bosses)] - public class CompanionDungeonSoulPetItem : CaughtDungeonSoulBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Companion Soul"); - Tooltip.SetDefault("Summons a friendly Soul to light your way" - + "\nLight pet slot"); - - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 6)); - ItemID.Sets.AnimatesAsSoul[Item.type] = true; - - ItemID.Sets.ItemNoGravity[Item.type] = true; - } - - public override void SafeSetDefaults() - { - Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); - frame2CounterCount = -1; - animatedTextureSelect = 0; - - Item.width = 26; - Item.height = 28; - Item.rare = -11; - Item.maxStack = 1; - Item.noUseGraphic = true; - - Item.value = Item.sellPrice(silver: 50); - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - player.AddBuff(Item.buffType, 3600); - return false; - } - - //hardmode recipe - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.Bone, 2).AddTile(TileID.CrystalBall).Register(); - CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddTile(TileID.CrystalBall).Register(); - } - } + [Content(ContentType.Bosses)] + public class CompanionDungeonSoulPetItem : CaughtDungeonSoulBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Companion Soul"); + Tooltip.SetDefault("Summons a friendly Soul to light your way" + + "\nLight pet slot"); + + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 6)); + ItemID.Sets.AnimatesAsSoul[Item.type] = true; + + ItemID.Sets.ItemNoGravity[Item.type] = true; + } + + public override void SafeSetDefaults() + { + Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); + frame2CounterCount = -1; + animatedTextureSelect = 0; + + Item.width = 26; + Item.height = 28; + Item.rare = -11; + Item.maxStack = 1; + Item.noUseGraphic = true; + + Item.value = Item.sellPrice(silver: 50); + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + player.AddBuff(Item.buffType, 3600); + return false; + } + + //hardmode recipe + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.Bone, 2).AddTile(TileID.CrystalBall).Register(); + CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddTile(TileID.CrystalBall).Register(); + } + } } diff --git a/Items/Pets/CompanionDungeonSoulPetItem2.cs b/Items/Pets/CompanionDungeonSoulPetItem2.cs index 0457667c..a524f841 100644 --- a/Items/Pets/CompanionDungeonSoulPetItem2.cs +++ b/Items/Pets/CompanionDungeonSoulPetItem2.cs @@ -6,35 +6,35 @@ namespace AssortedCrazyThings.Items.Pets { - public class CompanionDungeonSoulPetItem2 : CompanionDungeonSoulPetItem - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Items/Pets/CompanionDungeonSoulPetItem"; //use fixed texture - } - } + public class CompanionDungeonSoulPetItem2 : CompanionDungeonSoulPetItem + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Items/Pets/CompanionDungeonSoulPetItem"; //use fixed texture + } + } - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); - Tooltip.SetDefault("Summons a friendly Soul to light your way" - + "\nPet slot"); - } + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + Tooltip.SetDefault("Summons a friendly Soul to light your way" + + "\nPet slot"); + } - public override void SafeSetDefaults() - { - base.SafeSetDefaults(); + public override void SafeSetDefaults() + { + base.SafeSetDefaults(); - Item.shoot = ModContent.ProjectileType(); - Item.buffType = ModContent.BuffType(); - } + Item.shoot = ModContent.ProjectileType(); + Item.buffType = ModContent.BuffType(); + } - //hardmode recipe - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddTile(TileID.CrystalBall).Register(); - } - } + //hardmode recipe + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddTile(TileID.CrystalBall).Register(); + } + } } diff --git a/Items/Pets/CursedSkullItem.cs b/Items/Pets/CursedSkullItem.cs index fc69f817..700787dd 100644 --- a/Items/Pets/CursedSkullItem.cs +++ b/Items/Pets/CursedSkullItem.cs @@ -1,34 +1,34 @@ +using AssortedCrazyThings.Buffs.Pets; +using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using AssortedCrazyThings.Buffs.Pets; -using AssortedCrazyThings.Projectiles.Pets; namespace AssortedCrazyThings.Items.Pets { - [LegacyName("CursedSkull")] - public class CursedSkullItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CursedSkull")] + public class CursedSkullItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Inert Skull"); - Tooltip.SetDefault("Summons a friendly cursed skull that follows you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Inert Skull"); + Tooltip.SetDefault("Summons a friendly cursed skull that follows you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Bone, 10).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Bone, 10).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/CuteGastropodItem.cs b/Items/Pets/CuteGastropodItem.cs index a4e7b5d9..dc706f30 100644 --- a/Items/Pets/CuteGastropodItem.cs +++ b/Items/Pets/CuteGastropodItem.cs @@ -1,27 +1,27 @@ -using Terraria; -using Terraria.ModLoader; using AssortedCrazyThings.Buffs.Pets; using AssortedCrazyThings.Projectiles.Pets; +using Terraria; +using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.CuteSlimes)] - [LegacyName("CuteGastropod")] - public class CuteGastropodItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.CuteSlimes)] + [LegacyName("CuteGastropod")] + public class CuteGastropodItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mysterious Pod"); - Tooltip.SetDefault("Summons a friendly Cute Gastropod to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mysterious Pod"); + Tooltip.SetDefault("Summons a friendly Cute Gastropod to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + } + } } diff --git a/Items/Pets/CuteLamiaPetItem.cs b/Items/Pets/CuteLamiaPetItem.cs index cbe3b0aa..ec0e8ef0 100644 --- a/Items/Pets/CuteLamiaPetItem.cs +++ b/Items/Pets/CuteLamiaPetItem.cs @@ -1,27 +1,27 @@ -using Terraria; -using Terraria.ModLoader; using AssortedCrazyThings.Buffs.Pets; using AssortedCrazyThings.Projectiles.Pets; +using Terraria; +using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class CuteLamiaPetItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class CuteLamiaPetItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shaking Snake Pot"); - Tooltip.SetDefault("Summons a small, friendly snake to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shaking Snake Pot"); + Tooltip.SetDefault("Summons a small, friendly snake to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeBlackItem.cs b/Items/Pets/CuteSlimes/CuteSlimeBlackItem.cs index 05960673..0ceaf226 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeBlackItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeBlackItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeBlackNew")] - public class CuteSlimeBlackItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeBlackNew")] + public class CuteSlimeBlackItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Black Slime"); - Tooltip.SetDefault("Summons a friendly Cute Black Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Black Slime"); + Tooltip.SetDefault("Summons a friendly Cute Black Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeBlueItem.cs b/Items/Pets/CuteSlimes/CuteSlimeBlueItem.cs index f5083b25..6149972c 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeBlueItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeBlueItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeBlueNew")] - public class CuteSlimeBlueItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeBlueNew")] + public class CuteSlimeBlueItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Blue Slime"); - Tooltip.SetDefault("Summons a friendly Cute Blue Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Blue Slime"); + Tooltip.SetDefault("Summons a friendly Cute Blue Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeCorruptItem.cs b/Items/Pets/CuteSlimes/CuteSlimeCorruptItem.cs index 2e5db62e..cbb2f4d0 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeCorruptItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeCorruptItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeCorruptNew")] - public class CuteSlimeCorruptItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeCorruptNew")] + public class CuteSlimeCorruptItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Corrupt Slime"); - Tooltip.SetDefault("Summons a friendly Cute Corrupt Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Corrupt Slime"); + Tooltip.SetDefault("Summons a friendly Cute Corrupt Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeCrimsonItem.cs b/Items/Pets/CuteSlimes/CuteSlimeCrimsonItem.cs index b4481c8e..bc26403b 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeCrimsonItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeCrimsonItem.cs @@ -1,21 +1,20 @@ using AssortedCrazyThings.Buffs.Pets.CuteSlimes; using AssortedCrazyThings.Projectiles.Pets.CuteSlimes; -using Terraria; using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeCrimsonNew")] - public class CuteSlimeCrimsonItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeCrimsonNew")] + public class CuteSlimeCrimsonItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Crimson Slime"); - Tooltip.SetDefault("Summons a friendly Cute Crimson Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Crimson Slime"); + Tooltip.SetDefault("Summons a friendly Cute Crimson Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeDungeonItem.cs b/Items/Pets/CuteSlimes/CuteSlimeDungeonItem.cs index d8f44b60..5c8bb1b2 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeDungeonItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeDungeonItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeDungeonNew")] - public class CuteSlimeDungeonItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeDungeonNew")] + public class CuteSlimeDungeonItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Dungeon Slime"); - Tooltip.SetDefault("Summons a friendly Cute Dungeon Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Dungeon Slime"); + Tooltip.SetDefault("Summons a friendly Cute Dungeon Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeGreenItem.cs b/Items/Pets/CuteSlimes/CuteSlimeGreenItem.cs index 99a0e71d..9a2e76c0 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeGreenItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeGreenItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeGreenNew")] - public class CuteSlimeGreenItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeGreenNew")] + public class CuteSlimeGreenItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Green Slime"); - Tooltip.SetDefault("Summons a friendly Cute Green Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Green Slime"); + Tooltip.SetDefault("Summons a friendly Cute Green Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeIceItem.cs b/Items/Pets/CuteSlimes/CuteSlimeIceItem.cs index 67a5e750..b60d7a14 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeIceItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeIceItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeIceNew")] - public class CuteSlimeIceItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeIceNew")] + public class CuteSlimeIceItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Ice Slime"); - Tooltip.SetDefault("Summons a friendly Cute Ice Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Ice Slime"); + Tooltip.SetDefault("Summons a friendly Cute Ice Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeIlluminantItem.cs b/Items/Pets/CuteSlimes/CuteSlimeIlluminantItem.cs index b2534797..b72512d7 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeIlluminantItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeIlluminantItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeIlluminantNew")] - public class CuteSlimeIlluminantItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeIlluminantNew")] + public class CuteSlimeIlluminantItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Illuminant Slime"); - Tooltip.SetDefault("Summons a friendly Cute Illuminant Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Illuminant Slime"); + Tooltip.SetDefault("Summons a friendly Cute Illuminant Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeItem.cs b/Items/Pets/CuteSlimes/CuteSlimeItem.cs index 5eef2f94..145d46bc 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeItem.cs @@ -8,80 +8,80 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [Content(ContentType.CuteSlimes)] - public abstract class CuteSlimeItem : SimplePetItemBase - { - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } + [Content(ContentType.CuteSlimes)] + public abstract class CuteSlimeItem : SimplePetItemBase + { + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } - public override void ModifyTooltips(List tooltips) - { - try - { - PetPlayer pPlayer = Main.LocalPlayer.GetModPlayer(); - if (pPlayer.HasValidSlimePet(out SlimePet slimePet)) - { - Projectile projectile = Main.projectile[pPlayer.slimePetIndex]; - //checks if this item is infact a pet slime summoning item - if (Item.shoot == projectile.type) - { - for (byte slotNumber = 1; slotNumber < 5; slotNumber++) //0 is None, reserved - { - string tooltip; + public override void ModifyTooltips(List tooltips) + { + try + { + PetPlayer pPlayer = Main.LocalPlayer.GetModPlayer(); + if (pPlayer.HasValidSlimePet(out SlimePet slimePet)) + { + Projectile projectile = Main.projectile[pPlayer.slimePetIndex]; + //checks if this item is infact a pet slime summoning item + if (Item.shoot == projectile.type) + { + for (byte slotNumber = 1; slotNumber < 5; slotNumber++) //0 is None, reserved + { + string tooltip; - if (slimePet.IsSlotTypeBlacklisted[slotNumber]) - { - tooltip = "Blacklisted"; - } - else - { - if (pPlayer.TryGetAccessoryInSlot(slotNumber, out PetAccessory petAccessory)) - { - //type = PetAccessory.Items[accessory - 1]; - Item itemTemp = new Item(); - itemTemp.SetDefaults(petAccessory.Type); - tooltip = itemTemp.Name.StartsWith("Cute ") ? itemTemp.Name.Substring(5) : itemTemp.Name; - tooltip += petAccessory.HasAlts ? " (" + petAccessory.AltTextureSuffixes[petAccessory.AltTextureIndex] + ")" : ""; - } - else - { - tooltip = "None"; - } - } + if (slimePet.IsSlotTypeBlacklisted[slotNumber]) + { + tooltip = "Blacklisted"; + } + else + { + if (pPlayer.TryGetAccessoryInSlot(slotNumber, out PetAccessory petAccessory)) + { + //type = PetAccessory.Items[accessory - 1]; + Item itemTemp = new Item(); + itemTemp.SetDefaults(petAccessory.Type); + tooltip = itemTemp.Name.StartsWith("Cute ") ? itemTemp.Name.Substring(5) : itemTemp.Name; + tooltip += petAccessory.HasAlts ? " (" + petAccessory.AltTextureSuffixes[petAccessory.AltTextureIndex] + ")" : ""; + } + else + { + tooltip = "None"; + } + } - tooltips.Add(new TooltipLine(Mod, ((SlotType)slotNumber).ToString(), Enum2String(slotNumber) + tooltip)); - } - } - } - } - catch (Exception e) - { - Main.NewText(e, Color.Red); - } - } + tooltips.Add(new TooltipLine(Mod, ((SlotType)slotNumber).ToString(), Enum2String(slotNumber) + tooltip)); + } + } + } + } + catch (Exception e) + { + Main.NewText(e, Color.Red); + } + } - private string Enum2String(byte b) - { - if (b == (byte)SlotType.Hat) - { - return "Hat slot: "; - } - if (b == (byte)SlotType.Body) - { - return "Body slot: "; - } - if (b == (byte)SlotType.Carried) - { - return "Carry slot: "; - } - if (b == (byte)SlotType.Accessory) - { - return "Accessory slot: "; - } - return "UNINTENDED BEHAVIOR, REPORT TO DEV! (" + b + ")"; - } - } + private string Enum2String(byte b) + { + if (b == (byte)SlotType.Hat) + { + return "Hat slot: "; + } + if (b == (byte)SlotType.Body) + { + return "Body slot: "; + } + if (b == (byte)SlotType.Carried) + { + return "Carry slot: "; + } + if (b == (byte)SlotType.Accessory) + { + return "Accessory slot: "; + } + return "UNINTENDED BEHAVIOR, REPORT TO DEV! (" + b + ")"; + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeJungleItem.cs b/Items/Pets/CuteSlimes/CuteSlimeJungleItem.cs index bc405be7..ed18e77d 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeJungleItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeJungleItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeJungleNew")] - public class CuteSlimeJungleItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeJungleNew")] + public class CuteSlimeJungleItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Jungle Slime"); - Tooltip.SetDefault("Summons a friendly Cute Jungle Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Jungle Slime"); + Tooltip.SetDefault("Summons a friendly Cute Jungle Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeLavaItem.cs b/Items/Pets/CuteSlimes/CuteSlimeLavaItem.cs index 3719931b..da3aea21 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeLavaItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeLavaItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeLavaNew")] - public class CuteSlimeLavaItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeLavaNew")] + public class CuteSlimeLavaItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Lava Slime"); - Tooltip.SetDefault("Summons a friendly Cute Lava Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Lava Slime"); + Tooltip.SetDefault("Summons a friendly Cute Lava Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimePinkItem.cs b/Items/Pets/CuteSlimes/CuteSlimePinkItem.cs index ed984e12..f1ac1a8f 100644 --- a/Items/Pets/CuteSlimes/CuteSlimePinkItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimePinkItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimePinkNew")] - public class CuteSlimePinkItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimePinkNew")] + public class CuteSlimePinkItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Pink Slime"); - Tooltip.SetDefault("Summons a friendly Cute Pink Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Pink Slime"); + Tooltip.SetDefault("Summons a friendly Cute Pink Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimePrincessItem.cs b/Items/Pets/CuteSlimes/CuteSlimePrincessItem.cs index 6fd06a6c..562db605 100644 --- a/Items/Pets/CuteSlimes/CuteSlimePrincessItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimePrincessItem.cs @@ -1,27 +1,26 @@ using AssortedCrazyThings.Buffs.Pets.CuteSlimes; using AssortedCrazyThings.Projectiles.Pets.CuteSlimes; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimePrincessNew")] - public class CuteSlimePrincessItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimePrincessNew")] + public class CuteSlimePrincessItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Princess Slime"); - Tooltip.SetDefault("Summons a friendly Cute Princess Slime to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Princess Slime"); + Tooltip.SetDefault("Summons a friendly Cute Princess Slime to follow you"); + } - public override void SafeSetDefaults() - { - Item.value = Item.sellPrice(copper: 20); - } - } + public override void SafeSetDefaults() + { + Item.value = Item.sellPrice(copper: 20); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimePurpleItem.cs b/Items/Pets/CuteSlimes/CuteSlimePurpleItem.cs index bdf55492..7536057d 100644 --- a/Items/Pets/CuteSlimes/CuteSlimePurpleItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimePurpleItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimePurpleNew")] - public class CuteSlimePurpleItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimePurpleNew")] + public class CuteSlimePurpleItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Purple Slime"); - Tooltip.SetDefault("Summons a friendly Cute Purple Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Purple Slime"); + Tooltip.SetDefault("Summons a friendly Cute Purple Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeQueenItem.cs b/Items/Pets/CuteSlimes/CuteSlimeQueenItem.cs index bdbd9046..e5206316 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeQueenItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeQueenItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [Content(ContentType.CuteSlimes)] - public class CuteSlimeQueenItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.CuteSlimes)] + public class CuteSlimeQueenItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Queen Slime"); - Tooltip.SetDefault("Summons a friendly Cute Queen Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Queen Slime"); + Tooltip.SetDefault("Summons a friendly Cute Queen Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeRainbowItem.cs b/Items/Pets/CuteSlimes/CuteSlimeRainbowItem.cs index f4006424..90d9c4e6 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeRainbowItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeRainbowItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeRainbowNew")] - public class CuteSlimeRainbowItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeRainbowNew")] + public class CuteSlimeRainbowItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Rainbow Slime"); - Tooltip.SetDefault("Summons a friendly Cute Rainbow Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Rainbow Slime"); + Tooltip.SetDefault("Summons a friendly Cute Rainbow Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeRedItem.cs b/Items/Pets/CuteSlimes/CuteSlimeRedItem.cs index 838ebad4..944a8d4e 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeRedItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeRedItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeRedNew")] - public class CuteSlimeRedItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeRedNew")] + public class CuteSlimeRedItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Red Slime"); - Tooltip.SetDefault("Summons a friendly Cute Red Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Red Slime"); + Tooltip.SetDefault("Summons a friendly Cute Red Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeSandItem.cs b/Items/Pets/CuteSlimes/CuteSlimeSandItem.cs index 7596e4d0..8783ddaf 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeSandItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeSandItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeSandNew")] - public class CuteSlimeSandItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeSandNew")] + public class CuteSlimeSandItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Sand Slime"); - Tooltip.SetDefault("Summons a friendly Cute Sand Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Sand Slime"); + Tooltip.SetDefault("Summons a friendly Cute Sand Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeToxicItem.cs b/Items/Pets/CuteSlimes/CuteSlimeToxicItem.cs index 6aaf59b8..6e12fbf7 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeToxicItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeToxicItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeToxicNew")] - public class CuteSlimeToxicItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeToxicNew")] + public class CuteSlimeToxicItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Toxic Slime"); - Tooltip.SetDefault("Summons a friendly Cute Toxic Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Toxic Slime"); + Tooltip.SetDefault("Summons a friendly Cute Toxic Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeXmasItem.cs b/Items/Pets/CuteSlimes/CuteSlimeXmasItem.cs index 8425322b..8d579450 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeXmasItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeXmasItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeXmasNew")] - public class CuteSlimeXmasItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeXmasNew")] + public class CuteSlimeXmasItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Christmas Slime"); - Tooltip.SetDefault("Summons a friendly Cute Christmas Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Christmas Slime"); + Tooltip.SetDefault("Summons a friendly Cute Christmas Slime to follow you"); + } + } } diff --git a/Items/Pets/CuteSlimes/CuteSlimeYellowItem.cs b/Items/Pets/CuteSlimes/CuteSlimeYellowItem.cs index 69b74f30..3922b064 100644 --- a/Items/Pets/CuteSlimes/CuteSlimeYellowItem.cs +++ b/Items/Pets/CuteSlimes/CuteSlimeYellowItem.cs @@ -4,17 +4,17 @@ namespace AssortedCrazyThings.Items.Pets.CuteSlimes { - [LegacyName("CuteSlimeYellowNew")] - public class CuteSlimeYellowItem : CuteSlimeItem - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("CuteSlimeYellowNew")] + public class CuteSlimeYellowItem : CuteSlimeItem + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Cute Yellow Slime"); - Tooltip.SetDefault("Summons a friendly Cute Yellow Slime to follow you"); - } - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Cute Yellow Slime"); + Tooltip.SetDefault("Summons a friendly Cute Yellow Slime to follow you"); + } + } } diff --git a/Items/Pets/DemonHeartItem.cs b/Items/Pets/DemonHeartItem.cs index af70380e..576b4623 100644 --- a/Items/Pets/DemonHeartItem.cs +++ b/Items/Pets/DemonHeartItem.cs @@ -1,33 +1,33 @@ +using AssortedCrazyThings.Buffs.Pets; +using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using AssortedCrazyThings.Buffs.Pets; -using AssortedCrazyThings.Projectiles.Pets; namespace AssortedCrazyThings.Items.Pets { - [LegacyName("DemonHeart")] - public class DemonHeartItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("DemonHeart")] + public class DemonHeartItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Demon Heart"); - Tooltip.SetDefault("Summons a friendly Demon Heart to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Demon Heart"); + Tooltip.SetDefault("Summons a friendly Demon Heart to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(gold: 2); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(gold: 2); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.DemonHeart, 1).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.DemonHeart, 1).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/DetachedHungryItem.cs b/Items/Pets/DetachedHungryItem.cs index 35925594..63f4e2e5 100644 --- a/Items/Pets/DetachedHungryItem.cs +++ b/Items/Pets/DetachedHungryItem.cs @@ -6,28 +6,28 @@ namespace AssortedCrazyThings.Items.Pets { - [LegacyName("DetachedHungry")] - public class DetachedHungryItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("DetachedHungry")] + public class DetachedHungryItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Unconscious Hungry"); - Tooltip.SetDefault("Summons a detached Hungry to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Unconscious Hungry"); + Tooltip.SetDefault("Summons a detached Hungry to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(gold: 1); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(gold: 1); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.HellstoneBar, 4).AddIngredient(ItemID.RottenChunk, 10).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.HellstoneBar, 4).AddIngredient(ItemID.RottenChunk, 10).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/DocileDemonEyeItem.cs b/Items/Pets/DocileDemonEyeItem.cs index 4c1a41a3..3361c117 100644 --- a/Items/Pets/DocileDemonEyeItem.cs +++ b/Items/Pets/DocileDemonEyeItem.cs @@ -6,32 +6,32 @@ namespace AssortedCrazyThings.Items.Pets { - [LegacyName("DocileDemonEye")] - public class DocileDemonEyeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("DocileDemonEye")] + public class DocileDemonEyeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Docile Demon Eye"); - Tooltip.SetDefault("Summons a docile Demon Eye to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Docile Demon Eye"); + Tooltip.SetDefault("Summons a docile Demon Eye to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.width = 34; - Item.height = 22; - Item.rare = -11; - Item.value = Item.sellPrice(silver: 10); - } + public override void SafeSetDefaults() + { + Item.width = 34; + Item.height = 22; + Item.rare = -11; + Item.value = Item.sellPrice(silver: 10); + } - public override void AddRecipes() - { - //regular recipe, dont delete - CreateRecipe(1).AddIngredient(ItemID.BlackLens, 1).AddIngredient(ItemID.Lens, 1).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + //regular recipe, dont delete + CreateRecipe(1).AddIngredient(ItemID.BlackLens, 1).AddIngredient(ItemID.Lens, 1).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/DrumstickElementalItem.cs b/Items/Pets/DrumstickElementalItem.cs index 8bb0bb3f..b5fdf2a9 100644 --- a/Items/Pets/DrumstickElementalItem.cs +++ b/Items/Pets/DrumstickElementalItem.cs @@ -6,28 +6,28 @@ namespace AssortedCrazyThings.Items.Pets { - public class DrumstickElementalItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class DrumstickElementalItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Magical Drumstick"); - Tooltip.SetDefault("Summons a delicious Drumstick Elemental to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Magical Drumstick"); + Tooltip.SetDefault("Summons a delicious Drumstick Elemental to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 7, copper: 50); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 7, copper: 50); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Duck).AddTile(TileID.CookingPots).Register(); - CreateRecipe(1).AddIngredient(ItemID.MallardDuck).AddTile(TileID.CookingPots).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Duck).AddTile(TileID.CookingPots).Register(); + CreateRecipe(1).AddIngredient(ItemID.MallardDuck).AddTile(TileID.CookingPots).Register(); + } + } } diff --git a/Items/Pets/DynamiteBunnyItem.cs b/Items/Pets/DynamiteBunnyItem.cs index 1df06dc5..4f2709db 100644 --- a/Items/Pets/DynamiteBunnyItem.cs +++ b/Items/Pets/DynamiteBunnyItem.cs @@ -6,40 +6,40 @@ namespace AssortedCrazyThings.Items.Pets { - public class DynamiteBunnyItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class DynamiteBunnyItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Dynamite Carrot"); - Tooltip.SetDefault("Summons a Dynamite Bunny to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dynamite Carrot"); + Tooltip.SetDefault("Summons a Dynamite Bunny to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.width = 14; - Item.height = 32; + public override void SafeSetDefaults() + { + Item.width = 14; + Item.height = 32; - Item.rare = -11; - Item.value = Item.sellPrice(silver: 4); - } + Item.rare = -11; + Item.value = Item.sellPrice(silver: 4); + } - public override void AddRecipes() - { - var recipe = CreateRecipe(); - recipe.AddIngredient(ItemID.Dynamite); - recipe.AddIngredient(ItemID.Carrot); - recipe.AddTile(TileID.DemonAltar); - recipe.Register(); + public override void AddRecipes() + { + var recipe = CreateRecipe(); + recipe.AddIngredient(ItemID.Dynamite); + recipe.AddIngredient(ItemID.Carrot); + recipe.AddTile(TileID.DemonAltar); + recipe.Register(); - recipe = CreateRecipe(); - recipe.AddIngredient(ItemID.ExplosiveBunny); - recipe.AddTile(TileID.DemonAltar); - recipe.Register(); - } - } + recipe = CreateRecipe(); + recipe.AddIngredient(ItemID.ExplosiveBunny); + recipe.AddTile(TileID.DemonAltar); + recipe.Register(); + } + } } diff --git a/Items/Pets/EnchantedSwordItem.cs b/Items/Pets/EnchantedSwordItem.cs index b9f2f3f9..5aac38d3 100644 --- a/Items/Pets/EnchantedSwordItem.cs +++ b/Items/Pets/EnchantedSwordItem.cs @@ -1,33 +1,33 @@ +using AssortedCrazyThings.Buffs.Pets; +using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using AssortedCrazyThings.Buffs.Pets; -using AssortedCrazyThings.Projectiles.Pets; namespace AssortedCrazyThings.Items.Pets { - [LegacyName("EnchantedSword")] - public class EnchantedSwordItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("EnchantedSword")] + public class EnchantedSwordItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Enchanted Sword"); - Tooltip.SetDefault("Summons an Enchanted Sword to watch over you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Enchanted Sword"); + Tooltip.SetDefault("Summons an Enchanted Sword to watch over you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 40); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 40); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.EnchantedSword, 1).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.EnchantedSword, 1).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/FailureSlimeItem.cs b/Items/Pets/FailureSlimeItem.cs index e332036a..0dd028e0 100644 --- a/Items/Pets/FailureSlimeItem.cs +++ b/Items/Pets/FailureSlimeItem.cs @@ -1,29 +1,28 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; using AssortedCrazyThings.Buffs.Pets; using AssortedCrazyThings.Projectiles.Pets; +using Terraria; +using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - public class FailureSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class FailureSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slimy Skull"); - Tooltip.SetDefault("Summons a strange creature to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slimy Skull"); + Tooltip.SetDefault("Summons a strange creature to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 40); //TODO value - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 40); //TODO value + } - //TODO obtain (grab bag?) - } + //TODO obtain (grab bag?) + } } diff --git a/Items/Pets/FairySlimeItem.cs b/Items/Pets/FairySlimeItem.cs index a6e4fa93..1e070bcb 100644 --- a/Items/Pets/FairySlimeItem.cs +++ b/Items/Pets/FairySlimeItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.FriendlyNPCs)] - public class FairySlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.FriendlyNPCs)] + public class FairySlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Fairy Slime"); - Tooltip.SetDefault("Summons a friendly Fairy Slime to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Fairy Slime"); + Tooltip.SetDefault("Summons a friendly Fairy Slime to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/FairySwarmItem.cs b/Items/Pets/FairySwarmItem.cs index a57d2665..813a422c 100644 --- a/Items/Pets/FairySwarmItem.cs +++ b/Items/Pets/FairySwarmItem.cs @@ -7,27 +7,27 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class FairySwarmItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class FairySwarmItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottle of Assorted Fairies"); - Tooltip.SetDefault("Summons several fairies to swarm around you"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottle of Assorted Fairies"); + Tooltip.SetDefault("Summons several fairies to swarm around you"); - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 4)); - ItemID.Sets.AnimatesAsSoul[Item.type] = true; - } + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 4)); + ItemID.Sets.AnimatesAsSoul[Item.type] = true; + } - public override void SafeSetDefaults() - { - Item.noUseGraphic = true; - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.noUseGraphic = true; + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/GhostMartianItem.cs b/Items/Pets/GhostMartianItem.cs index 42eaa26b..f40972b9 100644 --- a/Items/Pets/GhostMartianItem.cs +++ b/Items/Pets/GhostMartianItem.cs @@ -6,32 +6,32 @@ namespace AssortedCrazyThings.Items.Pets { - public class GhostMartianItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class GhostMartianItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("K-II Meter"); - Tooltip.SetDefault("Summons a vengeful invader's ghost to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("K-II Meter"); + Tooltip.SetDefault("Summons a vengeful invader's ghost to follow you"); + } - public override void SafeSetDefaults() - { - Item.noUseGraphic = true; - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } + public override void SafeSetDefaults() + { + Item.noUseGraphic = true; + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } - public override void AddRecipes() - { - CreateRecipe() - .AddIngredient(ItemID.MartianConduitPlating, 25) - .AddCondition(Recipe.Condition.InGraveyardBiome) - .AddTile(TileID.Anvils) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe() + .AddIngredient(ItemID.MartianConduitPlating, 25) + .AddCondition(Recipe.Condition.InGraveyardBiome) + .AddTile(TileID.Anvils) + .Register(); + } + } } diff --git a/Items/Pets/GobletItem.cs b/Items/Pets/GobletItem.cs index aa047dd8..d6e26fc8 100644 --- a/Items/Pets/GobletItem.cs +++ b/Items/Pets/GobletItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class GobletItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class GobletItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Goblet Battle Standard"); - Tooltip.SetDefault("Summons a tiny goblin to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Goblet Battle Standard"); + Tooltip.SetDefault("Summons a tiny goblin to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 10); + } + } } diff --git a/Items/Pets/HornedSlimeItem.cs b/Items/Pets/HornedSlimeItem.cs index 0daf3ef7..d0283747 100644 --- a/Items/Pets/HornedSlimeItem.cs +++ b/Items/Pets/HornedSlimeItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - public class HornedSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class HornedSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Horned Slime"); - Tooltip.SetDefault("Summons a friendly Horned Slime to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Horned Slime"); + Tooltip.SetDefault("Summons a friendly Horned Slime to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/IlluminantSlimeItem.cs b/Items/Pets/IlluminantSlimeItem.cs index 61e09d47..5b8d13a1 100644 --- a/Items/Pets/IlluminantSlimeItem.cs +++ b/Items/Pets/IlluminantSlimeItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class IlluminantSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class IlluminantSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Illuminant Slime"); - Tooltip.SetDefault("Summons a friendly Illuminant Slime to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Illuminant Slime"); + Tooltip.SetDefault("Summons a friendly Illuminant Slime to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/JoyousSlimeItem.cs b/Items/Pets/JoyousSlimeItem.cs index 1a6918f9..35402411 100644 --- a/Items/Pets/JoyousSlimeItem.cs +++ b/Items/Pets/JoyousSlimeItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.FriendlyNPCs)] - public class JoyousSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.FriendlyNPCs)] + public class JoyousSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Joyous Slime"); - Tooltip.SetDefault("Summons a friendly Joyous Slime to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Joyous Slime"); + Tooltip.SetDefault("Summons a friendly Joyous Slime to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/LifelikeMechanicalFrogItem.cs b/Items/Pets/LifelikeMechanicalFrogItem.cs index aee634c3..6af392ab 100644 --- a/Items/Pets/LifelikeMechanicalFrogItem.cs +++ b/Items/Pets/LifelikeMechanicalFrogItem.cs @@ -1,34 +1,34 @@ +using AssortedCrazyThings.Buffs.Pets; +using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using AssortedCrazyThings.Buffs.Pets; -using AssortedCrazyThings.Projectiles.Pets; namespace AssortedCrazyThings.Items.Pets { - [LegacyName("LifelikeMechanicalFrog")] - public class LifelikeMechanicalFrogItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("LifelikeMechanicalFrog")] + public class LifelikeMechanicalFrogItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Lifelike Mechanical Frog"); - Tooltip.SetDefault("Summons a friendly Frog to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Lifelike Mechanical Frog"); + Tooltip.SetDefault("Summons a friendly Frog to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Frog, 1).AddTile(TileID.Anvils).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Frog, 1).AddTile(TileID.Anvils).Register(); + } + } } diff --git a/Items/Pets/LilWrapsItem.cs b/Items/Pets/LilWrapsItem.cs index 5dfcfb8c..e0f124da 100644 --- a/Items/Pets/LilWrapsItem.cs +++ b/Items/Pets/LilWrapsItem.cs @@ -5,26 +5,26 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class LilWrapsItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class LilWrapsItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gilded Coffin"); - Tooltip.SetDefault("Summons Lil' Wraps to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gilded Coffin"); + Tooltip.SetDefault("Summons Lil' Wraps to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.width = 20; - Item.height = 26; - Item.rare = -11; - Item.value = Item.sellPrice(silver: 10); - } - } + public override void SafeSetDefaults() + { + Item.width = 20; + Item.height = 26; + Item.rare = -11; + Item.value = Item.sellPrice(silver: 10); + } + } } diff --git a/Items/Pets/MeatballItem.cs b/Items/Pets/MeatballItem.cs index 397842d0..7e7f83a7 100644 --- a/Items/Pets/MeatballItem.cs +++ b/Items/Pets/MeatballItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - public class MeatballItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class MeatballItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Meatball"); - Tooltip.SetDefault("Summons Meatball to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Meatball"); + Tooltip.SetDefault("Summons Meatball to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/MetroidPetItem.cs b/Items/Pets/MetroidPetItem.cs index d9153e20..9f737b53 100644 --- a/Items/Pets/MetroidPetItem.cs +++ b/Items/Pets/MetroidPetItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - public class MetroidPetItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class MetroidPetItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Parasite Container"); - Tooltip.SetDefault("Summons a space parasite to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Parasite Container"); + Tooltip.SetDefault("Summons a space parasite to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/MiniAntlionItem.cs b/Items/Pets/MiniAntlionItem.cs index fe57788d..7490ea27 100644 --- a/Items/Pets/MiniAntlionItem.cs +++ b/Items/Pets/MiniAntlionItem.cs @@ -5,24 +5,24 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class MiniAntlionItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class MiniAntlionItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Antlion Egg"); - Tooltip.SetDefault("Summons a friendly Baby Antlion to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Antlion Egg"); + Tooltip.SetDefault("Summons a friendly Baby Antlion to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 10); + } + } } diff --git a/Items/Pets/MiniMegalodonItem.cs b/Items/Pets/MiniMegalodonItem.cs index fc186cc2..304114bb 100644 --- a/Items/Pets/MiniMegalodonItem.cs +++ b/Items/Pets/MiniMegalodonItem.cs @@ -5,24 +5,24 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] - [LegacyName("MiniMegalodon")] - public class MiniMegalodonItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] + [LegacyName("MiniMegalodon")] + public class MiniMegalodonItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Small Megalodon Tooth"); - Tooltip.SetDefault("Summons a friendly Mini Megalodon that follows you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Small Megalodon Tooth"); + Tooltip.SetDefault("Summons a friendly Mini Megalodon that follows you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 10); + } + } } diff --git a/Items/Pets/NumberMuncherItem.cs b/Items/Pets/NumberMuncherItem.cs index ce8c7c62..450db4eb 100644 --- a/Items/Pets/NumberMuncherItem.cs +++ b/Items/Pets/NumberMuncherItem.cs @@ -6,30 +6,30 @@ namespace AssortedCrazyThings.Items.Pets { - public class NumberMuncherItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class NumberMuncherItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Archaic Storage Device"); - Tooltip.SetDefault("Summons an educated amphibian that follows you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Archaic Storage Device"); + Tooltip.SetDefault("Summons an educated amphibian that follows you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(0, 0, 1, 20); //two statues - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(0, 0, 1, 20); //two statues + } - public override void AddRecipes() - { - CreateRecipe() - .AddIngredient(ItemID.AlphabetStatue1, 2) - .AddTile(TileID.Bookcases) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe() + .AddIngredient(ItemID.AlphabetStatue1, 2) + .AddTile(TileID.Bookcases) + .Register(); + } + } } diff --git a/Items/Pets/OceanSlimeItem.cs b/Items/Pets/OceanSlimeItem.cs index 82eeb1e3..56bf2fab 100644 --- a/Items/Pets/OceanSlimeItem.cs +++ b/Items/Pets/OceanSlimeItem.cs @@ -5,24 +5,24 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - public class OceanSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class OceanSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Ocean Slime"); - Tooltip.SetDefault("Summons a friendly Ocean Slime to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Ocean Slime"); + Tooltip.SetDefault("Summons a friendly Ocean Slime to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/PetCultistItem.cs b/Items/Pets/PetCultistItem.cs index 793085a3..107b8307 100644 --- a/Items/Pets/PetCultistItem.cs +++ b/Items/Pets/PetCultistItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class PetCultistItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetCultistItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tiny Ominous Coin"); - Tooltip.SetDefault("Summons a tiny cultist to follow you and heal when injured"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tiny Ominous Coin"); + Tooltip.SetDefault("Summons a tiny cultist to follow you and heal when injured"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/PetDestroyerItem.cs b/Items/Pets/PetDestroyerItem.cs index 0bf4c5b7..1243e1d7 100644 --- a/Items/Pets/PetDestroyerItem.cs +++ b/Items/Pets/PetDestroyerItem.cs @@ -2,84 +2,84 @@ using AssortedCrazyThings.Projectiles.Pets; using System; using Terraria; -using Terraria.ModLoader; using Terraria.DataStructures; +using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class PetDestroyerItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetDestroyerItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Destroyer's Core"); - Tooltip.SetDefault("Summons a tiny Destroyer and two tiny Probes to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Destroyer's Core"); + Tooltip.SetDefault("Summons a tiny Destroyer and two tiny Probes to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.rare = -11; + } - public static void Spawn(Player player, int buffIndex = -1, Item item = null) - { - if (Main.myPlayer != player.whoAmI) - { - //Clientside only - return; - } + public static void Spawn(Player player, int buffIndex = -1, Item item = null) + { + if (Main.myPlayer != player.whoAmI) + { + //Clientside only + return; + } - IEntitySource source; - if (buffIndex > -1) - { - source = player.GetProjectileSource_Buff(buffIndex); - } - else if (item != null) - { - source = player.GetProjectileSource_Item(item); - } - else - { - return; - } + IEntitySource source; + if (buffIndex > -1) + { + source = player.GetProjectileSource_Buff(buffIndex); + } + else if (item != null) + { + source = player.GetProjectileSource_Item(item); + } + else + { + return; + } - int probe = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.owner == player.whoAmI && (Array.IndexOf(PetDestroyerBase.wormTypes, proj.type) > -1 || proj.type == probe)) - { - proj.Kill(); - } - } + int probe = ModContent.ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.owner == player.whoAmI && (Array.IndexOf(PetDestroyerBase.wormTypes, proj.type) > -1 || proj.type == probe)) + { + proj.Kill(); + } + } - //prevIndex stuff only needed for when replacing/summoning the minion segments individually + //prevIndex stuff only needed for when replacing/summoning the minion segments individually - int index = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, player.direction, -player.gravDir, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); - int prevIndex = index; - int off = PetDestroyerBase.DISTANCE_BETWEEN_SEGMENTS; + int index = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, player.direction, -player.gravDir, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + int prevIndex = index; + int off = PetDestroyerBase.DISTANCE_BETWEEN_SEGMENTS; - for (int i = 1; i <= PetDestroyerBase.NUMBER_OF_BODY_SEGMENTS; i++) - { - index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); - Main.projectile[prevIndex].localAI[1] = index; - prevIndex = index; - off += PetDestroyerBase.DISTANCE_BETWEEN_SEGMENTS; - index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); - Main.projectile[prevIndex].localAI[1] = index; - prevIndex = index; - off += PetDestroyerBase.DISTANCE_BETWEEN_SEGMENTS; - } - index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); - Main.projectile[prevIndex].localAI[1] = index; + for (int i = 1; i <= PetDestroyerBase.NUMBER_OF_BODY_SEGMENTS; i++) + { + index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); + Main.projectile[prevIndex].localAI[1] = index; + prevIndex = index; + off += PetDestroyerBase.DISTANCE_BETWEEN_SEGMENTS; + index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); + Main.projectile[prevIndex].localAI[1] = index; + prevIndex = index; + off += PetDestroyerBase.DISTANCE_BETWEEN_SEGMENTS; + } + index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); + Main.projectile[prevIndex].localAI[1] = index; - //spawn probes - Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, 0f, probe, 0, 0f, player.whoAmI, 0f, 0f); - Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, 0f, probe, 0, 0f, player.whoAmI, 0f, ((player.whoAmI + 1) * 13) % PetDestroyerProbe.AttackDelay); - } - } + //spawn probes + Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, 0f, probe, 0, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, 0f, probe, 0, 0f, player.whoAmI, 0f, ((player.whoAmI + 1) * 13) % PetDestroyerProbe.AttackDelay); + } + } } diff --git a/Items/Pets/PetEaterofWorldsItem.cs b/Items/Pets/PetEaterofWorldsItem.cs index d7992aef..ee510a07 100644 --- a/Items/Pets/PetEaterofWorldsItem.cs +++ b/Items/Pets/PetEaterofWorldsItem.cs @@ -2,80 +2,79 @@ using AssortedCrazyThings.Projectiles.Pets; using System; using Terraria; -using Terraria.ModLoader; using Terraria.DataStructures; -using Microsoft.Xna.Framework; +using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class PetEaterofWorldsItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetEaterofWorldsItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cracked Worm Egg"); - Tooltip.SetDefault("Summons a tiny Eater of Worlds to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cracked Worm Egg"); + Tooltip.SetDefault("Summons a tiny Eater of Worlds to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - } + public override void SafeSetDefaults() + { + Item.rare = -11; + } - public static void Spawn(Player player, int buffIndex = -1, Item item = null) - { - if (Main.myPlayer != player.whoAmI) - { - //Clientside only - return; - } + public static void Spawn(Player player, int buffIndex = -1, Item item = null) + { + if (Main.myPlayer != player.whoAmI) + { + //Clientside only + return; + } - IEntitySource source; - if (buffIndex > -1) - { - source = player.GetProjectileSource_Buff(buffIndex); - } - else if (item != null) - { - source = player.GetProjectileSource_Item(item); - } - else - { - return; - } + IEntitySource source; + if (buffIndex > -1) + { + source = player.GetProjectileSource_Buff(buffIndex); + } + else if (item != null) + { + source = player.GetProjectileSource_Item(item); + } + else + { + return; + } - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.owner == player.whoAmI && Array.IndexOf(PetEaterofWorldsBase.wormTypes, proj.type) > -1) - { - proj.Kill(); - } - } + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.owner == player.whoAmI && Array.IndexOf(PetEaterofWorldsBase.wormTypes, proj.type) > -1) + { + proj.Kill(); + } + } - //prevIndex stuff only needed for when replacing/summoning the minion segments individually + //prevIndex stuff only needed for when replacing/summoning the minion segments individually - int index = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, player.direction, -player.gravDir, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); - int prevIndex = index; - int off = PetEaterofWorldsBase.DISTANCE_BETWEEN_SEGMENTS; + int index = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, player.direction, -player.gravDir, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + int prevIndex = index; + int off = PetEaterofWorldsBase.DISTANCE_BETWEEN_SEGMENTS; - for (int i = 1; i <= PetEaterofWorldsBase.NUMBER_OF_BODY_SEGMENTS; i++) - { - index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); - Main.projectile[prevIndex].localAI[1] = index; - prevIndex = index; - off += PetEaterofWorldsBase.DISTANCE_BETWEEN_SEGMENTS; - index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); - Main.projectile[prevIndex].localAI[1] = index; - prevIndex = index; - off += PetEaterofWorldsBase.DISTANCE_BETWEEN_SEGMENTS; - } - index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); - Main.projectile[prevIndex].localAI[1] = index; - } - } + for (int i = 1; i <= PetEaterofWorldsBase.NUMBER_OF_BODY_SEGMENTS; i++) + { + index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); + Main.projectile[prevIndex].localAI[1] = index; + prevIndex = index; + off += PetEaterofWorldsBase.DISTANCE_BETWEEN_SEGMENTS; + index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); + Main.projectile[prevIndex].localAI[1] = index; + prevIndex = index; + off += PetEaterofWorldsBase.DISTANCE_BETWEEN_SEGMENTS; + } + index = Projectile.NewProjectile(source, player.Center.X - off * player.direction, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, index, 0f); + Main.projectile[prevIndex].localAI[1] = index; + } + } } diff --git a/Items/Pets/PetFishronItem.cs b/Items/Pets/PetFishronItem.cs index 7e92ad7d..daf1644d 100644 --- a/Items/Pets/PetFishronItem.cs +++ b/Items/Pets/PetFishronItem.cs @@ -5,24 +5,24 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class PetFishronItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetFishronItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Soggy Fish Cake"); - Tooltip.SetDefault("Summons a friendly Fishron that flies with you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soggy Fish Cake"); + Tooltip.SetDefault("Summons a friendly Fishron that flies with you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/PetGoldfishItem.cs b/Items/Pets/PetGoldfishItem.cs index 1a64338a..57e2e07e 100644 --- a/Items/Pets/PetGoldfishItem.cs +++ b/Items/Pets/PetGoldfishItem.cs @@ -6,29 +6,29 @@ namespace AssortedCrazyThings.Items.Pets { - public class PetGoldfishItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetGoldfishItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Possessed Fish Idol"); - Tooltip.SetDefault("Summons a goldfish that follows you" - + "\n'You feel like you lost something important in obtaining this idol...'" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Possessed Fish Idol"); + Tooltip.SetDefault("Summons a goldfish that follows you" + + "\n'You feel like you lost something important in obtaining this idol...'" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.FishStatue, 1).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.FishStatue, 1).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/PetGolemHeadItem.cs b/Items/Pets/PetGolemHeadItem.cs index ccaf0718..6d18f045 100644 --- a/Items/Pets/PetGolemHeadItem.cs +++ b/Items/Pets/PetGolemHeadItem.cs @@ -5,24 +5,24 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class PetGolemHeadItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetGolemHeadItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Replica Golem Head"); - Tooltip.SetDefault("Summons a Replica Golem Head to watch over you" - + "\nShoots bouncing fireballs at nearby enemies"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Replica Golem Head"); + Tooltip.SetDefault("Summons a Replica Golem Head to watch over you" + + "\nShoots bouncing fireballs at nearby enemies"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/PetHarvesterItem.cs b/Items/Pets/PetHarvesterItem.cs index 51528da5..8ebdfdca 100644 --- a/Items/Pets/PetHarvesterItem.cs +++ b/Items/Pets/PetHarvesterItem.cs @@ -7,30 +7,30 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.Bosses)] - public class PetHarvesterItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.Bosses)] + public class PetHarvesterItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stubborn Bird Soul"); - Tooltip.SetDefault("Summons a stubborn bird to follow you"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stubborn Bird Soul"); + Tooltip.SetDefault("Summons a stubborn bird to follow you"); - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 6)); - ItemID.Sets.AnimatesAsSoul[Item.type] = true; + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 6)); + ItemID.Sets.AnimatesAsSoul[Item.type] = true; - ItemID.Sets.ItemNoGravity[Item.type] = true; - } + ItemID.Sets.ItemNoGravity[Item.type] = true; + } - public override void SafeSetDefaults() - { - Item.noUseGraphic = true; - Item.rare = ItemRarityID.Master; - Item.master = true; - Item.value = Item.sellPrice(0, 5); - } - } + public override void SafeSetDefaults() + { + Item.noUseGraphic = true; + Item.rare = ItemRarityID.Master; + Item.master = true; + Item.value = Item.sellPrice(0, 5); + } + } } diff --git a/Items/Pets/PetMoonItem.cs b/Items/Pets/PetMoonItem.cs index e980595e..e1290c4a 100644 --- a/Items/Pets/PetMoonItem.cs +++ b/Items/Pets/PetMoonItem.cs @@ -6,31 +6,31 @@ namespace AssortedCrazyThings.Items.Pets { - public class PetMoonItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetMoonItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Moon"); - Tooltip.SetDefault("Summons a small moon that provides you with constant moonlight" - + "\nShows the current moon cycle in the buff tip" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Moon"); + Tooltip.SetDefault("Summons a small moon that provides you with constant moonlight" + + "\nShows the current moon cycle in the buff tip" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.width = 20; - Item.height = 26; - Item.rare = -11; - Item.value = Item.sellPrice(gold: 7); - } + public override void SafeSetDefaults() + { + Item.width = 20; + Item.height = 26; + Item.rare = -11; + Item.value = Item.sellPrice(gold: 7); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Bottle).AddIngredient(ItemID.MoonStone).AddIngredient(ItemID.Sextant).AddTile(TileID.CrystalBall).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Bottle).AddIngredient(ItemID.MoonStone).AddIngredient(ItemID.Sextant).AddTile(TileID.CrystalBall).Register(); + } + } } diff --git a/Items/Pets/PetPlanteraItem.cs b/Items/Pets/PetPlanteraItem.cs index d7e567e5..a8179d99 100644 --- a/Items/Pets/PetPlanteraItem.cs +++ b/Items/Pets/PetPlanteraItem.cs @@ -2,72 +2,71 @@ using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class PetPlanteraItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PetPlanteraItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Potted Plantera Seed"); - Tooltip.SetDefault("Summons a Plantera Sprout to watch over you" - + "\n'It's a mean and green'"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Potted Plantera Seed"); + Tooltip.SetDefault("Summons a Plantera Sprout to watch over you" + + "\n'It's a mean and green'"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } - public static void Spawn(Player player, int buffIndex = -1, Item item = null) - { - if (Main.myPlayer != player.whoAmI) - { - //Clientside only - return; - } + public static void Spawn(Player player, int buffIndex = -1, Item item = null) + { + if (Main.myPlayer != player.whoAmI) + { + //Clientside only + return; + } - IEntitySource source; - if (buffIndex > -1) - { - source = player.GetProjectileSource_Buff(buffIndex); - } - else if (item != null) - { - source = player.GetProjectileSource_Item(item); - } - else - { - return; - } + IEntitySource source; + if (buffIndex > -1) + { + source = player.GetProjectileSource_Buff(buffIndex); + } + else if (item != null) + { + source = player.GetProjectileSource_Item(item); + } + else + { + return; + } - int tentacle = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.owner == player.whoAmI && proj.type == tentacle) - { - proj.Kill(); - } - } + int tentacle = ModContent.ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.owner == player.whoAmI && proj.type == tentacle) + { + proj.Kill(); + } + } - Projectile.NewProjectile(source, player.position.X + (player.width / 2), player.position.Y + player.height / 3, 0f, 0f, ModContent.ProjectileType(), PetPlanteraProj.ContactDamage, 1f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, player.position.X + (player.width / 2), player.position.Y + player.height / 3, 0f, 0f, ModContent.ProjectileType(), PetPlanteraProj.ContactDamage, 1f, player.whoAmI, 0f, 0f); - if (player.ownedProjectileCounts[tentacle] == 0) - { - for (int i = 0; i < 4; i++) - { - Projectile.NewProjectile(source, player.position.X + (player.width / 2), player.position.Y + player.height / 3, 0f, 0f, tentacle, 1, 0f, player.whoAmI, 0f, 0f); - } - } - } - } + if (player.ownedProjectileCounts[tentacle] == 0) + { + for (int i = 0; i < 4; i++) + { + Projectile.NewProjectile(source, player.position.X + (player.width / 2), player.position.Y + player.height / 3, 0f, 0f, tentacle, 1, 0f, player.whoAmI, 0f, 0f); + } + } + } + } } diff --git a/Items/Pets/PetQueenSlimeItem.cs b/Items/Pets/PetQueenSlimeItem.cs index 15c2716d..1f1aa404 100644 --- a/Items/Pets/PetQueenSlimeItem.cs +++ b/Items/Pets/PetQueenSlimeItem.cs @@ -5,22 +5,22 @@ namespace AssortedCrazyThings.Items.Pets { - public class PetQueenSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetQueenSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Playful Slimelings"); - Tooltip.SetDefault("Summons a trio of slimelings to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Playful Slimelings"); + Tooltip.SetDefault("Summons a trio of slimelings to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.buyPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.buyPrice(copper: 10); + } + } } diff --git a/Items/Pets/PetSunItem.cs b/Items/Pets/PetSunItem.cs index be68cbd1..f1f669e2 100644 --- a/Items/Pets/PetSunItem.cs +++ b/Items/Pets/PetSunItem.cs @@ -6,30 +6,30 @@ namespace AssortedCrazyThings.Items.Pets { - public class PetSunItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetSunItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Sun"); - Tooltip.SetDefault("Summons a small sun that provides you with constant sunlight" - + "\nShows the current time in the buff tip"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Sun"); + Tooltip.SetDefault("Summons a small sun that provides you with constant sunlight" + + "\nShows the current time in the buff tip"); + } - public override void SafeSetDefaults() - { - Item.width = 20; - Item.height = 26; - Item.rare = -11; - Item.value = Item.sellPrice(gold: 9, silver: 20); - } + public override void SafeSetDefaults() + { + Item.width = 20; + Item.height = 26; + Item.rare = -11; + Item.value = Item.sellPrice(gold: 9, silver: 20); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Bottle).AddIngredient(ItemID.SunStone).AddIngredient(ItemID.Hellstone, 25).AddTile(TileID.CrystalBall).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Bottle).AddIngredient(ItemID.SunStone).AddIngredient(ItemID.Hellstone, 25).AddTile(TileID.CrystalBall).Register(); + } + } } diff --git a/Items/Pets/PetSunMoonItem.cs b/Items/Pets/PetSunMoonItem.cs index c11dad78..8f1f4a2e 100644 --- a/Items/Pets/PetSunMoonItem.cs +++ b/Items/Pets/PetSunMoonItem.cs @@ -6,32 +6,32 @@ namespace AssortedCrazyThings.Items.Pets { - public class PetSunMoonItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class PetSunMoonItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Sun and Moon"); - Tooltip.SetDefault("Summons a small sun and moon that provide you with constant light" - + "\nShows the current time in the buff tip" - + "\nShows the current moon cycle in the buff tip" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Sun and Moon"); + Tooltip.SetDefault("Summons a small sun and moon that provide you with constant light" + + "\nShows the current time in the buff tip" + + "\nShows the current moon cycle in the buff tip" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.width = 38; - Item.height = 26; - Item.rare = -11; - Item.value = Item.sellPrice(gold: 16, silver: 20); - } + public override void SafeSetDefaults() + { + Item.width = 38; + Item.height = 26; + Item.rare = -11; + Item.value = Item.sellPrice(gold: 16, silver: 20); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddTile(TileID.CrystalBall).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType()).AddIngredient(ModContent.ItemType()).AddTile(TileID.CrystalBall).Register(); + } + } } diff --git a/Items/Pets/PigronataItem.cs b/Items/Pets/PigronataItem.cs index 3fa9a121..a872c804 100644 --- a/Items/Pets/PigronataItem.cs +++ b/Items/Pets/PigronataItem.cs @@ -1,33 +1,33 @@ +using AssortedCrazyThings.Buffs.Pets; +using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using AssortedCrazyThings.Projectiles.Pets; -using AssortedCrazyThings.Buffs.Pets; namespace AssortedCrazyThings.Items.Pets { - public class PigronataItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class PigronataItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pigronata"); - Tooltip.SetDefault("Summons a friendly Pigronata to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pigronata"); + Tooltip.SetDefault("Summons a friendly Pigronata to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(gold: 2, silver: 20); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(gold: 2, silver: 20); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Pigronata, 1).AddIngredient(ItemID.LifeFruit, 1).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Pigronata, 1).AddIngredient(ItemID.LifeFruit, 1).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/PrinceSlimeItem.cs b/Items/Pets/PrinceSlimeItem.cs index 3e69770a..46bf6f63 100644 --- a/Items/Pets/PrinceSlimeItem.cs +++ b/Items/Pets/PrinceSlimeItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class PrinceSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class PrinceSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Prince Slime"); - Tooltip.SetDefault("Summons a friendly Prince Slime to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Prince Slime"); + Tooltip.SetDefault("Summons a friendly Prince Slime to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/QueenLarvaItem.cs b/Items/Pets/QueenLarvaItem.cs index 84de46b1..630a395a 100644 --- a/Items/Pets/QueenLarvaItem.cs +++ b/Items/Pets/QueenLarvaItem.cs @@ -1,30 +1,30 @@ +using AssortedCrazyThings.Buffs.Pets; +using AssortedCrazyThings.Projectiles.Pets; using Terraria; using Terraria.ModLoader; -using AssortedCrazyThings.Projectiles.Pets; -using AssortedCrazyThings.Buffs.Pets; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class QueenLarvaItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class QueenLarvaItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Queen Larva"); - Tooltip.SetDefault("Summons a Queen Bee Larva to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Queen Larva"); + Tooltip.SetDefault("Summons a Queen Bee Larva to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.width = 28; - Item.height = 32; - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.width = 28; + Item.height = 32; + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/RainbowSlimeItem.cs b/Items/Pets/RainbowSlimeItem.cs index d3b383c9..820e4fb2 100644 --- a/Items/Pets/RainbowSlimeItem.cs +++ b/Items/Pets/RainbowSlimeItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class RainbowSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class RainbowSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Rainbow Slime"); - Tooltip.SetDefault("Summons a friendly Rainbow Slime to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Rainbow Slime"); + Tooltip.SetDefault("Summons a friendly Rainbow Slime to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/SimplePetItemBase.cs b/Items/Pets/SimplePetItemBase.cs index 993cdc42..b2297ac2 100644 --- a/Items/Pets/SimplePetItemBase.cs +++ b/Items/Pets/SimplePetItemBase.cs @@ -1,43 +1,42 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - /// - /// Provided a pet projectile type, and a buff type, handles spawning the pet via using the item - /// - [Content(ContentType.OtherPets)] //Give it to the base class, as it covers most pets - public abstract class SimplePetItemBase : AssItem - { - public abstract int PetType { get; } - - public abstract int BuffType { get; } - - public sealed override void SetDefaults() - { - Item.DefaultToVanitypet(PetType, BuffType); - Item.value = 0; - - SafeSetDefaults(); - } - - public virtual void SafeSetDefaults() - { - - } - - public sealed override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - player.AddBuff(Item.buffType, 3600, true); - return SafeShoot(player, source, position, velocity, type, damage, knockback); - } - - //By default, do not shoot, as the buff handles it already - public virtual bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - return false; - } - } + /// + /// Provided a pet projectile type, and a buff type, handles spawning the pet via using the item + /// + [Content(ContentType.OtherPets)] //Give it to the base class, as it covers most pets + public abstract class SimplePetItemBase : AssItem + { + public abstract int PetType { get; } + + public abstract int BuffType { get; } + + public sealed override void SetDefaults() + { + Item.DefaultToVanitypet(PetType, BuffType); + Item.value = 0; + + SafeSetDefaults(); + } + + public virtual void SafeSetDefaults() + { + + } + + public sealed override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + player.AddBuff(Item.buffType, 3600, true); + return SafeShoot(player, source, position, velocity, type, damage, knockback); + } + + //By default, do not shoot, as the buff handles it already + public virtual bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + return false; + } + } } diff --git a/Items/Pets/SkeletronHandItem.cs b/Items/Pets/SkeletronHandItem.cs index 778a25fb..5ffc3846 100644 --- a/Items/Pets/SkeletronHandItem.cs +++ b/Items/Pets/SkeletronHandItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class SkeletronHandItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class SkeletronHandItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Skeletron's Spare Hand"); - Tooltip.SetDefault("Summons Skeletron's Hand attached to you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Skeletron's Spare Hand"); + Tooltip.SetDefault("Summons Skeletron's Hand attached to you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/SkeletronPrimeHandItem.cs b/Items/Pets/SkeletronPrimeHandItem.cs index 4778cbfc..5480b8d2 100644 --- a/Items/Pets/SkeletronPrimeHandItem.cs +++ b/Items/Pets/SkeletronPrimeHandItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class SkeletronPrimeHandItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class SkeletronPrimeHandItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Skeletron Prime's Spare Hand"); - Tooltip.SetDefault("Summons Skeletron Prime's Hand attached to you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Skeletron Prime's Spare Hand"); + Tooltip.SetDefault("Summons Skeletron Prime's Hand attached to you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/StingSlimeItem.cs b/Items/Pets/StingSlimeItem.cs index 35b60743..84c22e02 100644 --- a/Items/Pets/StingSlimeItem.cs +++ b/Items/Pets/StingSlimeItem.cs @@ -5,25 +5,25 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - [LegacyName("StingSlimeBlackItem", "StingSlimeOrangeItem")] - public class StingSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + [LegacyName("StingSlimeBlackItem", "StingSlimeOrangeItem")] + public class StingSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Sting Slime"); - Tooltip.SetDefault("Summons a friendly black Sting Slime to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Sting Slime"); + Tooltip.SetDefault("Summons a friendly black Sting Slime to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/StrangeRobotItem.cs b/Items/Pets/StrangeRobotItem.cs index ccf5c5e9..6d7d6296 100644 --- a/Items/Pets/StrangeRobotItem.cs +++ b/Items/Pets/StrangeRobotItem.cs @@ -6,21 +6,21 @@ namespace AssortedCrazyThings.Items.Pets { - public class StrangeRobotItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class StrangeRobotItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Odd Mechanical Device"); - Tooltip.SetDefault("Summons a strange robot to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Odd Mechanical Device"); + Tooltip.SetDefault("Summons a strange robot to follow you"); + } - public override void SafeSetDefaults() - { - Item.SetShopValues(ItemRarityColor.Orange3, Item.buyPrice(1)); //Same as other travelling merchant pets - } - } + public override void SafeSetDefaults() + { + Item.SetShopValues(ItemRarityColor.Orange3, Item.buyPrice(1)); //Same as other travelling merchant pets + } + } } diff --git a/Items/Pets/SuspiciousNuggetItem.cs b/Items/Pets/SuspiciousNuggetItem.cs index d297d5e2..5a5c7088 100644 --- a/Items/Pets/SuspiciousNuggetItem.cs +++ b/Items/Pets/SuspiciousNuggetItem.cs @@ -6,21 +6,21 @@ namespace AssortedCrazyThings.Items.Pets { - public class SuspiciousNuggetItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class SuspiciousNuggetItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Suspicious Nugget"); - Tooltip.SetDefault("Summons a Suspicious Nugget to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Suspicious Nugget"); + Tooltip.SetDefault("Summons a Suspicious Nugget to follow you"); + } - public override void SafeSetDefaults() - { - Item.SetShopValues(ItemRarityColor.Orange3, Item.buyPrice(50)); //10 times more expensive then cube - } - } + public override void SafeSetDefaults() + { + Item.SetShopValues(ItemRarityColor.Orange3, Item.buyPrice(50)); //10 times more expensive then cube + } + } } diff --git a/Items/Pets/SwarmofCthulhuItem.cs b/Items/Pets/SwarmofCthulhuItem.cs index 4a966325..2f2eda2f 100644 --- a/Items/Pets/SwarmofCthulhuItem.cs +++ b/Items/Pets/SwarmofCthulhuItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class SwarmofCthulhuItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class SwarmofCthulhuItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottle of Restless Eyes"); - Tooltip.SetDefault("Summons several eyes to swarm around you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottle of Restless Eyes"); + Tooltip.SetDefault("Summons several eyes to swarm around you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/TinyTwinsItem.cs b/Items/Pets/TinyTwinsItem.cs index d41f4f2b..722e8034 100644 --- a/Items/Pets/TinyTwinsItem.cs +++ b/Items/Pets/TinyTwinsItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class TinyTwinsItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class TinyTwinsItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tiny Twins"); - Tooltip.SetDefault("Summons a tiny pair of The Twins to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tiny Twins"); + Tooltip.SetDefault("Summons a tiny pair of The Twins to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/TorchGodLightPetItem.cs b/Items/Pets/TorchGodLightPetItem.cs index 7dafc51d..d4cfa965 100644 --- a/Items/Pets/TorchGodLightPetItem.cs +++ b/Items/Pets/TorchGodLightPetItem.cs @@ -6,32 +6,32 @@ namespace AssortedCrazyThings.Items.Pets { - public class TorchGodLightPetItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + public class TorchGodLightPetItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Godly Torch"); - Tooltip.SetDefault("Summons a godly torch to follow you\n"+ - "Automatically places your normal torches with 'Smart Cursor' active"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Godly Torch"); + Tooltip.SetDefault("Summons a godly torch to follow you\n" + + "Automatically places your normal torches with 'Smart Cursor' active"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(gold: 2); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(gold: 2); + } - public override void AddRecipes() - { - CreateRecipe() - .AddIngredient(ItemID.TorchGodsFavor) - .AddIngredient(ItemID.Torch, 999) - .AddTile(TileID.DemonAltar) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe() + .AddIngredient(ItemID.TorchGodsFavor) + .AddIngredient(ItemID.Torch, 999) + .AddTile(TileID.DemonAltar) + .Register(); + } + } } diff --git a/Items/Pets/TorturedSoulItem.cs b/Items/Pets/TorturedSoulItem.cs index b8b69896..41642499 100644 --- a/Items/Pets/TorturedSoulItem.cs +++ b/Items/Pets/TorturedSoulItem.cs @@ -6,28 +6,28 @@ namespace AssortedCrazyThings.Items.Pets { - [LegacyName("TorturedSoul")] - public class TorturedSoulItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("TorturedSoul")] + public class TorturedSoulItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tortured Soul"); - Tooltip.SetDefault("Summons an unfriendly Tortured Soul to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tortured Soul"); + Tooltip.SetDefault("Summons an unfriendly Tortured Soul to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 50); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 50); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.TaxCollectorsStickOfDoom, 1).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.TaxCollectorsStickOfDoom, 1).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/TrueObservingEyeItem.cs b/Items/Pets/TrueObservingEyeItem.cs index b1ae8e98..e80c81b5 100644 --- a/Items/Pets/TrueObservingEyeItem.cs +++ b/Items/Pets/TrueObservingEyeItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class TrueObservingEyeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class TrueObservingEyeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("True Observing Eye"); - Tooltip.SetDefault("Summons a True Eye of Cthulhu to watch after you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("True Observing Eye"); + Tooltip.SetDefault("Summons a True Eye of Cthulhu to watch after you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/TurtleSlimeItem.cs b/Items/Pets/TurtleSlimeItem.cs index e0efdcc9..605d35cb 100644 --- a/Items/Pets/TurtleSlimeItem.cs +++ b/Items/Pets/TurtleSlimeItem.cs @@ -5,23 +5,23 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.HostileNPCs)] - public class TurtleSlimeItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.HostileNPCs)] + public class TurtleSlimeItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bottled Turtle Slime"); - Tooltip.SetDefault("Summons a friendly Turtle Slime to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bottled Turtle Slime"); + Tooltip.SetDefault("Summons a friendly Turtle Slime to follow you"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/VampireBatItem.cs b/Items/Pets/VampireBatItem.cs index d2c81b51..9efdaebe 100644 --- a/Items/Pets/VampireBatItem.cs +++ b/Items/Pets/VampireBatItem.cs @@ -6,29 +6,29 @@ namespace AssortedCrazyThings.Items.Pets { - [LegacyName("VampireBat")] - public class VampireBatItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("VampireBat")] + public class VampireBatItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Fixed Bat Wing"); - Tooltip.SetDefault("Summons a friendly vampire that flies with you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fixed Bat Wing"); + Tooltip.SetDefault("Summons a friendly vampire that flies with you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(silver: 20); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(silver: 20); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.BrokenBatWing, 2).AddIngredient(ItemID.SoulofNight, 10).AddTile(TileID.DemonAltar).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.BrokenBatWing, 2).AddIngredient(ItemID.SoulofNight, 10).AddTile(TileID.DemonAltar).Register(); + } + } } diff --git a/Items/Pets/WallFragmentItem.cs b/Items/Pets/WallFragmentItem.cs index 871eeb4c..ecb2646c 100644 --- a/Items/Pets/WallFragmentItem.cs +++ b/Items/Pets/WallFragmentItem.cs @@ -1,29 +1,29 @@ -using Terraria; -using Terraria.ModLoader; using AssortedCrazyThings.Buffs.Pets; using AssortedCrazyThings.Projectiles.Pets; +using Terraria; +using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.DroppedPets)] - public class WallFragmentItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.DroppedPets)] + public class WallFragmentItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wall Fragment"); - Tooltip.SetDefault("Summons several fragments of the Wall to follow you"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wall Fragment"); + Tooltip.SetDefault("Summons several fragments of the Wall to follow you"); + } - public override void SafeSetDefaults() - { - Item.width = 22; - Item.height = 26; - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.width = 22; + Item.height = 26; + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/YoungHarpyItem.cs b/Items/Pets/YoungHarpyItem.cs index 418e9eda..5e96d860 100644 --- a/Items/Pets/YoungHarpyItem.cs +++ b/Items/Pets/YoungHarpyItem.cs @@ -5,25 +5,25 @@ namespace AssortedCrazyThings.Items.Pets { - [Content(ContentType.FriendlyNPCs)] - [LegacyName("YoungHarpy")] - public class YoungHarpyItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [Content(ContentType.FriendlyNPCs)] + [LegacyName("YoungHarpy")] + public class YoungHarpyItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Clump of Down Feathers"); - Tooltip.SetDefault("Summons a friendly Harpy to follow you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Clump of Down Feathers"); + Tooltip.SetDefault("Summons a friendly Harpy to follow you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } + } } diff --git a/Items/Pets/YoungWyvernItem.cs b/Items/Pets/YoungWyvernItem.cs index a8fab67d..aebd1ca0 100644 --- a/Items/Pets/YoungWyvernItem.cs +++ b/Items/Pets/YoungWyvernItem.cs @@ -6,29 +6,29 @@ namespace AssortedCrazyThings.Items.Pets { - [LegacyName("YoungWyvern")] - public class YoungWyvernItem : SimplePetItemBase - { - public override int PetType => ModContent.ProjectileType(); + [LegacyName("YoungWyvern")] + public class YoungWyvernItem : SimplePetItemBase + { + public override int PetType => ModContent.ProjectileType(); - public override int BuffType => ModContent.BuffType(); + public override int BuffType => ModContent.BuffType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wyverntail"); - Tooltip.SetDefault("Summons a friendly Young Wyvern that flies with you" - + "\nAppearance can be changed with Costume Suitcase"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wyverntail"); + Tooltip.SetDefault("Summons a friendly Young Wyvern that flies with you" + + "\nAppearance can be changed with Costume Suitcase"); + } - public override void SafeSetDefaults() - { - Item.rare = -11; - Item.value = Item.sellPrice(copper: 10); - } + public override void SafeSetDefaults() + { + Item.rare = -11; + Item.value = Item.sellPrice(copper: 10); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Wyverntail, 1).AddTile(TileID.WorkBenches).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Wyverntail, 1).AddTile(TileID.WorkBenches).Register(); + } + } } diff --git a/Items/Placeable/CuteSlimeStatueItem.cs b/Items/Placeable/CuteSlimeStatueItem.cs index 1042dfa0..ecab611b 100644 --- a/Items/Placeable/CuteSlimeStatueItem.cs +++ b/Items/Placeable/CuteSlimeStatueItem.cs @@ -4,29 +4,29 @@ namespace AssortedCrazyThings.Items.Placeable { - //TODO RegularCuteSlimes config - [Content(ContentType.PlaceablesFunctional | ContentType.CuteSlimes)] - public class CuteSlimeStatueItem : PlaceableItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Slime Statue"); - Tooltip.SetDefault("You can't catch statue spawned creatures"); - } + //TODO RegularCuteSlimes config + [Content(ContentType.PlaceablesFunctional | ContentType.CuteSlimes)] + public class CuteSlimeStatueItem : PlaceableItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Slime Statue"); + Tooltip.SetDefault("You can't catch statue spawned creatures"); + } - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(TileType); - Item.width = 24; - Item.height = 32; - Item.maxStack = 99; - Item.rare = -11; - Item.value = Item.sellPrice(0, 0, 0, 60); - } + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(TileType); + Item.width = 24; + Item.height = 32; + Item.maxStack = 99; + Item.rare = -11; + Item.value = Item.sellPrice(0, 0, 0, 60); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Gel, 200).AddIngredient(ItemID.StoneBlock, 50).AddRecipeGroup("ACT:RegularCuteSlimes", 1).AddTile(TileID.HeavyWorkBench).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Gel, 200).AddIngredient(ItemID.StoneBlock, 50).AddRecipeGroup("ACT:RegularCuteSlimes", 1).AddTile(TileID.HeavyWorkBench).Register(); + } + } } diff --git a/Items/Placeable/HarvesterRelicItem.cs b/Items/Placeable/HarvesterRelicItem.cs index e10c819a..406e1d61 100644 --- a/Items/Placeable/HarvesterRelicItem.cs +++ b/Items/Placeable/HarvesterRelicItem.cs @@ -4,23 +4,23 @@ namespace AssortedCrazyThings.Items.Placeable { - [Content(ContentType.Bosses)] - public class HarvesterRelicItem : PlaceableItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Soul Harvester Relic"); - } + [Content(ContentType.Bosses)] + public class HarvesterRelicItem : PlaceableItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul Harvester Relic"); + } - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(TileType); - Item.width = 30; - Item.height = 40; - Item.maxStack = 99; - Item.rare = ItemRarityID.Master; - Item.master = true; - Item.value = Item.buyPrice(0, 5); - } - } + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(TileType); + Item.width = 30; + Item.height = 40; + Item.maxStack = 99; + Item.rare = ItemRarityID.Master; + Item.master = true; + Item.value = Item.buyPrice(0, 5); + } + } } diff --git a/Items/Placeable/HarvesterTrophyItem.cs b/Items/Placeable/HarvesterTrophyItem.cs index 52e4a765..b58f6b56 100644 --- a/Items/Placeable/HarvesterTrophyItem.cs +++ b/Items/Placeable/HarvesterTrophyItem.cs @@ -4,22 +4,22 @@ namespace AssortedCrazyThings.Items.Placeable { - [Content(ContentType.Bosses)] - public class HarvesterTrophyItem : PlaceableItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Soul Harvester Trophy"); - } + [Content(ContentType.Bosses)] + public class HarvesterTrophyItem : PlaceableItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul Harvester Trophy"); + } - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(TileType); - Item.width = 30; - Item.height = 30; - Item.maxStack = 99; - Item.rare = ItemRarityID.Blue; - Item.value = Item.buyPrice(0, 1); - } - } + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(TileType); + Item.width = 30; + Item.height = 30; + Item.maxStack = 99; + Item.rare = ItemRarityID.Blue; + Item.value = Item.buyPrice(0, 1); + } + } } diff --git a/Items/Placeable/Paintings/FieldsOfJoyItem.cs b/Items/Placeable/Paintings/FieldsOfJoyItem.cs index 9e5e09f7..c91f34d2 100644 --- a/Items/Placeable/Paintings/FieldsOfJoyItem.cs +++ b/Items/Placeable/Paintings/FieldsOfJoyItem.cs @@ -10,5 +10,5 @@ public class FieldsOfJoyItem : PaintingItemBase public override string PaintingAuthor => "C. Paigner"; public override (int item, int amount) RecipeIngredient => (ItemID.Gel, 1); - } + } } diff --git a/Items/Placeable/Paintings/PaintingItemBase.cs b/Items/Placeable/Paintings/PaintingItemBase.cs index 5f74ac12..bf322851 100644 --- a/Items/Placeable/Paintings/PaintingItemBase.cs +++ b/Items/Placeable/Paintings/PaintingItemBase.cs @@ -38,19 +38,19 @@ public sealed override void SetDefaults() Item.rare = ItemRarityID.Blue; } - public override void AddRecipes() - { + public override void AddRecipes() + { var recipe = CreateRecipe() .AddIngredient(ItemID.TatteredCloth, 2) .AddRecipeGroup(RecipeGroupID.Wood) .AddTile(TileID.Sawmill); if (RecipeIngredient.item > 0 && RecipeIngredient.amount > 0) - { + { recipe.AddIngredient(RecipeIngredient.item, RecipeIngredient.amount); } recipe.Register(); - } - } + } + } } diff --git a/Items/Placeable/SlimeBeaconItem.cs b/Items/Placeable/SlimeBeaconItem.cs index cf0abe12..3d9d58c4 100644 --- a/Items/Placeable/SlimeBeaconItem.cs +++ b/Items/Placeable/SlimeBeaconItem.cs @@ -6,27 +6,27 @@ namespace AssortedCrazyThings.Items.Placeable { - public class SlimeBeaconItem : PlaceableItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slime Beacon"); - Tooltip.SetDefault("'Do The Slime With Me!'"); - } + public class SlimeBeaconItem : PlaceableItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slime Beacon"); + Tooltip.SetDefault("'Do The Slime With Me!'"); + } - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(TileType); - Item.width = 28; - Item.height = 28; - Item.maxStack = 99; - Item.rare = -11; - Item.value = Item.buyPrice(0, 10, 0, 0); - } + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(TileType); + Item.width = 28; + Item.height = 28; + Item.maxStack = 99; + Item.rare = -11; + Item.value = Item.buyPrice(0, 10, 0, 0); + } - public override void ModifyTooltips(List tooltips) - { - if (Main.netMode == NetmodeID.MultiplayerClient) tooltips.Add(new TooltipLine(Mod, "Multi", "[c/FFA01D:DOES NOT WORK IN MULTIPLAYER]")); - } - } + public override void ModifyTooltips(List tooltips) + { + if (Main.netMode == NetmodeID.MultiplayerClient) tooltips.Add(new TooltipLine(Mod, "Multi", "[c/FFA01D:DOES NOT WORK IN MULTIPLAYER]")); + } + } } diff --git a/Items/Placeable/StarRodItem.cs b/Items/Placeable/StarRodItem.cs index 3d439e4a..3d73497b 100644 --- a/Items/Placeable/StarRodItem.cs +++ b/Items/Placeable/StarRodItem.cs @@ -4,35 +4,35 @@ namespace AssortedCrazyThings.Items.Placeable { - public class StarRodItem : PlaceableItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star Rod"); - Tooltip.SetDefault("Attracts Falling Stars at night if you are nearby"); - } + public class StarRodItem : PlaceableItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Star Rod"); + Tooltip.SetDefault("Attracts Falling Stars at night if you are nearby"); + } - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(TileType); - Item.width = 18; - Item.height = 32; - Item.maxStack = 99; - Item.rare = -11; - Item.value = - Item.sellPrice(0, 0, 12, 0) * 10 + - Item.sellPrice(0, 0, 30, 0) * 5 + - Item.sellPrice(0, 0, 5, 0) * 25 - 10; //Using the cheaper bar variants, minus rounding due to shop happiness variance - } + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(TileType); + Item.width = 18; + Item.height = 32; + Item.maxStack = 99; + Item.rare = -11; + Item.value = + Item.sellPrice(0, 0, 12, 0) * 10 + + Item.sellPrice(0, 0, 30, 0) * 5 + + Item.sellPrice(0, 0, 5, 0) * 25 - 10; //Using the cheaper bar variants, minus rounding due to shop happiness variance + } - public override void AddRecipes() - { - CreateRecipe() - .AddRecipeGroup("ACT:GoldPlatinum", 10) - .AddRecipeGroup("ACT:DemoniteCrimtane", 5) - .AddIngredient(ItemID.FallenStar, 25) - .AddTile(TileID.Anvils) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe() + .AddRecipeGroup("ACT:GoldPlatinum", 10) + .AddRecipeGroup("ACT:DemoniteCrimtane", 5) + .AddIngredient(ItemID.FallenStar, 25) + .AddTile(TileID.Anvils) + .Register(); + } + } } diff --git a/Items/Placeable/VanityDresserItem.cs b/Items/Placeable/VanityDresserItem.cs index 0b998b5f..b457b962 100644 --- a/Items/Placeable/VanityDresserItem.cs +++ b/Items/Placeable/VanityDresserItem.cs @@ -5,29 +5,29 @@ namespace AssortedCrazyThings.Items.Placeable { - [Content(ContentType.PlaceablesFunctional | ContentType.DroppedPets | ContentType.OtherPets, needsAllToFilter: true)] - public class VanityDresserItem : PlaceableItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Costume Dresser"); - Tooltip.SetDefault("Left Click to change your Pet's appearance" - + "\nRight Click to change your Light Pet's appearance"); - } + [Content(ContentType.PlaceablesFunctional | ContentType.DroppedPets | ContentType.OtherPets, needsAllToFilter: true)] + public class VanityDresserItem : PlaceableItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Costume Dresser"); + Tooltip.SetDefault("Left Click to change your Pet's appearance" + + "\nRight Click to change your Light Pet's appearance"); + } - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(TileType); - Item.width = 34; - Item.height = 26; - Item.maxStack = 99; - Item.rare = -11; - Item.value = Item.sellPrice(silver: 10); - } + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(TileType); + Item.width = 34; + Item.height = 26; + Item.maxStack = 99; + Item.rare = -11; + Item.value = Item.sellPrice(silver: 10); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Dresser).AddIngredient(ModContent.ItemType()).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Dresser).AddIngredient(ModContent.ItemType()).Register(); + } + } } diff --git a/Items/Placeable/WyvernCampfireItem.cs b/Items/Placeable/WyvernCampfireItem.cs index ac6886be..dcda67fe 100644 --- a/Items/Placeable/WyvernCampfireItem.cs +++ b/Items/Placeable/WyvernCampfireItem.cs @@ -1,31 +1,30 @@ using AssortedCrazyThings.Tiles; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Placeable { - public class WyvernCampfireItem : PlaceableItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wyvern Campfire"); - Tooltip.SetDefault("'Makes Wyverns go poof!'"); - } + public class WyvernCampfireItem : PlaceableItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wyvern Campfire"); + Tooltip.SetDefault("'Makes Wyverns go poof!'"); + } - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(TileType); - Item.width = 32; - Item.height = 18; - Item.maxStack = 99; - Item.rare = -11; - Item.value = Item.buyPrice(0, 11, 50, 0); - } + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(TileType); + Item.width = 32; + Item.height = 18; + Item.maxStack = 99; + Item.rare = -11; + Item.value = Item.buyPrice(0, 11, 50, 0); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.GiantHarpyFeather).AddRecipeGroup("ACT:AdamantiteTitanium", 12).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.GiantHarpyFeather).AddRecipeGroup("ACT:AdamantiteTitanium", 12).Register(); + } + } } diff --git a/Items/Tools/ExtendoNetBase.cs b/Items/Tools/ExtendoNetBase.cs index a45821af..e41bb304 100644 --- a/Items/Tools/ExtendoNetBase.cs +++ b/Items/Tools/ExtendoNetBase.cs @@ -1,54 +1,52 @@ -using System; -using System.Reflection; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Tools { - [Content(ContentType.Tools)] - public abstract class ExtendoNetBase : AssItem - { - public override void SetDefaults() - { - Item.useStyle = ItemUseStyleID.Shoot; - Item.shootSpeed = 3.7f; - Item.width = 40; - Item.height = 40; - Item.DamageType = DamageClass.Melee; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; - Item.UseSound = SoundID.Item1; - } + [Content(ContentType.Tools)] + public abstract class ExtendoNetBase : AssItem + { + public override void SetDefaults() + { + Item.useStyle = ItemUseStyleID.Shoot; + Item.shootSpeed = 3.7f; + Item.width = 40; + Item.height = 40; + Item.DamageType = DamageClass.Melee; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.autoReuse = true; + Item.UseSound = SoundID.Item1; + } - public override bool CanUseItem(Player player) - { - return player.ownedProjectileCounts[Item.shoot] < 1; - } + public override bool CanUseItem(Player player) + { + return player.ownedProjectileCounts[Item.shoot] < 1; + } - public void OverhaulInit() - { - //TODO remove this/change/whatever - //Mod oMod = ModLoader.GetMod("TerrariaOverhaul"); - //if (oMod != null) - //{ - // try - // { - // Assembly TerrariaOverhaul = oMod.Code; - // Type Extensions = TerrariaOverhaul.GetType(oMod.Name + ".Extensions"); - // MethodInfo SetTag = Extensions.GetMethod("SetTag", new Type[] { typeof(ModItem), typeof(int), typeof(bool) }); - // Type ItemTags = TerrariaOverhaul.GetType(oMod.Name + ".ItemTags"); - // FieldInfo AllowQuickUse = ItemTags.GetField("AllowQuickUse", BindingFlags.Static | BindingFlags.Public); - // object AllowQuickUseValue = AllowQuickUse.GetValue(null); - // SetTag.Invoke(null, new object[] { this, AllowQuickUseValue, true }); - // } - // catch - // { - // mod.Logger.Warn("Failed to register Overhaul Quick Use feature to Extendo Nets"); - // } - //} - //this.SetTag(ItemTags.AllowQuickUse); - } - } + public void OverhaulInit() + { + //TODO remove this/change/whatever + //Mod oMod = ModLoader.GetMod("TerrariaOverhaul"); + //if (oMod != null) + //{ + // try + // { + // Assembly TerrariaOverhaul = oMod.Code; + // Type Extensions = TerrariaOverhaul.GetType(oMod.Name + ".Extensions"); + // MethodInfo SetTag = Extensions.GetMethod("SetTag", new Type[] { typeof(ModItem), typeof(int), typeof(bool) }); + // Type ItemTags = TerrariaOverhaul.GetType(oMod.Name + ".ItemTags"); + // FieldInfo AllowQuickUse = ItemTags.GetField("AllowQuickUse", BindingFlags.Static | BindingFlags.Public); + // object AllowQuickUseValue = AllowQuickUse.GetValue(null); + // SetTag.Invoke(null, new object[] { this, AllowQuickUseValue, true }); + // } + // catch + // { + // mod.Logger.Warn("Failed to register Overhaul Quick Use feature to Extendo Nets"); + // } + //} + //this.SetTag(ItemTags.AllowQuickUse); + } + } } diff --git a/Items/Tools/ExtendoNetGolden.cs b/Items/Tools/ExtendoNetGolden.cs index 3c18ee8d..d374caae 100644 --- a/Items/Tools/ExtendoNetGolden.cs +++ b/Items/Tools/ExtendoNetGolden.cs @@ -5,26 +5,26 @@ namespace AssortedCrazyThings.Items.Tools { - public class ExtendoNetGolden : ExtendoNetBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Golden Extendo-Net"); - Tooltip.SetDefault("'Catches those REALLY hard to reach critters'"); - } + public class ExtendoNetGolden : ExtendoNetBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Golden Extendo-Net"); + Tooltip.SetDefault("'Catches those REALLY hard to reach critters'"); + } - public override void SetDefaults() - { - base.SetDefaults(); - Item.useAnimation = 18; - Item.useTime = 24; - Item.value = Item.sellPrice(gold: 5, silver: 90); - Item.shoot = ModContent.ProjectileType(); - } + public override void SetDefaults() + { + base.SetDefaults(); + Item.useAnimation = 18; + Item.useTime = 24; + Item.value = Item.sellPrice(gold: 5, silver: 90); + Item.shoot = ModContent.ProjectileType(); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Wire, 10).AddRecipeGroup("ACT:GoldPlatinum", 10).AddIngredient(ItemID.GoldenBugNet, 1).AddTile(TileID.Anvils).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Wire, 10).AddRecipeGroup("ACT:GoldPlatinum", 10).AddIngredient(ItemID.GoldenBugNet, 1).AddTile(TileID.Anvils).Register(); + } + } } diff --git a/Items/Tools/ExtendoNetRegular.cs b/Items/Tools/ExtendoNetRegular.cs index a35a781a..aa9e4429 100644 --- a/Items/Tools/ExtendoNetRegular.cs +++ b/Items/Tools/ExtendoNetRegular.cs @@ -5,26 +5,26 @@ namespace AssortedCrazyThings.Items.Tools { - public class ExtendoNetRegular : ExtendoNetBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Extendo-Net"); - Tooltip.SetDefault("'Catches those hard to reach critters'"); - } + public class ExtendoNetRegular : ExtendoNetBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Extendo-Net"); + Tooltip.SetDefault("'Catches those hard to reach critters'"); + } - public override void SetDefaults() - { - base.SetDefaults(); - Item.useAnimation = 24; - Item.useTime = 32; - Item.value = Item.sellPrice(silver: 45); - Item.shoot = ModContent.ProjectileType(); - } + public override void SetDefaults() + { + base.SetDefaults(); + Item.useAnimation = 24; + Item.useTime = 32; + Item.value = Item.sellPrice(silver: 45); + Item.shoot = ModContent.ProjectileType(); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Wire, 10).AddRecipeGroup("IronBar", 10).AddIngredient(ItemID.BugNet, 1).AddTile(TileID.Anvils).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Wire, 10).AddRecipeGroup("IronBar", 10).AddIngredient(ItemID.BugNet, 1).AddTile(TileID.Anvils).Register(); + } + } } diff --git a/Items/VanityArmor/PrettyMask.cs b/Items/VanityArmor/PrettyMask.cs index b0438c2f..33619083 100644 --- a/Items/VanityArmor/PrettyMask.cs +++ b/Items/VanityArmor/PrettyMask.cs @@ -3,29 +3,29 @@ namespace AssortedCrazyThings.Items.VanityArmor { - [Content(ContentType.VanityArmor)] - [AutoloadEquip(EquipType.Head)] - public class PrettyMask : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pretty Mask"); - Tooltip.SetDefault("'Goes well with a red scarf, red gloves, red boots, and your birthday suit'"); - } - public override void SetDefaults() - { - //item.CloneDefaults(ItemID.BallaHat); - Item.width = 26; - Item.height = 26; - Item.rare = -11; - Item.value = 0; - Item.vanity = true; - Item.maxStack = 1; - } + [Content(ContentType.VanityArmor)] + [AutoloadEquip(EquipType.Head)] + public class PrettyMask : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pretty Mask"); + Tooltip.SetDefault("'Goes well with a red scarf, red gloves, red boots, and your birthday suit'"); + } + public override void SetDefaults() + { + //item.CloneDefaults(ItemID.BallaHat); + Item.width = 26; + Item.height = 26; + Item.rare = -11; + Item.value = 0; + Item.vanity = true; + Item.maxStack = 1; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Silk, 50).AddIngredient(ItemID.Feather, 1).AddTile(TileID.Loom).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Silk, 50).AddIngredient(ItemID.Feather, 1).AddTile(TileID.Loom).Register(); + } + } } diff --git a/Items/VanityArmor/SoulHarvesterMask.cs b/Items/VanityArmor/SoulHarvesterMask.cs index e76cdaad..3d0db337 100644 --- a/Items/VanityArmor/SoulHarvesterMask.cs +++ b/Items/VanityArmor/SoulHarvesterMask.cs @@ -4,23 +4,23 @@ namespace AssortedCrazyThings.Items.VanityArmor { - [Content(ContentType.Bosses)] - [AutoloadEquip(EquipType.Head)] - public class SoulHarvesterMask : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Soul Harvester Mask"); - } + [Content(ContentType.Bosses)] + [AutoloadEquip(EquipType.Head)] + public class SoulHarvesterMask : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul Harvester Mask"); + } - public override void SetDefaults() - { - Item.width = 32; - Item.height = 28; - Item.rare = ItemRarityID.Blue; - Item.value = Item.sellPrice(silver: 75); - Item.vanity = true; - Item.maxStack = 1; - } - } + public override void SetDefaults() + { + Item.width = 32; + Item.height = 28; + Item.rare = ItemRarityID.Blue; + Item.value = Item.sellPrice(silver: 75); + Item.vanity = true; + Item.maxStack = 1; + } + } } diff --git a/Items/VanitySelector.cs b/Items/VanitySelector.cs index 71a2092f..1175e5a5 100644 --- a/Items/VanitySelector.cs +++ b/Items/VanitySelector.cs @@ -3,39 +3,39 @@ namespace AssortedCrazyThings.Items { - //Needs Placeables as it's an ingredient for VanityDresserItem - [Content(ContentType.PlaceablesFunctional | ContentType.DroppedPets | ContentType.OtherPets, needsAllToFilter: true)] - public class VanitySelector : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Costume Suitcase"); - Tooltip.SetDefault("Left Click to change your Pet's appearance" - + "\nRight Click to change your Light Pet's appearance"); - } + //Needs Placeables as it's an ingredient for VanityDresserItem + [Content(ContentType.PlaceablesFunctional | ContentType.DroppedPets | ContentType.OtherPets, needsAllToFilter: true)] + public class VanitySelector : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Costume Suitcase"); + Tooltip.SetDefault("Left Click to change your Pet's appearance" + + "\nRight Click to change your Light Pet's appearance"); + } - public override void SetDefaults() - { - Item.width = 32; - Item.height = 32; - Item.maxStack = 1; - Item.rare = -11; - Item.useAnimation = 16; - Item.useTime = 16; - Item.UseSound = SoundID.Item1; - Item.consumable = false; - Item.value = Item.sellPrice(silver: 10); - } + public override void SetDefaults() + { + Item.width = 32; + Item.height = 32; + Item.maxStack = 1; + Item.rare = -11; + Item.useAnimation = 16; + Item.useTime = 16; + Item.UseSound = SoundID.Item1; + Item.consumable = false; + Item.value = Item.sellPrice(silver: 10); + } - public override bool CanUseItem(Player player) - { - return false; - } + public override bool CanUseItem(Player player) + { + return false; + } - public override void AddRecipes() - { - //actual recipe here - CreateRecipe(1).AddRecipeGroup("IronBar", 10).AddIngredient(ItemID.Silk, 50).AddTile(TileID.Anvils).Register(); - } - } + public override void AddRecipes() + { + //actual recipe here + CreateRecipe(1).AddRecipeGroup("IronBar", 10).AddIngredient(ItemID.Silk, 50).AddTile(TileID.Anvils).Register(); + } + } } diff --git a/Items/Weapons/BreathOfSpazmatism.cs b/Items/Weapons/BreathOfSpazmatism.cs index 336b3630..0737fb25 100644 --- a/Items/Weapons/BreathOfSpazmatism.cs +++ b/Items/Weapons/BreathOfSpazmatism.cs @@ -6,48 +6,48 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class BreathOfSpazmatism : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Breath of Spazmatism"); - Tooltip.SetDefault("Uses gel to fire a stream of cursed flames"); - } + [Content(ContentType.Weapons)] + public class BreathOfSpazmatism : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Breath of Spazmatism"); + Tooltip.SetDefault("Uses gel to fire a stream of cursed flames"); + } - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.Flamethrower); - Item.width = 72; - Item.height = 38; - //item.damage = 20; //same damage as flamethrower, which is 35 - Item.UseSound = SoundID.Item34; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 8f; - Item.noMelee = true; - Item.DamageType = DamageClass.Ranged; - Item.useAmmo = AmmoID.Gel; - Item.useTime = 3; //adjusted from 10 to 3 to match spazmatism speed - Item.useAnimation = 3; //^ - Item.useStyle = ItemUseStyleID.Shoot; - Item.value = Item.sellPrice(gold: 15, silver: 20); - Item.rare = -11; - Item.autoReuse = true; - } + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.Flamethrower); + Item.width = 72; + Item.height = 38; + //item.damage = 20; //same damage as flamethrower, which is 35 + Item.UseSound = SoundID.Item34; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 8f; + Item.noMelee = true; + Item.DamageType = DamageClass.Ranged; + Item.useAmmo = AmmoID.Gel; + Item.useTime = 3; //adjusted from 10 to 3 to match spazmatism speed + Item.useAnimation = 3; //^ + Item.useStyle = ItemUseStyleID.Shoot; + Item.value = Item.sellPrice(gold: 15, silver: 20); + Item.rare = -11; + Item.autoReuse = true; + } - public override Vector2? HoldoutOffset() - { - return new Vector2(-0, 0); - } + public override Vector2? HoldoutOffset() + { + return new Vector2(-0, 0); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.HallowedBar, 5).AddIngredient(ItemID.SoulofSight, 5).AddIngredient(ItemID.Flamethrower, 1).AddTile(TileID.MythrilAnvil).Register(); - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.HallowedBar, 5).AddIngredient(ItemID.SoulofSight, 5).AddIngredient(ItemID.Flamethrower, 1).AddTile(TileID.MythrilAnvil).Register(); + } - public override bool CanConsumeAmmo(Player player) - { - return Main.rand.NextFloat() >= .80f; //80% chance not to consume ammo (since its so fast) - } - } + public override bool CanConsumeAmmo(Player player) + { + return Main.rand.NextFloat() >= .80f; //80% chance not to consume ammo (since its so fast) + } + } } diff --git a/Items/Weapons/DroneController.cs b/Items/Weapons/DroneController.cs index 5867e107..79d47fc5 100644 --- a/Items/Weapons/DroneController.cs +++ b/Items/Weapons/DroneController.cs @@ -14,442 +14,442 @@ namespace AssortedCrazyThings.Items.Weapons { - public class DroneController : MinionItemBase - { - #region Static Methods - /// - /// Checks if drones are unlocked - /// - public static bool AllUnlocked(DroneType unlocked) - { - foreach (DroneType type in Enum.GetValues(typeof(DroneType))) - { - if (type != DroneType.None) - { - if (!unlocked.HasFlag(type)) - { - return false; - } - } - } - return true; - } - - /// - /// Checks if all drones are unlocked for the player - /// - public static bool AllUnlocked(Player player) - { - return AllUnlocked(player.GetModPlayer().droneControllerUnlocked); - } - - /// - /// Returns the custom MinionPos - /// - public static int GetSlotOfNextDrone(Projectile self) - { - int slot = 0; - int min = Main.maxProjectiles; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.active) - { - if (proj.owner == self.owner && proj.identity != self.identity) - { - if (proj.ModProjectile is DroneBase drone && drone.IsCombatDrone) - { - int minionPos = drone.MinionPos; - min = Math.Min(min, minionPos); - if (minionPos > slot) slot = minionPos; - } - } - } - } - if (min > 0) return 0; - - return slot + 1; - } - - /// - /// Determines position for the current projectile based on minionPos - /// - public static Vector2 GetPosition(Projectile projectile, int minionPos) - { - int initialVecticalOffset = -70; - int initialHorizontalOffset = 0; - int verticalOffset = -(int)(projectile.height * 1.2f); - int horizontalOffset = (int)(projectile.width * 1.75f); - int tempPos = minionPos % 6; - int side = minionPos % 2; //1 means left, 0 means right - int columnOffset = minionPos / 6 + 1; //1 for <6, 2 for <12, etc - - int rowOffset = tempPos / 2; //0, 1 or 2 - - int middleOffset = 0; - if (rowOffset == 1) middleOffset = horizontalOffset / 2; //the middle one - - Vector2 offset = new Vector2 - ( - initialHorizontalOffset + columnOffset * horizontalOffset + middleOffset, - initialVecticalOffset + rowOffset * verticalOffset - ); - offset.X *= side == 1 ? -1 : 1; - return offset; - } - - public static int SumOfSummonedDrones(Player player) - { - int sum = 0; - for (int i = 0; i < DataList.Length; i++) - { - sum += player.ownedProjectileCounts[DataList[i].ProjType]; - } - return sum; - } - - public static bool CanSpawn(Player player, DroneType selected, out bool blocked) - { - bool canSpawn = true; - blocked = false; - if (selected == DroneType.Healing || selected == DroneType.Shield) - { - canSpawn = player.ownedProjectileCounts[GetDroneData(selected).ProjType] == 0; - if (!canSpawn) blocked = true; - } - canSpawn &= player.GetModPlayer().droneControllerUnlocked.HasFlag(selected); - return canSpawn; - } - - private static void PreSync(Projectile proj) - { - if (proj.ModProjectile is DroneBase drone && drone.IsCombatDrone) - { - drone.MinionPos = GetSlotOfNextDrone(proj); - } - } - - /// - /// Sets the data up for a DroneType - /// - public static DroneData SetDroneData(DroneType selected) - { - switch (selected) - { - case DroneType.BasicLaser: - return new DroneData - ( - projType: ModContent.ProjectileType(), - name: "Basic Laser Drone", - desc: "Rapidly fires lasers", - firerate: "High" - ); - case DroneType.HeavyLaser: - return new DroneData - ( - projType: ModContent.ProjectileType(), - name: "Heavy Laser Drone", - desc: "Fires a penetrating laser after a long delay", - firerate: "Extremely slow", - dmgModifier: 8.091f, - kBModifier: 4f - ); - case DroneType.Missile: - return new DroneData - ( - projType: ModContent.ProjectileType(), - name: "Missile Drone", - desc: "Fires a salvo of missiles after a long delay", - firerate: "Very slow", - dmgModifier: 2.19f, - kBModifier: 1.2f - ); - case DroneType.Healing: - return new DroneData - ( - projType: ModContent.ProjectileType(), - name: "Healing Drone", - desc: "Heals you when hurt", - misc: "Only one can be summoned", - combat: false - ); - case DroneType.Shield: - return new DroneData - ( - projType: ModContent.ProjectileType(), - name: "Shield Drone", - desc: "Creates a damage reducing shield over time", - misc: "Only one can be summoned\nShield resets if drone despawns", - combat: false - ); - default: - throw new Exception("No DroneType specified"); - } - } - - /// - /// Holds data about each DroneType - /// - public static DroneData[] DataList; - - /// - /// Used to access a particular DroneTypes data - /// - public static DroneData GetDroneData(DroneType selected) - { - return DataList[(int)Math.Log((int)selected, 2)]; - } - - public static CircleUIConf GetUIConf() - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - List tooltips = new List(); - List toUnlock = new List(); - List> assets = new List>(); - List unlocked = new List(); - - foreach (DroneType type in Enum.GetValues(typeof(DroneType))) - { - if (type != DroneType.None) - { - DroneData data = GetDroneData(type); - assets.Add(AssUtils.Instance.Assets.Request(data.PreviewTextureName)); - unlocked.Add(mPlayer.droneControllerUnlocked.HasFlag(type)); - tooltips.Add(data.UITooltip); - toUnlock.Add("Craft and use a '" + data.Name + " Components' Item"); - } - } - - return new CircleUIConf(0, -1, assets, unlocked, tooltips, toUnlock); - } - - /// - /// Called in Mod.Load - /// - public static void DoLoad() - { - if (!ContentConfig.Instance.Weapons) - { - return; - } - - Array a = Enum.GetValues(typeof(DroneType)); - DataList = new DroneData[a.Length - 1]; //without None - int i = 0; - foreach (DroneType type in a) - { - if (type != DroneType.None) - { - DataList[i++] = SetDroneData(type); - } - } - } - - public override void Unload() - { - DataList = null; - } - #endregion - - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Drone Controller"); - Tooltip.SetDefault("Summons a friendly Drone to support or fight for you" - + "\nRight click to pick from available drones" - + "\nHolding the item improves the Drones' supportive and offensive abilities"); - } - - public const int BaseDmg = 22; - public const float BaseKB = 2.5f; - - public override void SetDefaults() - { - Item.damage = BaseDmg; - Item.knockBack = BaseKB; - Item.DamageType = DamageClass.Summon; - Item.mana = 10; - Item.width = 28; - Item.height = 30; - Item.useTime = 30; - Item.useAnimation = 30; - Item.useStyle = ItemUseStyleID.HoldUp; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.value = Item.sellPrice(0, 0, 75, 0); - Item.rare = -11; - Item.UseSound = SoundID.Item44; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; - Item.buffType = ModContent.BuffType(); - } - - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) - { - AssPlayer mPlayer = player.GetModPlayer(); - - DroneType selected = mPlayer.selectedDroneControllerMinionType; - damage += GetDroneData(selected).DmgModifier; - } - - public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) - { - AssPlayer mPlayer = player.GetModPlayer(); - - DroneType selected = mPlayer.selectedDroneControllerMinionType; - knockback *= GetDroneData(selected).KBModifier; - } - - public override bool CanUseItem(Player player) - { - if (Main.netMode != NetmodeID.Server && player.whoAmI == Main.myPlayer) - { - AssPlayer mPlayer = player.GetModPlayer(); - DroneType selected = mPlayer.selectedDroneControllerMinionType; - - if (!CanSpawn(player, selected, out _)) - { - return false; - } - } - return true; - } - - public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - AssPlayer mPlayer = player.GetModPlayer(); - DroneType selected = mPlayer.selectedDroneControllerMinionType; - DroneData droneData = GetDroneData(selected); - type = droneData.ProjType; - - int index = AssUtils.NewProjectile(source, player.Center.X, player.Center.Y, 0f, player.velocity.Y - 6f, type, damage, knockback, preSync: PreSync); - Main.projectile[index].originalDamage = (int)(Item.damage * (1f + droneData.DmgModifier)); - return false; - } - - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.HallowedBar, 1).AddIngredient(ItemID.Switch, 2).AddIngredient(ItemID.Wire, 10).AddTile(TileID.MythrilAnvil).Register(); - } - - public override void ModifyTooltips(List tooltips) - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - DroneType selected = mPlayer.selectedDroneControllerMinionType; - - DroneData data = GetDroneData(selected); - - int damageIndex = -1; - int knockbackIndex = -1; - - bool hasController = Main.LocalPlayer.HasItem(Item.type); - - for (int i = 0; i < tooltips.Count; i++) - { - TooltipLine line = tooltips[i]; - if (hasController) - { - if (line.Mod == "Terraria" && line.Name == "ItemName") - { - line.Text += " (" + data.Name + ")"; - } - } - - if (line.Mod == "Terraria" && line.Name == "Damage") - { - damageIndex = i; - } - - if (line.Mod == "Terraria" && line.Name == "Knockback") - { - knockbackIndex = i; - } - } - - if (damageIndex > -1) - { - if (!data.Combat) - { - tooltips.RemoveAt(damageIndex); - } - } - - if (knockbackIndex != -1) - { - if (data.Combat) - { - if (data.Firerate != "") tooltips.Insert(knockbackIndex, new TooltipLine(Mod, "Firerate", data.Firerate + " firerate")); - } - else - { - //here damageIndex one is removed, so find knockbackindex again - knockbackIndex = tooltips.FindIndex(line => line.Name == "Knockback"); - if (knockbackIndex > -1) tooltips.RemoveAt(knockbackIndex); - } - } - - bool allUnlocked = AllUnlocked(mPlayer.droneControllerUnlocked); - - if (!(allUnlocked && hasController)) - { - tooltips.Add(new TooltipLine(Mod, "Destroyer", "Defeat The Destroyer to unlock more drones")); - } - - CanSpawn(Main.LocalPlayer, selected, out bool blocked); - if (hasController && blocked) - { - tooltips.Add(new TooltipLine(Mod, "CanSpawn", "Only one " + data.Name + " can be out at once")); - } - } - } - - /// - /// Holds data about a DroneType - /// - public struct DroneData - { - public readonly int ProjType; - public readonly string Name; - public readonly float DmgModifier; - public readonly float KBModifier; - public readonly string UITooltip; - public readonly string Firerate; - public readonly bool Combat; - - public string PreviewTextureName - { - get - { - return "Projectiles/Minions/Drones/" + Name.Replace(" ", "") + "Preview"; - } - } - - public DroneData(int projType, string name, string desc, string misc = "", string firerate = "", float dmgModifier = 0f, float kBModifier = 1f, bool combat = true) - { - ProjType = projType; - Name = name; - DmgModifier = dmgModifier; - KBModifier = kBModifier; - Firerate = firerate; - string stats = combat ? ("\nBase Damage: " + (int)(DroneController.BaseDmg * (DmgModifier + 1f)) - + "\nBase Knockback: " + Math.Round(DroneController.BaseKB * KBModifier, 1)) : ""; - UITooltip = Name + stats + "\n" + desc + "\n" + misc; - Combat = combat; - } - } - - - - /// - /// The type of drone enumerated, so you can check against it via .HasFlag(DroneType.SomeType) - /// - [Flags] - public enum DroneType : byte - { - None = 0, - BasicLaser = 1, - HeavyLaser = 2, - Missile = 4, - Healing = 8, - Shield = 16 - } + public class DroneController : MinionItemBase + { + #region Static Methods + /// + /// Checks if drones are unlocked + /// + public static bool AllUnlocked(DroneType unlocked) + { + foreach (DroneType type in Enum.GetValues(typeof(DroneType))) + { + if (type != DroneType.None) + { + if (!unlocked.HasFlag(type)) + { + return false; + } + } + } + return true; + } + + /// + /// Checks if all drones are unlocked for the player + /// + public static bool AllUnlocked(Player player) + { + return AllUnlocked(player.GetModPlayer().droneControllerUnlocked); + } + + /// + /// Returns the custom MinionPos + /// + public static int GetSlotOfNextDrone(Projectile self) + { + int slot = 0; + int min = Main.maxProjectiles; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active) + { + if (proj.owner == self.owner && proj.identity != self.identity) + { + if (proj.ModProjectile is DroneBase drone && drone.IsCombatDrone) + { + int minionPos = drone.MinionPos; + min = Math.Min(min, minionPos); + if (minionPos > slot) slot = minionPos; + } + } + } + } + if (min > 0) return 0; + + return slot + 1; + } + + /// + /// Determines position for the current projectile based on minionPos + /// + public static Vector2 GetPosition(Projectile projectile, int minionPos) + { + int initialVecticalOffset = -70; + int initialHorizontalOffset = 0; + int verticalOffset = -(int)(projectile.height * 1.2f); + int horizontalOffset = (int)(projectile.width * 1.75f); + int tempPos = minionPos % 6; + int side = minionPos % 2; //1 means left, 0 means right + int columnOffset = minionPos / 6 + 1; //1 for <6, 2 for <12, etc + + int rowOffset = tempPos / 2; //0, 1 or 2 + + int middleOffset = 0; + if (rowOffset == 1) middleOffset = horizontalOffset / 2; //the middle one + + Vector2 offset = new Vector2 + ( + initialHorizontalOffset + columnOffset * horizontalOffset + middleOffset, + initialVecticalOffset + rowOffset * verticalOffset + ); + offset.X *= side == 1 ? -1 : 1; + return offset; + } + + public static int SumOfSummonedDrones(Player player) + { + int sum = 0; + for (int i = 0; i < DataList.Length; i++) + { + sum += player.ownedProjectileCounts[DataList[i].ProjType]; + } + return sum; + } + + public static bool CanSpawn(Player player, DroneType selected, out bool blocked) + { + bool canSpawn = true; + blocked = false; + if (selected == DroneType.Healing || selected == DroneType.Shield) + { + canSpawn = player.ownedProjectileCounts[GetDroneData(selected).ProjType] == 0; + if (!canSpawn) blocked = true; + } + canSpawn &= player.GetModPlayer().droneControllerUnlocked.HasFlag(selected); + return canSpawn; + } + + private static void PreSync(Projectile proj) + { + if (proj.ModProjectile is DroneBase drone && drone.IsCombatDrone) + { + drone.MinionPos = GetSlotOfNextDrone(proj); + } + } + + /// + /// Sets the data up for a DroneType + /// + public static DroneData SetDroneData(DroneType selected) + { + switch (selected) + { + case DroneType.BasicLaser: + return new DroneData + ( + projType: ModContent.ProjectileType(), + name: "Basic Laser Drone", + desc: "Rapidly fires lasers", + firerate: "High" + ); + case DroneType.HeavyLaser: + return new DroneData + ( + projType: ModContent.ProjectileType(), + name: "Heavy Laser Drone", + desc: "Fires a penetrating laser after a long delay", + firerate: "Extremely slow", + dmgModifier: 8.091f, + kBModifier: 4f + ); + case DroneType.Missile: + return new DroneData + ( + projType: ModContent.ProjectileType(), + name: "Missile Drone", + desc: "Fires a salvo of missiles after a long delay", + firerate: "Very slow", + dmgModifier: 2.19f, + kBModifier: 1.2f + ); + case DroneType.Healing: + return new DroneData + ( + projType: ModContent.ProjectileType(), + name: "Healing Drone", + desc: "Heals you when hurt", + misc: "Only one can be summoned", + combat: false + ); + case DroneType.Shield: + return new DroneData + ( + projType: ModContent.ProjectileType(), + name: "Shield Drone", + desc: "Creates a damage reducing shield over time", + misc: "Only one can be summoned\nShield resets if drone despawns", + combat: false + ); + default: + throw new Exception("No DroneType specified"); + } + } + + /// + /// Holds data about each DroneType + /// + public static DroneData[] DataList; + + /// + /// Used to access a particular DroneTypes data + /// + public static DroneData GetDroneData(DroneType selected) + { + return DataList[(int)Math.Log((int)selected, 2)]; + } + + public static CircleUIConf GetUIConf() + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + List tooltips = new List(); + List toUnlock = new List(); + List> assets = new List>(); + List unlocked = new List(); + + foreach (DroneType type in Enum.GetValues(typeof(DroneType))) + { + if (type != DroneType.None) + { + DroneData data = GetDroneData(type); + assets.Add(AssUtils.Instance.Assets.Request(data.PreviewTextureName)); + unlocked.Add(mPlayer.droneControllerUnlocked.HasFlag(type)); + tooltips.Add(data.UITooltip); + toUnlock.Add("Craft and use a '" + data.Name + " Components' Item"); + } + } + + return new CircleUIConf(0, -1, assets, unlocked, tooltips, toUnlock); + } + + /// + /// Called in Mod.Load + /// + public static void DoLoad() + { + if (!ContentConfig.Instance.Weapons) + { + return; + } + + Array a = Enum.GetValues(typeof(DroneType)); + DataList = new DroneData[a.Length - 1]; //without None + int i = 0; + foreach (DroneType type in a) + { + if (type != DroneType.None) + { + DataList[i++] = SetDroneData(type); + } + } + } + + public override void Unload() + { + DataList = null; + } + #endregion + + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Drone Controller"); + Tooltip.SetDefault("Summons a friendly Drone to support or fight for you" + + "\nRight click to pick from available drones" + + "\nHolding the item improves the Drones' supportive and offensive abilities"); + } + + public const int BaseDmg = 22; + public const float BaseKB = 2.5f; + + public override void SetDefaults() + { + Item.damage = BaseDmg; + Item.knockBack = BaseKB; + Item.DamageType = DamageClass.Summon; + Item.mana = 10; + Item.width = 28; + Item.height = 30; + Item.useTime = 30; + Item.useAnimation = 30; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.value = Item.sellPrice(0, 0, 75, 0); + Item.rare = -11; + Item.UseSound = SoundID.Item44; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; + Item.buffType = ModContent.BuffType(); + } + + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) + { + AssPlayer mPlayer = player.GetModPlayer(); + + DroneType selected = mPlayer.selectedDroneControllerMinionType; + damage += GetDroneData(selected).DmgModifier; + } + + public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) + { + AssPlayer mPlayer = player.GetModPlayer(); + + DroneType selected = mPlayer.selectedDroneControllerMinionType; + knockback *= GetDroneData(selected).KBModifier; + } + + public override bool CanUseItem(Player player) + { + if (Main.netMode != NetmodeID.Server && player.whoAmI == Main.myPlayer) + { + AssPlayer mPlayer = player.GetModPlayer(); + DroneType selected = mPlayer.selectedDroneControllerMinionType; + + if (!CanSpawn(player, selected, out _)) + { + return false; + } + } + return true; + } + + public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + AssPlayer mPlayer = player.GetModPlayer(); + DroneType selected = mPlayer.selectedDroneControllerMinionType; + DroneData droneData = GetDroneData(selected); + type = droneData.ProjType; + + int index = AssUtils.NewProjectile(source, player.Center.X, player.Center.Y, 0f, player.velocity.Y - 6f, type, damage, knockback, preSync: PreSync); + Main.projectile[index].originalDamage = (int)(Item.damage * (1f + droneData.DmgModifier)); + return false; + } + + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.HallowedBar, 1).AddIngredient(ItemID.Switch, 2).AddIngredient(ItemID.Wire, 10).AddTile(TileID.MythrilAnvil).Register(); + } + + public override void ModifyTooltips(List tooltips) + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + DroneType selected = mPlayer.selectedDroneControllerMinionType; + + DroneData data = GetDroneData(selected); + + int damageIndex = -1; + int knockbackIndex = -1; + + bool hasController = Main.LocalPlayer.HasItem(Item.type); + + for (int i = 0; i < tooltips.Count; i++) + { + TooltipLine line = tooltips[i]; + if (hasController) + { + if (line.Mod == "Terraria" && line.Name == "ItemName") + { + line.Text += " (" + data.Name + ")"; + } + } + + if (line.Mod == "Terraria" && line.Name == "Damage") + { + damageIndex = i; + } + + if (line.Mod == "Terraria" && line.Name == "Knockback") + { + knockbackIndex = i; + } + } + + if (damageIndex > -1) + { + if (!data.Combat) + { + tooltips.RemoveAt(damageIndex); + } + } + + if (knockbackIndex != -1) + { + if (data.Combat) + { + if (data.Firerate != "") tooltips.Insert(knockbackIndex, new TooltipLine(Mod, "Firerate", data.Firerate + " firerate")); + } + else + { + //here damageIndex one is removed, so find knockbackindex again + knockbackIndex = tooltips.FindIndex(line => line.Name == "Knockback"); + if (knockbackIndex > -1) tooltips.RemoveAt(knockbackIndex); + } + } + + bool allUnlocked = AllUnlocked(mPlayer.droneControllerUnlocked); + + if (!(allUnlocked && hasController)) + { + tooltips.Add(new TooltipLine(Mod, "Destroyer", "Defeat The Destroyer to unlock more drones")); + } + + CanSpawn(Main.LocalPlayer, selected, out bool blocked); + if (hasController && blocked) + { + tooltips.Add(new TooltipLine(Mod, "CanSpawn", "Only one " + data.Name + " can be out at once")); + } + } + } + + /// + /// Holds data about a DroneType + /// + public struct DroneData + { + public readonly int ProjType; + public readonly string Name; + public readonly float DmgModifier; + public readonly float KBModifier; + public readonly string UITooltip; + public readonly string Firerate; + public readonly bool Combat; + + public string PreviewTextureName + { + get + { + return "Projectiles/Minions/Drones/" + Name.Replace(" ", "") + "Preview"; + } + } + + public DroneData(int projType, string name, string desc, string misc = "", string firerate = "", float dmgModifier = 0f, float kBModifier = 1f, bool combat = true) + { + ProjType = projType; + Name = name; + DmgModifier = dmgModifier; + KBModifier = kBModifier; + Firerate = firerate; + string stats = combat ? ("\nBase Damage: " + (int)(DroneController.BaseDmg * (DmgModifier + 1f)) + + "\nBase Knockback: " + Math.Round(DroneController.BaseKB * KBModifier, 1)) : ""; + UITooltip = Name + stats + "\n" + desc + "\n" + misc; + Combat = combat; + } + } + + + + /// + /// The type of drone enumerated, so you can check against it via .HasFlag(DroneType.SomeType) + /// + [Flags] + public enum DroneType : byte + { + None = 0, + BasicLaser = 1, + HeavyLaser = 2, + Missile = 4, + Healing = 8, + Shield = 16 + } } diff --git a/Items/Weapons/EverglowLantern.cs b/Items/Weapons/EverglowLantern.cs index 75322153..b233a293 100644 --- a/Items/Weapons/EverglowLantern.cs +++ b/Items/Weapons/EverglowLantern.cs @@ -10,98 +10,98 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Bosses)] - public class EverglowLantern : MinionItemBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Everglow Lantern"); - Tooltip.SetDefault("Summons two freed Dungeon Souls at a time to fight for you\nEach Dungeon Soul occupies only half a minion slot"); - } + [Content(ContentType.Bosses)] + public class EverglowLantern : MinionItemBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Everglow Lantern"); + Tooltip.SetDefault("Summons two freed Dungeon Souls at a time to fight for you\nEach Dungeon Soul occupies only half a minion slot"); + } - public override void SetDefaults() - { - //Defaults for damage, shoot and knockback dont matter too much here - //default to PreWol - Item.damage = EverhallowedLantern.BaseDmg / 2 - 1; - Item.DamageType = DamageClass.Summon; - Item.mana = 10; - Item.width = 22; - Item.height = 38; - Item.useTime = 36; - Item.useAnimation = 36; - Item.useStyle = ItemUseStyleID.HoldUp; //4 for life crystal - Item.noMelee = true; - Item.value = Item.sellPrice(0, 0, 75, 0); - Item.rare = -11; - Item.UseSound = SoundID.Item44; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; - Item.knockBack = EverhallowedLantern.BaseKB; - Item.buffType = ModContent.BuffType(); - } + public override void SetDefaults() + { + //Defaults for damage, shoot and knockback dont matter too much here + //default to PreWol + Item.damage = EverhallowedLantern.BaseDmg / 2 - 1; + Item.DamageType = DamageClass.Summon; + Item.mana = 10; + Item.width = 22; + Item.height = 38; + Item.useTime = 36; + Item.useAnimation = 36; + Item.useStyle = ItemUseStyleID.HoldUp; //4 for life crystal + Item.noMelee = true; + Item.value = Item.sellPrice(0, 0, 75, 0); + Item.rare = -11; + Item.UseSound = SoundID.Item44; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; + Item.knockBack = EverhallowedLantern.BaseKB; + Item.buffType = ModContent.BuffType(); + } - public override bool AltFunctionUse(Player player) - { - return false; //true - } + public override bool AltFunctionUse(Player player) + { + return false; //true + } - public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - //one that shoots out far - int index = Projectile.NewProjectile(source, player.Center.X + player.direction * 8f, player.Bottom.Y - 12f, player.velocity.X + player.direction * 1.5f, player.velocity.Y - 1f, type, damage, knockback, Main.myPlayer, 0f, 0f); - Main.projectile[index].originalDamage = Item.damage; + public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + //one that shoots out far + int index = Projectile.NewProjectile(source, player.Center.X + player.direction * 8f, player.Bottom.Y - 12f, player.velocity.X + player.direction * 1.5f, player.velocity.Y - 1f, type, damage, knockback, Main.myPlayer, 0f, 0f); + Main.projectile[index].originalDamage = Item.damage; - //one that shoots out less - index = Projectile.NewProjectile(source, player.Center.X + player.direction * 8f, player.Bottom.Y - 10f, player.velocity.X + player.direction * 1, player.velocity.Y - 1 / 2f, type, damage, knockback, Main.myPlayer, 0f, 0f); - Main.projectile[index].originalDamage = Item.damage; + //one that shoots out less + index = Projectile.NewProjectile(source, player.Center.X + player.direction * 8f, player.Bottom.Y - 10f, player.velocity.X + player.direction * 1, player.velocity.Y - 1 / 2f, type, damage, knockback, Main.myPlayer, 0f, 0f); + Main.projectile[index].originalDamage = Item.damage; - return false; - } + return false; + } - public override void UseStyle(Player player, Rectangle heldItemFrame) - { - player.itemLocation.X = player.Center.X; - player.itemLocation.Y = player.Bottom.Y + 2f; - } + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.itemLocation.X = player.Center.X; + player.itemLocation.Y = player.Bottom.Y + 2f; + } - public override void ModifyTooltips(List tooltips) - { - //need a dummy because you can't remove elements from a list while you are iterating - string[] newDamage; - string tempString; + public override void ModifyTooltips(List tooltips) + { + //need a dummy because you can't remove elements from a list while you are iterating + string[] newDamage; + string tempString; - foreach (TooltipLine line2 in tooltips) - { - if (line2.Mod == "Terraria" && line2.Name == "Damage") - { - try //try catch in case some other mods modify it - { - //split string up into words - newDamage = line2.Text.Split(new string[] { " " }, 10, StringSplitOptions.RemoveEmptyEntries); + foreach (TooltipLine line2 in tooltips) + { + if (line2.Mod == "Terraria" && line2.Name == "Damage") + { + try //try catch in case some other mods modify it + { + //split string up into words + newDamage = line2.Text.Split(new string[] { " " }, 10, StringSplitOptions.RemoveEmptyEntries); - //rebuild text string and add "x 2" after the damage number - tempString = newDamage[0] + " x 2"; + //rebuild text string and add "x 2" after the damage number + tempString = newDamage[0] + " x 2"; - //add remaining words back - for (int i = 1; i < newDamage.Length; i++) - { - tempString += " " + newDamage[i]; - } + //add remaining words back + for (int i = 1; i < newDamage.Length; i++) + { + tempString += " " + newDamage[i]; + } - line2.Text = tempString; - } - catch (Exception) - { + line2.Text = tempString; + } + catch (Exception) + { - } - } - } - } + } + } + } + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.MeteoriteBar, 5).AddIngredient(ModContent.ItemType(), 2).AddTile(TileID.Anvils).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.MeteoriteBar, 5).AddIngredient(ModContent.ItemType(), 2).AddTile(TileID.Anvils).Register(); + } + } } diff --git a/Items/Weapons/EverhallowedLantern.cs b/Items/Weapons/EverhallowedLantern.cs index dab59ea0..1177161f 100644 --- a/Items/Weapons/EverhallowedLantern.cs +++ b/Items/Weapons/EverhallowedLantern.cs @@ -15,292 +15,292 @@ namespace AssortedCrazyThings.Items.Weapons { - /// - /// Holds the type of Dungeon Soul (All just for Everhallowed Lantern) - /// - [Flags] - public enum SoulType : byte - { - None = 0, - Dungeon = 1, - Fright = 2, - Sight = 4, - Might = 8, - } - - /// - /// Holds data about a SoulType - /// - public struct SoulData - { - public readonly int ProjType; - public readonly string Name; - - public readonly float DmgModifier; - public readonly float KBModifier; - public readonly string Tooltip; - public readonly string ToUnlock; - public readonly Func Unlocked; - - public SoulData(int projType, string name, string desc = "", string toUnlock = "", Func unlocked = null, float dmgModifier = 0f, float kBModifier = 0f) - { - ProjType = projType; - Name = name; - DmgModifier = dmgModifier; - KBModifier = kBModifier; - ToUnlock = toUnlock; - Unlocked = unlocked ?? (() => true); - string stats = "\nBase Damage: " + (int)(EverhallowedLantern.BaseDmg * (DmgModifier + 1f)) - + "\nBase Knockback: " + Math.Round(EverhallowedLantern.BaseKB * (KBModifier + 1f), 1); - Tooltip = Name + stats + "\n" + desc; - } - } - - [Content(ContentType.Bosses)] - public class EverhallowedLantern : MinionItemBase - { - public const int BaseDmg = 26; - public const float BaseKB = 0.5f; - - #region Static Methods - /// - /// Sets the data up for a SoulType - /// - public static SoulData SetSoulData(SoulType selected) - { - switch (selected) - { - case SoulType.Dungeon: - return new SoulData - ( - projType: ModContent.ProjectileType(), - name: "Dungeon Soul", - dmgModifier: 0.1f - ); - case SoulType.Fright: - return new SoulData - ( - projType: ModContent.ProjectileType(), - name: "Soul of Fright", - desc: "Inflicts Ichor and Posioned", - toUnlock: "Defeat Skeletron Prime", - unlocked: () => NPC.downedMechBoss3, - dmgModifier: 0.25f, - kBModifier: 3f - ); - case SoulType.Sight: - return new SoulData - ( - projType: ModContent.ProjectileType(), - name: "Soul of Sight", - desc: "Inflicts Cursed Inferno", - toUnlock: "Defeat The Twins", - unlocked: () => NPC.downedMechBoss2, - dmgModifier: -0.15f - ); - case SoulType.Might: - return new SoulData - ( - projType: ModContent.ProjectileType(), - name: "Soul of Might", - toUnlock: "Defeat The Destroyer", - unlocked: () => NPC.downedMechBoss1, - dmgModifier: 0.55f, - kBModifier: 7f - ); - default: - throw new Exception("No SoulData specified"); - } - } - - /// - /// Holds data about each SoulType - /// - public static SoulData[] DataList; - - /// - /// Used to access a particular SoulTypes data - /// - public static SoulData GetSoulData(SoulType selected) - { - return DataList[(int)Math.Log((int)selected, 2)]; - } - - public static CircleUIConf GetUIConf() - { - List tooltips = new List(); - List toUnlock = new List(); - List> assets = new List>(); - List unlocked = new List(); - - int firstValidProjType = -1; - foreach (SoulType type in Enum.GetValues(typeof(SoulType))) - { - if (type != SoulType.None) - { - SoulData data = GetSoulData(type); - firstValidProjType = data.ProjType; - assets.Add(TextureAssets.Projectile[firstValidProjType]); - unlocked.Add(data.Unlocked()); - tooltips.Add(data.Tooltip); - toUnlock.Add(data.ToUnlock); - } - } - - return new CircleUIConf(firstValidProjType == -1 ? 0 : Main.projFrames[firstValidProjType], -1, assets, unlocked, tooltips, toUnlock); - } - - /// - /// Called in Mod.Load - /// - public static void DoLoad() - { - if (!ContentConfig.Instance.Bosses) - { - return; - } - - Array a = Enum.GetValues(typeof(SoulType)); - DataList = new SoulData[a.Length - 1]; //without None - int i = 0; - foreach (SoulType type in a) - { - if (type != SoulType.None) - { - DataList[i++] = SetSoulData(type); - } - } - } - - /// - /// Called in Mod.Unload - /// - public static void DoUnload() - { - DataList = null; - } - #endregion - - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Everhallowed Lantern"); - //"Summons a Soul to fight for you" is changed for the appropriate type in ModifyTooltips - Tooltip.SetDefault("Summons a Soul to fight for you" - + "\nRight click to pick from available forms"); - } - - public override void SetDefaults() - { - //Defaults for damage, shoot and knockback dont matter too much here, only for the first summon - //default to PostWOF - Item.damage = BaseDmg; - Item.knockBack = BaseKB; - Item.DamageType = DamageClass.Summon; - Item.mana = 10; - Item.width = 26; - Item.height = 40; - Item.useTime = 30; - Item.useAnimation = 30; - Item.useStyle = ItemUseStyleID.HoldUp; //4 for life crystal - Item.noMelee = true; - Item.value = Item.sellPrice(0, 0, 95, 0); - Item.rare = -11; - Item.UseSound = SoundID.Item44; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; - Item.buffType = ModContent.BuffType(); - } - - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) - { - AssPlayer mPlayer = player.GetModPlayer(); - - SoulType selected = mPlayer.selectedSoulMinionType; - damage += GetSoulData(selected).DmgModifier; - } - - public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) - { - AssPlayer mPlayer = player.GetModPlayer(); - - SoulType selected = mPlayer.selectedSoulMinionType; - knockback *= GetSoulData(selected).KBModifier; - } - - public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - AssPlayer mPlayer = player.GetModPlayer(); - SoulType selected = mPlayer.selectedSoulMinionType; - SoulData soulData = GetSoulData(selected); - type = soulData.ProjType; - - Vector2 spawnPos = new Vector2(player.Center.X + player.direction * 8f, player.Bottom.Y - 12f); - Vector2 spawnVelo = new Vector2(player.velocity.X + player.direction * 1.5f, player.velocity.Y - 1f); - - int index = Projectile.NewProjectile(source, spawnPos, spawnVelo, type, damage, knockback, Main.myPlayer, 0f, 0f); - Main.projectile[index].originalDamage = (int)(Item.damage * (1f + soulData.DmgModifier)); - return false; - } - - public override void UseStyle(Player player, Rectangle heldItemFrame) - { - player.itemLocation.X = player.Center.X; - player.itemLocation.Y = player.Bottom.Y + 2f; - } - - public override void ModifyTooltips(List tooltips) - { - AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); - SoulType selected = mPlayer.selectedSoulMinionType; - - SoulData data = GetSoulData(selected); - - TooltipLine line = new TooltipLine(Mod, "dummy", "dummy"); - - for (int i = 0; i < tooltips.Count; i++) - { - if (Main.LocalPlayer.HasItem(ModContent.ItemType())) - { - if (tooltips[i].Mod == "Terraria" && tooltips[i].Name == "ItemName") - { - tooltips[i].Text += " (" + data.Name + ")"; - } - } - - if (tooltips[i].Mod == "Terraria" && tooltips[i].Name == "Tooltip0") - { - line = tooltips[i]; - } - } - - int tooltipIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); - - if (line.Name != "dummy") tooltips.Remove(line); - - bool allUnlocked = true; - foreach (SoulType type in Enum.GetValues(typeof(SoulType))) - { - if (type != SoulType.None) - { - data = GetSoulData(type); - if (!data.Unlocked()) - { - allUnlocked = false; - } - } - } - - if (!(allUnlocked && Main.LocalPlayer.HasItem(Item.type))) - { - tooltips.Insert(tooltipIndex++, new TooltipLine(Mod, "Mech", "Defeat mechanical bosses to unlock new minions")); - } - - tooltips.Insert(tooltipIndex++, new TooltipLine(Mod, "Boost", "30% damage increase from wearing the 'Soul Savior' Set")); - } - - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.SoulofNight, 5).AddIngredient(ItemID.SoulofLight, 5).AddIngredient(ModContent.ItemType(), 1).AddTile(TileID.MythrilAnvil).Register(); - } - } + /// + /// Holds the type of Dungeon Soul (All just for Everhallowed Lantern) + /// + [Flags] + public enum SoulType : byte + { + None = 0, + Dungeon = 1, + Fright = 2, + Sight = 4, + Might = 8, + } + + /// + /// Holds data about a SoulType + /// + public struct SoulData + { + public readonly int ProjType; + public readonly string Name; + + public readonly float DmgModifier; + public readonly float KBModifier; + public readonly string Tooltip; + public readonly string ToUnlock; + public readonly Func Unlocked; + + public SoulData(int projType, string name, string desc = "", string toUnlock = "", Func unlocked = null, float dmgModifier = 0f, float kBModifier = 0f) + { + ProjType = projType; + Name = name; + DmgModifier = dmgModifier; + KBModifier = kBModifier; + ToUnlock = toUnlock; + Unlocked = unlocked ?? (() => true); + string stats = "\nBase Damage: " + (int)(EverhallowedLantern.BaseDmg * (DmgModifier + 1f)) + + "\nBase Knockback: " + Math.Round(EverhallowedLantern.BaseKB * (KBModifier + 1f), 1); + Tooltip = Name + stats + "\n" + desc; + } + } + + [Content(ContentType.Bosses)] + public class EverhallowedLantern : MinionItemBase + { + public const int BaseDmg = 26; + public const float BaseKB = 0.5f; + + #region Static Methods + /// + /// Sets the data up for a SoulType + /// + public static SoulData SetSoulData(SoulType selected) + { + switch (selected) + { + case SoulType.Dungeon: + return new SoulData + ( + projType: ModContent.ProjectileType(), + name: "Dungeon Soul", + dmgModifier: 0.1f + ); + case SoulType.Fright: + return new SoulData + ( + projType: ModContent.ProjectileType(), + name: "Soul of Fright", + desc: "Inflicts Ichor and Posioned", + toUnlock: "Defeat Skeletron Prime", + unlocked: () => NPC.downedMechBoss3, + dmgModifier: 0.25f, + kBModifier: 3f + ); + case SoulType.Sight: + return new SoulData + ( + projType: ModContent.ProjectileType(), + name: "Soul of Sight", + desc: "Inflicts Cursed Inferno", + toUnlock: "Defeat The Twins", + unlocked: () => NPC.downedMechBoss2, + dmgModifier: -0.15f + ); + case SoulType.Might: + return new SoulData + ( + projType: ModContent.ProjectileType(), + name: "Soul of Might", + toUnlock: "Defeat The Destroyer", + unlocked: () => NPC.downedMechBoss1, + dmgModifier: 0.55f, + kBModifier: 7f + ); + default: + throw new Exception("No SoulData specified"); + } + } + + /// + /// Holds data about each SoulType + /// + public static SoulData[] DataList; + + /// + /// Used to access a particular SoulTypes data + /// + public static SoulData GetSoulData(SoulType selected) + { + return DataList[(int)Math.Log((int)selected, 2)]; + } + + public static CircleUIConf GetUIConf() + { + List tooltips = new List(); + List toUnlock = new List(); + List> assets = new List>(); + List unlocked = new List(); + + int firstValidProjType = -1; + foreach (SoulType type in Enum.GetValues(typeof(SoulType))) + { + if (type != SoulType.None) + { + SoulData data = GetSoulData(type); + firstValidProjType = data.ProjType; + assets.Add(TextureAssets.Projectile[firstValidProjType]); + unlocked.Add(data.Unlocked()); + tooltips.Add(data.Tooltip); + toUnlock.Add(data.ToUnlock); + } + } + + return new CircleUIConf(firstValidProjType == -1 ? 0 : Main.projFrames[firstValidProjType], -1, assets, unlocked, tooltips, toUnlock); + } + + /// + /// Called in Mod.Load + /// + public static void DoLoad() + { + if (!ContentConfig.Instance.Bosses) + { + return; + } + + Array a = Enum.GetValues(typeof(SoulType)); + DataList = new SoulData[a.Length - 1]; //without None + int i = 0; + foreach (SoulType type in a) + { + if (type != SoulType.None) + { + DataList[i++] = SetSoulData(type); + } + } + } + + /// + /// Called in Mod.Unload + /// + public static void DoUnload() + { + DataList = null; + } + #endregion + + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Everhallowed Lantern"); + //"Summons a Soul to fight for you" is changed for the appropriate type in ModifyTooltips + Tooltip.SetDefault("Summons a Soul to fight for you" + + "\nRight click to pick from available forms"); + } + + public override void SetDefaults() + { + //Defaults for damage, shoot and knockback dont matter too much here, only for the first summon + //default to PostWOF + Item.damage = BaseDmg; + Item.knockBack = BaseKB; + Item.DamageType = DamageClass.Summon; + Item.mana = 10; + Item.width = 26; + Item.height = 40; + Item.useTime = 30; + Item.useAnimation = 30; + Item.useStyle = ItemUseStyleID.HoldUp; //4 for life crystal + Item.noMelee = true; + Item.value = Item.sellPrice(0, 0, 95, 0); + Item.rare = -11; + Item.UseSound = SoundID.Item44; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; + Item.buffType = ModContent.BuffType(); + } + + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) + { + AssPlayer mPlayer = player.GetModPlayer(); + + SoulType selected = mPlayer.selectedSoulMinionType; + damage += GetSoulData(selected).DmgModifier; + } + + public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) + { + AssPlayer mPlayer = player.GetModPlayer(); + + SoulType selected = mPlayer.selectedSoulMinionType; + knockback *= GetSoulData(selected).KBModifier; + } + + public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + AssPlayer mPlayer = player.GetModPlayer(); + SoulType selected = mPlayer.selectedSoulMinionType; + SoulData soulData = GetSoulData(selected); + type = soulData.ProjType; + + Vector2 spawnPos = new Vector2(player.Center.X + player.direction * 8f, player.Bottom.Y - 12f); + Vector2 spawnVelo = new Vector2(player.velocity.X + player.direction * 1.5f, player.velocity.Y - 1f); + + int index = Projectile.NewProjectile(source, spawnPos, spawnVelo, type, damage, knockback, Main.myPlayer, 0f, 0f); + Main.projectile[index].originalDamage = (int)(Item.damage * (1f + soulData.DmgModifier)); + return false; + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.itemLocation.X = player.Center.X; + player.itemLocation.Y = player.Bottom.Y + 2f; + } + + public override void ModifyTooltips(List tooltips) + { + AssPlayer mPlayer = Main.LocalPlayer.GetModPlayer(); + SoulType selected = mPlayer.selectedSoulMinionType; + + SoulData data = GetSoulData(selected); + + TooltipLine line = new TooltipLine(Mod, "dummy", "dummy"); + + for (int i = 0; i < tooltips.Count; i++) + { + if (Main.LocalPlayer.HasItem(ModContent.ItemType())) + { + if (tooltips[i].Mod == "Terraria" && tooltips[i].Name == "ItemName") + { + tooltips[i].Text += " (" + data.Name + ")"; + } + } + + if (tooltips[i].Mod == "Terraria" && tooltips[i].Name == "Tooltip0") + { + line = tooltips[i]; + } + } + + int tooltipIndex = tooltips.FindLastIndex(l => l.Name.StartsWith("Tooltip")); + + if (line.Name != "dummy") tooltips.Remove(line); + + bool allUnlocked = true; + foreach (SoulType type in Enum.GetValues(typeof(SoulType))) + { + if (type != SoulType.None) + { + data = GetSoulData(type); + if (!data.Unlocked()) + { + allUnlocked = false; + } + } + } + + if (!(allUnlocked && Main.LocalPlayer.HasItem(Item.type))) + { + tooltips.Insert(tooltipIndex++, new TooltipLine(Mod, "Mech", "Defeat mechanical bosses to unlock new minions")); + } + + tooltips.Insert(tooltipIndex++, new TooltipLine(Mod, "Boost", "30% damage increase from wearing the 'Soul Savior' Set")); + } + + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.SoulofNight, 5).AddIngredient(ItemID.SoulofLight, 5).AddIngredient(ModContent.ItemType(), 1).AddTile(TileID.MythrilAnvil).Register(); + } + } } diff --git a/Items/Weapons/GoblinUnderlingItem.cs b/Items/Weapons/GoblinUnderlingItem.cs index 5e2f2639..67df4254 100644 --- a/Items/Weapons/GoblinUnderlingItem.cs +++ b/Items/Weapons/GoblinUnderlingItem.cs @@ -2,7 +2,6 @@ using AssortedCrazyThings.Buffs; using AssortedCrazyThings.Projectiles.Minions.GoblinUnderling; using Microsoft.Xna.Framework; -using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,124 +9,124 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class GoblinUnderlingItem : MinionItemBase - { - public const int BaseDmg = 8; - public const float BaseKB = 1.5f; + [Content(ContentType.Weapons)] + public class GoblinUnderlingItem : MinionItemBase + { + public const int BaseDmg = 8; + public const float BaseKB = 1.5f; - public override void Load() - { - On.Terraria.NPC.SetEventFlagCleared += DropItemIfPossible; - } + public override void Load() + { + On.Terraria.NPC.SetEventFlagCleared += DropItemIfPossible; + } - private static void DropItemIfPossible(On.Terraria.NPC.orig_SetEventFlagCleared orig, ref bool eventFlag, int gameEventId) - { - //This is not clientside - orig(ref eventFlag, gameEventId); + private static void DropItemIfPossible(On.Terraria.NPC.orig_SetEventFlagCleared orig, ref bool eventFlag, int gameEventId) + { + //This is not clientside + orig(ref eventFlag, gameEventId); - if (gameEventId == GameEventClearedID.DefeatedGoblinArmy) - { - int itemType = ModContent.ItemType(); + if (gameEventId == GameEventClearedID.DefeatedGoblinArmy) + { + int itemType = ModContent.ItemType(); - static bool Condition(Player player, int itemType) => !player.HasItemWithBanks(itemType); + static bool Condition(Player player, int itemType) => !player.HasItemWithBanks(itemType); - if (Main.netMode == NetmodeID.Server) - { - int itemIndex = -1; - for (int p = 0; p < Main.maxPlayers; p++) - { - Player player = Main.player[p]; - if (player.active) - { - if (Condition(player, itemType)) - { - int item = Item.NewItem(new EntitySource_WorldEvent(), player.Center, itemType, noBroadcast: true); - itemIndex = item; - NetMessage.SendData(MessageID.InstancedItem, p, -1, null, item); - Main.item[item].active = false; - } - } - } + if (Main.netMode == NetmodeID.Server) + { + int itemIndex = -1; + for (int p = 0; p < Main.maxPlayers; p++) + { + Player player = Main.player[p]; + if (player.active) + { + if (Condition(player, itemType)) + { + int item = Item.NewItem(new EntitySource_WorldEvent(), player.Center, itemType, noBroadcast: true); + itemIndex = item; + NetMessage.SendData(MessageID.InstancedItem, p, -1, null, item); + Main.item[item].active = false; + } + } + } - if (itemIndex != -1) - { - Main.timeItemSlotCannotBeReusedFor[itemIndex] = 54000; - } - } - else if (Main.netMode == NetmodeID.SinglePlayer) - { - Player player = Main.LocalPlayer; - if (Condition(player, itemType)) - { - Item.NewItem(new EntitySource_WorldEvent(), player.Center, itemType); - } - } - } - } + if (itemIndex != -1) + { + Main.timeItemSlotCannotBeReusedFor[itemIndex] = 54000; + } + } + else if (Main.netMode == NetmodeID.SinglePlayer) + { + Player player = Main.LocalPlayer; + if (Condition(player, itemType)) + { + Item.NewItem(new EntitySource_WorldEvent(), player.Center, itemType); + } + } + } + } - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Satchel of Goodies"); - Tooltip.SetDefault("Summons a Goblin Underling to fight for you" - + "\nGets stronger throughout progression" - + "\nDoes not occupy a minion slot, but only one can be summoned" - + "\n'Inside, there's a spiky ball, a coin, and a...moon?'"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Satchel of Goodies"); + Tooltip.SetDefault("Summons a Goblin Underling to fight for you" + + "\nGets stronger throughout progression" + + "\nDoes not occupy a minion slot, but only one can be summoned" + + "\n'Inside, there's a spiky ball, a coin, and a...moon?'"); + } - public override void SetDefaults() - { - Item.damage = BaseDmg; - Item.knockBack = BaseKB; - Item.DamageType = DamageClass.Summon; - Item.mana = 10; - Item.width = 30; - Item.height = 30; - Item.useTime = 30; - Item.useAnimation = 30; - Item.useStyle = ItemUseStyleID.HoldUp; - Item.noMelee = true; - Item.value = Item.sellPrice(0, 0, 50, 0); - Item.rare = -11; - Item.UseSound = SoundID.Item44; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 0f; - Item.buffType = ModContent.BuffType(); - } + public override void SetDefaults() + { + Item.damage = BaseDmg; + Item.knockBack = BaseKB; + Item.DamageType = DamageClass.Summon; + Item.mana = 10; + Item.width = 30; + Item.height = 30; + Item.useTime = 30; + Item.useAnimation = 30; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.noMelee = true; + Item.value = Item.sellPrice(0, 0, 50, 0); + Item.rare = -11; + Item.UseSound = SoundID.Item44; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 0f; + Item.buffType = ModContent.BuffType(); + } - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) - { - //This is purely done for the tooltip - damage *= GoblinUnderlingSystem.GetCurrentTier().damageMult; - } + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) + { + //This is purely done for the tooltip + damage *= GoblinUnderlingSystem.GetCurrentTier().damageMult; + } - public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) - { - //This is purely done for the tooltip - knockback *= GoblinUnderlingSystem.GetCurrentTier().knockbackMult; - } + public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) + { + //This is purely done for the tooltip + knockback *= GoblinUnderlingSystem.GetCurrentTier().knockbackMult; + } - public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (player.ownedProjectileCounts[type] > 0) - { - //Use always resummons - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile other = Main.projectile[i]; - if (other.active && other.owner == player.whoAmI && other.type == type) - { - other.Kill(); - } - } - } + public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.ownedProjectileCounts[type] > 0) + { + //Use always resummons + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile other = Main.projectile[i]; + if (other.active && other.owner == player.whoAmI && other.type == type) + { + other.Kill(); + } + } + } - knockback = Item.knockBack; //Use baseline values - int origDamage = Item.damage; + knockback = Item.knockBack; //Use baseline values + int origDamage = Item.damage; - int index = Projectile.NewProjectile(source, position, Vector2.UnitX * player.direction, type, damage, knockback, Main.myPlayer); - Main.projectile[index].originalDamage = origDamage; - return false; - } - } + int index = Projectile.NewProjectile(source, position, Vector2.UnitX * player.direction, type, damage, knockback, Main.myPlayer); + Main.projectile[index].originalDamage = origDamage; + return false; + } + } } diff --git a/Items/Weapons/LegendaryWoodenSword.cs b/Items/Weapons/LegendaryWoodenSword.cs index 6ba003d7..adc87de8 100644 --- a/Items/Weapons/LegendaryWoodenSword.cs +++ b/Items/Weapons/LegendaryWoodenSword.cs @@ -5,47 +5,47 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class LegendaryWoodenSword : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Legendary Wooden Sword"); - } + [Content(ContentType.Weapons)] + public class LegendaryWoodenSword : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Legendary Wooden Sword"); + } - public override void SetDefaults() - { - //Item.CloneDefaults(ItemID.IronShortsword); - Item.damage = 8; - Item.knockBack = 4f; - Item.shootSpeed = 2.1f; - Item.useStyle = 13; - Item.useAnimation = 12; - Item.useTime = 12; - Item.width = 32; - Item.height = 32; - Item.UseSound = SoundID.Item1; - Item.DamageType = DamageClass.Melee; - Item.autoReuse = false; - Item.noMelee = true; - Item.noUseGraphic = true; + public override void SetDefaults() + { + //Item.CloneDefaults(ItemID.IronShortsword); + Item.damage = 8; + Item.knockBack = 4f; + Item.shootSpeed = 2.1f; + Item.useStyle = 13; + Item.useAnimation = 12; + Item.useTime = 12; + Item.width = 32; + Item.height = 32; + Item.UseSound = SoundID.Item1; + Item.DamageType = DamageClass.Melee; + Item.autoReuse = false; + Item.noMelee = true; + Item.noUseGraphic = true; - Item.rare = -11; - Item.value = Item.sellPrice(0, 0, 0, 10); //Woods have no sell value, just make this 10 copper cause why not - Item.shoot = ModContent.ProjectileType(); - } + Item.rare = -11; + Item.value = Item.sellPrice(0, 0, 0, 10); //Woods have no sell value, just make this 10 copper cause why not + Item.shoot = ModContent.ProjectileType(); + } - public override void AddRecipes() - { - CreateRecipe() - .AddIngredient(ItemID.Wood, 10) - .AddIngredient(ItemID.BorealWood, 10) - .AddIngredient(ItemID.PalmWood, 10) - .AddIngredient(ItemID.RichMahogany, 10) - .AddIngredient(ItemID.Wood, 10) - .AddRecipeGroup("ACT:EvilWood", 10) - .AddTile(TileID.WorkBenches) - .Register(); - } - } + public override void AddRecipes() + { + CreateRecipe() + .AddIngredient(ItemID.Wood, 10) + .AddIngredient(ItemID.BorealWood, 10) + .AddIngredient(ItemID.PalmWood, 10) + .AddIngredient(ItemID.RichMahogany, 10) + .AddIngredient(ItemID.Wood, 10) + .AddRecipeGroup("ACT:EvilWood", 10) + .AddTile(TileID.WorkBenches) + .Register(); + } + } } diff --git a/Items/Weapons/MagicSlimeSling.cs b/Items/Weapons/MagicSlimeSling.cs index 46a7bff7..39ad3c28 100644 --- a/Items/Weapons/MagicSlimeSling.cs +++ b/Items/Weapons/MagicSlimeSling.cs @@ -9,91 +9,91 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class MagicSlimeSling : AssItem - { - public static Color GetColor(byte c) - { - //, 100 Alpha - return c switch - { - 0 => new Color(0, 80, 255),//blue - 1 => new Color(0, 220, 40),//green - _ => new Color(255, 30, 0),//red - }; - } + [Content(ContentType.Weapons)] + public class MagicSlimeSling : AssItem + { + public static Color GetColor(byte c) + { + //, 100 Alpha + return c switch + { + 0 => new Color(0, 80, 255),//blue + 1 => new Color(0, 220, 40),//green + _ => new Color(255, 30, 0),//red + }; + } - private void PreSync(Projectile proj) - { - if (proj.ModProjectile is MagicSlimeSlingFired fired) - { - fired.ColorType = proj.GetOwner().GetModPlayer().nextMagicSlimeSlingMinion; - //Color won't be synced, its assigned in send/recv - fired.Color = GetColor(fired.ColorType); - } - } + private void PreSync(Projectile proj) + { + if (proj.ModProjectile is MagicSlimeSlingFired fired) + { + fired.ColorType = proj.GetOwner().GetModPlayer().nextMagicSlimeSlingMinion; + //Color won't be synced, its assigned in send/recv + fired.Color = GetColor(fired.ColorType); + } + } - public const byte MagicSlimeSlingMinionTypes = 3; + public const byte MagicSlimeSlingMinionTypes = 3; - public static int[] Types => new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }; + public static int[] Types => new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Magic Slime Sling"); - Tooltip.SetDefault("Shoots magic gel that turns into slime minions on hit"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Magic Slime Sling"); + Tooltip.SetDefault("Shoots magic gel that turns into slime minions on hit"); + } - public override void SetDefaults() - { - Item.width = 12; - Item.height = 24; - Item.DamageType = DamageClass.Summon; - Item.damage = 5; - Item.useStyle = ItemUseStyleID.Thrust; - Item.useTime = 35; - Item.useAnimation = 35; - Item.UseSound = SoundID.Item19; - Item.mana = 10; - Item.shootSpeed = 9f; - Item.shoot = ModContent.ProjectileType(); - Item.rare = -11; - Item.value = Item.sellPrice(silver: 15); - } + public override void SetDefaults() + { + Item.width = 12; + Item.height = 24; + Item.DamageType = DamageClass.Summon; + Item.damage = 5; + Item.useStyle = ItemUseStyleID.Thrust; + Item.useTime = 35; + Item.useAnimation = 35; + Item.UseSound = SoundID.Item19; + Item.mana = 10; + Item.shootSpeed = 9f; + Item.shoot = ModContent.ProjectileType(); + Item.rare = -11; + Item.value = Item.sellPrice(silver: 15); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Gel, 20).AddIngredient(ItemID.FallenStar, 3).AddTile(TileID.WorkBenches).Register(); - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Gel, 20).AddIngredient(ItemID.FallenStar, 3).AddTile(TileID.WorkBenches).Register(); + } - private int YOff => Item.height / 4; + private int YOff => Item.height / 4; - public override void UseStyle(Player player, Rectangle heldItemFrame) - { - //using shortsword arm position but reset the movement/rotation stuff - player.itemLocation.X = player.Center.X; - player.itemLocation.Y = player.Center.Y + YOff; - player.itemRotation = 0f; - } + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + //using shortsword arm position but reset the movement/rotation stuff + player.itemLocation.X = player.Center.X; + player.itemLocation.Y = player.Center.Y + YOff; + player.itemRotation = 0f; + } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - AssPlayer mPlayer = player.GetModPlayer(); - float magnitude = velocity.Length(); - velocity.Y = -1f; - velocity.X = magnitude * Math.Sign(velocity.X); + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + AssPlayer mPlayer = player.GetModPlayer(); + float magnitude = velocity.Length(); + velocity.Y = -1f; + velocity.X = magnitude * Math.Sign(velocity.X); - //PreSync uses current mPlayer.nextMagicSlimeSlingMinion - int index = AssUtils.NewProjectile(source, position.X, position.Y - YOff, velocity.X, velocity.Y, type, damage, knockback, preSync: PreSync); - Main.projectile[index].originalDamage = Item.damage; + //PreSync uses current mPlayer.nextMagicSlimeSlingMinion + int index = AssUtils.NewProjectile(source, position.X, position.Y - YOff, velocity.X, velocity.Y, type, damage, knockback, preSync: PreSync); + Main.projectile[index].originalDamage = Item.damage; - //switch to next type - mPlayer.nextMagicSlimeSlingMinion = (byte)((mPlayer.nextMagicSlimeSlingMinion + 1) % MagicSlimeSlingMinionTypes); - return false; - } - } + //switch to next type + mPlayer.nextMagicSlimeSlingMinion = (byte)((mPlayer.nextMagicSlimeSlingMinion + 1) % MagicSlimeSlingMinionTypes); + return false; + } + } } diff --git a/Items/Weapons/MinionItemBase.cs b/Items/Weapons/MinionItemBase.cs index 388eea9c..eb23dc4a 100644 --- a/Items/Weapons/MinionItemBase.cs +++ b/Items/Weapons/MinionItemBase.cs @@ -1,41 +1,41 @@ -using Terraria; using Microsoft.Xna.Framework; +using Terraria; using Terraria.DataStructures; using Terraria.ID; namespace AssortedCrazyThings.Items.Weapons { - //Custom damage scaling works as long as you use the same calculations as ModifyWeaponDamage (NOT calling GetWeaponDamage, that might have modded buffs) - /// - /// Item that applies a buff. Does not spawn a projectile on use by default - /// - [Content(ContentType.Weapons)] - public abstract class MinionItemBase : AssItem - { - public sealed override void SetStaticDefaults() - { - ItemID.Sets.GamepadWholeScreenUseRange[Type] = true; - ItemID.Sets.LockOnIgnoresCollision[Type] = true; - - SafeSetStaticDefaults(); - } - - - public virtual void SafeSetStaticDefaults() - { - - } - - public sealed override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - player.AddBuff(Item.buffType, 2); - - return SafeShoot(player, source, position, velocity, type, damage, knockback); - } - - public virtual bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - return false; - } - } + //Custom damage scaling works as long as you use the same calculations as ModifyWeaponDamage (NOT calling GetWeaponDamage, that might have modded buffs) + /// + /// Item that applies a buff. Does not spawn a projectile on use by default + /// + [Content(ContentType.Weapons)] + public abstract class MinionItemBase : AssItem + { + public sealed override void SetStaticDefaults() + { + ItemID.Sets.GamepadWholeScreenUseRange[Type] = true; + ItemID.Sets.LockOnIgnoresCollision[Type] = true; + + SafeSetStaticDefaults(); + } + + + public virtual void SafeSetStaticDefaults() + { + + } + + public sealed override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + player.AddBuff(Item.buffType, 2); + + return SafeShoot(player, source, position, velocity, type, damage, knockback); + } + + public virtual bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + return false; + } + } } diff --git a/Items/Weapons/PlagueOfToads.cs b/Items/Weapons/PlagueOfToads.cs index 0bf6b00c..0ba2ddbf 100644 --- a/Items/Weapons/PlagueOfToads.cs +++ b/Items/Weapons/PlagueOfToads.cs @@ -7,59 +7,59 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class PlagueOfToads : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plague of Toads"); - Tooltip.SetDefault("Summons a cloud to rain toads on your foes"); - } + [Content(ContentType.Weapons)] + public class PlagueOfToads : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plague of Toads"); + Tooltip.SetDefault("Summons a cloud to rain toads on your foes"); + } - public override void SetDefaults() - { - //item.mana = 10; - //item.damage = 36; - //item.useStyle = 1; - //item.shootSpeed = 16f; - //item.shoot = ModContent.ProjectileType(); - //item.width = 26; - //item.height = 28; - //item.UseSound = SoundID.Item66; - //item.useAnimation = 22; - //item.useTime = 22; - //item.rare = -11; - //item.noMelee = true; - //item.knockback = 0f; - //item.value = Item.sellPrice(gold: 3, silver: 50); - //item.magic = true; + public override void SetDefaults() + { + //item.mana = 10; + //item.damage = 36; + //item.useStyle = 1; + //item.shootSpeed = 16f; + //item.shoot = ModContent.ProjectileType(); + //item.width = 26; + //item.height = 28; + //item.UseSound = SoundID.Item66; + //item.useAnimation = 22; + //item.useTime = 22; + //item.rare = -11; + //item.noMelee = true; + //item.knockback = 0f; + //item.value = Item.sellPrice(gold: 3, silver: 50); + //item.magic = true; - Item.mana = 20; - Item.damage = 8; - Item.useStyle = ItemUseStyleID.Swing; - Item.shootSpeed = 16f; - Item.shoot = ModContent.ProjectileType(); - Item.width = 26; - Item.height = 28; - Item.UseSound = SoundID.Item66; - Item.useAnimation = 22; - Item.useTime = 22; - Item.rare = -11; - Item.noMelee = true; - Item.knockBack = 0f; - Item.value = Item.sellPrice(silver: 25); - Item.DamageType = DamageClass.Magic; - } + Item.mana = 20; + Item.damage = 8; + Item.useStyle = ItemUseStyleID.Swing; + Item.shootSpeed = 16f; + Item.shoot = ModContent.ProjectileType(); + Item.width = 26; + Item.height = 28; + Item.UseSound = SoundID.Item66; + Item.useAnimation = 22; + Item.useTime = 22; + Item.rare = -11; + Item.noMelee = true; + Item.knockBack = 0f; + Item.value = Item.sellPrice(silver: 25); + Item.DamageType = DamageClass.Magic; + } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, Main.myPlayer, Main.mouseX + Main.screenPosition.X, Main.mouseY + Main.screenPosition.Y); - return false; - } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, Main.myPlayer, Main.mouseX + Main.screenPosition.X, Main.mouseY + Main.screenPosition.Y); + return false; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.Frog, 3).AddIngredient(ItemID.WandofSparking, 1).AddTile(TileID.Anvils).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.Frog, 3).AddIngredient(ItemID.WandofSparking, 1).AddTile(TileID.Anvils).Register(); + } + } } diff --git a/Items/Weapons/PocketSand.cs b/Items/Weapons/PocketSand.cs index 0b4717fd..6650a66d 100644 --- a/Items/Weapons/PocketSand.cs +++ b/Items/Weapons/PocketSand.cs @@ -7,50 +7,50 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class PocketSand : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pocket Sand"); - Tooltip.SetDefault("'Throw a clump of sand at an enemy to confuse it'"); - } + [Content(ContentType.Weapons)] + public class PocketSand : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pocket Sand"); + Tooltip.SetDefault("'Throw a clump of sand at an enemy to confuse it'"); + } - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.ThrowingKnife); - Item.damage = 1; - Item.useTime = 35; - Item.shootSpeed = 4.5f; - Item.shoot = ModContent.ProjectileType(); - Item.useAnimation = 35; - Item.autoReuse = true; - Item.rare = -11; - Item.noUseGraphic = true; - Item.value = 0; - } + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.ThrowingKnife); + Item.damage = 1; + Item.useTime = 35; + Item.shootSpeed = 4.5f; + Item.shoot = ModContent.ProjectileType(); + Item.useAnimation = 35; + Item.autoReuse = true; + Item.rare = -11; + Item.noUseGraphic = true; + Item.value = 0; + } - public override void AddRecipes() - { - CreateRecipe(10).AddIngredient(ItemID.SandBlock, 1).AddTile(TileID.WorkBenches).Register(); - } + public override void AddRecipes() + { + CreateRecipe(10).AddIngredient(ItemID.SandBlock, 1).AddTile(TileID.WorkBenches).Register(); + } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - for (int i = 0; i < 2; i++) //spawn two more with random velocity if first one is actually spawned - { - //Vector2 cm = new Vector2(Main.MouseWorld.X - player.Center.X, Main.MouseWorld.Y - player.Center.Y); - Vector2 cm = velocity; - float randx = Main.rand.NextFloat(0.8f, 1.2f); - float randx2 = Main.rand.NextFloat(-1.1f, 1.1f); - float randy = Main.rand.NextFloat(0.8f, 1.2f); - float bobandy = Main.rand.NextFloat(-1.1f, 1.1f); - float velox = ((cm.X * Item.shootSpeed * randx) / cm.Length()) + randx2; //first rand makes it so it has different velocity factor (how far it flies) - float veloy = ((cm.Y * Item.shootSpeed * randy) / cm.Length()) + bobandy; //second rand is a kinda offset used mainly for when shooting vertically or horizontally - Vector2 velo = new Vector2(velox, veloy); - Projectile.NewProjectile(source, position, velo, type, damage, knockback, Main.myPlayer); //TODO mention bugfix no owner in MP - } - return true; - } - } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + for (int i = 0; i < 2; i++) //spawn two more with random velocity if first one is actually spawned + { + //Vector2 cm = new Vector2(Main.MouseWorld.X - player.Center.X, Main.MouseWorld.Y - player.Center.Y); + Vector2 cm = velocity; + float randx = Main.rand.NextFloat(0.8f, 1.2f); + float randx2 = Main.rand.NextFloat(-1.1f, 1.1f); + float randy = Main.rand.NextFloat(0.8f, 1.2f); + float bobandy = Main.rand.NextFloat(-1.1f, 1.1f); + float velox = ((cm.X * Item.shootSpeed * randx) / cm.Length()) + randx2; //first rand makes it so it has different velocity factor (how far it flies) + float veloy = ((cm.Y * Item.shootSpeed * randy) / cm.Length()) + bobandy; //second rand is a kinda offset used mainly for when shooting vertically or horizontally + Vector2 velo = new Vector2(velox, veloy); + Projectile.NewProjectile(source, position, velo, type, damage, knockback, Main.myPlayer); //TODO mention bugfix no owner in MP + } + return true; + } + } } diff --git a/Items/Weapons/SightofRetinazer.cs b/Items/Weapons/SightofRetinazer.cs index 9c01065f..0b90be3c 100644 --- a/Items/Weapons/SightofRetinazer.cs +++ b/Items/Weapons/SightofRetinazer.cs @@ -5,40 +5,40 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class SightofRetinazer : AssItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sight of Retinazer"); - } + [Content(ContentType.Weapons)] + public class SightofRetinazer : AssItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sight of Retinazer"); + } - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.LaserRifle); - Item.width = 62; - Item.height = 32; - Item.damage = 40; - Item.mana = 0; - Item.shoot = ProjectileID.MiniRetinaLaser; - Item.shootSpeed = 15f; - Item.noMelee = true; - Item.DamageType = DamageClass.Ranged; - Item.useAnimation = 10; - Item.useTime = 10; - Item.value = Item.sellPrice(gold: 1); - Item.rare = -11; - Item.autoReuse = true; - } + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.LaserRifle); + Item.width = 62; + Item.height = 32; + Item.damage = 40; + Item.mana = 0; + Item.shoot = ProjectileID.MiniRetinaLaser; + Item.shootSpeed = 15f; + Item.noMelee = true; + Item.DamageType = DamageClass.Ranged; + Item.useAnimation = 10; + Item.useTime = 10; + Item.value = Item.sellPrice(gold: 1); + Item.rare = -11; + Item.autoReuse = true; + } - public override Vector2? HoldoutOffset() - { - return new Vector2(0, 0); - } + public override Vector2? HoldoutOffset() + { + return new Vector2(0, 0); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.HallowedBar, 5).AddIngredient(ItemID.SoulofSight, 5).AddIngredient(ItemID.LaserRifle, 1).AddTile(TileID.MythrilAnvil).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.HallowedBar, 5).AddIngredient(ItemID.SoulofSight, 5).AddIngredient(ItemID.LaserRifle, 1).AddTile(TileID.MythrilAnvil).Register(); + } + } } diff --git a/Items/Weapons/SlimeHandlerKnapsack.cs b/Items/Weapons/SlimeHandlerKnapsack.cs index b0fea763..f35a2214 100644 --- a/Items/Weapons/SlimeHandlerKnapsack.cs +++ b/Items/Weapons/SlimeHandlerKnapsack.cs @@ -14,123 +14,123 @@ namespace AssortedCrazyThings.Items.Weapons { - public class SlimeHandlerKnapsack : MinionItemBase - { - public static CircleUIConf GetUIConf() - { - List> assets = new List>() { - AssUtils.Instance.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinionPreview"), - AssUtils.Instance.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinionAssortedPreview"), - AssUtils.Instance.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinionSpikedPreview") }; - List tooltips = new List - { - "Default" - + "\nBase Damage: " + SlimePackMinion.DefDamage - + "\nBase Knockback: " + SlimePackMinion.DefKnockback, - "Assorted" - + "\nBase Damage: " + SlimePackMinion.DefDamage - + "\nBase Knockback: " + SlimePackMinion.DefKnockback, - "Spiked" - + "\nBase Damage: " + Math.Round(SlimePackMinion.DefDamage * (SlimePackMinion.SpikedIncrease + 1)) - + "\nBase Knockback: " + Math.Round(SlimePackMinion.DefKnockback * (SlimePackMinion.SpikedIncrease + 1), 1) - + "\nShoots spikes while fighting" - }; - List toUnlock = new List() { "Default", "Default", "Defeat Plantera" }; + public class SlimeHandlerKnapsack : MinionItemBase + { + public static CircleUIConf GetUIConf() + { + List> assets = new List>() { + AssUtils.Instance.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinionPreview"), + AssUtils.Instance.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinionAssortedPreview"), + AssUtils.Instance.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinionSpikedPreview") }; + List tooltips = new List + { + "Default" + + "\nBase Damage: " + SlimePackMinion.DefDamage + + "\nBase Knockback: " + SlimePackMinion.DefKnockback, + "Assorted" + + "\nBase Damage: " + SlimePackMinion.DefDamage + + "\nBase Knockback: " + SlimePackMinion.DefKnockback, + "Spiked" + + "\nBase Damage: " + Math.Round(SlimePackMinion.DefDamage * (SlimePackMinion.SpikedIncrease + 1)) + + "\nBase Knockback: " + Math.Round(SlimePackMinion.DefKnockback * (SlimePackMinion.SpikedIncrease + 1), 1) + + "\nShoots spikes while fighting" + }; + List toUnlock = new List() { "Default", "Default", "Defeat Plantera" }; - List unlocked = new List() - { - true, // 0 + List unlocked = new List() + { + true, // 0 true, // 1 NPC.downedPlantBoss, // 2 }; - return new CircleUIConf(0, -1, assets, unlocked, tooltips, toUnlock, drawOffset: new Vector2(0f, -2f)); - } + return new CircleUIConf(0, -1, assets, unlocked, tooltips, toUnlock, drawOffset: new Vector2(0f, -2f)); + } - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Slime Handler Knapsack"); - Tooltip.SetDefault("Summons a friendly Slime of a random color from your Knapsack to fight for you" - + "\nRight click to pick from available forms"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Slime Handler Knapsack"); + Tooltip.SetDefault("Summons a friendly Slime of a random color from your Knapsack to fight for you" + + "\nRight click to pick from available forms"); + } - public override void SetDefaults() - { - //change damage in SlimePackMinion.cs - Item.damage = SlimePackMinion.DefDamage; - Item.DamageType = DamageClass.Summon; - Item.mana = 10; - Item.width = 24; - Item.height = 30; - Item.useTime = 36; - Item.useAnimation = 36; - Item.useStyle = ItemUseStyleID.HoldUp; //4 for life crystal - Item.noMelee = true; - Item.noUseGraphic = true; - Item.value = Item.sellPrice(0, 0, 75, 0); - Item.rare = -11; - Item.UseSound = SoundID.Item44; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; - Item.knockBack = SlimePackMinion.DefKnockback; - Item.buffType = ModContent.BuffType(); - } + public override void SetDefaults() + { + //change damage in SlimePackMinion.cs + Item.damage = SlimePackMinion.DefDamage; + Item.DamageType = DamageClass.Summon; + Item.mana = 10; + Item.width = 24; + Item.height = 30; + Item.useTime = 36; + Item.useAnimation = 36; + Item.useStyle = ItemUseStyleID.HoldUp; //4 for life crystal + Item.noMelee = true; + Item.noUseGraphic = true; + Item.value = Item.sellPrice(0, 0, 75, 0); + Item.rare = -11; + Item.UseSound = SoundID.Item44; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; + Item.knockBack = SlimePackMinion.DefKnockback; + Item.buffType = ModContent.BuffType(); + } - public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) - { - AssPlayer mPlayer = player.GetModPlayer(); - if (mPlayer.selectedSlimePackMinionType == 2) - { - knockback *= 1f + SlimePackMinion.SpikedIncrease; - } - } + public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) + { + AssPlayer mPlayer = player.GetModPlayer(); + if (mPlayer.selectedSlimePackMinionType == 2) + { + knockback *= 1f + SlimePackMinion.SpikedIncrease; + } + } - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) - { - AssPlayer mPlayer = player.GetModPlayer(); - if (mPlayer.selectedSlimePackMinionType == 2) - { - damage += SlimePackMinion.SpikedIncrease; - } - } + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) + { + AssPlayer mPlayer = player.GetModPlayer(); + if (mPlayer.selectedSlimePackMinionType == 2) + { + damage += SlimePackMinion.SpikedIncrease; + } + } - public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - AssPlayer mPlayer = player.GetModPlayer(); - byte selected = mPlayer.selectedSlimePackMinionType; - if (selected == 1) - { - type = ModContent.ProjectileType(); - } - else if (selected == 2) - { - type = ModContent.ProjectileType(); - } - else - { - //default - } - Vector2 spawnPos = new Vector2(player.Center.X - player.direction * 12f, player.position.Y - 8f); - if (Collision.SolidCollision(spawnPos + new Vector2(-player.direction * 18f, 0f), 12, 1)) - { - spawnPos.X = player.Center.X + player.direction * 8f; - spawnPos.Y = player.Center.Y; - } - int index = Projectile.NewProjectile(source, spawnPos.X, spawnPos.Y, -player.velocity.X, player.velocity.Y - 6f, type, damage, knockback, Main.myPlayer, 0f, 0f); + public override bool SafeShoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + AssPlayer mPlayer = player.GetModPlayer(); + byte selected = mPlayer.selectedSlimePackMinionType; + if (selected == 1) + { + type = ModContent.ProjectileType(); + } + else if (selected == 2) + { + type = ModContent.ProjectileType(); + } + else + { + //default + } + Vector2 spawnPos = new Vector2(player.Center.X - player.direction * 12f, player.position.Y - 8f); + if (Collision.SolidCollision(spawnPos + new Vector2(-player.direction * 18f, 0f), 12, 1)) + { + spawnPos.X = player.Center.X + player.direction * 8f; + spawnPos.Y = player.Center.Y; + } + int index = Projectile.NewProjectile(source, spawnPos.X, spawnPos.Y, -player.velocity.X, player.velocity.Y - 6f, type, damage, knockback, Main.myPlayer, 0f, 0f); - int ogDamage = Item.damage; - if (selected == 2) - { - ogDamage = (int)(ogDamage * (1f + SlimePackMinion.SpikedIncrease)); - } + int ogDamage = Item.damage; + if (selected == 2) + { + ogDamage = (int)(ogDamage * (1f + SlimePackMinion.SpikedIncrease)); + } - Main.projectile[index].originalDamage = ogDamage; - return false; - } + Main.projectile[index].originalDamage = ogDamage; + return false; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.SlimeCrown, 1).AddIngredient(ItemID.Gel, 200).AddIngredient(ItemID.SoulofLight, 5).AddIngredient(ItemID.SoulofNight, 5).AddTile(TileID.MythrilAnvil).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.SlimeCrown, 1).AddIngredient(ItemID.Gel, 200).AddIngredient(ItemID.SoulofLight, 5).AddIngredient(ItemID.SoulofNight, 5).AddTile(TileID.MythrilAnvil).Register(); + } + } } diff --git a/Items/Weapons/TomeOfShadowflameSkulls.cs b/Items/Weapons/TomeOfShadowflameSkulls.cs index 7ef84001..75e2f9d6 100644 --- a/Items/Weapons/TomeOfShadowflameSkulls.cs +++ b/Items/Weapons/TomeOfShadowflameSkulls.cs @@ -1,35 +1,34 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class TomeOfShadowflameSkulls : AssItem - { - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.BookofSkulls); - Item.damage = 50; - Item.mana = 6; - Item.useTime = 35; - Item.shootSpeed = 10f; - Item.shoot = ProjectileID.ClothiersCurse; - Item.useAnimation = 35; - Item.value = Item.sellPrice(silver: 10); - Item.rare = -11; - Item.noUseGraphic = true; - } + [Content(ContentType.Weapons)] + public class TomeOfShadowflameSkulls : AssItem + { + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.BookofSkulls); + Item.damage = 50; + Item.mana = 6; + Item.useTime = 35; + Item.shootSpeed = 10f; + Item.shoot = ProjectileID.ClothiersCurse; + Item.useAnimation = 35; + Item.value = Item.sellPrice(silver: 10); + Item.rare = -11; + Item.noUseGraphic = true; + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tome of Shadowflame Skulls"); - Tooltip.SetDefault("Inflicts Shadowflame on enemies"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tome of Shadowflame Skulls"); + Tooltip.SetDefault("Inflicts Shadowflame on enemies"); + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ItemID.SoulofFright, 10).AddIngredient(ItemID.BookofSkulls, 1).AddTile(TileID.CrystalBall).Register(); - } - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ItemID.SoulofFright, 10).AddIngredient(ItemID.BookofSkulls, 1).AddTile(TileID.CrystalBall).Register(); + } + } } diff --git a/Items/Weapons/TrueLegendaryWoodenSword.cs b/Items/Weapons/TrueLegendaryWoodenSword.cs index 30450ec8..bc441223 100644 --- a/Items/Weapons/TrueLegendaryWoodenSword.cs +++ b/Items/Weapons/TrueLegendaryWoodenSword.cs @@ -7,48 +7,48 @@ namespace AssortedCrazyThings.Items.Weapons { - [Content(ContentType.Weapons)] - public class TrueLegendaryWoodenSword : AssItem - { - public int ProjDamage = 28; //Default fallback + [Content(ContentType.Weapons)] + public class TrueLegendaryWoodenSword : AssItem + { + public int ProjDamage = 28; //Default fallback - public override void SetStaticDefaults() - { - DisplayName.SetDefault("True Legendary Wooden Sword"); - Tooltip.SetDefault("'Truly Legendary'"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("True Legendary Wooden Sword"); + Tooltip.SetDefault("'Truly Legendary'"); + } - public override void SetDefaults() - { - Item.CloneDefaults(ItemID.CobaltSword); - ProjDamage = (int)(Item.damage * 0.8f); - Item.width = 58; - Item.height = 58; - Item.rare = -11; - Item.value = Item.sellPrice(0, 2, 0, 10); //2 gold for broken, 10 copper for legendary - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; //fairly short range, similar to throwing knife - } + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.CobaltSword); + ProjDamage = (int)(Item.damage * 0.8f); + Item.width = 58; + Item.height = 58; + Item.rare = -11; + Item.value = Item.sellPrice(0, 2, 0, 10); //2 gold for broken, 10 copper for legendary + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; //fairly short range, similar to throwing knife + } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - //162 for "sparks" - //169 for just light - int dustType = 169; - Dust dust = Dust.NewDustDirect(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, dustType, player.velocity.X * 0.2f + (player.direction * 3), player.velocity.Y * 0.2f, 100, Color.White, 1.25f); - dust.noGravity = true; - dust.velocity *= 2f; - } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + //162 for "sparks" + //169 for just light + int dustType = 169; + Dust dust = Dust.NewDustDirect(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, dustType, player.velocity.X * 0.2f + (player.direction * 3), player.velocity.Y * 0.2f, 100, Color.White, 1.25f); + dust.noGravity = true; + dust.velocity *= 2f; + } - public override void AddRecipes() - { - CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.BrokenHeroSword, 1).AddTile(TileID.MythrilAnvil).Register(); - } + public override void AddRecipes() + { + CreateRecipe(1).AddIngredient(ModContent.ItemType(), 1).AddIngredient(ItemID.BrokenHeroSword, 1).AddTile(TileID.MythrilAnvil).Register(); + } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - Projectile.NewProjectile(source, player.Center + Vector2.Normalize(velocity) * 30f, velocity, type, ProjDamage, knockback, Main.myPlayer); - return false; - } - } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile.NewProjectile(source, player.Center + Vector2.Normalize(velocity) * 30f, velocity, type, ProjDamage, knockback, Main.myPlayer); + return false; + } + } } diff --git a/NPCs/AnimatedSpellTome.cs b/NPCs/AnimatedSpellTome.cs index b1bb09c8..f58feff9 100644 --- a/NPCs/AnimatedSpellTome.cs +++ b/NPCs/AnimatedSpellTome.cs @@ -9,118 +9,118 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class AnimatedSpellTome : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Animated Spell Tome"); - Main.npcFrameCount[NPC.type] = 5; - } + [Content(ContentType.HostileNPCs)] + public class AnimatedSpellTome : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Animated Spell Tome"); + Main.npcFrameCount[NPC.type] = 5; + } - public override void SetDefaults() - { - NPC.width = 26; - NPC.height = 16; - NPC.damage = 13; - NPC.defense = 2; - NPC.lifeMax = 16; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 60f; - NPC.knockBackResist = 0.8f; - NPC.aiStyle = 14; - NPC.noGravity = true; - AIType = NPCID.GiantBat; - } + public override void SetDefaults() + { + NPC.width = 26; + NPC.height = 16; + NPC.damage = 13; + NPC.defense = 2; + NPC.lifeMax = 16; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 60f; + NPC.knockBackResist = 0.8f; + NPC.aiStyle = 14; + NPC.noGravity = true; + AIType = NPCID.GiantBat; + } - public override void FindFrame(int frameHeight) - { - NPC.LoopAnimation(frameHeight, 8); - } + public override void FindFrame(int frameHeight) + { + NPC.LoopAnimation(frameHeight, 8); + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.DungeonNormal.Chance * 0.005f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.DungeonNormal.Chance * 0.005f; + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheDungeon, - new FlavorTextBestiaryInfoElement("Master wizards need not look for a specific tome; it will find them when needed.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheDungeon, + new FlavorTextBestiaryInfoElement("Master wizards need not look for a specific tome; it will find them when needed.") + }); + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.SpellTome)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.SpellTome)); + } - //golden dust particles on hit and passively spawning sparkles in the next two methods - //make sure to do "using Microsoft.Xna.Framework;" - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + //golden dust particles on hit and passively spawning sparkles in the next two methods + //make sure to do "using Microsoft.Xna.Framework;" + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life > 0) - { - for (int i = 0; i < 10; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.Next(232, 234), hitDirection, -1f); - } - } - else - { - for (int i = 0; i < 20; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.Next(232, 234), 2 * hitDirection, -2f); - } + if (NPC.life > 0) + { + for (int i = 0; i < 10; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.Next(232, 234), hitDirection, -1f); + } + } + else + { + for (int i = 0; i < 20; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.Next(232, 234), 2 * hitDirection, -2f); + } - for (int u = 0; u < 6; u++) - { - Vector2 pos = NPC.position + new Vector2(Main.rand.Next(NPC.width), Main.rand.Next(NPC.height)); - Gore gore = Gore.NewGoreDirect(pos, NPC.velocity * 0.5f, Mod.Find("PaperScrapGore").Type, 1f); - gore.velocity += new Vector2(Main.rand.NextFloat(3) - 1f, Main.rand.NextFloat(MathHelper.TwoPi) - 0.3f); - } + for (int u = 0; u < 6; u++) + { + Vector2 pos = NPC.position + new Vector2(Main.rand.Next(NPC.width), Main.rand.Next(NPC.height)); + Gore gore = Gore.NewGoreDirect(pos, NPC.velocity * 0.5f, Mod.Find("PaperScrapGore").Type, 1f); + gore.velocity += new Vector2(Main.rand.NextFloat(3) - 1f, Main.rand.NextFloat(MathHelper.TwoPi) - 0.3f); + } - for (int i = 0; i < 3; i++) - { - Gore gore = Gore.NewGoreDirect(NPC.position, NPC.velocity.SafeNormalize(Vector2.UnitY) * 3f, Mod.Find("PaperGore").Type, 1f + Main.rand.NextFloatDirection() * 0.2f); - gore.velocity += new Vector2(Main.rand.NextFloat(2) - 1f, Main.rand.NextFloat(MathHelper.TwoPi) - 0.3f); - gore.velocity *= 4f; - } - } - } + for (int i = 0; i < 3; i++) + { + Gore gore = Gore.NewGoreDirect(NPC.position, NPC.velocity.SafeNormalize(Vector2.UnitY) * 3f, Mod.Find("PaperGore").Type, 1f + Main.rand.NextFloatDirection() * 0.2f); + gore.velocity += new Vector2(Main.rand.NextFloat(2) - 1f, Main.rand.NextFloat(MathHelper.TwoPi) - 0.3f); + gore.velocity *= 4f; + } + } + } - public override void PostAI() - { - NPC.rotation = NPC.velocity.X * 0.06f; + public override void PostAI() + { + NPC.rotation = NPC.velocity.X * 0.06f; - //using Microsoft.Xna.Framework; - //change the npc. to projectile. if you port this to pets - Color color = Lighting.GetColor((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16); - if (color.R > 20 || color.B > 20 || color.G > 20) - { - int num = color.R; - if (color.G > num) - { - num = color.G; - } - if (color.B > num) - { - num = color.B; - } - num /= 30; - if (Main.rand.Next(300) < num) - { - Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 43, 0f, 0f, 254, new Color(255, 255, 0), 0.5f); - dust.velocity *= 0f; - } - } - } - } + //using Microsoft.Xna.Framework; + //change the npc. to projectile. if you port this to pets + Color color = Lighting.GetColor((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16); + if (color.R > 20 || color.B > 20 || color.G > 20) + { + int num = color.R; + if (color.G > num) + { + num = color.G; + } + if (color.B > num) + { + num = color.B; + } + num /= 30; + if (Main.rand.Next(300) < num) + { + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 43, 0f, 0f, 254, new Color(255, 255, 0), 0.5f); + dust.velocity *= 0f; + } + } + } + } } diff --git a/NPCs/AnimatedTome.cs b/NPCs/AnimatedTome.cs index f8467c45..df549cc6 100644 --- a/NPCs/AnimatedTome.cs +++ b/NPCs/AnimatedTome.cs @@ -11,104 +11,104 @@ namespace AssortedCrazyThings.NPCs { - //this version of "retexture" is old and not recommended, refer to DemonEyeFractured or similar + //this version of "retexture" is old and not recommended, refer to DemonEyeFractured or similar - [Content(ContentType.HostileNPCs)] - public class AnimatedTome : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Animated Tome"); - Main.npcFrameCount[NPC.type] = 5; - Main.npcCatchable[NPC.type] = true; - } + [Content(ContentType.HostileNPCs)] + public class AnimatedTome : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Animated Tome"); + Main.npcFrameCount[NPC.type] = 5; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 26; - NPC.height = 16; - NPC.damage = 13; - NPC.defense = 2; - NPC.lifeMax = 16; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 60f; - NPC.knockBackResist = 0.8f; - NPC.aiStyle = 14; - NPC.noGravity = true; - AIType = NPCID.GiantBat; - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 26; + NPC.height = 16; + NPC.damage = 13; + NPC.defense = 2; + NPC.lifeMax = 16; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 60f; + NPC.knockBackResist = 0.8f; + NPC.aiStyle = 14; + NPC.noGravity = true; + AIType = NPCID.GiantBat; + NPC.catchItem = (short)ModContent.ItemType(); + } - public override void FindFrame(int frameHeight) - { - NPC.LoopAnimation(frameHeight, 8); - } + public override void FindFrame(int frameHeight) + { + NPC.LoopAnimation(frameHeight, 8); + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.DungeonNormal.Chance * 0.01f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.DungeonNormal.Chance * 0.01f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Book)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Book)); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheDungeon, - new FlavorTextBestiaryInfoElement("In the past, this book was a best seller; it practically flew from the shelves!") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheDungeon, + new FlavorTextBestiaryInfoElement("In the past, this book was a best seller; it practically flew from the shelves!") + }); + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life <= 0) - { - for (int u = 0; u < 7; u++) - { - Vector2 pos = NPC.position + new Vector2(Main.rand.Next(NPC.width), Main.rand.Next(NPC.height)); - Gore gore = Gore.NewGoreDirect(pos, NPC.velocity * 0.5f, Mod.Find("PaperScrapGore").Type, 1f); - gore.velocity += new Vector2(Main.rand.NextFloat(3) - 1.5f, Main.rand.NextFloat(MathHelper.TwoPi) - 0.3f); - } + if (NPC.life <= 0) + { + for (int u = 0; u < 7; u++) + { + Vector2 pos = NPC.position + new Vector2(Main.rand.Next(NPC.width), Main.rand.Next(NPC.height)); + Gore gore = Gore.NewGoreDirect(pos, NPC.velocity * 0.5f, Mod.Find("PaperScrapGore").Type, 1f); + gore.velocity += new Vector2(Main.rand.NextFloat(3) - 1.5f, Main.rand.NextFloat(MathHelper.TwoPi) - 0.3f); + } - for (int i = 0; i < 3; i++) - { - Gore gore = Gore.NewGoreDirect(NPC.position, NPC.velocity.SafeNormalize(Vector2.UnitY) * 3f, Mod.Find("PaperGore").Type, 1f + Main.rand.NextFloatDirection() * 0.2f); - gore.velocity += new Vector2(Main.rand.NextFloat(2) - 1f, Main.rand.NextFloat(MathHelper.TwoPi) - 0.3f); - gore.velocity *= 4f; - } - } - } + for (int i = 0; i < 3; i++) + { + Gore gore = Gore.NewGoreDirect(NPC.position, NPC.velocity.SafeNormalize(Vector2.UnitY) * 3f, Mod.Find("PaperGore").Type, 1f + Main.rand.NextFloatDirection() * 0.2f); + gore.velocity += new Vector2(Main.rand.NextFloat(2) - 1f, Main.rand.NextFloat(MathHelper.TwoPi) - 0.3f); + gore.velocity *= 4f; + } + } + } - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - int i = NPC.whoAmI % 5; //needs to be fixed per NPC instance - if (i < 4) - { - Texture2D texture = Mod.Assets.Request("NPCs/AnimatedTome_" + i).Value; - Vector2 stupidOffset = new Vector2(0f, 0f); //4f - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawPos = NPC.Center - screenPos - Vector2.Zero + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + int i = NPC.whoAmI % 5; //needs to be fixed per NPC instance + if (i < 4) + { + Texture2D texture = Mod.Assets.Request("NPCs/AnimatedTome_" + i).Value; + Vector2 stupidOffset = new Vector2(0f, 0f); //4f + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawPos = NPC.Center - screenPos - Vector2.Zero + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + } + } - public override void PostAI() - { - NPC.rotation = NPC.velocity.X * 0.06f; + public override void PostAI() + { + NPC.rotation = NPC.velocity.X * 0.06f; - if (Main.rand.NextBool(10)) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 15); - } - } - } + if (Main.rand.NextBool(10)) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 15); + } + } + } } diff --git a/NPCs/Bass.cs b/NPCs/Bass.cs index f1580813..1073294b 100644 --- a/NPCs/Bass.cs +++ b/NPCs/Bass.cs @@ -8,69 +8,69 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.FriendlyNPCs)] - public class Bass : AssNPC - { - public float scareRange = 200f; + [Content(ContentType.FriendlyNPCs)] + public class Bass : AssNPC + { + public float scareRange = 200f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bass"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Goldfish]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bass"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Goldfish]; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - IsWet = true - }; - NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; - } + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + IsWet = true + }; + NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; + } - public override void SetDefaults() - { - NPC.width = 42; - NPC.height = 32; - NPC.damage = 0; - NPC.defense = 0; - NPC.lifeMax = 5; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 0f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = -1; //custom - AIType = NPCID.Goldfish; - AnimationType = NPCID.Goldfish; - NPC.noGravity = true; - NPC.buffImmune[BuffID.Confused] = false; - } + public override void SetDefaults() + { + NPC.width = 42; + NPC.height = 32; + NPC.damage = 0; + NPC.defense = 0; + NPC.lifeMax = 5; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 0f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = -1; //custom + AIType = NPCID.Goldfish; + AnimationType = NPCID.Goldfish; + NPC.noGravity = true; + NPC.buffImmune[BuffID.Confused] = false; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (Main.raining) - { - return SpawnCondition.TownWaterCritter.Chance * 0.8f; - } - else - { - return SpawnCondition.TownWaterCritter.Chance * 0.05f; - } - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (Main.raining) + { + return SpawnCondition.TownWaterCritter.Chance * 0.8f; + } + else + { + return SpawnCondition.TownWaterCritter.Chance * 0.05f; + } + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("A simple fish commonly found in calm freshwater rivers and lakes.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("A simple fish commonly found in calm freshwater rivers and lakes.") + }); + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Bass)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Bass)); + } - public override void AI() - { - AssAI.ModifiedGoldfishAI(NPC, 200f); - } - } + public override void AI() + { + AssAI.ModifiedGoldfishAI(NPC, 200f); + } + } } diff --git a/NPCs/BloatedBaitThief.cs b/NPCs/BloatedBaitThief.cs index b813b497..93deb30a 100644 --- a/NPCs/BloatedBaitThief.cs +++ b/NPCs/BloatedBaitThief.cs @@ -8,82 +8,82 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.FriendlyNPCs)] - public class BloatedBaitThief : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bloated Bait Thief"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Goldfish]; - - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - IsWet = true - }; - NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; - } + [Content(ContentType.FriendlyNPCs)] + public class BloatedBaitThief : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bloated Bait Thief"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Goldfish]; - public override void SetDefaults() - { - NPC.width = 48; - NPC.height = 42; - NPC.damage = 0; - NPC.defense = 0; - NPC.lifeMax = 5; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 0f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = -1; - AIType = NPCID.Goldfish; - AnimationType = NPCID.Goldfish; - NPC.noGravity = true; - NPC.buffImmune[BuffID.Confused] = false; - } + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + IsWet = true + }; + NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (Main.raining) - { - return SpawnCondition.TownWaterCritter.Chance * 0.8f; - } - else - { - return SpawnCondition.TownWaterCritter.Chance * 0.5f; - } - } + public override void SetDefaults() + { + NPC.width = 48; + NPC.height = 42; + NPC.damage = 0; + NPC.defense = 0; + NPC.lifeMax = 5; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 0f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = -1; + AIType = NPCID.Goldfish; + AnimationType = NPCID.Goldfish; + NPC.noGravity = true; + NPC.buffImmune[BuffID.Confused] = false; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.GoldWorm, chanceDenominator: 100)); - npcLoot.Add(ItemDropRule.Common(ItemID.Worm, minimumDropped: 2, maximumDropped: 8)); - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (Main.raining) + { + return SpawnCondition.TownWaterCritter.Chance * 0.8f; + } + else + { + return SpawnCondition.TownWaterCritter.Chance * 0.5f; + } + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("An engorged bass with a bloated belly. Something is wriggling inside...") - }); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.GoldWorm, chanceDenominator: 100)); + npcLoot.Add(ItemDropRule.Common(ItemID.Worm, minimumDropped: 2, maximumDropped: 8)); + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("An engorged bass with a bloated belly. Something is wriggling inside...") + }); + } - if (NPC.life <= 0) - { - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("BaitThiefGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("BaitThiefGore_0").Type, 1f); - } - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - public override void AI() - { - AssAI.ModifiedGoldfishAI(NPC, 400f); - } - } + if (NPC.life <= 0) + { + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("BaitThiefGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("BaitThiefGore_0").Type, 1f); + } + } + + public override void AI() + { + AssAI.ModifiedGoldfishAI(NPC, 400f); + } + } } diff --git a/NPCs/Chunky.cs b/NPCs/Chunky.cs index 40cca1f8..e502baa9 100644 --- a/NPCs/Chunky.cs +++ b/NPCs/Chunky.cs @@ -1,5 +1,4 @@ using AssortedCrazyThings.Items.Pets; -using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; @@ -9,80 +8,80 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class Chunky : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Chunky"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - } + [Content(ContentType.HostileNPCs)] + public class Chunky : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Chunky"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 36; - NPC.height = 26; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 20; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 20f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 36; + NPC.height = 26; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 20; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 20f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.catchItem = (short)ModContent.ItemType(); + } - public override void HitEffect(int hitDirection, double damage) - { - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 18, hitDirection, -1f); - } - } - else - { - for (int i = 0; i < 40; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 18, 2 * hitDirection, -2f); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 18, hitDirection, -1f); + } + } + else + { + for (int i = 0; i < 40; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 18, 2 * hitDirection, -2f); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (Main.hardMode) return SpawnCondition.Corruption.Chance * 0.05f; - return SpawnCondition.Corruption.Chance * 0.2f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (Main.hardMode) return SpawnCondition.Corruption.Chance * 0.05f; + return SpawnCondition.Corruption.Chance * 0.2f; + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCorruption, - new FlavorTextBestiaryInfoElement("A mass of rotten flesh with a single eye. It seems as though the eye and the mass do not get along.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCorruption, + new FlavorTextBestiaryInfoElement("A mass of rotten flesh with a single eye. It seems as though the eye and the mass do not get along.") + }); + } - public override void OnKill() - { - if (Main.rand.NextBool(10)) - { - int i = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)NPC.position.X, (int)NPC.position.Y - 16, ModContent.NPCType()); - if (Main.netMode == NetmodeID.Server && i < Main.maxNPCs) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); - } - } - } + public override void OnKill() + { + if (Main.rand.NextBool(10)) + { + int i = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)NPC.position.X, (int)NPC.position.Y - 16, ModContent.NPCType()); + if (Main.netMode == NetmodeID.Server && i < Main.maxNPCs) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); + } + } + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.RottenChunk)); - } - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.RottenChunk)); + } + } } diff --git a/NPCs/ChunkysEye.cs b/NPCs/ChunkysEye.cs index 437edd15..e41d6727 100644 --- a/NPCs/ChunkysEye.cs +++ b/NPCs/ChunkysEye.cs @@ -4,28 +4,28 @@ namespace AssortedCrazyThings.NPCs { - public class ChunkysEye : ChunkysMeatballsEyeBase - { - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); + public class ChunkysEye : ChunkysMeatballsEyeBase + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); - DisplayName.SetDefault("Chunky's Eye"); - } + DisplayName.SetDefault("Chunky's Eye"); + } - public override void SetDefaults() - { - base.SetDefaults(); + public override void SetDefaults() + { + base.SetDefaults(); - NPC.catchItem = (short)ModContent.ItemType(); - } + NPC.catchItem = (short)ModContent.ItemType(); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCorruption, - new FlavorTextBestiaryInfoElement("A minion of Cthulhu that was trapped in the Corruption. It now seeks its lost little brother.") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCorruption, + new FlavorTextBestiaryInfoElement("A minion of Cthulhu that was trapped in the Corruption. It now seeks its lost little brother.") + }); + } + } } diff --git a/NPCs/ChunkysMeatballsEyeBase.cs b/NPCs/ChunkysMeatballsEyeBase.cs index 22b90a58..adb7e74d 100644 --- a/NPCs/ChunkysMeatballsEyeBase.cs +++ b/NPCs/ChunkysMeatballsEyeBase.cs @@ -1,61 +1,60 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] //Tied to chunky/meatball which is hostile - public abstract class ChunkysMeatballsEyeBase : AssNPC - { - public override void SetStaticDefaults() - { - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.DemonEye]; - Main.npcCatchable[NPC.type] = true; + [Content(ContentType.HostileNPCs)] //Tied to chunky/meatball which is hostile + public abstract class ChunkysMeatballsEyeBase : AssNPC + { + public override void SetStaticDefaults() + { + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.DemonEye]; + Main.npcCatchable[NPC.type] = true; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - Position = new Vector2(0, -6f) - }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value); - } + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + Position = new Vector2(0, -6f) + }; + NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value); + } - public override void SetDefaults() - { - NPC.width = 38; - NPC.height = 46; - NPC.friendly = true; - NPC.damage = 0; - NPC.defense = 0; - NPC.lifeMax = 60; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 75f; - NPC.knockBackResist = 0.5f; - NPC.aiStyle = -1; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.dontTakeDamage = true; - AnimationType = NPCID.DemonEye; - } + public override void SetDefaults() + { + NPC.width = 38; + NPC.height = 46; + NPC.friendly = true; + NPC.damage = 0; + NPC.defense = 0; + NPC.lifeMax = 60; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 75f; + NPC.knockBackResist = 0.5f; + NPC.aiStyle = -1; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.dontTakeDamage = true; + AnimationType = NPCID.DemonEye; + } - public override void AI() - { - if (NPC.ai[0] == 0) - { - NPC.velocity.Y = -0.022f * 2f; - NPC.netUpdate = true; - } + public override void AI() + { + if (NPC.ai[0] == 0) + { + NPC.velocity.Y = -0.022f * 2f; + NPC.netUpdate = true; + } - NPC.rotation = MathHelper.PiOver2; - NPC.direction = 1; - NPC.velocity.X = 0; - NPC.ai[0]++; - NPC.velocity.Y -= 0.022f * 1.5f; //0.022f * 2f; - if (NPC.timeLeft > 80) - { - NPC.timeLeft = 80; - } - } - } + NPC.rotation = MathHelper.PiOver2; + NPC.direction = 1; + NPC.velocity.X = 0; + NPC.ai[0]++; + NPC.velocity.Y -= 0.022f * 1.5f; //0.022f * 2f; + if (NPC.timeLeft > 80) + { + NPC.timeLeft = 80; + } + } + } } diff --git a/NPCs/Cloudfish.cs b/NPCs/Cloudfish.cs index c0eb4939..30cd9ae5 100644 --- a/NPCs/Cloudfish.cs +++ b/NPCs/Cloudfish.cs @@ -8,99 +8,99 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.FriendlyNPCs)] - public class Cloudfish : AssNPC - { - public float scareRange = 200f; + [Content(ContentType.FriendlyNPCs)] + public class Cloudfish : AssNPC + { + public float scareRange = 200f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cloudfish"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Goldfish]; - Main.npcCatchable[NPC.type] = true; - - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - IsWet = true - }; - NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cloudfish"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Goldfish]; + Main.npcCatchable[NPC.type] = true; - public override void SetDefaults() - { - NPC.width = 38; - NPC.height = 36; - NPC.damage = 0; - NPC.defense = 0; - NPC.lifeMax = 5; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 0f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = -1; //custom - AIType = NPCID.Goldfish; - AnimationType = NPCID.Goldfish; - NPC.noGravity = true; - NPC.catchItem = ItemID.Cloudfish; - NPC.buffImmune[BuffID.Confused] = false; - } + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + IsWet = true + }; + NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.Player.ZoneSkyHeight) - { - int x = spawnInfo.SpawnTileX; - int y = spawnInfo.SpawnTileY; - if (Main.tile[x, y].LiquidAmount == 0) - { - return 0f; - } - else if ( - !WorldGen.SolidTile(x, y) && - !WorldGen.SolidTile(x, y + 1) && - !WorldGen.SolidTile(x, y + 2)) - { - return SpawnCondition.Sky.Chance * 4f; //0.05f before, 100f now because water check - } - } - return 0f; - } + public override void SetDefaults() + { + NPC.width = 38; + NPC.height = 36; + NPC.damage = 0; + NPC.defense = 0; + NPC.lifeMax = 5; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 0f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = -1; //custom + AIType = NPCID.Goldfish; + AnimationType = NPCID.Goldfish; + NPC.noGravity = true; + NPC.catchItem = ItemID.Cloudfish; + NPC.buffImmune[BuffID.Confused] = false; + } - //public override int SpawnNPC(int tileX, int tileY) - //{ - // if (Main.tile[tileX, tileY].LiquidAmount == 0) - // { - // return 0; - // } - // else if ( - // !WorldGen.SolidTile(tileX, tileY) && - // !WorldGen.SolidTile(tileX, tileY + 1) && - // !WorldGen.SolidTile(tileX, tileY + 2)) - // { - // //actually spawn - // return base.SpawnNPC(tileX, tileY); - // } - // return 0; - //} + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.ZoneSkyHeight) + { + int x = spawnInfo.SpawnTileX; + int y = spawnInfo.SpawnTileY; + if (Main.tile[x, y].LiquidAmount == 0) + { + return 0f; + } + else if ( + !WorldGen.SolidTile(x, y) && + !WorldGen.SolidTile(x, y + 1) && + !WorldGen.SolidTile(x, y + 2)) + { + return SpawnCondition.Sky.Chance * 4f; //0.05f before, 100f now because water check + } + } + return 0f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Cloud, minimumDropped: 10, maximumDropped: 20)); - npcLoot.Add(ItemDropRule.Common(ItemID.RainCloud, chanceDenominator: 10, minimumDropped: 10, maximumDropped: 20)); - npcLoot.Add(ItemDropRule.Common(ItemID.SnowCloudBlock, chanceDenominator: 15, minimumDropped: 10, maximumDropped: 20)); - } + //public override int SpawnNPC(int tileX, int tileY) + //{ + // if (Main.tile[tileX, tileY].LiquidAmount == 0) + // { + // return 0; + // } + // else if ( + // !WorldGen.SolidTile(tileX, tileY) && + // !WorldGen.SolidTile(tileX, tileY + 1) && + // !WorldGen.SolidTile(tileX, tileY + 2)) + // { + // //actually spawn + // return base.SpawnNPC(tileX, tileY); + // } + // return 0; + //} - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Sky, + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Cloud, minimumDropped: 10, maximumDropped: 20)); + npcLoot.Add(ItemDropRule.Common(ItemID.RainCloud, chanceDenominator: 10, minimumDropped: 10, maximumDropped: 20)); + npcLoot.Add(ItemDropRule.Common(ItemID.SnowCloudBlock, chanceDenominator: 15, minimumDropped: 10, maximumDropped: 20)); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Sky, new FlavorTextBestiaryInfoElement("Is it a cloud? Is it a fish? It's both!") - }); - } + }); + } - public override void AI() - { - AssAI.ModifiedGoldfishAI(NPC, 200f); - } - } + public override void AI() + { + AssAI.ModifiedGoldfishAI(NPC, 200f); + } + } } diff --git a/NPCs/CuteGastropod.cs b/NPCs/CuteGastropod.cs index 0b42b785..4b72706b 100644 --- a/NPCs/CuteGastropod.cs +++ b/NPCs/CuteGastropod.cs @@ -8,61 +8,61 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.CuteSlimes)] - public class CuteGastropod : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Gastropod"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.FlyingSnake]; - Main.npcCatchable[NPC.type] = true; - } + [Content(ContentType.CuteSlimes)] + public class CuteGastropod : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Gastropod"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.FlyingSnake]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 38; - NPC.height = 42; - DrawOffsetY = 4; - NPC.damage = 0; - NPC.defense = 0; - NPC.lifeMax = 20; - NPC.friendly = true; - NPC.dontTakeDamageFromHostiles = true; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 60f; - NPC.knockBackResist = 0.5f; - NPC.aiStyle = 14; - NPC.noGravity = true; - AIType = NPCID.FlyingSnake; - AnimationType = NPCID.FlyingSnake; - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 38; + NPC.height = 42; + DrawOffsetY = 4; + NPC.damage = 0; + NPC.defense = 0; + NPC.lifeMax = 20; + NPC.friendly = true; + NPC.dontTakeDamageFromHostiles = true; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 60f; + NPC.knockBackResist = 0.5f; + NPC.aiStyle = 14; + NPC.noGravity = true; + AIType = NPCID.FlyingSnake; + AnimationType = NPCID.FlyingSnake; + NPC.catchItem = (short)ModContent.ItemType(); + } - public override bool? CanBeHitByItem(Player player, Item item) - { - return null; //TODO NPC return true - } + public override bool? CanBeHitByItem(Player player, Item item) + { + return null; //TODO NPC return true + } - public override bool? CanBeHitByProjectile(Projectile projectile) - { - return !projectile.minion; - } + public override bool? CanBeHitByProjectile(Projectile projectile) + { + return !projectile.minion; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SlimePets.CuteSlimeSpawnChance(spawnInfo, SpawnConditionType.None, customFactor: !NPC.AnyNPCs(ModContent.NPCType()) ? SpawnCondition.OverworldHallow.Chance * 0.045f : 0f); - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SlimePets.CuteSlimeSpawnChance(spawnInfo, SpawnConditionType.None, customFactor: !NPC.AnyNPCs(ModContent.NPCType()) ? SpawnCondition.OverworldHallow.Chance * 0.045f : 0f); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - //quickUnlock: true so only 1 kill is required to list everything about it - bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + //quickUnlock: true so only 1 kill is required to list everything about it + bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheHallow, - new FlavorTextBestiaryInfoElement("This hallowed variant of slime has taken on a more friendly appearance after meeting a special person.") - }); - } - } + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheHallow, + new FlavorTextBestiaryInfoElement("This hallowed variant of slime has taken on a more friendly appearance after meeting a special person.") + }); + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeBaseNPC.cs b/NPCs/CuteSlimes/CuteSlimeBaseNPC.cs index f24f4141..2a41188a 100644 --- a/NPCs/CuteSlimes/CuteSlimeBaseNPC.cs +++ b/NPCs/CuteSlimes/CuteSlimeBaseNPC.cs @@ -8,127 +8,127 @@ namespace AssortedCrazyThings.NPCs.CuteSlimes { - //Not ContentType.FriendlyNPCs, but separate toggle - [Content(ContentType.CuteSlimes)] - public abstract class CuteSlimeBaseNPC : AssNPC - { - public abstract string IngameName { get; } - - public abstract int CatchItem { get; } - - public abstract SpawnConditionType SpawnCondition { get; } - - public abstract Color DustColor { get; } - - public virtual bool ShouldDropGel => true; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault(IngameName); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - NPCID.Sets.CountsAsCritter[NPC.type] = true; - - SafeSetStaticDefaults(); - } - - public virtual void SafeSetStaticDefaults() - { - - } - - public sealed override void SetDefaults() - { - NPC.friendly = true; - NPC.dontTakeDamageFromHostiles = true; - NPC.defense = 0; - NPC.lifeMax = 5; - NPC.width = 28; - NPC.height = 33; - NPC.damage = 0; - NPC.rarity = 1; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 25f; - NPC.knockBackResist = 0.9f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.alpha = 75; - NPC.catchItem = (short)CatchItem; - - SafeSetDefaults(); - - // Slime AI breaks with big enough height when it jumps against a low ceiling - // then glitches into the ground - if (NPC.scale > 1f) - { - NPC.height -= (int)((NPC.scale - 1f) * NPC.height); - } - } - - public override bool? CanBeHitByItem(Player player, Item item) - { - return null; //TODO NPC return true - } - - public override bool? CanBeHitByProjectile(Projectile projectile) - { - return !projectile.minion; - } - - public override void HitEffect(int hitDirection, double damage) - { - Color color = DustColor; - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); - } - } - else - { - for (int i = 0; i < 30; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); - } - } - } - - public virtual void SafeSetDefaults() - { - - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SlimePets.CuteSlimeSpawnChance(spawnInfo, SpawnCondition); - } - - public sealed override void ModifyNPCLoot(NPCLoot npcLoot) - { - if (ShouldDropGel) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); - } - - SafeModifyNPCLoot(npcLoot); - } - - public virtual void SafeModifyNPCLoot(NPCLoot npcLoot) - { - - } - - public sealed override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - return SafePreDraw(spriteBatch, screenPos, drawColor); - } - - public virtual bool SafePreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - return true; - } - } + //Not ContentType.FriendlyNPCs, but separate toggle + [Content(ContentType.CuteSlimes)] + public abstract class CuteSlimeBaseNPC : AssNPC + { + public abstract string IngameName { get; } + + public abstract int CatchItem { get; } + + public abstract SpawnConditionType SpawnCondition { get; } + + public abstract Color DustColor { get; } + + public virtual bool ShouldDropGel => true; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault(IngameName); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + NPCID.Sets.CountsAsCritter[NPC.type] = true; + + SafeSetStaticDefaults(); + } + + public virtual void SafeSetStaticDefaults() + { + + } + + public sealed override void SetDefaults() + { + NPC.friendly = true; + NPC.dontTakeDamageFromHostiles = true; + NPC.defense = 0; + NPC.lifeMax = 5; + NPC.width = 28; + NPC.height = 33; + NPC.damage = 0; + NPC.rarity = 1; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 25f; + NPC.knockBackResist = 0.9f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.alpha = 75; + NPC.catchItem = (short)CatchItem; + + SafeSetDefaults(); + + // Slime AI breaks with big enough height when it jumps against a low ceiling + // then glitches into the ground + if (NPC.scale > 1f) + { + NPC.height -= (int)((NPC.scale - 1f) * NPC.height); + } + } + + public override bool? CanBeHitByItem(Player player, Item item) + { + return null; //TODO NPC return true + } + + public override bool? CanBeHitByProjectile(Projectile projectile) + { + return !projectile.minion; + } + + public override void HitEffect(int hitDirection, double damage) + { + Color color = DustColor; + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); + } + } + else + { + for (int i = 0; i < 30; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); + } + } + } + + public virtual void SafeSetDefaults() + { + + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SlimePets.CuteSlimeSpawnChance(spawnInfo, SpawnCondition); + } + + public sealed override void ModifyNPCLoot(NPCLoot npcLoot) + { + if (ShouldDropGel) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); + } + + SafeModifyNPCLoot(npcLoot); + } + + public virtual void SafeModifyNPCLoot(NPCLoot npcLoot) + { + + } + + public sealed override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + return SafePreDraw(spriteBatch, screenPos, drawColor); + } + + public virtual bool SafePreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + return true; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeBlack.cs b/NPCs/CuteSlimes/CuteSlimeBlack.cs index ddc2232e..6a115a81 100644 --- a/NPCs/CuteSlimes/CuteSlimeBlack.cs +++ b/NPCs/CuteSlimes/CuteSlimeBlack.cs @@ -1,50 +1,50 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeBlack : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Black Slime"; - } - } + public class CuteSlimeBlack : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Black Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Overworld; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Overworld; + } + } - public override Color DustColor => new Color(80, 80, 80, 100); + public override Color DustColor => new Color(80, 80, 80, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("Harboring great vanity for its ponytail, the easiest way to befriend it is to compliment the hair.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("Harboring great vanity for its ponytail, the easiest way to befriend it is to compliment the hair.") + }); + } - public override void SafeSetDefaults() - { - NPC.scale = 0.9f; - } - } + public override void SafeSetDefaults() + { + NPC.scale = 0.9f; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeBlue.cs b/NPCs/CuteSlimes/CuteSlimeBlue.cs index 411e0f9e..9453957b 100644 --- a/NPCs/CuteSlimes/CuteSlimeBlue.cs +++ b/NPCs/CuteSlimes/CuteSlimeBlue.cs @@ -1,45 +1,45 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeBlue : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Blue Slime"; - } - } + public class CuteSlimeBlue : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Blue Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Overworld; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Overworld; + } + } - public override Color DustColor => new Color(123, 164, 255, 100); + public override Color DustColor => new Color(123, 164, 255, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("Though its expression is dull, this slime is very affectionate and loves to hug anyone that it gets close to.") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("Though its expression is dull, this slime is very affectionate and loves to hug anyone that it gets close to.") + }); + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeCorrupt.cs b/NPCs/CuteSlimes/CuteSlimeCorrupt.cs index b682100d..271c83b9 100644 --- a/NPCs/CuteSlimes/CuteSlimeCorrupt.cs +++ b/NPCs/CuteSlimes/CuteSlimeCorrupt.cs @@ -1,50 +1,50 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeCorrupt : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Corrupt Slime"; - } - } + public class CuteSlimeCorrupt : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Corrupt Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Corruption; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Corruption; + } + } - public override Color DustColor => new Color(97, 89, 164, 100); + public override Color DustColor => new Color(97, 89, 164, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCorruption, - new FlavorTextBestiaryInfoElement("Hollow eyes and a dark color makes you think this slime is dangerous, but it's just not very social.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCorruption, + new FlavorTextBestiaryInfoElement("Hollow eyes and a dark color makes you think this slime is dangerous, but it's just not very social.") + }); + } - public override void SafeSetDefaults() - { - NPC.scale = 1.2f; - } - } + public override void SafeSetDefaults() + { + NPC.scale = 1.2f; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeCrimson.cs b/NPCs/CuteSlimes/CuteSlimeCrimson.cs index 7a71c936..fb1d2770 100644 --- a/NPCs/CuteSlimes/CuteSlimeCrimson.cs +++ b/NPCs/CuteSlimes/CuteSlimeCrimson.cs @@ -1,50 +1,50 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeCrimson : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Crimson Slime"; - } - } + public class CuteSlimeCrimson : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Crimson Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Crimson; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Crimson; + } + } - public override Color DustColor => new Color(207, 140, 118, 100); + public override Color DustColor => new Color(207, 140, 118, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCrimson, - new FlavorTextBestiaryInfoElement("Though it looks like it has an unstable mind, this slime is incredibly calm and collected.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCrimson, + new FlavorTextBestiaryInfoElement("Though it looks like it has an unstable mind, this slime is incredibly calm and collected.") + }); + } - public override void SafeSetDefaults() - { - NPC.scale = 1.2f; - } - } + public override void SafeSetDefaults() + { + NPC.scale = 1.2f; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeDungeon.cs b/NPCs/CuteSlimes/CuteSlimeDungeon.cs index 2884dbcd..1af3b6b1 100644 --- a/NPCs/CuteSlimes/CuteSlimeDungeon.cs +++ b/NPCs/CuteSlimes/CuteSlimeDungeon.cs @@ -1,76 +1,76 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.PetAccessories; using AssortedCrazyThings.Items.Pets.CuteSlimes; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeDungeon : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Dungeon Slime"; - } - } + public class CuteSlimeDungeon : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Dungeon Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Dungeon; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Dungeon; + } + } - public override Color DustColor => new Color(137, 129, 193, 100); + public override Color DustColor => new Color(137, 129, 193, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheDungeon, - new FlavorTextBestiaryInfoElement("This slime was created in the image of an ancient sorceress. Other than the lack of legs, it's almost perfect.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheDungeon, + new FlavorTextBestiaryInfoElement("This slime was created in the image of an ancient sorceress. Other than the lack of legs, it's almost perfect.") + }); + } - public override bool ShouldDropGel => true; + public override bool ShouldDropGel => true; - public override void SafeSetDefaults() - { - NPC.scale = 1.2f; - } + public override void SafeSetDefaults() + { + NPC.scale = 1.2f; + } - public override void SafeModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 7)). - OnFailedRoll(ItemDropRule.Common(ItemID.GoldenKey)); - } + public override void SafeModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 7)). + OnFailedRoll(ItemDropRule.Common(ItemID.GoldenKey)); + } - public override bool SafePreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/CuteSlimes/CuteSlimeDungeonAddition").Value; - Vector2 stupidOffset = new Vector2(0f, -12f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - drawColor.A = 255; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + public override bool SafePreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/CuteSlimes/CuteSlimeDungeonAddition").Value; + Vector2 stupidOffset = new Vector2(0f, -12f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + drawColor.A = 255; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return true; - } - } + return true; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeGlobalNPC.cs b/NPCs/CuteSlimes/CuteSlimeGlobalNPC.cs index cda4df92..afeb67ea 100644 --- a/NPCs/CuteSlimes/CuteSlimeGlobalNPC.cs +++ b/NPCs/CuteSlimes/CuteSlimeGlobalNPC.cs @@ -6,19 +6,19 @@ namespace AssortedCrazyThings.NPCs.CuteSlimes { - [Content(ContentType.CuteSlimes)] - public class CuteSlimeGlobalNPC : AssGlobalNPC - { - public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) - { - if (npc.type == NPCID.KingSlime) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.QueenSlimeBoss) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - } - } + [Content(ContentType.CuteSlimes)] + public class CuteSlimeGlobalNPC : AssGlobalNPC + { + public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) + { + if (npc.type == NPCID.KingSlime) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.QueenSlimeBoss) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeGreen.cs b/NPCs/CuteSlimes/CuteSlimeGreen.cs index d8245626..4af14ebb 100644 --- a/NPCs/CuteSlimes/CuteSlimeGreen.cs +++ b/NPCs/CuteSlimes/CuteSlimeGreen.cs @@ -1,50 +1,50 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeGreen : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Green Slime"; - } - } + public class CuteSlimeGreen : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Green Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Overworld; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Overworld; + } + } - public override Color DustColor => new Color(27, 246, 66, 100); + public override Color DustColor => new Color(27, 246, 66, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("Don't let the closed eyes fool you; this slime is attentive and ready to act at a moment's notice.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("Don't let the closed eyes fool you; this slime is attentive and ready to act at a moment's notice.") + }); + } - public override void SafeSetDefaults() - { - NPC.scale = 0.9f; - } - } + public override void SafeSetDefaults() + { + NPC.scale = 0.9f; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeIce.cs b/NPCs/CuteSlimes/CuteSlimeIce.cs index b0e53400..c2dd76ff 100644 --- a/NPCs/CuteSlimes/CuteSlimeIce.cs +++ b/NPCs/CuteSlimes/CuteSlimeIce.cs @@ -1,50 +1,50 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeIce : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Ice Slime"; - } - } + public class CuteSlimeIce : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Ice Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Tundra; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Tundra; + } + } - public override Color DustColor => new Color(97, 200, 225, 100); + public override Color DustColor => new Color(97, 200, 225, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Snow, - new FlavorTextBestiaryInfoElement("Its body may be cold to the touch, but its expression and mannerisms will warm your heart.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Snow, + new FlavorTextBestiaryInfoElement("Its body may be cold to the touch, but its expression and mannerisms will warm your heart.") + }); + } - public override void SafeSetDefaults() - { - NPC.scale = 0.9f; - } - } + public override void SafeSetDefaults() + { + NPC.scale = 0.9f; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeIlluminant.cs b/NPCs/CuteSlimes/CuteSlimeIlluminant.cs index b5c816a9..bb9bf65b 100644 --- a/NPCs/CuteSlimes/CuteSlimeIlluminant.cs +++ b/NPCs/CuteSlimes/CuteSlimeIlluminant.cs @@ -1,77 +1,77 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeIlluminant : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Illuminant Slime"; - } - } + public class CuteSlimeIlluminant : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Illuminant Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Hallow; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Hallow; + } + } - public override Color DustColor => new Color(202, 59, 231, 100); + public override Color DustColor => new Color(202, 59, 231, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.UndergroundHallow, - new FlavorTextBestiaryInfoElement("The erratic nature of the Hallow has made this slime quite playful.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.UndergroundHallow, + new FlavorTextBestiaryInfoElement("The erratic nature of the Hallow has made this slime quite playful.") + }); + } - public override void SafeSetStaticDefaults() - { - NPCID.Sets.TrailingMode[NPC.type] = 3; - NPCID.Sets.TrailCacheLength[NPC.type] = 8; - } + public override void SafeSetStaticDefaults() + { + NPCID.Sets.TrailingMode[NPC.type] = 3; + NPCID.Sets.TrailCacheLength[NPC.type] = 8; + } - public override void SafeSetDefaults() - { - DrawOffsetY = 1f; - NPC.alpha = 80; - } + public override void SafeSetDefaults() + { + DrawOffsetY = 1f; + NPC.alpha = 80; + } - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/CuteSlimes/CuteSlimeIlluminantAddition").Value; - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width / 2, NPC.height / 2 + NPC.gfxOffY - 5f); + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/CuteSlimes/CuteSlimeIlluminantAddition").Value; + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width / 2, NPC.height / 2 + NPC.gfxOffY - 5f); - // The higher the k, the older the position - // Length is implicitely set in TrailCacheLength up there - for (int k = NPC.oldPos.Length - 1; k >= 0; k--) - { - Vector2 drawPos = NPC.oldPos[k] - screenPos + drawOrigin; - Color color = NPC.GetAlpha(Color.White) * ((NPC.oldPos.Length - k) / (1f * NPC.oldPos.Length)) * ((255 - NPC.alpha) / 255f) * 0.5f; - color.A = (byte)(NPC.alpha * ((NPC.oldPos.Length - k) / NPC.oldPos.Length)); - spriteBatch.Draw(texture, drawPos, NPC.frame, color, NPC.oldRot[k], NPC.frame.Size() / 2, NPC.scale, effect, 0f); - } - } - } + // The higher the k, the older the position + // Length is implicitely set in TrailCacheLength up there + for (int k = NPC.oldPos.Length - 1; k >= 0; k--) + { + Vector2 drawPos = NPC.oldPos[k] - screenPos + drawOrigin; + Color color = NPC.GetAlpha(Color.White) * ((NPC.oldPos.Length - k) / (1f * NPC.oldPos.Length)) * ((255 - NPC.alpha) / 255f) * 0.5f; + color.A = (byte)(NPC.alpha * ((NPC.oldPos.Length - k) / NPC.oldPos.Length)); + spriteBatch.Draw(texture, drawPos, NPC.frame, color, NPC.oldRot[k], NPC.frame.Size() / 2, NPC.scale, effect, 0f); + } + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeJungle.cs b/NPCs/CuteSlimes/CuteSlimeJungle.cs index 0684a999..c9530d49 100644 --- a/NPCs/CuteSlimes/CuteSlimeJungle.cs +++ b/NPCs/CuteSlimes/CuteSlimeJungle.cs @@ -1,45 +1,45 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeJungle : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Jungle Slime"; - } - } + public class CuteSlimeJungle : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Jungle Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Jungle; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Jungle; + } + } - public override Color DustColor => new Color(114, 187, 58, 100); + public override Color DustColor => new Color(114, 187, 58, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, - new FlavorTextBestiaryInfoElement("Life in the jungle is hard for soft-bodied visitors, but this slime proves it's not impossible.") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, + new FlavorTextBestiaryInfoElement("Life in the jungle is hard for soft-bodied visitors, but this slime proves it's not impossible.") + }); + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeLava.cs b/NPCs/CuteSlimes/CuteSlimeLava.cs index b0d56784..8ee7aac8 100644 --- a/NPCs/CuteSlimes/CuteSlimeLava.cs +++ b/NPCs/CuteSlimes/CuteSlimeLava.cs @@ -1,78 +1,78 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent.Bestiary; using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeLava : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Lava Slime"; - } - } + public class CuteSlimeLava : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Lava Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Hell; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Hell; + } + } - public override Color DustColor => new Color(253, 121, 3, 100); + public override Color DustColor => new Color(253, 121, 3, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheUnderworld, - new FlavorTextBestiaryInfoElement("Having accidentally gotten impaled by a chunk of obsidian, this slime laments being unable to remove it.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheUnderworld, + new FlavorTextBestiaryInfoElement("Having accidentally gotten impaled by a chunk of obsidian, this slime laments being unable to remove it.") + }); + } - public override bool ShouldDropGel => true; + public override bool ShouldDropGel => true; - public override void SafeSetDefaults() - { - NPC.lavaImmune = true; - } + public override void SafeSetDefaults() + { + NPC.lavaImmune = true; + } - public override Color? GetAlpha(Color drawColor) - { - drawColor = Color.White * 0.78f; - drawColor.A = 75; - return drawColor; - } + public override Color? GetAlpha(Color drawColor) + { + drawColor = Color.White * 0.78f; + drawColor.A = 75; + return drawColor; + } - public override void DrawEffects(ref Color drawColor) - { - int widthOffset = 12; - Dust.NewDustDirect(NPC.position + new Vector2(widthOffset, -20), NPC.width - 2 * widthOffset, NPC.height + 20, 6).noGravity = true; - } + public override void DrawEffects(ref Color drawColor) + { + int widthOffset = 12; + Dust.NewDustDirect(NPC.position + new Vector2(widthOffset, -20), NPC.width - 2 * widthOffset, NPC.height + 20, 6).noGravity = true; + } - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/CuteSlimes/CuteSlimeLavaAddition").Value; - Vector2 stupidOffset = new Vector2(0f, -6 * NPC.scale + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - drawColor.A = 255; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/CuteSlimes/CuteSlimeLavaAddition").Value; + Vector2 stupidOffset = new Vector2(0f, -6 * NPC.scale + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + drawColor.A = 255; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimePink.cs b/NPCs/CuteSlimes/CuteSlimePink.cs index 0b8e97a6..e52fc989 100644 --- a/NPCs/CuteSlimes/CuteSlimePink.cs +++ b/NPCs/CuteSlimes/CuteSlimePink.cs @@ -1,51 +1,51 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimePink : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Pink Slime"; - } - } + public class CuteSlimePink : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Pink Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Overworld; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Overworld; + } + } - public override Color DustColor => new Color(255, 155, 154, 100); + public override Color DustColor => new Color(255, 155, 154, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("Dimminutive does not mean lacking. Despite its size, this slime has more spunk than an entire party.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("Dimminutive does not mean lacking. Despite its size, this slime has more spunk than an entire party.") + }); + } - public override void SafeSetDefaults() - { - NPC.scale = 0.5f; - DrawOffsetY = -2f; - } - } + public override void SafeSetDefaults() + { + NPC.scale = 0.5f; + DrawOffsetY = -2f; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimePurple.cs b/NPCs/CuteSlimes/CuteSlimePurple.cs index a4b6b042..2f9ca3c4 100644 --- a/NPCs/CuteSlimes/CuteSlimePurple.cs +++ b/NPCs/CuteSlimes/CuteSlimePurple.cs @@ -1,50 +1,50 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimePurple : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Purple Slime"; - } - } + public class CuteSlimePurple : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Purple Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Overworld; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Overworld; + } + } - public override Color DustColor => new Color(224, 112, 255, 100); + public override Color DustColor => new Color(224, 112, 255, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("Don't let the smile fool you; it's actually much happier than it looks.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("Don't let the smile fool you; it's actually much happier than it looks.") + }); + } - public override void SafeSetDefaults() - { - NPC.scale = 1.2f; - } - } + public override void SafeSetDefaults() + { + NPC.scale = 1.2f; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeRainbow.cs b/NPCs/CuteSlimes/CuteSlimeRainbow.cs index 72d0eea0..b9962cb6 100644 --- a/NPCs/CuteSlimes/CuteSlimeRainbow.cs +++ b/NPCs/CuteSlimes/CuteSlimeRainbow.cs @@ -1,58 +1,58 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; using Microsoft.Xna.Framework; using Terraria; +using Terraria.GameContent.Bestiary; using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeRainbow : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Rainbow Slime"; - } - } + public class CuteSlimeRainbow : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Rainbow Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Overworld; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Overworld; + } + } - public override Color DustColor => new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 100); + public override Color DustColor => new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("The caring and motherly nature that this slime exhibits shows that it understands compassion.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("The caring and motherly nature that this slime exhibits shows that it understands compassion.") + }); + } - public override void SafeSetDefaults() - { - NPC.scale = 1.2f; - } + public override void SafeSetDefaults() + { + NPC.scale = 1.2f; + } - public override Color? GetAlpha(Color lightColor) - { - lightColor = Main.DiscoColor; - lightColor *= (255f - NPC.alpha) / 255f; - return lightColor; - } - } + public override Color? GetAlpha(Color lightColor) + { + lightColor = Main.DiscoColor; + lightColor *= (255f - NPC.alpha) / 255f; + return lightColor; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeRed.cs b/NPCs/CuteSlimes/CuteSlimeRed.cs index 3e0491d1..6b358191 100644 --- a/NPCs/CuteSlimes/CuteSlimeRed.cs +++ b/NPCs/CuteSlimes/CuteSlimeRed.cs @@ -1,45 +1,45 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeRed : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Red Slime"; - } - } + public class CuteSlimeRed : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Red Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Overworld; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Overworld; + } + } - public override Color DustColor => new Color(255, 125, 107, 100); + public override Color DustColor => new Color(255, 125, 107, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("A playful slime that is quite active. It sometimes goes overboard when having fun.") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("A playful slime that is quite active. It sometimes goes overboard when having fun.") + }); + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeSand.cs b/NPCs/CuteSlimes/CuteSlimeSand.cs index 14700270..e3c66b64 100644 --- a/NPCs/CuteSlimes/CuteSlimeSand.cs +++ b/NPCs/CuteSlimes/CuteSlimeSand.cs @@ -1,50 +1,50 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeSand : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Sand Slime"; - } - } + public class CuteSlimeSand : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Sand Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Desert; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Desert; + } + } - public override Color DustColor => new Color(244, 227, 117, 100); + public override Color DustColor => new Color(244, 227, 117, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Desert, - new FlavorTextBestiaryInfoElement("The coarse sand that coats its body leads it to keep its distance, but it won't turn down a friend.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Desert, + new FlavorTextBestiaryInfoElement("The coarse sand that coats its body leads it to keep its distance, but it won't turn down a friend.") + }); + } - public override void SafeSetDefaults() - { - NPC.alpha = 45; - } - } + public override void SafeSetDefaults() + { + NPC.alpha = 45; + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeToxic.cs b/NPCs/CuteSlimes/CuteSlimeToxic.cs index a0e3ce9f..7d521563 100644 --- a/NPCs/CuteSlimes/CuteSlimeToxic.cs +++ b/NPCs/CuteSlimes/CuteSlimeToxic.cs @@ -1,45 +1,45 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeToxic : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Toxic Slime"; - } - } + public class CuteSlimeToxic : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Toxic Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Underground; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Underground; + } + } - public override Color DustColor => new Color(142, 164, 89, 100); + public override Color DustColor => new Color(142, 164, 89, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Underground, - new FlavorTextBestiaryInfoElement("Appearances are deceiving; it's only half as monstrous as it looks!") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Underground, + new FlavorTextBestiaryInfoElement("Appearances are deceiving; it's only half as monstrous as it looks!") + }); + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeXmas.cs b/NPCs/CuteSlimes/CuteSlimeXmas.cs index 12e9724e..fe60f6d1 100644 --- a/NPCs/CuteSlimes/CuteSlimeXmas.cs +++ b/NPCs/CuteSlimes/CuteSlimeXmas.cs @@ -1,65 +1,65 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeXmas : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Holiday Slime"; - } - } + public class CuteSlimeXmas : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Holiday Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Xmas; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Xmas; + } + } - public override Color DustColor => new Color(115, 113, 62, 100); + public override Color DustColor => new Color(115, 113, 62, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("The greatest gift is a friend. This slime wants to bring that gift to everyone.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("The greatest gift is a friend. This slime wants to bring that gift to everyone.") + }); + } - public override void SafeModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.GiantBow, chanceDenominator: 5)); - } + public override void SafeModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.GiantBow, chanceDenominator: 5)); + } - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/CuteSlimes/CuteSlimeXmasAddition").Value; - Vector2 stupidOffset = new Vector2(0f, -6 * NPC.scale + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - drawColor.A = 255; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/CuteSlimes/CuteSlimeXmasAddition").Value; + Vector2 stupidOffset = new Vector2(0f, -6 * NPC.scale + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + drawColor.A = 255; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + } + } } diff --git a/NPCs/CuteSlimes/CuteSlimeYellow.cs b/NPCs/CuteSlimes/CuteSlimeYellow.cs index 87d5c60f..0094d50f 100644 --- a/NPCs/CuteSlimes/CuteSlimeYellow.cs +++ b/NPCs/CuteSlimes/CuteSlimeYellow.cs @@ -1,45 +1,45 @@ -using Terraria.GameContent.Bestiary; using AssortedCrazyThings.Base; using AssortedCrazyThings.Items.Pets.CuteSlimes; -using Terraria.ModLoader; using Microsoft.Xna.Framework; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs.CuteSlimes { - public class CuteSlimeYellow : CuteSlimeBaseNPC - { - public override string IngameName - { - get - { - return "Cute Yellow Slime"; - } - } + public class CuteSlimeYellow : CuteSlimeBaseNPC + { + public override string IngameName + { + get + { + return "Cute Yellow Slime"; + } + } - public override int CatchItem - { - get - { - return ModContent.ItemType(); - } - } + public override int CatchItem + { + get + { + return ModContent.ItemType(); + } + } - public override SpawnConditionType SpawnCondition - { - get - { - return SpawnConditionType.Overworld; - } - } + public override SpawnConditionType SpawnCondition + { + get + { + return SpawnConditionType.Overworld; + } + } - public override Color DustColor => new Color(181, 181, 1, 100); + public override Color DustColor => new Color(181, 181, 1, 100); - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("Moving with delicate grace, this slime dances about without missing a step.") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("Moving with delicate grace, this slime dances about without missing a step.") + }); + } + } } diff --git a/NPCs/DemonEyeFractured.cs b/NPCs/DemonEyeFractured.cs index 79cfe4d9..4035ed2c 100644 --- a/NPCs/DemonEyeFractured.cs +++ b/NPCs/DemonEyeFractured.cs @@ -7,7 +7,7 @@ namespace AssortedCrazyThings.NPCs { - /* This class holds three retextures of DemonEye, that only differ by their texture and their gore + /* This class holds three retextures of DemonEye, that only differ by their texture and their gore * First off, you need to declare the total number of retextures that you intend to use for this particular class * (private const int TotalNumberOfThese) * Then for organizations sake you "name" them by their number so you can see in the code what texture is what number @@ -31,62 +31,62 @@ namespace AssortedCrazyThings.NPCs * (Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeFractured_" + AiTexture).Value) */ - public class DemonEyeFractured : DemonEyeRecolorBase - { - public override int TotalNumberOfThese => 3; + public class DemonEyeFractured : DemonEyeRecolorBase + { + public override int TotalNumberOfThese => 3; - /*FG = 0 + /*FG = 0 * FP = 1 * FR = 2 */ - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/DemonEyeFractured_0"; //use fixed texture - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/DemonEyeFractured_0"; //use fixed texture + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return !NPC.downedBoss1 ? 0f : SpawnCondition.OverworldNightMonster.Chance * 0.025f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return !NPC.downedBoss1 ? 0f : SpawnCondition.OverworldNightMonster.Chance * 0.025f; + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life <= 0) - { - switch ((int)AiTexture) - { - case 0: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); - break; - case 1: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); - break; - case 2: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeRedGore_0").Type, 1f); - break; - default: - break; - } - } - } + if (NPC.life <= 0) + { + switch ((int)AiTexture) + { + case 0: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); + break; + case 1: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); + break; + case 2: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeRedGore_0").Type, 1f); + break; + default: + break; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeFractured_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, NPC.height / 3); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeFractured_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, NPC.height / 3); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + } } diff --git a/NPCs/DemonEyeLaser.cs b/NPCs/DemonEyeLaser.cs index d9b7b01d..ff95622a 100644 --- a/NPCs/DemonEyeLaser.cs +++ b/NPCs/DemonEyeLaser.cs @@ -8,160 +8,160 @@ namespace AssortedCrazyThings.NPCs { - public class DemonEyeLaser : DemonEyeRecolorBase - { - public override int TotalNumberOfThese => 3; + public class DemonEyeLaser : DemonEyeRecolorBase + { + public override int TotalNumberOfThese => 3; - /*LG = 0 + /*LG = 0 * LP = 1 * LR = 2 */ - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/DemonEyeLaser_0"; //use fixed texture - } - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return !NPC.downedMechBoss2 ? 0f : SpawnCondition.OverworldNightMonster.Chance * 0.025f; - } - - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } - - if (NPC.life <= 0) - { - switch ((int)AiTexture) - { - case 0: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); - break; - case 1: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); - break; - case 2: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeRedGore_0").Type, 1f); - break; - default: - break; - } - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeLaser_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(-4f, 0f); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeLaser_Glowmask").Value; - - Vector2 stupidOffset = new Vector2(-4f, 0f); - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, Color.White, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - } - - public Vector2 RotToNormal(float rotation) - { - return new Vector2((float)Math.Sin(rotation), (float)-Math.Cos(rotation)); - } - - public float AngleBetween(Vector2 v1, Vector2 v2) - { - double sin = v1.X * v2.Y - v2.X * v1.Y; - double cos = v1.X * v2.X + v1.Y * v2.Y; - - return (float)Math.Atan2(sin, cos); - } - - public ref float AiShootTimer => ref NPC.ai[0]; - - public ref float AiShootCount => ref NPC.ai[1]; - - public override void PostAI() - { - if (!NPC.HasValidTarget) return; - - if (Main.netMode == NetmodeID.MultiplayerClient) return; - - Vector2 npcposition = NPC.Center; - Player player = Main.player[NPC.target]; - Vector2 distance = new Vector2(player.position.X + player.width / 2 - npcposition.X, - player.position.Y + player.height / 2 - npcposition.Y); - float rot = NPC.rotation; - if (NPC.spriteDirection == 1) - { - rot += MathHelper.TwoPi / 2; - } - - //Vector fuckery - bool canShoot = Math.Abs(AngleBetween(RotToNormal(rot - MathHelper.TwoPi / 4), distance / distance.Length())) < 0.3f; - float shootDelay = 180f; - - //Main.NewText("rotation: " + (rot - MathHelper.TwoPi/4)); //(npc.rotation + MathHelper.TwoPi/4) - //Main.NewText("distance: " + AngleBetween(RotToNormal(rot - MathHelper.TwoPi/4), distance / distance.Length())); - //Main.NewText("rotation vector: " + RotToNormal(rot - MathHelper.TwoPi / 4)); - //Main.NewText("distance vector: " + distance/distance.Length()); - if (canShoot) - { - AiShootTimer++; - if (AiShootCount < 2f) - { - shootDelay = 30f; - } - else if (AiShootCount == 2f) - { - shootDelay = 180f; - } - else if (AiShootCount > 2f) - { - AiShootTimer = 0f; - AiShootCount = 0f; - } - } - else - { - AiShootTimer = 0f; - AiShootCount = 0f; - } - if (canShoot && (AiShootTimer > shootDelay) && Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) - { - AiShootCount++; - AiShootTimer = 0f; - float distancex = distance.X; - float distancey = distance.Y; - float num427 = 8.5f; - int damage = 8; - int type = ProjectileID.PinkLaser; //the gastropod one - if (Main.expertMode) - { - num427 = 10f; - damage = 6; - } - float distancen = (float)Math.Sqrt((double)(distancex * distancex + distancey * distancey)); - distancen = num427 / distancen; - distancex *= distancen; - distancey *= distancen; - npcposition.X += distancex * 5f; - npcposition.Y += distancey * 5f; - Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), npcposition.X, npcposition.Y, distancex, distancey, type, damage, 0f, Owner: Main.myPlayer); - } - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/DemonEyeLaser_0"; //use fixed texture + } + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return !NPC.downedMechBoss2 ? 0f : SpawnCondition.OverworldNightMonster.Chance * 0.025f; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } + + if (NPC.life <= 0) + { + switch ((int)AiTexture) + { + case 0: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); + break; + case 1: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); + break; + case 2: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeRedGore_0").Type, 1f); + break; + default: + break; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeLaser_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(-4f, 0f); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeLaser_Glowmask").Value; + + Vector2 stupidOffset = new Vector2(-4f, 0f); + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, Color.White, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + } + + public Vector2 RotToNormal(float rotation) + { + return new Vector2((float)Math.Sin(rotation), (float)-Math.Cos(rotation)); + } + + public float AngleBetween(Vector2 v1, Vector2 v2) + { + double sin = v1.X * v2.Y - v2.X * v1.Y; + double cos = v1.X * v2.X + v1.Y * v2.Y; + + return (float)Math.Atan2(sin, cos); + } + + public ref float AiShootTimer => ref NPC.ai[0]; + + public ref float AiShootCount => ref NPC.ai[1]; + + public override void PostAI() + { + if (!NPC.HasValidTarget) return; + + if (Main.netMode == NetmodeID.MultiplayerClient) return; + + Vector2 npcposition = NPC.Center; + Player player = Main.player[NPC.target]; + Vector2 distance = new Vector2(player.position.X + player.width / 2 - npcposition.X, + player.position.Y + player.height / 2 - npcposition.Y); + float rot = NPC.rotation; + if (NPC.spriteDirection == 1) + { + rot += MathHelper.TwoPi / 2; + } + + //Vector fuckery + bool canShoot = Math.Abs(AngleBetween(RotToNormal(rot - MathHelper.TwoPi / 4), distance / distance.Length())) < 0.3f; + float shootDelay = 180f; + + //Main.NewText("rotation: " + (rot - MathHelper.TwoPi/4)); //(npc.rotation + MathHelper.TwoPi/4) + //Main.NewText("distance: " + AngleBetween(RotToNormal(rot - MathHelper.TwoPi/4), distance / distance.Length())); + //Main.NewText("rotation vector: " + RotToNormal(rot - MathHelper.TwoPi / 4)); + //Main.NewText("distance vector: " + distance/distance.Length()); + if (canShoot) + { + AiShootTimer++; + if (AiShootCount < 2f) + { + shootDelay = 30f; + } + else if (AiShootCount == 2f) + { + shootDelay = 180f; + } + else if (AiShootCount > 2f) + { + AiShootTimer = 0f; + AiShootCount = 0f; + } + } + else + { + AiShootTimer = 0f; + AiShootCount = 0f; + } + if (canShoot && (AiShootTimer > shootDelay) && Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + { + AiShootCount++; + AiShootTimer = 0f; + float distancex = distance.X; + float distancey = distance.Y; + float num427 = 8.5f; + int damage = 8; + int type = ProjectileID.PinkLaser; //the gastropod one + if (Main.expertMode) + { + num427 = 10f; + damage = 6; + } + float distancen = (float)Math.Sqrt((double)(distancex * distancex + distancey * distancey)); + distancen = num427 / distancen; + distancex *= distancen; + distancey *= distancen; + npcposition.X += distancex * 5f; + npcposition.Y += distancey * 5f; + Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), npcposition.X, npcposition.Y, distancex, distancey, type, damage, 0f, Owner: Main.myPlayer); + } + } + } } diff --git a/NPCs/DemonEyeMechanical.cs b/NPCs/DemonEyeMechanical.cs index 45f1f7b6..e0cc533f 100644 --- a/NPCs/DemonEyeMechanical.cs +++ b/NPCs/DemonEyeMechanical.cs @@ -7,71 +7,71 @@ namespace AssortedCrazyThings.NPCs { - public class DemonEyeMechanical : DemonEyeRecolorBase - { - public override int TotalNumberOfThese => 3; + public class DemonEyeMechanical : DemonEyeRecolorBase + { + public override int TotalNumberOfThese => 3; - /*MG = 0 + /*MG = 0 * MP = 1 * MR = 2 */ - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/DemonEyeMechanical_0"; //use fixed texture - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/DemonEyeMechanical_0"; //use fixed texture + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return !NPC.downedMechBoss2 ? 0f : SpawnCondition.OverworldNightMonster.Chance * 0.025f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return !NPC.downedMechBoss2 ? 0f : SpawnCondition.OverworldNightMonster.Chance * 0.025f; + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life <= 0) - { - switch ((int)AiTexture) - { - case 0: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); - break; - case 1: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); - break; - case 2: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeRedGore_0").Type, 1f); - break; - default: - break; - } - } - } + if (NPC.life <= 0) + { + switch ((int)AiTexture) + { + case 0: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); + break; + case 1: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); + break; + case 2: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeRedGore_0").Type, 1f); + break; + default: + break; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeMechanical_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, 0f); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeMechanical_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, 0f); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeMechanical_Glowmask").Value; - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + new Vector2(0f, 0f); - spriteBatch.Draw(texture, drawPos, NPC.frame, Color.White, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeMechanical_Glowmask").Value; + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + new Vector2(0f, 0f); + spriteBatch.Draw(texture, drawPos, NPC.frame, Color.White, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + } + } } diff --git a/NPCs/DemonEyeRecolorBase.cs b/NPCs/DemonEyeRecolorBase.cs index a0c125b3..2e98fe20 100644 --- a/NPCs/DemonEyeRecolorBase.cs +++ b/NPCs/DemonEyeRecolorBase.cs @@ -1,89 +1,88 @@ using Terraria; -using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.NPCs { - /// - /// Hides from bestiary, has default stats, drops, and same texture handle - /// - [Content(ContentType.HostileNPCs)] - public abstract class DemonEyeRecolorBase : AssNPC - { - public virtual int TotalNumberOfThese => 0; + /// + /// Hides from bestiary, has default stats, drops, and same texture handle + /// + [Content(ContentType.HostileNPCs)] + public abstract class DemonEyeRecolorBase : AssNPC + { + public virtual int TotalNumberOfThese => 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Demon Eye"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.DemonEye]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Demon Eye"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.DemonEye]; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - Hide = true //Hides this NPC from the Bestiary - }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value); - } + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + Hide = true //Hides this NPC from the Bestiary + }; + NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value); + } - public override void SetDefaults() - { - NPC.CloneDefaults(NPCID.DemonEye); - NPC.width = 32; - NPC.height = 32; - NPC.damage = 18; - NPC.defense = 2; - NPC.lifeMax = 60; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 75f; - NPC.knockBackResist = 0.5f; - NPC.aiStyle = 2; - AIType = NPCID.DemonEye; - AnimationType = NPCID.DemonEye; - Banner = Item.NPCtoBanner(NPCID.DemonEye); - BannerItem = Item.BannerToItem(Banner); - } + public override void SetDefaults() + { + NPC.CloneDefaults(NPCID.DemonEye); + NPC.width = 32; + NPC.height = 32; + NPC.damage = 18; + NPC.defense = 2; + NPC.lifeMax = 60; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 75f; + NPC.knockBackResist = 0.5f; + NPC.aiStyle = 2; + AIType = NPCID.DemonEye; + AnimationType = NPCID.DemonEye; + Banner = Item.NPCtoBanner(NPCID.DemonEye); + BannerItem = Item.BannerToItem(Banner); + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - var vanillaDrops = Main.ItemDropsDB.GetRulesForNPCID(NPCID.DemonEye, false); // false is important here - foreach (var dropRule in vanillaDrops) - { - npcLoot.Add(dropRule); - } - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + var vanillaDrops = Main.ItemDropsDB.GetRulesForNPCID(NPCID.DemonEye, false); // false is important here + foreach (var dropRule in vanillaDrops) + { + npcLoot.Add(dropRule); + } + } - public override void HitEffect(int hitDirection, double damage) - { - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, hitDirection, -1f); - } - } - else - { - for (int i = 0; i < 30; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 2 * hitDirection, -1f); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, hitDirection, -1f); + } + } + else + { + for (int i = 0; i < 30; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 2 * hitDirection, -1f); + } + } + } - public ref float AiTexture => ref NPC.ai[3]; + public ref float AiTexture => ref NPC.ai[3]; - public override bool PreAI() - { - if (AiTexture == 0 && NPC.localAI[0] == 0 && Main.netMode != NetmodeID.MultiplayerClient && TotalNumberOfThese > 0) - { - AiTexture = Main.rand.Next(TotalNumberOfThese); + public override bool PreAI() + { + if (AiTexture == 0 && NPC.localAI[0] == 0 && Main.netMode != NetmodeID.MultiplayerClient && TotalNumberOfThese > 0) + { + AiTexture = Main.rand.Next(TotalNumberOfThese); - NPC.localAI[0] = 1; - NPC.netUpdate = true; - } + NPC.localAI[0] = 1; + NPC.netUpdate = true; + } - return true; - } - } + return true; + } + } } diff --git a/NPCs/DemonEyeRegular.cs b/NPCs/DemonEyeRegular.cs index 28545760..d88e8ebb 100644 --- a/NPCs/DemonEyeRegular.cs +++ b/NPCs/DemonEyeRegular.cs @@ -7,10 +7,10 @@ namespace AssortedCrazyThings.NPCs { - public class DemonEyeRegular : DemonEyeRecolorBase - { - public override int TotalNumberOfThese => 6; - /*CG = 0 + public class DemonEyeRegular : DemonEyeRecolorBase + { + public override int TotalNumberOfThese => 6; + /*CG = 0 * CP = 1 * DG = 2 * DP = 3 @@ -18,76 +18,76 @@ public class DemonEyeRegular : DemonEyeRecolorBase * SP = 5 */ - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/DemonEyeRegular_0"; //use fixed texture - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/DemonEyeRegular_0"; //use fixed texture + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.OverworldNightMonster.Chance * 0.025f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.OverworldNightMonster.Chance * 0.025f; + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life <= 0) - { - /*CG = 0 + if (NPC.life <= 0) + { + /*CG = 0 * CP = 1 * DG = 2 * DP = 3 * SG = 4 * SP = 5 */ - switch ((int)AiTexture) - { - case 0: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeCataractGore_0").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); - break; - case 1: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeCataractGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); - break; - case 2: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeDilatedGore_0").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); - break; - case 3: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeDilatedGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); - break; - case 4: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeSleepyGore_0").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); - break; - case 5: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeSleepyGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); - break; - default: - break; - } - } - } + switch ((int)AiTexture) + { + case 0: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeCataractGore_0").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); + break; + case 1: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeCataractGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); + break; + case 2: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeDilatedGore_0").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); + break; + case 3: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeDilatedGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); + break; + case 4: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeSleepyGore_0").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); + break; + case 5: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeSleepyGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); + break; + default: + break; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeRegular_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, 0f); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeRegular_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, 0f); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + } } diff --git a/NPCs/DemonEyeSeasonal.cs b/NPCs/DemonEyeSeasonal.cs index affef7a6..4c752b3e 100644 --- a/NPCs/DemonEyeSeasonal.cs +++ b/NPCs/DemonEyeSeasonal.cs @@ -7,74 +7,74 @@ namespace AssortedCrazyThings.NPCs { - public class DemonEyeSeasonal : DemonEyeRecolorBase - { - public override int TotalNumberOfThese => 4; + public class DemonEyeSeasonal : DemonEyeRecolorBase + { + public override int TotalNumberOfThese => 4; - /*OG = 0 + /*OG = 0 * OP = 1 * UG = 2 * UP = 3 */ - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/DemonEyeSeasonal_0"; //use fixed texture - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/DemonEyeSeasonal_0"; //use fixed texture + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (Main.halloween) - { - return SpawnCondition.OverworldNightMonster.Chance * 0.025f; - } - return 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (Main.halloween) + { + return SpawnCondition.OverworldNightMonster.Chance * 0.025f; + } + return 0f; + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life <= 0) - { - switch ((int)AiTexture) - { - case 0: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); - break; - case 1: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); - break; - case 2: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); - break; - case 3: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); - break; - default: - break; - } - } - } + if (NPC.life <= 0) + { + switch ((int)AiTexture) + { + case 0: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); + break; + case 1: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); + break; + case 2: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyeGreenGore_0").Type, 1f); + break; + case 3: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("DemonEyePurpleGore_0").Type, 1f); + break; + default: + break; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeSeasonal_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, NPC.height / 3); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeSeasonal_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, NPC.height / 3); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + } } diff --git a/NPCs/DemonEyeWandering.cs b/NPCs/DemonEyeWandering.cs index 979f80aa..f893417b 100644 --- a/NPCs/DemonEyeWandering.cs +++ b/NPCs/DemonEyeWandering.cs @@ -7,137 +7,137 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class DemonEyeWandering : AssNPC - { - private const int TotalNumberOfThese = 2; + [Content(ContentType.HostileNPCs)] + public class DemonEyeWandering : AssNPC + { + private const int TotalNumberOfThese = 2; - /*WG = 0 + /*WG = 0 * WP = 1 */ - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/DemonEyeWandering_0"; //use fixed texture - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wandering Eye"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.WanderingEye]; - - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - Hide = true //Hides this NPC from the Bestiary - }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value); - } - - public override void SetDefaults() - { - NPC.width = 38; - NPC.height = 32; - NPC.damage = 40; - NPC.defense = 20; - NPC.lifeMax = 300; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 75f; - NPC.knockBackResist = 0.8f; - NPC.aiStyle = 2; - AIType = NPCID.WanderingEye; - AnimationType = NPCID.WanderingEye; - Banner = Item.NPCtoBanner(NPCID.WanderingEye); - BannerItem = Item.BannerToItem(Banner); - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - var vanillaDrops = Main.ItemDropsDB.GetRulesForNPCID(NPCID.WanderingEye, false); // false is important here - foreach (var dropRule in vanillaDrops) - { - npcLoot.Add(dropRule); - } - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (Main.hardMode) - { - return SpawnCondition.OverworldNightMonster.Chance * 0.025f; - } - return 0f; - } - - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } - - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, hitDirection, -1f); - } - } - else - { - for (int i = 0; i < 30; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 2 * hitDirection, -1f); - } - - switch ((int)AiTexture)//switch ((int)npc.altTexture) - { - case 0: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WanderingEyeGreenGore").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WanderingEyeGreenGore").Type, 1f); - break; - case 1: - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WanderingEyePurpleGore").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WanderingEyePurpleGore").Type, 1f); - break; - default: - break; - } - } - } - - public ref float AiTexture => ref NPC.ai[3]; - - public bool DecidedAiTexture - { - get => NPC.localAI[0] == 1f; - set => NPC.localAI[0] = value ? 1f : 0f; - } - - public override bool PreAI() - { - if (AiTexture == 0 && !DecidedAiTexture && Main.netMode != NetmodeID.MultiplayerClient) - { - AiTexture = Main.rand.Next(TotalNumberOfThese); - - DecidedAiTexture = true; - NPC.netUpdate = true; - } - - return true; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeWandering_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, 0f); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/DemonEyeWandering_0"; //use fixed texture + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wandering Eye"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.WanderingEye]; + + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + Hide = true //Hides this NPC from the Bestiary + }; + NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value); + } + + public override void SetDefaults() + { + NPC.width = 38; + NPC.height = 32; + NPC.damage = 40; + NPC.defense = 20; + NPC.lifeMax = 300; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 75f; + NPC.knockBackResist = 0.8f; + NPC.aiStyle = 2; + AIType = NPCID.WanderingEye; + AnimationType = NPCID.WanderingEye; + Banner = Item.NPCtoBanner(NPCID.WanderingEye); + BannerItem = Item.BannerToItem(Banner); + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + var vanillaDrops = Main.ItemDropsDB.GetRulesForNPCID(NPCID.WanderingEye, false); // false is important here + foreach (var dropRule in vanillaDrops) + { + npcLoot.Add(dropRule); + } + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (Main.hardMode) + { + return SpawnCondition.OverworldNightMonster.Chance * 0.025f; + } + return 0f; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } + + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, hitDirection, -1f); + } + } + else + { + for (int i = 0; i < 30; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 2 * hitDirection, -1f); + } + + switch ((int)AiTexture)//switch ((int)npc.altTexture) + { + case 0: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WanderingEyeGreenGore").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WanderingEyeGreenGore").Type, 1f); + break; + case 1: + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WanderingEyePurpleGore").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WanderingEyePurpleGore").Type, 1f); + break; + default: + break; + } + } + } + + public ref float AiTexture => ref NPC.ai[3]; + + public bool DecidedAiTexture + { + get => NPC.localAI[0] == 1f; + set => NPC.localAI[0] = value ? 1f : 0f; + } + + public override bool PreAI() + { + if (AiTexture == 0 && !DecidedAiTexture && Main.netMode != NetmodeID.MultiplayerClient) + { + AiTexture = Main.rand.Next(TotalNumberOfThese); + + DecidedAiTexture = true; + NPC.netUpdate = true; + } + + return true; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/DemonEyeWandering_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, 0f); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + } } diff --git a/NPCs/DropConditions/MatchAppearanceCondition.cs b/NPCs/DropConditions/MatchAppearanceCondition.cs index e374fe66..19c4c0a7 100644 --- a/NPCs/DropConditions/MatchAppearanceCondition.cs +++ b/NPCs/DropConditions/MatchAppearanceCondition.cs @@ -2,25 +2,25 @@ namespace AssortedCrazyThings.NPCs.DropConditions { - public class MatchAppearanceCondition : Conditions.IsUsingSpecificAIValues, IProvideItemConditionDescription - { - public MatchAppearanceCondition(int aiSlot, int valueToMatch) : base(aiSlot, valueToMatch) - { + public class MatchAppearanceCondition : Conditions.IsUsingSpecificAIValues, IProvideItemConditionDescription + { + public MatchAppearanceCondition(int aiSlot, int valueToMatch) : base(aiSlot, valueToMatch) + { - } + } - public new bool CanDrop(DropAttemptInfo info) - { - if (!info.IsInSimulation) - { - return base.CanDrop(info); - } - return false; - } + public new bool CanDrop(DropAttemptInfo info) + { + if (!info.IsInSimulation) + { + return base.CanDrop(info); + } + return false; + } - public new string GetConditionDescription() - { - return "Drops based on appearance"; - } - } + public new string GetConditionDescription() + { + return "Drops based on appearance"; + } + } } diff --git a/NPCs/DropConditions/NoHasItemWithBankCondition.cs b/NPCs/DropConditions/NoHasItemWithBankCondition.cs index 69da6514..d9e4c45e 100644 --- a/NPCs/DropConditions/NoHasItemWithBankCondition.cs +++ b/NPCs/DropConditions/NoHasItemWithBankCondition.cs @@ -9,7 +9,7 @@ public class NoHasItemWithBankCondition : IItemDropRuleCondition, IProvideItemCo private int itemType; public NoHasItemWithBankCondition(int itemType) - { + { this.itemType = itemType; } diff --git a/NPCs/DropConditions/NotAllDronePartsUnlockedCondition.cs b/NPCs/DropConditions/NotAllDronePartsUnlockedCondition.cs index 41f1a4d9..ab670ef3 100644 --- a/NPCs/DropConditions/NotAllDronePartsUnlockedCondition.cs +++ b/NPCs/DropConditions/NotAllDronePartsUnlockedCondition.cs @@ -5,11 +5,11 @@ namespace AssortedCrazyThings.NPCs.DropConditions { - public class NotAllDronePartsUnlockedCondition : Conditions.NeverTrue, IProvideItemConditionDescription - { - public new string GetConditionDescription() - { - return $"Drops if not all {Lang.GetItemNameValue(ModContent.ItemType())} are unlocked yet"; - } - } + public class NotAllDronePartsUnlockedCondition : Conditions.NeverTrue, IProvideItemConditionDescription + { + public new string GetConditionDescription() + { + return $"Drops if not all {Lang.GetItemNameValue(ModContent.ItemType())} are unlocked yet"; + } + } } diff --git a/NPCs/DropRules/OneFromOptionsPerPlayerOnPlayerRule.cs b/NPCs/DropRules/OneFromOptionsPerPlayerOnPlayerRule.cs index 01184461..c3d5c69c 100644 --- a/NPCs/DropRules/OneFromOptionsPerPlayerOnPlayerRule.cs +++ b/NPCs/DropRules/OneFromOptionsPerPlayerOnPlayerRule.cs @@ -4,7 +4,7 @@ namespace AssortedCrazyThings.NPCs.DropRules { - class OneFromOptionsPerPlayerOnPlayerRule : IItemDropRule + class OneFromOptionsPerPlayerOnPlayerRule : IItemDropRule { public int[] dropIds; public int chanceDenominator; diff --git a/NPCs/DroppedPetsGlobalNPC.cs b/NPCs/DroppedPetsGlobalNPC.cs index 95f09c1e..ba0c164a 100644 --- a/NPCs/DroppedPetsGlobalNPC.cs +++ b/NPCs/DroppedPetsGlobalNPC.cs @@ -1,120 +1,120 @@ using AssortedCrazyThings.Items.Pets; using System; using Terraria; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; -using Terraria.GameContent.ItemDropRules; namespace AssortedCrazyThings.NPCs { - [Content(ContentType.DroppedPets)] - public class DroppedPetsGlobalNPC : AssGlobalNPC - { - public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) - { - //Other pets - if (npc.type == NPCID.Antlion || npc.type == NPCID.FlyingAntlion || npc.type == NPCID.WalkingAntlion) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 75)); - } - else if (npc.type == NPCID.GoblinArcher || npc.type == NPCID.GoblinPeon || npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.GoblinSummoner || npc.type == NPCID.GoblinThief || npc.type == NPCID.GoblinWarrior) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 200)); - } - else if (npc.type == NPCID.DarkMummy || npc.type == NPCID.LightMummy || npc.type == NPCID.Mummy) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 75)); - } - else if (npc.type == NPCID.DesertLamiaDark || npc.type == NPCID.DesertLamiaLight) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 75)); - } - else if (npc.type == NPCID.RainbowSlime) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 4)); - } - else if (npc.type == NPCID.IlluminantSlime) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 100)); - } + [Content(ContentType.DroppedPets)] + public class DroppedPetsGlobalNPC : AssGlobalNPC + { + public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) + { + //Other pets + if (npc.type == NPCID.Antlion || npc.type == NPCID.FlyingAntlion || npc.type == NPCID.WalkingAntlion) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 75)); + } + else if (npc.type == NPCID.GoblinArcher || npc.type == NPCID.GoblinPeon || npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.GoblinSummoner || npc.type == NPCID.GoblinThief || npc.type == NPCID.GoblinWarrior) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 200)); + } + else if (npc.type == NPCID.DarkMummy || npc.type == NPCID.LightMummy || npc.type == NPCID.Mummy) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 75)); + } + else if (npc.type == NPCID.DesertLamiaDark || npc.type == NPCID.DesertLamiaLight) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 75)); + } + else if (npc.type == NPCID.RainbowSlime) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 4)); + } + else if (npc.type == NPCID.IlluminantSlime) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 100)); + } - //Boss pets - else if (npc.type == NPCID.KingSlime) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.EyeofCthulhu) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.BrainofCthulhu) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (Array.IndexOf(new int[] { NPCID.EaterofWorldsBody, NPCID.EaterofWorldsHead, NPCID.EaterofWorldsTail }, npc.type) > -1) - { - LeadingConditionRule leadingConditionRule = new(new Conditions.LegacyHack_IsABoss()); - leadingConditionRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - npcLoot.Add(leadingConditionRule); - } - else if (npc.type == NPCID.QueenBee) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.SkeletronHead) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.WallofFlesh) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.QueenSlimeBoss) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.TheDestroyer) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.SkeletronPrime) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.Retinazer || npc.type == NPCID.Spazmatism) - { - LeadingConditionRule leadingConditionRule = new LeadingConditionRule(new Conditions.MissingTwin()); - leadingConditionRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - npcLoot.Add(leadingConditionRule); - } - else if (npc.type == NPCID.Plantera) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.Golem) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.DD2Betsy) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.DukeFishron) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.HallowBoss) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.CultistBoss) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - else if (npc.type == NPCID.MoonLordCore) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - } - } - } + //Boss pets + else if (npc.type == NPCID.KingSlime) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.EyeofCthulhu) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.BrainofCthulhu) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (Array.IndexOf(new int[] { NPCID.EaterofWorldsBody, NPCID.EaterofWorldsHead, NPCID.EaterofWorldsTail }, npc.type) > -1) + { + LeadingConditionRule leadingConditionRule = new(new Conditions.LegacyHack_IsABoss()); + leadingConditionRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + npcLoot.Add(leadingConditionRule); + } + else if (npc.type == NPCID.QueenBee) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.SkeletronHead) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.WallofFlesh) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.QueenSlimeBoss) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.TheDestroyer) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.SkeletronPrime) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.Retinazer || npc.type == NPCID.Spazmatism) + { + LeadingConditionRule leadingConditionRule = new LeadingConditionRule(new Conditions.MissingTwin()); + leadingConditionRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + npcLoot.Add(leadingConditionRule); + } + else if (npc.type == NPCID.Plantera) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.Golem) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.DD2Betsy) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.DukeFishron) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.HallowBoss) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.CultistBoss) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + else if (npc.type == NPCID.MoonLordCore) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + } + } + } } diff --git a/NPCs/DungeonBird/DungeonSoulBase.cs b/NPCs/DungeonBird/DungeonSoulBase.cs index c8b1b0eb..c4c17539 100644 --- a/NPCs/DungeonBird/DungeonSoulBase.cs +++ b/NPCs/DungeonBird/DungeonSoulBase.cs @@ -9,186 +9,186 @@ namespace AssortedCrazyThings.NPCs.DungeonBird { - //this class also contains the NPC classes at the very bottom - [Content(ContentType.Bosses)] - public abstract class DungeonSoulBase : AssNPC - { - protected int frameSpeed; - protected float fadeAwayMax; - public static int SoulActiveTime = NPC.activeTime * 5; - - public static int wid = 34; //24 - public static int hei = 38; - - public sealed override void SetStaticDefaults() - { - DisplayName.SetDefault("Dungeon Soul"); - Main.npcFrameCount[NPC.type] = 6; - Main.npcCatchable[NPC.type] = true; - - //Hide both souls - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - Hide = true //Hides this NPC from the Bestiary - }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value); - - SafeSetStaticDefaults(); - } - - public virtual void SafeSetStaticDefaults() - { - - } - - public override void SetDefaults() - { - NPC.width = wid; - NPC.height = hei; - NPC.npcSlots = 0f; - NPC.chaseable = false; - NPC.dontCountMe = true; - NPC.dontTakeDamageFromHostiles = true; - NPC.dontTakeDamage = true; - NPC.friendly = true; - NPC.noGravity = true; - NPC.damage = 0; - NPC.defense = 0; - NPC.lifeMax = 5; - NPC.scale = 1f; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 0f; - NPC.aiStyle = -1; - AIType = -1; - AnimationType = -1; - NPC.color = new Color(0, 0, 0, 50); - NPC.timeLeft = SoulActiveTime; - NPC.direction = 1; - SafeSetDefaults(); - } - - public virtual void SafeSetDefaults() - { - - } - - public static readonly short offsetYPeriod = 120; - - public ref float AI_Local_Timer => ref NPC.localAI[0]; - - public static void KillInstantly(NPC npc) - { - npc.life = 0; - npc.active = false; - npc.netUpdate = true; - } - - public override bool CheckActive() - { - //manually decrease timeleft - return false; - } - - public override void FindFrame(int frameHeight) - { - NPC.LoopAnimation(frameHeight, frameSpeed); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - return false; - } - - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - drawColor = NPC.GetAlpha(drawColor) * 0.99f; //1f is opaque - drawColor.R = Math.Max(drawColor.R, (byte)200); //100 for dark - drawColor.G = Math.Max(drawColor.G, (byte)200); - drawColor.B = Math.Max(drawColor.B, (byte)200); - - Texture2D image = Terraria.GameContent.TextureAssets.Npc[NPC.type].Value; - Rectangle bounds = new Rectangle - { - X = 0, - Y = NPC.frame.Y, - Width = image.Bounds.Width, - Height = image.Bounds.Height / Main.npcFrameCount[NPC.type] - }; - - float sinY = 0; - AI_Local_Timer = AI_Local_Timer > offsetYPeriod ? 0 : AI_Local_Timer + 1; - sinY = (float)((Math.Sin((AI_Local_Timer / offsetYPeriod) * MathHelper.TwoPi) - 1) * 10); - - if (NPC.timeLeft <= fadeAwayMax) - { - drawColor = NPC.GetAlpha(drawColor) * (NPC.timeLeft / (float)fadeAwayMax); - } - - Vector2 stupidOffset = new Vector2(wid / 2, (hei - 10f) + sinY); - - SpriteEffects effects = SpriteEffects.None; - - spriteBatch.Draw(image, NPC.position - screenPos + stupidOffset, bounds, drawColor, NPC.rotation, bounds.Size() / 2, NPC.scale, effects, 0f); - } - - public override void AI() - { - --NPC.timeLeft; - if (NPC.timeLeft < 0) - { - KillInstantly(NPC); - } - - NPC.scale = 1f; - - NPC.noGravity = true; - NPC.noTileCollide = false; - NPC.velocity *= 0.55f; - } - } - - //the one the harvester hunts for - public class DungeonSoul : DungeonSoulBase - { - public override void SafeSetDefaults() - { - frameSpeed = 6; - NPC.catchItem = (short)ModContent.ItemType(); - - fadeAwayMax = 240; - } - } - - //the one that gets converted into - public class DungeonSoulFreed : DungeonSoulBase - { - public override void SafeSetDefaults() - { - frameSpeed = 4; - NPC.catchItem = (short)ModContent.ItemType(); - - NPC.timeLeft = 3600; - fadeAwayMax = 3600; - } - - public override bool PreAI() - { - //only if awakened - if (NPC.ai[2] != 0) - { - AI_Local_Timer = NPC.ai[2]; - NPC.ai[2] = 0; - } - NPC.noTileCollide = false; - NPC.velocity *= 0.95f; - - --NPC.timeLeft; - if (NPC.timeLeft < 0) - { - KillInstantly(NPC); - } - return false; - } - } + //this class also contains the NPC classes at the very bottom + [Content(ContentType.Bosses)] + public abstract class DungeonSoulBase : AssNPC + { + protected int frameSpeed; + protected float fadeAwayMax; + public static int SoulActiveTime = NPC.activeTime * 5; + + public static int wid = 34; //24 + public static int hei = 38; + + public sealed override void SetStaticDefaults() + { + DisplayName.SetDefault("Dungeon Soul"); + Main.npcFrameCount[NPC.type] = 6; + Main.npcCatchable[NPC.type] = true; + + //Hide both souls + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + Hide = true //Hides this NPC from the Bestiary + }; + NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value); + + SafeSetStaticDefaults(); + } + + public virtual void SafeSetStaticDefaults() + { + + } + + public override void SetDefaults() + { + NPC.width = wid; + NPC.height = hei; + NPC.npcSlots = 0f; + NPC.chaseable = false; + NPC.dontCountMe = true; + NPC.dontTakeDamageFromHostiles = true; + NPC.dontTakeDamage = true; + NPC.friendly = true; + NPC.noGravity = true; + NPC.damage = 0; + NPC.defense = 0; + NPC.lifeMax = 5; + NPC.scale = 1f; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 0f; + NPC.aiStyle = -1; + AIType = -1; + AnimationType = -1; + NPC.color = new Color(0, 0, 0, 50); + NPC.timeLeft = SoulActiveTime; + NPC.direction = 1; + SafeSetDefaults(); + } + + public virtual void SafeSetDefaults() + { + + } + + public static readonly short offsetYPeriod = 120; + + public ref float AI_Local_Timer => ref NPC.localAI[0]; + + public static void KillInstantly(NPC npc) + { + npc.life = 0; + npc.active = false; + npc.netUpdate = true; + } + + public override bool CheckActive() + { + //manually decrease timeleft + return false; + } + + public override void FindFrame(int frameHeight) + { + NPC.LoopAnimation(frameHeight, frameSpeed); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + return false; + } + + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + drawColor = NPC.GetAlpha(drawColor) * 0.99f; //1f is opaque + drawColor.R = Math.Max(drawColor.R, (byte)200); //100 for dark + drawColor.G = Math.Max(drawColor.G, (byte)200); + drawColor.B = Math.Max(drawColor.B, (byte)200); + + Texture2D image = Terraria.GameContent.TextureAssets.Npc[NPC.type].Value; + Rectangle bounds = new Rectangle + { + X = 0, + Y = NPC.frame.Y, + Width = image.Bounds.Width, + Height = image.Bounds.Height / Main.npcFrameCount[NPC.type] + }; + + float sinY = 0; + AI_Local_Timer = AI_Local_Timer > offsetYPeriod ? 0 : AI_Local_Timer + 1; + sinY = (float)((Math.Sin((AI_Local_Timer / offsetYPeriod) * MathHelper.TwoPi) - 1) * 10); + + if (NPC.timeLeft <= fadeAwayMax) + { + drawColor = NPC.GetAlpha(drawColor) * (NPC.timeLeft / (float)fadeAwayMax); + } + + Vector2 stupidOffset = new Vector2(wid / 2, (hei - 10f) + sinY); + + SpriteEffects effects = SpriteEffects.None; + + spriteBatch.Draw(image, NPC.position - screenPos + stupidOffset, bounds, drawColor, NPC.rotation, bounds.Size() / 2, NPC.scale, effects, 0f); + } + + public override void AI() + { + --NPC.timeLeft; + if (NPC.timeLeft < 0) + { + KillInstantly(NPC); + } + + NPC.scale = 1f; + + NPC.noGravity = true; + NPC.noTileCollide = false; + NPC.velocity *= 0.55f; + } + } + + //the one the harvester hunts for + public class DungeonSoul : DungeonSoulBase + { + public override void SafeSetDefaults() + { + frameSpeed = 6; + NPC.catchItem = (short)ModContent.ItemType(); + + fadeAwayMax = 240; + } + } + + //the one that gets converted into + public class DungeonSoulFreed : DungeonSoulBase + { + public override void SafeSetDefaults() + { + frameSpeed = 4; + NPC.catchItem = (short)ModContent.ItemType(); + + NPC.timeLeft = 3600; + fadeAwayMax = 3600; + } + + public override bool PreAI() + { + //only if awakened + if (NPC.ai[2] != 0) + { + AI_Local_Timer = NPC.ai[2]; + NPC.ai[2] = 0; + } + NPC.noTileCollide = false; + NPC.velocity *= 0.95f; + + --NPC.timeLeft; + if (NPC.timeLeft < 0) + { + KillInstantly(NPC); + } + return false; + } + } } diff --git a/NPCs/DungeonBird/Harvester.cs b/NPCs/DungeonBird/Harvester.cs index bf67b6f1..7efbd7a1 100644 --- a/NPCs/DungeonBird/Harvester.cs +++ b/NPCs/DungeonBird/Harvester.cs @@ -1,350 +1,350 @@ +using AssortedCrazyThings.Base; +using AssortedCrazyThings.BossBars; using AssortedCrazyThings.Items; using AssortedCrazyThings.Items.Accessories.Useful; +using AssortedCrazyThings.Items.Consumables; +using AssortedCrazyThings.Items.Pets; +using AssortedCrazyThings.Items.Placeable; using AssortedCrazyThings.Items.VanityArmor; +using AssortedCrazyThings.NPCs.DropConditions; +using AssortedCrazyThings.NPCs.DropRules; +using AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using System; +using System.Collections.Generic; +using System.IO; using Terraria; -using Terraria.ID; -using Terraria.ModLoader; using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; -using AssortedCrazyThings.Items.Placeable; -using AssortedCrazyThings.NPCs.DropRules; -using AssortedCrazyThings.Items.Consumables; -using AssortedCrazyThings.Items.Pets; -using AssortedCrazyThings.Base; -using ReLogic.Content; -using Terraria.DataStructures; -using System.IO; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ModLoader.IO; -using AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird; -using Terraria.GameContent; -using System.Collections.Generic; -using AssortedCrazyThings.BossBars; -using AssortedCrazyThings.NPCs.DropConditions; namespace AssortedCrazyThings.NPCs.DungeonBird { - [AutoloadBossHead] - [Content(ContentType.Bosses)] - public class Harvester : AssNPC - { - public class AIStats - { - public float MaxHP { get; init; } - - public int FireballInterval { get; init; } = 50; - - public int FireballDuration { get; init; } = 300; - - public float FireballSpeed { get; init; } = 18; - - public bool AlwaysShootFireballs { get; init; } - - public int SwoopWaitTime { get; init; } = 80; - - public AIStats() - { - - } - } - - public static readonly string name = "Soul Harvester"; - public static readonly string deathMessage = "The Dungeon Souls have been freed!"; //on death - public const int SpawnedSoulCount = 15; - public static Color deathColor = new Color(35, 200, 254); - public const int FrameCountHorizontal = 4; - public const int FrameCountVertical = 5; - public const int FrameWidth = 314; //Old sprite 470 - public const int FrameHeight = 196; //Old sprite 254 - - public readonly static int talonDamage = 24; - public readonly static int wid = 96; - public readonly static int hei = 96; - - //Offsets from the center - public float talonOffsetLeftX = 0; - public float talonOffsetRightX = 0; - public float talonOffsetY = 0; - - public static int talonDirectionalOffset = 10; - - public Color overlayColor = Color.White; - - public static Asset SheetAsset { get; private set; } - public static Asset WingsAsset { get; private set; } - public static Asset MeleeIndicatorAsset { get; private set; } - - public static Dictionary reviveToAIStats { get; private set; } - - public AIStats GetAIStats() - { - if (reviveToAIStats.TryGetValue(RevivesDone, out AIStats stats)) - { - return stats; - } - - return reviveToAIStats[0]; - } - - public override void Load() - { - if (!Main.dedServ) - { - SheetAsset = ModContent.Request(Texture + "_Sheet"); - WingsAsset = ModContent.Request(Texture + "_Wings"); - - const short warriorEmblem = ItemID.WarriorEmblem; - Main.instance.LoadItem(warriorEmblem); - MeleeIndicatorAsset = TextureAssets.Item[warriorEmblem]; - } - - reviveToAIStats = new Dictionary() - { - [0] = new AIStats - { - MaxHP = 1f, - }, - [1] = new AIStats - { - MaxHP = 0.6f, - FireballDuration = 600, - FireballSpeed = 15, - FireballInterval = 35, - }, - [2] = new AIStats - { - MaxHP = 0.3f, - FireballDuration = 0, - FireballInterval = 60, - SwoopWaitTime = 34, - AlwaysShootFireballs = true, - }, - }; - } - - public override void Unload() - { - SheetAsset = null; - WingsAsset = null; - MeleeIndicatorAsset = null; - - reviveToAIStats = null; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault(name); //defined above since its used in CaughtDungeonSoul - Main.npcFrameCount[NPC.type] = 1; //Dummy texture and frame count, real sheet is two-dimensional - - NPCID.Sets.BossBestiaryPriority.Add(NPC.type); - NPCID.Sets.SpawnFromLastEmptySlot[NPC.type] = true; - NPCID.Sets.MPAllowedEnemies[NPC.type] = true; //Allows NPC.SpawnOnPlayer to work - - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - CustomTexturePath = "AssortedCrazyThings/NPCs/DungeonBird/Harvester_Bestiary", - Position = new Vector2(-9, 18), //Position on the icon - PortraitPositionXOverride = 0, //Position on the portrait when clicked on - PortraitPositionYOverride = 20, - SpriteDirection = -1, - PortraitScale = 1.4f, - Frame = 0, - }; - NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; - - NPCID.Sets.DebuffImmunitySets[NPC.type] = new NPCDebuffImmunityData() - { - SpecificallyImmuneTo = new int[] - { - BuffID.Confused, - BuffID.Poisoned, - BuffID.Venom, - BuffID.OnFire, - BuffID.CursedInferno, - } - }; - } - - public override void SetDefaults() - { - //npc.SetDefaults(NPCID.QueenBee); - NPC.boss = true; - NPC.npcSlots = 10f; //takes 10 npc slots, so no other npcs can spawn during the fight - //actual body hitbox - NPC.width = wid; - NPC.height = hei; - NPC.damage = talonDamage; //just a dummy value, it deals no contact damage. Used for projectile spawns - NPC.defense = 15; - NPC.lifeMax = 1750; - NPC.scale = 1f; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = Item.buyPrice(0, 10); - NPC.knockBackResist = 0f; - NPC.aiStyle = -1; //91; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.lavaImmune = true; - NPC.alpha = 255; - NPC.SpawnWithHigherTime(30); - - NPC.BossBar = ModContent.GetInstance(); - - DrawOffsetY = 36; //By default, hitbox aligns with bottom center of the frame. This pushes it up - Music = MusicID.Boss1; - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - float bossAdjustment = 1f; - if (Main.GameModeInfo.IsMasterMode) - { - bossAdjustment = 0.85f; - } - NPC.lifeMax = (int)(NPC.lifeMax * bossLifeScale * bossAdjustment); - NPC.damage = (int)(NPC.damage * 1.1f); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.WriteVarInt(AI_Counter); - writer.Write(activeTalonIndex); - writer.Write(RevivesDone); - - BitsByte flags = new BitsByte(); - flags[0] = allowAnimationSpeedAdjustment; - writer.Write(flags); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - AI_Counter = reader.ReadVarInt(); - activeTalonIndex = reader.ReadByte(); - RevivesDone = reader.ReadByte(); - - BitsByte flags = reader.ReadByte(); - allowAnimationSpeedAdjustment = flags[0]; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - //Body won't deal contact damage to players - return false; - } - - public override bool? CanHitNPC(NPC target) - { - //Body won't deal contact damage to townies/critters - return false; - } - - public override bool? CanBeHitByItem(Player player, Item item) - { - if (IsReviving) - { - return false; - } - - return base.CanBeHitByItem(player, item); - } - - public override bool? CanBeHitByProjectile(Projectile projectile) - { - if (IsReviving) - { - return false; - } - - return base.CanBeHitByProjectile(projectile); - } - - public override void ModifyHitByItem(Player player, Item item, ref int damage, ref float knockback, ref bool crit) - { - if (VulnerableToMelee) - { - //Take three times the damage from melee swings - damage *= 3; - } - } - - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (VulnerableToMelee && projectile.ownerHitCheck && projectile.CountsAsClass(DamageClass.Melee)) - { - //Take two times the damage from melee projectiles that require direct line of sight (things like arkhalis, spears, etc) - damage *= 2; - } - } - - public override void FindFrame(int frameHeight) - { - NPC.spriteDirection = -NPC.direction; - - NPC.frame.Width = FrameWidth; - NPC.frame.Height = FrameHeight; - NPC.frame.X = AI_Animation * FrameWidth; - int lastFrame = GetLastFrame(AI_Animation); - - if (AI_Intro < 255 && !NPC.IsABestiaryIconDummy) - { - //Fixed transform frame - NPC.frame.Y = FrameHeight * lastFrame; - NPC.frameCounter = 8; - return; - } - - if (AI_Animation != Animation_Swoop) - { - NPC.LoopAnimation(FrameHeight, 6, endFrame: lastFrame); - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - drawColor = NPC.GetAlpha(drawColor); - - //Vanilla draw code - float someNumModdedNPCsArentUsing = 0f; - float drawOffsetY = Main.NPCAddHeight(NPC); - Asset asset = SheetAsset; - Texture2D texture = asset.Value; - - Vector2 halfSize = new Vector2(asset.Width() / FrameCountHorizontal / 2, asset.Height() / FrameCountVertical / 2); - - SpriteEffects effects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 halfSizeOff = halfSize * NPC.scale; - Vector2 textureOff = new Vector2(asset.Width() * NPC.scale / FrameCountHorizontal / 2f, asset.Height() * NPC.scale / (float)FrameCountVertical); - Vector2 drawPosition = new Vector2(NPC.Center.X, NPC.Bottom.Y + drawOffsetY + someNumModdedNPCsArentUsing + NPC.gfxOffY + 4f); - Vector2 finalDrawPos = drawPosition + halfSizeOff - textureOff - screenPos; - spriteBatch.Draw(texture, finalDrawPos, NPC.frame, drawColor, NPC.rotation, halfSize, NPC.scale, effects, 0f); - - asset = WingsAsset; - texture = asset.Value; - Color glowmaskColor = NPC.GetAlpha(Color.White); - spriteBatch.Draw(texture, finalDrawPos, NPC.frame, glowmaskColor, NPC.rotation, halfSize, NPC.scale, effects, 0f); - - if (fadingAuraTimer > 0 && fadingAuraTimerMax > 0) - { - asset = SheetAsset; - texture = asset.Value; - float scale = fadingAuraTimer / (float)fadingAuraTimerMax; - float scaleInverse = 1f - scale; - Color auraColor = drawColor * scale * fadingAuraAlphaIntensity; - Color auraWingColor = glowmaskColor * scale * fadingAuraAlphaIntensity; - float auraScale = NPC.scale + scaleInverse * fadingAuraScaleIntensity; - - spriteBatch.Draw(texture, finalDrawPos, NPC.frame, auraColor, NPC.rotation, halfSize, auraScale, effects, 0f); - - asset = WingsAsset; - texture = asset.Value; - spriteBatch.Draw(texture, finalDrawPos, NPC.frame, auraWingColor, NPC.rotation, halfSize, auraScale, effects, 0f); - } - - //TODO figure out a better way to display it - /* + [AutoloadBossHead] + [Content(ContentType.Bosses)] + public class Harvester : AssNPC + { + public class AIStats + { + public float MaxHP { get; init; } + + public int FireballInterval { get; init; } = 50; + + public int FireballDuration { get; init; } = 300; + + public float FireballSpeed { get; init; } = 18; + + public bool AlwaysShootFireballs { get; init; } + + public int SwoopWaitTime { get; init; } = 80; + + public AIStats() + { + + } + } + + public static readonly string name = "Soul Harvester"; + public static readonly string deathMessage = "The Dungeon Souls have been freed!"; //on death + public const int SpawnedSoulCount = 15; + public static Color deathColor = new Color(35, 200, 254); + public const int FrameCountHorizontal = 4; + public const int FrameCountVertical = 5; + public const int FrameWidth = 314; //Old sprite 470 + public const int FrameHeight = 196; //Old sprite 254 + + public readonly static int talonDamage = 24; + public readonly static int wid = 96; + public readonly static int hei = 96; + + //Offsets from the center + public float talonOffsetLeftX = 0; + public float talonOffsetRightX = 0; + public float talonOffsetY = 0; + + public static int talonDirectionalOffset = 10; + + public Color overlayColor = Color.White; + + public static Asset SheetAsset { get; private set; } + public static Asset WingsAsset { get; private set; } + public static Asset MeleeIndicatorAsset { get; private set; } + + public static Dictionary reviveToAIStats { get; private set; } + + public AIStats GetAIStats() + { + if (reviveToAIStats.TryGetValue(RevivesDone, out AIStats stats)) + { + return stats; + } + + return reviveToAIStats[0]; + } + + public override void Load() + { + if (!Main.dedServ) + { + SheetAsset = ModContent.Request(Texture + "_Sheet"); + WingsAsset = ModContent.Request(Texture + "_Wings"); + + const short warriorEmblem = ItemID.WarriorEmblem; + Main.instance.LoadItem(warriorEmblem); + MeleeIndicatorAsset = TextureAssets.Item[warriorEmblem]; + } + + reviveToAIStats = new Dictionary() + { + [0] = new AIStats + { + MaxHP = 1f, + }, + [1] = new AIStats + { + MaxHP = 0.6f, + FireballDuration = 600, + FireballSpeed = 15, + FireballInterval = 35, + }, + [2] = new AIStats + { + MaxHP = 0.3f, + FireballDuration = 0, + FireballInterval = 60, + SwoopWaitTime = 34, + AlwaysShootFireballs = true, + }, + }; + } + + public override void Unload() + { + SheetAsset = null; + WingsAsset = null; + MeleeIndicatorAsset = null; + + reviveToAIStats = null; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault(name); //defined above since its used in CaughtDungeonSoul + Main.npcFrameCount[NPC.type] = 1; //Dummy texture and frame count, real sheet is two-dimensional + + NPCID.Sets.BossBestiaryPriority.Add(NPC.type); + NPCID.Sets.SpawnFromLastEmptySlot[NPC.type] = true; + NPCID.Sets.MPAllowedEnemies[NPC.type] = true; //Allows NPC.SpawnOnPlayer to work + + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + CustomTexturePath = "AssortedCrazyThings/NPCs/DungeonBird/Harvester_Bestiary", + Position = new Vector2(-9, 18), //Position on the icon + PortraitPositionXOverride = 0, //Position on the portrait when clicked on + PortraitPositionYOverride = 20, + SpriteDirection = -1, + PortraitScale = 1.4f, + Frame = 0, + }; + NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; + + NPCID.Sets.DebuffImmunitySets[NPC.type] = new NPCDebuffImmunityData() + { + SpecificallyImmuneTo = new int[] + { + BuffID.Confused, + BuffID.Poisoned, + BuffID.Venom, + BuffID.OnFire, + BuffID.CursedInferno, + } + }; + } + + public override void SetDefaults() + { + //npc.SetDefaults(NPCID.QueenBee); + NPC.boss = true; + NPC.npcSlots = 10f; //takes 10 npc slots, so no other npcs can spawn during the fight + //actual body hitbox + NPC.width = wid; + NPC.height = hei; + NPC.damage = talonDamage; //just a dummy value, it deals no contact damage. Used for projectile spawns + NPC.defense = 15; + NPC.lifeMax = 1750; + NPC.scale = 1f; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = Item.buyPrice(0, 10); + NPC.knockBackResist = 0f; + NPC.aiStyle = -1; //91; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.lavaImmune = true; + NPC.alpha = 255; + NPC.SpawnWithHigherTime(30); + + NPC.BossBar = ModContent.GetInstance(); + + DrawOffsetY = 36; //By default, hitbox aligns with bottom center of the frame. This pushes it up + Music = MusicID.Boss1; + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + float bossAdjustment = 1f; + if (Main.GameModeInfo.IsMasterMode) + { + bossAdjustment = 0.85f; + } + NPC.lifeMax = (int)(NPC.lifeMax * bossLifeScale * bossAdjustment); + NPC.damage = (int)(NPC.damage * 1.1f); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVarInt(AI_Counter); + writer.Write(activeTalonIndex); + writer.Write(RevivesDone); + + BitsByte flags = new BitsByte(); + flags[0] = allowAnimationSpeedAdjustment; + writer.Write(flags); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + AI_Counter = reader.ReadVarInt(); + activeTalonIndex = reader.ReadByte(); + RevivesDone = reader.ReadByte(); + + BitsByte flags = reader.ReadByte(); + allowAnimationSpeedAdjustment = flags[0]; + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + //Body won't deal contact damage to players + return false; + } + + public override bool? CanHitNPC(NPC target) + { + //Body won't deal contact damage to townies/critters + return false; + } + + public override bool? CanBeHitByItem(Player player, Item item) + { + if (IsReviving) + { + return false; + } + + return base.CanBeHitByItem(player, item); + } + + public override bool? CanBeHitByProjectile(Projectile projectile) + { + if (IsReviving) + { + return false; + } + + return base.CanBeHitByProjectile(projectile); + } + + public override void ModifyHitByItem(Player player, Item item, ref int damage, ref float knockback, ref bool crit) + { + if (VulnerableToMelee) + { + //Take three times the damage from melee swings + damage *= 3; + } + } + + public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (VulnerableToMelee && projectile.ownerHitCheck && projectile.CountsAsClass(DamageClass.Melee)) + { + //Take two times the damage from melee projectiles that require direct line of sight (things like arkhalis, spears, etc) + damage *= 2; + } + } + + public override void FindFrame(int frameHeight) + { + NPC.spriteDirection = -NPC.direction; + + NPC.frame.Width = FrameWidth; + NPC.frame.Height = FrameHeight; + NPC.frame.X = AI_Animation * FrameWidth; + int lastFrame = GetLastFrame(AI_Animation); + + if (AI_Intro < 255 && !NPC.IsABestiaryIconDummy) + { + //Fixed transform frame + NPC.frame.Y = FrameHeight * lastFrame; + NPC.frameCounter = 8; + return; + } + + if (AI_Animation != Animation_Swoop) + { + NPC.LoopAnimation(FrameHeight, 6, endFrame: lastFrame); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + drawColor = NPC.GetAlpha(drawColor); + + //Vanilla draw code + float someNumModdedNPCsArentUsing = 0f; + float drawOffsetY = Main.NPCAddHeight(NPC); + Asset asset = SheetAsset; + Texture2D texture = asset.Value; + + Vector2 halfSize = new Vector2(asset.Width() / FrameCountHorizontal / 2, asset.Height() / FrameCountVertical / 2); + + SpriteEffects effects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 halfSizeOff = halfSize * NPC.scale; + Vector2 textureOff = new Vector2(asset.Width() * NPC.scale / FrameCountHorizontal / 2f, asset.Height() * NPC.scale / (float)FrameCountVertical); + Vector2 drawPosition = new Vector2(NPC.Center.X, NPC.Bottom.Y + drawOffsetY + someNumModdedNPCsArentUsing + NPC.gfxOffY + 4f); + Vector2 finalDrawPos = drawPosition + halfSizeOff - textureOff - screenPos; + spriteBatch.Draw(texture, finalDrawPos, NPC.frame, drawColor, NPC.rotation, halfSize, NPC.scale, effects, 0f); + + asset = WingsAsset; + texture = asset.Value; + Color glowmaskColor = NPC.GetAlpha(Color.White); + spriteBatch.Draw(texture, finalDrawPos, NPC.frame, glowmaskColor, NPC.rotation, halfSize, NPC.scale, effects, 0f); + + if (fadingAuraTimer > 0 && fadingAuraTimerMax > 0) + { + asset = SheetAsset; + texture = asset.Value; + float scale = fadingAuraTimer / (float)fadingAuraTimerMax; + float scaleInverse = 1f - scale; + Color auraColor = drawColor * scale * fadingAuraAlphaIntensity; + Color auraWingColor = glowmaskColor * scale * fadingAuraAlphaIntensity; + float auraScale = NPC.scale + scaleInverse * fadingAuraScaleIntensity; + + spriteBatch.Draw(texture, finalDrawPos, NPC.frame, auraColor, NPC.rotation, halfSize, auraScale, effects, 0f); + + asset = WingsAsset; + texture = asset.Value; + spriteBatch.Draw(texture, finalDrawPos, NPC.frame, auraWingColor, NPC.rotation, halfSize, auraScale, effects, 0f); + } + + //TODO figure out a better way to display it + /* if (!displayedMeleeIndicatorOnce && displayMeleeIndicator && StateToDisplayMeleeIndicator) { asset = MeleeIndicatorAsset; @@ -369,1214 +369,1214 @@ public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color d } */ - return false; - } - - public override Color? GetAlpha(Color drawColor) - { - if (NPC.IsABestiaryIconDummy) - { - //This is required because we have NPC.alpha = 255 in SetDefaults, in the bestiary it would look transparent - return NPC.GetBestiaryEntryColor(); - } - return Color.Lerp(drawColor, Color.White, 0.4f).MultiplyRGBA(overlayColor) * NPC.Opacity; - } - - /// - /// Spawns souls multiplied by the number of people present during the fight - /// - private void SpawnSouls(int npcTypeNew) - { - int count = Array.FindAll(NPC.playerInteraction, interacted => interacted).Length; - - for (int i = 0; i < count; i++) - { - Vector2 randVector = Vector2.One; - float randFactor; - int index; - - for (int j = 0; j < SpawnedSoulCount; j++) //spawn souls when dies - { - index = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)NPC.Center.X, (int)NPC.Center.Y, npcTypeNew); - if (index < Main.maxNPCs && Main.npc[index] is NPC soul) - { - soul.SetDefaults(npcTypeNew); - randVector = randVector.RotatedByRandom(MathHelper.ToRadians(359f)); - randFactor = Main.rand.NextFloat(2f, 8f); - //Main.npc[index].timeLeft = 3600; - soul.velocity = randVector * randFactor; - soul.ai[2] = Main.rand.Next(1, DungeonSoulBase.offsetYPeriod); //doesnt get synced properly to clients idk - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.SyncNPC, number: index); - } - } - } - } - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheDungeon, - new FlavorTextBestiaryInfoElement("After having absorbed the essence of fallen dungeon denizens, this skeletal bird rapidly grew into a ferocious hunter that sought to eat the hand that once fed it.") - }); - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - int idolOfDecay = ModContent.ItemType(); - LeadingConditionRule noHasItemWithBankRule = new LeadingConditionRule(new NoHasItemWithBankCondition(idolOfDecay)); - noHasItemWithBankRule.OnSuccess(ItemDropRule.Common(idolOfDecay)); - npcLoot.Add(noHasItemWithBankRule); - - LeadingConditionRule neverDropsRule = new LeadingConditionRule(new Conditions.NeverTrue()); - neverDropsRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), 1, SpawnedSoulCount, SpawnedSoulCount)); - npcLoot.Add(neverDropsRule); - - npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); - - //Relic and trophy are NOT spawned in the bag - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); - npcLoot.Add(ItemDropRule.MasterModeCommonDrop(ModContent.ItemType())); - - npcLoot.Add(ItemDropRule.MasterModeDropOnAllPlayers(ModContent.ItemType(), 4)); - - //Drop one of three sigils, one random one per player - var sigils = new int[] { ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType() }; - var sigilRule = new OneFromOptionsPerPlayerOnPlayerRule(options: sigils); - npcLoot.Add(sigilRule); - - //All our drops here are based on "not expert", meaning we use .OnSuccess() to add them into the rule, which then gets added - LeadingConditionRule notExpertRule = new LeadingConditionRule(new Conditions.NotExpert()); - - notExpertRule.OnSuccess(ItemDropRule.Common(ItemID.Bone, minimumDropped: 40, maximumDropped: 60)); - notExpertRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType())); - - notExpertRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 7)); - - //Finally add the leading rule - npcLoot.Add(notExpertRule); - } - - public override void OnKill() - { - NPC.SetEventFlagCleared(ref AssWorld.downedHarvester, -1); - - AssWorld.Message(deathMessage, deathColor); - - int npcTypeOld = ModContent.NPCType(); - int npcTypeNew = ModContent.NPCType(); //version that doesn't get eaten by harvesters - - int itemTypeOld = ModContent.ItemType(); - int itemTypeNew = ModContent.ItemType(); //version that is used in crafting - - //"convert" NPC souls - ConvertSouls(npcTypeOld, npcTypeNew, itemTypeOld, itemTypeNew); - - SpawnSouls(npcTypeNew); - } - - public override bool CheckDead() - { - if (RevivesDone < Revive_Count) - { - //Main.NewText(Main.GameUpdateCount + " checkdead false " + (revivesDone < Revive_Count)); - NPC.life = NPC.lifeMax; - NPC.defense = Revive_Defense; - - if (AI_State != State_Weakened) - { - NPC.dontTakeDamage = true; //Set for one tick to prevent damage in same tick from applying - RevivesDone++; - //Main.NewText("revive #" + revivesDone); - - if (Main.netMode != NetmodeID.Server) - { - for (int i = 0; i < 6; i++) - { - Gore.NewGore(Main.rand.NextVector2FromRectangle(NPC.getRect()), NPC.velocity, Mod.Find("SoulHarvesterGore_05").Type, 1f); - } - } - - SetState(State_Weakened); - SetFrame(0); - - for (int i = 0; i < NPC.maxBuffs; i++) - { - //Clear potential DoT debuffs - NPC.DelBuff(i); - } - } - - return false; - } - - //Main.NewText("checkdead skip " + (revivesDone < Revive_Count)); - return base.CheckDead(); - } - - private void ConvertSouls(int npcTypeOld, int npcTypeNew, int itemTypeOld, int itemTypeNew) - { - for (short j = 0; j < Main.maxNPCs; j++) - { - NPC other = Main.npc[j]; - if (other.active && other.type == npcTypeOld) - { - other.active = false; - int index = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)other.position.X, (int)other.position.Y, npcTypeNew); - NPC npcnew = Main.npc[index]; - npcnew.ai[2] = Main.rand.Next(1, DungeonSoulBase.offsetYPeriod); //doesnt get synced properly to clients idk - npcnew.timeLeft = 3600; - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.SyncNPC, number: index); - } - - //poof visual works only in singleplayer - for (int i = 0; i < 15; i++) - { - Dust dust = Dust.NewDustPerfect(npcnew.Center, 59, new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 1.5f)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); - dust.noLight = true; - dust.noGravity = true; - dust.fadeIn = Main.rand.NextFloat(0.1f, 0.6f); - } - } - } - - //"convert" Item souls that got dropped for some reason - int tempStackCount; - for (int j = 0; j < Main.maxItems; j++) - { - Item item = Main.item[j]; - if (item.active && item.type == itemTypeOld) - { - tempStackCount = item.stack; - item.SetDefaults(itemTypeNew); - item.stack = tempStackCount; - - //poof visual - for (int i = 0; i < 15; i++) - { - Dust dust = Dust.NewDustPerfect(item.Center, 59, new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 1.5f)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); - dust.noLight = true; - dust.noGravity = true; - dust.fadeIn = Main.rand.NextFloat(0.1f, 0.6f); - } - } - } - - //"convert" Item souls in inventory - for (int j = 0; j < Main.maxPlayers; j++) - { - Player player = Main.player[j]; - if (player.active/* && !Main.player[j].dead*/) - { - AssPlayer mPlayer = player.GetModPlayer(); - - if (Main.netMode == NetmodeID.Server) - { - SendConvertInertSoulsInventory(j); - } - else //singleplayer - { - mPlayer.ConvertInertSoulsInventory(); - } - } - } - } - - private void SendConvertInertSoulsInventory(int toWho) - { - if (Main.netMode == NetmodeID.Server) - { - ModPacket packet = Mod.GetPacket(); - packet.Write((byte)AssMessageType.ConvertInertSoulsInventory); - packet.Send(toClient: toWho); - } - } - - /// - /// Sets the y on the spritesheet. use AI_Animation to set x - /// - /// The y - public void SetFrame(int frameY) - { - NPC.frame.Y = frameY * FrameHeight; - NPC.frameCounter = 0; - } - - /// - /// (Counter/Timer only resets on hard state change) - /// - /// State to change to. By default, no change - /// Sub-State to change to. - public void SetState(float state = State_KeepCurrent, float subState = 0f) - { - if (state != State_KeepCurrent) - { - AI_State = state; - AI_Counter = 0; - AI_Timer = 0; - } - - AI_SubState = subState; - NPC.netUpdate = true; - } - - public static int GetLastFrame(int animation) - { - return animation switch - { - Animation_Swoop => 2, - _ => FrameCountVertical - 1 - }; - } - - public const float State_KeepCurrent = -1f; - public const float State_Fireball = 0f; //Basic flying, homing attack - public const float State_SpawnedByBaby = 1f; //Special state set on spawn - public const float State_Swoop = 2f; - public const float State_Bombing = 3f; - public const float State_Weakened = 4f; //Can enter from any state, special conditions - - //Substates: - public const int Swoop_SeekStart = 0;//Second half the "U" - public const int Swoop_Swooping = 1; //First half the "U" - - public const int Swooping_Distance = 500; - public const int Swooping_Height = 280; - public const int Swoop_Count = 3; - public const int Revive_Count = 2; - public const float Revive_MinHP = 0.1f; - public const int Revive_Duration = 180; - public const int Revive_Defense = 999; - - public const int Bombing_Distance = Swooping_Distance + 300; - public const int Bombing_Height = 200; - - public const int Animation_NoHorizontal = 0; - public const int Animation_Flight = 1; - public const int Animation_Swoop = 2; - public const int Animation_Bombing = 3; - - public ref float AI_State => ref NPC.ai[0]; - - public ref float AI_SubState => ref NPC.ai[1]; - - public ref float AI_Timer => ref NPC.ai[2]; - - public int AI_Animation - { - get => (int)NPC.ai[3]; - set => NPC.ai[3] = value; - } - - public ref float AI_Intro => ref NPC.localAI[0]; - - public bool Initialized - { - get => NPC.localAI[1] == 1f; - set => NPC.localAI[1] = value ? 1f : 0f; - } - - public ref float Animation_Timer => ref NPC.localAI[2]; - - //Synced - public int AI_Counter - { - get => (int)NPC.localAI[3]; - set => NPC.localAI[3] = value; - } - - //Synced - private byte activeTalonIndex = Main.maxNPCs; - - //Synced - //0: no revives yet - //1: first revive initiated/ongoing - //... - //Revive_Count: final possible revive initiated/ongoing - public byte RevivesDone { get; private set; } - - public ref float ReviveProgress => ref AI_Timer; - - public bool IsReviving => AI_State == State_Weakened; - - public bool StateToDisplayMeleeIndicator => AI_State == State_Swoop && AI_Timer < 0 || VulnerableToMelee; - - public bool VulnerableToMelee => AI_State == State_Swoop && AI_SubState == Swoop_Swooping; - - //Not synced, serverside - public int FireballTimer { get; private set; } - - //Not synced, should be clientside - private bool displayMeleeIndicator = false; - private bool displayedMeleeIndicatorOnce = false; - - private bool allowAnimationSpeedAdjustment = true; - - private float fadingAuraAlphaIntensity = 0f; - private float fadingAuraScaleIntensity = 0f; - private int fadingAuraTimerMax = 0; - private int fadingAuraTimer = 0; - - private void SetFadingAura(int alphaTimer, float alphaIntensity = 0.8f, float scaleIntensity = 0.5f) - { - fadingAuraTimerMax = fadingAuraTimer = alphaTimer; - fadingAuraAlphaIntensity = alphaIntensity; - fadingAuraScaleIntensity = scaleIntensity; - } - - private void HandleFadingAura() - { - if (fadingAuraTimer > 0) - { - fadingAuraTimer--; - } - else - { - fadingAuraTimerMax = 0; - fadingAuraAlphaIntensity = 0f; - fadingAuraScaleIntensity = 0f; - } - } - - public override void AI() - { - Lighting.AddLight(NPC.Center, 0.3f, 0.3f, 0.7f); - - if (NPC.target < 0 || NPC.target >= 255 || !Main.player[NPC.target].active || Main.player[NPC.target].dead) - { - NPC.TargetClosest(); - } - - Player target = Main.player[NPC.target]; - - if (target.DistanceSQ(NPC.Center) > 2000 * 2000) - { - NPC.TargetClosest(); - } - - HandleMeleeIndicator(target); - - HandleAnimation(); - - HandleReviveVisuals(); - - HandleFadingAura(); - - HandleReviveTrigger(); - - List talons = GetTalons(); - - MonitorExtendedTalons(talons); - - NPC.chaseable = !IsReviving; - NPC.dontTakeDamage = IsReviving; - NPC.scale = 1f; - - if (!IsReviving && NPC.defense == Revive_Defense) - { - //Restore defense after revived - NPC.defense = NPC.defDefense; - } - - if (target.dead && !IsReviving) - { - AI_Animation = Animation_Flight; - SetState(State_Fireball); - NPC.velocity.Y += 0.06f; - NPC.velocity.X *= 0.97f; - if (NPC.timeLeft > 10) - { - NPC.timeLeft = 10; - } - return; - } - - NPC.rotation = NPC.velocity.X * 0.02f; - - int diff = 38; //Distance offset between two talons - int offX = -10; //Offset from the center for the left talon - talonOffsetLeftX = offX * NPC.direction + NPC.velocity.X/* * TalonDirectionalOffset*/; - talonOffsetRightX = (diff + offX) * NPC.direction + NPC.velocity.X/* * TalonDirectionalOffset*/; - talonOffsetY = hei / 2 + 4 + NPC.velocity.Y; - //Due to update order (boss updates after talons), add velocity to the offsets aswell - - if (!Initialized) - { - SoundEngine.PlaySound(SoundID.Roar, (int)NPC.Center.X, (int)NPC.Center.Y, 0); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int y = (int)(NPC.Center.Y + talonOffsetY); - - (int x, int type)[] talonTypes = new (int, int)[] - { - ((int)(NPC.Center.X + talonOffsetLeftX), AssortedCrazyThings.harvesterTalonLeft), - ((int)(NPC.Center.X + talonOffsetRightX), AssortedCrazyThings.harvesterTalonRight) - }; - - var source = NPC.GetSpawnSourceForNPCFromNPCAI(); - foreach (var (x, type) in talonTypes) - { - int index = NPC.NewNPC(source, x, y, type); - if (index < Main.maxNPCs && Main.npc[index] is NPC talonNPC && talonNPC.ModNPC is HarvesterTalon talon) - { - talon.ParentWhoAmI = NPC.whoAmI; - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.SyncNPC, number: index); - } - } - } - } - - AI_Timer = 0; - NPC.TargetClosest(); - - if (AI_State != State_SpawnedByBaby) - { - SetState(State_Fireball); - } - Initialized = true; - } - - //Spawned through summon item/cheated in - if (AI_State != State_SpawnedByBaby && AI_Intro < 255) - { - AI_Intro += 5; - NPC.alpha -= 5; - if (AI_Intro >= 255) - { - AI_Intro = 255; - NPC.alpha = 0; - SetFadingAura(20, 0.8f, 0.5f); - NPC.netUpdate = true; - } - return; - } - else - { - AI_Intro = 255; - NPC.alpha = 0; - } - - //Spawned by baby, which shows the transformation before spawning - if (AI_State == State_SpawnedByBaby) - { - AI_Intro = 255; - NPC.alpha = 0; - SetFadingAura(20, 0.8f, 0.5f); - SetState(State_Fireball); - NPC.netUpdate = true; - } - - HandleAI(target, talons); - } - - private void MonitorExtendedTalons(List talons) - { - //Monitor talons that extend too far - for (int i = 0; i < talons.Count; i++) - { - HarvesterTalon talon = talons[i]; - if (talon.AI_State == HarvesterTalon.State_Punching) - { - if (talon.NPC.Top.Y > NPC.Center.Y + Bombing_Height) - { - //Main.NewText("manually retract talon " + i); - talon.AI_State = HarvesterTalon.State_Seek_Retract; - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.SyncNPC, number: i); - } - } - } - } - } - - private List GetTalons() - { - List talons = new List(); - - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - - //If talon and belongs to self - if (npc.active && npc.ModNPC is HarvesterTalon talon && talon.ParentWhoAmI == NPC.whoAmI) - { - talons.Add(talon); - } - } - - return talons; - } - - private void HandleAI(Player target, List talons) - { - float lifeRatio = NPC.life / (float)NPC.lifeMax; - var aiStats = GetAIStats(); - - if (AI_State == State_Fireball || aiStats.AlwaysShootFireballs) - { - //Generate souls in a half circle above the boss and have them home to whatever the nearest player to them is - FireballTimer++; - if (FireballTimer % aiStats.FireballInterval == 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 random = (-Vector2.UnitY).RotatedByRandom(MathHelper.PiOver2) * 160; - Vector2 pos = NPC.Center + random; - Vector2 toPlayer = target.DirectionFrom(pos); - int damage = (int)(NPC.damage * 0.70f); - damage = NPC.GetAttackDamage_ForProjectiles(damage, damage * 0.33f); //To compensate expert mode NPC damage + projectile damage increase - Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), pos, toPlayer * 1, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, aiStats.FireballSpeed); - } - } - } - - if (AI_State == State_Fireball) - { - if (AI_Animation != Animation_Flight && AI_Animation != Animation_NoHorizontal) - { - AI_Animation = Animation_Flight; - } - - AI_Timer++; - - float acceleration = 0.05f; - - Vector2 origin = new Vector2(NPC.Center.X + 6 * NPC.direction, NPC.position.Y + NPC.height * 0.8f); - float diffX = target.Center.X - NPC.Center.X; - float diffY = target.Center.Y - 200f - NPC.Center.Y; //300f - float length = (float)Math.Sqrt(diffX * diffX + diffY * diffY); - - if (!Collision.CanHit(new Vector2(origin.X, origin.Y - 30f), 1, 1, target.position, target.width, target.height)) - { - acceleration = 0.1f; - diffX = target.Center.X - NPC.Center.X; - diffY = target.Center.Y - NPC.Center.Y; - - //WHEN NO DIRECT CAN HIT LINE - - if (Math.Abs(NPC.velocity.X) < 32) - { - if (NPC.velocity.X < diffX) - { - NPC.velocity.X += acceleration; - if (NPC.velocity.X < 0f && diffX > 0f) - { - NPC.velocity.X += acceleration * 2.5f; //1f all - } - } - else if (NPC.velocity.X > diffX) - { - NPC.velocity.X -= acceleration; - if (NPC.velocity.X > 0f && diffX < 0f) - { - NPC.velocity.X -= acceleration * 2.5f; - } - } - } - if (Math.Abs(NPC.velocity.Y) < 32) - { - if (NPC.velocity.Y < diffY) - { - NPC.velocity.Y += acceleration; - if (NPC.velocity.Y < 0f && diffY > 0f) - { - NPC.velocity.Y += acceleration * 2.5f; - } - } - else if (NPC.velocity.Y > diffY) - { - NPC.velocity.Y -= acceleration; - if (NPC.velocity.Y > 0f && diffY < 0f) - { - NPC.velocity.Y -= acceleration * 2.5f; - } - } - } - } - else if (length > 100f) - { - NPC.TargetClosest(); - if (Math.Abs(NPC.velocity.X) < 32) - { - if (NPC.velocity.X < diffX) - { - NPC.velocity.X += acceleration; - if (NPC.velocity.X < 0f && diffX > 0f) - { - NPC.velocity.X += acceleration * 2f; //2f all - } - } - else if (NPC.velocity.X > diffX) - { - NPC.velocity.X -= acceleration; - if (NPC.velocity.X > 0f && diffX < 0f) - { - NPC.velocity.X -= acceleration * 2f; - } - } - } - if (Math.Abs(NPC.velocity.Y) < 32) - { - if (NPC.velocity.Y < diffY) - { - NPC.velocity.Y += acceleration; - if (NPC.velocity.Y < 0f && diffY > 0f) - { - NPC.velocity.Y += acceleration * 2f; - } - } - else if (NPC.velocity.Y > diffY) - { - NPC.velocity.Y -= acceleration; - if (NPC.velocity.Y > 0f && diffY < 0f) - { - NPC.velocity.Y -= acceleration * 2f; - } - } - } - } - - float lifeRatioClamped = Utils.Remap(lifeRatio, 0, 1, 0.666f, 1); - float timeToNextState = aiStats.FireballDuration * lifeRatioClamped; - - if (Main.expertMode && RevivesDone == Revive_Count) //Final revive - { - timeToNextState = 0; - } - - if (AI_Timer > timeToNextState) - { - AI_Timer = 0; - SetState(State_Swoop); - NPC.TargetClosest(false); - } - } - else if (AI_State == State_Swoop) - { - //Main.NewText("substat: " + AI_SubState); - //Main.NewText("counter: " + AI_Counter); - //Main.NewText("timer: " + AI_Timer); - - //AI_Counter meaning: - //0: first swoop: decide direction (sign) and set 1 - //absolute value: swoop count - //sign: swoop direction - - //After passing the player during start, change to seekStart - - int count = Math.Abs(AI_Counter); - bool keepSwooping = count <= Swoop_Count; - - if (AI_SubState == Swoop_SeekStart) - { - float speed = 10; - const float minInertia = 6; - float inertia = minInertia; - float lifeRatioClamped = Utils.Remap(lifeRatio, 0, 1, 0.6f, 1); - - if (AI_Counter != 0 && AI_Animation == Animation_Swoop) - { - float swoopPostTime = aiStats.SwoopWaitTime * lifeRatioClamped; - - //This means a swoop has already taken place, and the "post-swoop" frame should be displayed for a while - AI_Timer++; - inertia += (swoopPostTime - AI_Timer) / swoopPostTime * 16; //Increase inertia during the "post-swoop" so that it follows the U shape for a bit at the bottom - - inertia = Math.Max(inertia, minInertia); - - if (AI_Timer > 8 * lifeRatioClamped) - { - SetFrame(2); //Post-swoop - } - else if (AI_Timer > swoopPostTime) - { - AI_Timer = 0; - AI_Animation = Animation_Flight; - SetFrame(4); //Regular flight, frame after the post-swoop in regards to wing position - } - } - - //Find location to start swoop on the side of the player closer to the boss - Vector2 toPlayer = target.DirectionFrom(NPC.Bottom); //Talons should hit center of player - bool leftOfPlayer = toPlayer.X > 0; - - int targetY = keepSwooping ? Swooping_Height : Bombing_Height; - - Vector2 start = new Vector2(Swooping_Distance, -targetY); - if (AI_Counter == 0) - { - //First swoop - //Initial start is "right of player" meaning initial dir should be "left towards player" - AI_Counter = -1; - if (!leftOfPlayer) - { - //Flip both if NPC is "left of player" - start.X *= -1; - AI_Counter *= -1; - } - } - else - { - //Consecutive swoops - if (AI_Counter < 0) //current dir is "left towards player" - { - //Flip - start.X *= -1; - } - //No flip required otherwise - } - - //Apply absolute vector - start += target.Center; - - Vector2 toStart = start - NPC.Center; - - if (toStart.LengthSquared() <= speed * speed) - { - if (AI_Timer >= 0) - { - //Kickstart timer - AI_Timer = -1; - } - - NPC.direction = leftOfPlayer.ToDirectionInt(); - AI_Animation = Animation_NoHorizontal; - NPC.Center = start; - if (NPC.velocity.LengthSquared() > 1) - { - NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY); - } - NPC.velocity *= 0.95f; - } - else - { - toStart = toStart.SafeNormalize(Vector2.UnitY); - toStart *= speed; - - NPC.velocity = (NPC.velocity * (inertia - 1) + toStart) / inertia; - - if (NPC.direction == 1 && NPC.velocity.X < 0 || - NPC.direction == -1 && NPC.velocity.X > 0) - { - //Swap direction if not locked into position yet but flew past it - NPC.direction *= -1; - } - } - - if (AI_Timer < 0) - { - AI_Timer--; - float swoopPostTime = aiStats.SwoopWaitTime * lifeRatioClamped; - if (AI_Timer < -swoopPostTime) - { - AI_Timer = 0; - - if (keepSwooping) - { - //This does keep whatever animation was previously happening, but changes it on swoop - SetState(subState: Swoop_Swooping); - NPC.direction = leftOfPlayer.ToDirectionInt(); - AI_Animation = Animation_Swoop; - SetFrame(0); - } - else - { - SetState(State_Bombing); - NPC.direction = leftOfPlayer.ToDirectionInt(); - AI_Animation = Animation_Bombing; - //Frames match, so don't need to call SetFrame - } - } - } - } - else if (AI_SubState == Swoop_Swooping) - { - if (AI_Timer == 0) - { - SoundEngine.PlaySound(SoundID.Roar, (int)NPC.Center.X, (int)NPC.Center.Y, 0, pitchOffset: 0.15f); - } - - int xSpeed = 12; - AI_Timer += xSpeed; //AI_Timer is memory of distance traversed - - //Keep constant speed towards direction (not player) - float xDir = NPC.direction * xSpeed; - - //Go down towards straight line smoothly, fast at first (to create half of "u" shape) - //Number from 0 (start) to 1 (end, reached swoop location) - - float xProgress = AI_Timer / Swooping_Distance; - float yProgress = EaseOutLinear(xProgress, 1f); - - //Used on VELOCITY, meaning this is a parabola position wise - float EaseOutLinear(float x, float y0 = 1f) - { - //Start at y0, finish at 0 - float m = -y0; - return m * x + y0; - } - - //float EaseOutCirc(float x) - //{ - // //Start fast, but slow down slowly 30% through - // return (float)Math.Sqrt(1 - Math.Pow((double)x - 1, 2)); - //} - - int ySpeed = 10; - float yDir = ySpeed * yProgress; - - if (xProgress >= 0.95f) - { - //About to hit player/finish swoop down - SetFrame(1); - } - - //bool passedPlayer = (NPC.Center.X > target.Center.X).ToDirectionInt() == NPC.direction; - if (xProgress >= 1f/* || passedPlayer*/) - { - AI_Timer = 0; - - //Increment count for next swoop - //Flip dir - count++; - int dir = Math.Sign(AI_Counter); - dir *= -1; - AI_Counter = dir * count; - - if (keepSwooping) - { - SetState(subState: Swoop_SeekStart); - } - else - { - SetState(State_Fireball); - - //Go into the state that picks an attack - } - } - else - { - NPC.velocity = new Vector2(xDir, yDir); - - if (xProgress >= 0.5f) - { - //Course correct on second half of dive. For players trying to easily dodge the talons by stepping left/right - Vector2 toPlayer = target.Center - NPC.Center; - toPlayer = toPlayer.SafeNormalize(Vector2.UnitX * NPC.direction) * 20; - float inertia = 10; - NPC.velocity = (NPC.velocity * (inertia - 1) + toPlayer) / inertia; - } - } - } - } - else if (AI_State == State_Bombing) - { - //This gets entered - if (AI_Timer == 0) - { - SetFadingAura(20, 1.4f, 0.5f); - SoundEngine.PlaySound(SoundID.Roar, (int)target.Center.X, (int)target.Center.Y, 0, pitchOffset: 0f); - } - - //Lock rotation, talons do not move based on rotation - NPC.rotation = 0f; - - float xSpeed = 7.5f; //9 - AI_Timer += xSpeed; //AI_Timer is memory of distance traversed - - //Keep constant speed towards direction (not player) - float xDir = NPC.direction * xSpeed; - - float xProgress = AI_Timer / Bombing_Distance; - - //Adjust Y level to keep same level to targeted player if not reached player yet - Vector2 targetCenter = target.Center; - Vector2 toTarget = targetCenter - NPC.Center; - float yDir = NPC.velocity.Y; - if (NPC.direction * toTarget.X > 0) - { - targetCenter += new Vector2(0, -Bombing_Height); - toTarget = targetCenter - NPC.Center; - int ySpeed = 20; - if (toTarget.LengthSquared() > ySpeed * ySpeed) - { - toTarget = toTarget.SafeNormalize(Vector2.UnitY) * ySpeed; - } - float inertia = 10; - yDir = (NPC.velocity.Y * (inertia - 1) + toTarget.Y) / inertia; - } - - if (toTarget.Y > Bombing_Height) - { - //player below targeted bombing line, move directly with player to catch up - //yDir *= 1; - } - else - { - //if distance smaller (i.e player jumps) only catch up with slower speed - yDir *= 0.75f; - } - - NPC.velocity = new Vector2(xDir + target.velocity.X / 2, yDir); - - if (xProgress >= 1) - { - NPC.TargetClosest(true); - SetState(State_Fireball); - } - - HandleTalonBombing(target, talons); - } - else if (AI_State == State_Weakened) - { - if (AI_Animation != Animation_Flight && AI_Animation != Animation_NoHorizontal) - { - AI_Animation = Animation_Flight; - } - - NPC.velocity *= 0.98f; - - float len = NPC.velocity.Length(); - if (len <= 0.5f) - { - NPC.velocity *= 0; - } - - int period = 15; - if (Main.netMode != NetmodeID.Server) - { - if (ReviveProgress % (3 * period) == 0) - { - SetFadingAura(20, 0.3f + 0.5f * (ReviveProgress / Revive_Duration)); - SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - overlayColor = new Color(195, 247, 255) * 0.4f; - overlayColor.A = 255; - - Vector2 dustOffset = new Vector2(0, (NPC.height + NPC.width) / 2 * 0.5f); - Vector2 center = NPC.Center; - float amount = 0.5f + 0.5f * (ReviveProgress / Revive_Duration); - for (int i = 0; i < 30 * amount; i++) - { - Vector2 dustOffset2 = dustOffset.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.1f, 1f); - Dust dust = Dust.NewDustPerfect(center + dustOffset2, 59, newColor: Color.White, Scale: 2.1f); - dust.noLight = true; - dust.noGravity = true; - dust.fadeIn = Main.rand.NextFloat(0.2f, 0.8f); - dust.velocity = Utils.SafeNormalize(dust.position - center, Vector2.Zero) * 3; - } - } - } - - ReviveProgress++; - - if (ReviveProgress >= Revive_Duration) - { - NPC.TargetClosest(); - - NPC.life = (int)(NPC.lifeMax * aiStats.MaxHP); - - SetFadingAura(20, 0.8f, 0.5f); - SoundEngine.PlaySound(SoundID.Roar, (int)NPC.Center.X, (int)NPC.Center.Y, 0); - AI_Animation = Animation_NoHorizontal; - SetState(State_Fireball); - } - } - } - - private void HandleReviveVisuals() - { - overlayColor = Color.Lerp(overlayColor, Color.White, 0.1f); - } - - private void HandleReviveTrigger() - { - if (RevivesDone < Revive_Count && NPC.life < NPC.lifeMax * Revive_MinHP) - { - NPC.life = 0; - NPC.checkDead(); - } - } - - private void HandleTalonBombing(Player target, List talons) - { - //Handle synchronised talon punches - if (talons.Count == 0) - { - return; - } - - HarvesterTalon activeTalon = null; - if (activeTalonIndex == Main.maxNPCs) - { - for (int i = 0; i < talons.Count; i++) - { - HarvesterTalon talon = talons[i]; - if (talon.Idle) - { - if (activeTalonIndex != Main.maxNPCs) - { - //Already has an idle talon, choose the one further away from player - if (Math.Abs(talons[activeTalonIndex].NPC.Center.X - target.Center.X) <= Math.Abs(talon.NPC.Center.X - target.Center.X)) - { - activeTalonIndex = (byte)i; - } - } - else - { - activeTalonIndex = (byte)i; - } - } - } - - //During kickstart found one idle talon: turn it active - if (activeTalonIndex != Main.maxNPCs) - { - activeTalon = talons[activeTalonIndex]; - ActivateTalon(talons[activeTalonIndex]); - } - } - else - { - activeTalon = talons[activeTalonIndex]; - } - - if (activeTalon != null) - { - //If one is active, monitor it and detect when it retracts - if (activeTalon.AI_State == HarvesterTalon.State_Seek_Retract) - { - //Swap to next talon - for (int i = 0; i < talons.Count; i++) - { - HarvesterTalon talon = talons[i]; - if (talon.Idle && i != activeTalonIndex) - { - activeTalonIndex = (byte)i; - ActivateTalon(talon); - break; - } - } - } - } - - //Main.NewText("active: " + activeTalon.NPC.whoAmI); - } - - private void ActivateTalon(HarvesterTalon talon) - { - if (talon != null && talon.Idle) - { - //Main.NewText("manually fire talon " + talon.NPC.whoAmI); - talon.AI_State = HarvesterTalon.State_Punch; - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.SyncNPC, number: talon.NPC.whoAmI); - } - } - } - - private void HandleMeleeIndicator(Player target) - { - return; //TODO disabled for now - - if (Main.myPlayer == target.whoAmI) - { - if (!displayMeleeIndicator && StateToDisplayMeleeIndicator && !displayedMeleeIndicatorOnce) - { - Rectangle screenRect = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, - Main.screenWidth, Main.screenHeight); //Lazy solution, does not respond to zoom - - Rectangle npcRect = NPC.getRect(); - npcRect.Inflate(-20, -20); - - if (screenRect.Contains(npcRect)) - { - //Main.NewText("display indic"); - displayMeleeIndicator = true; - } - } - - if (displayMeleeIndicator && !StateToDisplayMeleeIndicator) - { - //Main.NewText("stop displaying indic"); - //Reset after displaying once - displayMeleeIndicator = false; - displayedMeleeIndicatorOnce = true; - } - } - } - - private void HandleAnimation() - { - if (allowAnimationSpeedAdjustment) - { - //"Global" animation rule - float speedX = Math.Abs(NPC.velocity.X); - //Main.NewText("AI_Animation: " + AI_Animation); - //Main.NewText("Animation_Timer: " + Animation_Timer); - //Main.NewText("speedX: " + speedX); - - if (AI_Animation == Animation_Flight && speedX < 0.75f) - { - //The timer usage is for not immediately spazzing with the talons when changing directions - if (Animation_Timer++ >= 20) - { - Animation_Timer = 0; - //If not flight, and speed less than low threshold, change after 20 ticks - AI_Animation = Animation_NoHorizontal; - } - } - else if (AI_Animation == Animation_NoHorizontal && speedX > 1f) - { - if (Animation_Timer++ >= 20 || speedX > 3) - { - Animation_Timer = 0; - //If not in horizontal, and speed more than high threshold, change after 20 ticks, or if really fast already - AI_Animation = Animation_Flight; - } - } - } - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 1.5f; - return null; - } - - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } - - //Gore 5 is a broken rib. For use when entering its damaged phase. - - if (NPC.life <= 0 && !NPC.active) //!active is important due to CheckDead shenanigans - { - int first = 1; //Head - int second = 13 + first; //"Feather" - int third = 2 + second; //Large wing bone - int fourth = 2 + third; //Talon - int total = fourth; - for (int i = 0; i < total; i++) - { - int name = 4; - if (i < first) name = 1; - else if (i < second) name = 2; - else if (i < third) name = 3; - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("SoulHarvesterGore_0" + name).Type, 1f); - } - } - } - } + return false; + } + + public override Color? GetAlpha(Color drawColor) + { + if (NPC.IsABestiaryIconDummy) + { + //This is required because we have NPC.alpha = 255 in SetDefaults, in the bestiary it would look transparent + return NPC.GetBestiaryEntryColor(); + } + return Color.Lerp(drawColor, Color.White, 0.4f).MultiplyRGBA(overlayColor) * NPC.Opacity; + } + + /// + /// Spawns souls multiplied by the number of people present during the fight + /// + private void SpawnSouls(int npcTypeNew) + { + int count = Array.FindAll(NPC.playerInteraction, interacted => interacted).Length; + + for (int i = 0; i < count; i++) + { + Vector2 randVector = Vector2.One; + float randFactor; + int index; + + for (int j = 0; j < SpawnedSoulCount; j++) //spawn souls when dies + { + index = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)NPC.Center.X, (int)NPC.Center.Y, npcTypeNew); + if (index < Main.maxNPCs && Main.npc[index] is NPC soul) + { + soul.SetDefaults(npcTypeNew); + randVector = randVector.RotatedByRandom(MathHelper.ToRadians(359f)); + randFactor = Main.rand.NextFloat(2f, 8f); + //Main.npc[index].timeLeft = 3600; + soul.velocity = randVector * randFactor; + soul.ai[2] = Main.rand.Next(1, DungeonSoulBase.offsetYPeriod); //doesnt get synced properly to clients idk + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.SyncNPC, number: index); + } + } + } + } + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheDungeon, + new FlavorTextBestiaryInfoElement("After having absorbed the essence of fallen dungeon denizens, this skeletal bird rapidly grew into a ferocious hunter that sought to eat the hand that once fed it.") + }); + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + int idolOfDecay = ModContent.ItemType(); + LeadingConditionRule noHasItemWithBankRule = new LeadingConditionRule(new NoHasItemWithBankCondition(idolOfDecay)); + noHasItemWithBankRule.OnSuccess(ItemDropRule.Common(idolOfDecay)); + npcLoot.Add(noHasItemWithBankRule); + + LeadingConditionRule neverDropsRule = new LeadingConditionRule(new Conditions.NeverTrue()); + neverDropsRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), 1, SpawnedSoulCount, SpawnedSoulCount)); + npcLoot.Add(neverDropsRule); + + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + //Relic and trophy are NOT spawned in the bag + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 10)); + npcLoot.Add(ItemDropRule.MasterModeCommonDrop(ModContent.ItemType())); + + npcLoot.Add(ItemDropRule.MasterModeDropOnAllPlayers(ModContent.ItemType(), 4)); + + //Drop one of three sigils, one random one per player + var sigils = new int[] { ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType() }; + var sigilRule = new OneFromOptionsPerPlayerOnPlayerRule(options: sigils); + npcLoot.Add(sigilRule); + + //All our drops here are based on "not expert", meaning we use .OnSuccess() to add them into the rule, which then gets added + LeadingConditionRule notExpertRule = new LeadingConditionRule(new Conditions.NotExpert()); + + notExpertRule.OnSuccess(ItemDropRule.Common(ItemID.Bone, minimumDropped: 40, maximumDropped: 60)); + notExpertRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType())); + + notExpertRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 7)); + + //Finally add the leading rule + npcLoot.Add(notExpertRule); + } + + public override void OnKill() + { + NPC.SetEventFlagCleared(ref AssWorld.downedHarvester, -1); + + AssWorld.Message(deathMessage, deathColor); + + int npcTypeOld = ModContent.NPCType(); + int npcTypeNew = ModContent.NPCType(); //version that doesn't get eaten by harvesters + + int itemTypeOld = ModContent.ItemType(); + int itemTypeNew = ModContent.ItemType(); //version that is used in crafting + + //"convert" NPC souls + ConvertSouls(npcTypeOld, npcTypeNew, itemTypeOld, itemTypeNew); + + SpawnSouls(npcTypeNew); + } + + public override bool CheckDead() + { + if (RevivesDone < Revive_Count) + { + //Main.NewText(Main.GameUpdateCount + " checkdead false " + (revivesDone < Revive_Count)); + NPC.life = NPC.lifeMax; + NPC.defense = Revive_Defense; + + if (AI_State != State_Weakened) + { + NPC.dontTakeDamage = true; //Set for one tick to prevent damage in same tick from applying + RevivesDone++; + //Main.NewText("revive #" + revivesDone); + + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < 6; i++) + { + Gore.NewGore(Main.rand.NextVector2FromRectangle(NPC.getRect()), NPC.velocity, Mod.Find("SoulHarvesterGore_05").Type, 1f); + } + } + + SetState(State_Weakened); + SetFrame(0); + + for (int i = 0; i < NPC.maxBuffs; i++) + { + //Clear potential DoT debuffs + NPC.DelBuff(i); + } + } + + return false; + } + + //Main.NewText("checkdead skip " + (revivesDone < Revive_Count)); + return base.CheckDead(); + } + + private void ConvertSouls(int npcTypeOld, int npcTypeNew, int itemTypeOld, int itemTypeNew) + { + for (short j = 0; j < Main.maxNPCs; j++) + { + NPC other = Main.npc[j]; + if (other.active && other.type == npcTypeOld) + { + other.active = false; + int index = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)other.position.X, (int)other.position.Y, npcTypeNew); + NPC npcnew = Main.npc[index]; + npcnew.ai[2] = Main.rand.Next(1, DungeonSoulBase.offsetYPeriod); //doesnt get synced properly to clients idk + npcnew.timeLeft = 3600; + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.SyncNPC, number: index); + } + + //poof visual works only in singleplayer + for (int i = 0; i < 15; i++) + { + Dust dust = Dust.NewDustPerfect(npcnew.Center, 59, new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 1.5f)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); + dust.noLight = true; + dust.noGravity = true; + dust.fadeIn = Main.rand.NextFloat(0.1f, 0.6f); + } + } + } + + //"convert" Item souls that got dropped for some reason + int tempStackCount; + for (int j = 0; j < Main.maxItems; j++) + { + Item item = Main.item[j]; + if (item.active && item.type == itemTypeOld) + { + tempStackCount = item.stack; + item.SetDefaults(itemTypeNew); + item.stack = tempStackCount; + + //poof visual + for (int i = 0; i < 15; i++) + { + Dust dust = Dust.NewDustPerfect(item.Center, 59, new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 1.5f)), 26, Color.White, Main.rand.NextFloat(1.5f, 2.4f)); + dust.noLight = true; + dust.noGravity = true; + dust.fadeIn = Main.rand.NextFloat(0.1f, 0.6f); + } + } + } + + //"convert" Item souls in inventory + for (int j = 0; j < Main.maxPlayers; j++) + { + Player player = Main.player[j]; + if (player.active/* && !Main.player[j].dead*/) + { + AssPlayer mPlayer = player.GetModPlayer(); + + if (Main.netMode == NetmodeID.Server) + { + SendConvertInertSoulsInventory(j); + } + else //singleplayer + { + mPlayer.ConvertInertSoulsInventory(); + } + } + } + } + + private void SendConvertInertSoulsInventory(int toWho) + { + if (Main.netMode == NetmodeID.Server) + { + ModPacket packet = Mod.GetPacket(); + packet.Write((byte)AssMessageType.ConvertInertSoulsInventory); + packet.Send(toClient: toWho); + } + } + + /// + /// Sets the y on the spritesheet. use AI_Animation to set x + /// + /// The y + public void SetFrame(int frameY) + { + NPC.frame.Y = frameY * FrameHeight; + NPC.frameCounter = 0; + } + + /// + /// (Counter/Timer only resets on hard state change) + /// + /// State to change to. By default, no change + /// Sub-State to change to. + public void SetState(float state = State_KeepCurrent, float subState = 0f) + { + if (state != State_KeepCurrent) + { + AI_State = state; + AI_Counter = 0; + AI_Timer = 0; + } + + AI_SubState = subState; + NPC.netUpdate = true; + } + + public static int GetLastFrame(int animation) + { + return animation switch + { + Animation_Swoop => 2, + _ => FrameCountVertical - 1 + }; + } + + public const float State_KeepCurrent = -1f; + public const float State_Fireball = 0f; //Basic flying, homing attack + public const float State_SpawnedByBaby = 1f; //Special state set on spawn + public const float State_Swoop = 2f; + public const float State_Bombing = 3f; + public const float State_Weakened = 4f; //Can enter from any state, special conditions + + //Substates: + public const int Swoop_SeekStart = 0;//Second half the "U" + public const int Swoop_Swooping = 1; //First half the "U" + + public const int Swooping_Distance = 500; + public const int Swooping_Height = 280; + public const int Swoop_Count = 3; + public const int Revive_Count = 2; + public const float Revive_MinHP = 0.1f; + public const int Revive_Duration = 180; + public const int Revive_Defense = 999; + + public const int Bombing_Distance = Swooping_Distance + 300; + public const int Bombing_Height = 200; + + public const int Animation_NoHorizontal = 0; + public const int Animation_Flight = 1; + public const int Animation_Swoop = 2; + public const int Animation_Bombing = 3; + + public ref float AI_State => ref NPC.ai[0]; + + public ref float AI_SubState => ref NPC.ai[1]; + + public ref float AI_Timer => ref NPC.ai[2]; + + public int AI_Animation + { + get => (int)NPC.ai[3]; + set => NPC.ai[3] = value; + } + + public ref float AI_Intro => ref NPC.localAI[0]; + + public bool Initialized + { + get => NPC.localAI[1] == 1f; + set => NPC.localAI[1] = value ? 1f : 0f; + } + + public ref float Animation_Timer => ref NPC.localAI[2]; + + //Synced + public int AI_Counter + { + get => (int)NPC.localAI[3]; + set => NPC.localAI[3] = value; + } + + //Synced + private byte activeTalonIndex = Main.maxNPCs; + + //Synced + //0: no revives yet + //1: first revive initiated/ongoing + //... + //Revive_Count: final possible revive initiated/ongoing + public byte RevivesDone { get; private set; } + + public ref float ReviveProgress => ref AI_Timer; + + public bool IsReviving => AI_State == State_Weakened; + + public bool StateToDisplayMeleeIndicator => AI_State == State_Swoop && AI_Timer < 0 || VulnerableToMelee; + + public bool VulnerableToMelee => AI_State == State_Swoop && AI_SubState == Swoop_Swooping; + + //Not synced, serverside + public int FireballTimer { get; private set; } + + //Not synced, should be clientside + private bool displayMeleeIndicator = false; + private bool displayedMeleeIndicatorOnce = false; + + private bool allowAnimationSpeedAdjustment = true; + + private float fadingAuraAlphaIntensity = 0f; + private float fadingAuraScaleIntensity = 0f; + private int fadingAuraTimerMax = 0; + private int fadingAuraTimer = 0; + + private void SetFadingAura(int alphaTimer, float alphaIntensity = 0.8f, float scaleIntensity = 0.5f) + { + fadingAuraTimerMax = fadingAuraTimer = alphaTimer; + fadingAuraAlphaIntensity = alphaIntensity; + fadingAuraScaleIntensity = scaleIntensity; + } + + private void HandleFadingAura() + { + if (fadingAuraTimer > 0) + { + fadingAuraTimer--; + } + else + { + fadingAuraTimerMax = 0; + fadingAuraAlphaIntensity = 0f; + fadingAuraScaleIntensity = 0f; + } + } + + public override void AI() + { + Lighting.AddLight(NPC.Center, 0.3f, 0.3f, 0.7f); + + if (NPC.target < 0 || NPC.target >= 255 || !Main.player[NPC.target].active || Main.player[NPC.target].dead) + { + NPC.TargetClosest(); + } + + Player target = Main.player[NPC.target]; + + if (target.DistanceSQ(NPC.Center) > 2000 * 2000) + { + NPC.TargetClosest(); + } + + HandleMeleeIndicator(target); + + HandleAnimation(); + + HandleReviveVisuals(); + + HandleFadingAura(); + + HandleReviveTrigger(); + + List talons = GetTalons(); + + MonitorExtendedTalons(talons); + + NPC.chaseable = !IsReviving; + NPC.dontTakeDamage = IsReviving; + NPC.scale = 1f; + + if (!IsReviving && NPC.defense == Revive_Defense) + { + //Restore defense after revived + NPC.defense = NPC.defDefense; + } + + if (target.dead && !IsReviving) + { + AI_Animation = Animation_Flight; + SetState(State_Fireball); + NPC.velocity.Y += 0.06f; + NPC.velocity.X *= 0.97f; + if (NPC.timeLeft > 10) + { + NPC.timeLeft = 10; + } + return; + } + + NPC.rotation = NPC.velocity.X * 0.02f; + + int diff = 38; //Distance offset between two talons + int offX = -10; //Offset from the center for the left talon + talonOffsetLeftX = offX * NPC.direction + NPC.velocity.X/* * TalonDirectionalOffset*/; + talonOffsetRightX = (diff + offX) * NPC.direction + NPC.velocity.X/* * TalonDirectionalOffset*/; + talonOffsetY = hei / 2 + 4 + NPC.velocity.Y; + //Due to update order (boss updates after talons), add velocity to the offsets aswell + + if (!Initialized) + { + SoundEngine.PlaySound(SoundID.Roar, (int)NPC.Center.X, (int)NPC.Center.Y, 0); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int y = (int)(NPC.Center.Y + talonOffsetY); + + (int x, int type)[] talonTypes = new (int, int)[] + { + ((int)(NPC.Center.X + talonOffsetLeftX), AssortedCrazyThings.harvesterTalonLeft), + ((int)(NPC.Center.X + talonOffsetRightX), AssortedCrazyThings.harvesterTalonRight) + }; + + var source = NPC.GetSpawnSourceForNPCFromNPCAI(); + foreach (var (x, type) in talonTypes) + { + int index = NPC.NewNPC(source, x, y, type); + if (index < Main.maxNPCs && Main.npc[index] is NPC talonNPC && talonNPC.ModNPC is HarvesterTalon talon) + { + talon.ParentWhoAmI = NPC.whoAmI; + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.SyncNPC, number: index); + } + } + } + } + + AI_Timer = 0; + NPC.TargetClosest(); + + if (AI_State != State_SpawnedByBaby) + { + SetState(State_Fireball); + } + Initialized = true; + } + + //Spawned through summon item/cheated in + if (AI_State != State_SpawnedByBaby && AI_Intro < 255) + { + AI_Intro += 5; + NPC.alpha -= 5; + if (AI_Intro >= 255) + { + AI_Intro = 255; + NPC.alpha = 0; + SetFadingAura(20, 0.8f, 0.5f); + NPC.netUpdate = true; + } + return; + } + else + { + AI_Intro = 255; + NPC.alpha = 0; + } + + //Spawned by baby, which shows the transformation before spawning + if (AI_State == State_SpawnedByBaby) + { + AI_Intro = 255; + NPC.alpha = 0; + SetFadingAura(20, 0.8f, 0.5f); + SetState(State_Fireball); + NPC.netUpdate = true; + } + + HandleAI(target, talons); + } + + private void MonitorExtendedTalons(List talons) + { + //Monitor talons that extend too far + for (int i = 0; i < talons.Count; i++) + { + HarvesterTalon talon = talons[i]; + if (talon.AI_State == HarvesterTalon.State_Punching) + { + if (talon.NPC.Top.Y > NPC.Center.Y + Bombing_Height) + { + //Main.NewText("manually retract talon " + i); + talon.AI_State = HarvesterTalon.State_Seek_Retract; + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.SyncNPC, number: i); + } + } + } + } + } + + private List GetTalons() + { + List talons = new List(); + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + + //If talon and belongs to self + if (npc.active && npc.ModNPC is HarvesterTalon talon && talon.ParentWhoAmI == NPC.whoAmI) + { + talons.Add(talon); + } + } + + return talons; + } + + private void HandleAI(Player target, List talons) + { + float lifeRatio = NPC.life / (float)NPC.lifeMax; + var aiStats = GetAIStats(); + + if (AI_State == State_Fireball || aiStats.AlwaysShootFireballs) + { + //Generate souls in a half circle above the boss and have them home to whatever the nearest player to them is + FireballTimer++; + if (FireballTimer % aiStats.FireballInterval == 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 random = (-Vector2.UnitY).RotatedByRandom(MathHelper.PiOver2) * 160; + Vector2 pos = NPC.Center + random; + Vector2 toPlayer = target.DirectionFrom(pos); + int damage = (int)(NPC.damage * 0.70f); + damage = NPC.GetAttackDamage_ForProjectiles(damage, damage * 0.33f); //To compensate expert mode NPC damage + projectile damage increase + Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), pos, toPlayer * 1, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, aiStats.FireballSpeed); + } + } + } + + if (AI_State == State_Fireball) + { + if (AI_Animation != Animation_Flight && AI_Animation != Animation_NoHorizontal) + { + AI_Animation = Animation_Flight; + } + + AI_Timer++; + + float acceleration = 0.05f; + + Vector2 origin = new Vector2(NPC.Center.X + 6 * NPC.direction, NPC.position.Y + NPC.height * 0.8f); + float diffX = target.Center.X - NPC.Center.X; + float diffY = target.Center.Y - 200f - NPC.Center.Y; //300f + float length = (float)Math.Sqrt(diffX * diffX + diffY * diffY); + + if (!Collision.CanHit(new Vector2(origin.X, origin.Y - 30f), 1, 1, target.position, target.width, target.height)) + { + acceleration = 0.1f; + diffX = target.Center.X - NPC.Center.X; + diffY = target.Center.Y - NPC.Center.Y; + + //WHEN NO DIRECT CAN HIT LINE + + if (Math.Abs(NPC.velocity.X) < 32) + { + if (NPC.velocity.X < diffX) + { + NPC.velocity.X += acceleration; + if (NPC.velocity.X < 0f && diffX > 0f) + { + NPC.velocity.X += acceleration * 2.5f; //1f all + } + } + else if (NPC.velocity.X > diffX) + { + NPC.velocity.X -= acceleration; + if (NPC.velocity.X > 0f && diffX < 0f) + { + NPC.velocity.X -= acceleration * 2.5f; + } + } + } + if (Math.Abs(NPC.velocity.Y) < 32) + { + if (NPC.velocity.Y < diffY) + { + NPC.velocity.Y += acceleration; + if (NPC.velocity.Y < 0f && diffY > 0f) + { + NPC.velocity.Y += acceleration * 2.5f; + } + } + else if (NPC.velocity.Y > diffY) + { + NPC.velocity.Y -= acceleration; + if (NPC.velocity.Y > 0f && diffY < 0f) + { + NPC.velocity.Y -= acceleration * 2.5f; + } + } + } + } + else if (length > 100f) + { + NPC.TargetClosest(); + if (Math.Abs(NPC.velocity.X) < 32) + { + if (NPC.velocity.X < diffX) + { + NPC.velocity.X += acceleration; + if (NPC.velocity.X < 0f && diffX > 0f) + { + NPC.velocity.X += acceleration * 2f; //2f all + } + } + else if (NPC.velocity.X > diffX) + { + NPC.velocity.X -= acceleration; + if (NPC.velocity.X > 0f && diffX < 0f) + { + NPC.velocity.X -= acceleration * 2f; + } + } + } + if (Math.Abs(NPC.velocity.Y) < 32) + { + if (NPC.velocity.Y < diffY) + { + NPC.velocity.Y += acceleration; + if (NPC.velocity.Y < 0f && diffY > 0f) + { + NPC.velocity.Y += acceleration * 2f; + } + } + else if (NPC.velocity.Y > diffY) + { + NPC.velocity.Y -= acceleration; + if (NPC.velocity.Y > 0f && diffY < 0f) + { + NPC.velocity.Y -= acceleration * 2f; + } + } + } + } + + float lifeRatioClamped = Utils.Remap(lifeRatio, 0, 1, 0.666f, 1); + float timeToNextState = aiStats.FireballDuration * lifeRatioClamped; + + if (Main.expertMode && RevivesDone == Revive_Count) //Final revive + { + timeToNextState = 0; + } + + if (AI_Timer > timeToNextState) + { + AI_Timer = 0; + SetState(State_Swoop); + NPC.TargetClosest(false); + } + } + else if (AI_State == State_Swoop) + { + //Main.NewText("substat: " + AI_SubState); + //Main.NewText("counter: " + AI_Counter); + //Main.NewText("timer: " + AI_Timer); + + //AI_Counter meaning: + //0: first swoop: decide direction (sign) and set 1 + //absolute value: swoop count + //sign: swoop direction + + //After passing the player during start, change to seekStart + + int count = Math.Abs(AI_Counter); + bool keepSwooping = count <= Swoop_Count; + + if (AI_SubState == Swoop_SeekStart) + { + float speed = 10; + const float minInertia = 6; + float inertia = minInertia; + float lifeRatioClamped = Utils.Remap(lifeRatio, 0, 1, 0.6f, 1); + + if (AI_Counter != 0 && AI_Animation == Animation_Swoop) + { + float swoopPostTime = aiStats.SwoopWaitTime * lifeRatioClamped; + + //This means a swoop has already taken place, and the "post-swoop" frame should be displayed for a while + AI_Timer++; + inertia += (swoopPostTime - AI_Timer) / swoopPostTime * 16; //Increase inertia during the "post-swoop" so that it follows the U shape for a bit at the bottom + + inertia = Math.Max(inertia, minInertia); + + if (AI_Timer > 8 * lifeRatioClamped) + { + SetFrame(2); //Post-swoop + } + else if (AI_Timer > swoopPostTime) + { + AI_Timer = 0; + AI_Animation = Animation_Flight; + SetFrame(4); //Regular flight, frame after the post-swoop in regards to wing position + } + } + + //Find location to start swoop on the side of the player closer to the boss + Vector2 toPlayer = target.DirectionFrom(NPC.Bottom); //Talons should hit center of player + bool leftOfPlayer = toPlayer.X > 0; + + int targetY = keepSwooping ? Swooping_Height : Bombing_Height; + + Vector2 start = new Vector2(Swooping_Distance, -targetY); + if (AI_Counter == 0) + { + //First swoop + //Initial start is "right of player" meaning initial dir should be "left towards player" + AI_Counter = -1; + if (!leftOfPlayer) + { + //Flip both if NPC is "left of player" + start.X *= -1; + AI_Counter *= -1; + } + } + else + { + //Consecutive swoops + if (AI_Counter < 0) //current dir is "left towards player" + { + //Flip + start.X *= -1; + } + //No flip required otherwise + } + + //Apply absolute vector + start += target.Center; + + Vector2 toStart = start - NPC.Center; + + if (toStart.LengthSquared() <= speed * speed) + { + if (AI_Timer >= 0) + { + //Kickstart timer + AI_Timer = -1; + } + + NPC.direction = leftOfPlayer.ToDirectionInt(); + AI_Animation = Animation_NoHorizontal; + NPC.Center = start; + if (NPC.velocity.LengthSquared() > 1) + { + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY); + } + NPC.velocity *= 0.95f; + } + else + { + toStart = toStart.SafeNormalize(Vector2.UnitY); + toStart *= speed; + + NPC.velocity = (NPC.velocity * (inertia - 1) + toStart) / inertia; + + if (NPC.direction == 1 && NPC.velocity.X < 0 || + NPC.direction == -1 && NPC.velocity.X > 0) + { + //Swap direction if not locked into position yet but flew past it + NPC.direction *= -1; + } + } + + if (AI_Timer < 0) + { + AI_Timer--; + float swoopPostTime = aiStats.SwoopWaitTime * lifeRatioClamped; + if (AI_Timer < -swoopPostTime) + { + AI_Timer = 0; + + if (keepSwooping) + { + //This does keep whatever animation was previously happening, but changes it on swoop + SetState(subState: Swoop_Swooping); + NPC.direction = leftOfPlayer.ToDirectionInt(); + AI_Animation = Animation_Swoop; + SetFrame(0); + } + else + { + SetState(State_Bombing); + NPC.direction = leftOfPlayer.ToDirectionInt(); + AI_Animation = Animation_Bombing; + //Frames match, so don't need to call SetFrame + } + } + } + } + else if (AI_SubState == Swoop_Swooping) + { + if (AI_Timer == 0) + { + SoundEngine.PlaySound(SoundID.Roar, (int)NPC.Center.X, (int)NPC.Center.Y, 0, pitchOffset: 0.15f); + } + + int xSpeed = 12; + AI_Timer += xSpeed; //AI_Timer is memory of distance traversed + + //Keep constant speed towards direction (not player) + float xDir = NPC.direction * xSpeed; + + //Go down towards straight line smoothly, fast at first (to create half of "u" shape) + //Number from 0 (start) to 1 (end, reached swoop location) + + float xProgress = AI_Timer / Swooping_Distance; + float yProgress = EaseOutLinear(xProgress, 1f); + + //Used on VELOCITY, meaning this is a parabola position wise + float EaseOutLinear(float x, float y0 = 1f) + { + //Start at y0, finish at 0 + float m = -y0; + return m * x + y0; + } + + //float EaseOutCirc(float x) + //{ + // //Start fast, but slow down slowly 30% through + // return (float)Math.Sqrt(1 - Math.Pow((double)x - 1, 2)); + //} + + int ySpeed = 10; + float yDir = ySpeed * yProgress; + + if (xProgress >= 0.95f) + { + //About to hit player/finish swoop down + SetFrame(1); + } + + //bool passedPlayer = (NPC.Center.X > target.Center.X).ToDirectionInt() == NPC.direction; + if (xProgress >= 1f/* || passedPlayer*/) + { + AI_Timer = 0; + + //Increment count for next swoop + //Flip dir + count++; + int dir = Math.Sign(AI_Counter); + dir *= -1; + AI_Counter = dir * count; + + if (keepSwooping) + { + SetState(subState: Swoop_SeekStart); + } + else + { + SetState(State_Fireball); + + //Go into the state that picks an attack + } + } + else + { + NPC.velocity = new Vector2(xDir, yDir); + + if (xProgress >= 0.5f) + { + //Course correct on second half of dive. For players trying to easily dodge the talons by stepping left/right + Vector2 toPlayer = target.Center - NPC.Center; + toPlayer = toPlayer.SafeNormalize(Vector2.UnitX * NPC.direction) * 20; + float inertia = 10; + NPC.velocity = (NPC.velocity * (inertia - 1) + toPlayer) / inertia; + } + } + } + } + else if (AI_State == State_Bombing) + { + //This gets entered + if (AI_Timer == 0) + { + SetFadingAura(20, 1.4f, 0.5f); + SoundEngine.PlaySound(SoundID.Roar, (int)target.Center.X, (int)target.Center.Y, 0, pitchOffset: 0f); + } + + //Lock rotation, talons do not move based on rotation + NPC.rotation = 0f; + + float xSpeed = 7.5f; //9 + AI_Timer += xSpeed; //AI_Timer is memory of distance traversed + + //Keep constant speed towards direction (not player) + float xDir = NPC.direction * xSpeed; + + float xProgress = AI_Timer / Bombing_Distance; + + //Adjust Y level to keep same level to targeted player if not reached player yet + Vector2 targetCenter = target.Center; + Vector2 toTarget = targetCenter - NPC.Center; + float yDir = NPC.velocity.Y; + if (NPC.direction * toTarget.X > 0) + { + targetCenter += new Vector2(0, -Bombing_Height); + toTarget = targetCenter - NPC.Center; + int ySpeed = 20; + if (toTarget.LengthSquared() > ySpeed * ySpeed) + { + toTarget = toTarget.SafeNormalize(Vector2.UnitY) * ySpeed; + } + float inertia = 10; + yDir = (NPC.velocity.Y * (inertia - 1) + toTarget.Y) / inertia; + } + + if (toTarget.Y > Bombing_Height) + { + //player below targeted bombing line, move directly with player to catch up + //yDir *= 1; + } + else + { + //if distance smaller (i.e player jumps) only catch up with slower speed + yDir *= 0.75f; + } + + NPC.velocity = new Vector2(xDir + target.velocity.X / 2, yDir); + + if (xProgress >= 1) + { + NPC.TargetClosest(true); + SetState(State_Fireball); + } + + HandleTalonBombing(target, talons); + } + else if (AI_State == State_Weakened) + { + if (AI_Animation != Animation_Flight && AI_Animation != Animation_NoHorizontal) + { + AI_Animation = Animation_Flight; + } + + NPC.velocity *= 0.98f; + + float len = NPC.velocity.Length(); + if (len <= 0.5f) + { + NPC.velocity *= 0; + } + + int period = 15; + if (Main.netMode != NetmodeID.Server) + { + if (ReviveProgress % (3 * period) == 0) + { + SetFadingAura(20, 0.3f + 0.5f * (ReviveProgress / Revive_Duration)); + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + overlayColor = new Color(195, 247, 255) * 0.4f; + overlayColor.A = 255; + + Vector2 dustOffset = new Vector2(0, (NPC.height + NPC.width) / 2 * 0.5f); + Vector2 center = NPC.Center; + float amount = 0.5f + 0.5f * (ReviveProgress / Revive_Duration); + for (int i = 0; i < 30 * amount; i++) + { + Vector2 dustOffset2 = dustOffset.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.1f, 1f); + Dust dust = Dust.NewDustPerfect(center + dustOffset2, 59, newColor: Color.White, Scale: 2.1f); + dust.noLight = true; + dust.noGravity = true; + dust.fadeIn = Main.rand.NextFloat(0.2f, 0.8f); + dust.velocity = Utils.SafeNormalize(dust.position - center, Vector2.Zero) * 3; + } + } + } + + ReviveProgress++; + + if (ReviveProgress >= Revive_Duration) + { + NPC.TargetClosest(); + + NPC.life = (int)(NPC.lifeMax * aiStats.MaxHP); + + SetFadingAura(20, 0.8f, 0.5f); + SoundEngine.PlaySound(SoundID.Roar, (int)NPC.Center.X, (int)NPC.Center.Y, 0); + AI_Animation = Animation_NoHorizontal; + SetState(State_Fireball); + } + } + } + + private void HandleReviveVisuals() + { + overlayColor = Color.Lerp(overlayColor, Color.White, 0.1f); + } + + private void HandleReviveTrigger() + { + if (RevivesDone < Revive_Count && NPC.life < NPC.lifeMax * Revive_MinHP) + { + NPC.life = 0; + NPC.checkDead(); + } + } + + private void HandleTalonBombing(Player target, List talons) + { + //Handle synchronised talon punches + if (talons.Count == 0) + { + return; + } + + HarvesterTalon activeTalon = null; + if (activeTalonIndex == Main.maxNPCs) + { + for (int i = 0; i < talons.Count; i++) + { + HarvesterTalon talon = talons[i]; + if (talon.Idle) + { + if (activeTalonIndex != Main.maxNPCs) + { + //Already has an idle talon, choose the one further away from player + if (Math.Abs(talons[activeTalonIndex].NPC.Center.X - target.Center.X) <= Math.Abs(talon.NPC.Center.X - target.Center.X)) + { + activeTalonIndex = (byte)i; + } + } + else + { + activeTalonIndex = (byte)i; + } + } + } + + //During kickstart found one idle talon: turn it active + if (activeTalonIndex != Main.maxNPCs) + { + activeTalon = talons[activeTalonIndex]; + ActivateTalon(talons[activeTalonIndex]); + } + } + else + { + activeTalon = talons[activeTalonIndex]; + } + + if (activeTalon != null) + { + //If one is active, monitor it and detect when it retracts + if (activeTalon.AI_State == HarvesterTalon.State_Seek_Retract) + { + //Swap to next talon + for (int i = 0; i < talons.Count; i++) + { + HarvesterTalon talon = talons[i]; + if (talon.Idle && i != activeTalonIndex) + { + activeTalonIndex = (byte)i; + ActivateTalon(talon); + break; + } + } + } + } + + //Main.NewText("active: " + activeTalon.NPC.whoAmI); + } + + private void ActivateTalon(HarvesterTalon talon) + { + if (talon != null && talon.Idle) + { + //Main.NewText("manually fire talon " + talon.NPC.whoAmI); + talon.AI_State = HarvesterTalon.State_Punch; + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.SyncNPC, number: talon.NPC.whoAmI); + } + } + } + + private void HandleMeleeIndicator(Player target) + { + return; //TODO disabled for now + + if (Main.myPlayer == target.whoAmI) + { + if (!displayMeleeIndicator && StateToDisplayMeleeIndicator && !displayedMeleeIndicatorOnce) + { + Rectangle screenRect = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, + Main.screenWidth, Main.screenHeight); //Lazy solution, does not respond to zoom + + Rectangle npcRect = NPC.getRect(); + npcRect.Inflate(-20, -20); + + if (screenRect.Contains(npcRect)) + { + //Main.NewText("display indic"); + displayMeleeIndicator = true; + } + } + + if (displayMeleeIndicator && !StateToDisplayMeleeIndicator) + { + //Main.NewText("stop displaying indic"); + //Reset after displaying once + displayMeleeIndicator = false; + displayedMeleeIndicatorOnce = true; + } + } + } + + private void HandleAnimation() + { + if (allowAnimationSpeedAdjustment) + { + //"Global" animation rule + float speedX = Math.Abs(NPC.velocity.X); + //Main.NewText("AI_Animation: " + AI_Animation); + //Main.NewText("Animation_Timer: " + Animation_Timer); + //Main.NewText("speedX: " + speedX); + + if (AI_Animation == Animation_Flight && speedX < 0.75f) + { + //The timer usage is for not immediately spazzing with the talons when changing directions + if (Animation_Timer++ >= 20) + { + Animation_Timer = 0; + //If not flight, and speed less than low threshold, change after 20 ticks + AI_Animation = Animation_NoHorizontal; + } + } + else if (AI_Animation == Animation_NoHorizontal && speedX > 1f) + { + if (Animation_Timer++ >= 20 || speedX > 3) + { + Animation_Timer = 0; + //If not in horizontal, and speed more than high threshold, change after 20 ticks, or if really fast already + AI_Animation = Animation_Flight; + } + } + } + } + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + scale = 1.5f; + return null; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } + + //Gore 5 is a broken rib. For use when entering its damaged phase. + + if (NPC.life <= 0 && !NPC.active) //!active is important due to CheckDead shenanigans + { + int first = 1; //Head + int second = 13 + first; //"Feather" + int third = 2 + second; //Large wing bone + int fourth = 2 + third; //Talon + int total = fourth; + for (int i = 0; i < total; i++) + { + int name = 4; + if (i < first) name = 1; + else if (i < second) name = 2; + else if (i < third) name = 3; + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("SoulHarvesterGore_0" + name).Type, 1f); + } + } + } + } } diff --git a/NPCs/DungeonBird/HarvesterTalon.cs b/NPCs/DungeonBird/HarvesterTalon.cs index ef0bceb3..ba064c2e 100644 --- a/NPCs/DungeonBird/HarvesterTalon.cs +++ b/NPCs/DungeonBird/HarvesterTalon.cs @@ -10,71 +10,71 @@ namespace AssortedCrazyThings.NPCs.DungeonBird { - [Content(ContentType.Bosses)] - public abstract class HarvesterTalon : AssNPC - { - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/DungeonBird/HarvesterTalon"; - } - } - - /// - /// Used for offset/directional calculations - /// - public virtual bool RightTalon => false; - - public const int ChainFrameCount = 6; - public const int ChainFrameSpeed = 6; - public static Asset ChainAsset; - - public override void Load() - { - ChainAsset = Mod.Assets.Request("NPCs/DungeonBird/HarvesterChain"); - } - - public override void Unload() - { - ChainAsset = null; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault(Harvester.name); - Main.npcFrameCount[NPC.type] = 1; - - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - Hide = true //Hides this NPC from the Bestiary - }; - NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; - - NPCID.Sets.DebuffImmunitySets[NPC.type] = new NPCDebuffImmunityData() - { - SpecificallyImmuneTo = new int[] - { - BuffID.Poisoned, - BuffID.OnFire - } - }; - } - - public override Color? GetAlpha(Color lightColor) - { - if (!HasParent) - { - return base.GetAlpha(lightColor); - } - - NPC body = Main.npc[ParentWhoAmI]; - return body.GetAlpha(lightColor); - } - - public override void SetDefaults() - { - /*else if (type == 247 || type == 248) + [Content(ContentType.Bosses)] + public abstract class HarvesterTalon : AssNPC + { + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/DungeonBird/HarvesterTalon"; + } + } + + /// + /// Used for offset/directional calculations + /// + public virtual bool RightTalon => false; + + public const int ChainFrameCount = 6; + public const int ChainFrameSpeed = 6; + public static Asset ChainAsset; + + public override void Load() + { + ChainAsset = Mod.Assets.Request("NPCs/DungeonBird/HarvesterChain"); + } + + public override void Unload() + { + ChainAsset = null; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault(Harvester.name); + Main.npcFrameCount[NPC.type] = 1; + + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + Hide = true //Hides this NPC from the Bestiary + }; + NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; + + NPCID.Sets.DebuffImmunitySets[NPC.type] = new NPCDebuffImmunityData() + { + SpecificallyImmuneTo = new int[] + { + BuffID.Poisoned, + BuffID.OnFire + } + }; + } + + public override Color? GetAlpha(Color lightColor) + { + if (!HasParent) + { + return base.GetAlpha(lightColor); + } + + NPC body = Main.npc[ParentWhoAmI]; + return body.GetAlpha(lightColor); + } + + public override void SetDefaults() + { + /*else if (type == 247 || type == 248) { noGravity = true; width = 40; @@ -90,253 +90,253 @@ public override void SetDefaults() buffImmune[24] = true; }*/ - NPC.boss = true; //TODO Why is it true? - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.width = 40; //38 //latest 40 - NPC.height = 42; //42//latest 30 - NPC.aiStyle = -1; - NPC.damage = Harvester.talonDamage; - NPC.defense = 28; - NPC.lifeMax = 1337; - NPC.scale = 1f; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.alpha = 255; - NPC.dontTakeDamage = true; - NPC.dontCountMe = true; - NPC.SpawnWithHigherTime(30); - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - //float bossAdjustment = 1f; - //if (Main.GameModeInfo.IsMasterMode) - //{ - // bossAdjustment = 0.85f; - //} - //NPC.lifeMax = (int)(NPC.lifeMax * 1.3f * bossLifeScale * bossAdjustment); - NPC.lifeMax = 1337; - NPC.damage = (int)(NPC.damage * 1.1f); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - return false; - } - - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - if (!HasParent) - { - return; - } - - NPC body = Main.npc[ParentWhoAmI]; - Harvester harvester = null; - - if (body.ModNPC is Harvester h) - { - harvester = h; - if (h.AI_State != Harvester.State_Bombing) - { - return; - } - } - - if (harvester == null) - { - return; - } - - Vector2 center = NPC.Center; - float x = body.Center.X - center.X; - float y = body.Center.Y - center.Y; - y -= -harvester.talonOffsetY + 20f; //has to result to 7f - - x += GetOffset(harvester); //66f, -70f - x += NPC.spriteDirection * (Harvester.talonDirectionalOffset + 6); - - SpriteEffects effect = (NPC.spriteDirection == 1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Texture2D texture = ChainAsset.Value; - bool keepDrawing = true; - int step = 0; - while (keepDrawing) - { - step++; - float len = (float)Math.Sqrt(x * x + y * y); - float between = 38f; - if (len < between) //16 - { - keepDrawing = false; - } - else - { - len = between / len; //16 - x *= len; - y *= len; - center.X += x; - center.Y += y; - x = body.Center.X - center.X; - y = body.Center.Y - center.Y; - y -= -harvester.talonOffsetY + 20f; - x += GetOffset(harvester); - x += NPC.spriteDirection * (Harvester.talonDirectionalOffset + 0); - - if (Main.rand.NextBool(8)) - { - Dust dust = Dust.NewDustPerfect(center, 135, new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-3f, 3f)), 26, new Color(255, 255, 255), Main.rand.NextFloat(1f, 1.6f)); - dust.noLight = true; - dust.noGravity = true; - dust.fadeIn = Main.rand.NextFloat(0.5f, 1.5f); - } - - int frameY = (((int)NPC.frameCounter / ChainFrameSpeed) + step) % ChainFrameCount; - Rectangle frame = texture.Frame(1, ChainFrameCount, frameY: frameY); - spriteBatch.Draw(texture, center - screenPos + new Vector2(0f, NPC.gfxOffY + NPC.height / 2), frame, Color.White * NPC.Opacity, 0f, frame.Size() / 2, 1f, effect, 0f); - } - } - - texture = TextureAssets.Npc[NPC.type].Value; - spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, NPC.GetAlpha(drawColor), 0f, texture.Size() / 2, 1f, effect, 0f); - } - - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Slow, 120, false); //2 seconds, 100% chance - } - - public const float State_Seek_Retract = 0f; - public const float State_Punch = 1f; - public const float State_Punching = 2f; - - public ref float AI_State => ref NPC.ai[0]; - - public ref float AI_Timer => ref NPC.ai[1]; - - public ref float RetractCounter => ref NPC.ai[2]; - - public int ParentWhoAmI - { - get => (int)NPC.ai[3] - 1; - set => NPC.ai[3] = value + 1; - } - - public bool HasParent => ParentWhoAmI >= 0 && ParentWhoAmI < Main.maxNPCs; - - public bool Idle - { - get => NPC.localAI[0] == 0f; - set => NPC.localAI[0] = value ? 0f : 1f; - } - - public override bool CheckDead() - { - NPC.boss = false; //To get rid of the default death message - return base.CheckDead(); - } - - public override void FindFrame(int frameHeight) - { - //Used just for chain anim - NPC.frameCounter++; - } - - public override void AI() - { - if (!HasParent) - { - NPC.life = 0; - NPC.active = false; - NPC.netUpdate = true; - return; - } - - NPC body = Main.npc[ParentWhoAmI]; - if (!body.active || body.type != AssortedCrazyThings.harvester) - { - NPC.life = 0; - NPC.active = false; - NPC.netUpdate = true; - return; - } - - Harvester harvester = body.ModNPC as Harvester; - - NPC.target = body.target; - if (NPC.target < 0 || NPC.target >= Main.maxPlayers) return; - Player target = Main.player[NPC.target]; - - NPC.gfxOffY = body.gfxOffY; - NPC.spriteDirection = body.spriteDirection; - NPC.direction = body.direction; - NPC.alpha = body.alpha; - - //TODO has unused tile collision code and manual retract detection (fallback) - - if (NPC.alpha > 0) - { - //NPC.alpha -= 5; - //if (NPC.alpha < 4) - //{ - // NPC.alpha = 0; - // NPC.netUpdate = true; - //} - NPC.scale = 1f; - AI_Timer = 0f; - } - - if (AI_State != State_Seek_Retract) - { - Idle = false; - } - - if (AI_State == State_Seek_Retract) - { - //NPC.noTileCollide = true; - - if (NPC.Hitbox.Intersects(body.Hitbox)) - { - //If in idle/retract state, and fully retracted (aka colliding with body hitbox), fix position, so that direction changes wont have the talons move left/right - NPC.Center = body.Center + new Vector2(GetOffset(harvester), harvester.talonOffsetY); - NPC.velocity *= 0f; - NPC.netOffset = body.netOffset; - Idle = true; - return; - } - - float speed = 18f; //14f - if (NPC.life < NPC.lifeMax / 2) - { - speed += 3f; //3f - } - if (NPC.life < NPC.lifeMax / 4) - { - speed += 3f; //3f - } - if (body.life < body.lifeMax) - { - speed += 8f; //8f - } - - Vector2 toBody = body.Center - NPC.Center; - toBody.Y += harvester.talonOffsetY; - toBody.X += GetOffset(harvester); - - float betweenSelfAndBodyX = body.Center.X - NPC.Center.X; - float betweenSelfAndBodyY = body.Center.Y - NPC.Center.Y; - betweenSelfAndBodyY -= -harvester.talonOffsetY; - betweenSelfAndBodyX += GetOffset(harvester); - float len = (float)Math.Sqrt(betweenSelfAndBodyX * betweenSelfAndBodyX + betweenSelfAndBodyY * betweenSelfAndBodyY); - float somevar = 12f; - if (len < somevar + speed && harvester.AI_State == Harvester.State_Bombing) - { - RetractCounter = 0f; - NPC.velocity.X = betweenSelfAndBodyX; - NPC.velocity.Y = betweenSelfAndBodyY; - //Handled by harvester - /* + NPC.boss = true; //TODO Why is it true? + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.width = 40; //38 //latest 40 + NPC.height = 42; //42//latest 30 + NPC.aiStyle = -1; + NPC.damage = Harvester.talonDamage; + NPC.defense = 28; + NPC.lifeMax = 1337; + NPC.scale = 1f; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.alpha = 255; + NPC.dontTakeDamage = true; + NPC.dontCountMe = true; + NPC.SpawnWithHigherTime(30); + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + //float bossAdjustment = 1f; + //if (Main.GameModeInfo.IsMasterMode) + //{ + // bossAdjustment = 0.85f; + //} + //NPC.lifeMax = (int)(NPC.lifeMax * 1.3f * bossLifeScale * bossAdjustment); + NPC.lifeMax = 1337; + NPC.damage = (int)(NPC.damage * 1.1f); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + return false; + } + + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (!HasParent) + { + return; + } + + NPC body = Main.npc[ParentWhoAmI]; + Harvester harvester = null; + + if (body.ModNPC is Harvester h) + { + harvester = h; + if (h.AI_State != Harvester.State_Bombing) + { + return; + } + } + + if (harvester == null) + { + return; + } + + Vector2 center = NPC.Center; + float x = body.Center.X - center.X; + float y = body.Center.Y - center.Y; + y -= -harvester.talonOffsetY + 20f; //has to result to 7f + + x += GetOffset(harvester); //66f, -70f + x += NPC.spriteDirection * (Harvester.talonDirectionalOffset + 6); + + SpriteEffects effect = (NPC.spriteDirection == 1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Texture2D texture = ChainAsset.Value; + bool keepDrawing = true; + int step = 0; + while (keepDrawing) + { + step++; + float len = (float)Math.Sqrt(x * x + y * y); + float between = 38f; + if (len < between) //16 + { + keepDrawing = false; + } + else + { + len = between / len; //16 + x *= len; + y *= len; + center.X += x; + center.Y += y; + x = body.Center.X - center.X; + y = body.Center.Y - center.Y; + y -= -harvester.talonOffsetY + 20f; + x += GetOffset(harvester); + x += NPC.spriteDirection * (Harvester.talonDirectionalOffset + 0); + + if (Main.rand.NextBool(8)) + { + Dust dust = Dust.NewDustPerfect(center, 135, new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-3f, 3f)), 26, new Color(255, 255, 255), Main.rand.NextFloat(1f, 1.6f)); + dust.noLight = true; + dust.noGravity = true; + dust.fadeIn = Main.rand.NextFloat(0.5f, 1.5f); + } + + int frameY = (((int)NPC.frameCounter / ChainFrameSpeed) + step) % ChainFrameCount; + Rectangle frame = texture.Frame(1, ChainFrameCount, frameY: frameY); + spriteBatch.Draw(texture, center - screenPos + new Vector2(0f, NPC.gfxOffY + NPC.height / 2), frame, Color.White * NPC.Opacity, 0f, frame.Size() / 2, 1f, effect, 0f); + } + } + + texture = TextureAssets.Npc[NPC.type].Value; + spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, NPC.GetAlpha(drawColor), 0f, texture.Size() / 2, 1f, effect, 0f); + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Slow, 120, false); //2 seconds, 100% chance + } + + public const float State_Seek_Retract = 0f; + public const float State_Punch = 1f; + public const float State_Punching = 2f; + + public ref float AI_State => ref NPC.ai[0]; + + public ref float AI_Timer => ref NPC.ai[1]; + + public ref float RetractCounter => ref NPC.ai[2]; + + public int ParentWhoAmI + { + get => (int)NPC.ai[3] - 1; + set => NPC.ai[3] = value + 1; + } + + public bool HasParent => ParentWhoAmI >= 0 && ParentWhoAmI < Main.maxNPCs; + + public bool Idle + { + get => NPC.localAI[0] == 0f; + set => NPC.localAI[0] = value ? 0f : 1f; + } + + public override bool CheckDead() + { + NPC.boss = false; //To get rid of the default death message + return base.CheckDead(); + } + + public override void FindFrame(int frameHeight) + { + //Used just for chain anim + NPC.frameCounter++; + } + + public override void AI() + { + if (!HasParent) + { + NPC.life = 0; + NPC.active = false; + NPC.netUpdate = true; + return; + } + + NPC body = Main.npc[ParentWhoAmI]; + if (!body.active || body.type != AssortedCrazyThings.harvester) + { + NPC.life = 0; + NPC.active = false; + NPC.netUpdate = true; + return; + } + + Harvester harvester = body.ModNPC as Harvester; + + NPC.target = body.target; + if (NPC.target < 0 || NPC.target >= Main.maxPlayers) return; + Player target = Main.player[NPC.target]; + + NPC.gfxOffY = body.gfxOffY; + NPC.spriteDirection = body.spriteDirection; + NPC.direction = body.direction; + NPC.alpha = body.alpha; + + //TODO has unused tile collision code and manual retract detection (fallback) + + if (NPC.alpha > 0) + { + //NPC.alpha -= 5; + //if (NPC.alpha < 4) + //{ + // NPC.alpha = 0; + // NPC.netUpdate = true; + //} + NPC.scale = 1f; + AI_Timer = 0f; + } + + if (AI_State != State_Seek_Retract) + { + Idle = false; + } + + if (AI_State == State_Seek_Retract) + { + //NPC.noTileCollide = true; + + if (NPC.Hitbox.Intersects(body.Hitbox)) + { + //If in idle/retract state, and fully retracted (aka colliding with body hitbox), fix position, so that direction changes wont have the talons move left/right + NPC.Center = body.Center + new Vector2(GetOffset(harvester), harvester.talonOffsetY); + NPC.velocity *= 0f; + NPC.netOffset = body.netOffset; + Idle = true; + return; + } + + float speed = 18f; //14f + if (NPC.life < NPC.lifeMax / 2) + { + speed += 3f; //3f + } + if (NPC.life < NPC.lifeMax / 4) + { + speed += 3f; //3f + } + if (body.life < body.lifeMax) + { + speed += 8f; //8f + } + + Vector2 toBody = body.Center - NPC.Center; + toBody.Y += harvester.talonOffsetY; + toBody.X += GetOffset(harvester); + + float betweenSelfAndBodyX = body.Center.X - NPC.Center.X; + float betweenSelfAndBodyY = body.Center.Y - NPC.Center.Y; + betweenSelfAndBodyY -= -harvester.talonOffsetY; + betweenSelfAndBodyX += GetOffset(harvester); + float len = (float)Math.Sqrt(betweenSelfAndBodyX * betweenSelfAndBodyX + betweenSelfAndBodyY * betweenSelfAndBodyY); + float somevar = 12f; + if (len < somevar + speed && harvester.AI_State == Harvester.State_Bombing) + { + RetractCounter = 0f; + NPC.velocity.X = betweenSelfAndBodyX; + NPC.velocity.Y = betweenSelfAndBodyY; + //Handled by harvester + /* AI_Timer += 1f; //new if (body.life < body.lifeMax / 2) @@ -375,124 +375,124 @@ public override void AI() } } */ - } - else //retract - { - //new - RetractCounter += 1f; - float retractFactor = 0.5f + RetractCounter / 100f; - if (body.life < body.lifeMax / 2) - { - retractFactor += 0.25f; - } - if (body.life < body.lifeMax / 4) - { - retractFactor += 0.25f; - } - - //Also scale retract speed with velocity - float velo = body.velocity.Length(); - - retractFactor += velo / 80f; - - //end new - - if (len > speed) - { - len = speed / len; - } - NPC.velocity.X = betweenSelfAndBodyX * len * retractFactor; //both 1f - NPC.velocity.Y = betweenSelfAndBodyY * len * retractFactor; - } - } - else if (AI_State == State_Punch) - { - //Punch toward moving direction diagonally - //NPC.noTileCollide = true; - NPC.collideX = false; - NPC.collideY = false; - float speed = 17f; - //new - if (body.life <= body.lifeMax / 2) - { - speed += 2f; - } - if (body.life <= body.lifeMax / 4) - { - speed += 4f; - } - Vector2 directionTo = new Vector2(NPC.direction, 1f); //1/1 ratio - directionTo.Normalize(); - - NPC.velocity = directionTo * speed; - AI_State = State_Punching; - } - else if (AI_State == State_Punching) - { - //fly through air/whatever and check if it hit tiles - //fist has 40 width 30 height - //talon has 38 width 42 height - //if (Math.Abs(NPC.velocity.X) > Math.Abs(NPC.velocity.Y)) - //{ - // if (NPC.velocity.X > 0f && NPC.Center.X > target.Center.X) - // { - // NPC.noTileCollide = false; - // } - // if (NPC.velocity.X < 0f && NPC.Center.X < target.Center.X) - // { - // NPC.noTileCollide = false; - // } - //} - //else - //{ - // if (NPC.velocity.Y > 0f && NPC.Center.Y > target.Center.Y) - // { - // NPC.noTileCollide = false; - // } - // if (NPC.velocity.Y < 0f && NPC.Center.Y < target.Center.Y) - // { - // NPC.noTileCollide = false; - // } - //} - - Vector2 toBody = body.Center + body.velocity - NPC.Center; - toBody.Y += harvester.talonOffsetY; - toBody.X += GetOffset(harvester); - float distSQ = toBody.LengthSquared(); - if (body.life < body.lifeMax) - { - NPC.knockBackResist = 0f; - if (distSQ > 700f * 700f /*|| NPC.collideX || NPC.collideY || Collision.SolidCollision(NPC.position, NPC.width, NPC.height + 8)*/) //if collides with tiles or far away, go back to 0 and do the retreat code - { - //NPC.noTileCollide = true; - NPC.netUpdate = true; - AI_State = State_Seek_Retract; - } - } - else - { - if ((distSQ > 600f * 600f /*|| NPC.collideX || NPC.collideY || Collision.SolidCollision(NPC.position, NPC.width, NPC.height + 8)*/) | NPC.justHit) - { - //NPC.noTileCollide = true; - NPC.netUpdate = true; - AI_State = State_Seek_Retract; - } - } - } - } - - private float GetOffset(Harvester harvester) - { - return RightTalon ? harvester.talonOffsetRightX : harvester.talonOffsetLeftX; - } - } - - public class HarvesterTalonLeft : HarvesterTalon - { - } - - public class HarvesterTalonRight : HarvesterTalon - { - public override bool RightTalon => true; - } + } + else //retract + { + //new + RetractCounter += 1f; + float retractFactor = 0.5f + RetractCounter / 100f; + if (body.life < body.lifeMax / 2) + { + retractFactor += 0.25f; + } + if (body.life < body.lifeMax / 4) + { + retractFactor += 0.25f; + } + + //Also scale retract speed with velocity + float velo = body.velocity.Length(); + + retractFactor += velo / 80f; + + //end new + + if (len > speed) + { + len = speed / len; + } + NPC.velocity.X = betweenSelfAndBodyX * len * retractFactor; //both 1f + NPC.velocity.Y = betweenSelfAndBodyY * len * retractFactor; + } + } + else if (AI_State == State_Punch) + { + //Punch toward moving direction diagonally + //NPC.noTileCollide = true; + NPC.collideX = false; + NPC.collideY = false; + float speed = 17f; + //new + if (body.life <= body.lifeMax / 2) + { + speed += 2f; + } + if (body.life <= body.lifeMax / 4) + { + speed += 4f; + } + Vector2 directionTo = new Vector2(NPC.direction, 1f); //1/1 ratio + directionTo.Normalize(); + + NPC.velocity = directionTo * speed; + AI_State = State_Punching; + } + else if (AI_State == State_Punching) + { + //fly through air/whatever and check if it hit tiles + //fist has 40 width 30 height + //talon has 38 width 42 height + //if (Math.Abs(NPC.velocity.X) > Math.Abs(NPC.velocity.Y)) + //{ + // if (NPC.velocity.X > 0f && NPC.Center.X > target.Center.X) + // { + // NPC.noTileCollide = false; + // } + // if (NPC.velocity.X < 0f && NPC.Center.X < target.Center.X) + // { + // NPC.noTileCollide = false; + // } + //} + //else + //{ + // if (NPC.velocity.Y > 0f && NPC.Center.Y > target.Center.Y) + // { + // NPC.noTileCollide = false; + // } + // if (NPC.velocity.Y < 0f && NPC.Center.Y < target.Center.Y) + // { + // NPC.noTileCollide = false; + // } + //} + + Vector2 toBody = body.Center + body.velocity - NPC.Center; + toBody.Y += harvester.talonOffsetY; + toBody.X += GetOffset(harvester); + float distSQ = toBody.LengthSquared(); + if (body.life < body.lifeMax) + { + NPC.knockBackResist = 0f; + if (distSQ > 700f * 700f /*|| NPC.collideX || NPC.collideY || Collision.SolidCollision(NPC.position, NPC.width, NPC.height + 8)*/) //if collides with tiles or far away, go back to 0 and do the retreat code + { + //NPC.noTileCollide = true; + NPC.netUpdate = true; + AI_State = State_Seek_Retract; + } + } + else + { + if ((distSQ > 600f * 600f /*|| NPC.collideX || NPC.collideY || Collision.SolidCollision(NPC.position, NPC.width, NPC.height + 8)*/) | NPC.justHit) + { + //NPC.noTileCollide = true; + NPC.netUpdate = true; + AI_State = State_Seek_Retract; + } + } + } + } + + private float GetOffset(Harvester harvester) + { + return RightTalon ? harvester.talonOffsetRightX : harvester.talonOffsetLeftX; + } + } + + public class HarvesterTalonLeft : HarvesterTalon + { + } + + public class HarvesterTalonRight : HarvesterTalon + { + public override bool RightTalon => true; + } } diff --git a/NPCs/FairySlime.cs b/NPCs/FairySlime.cs index e94a1932..fb972bc5 100644 --- a/NPCs/FairySlime.cs +++ b/NPCs/FairySlime.cs @@ -9,85 +9,85 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.FriendlyNPCs)] - public class FairySlime : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Fairy Slime"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - } + [Content(ContentType.FriendlyNPCs)] + public class FairySlime : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fairy Slime"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 34; - NPC.height = 30; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 25; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 25f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.friendly = true; - NPC.dontTakeDamageFromHostiles = true; - NPC.alpha = 175; - NPC.color = new Color(213, 196, 197, 100); - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 34; + NPC.height = 30; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 25; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 25f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.friendly = true; + NPC.dontTakeDamageFromHostiles = true; + NPC.alpha = 175; + NPC.color = new Color(213, 196, 197, 100); + NPC.catchItem = (short)ModContent.ItemType(); + } - public override bool? CanBeHitByItem(Player player, Item item) - { - return null; //TODO NPC return true - } + public override bool? CanBeHitByItem(Player player, Item item) + { + return null; //TODO NPC return true + } - public override bool? CanBeHitByProjectile(Projectile projectile) - { - return !projectile.minion; - } + public override bool? CanBeHitByProjectile(Projectile projectile) + { + return !projectile.minion; + } - public override void HitEffect(int hitDirection, double damage) - { - Color color = NPC.color; - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); - } - } - else - { - for (int i = 0; i < 40; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Color color = NPC.color; + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); + } + } + else + { + for (int i = 0; i < 40; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.OverworldHallow.Chance * 0.015f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.OverworldHallow.Chance * 0.015f; + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - //quickUnlock: true so only 1 kill is required to list everything about it - bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + //quickUnlock: true so only 1 kill is required to list everything about it + bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheHallow, - new FlavorTextBestiaryInfoElement("Not wanting to lose to its flying neighbors, it has grown wing-like extentions. It can't fly, but it's happy regardless of this fact.") - }); - } + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheHallow, + new FlavorTextBestiaryInfoElement("Not wanting to lose to its flying neighbors, it has grown wing-like extentions. It can't fly, but it's happy regardless of this fact.") + }); + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); - } - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); + } + } } diff --git a/NPCs/GeneralGlobalNPC.cs b/NPCs/GeneralGlobalNPC.cs index b4859911..6670f3f8 100644 --- a/NPCs/GeneralGlobalNPC.cs +++ b/NPCs/GeneralGlobalNPC.cs @@ -11,82 +11,82 @@ namespace AssortedCrazyThings.NPCs { - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - public class GeneralGlobalNPC : AssGlobalNPC - { - public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) - { - if (ContentConfig.Instance.Weapons) - { - //TODO convert this to a proper drop rule, see OnKill - if (npc.type == NPCID.TheDestroyer) - { - LeadingConditionRule neverDropsRule = new LeadingConditionRule(new NotAllDronePartsUnlockedCondition()); - neverDropsRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType())); - npcLoot.Add(neverDropsRule); - } - } - } + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + public class GeneralGlobalNPC : AssGlobalNPC + { + public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) + { + if (ContentConfig.Instance.Weapons) + { + //TODO convert this to a proper drop rule, see OnKill + if (npc.type == NPCID.TheDestroyer) + { + LeadingConditionRule neverDropsRule = new LeadingConditionRule(new NotAllDronePartsUnlockedCondition()); + neverDropsRule.OnSuccess(ItemDropRule.Common(ModContent.ItemType())); + npcLoot.Add(neverDropsRule); + } + } + } - public override void OnKill(NPC npc) - { - if (ContentConfig.Instance.Weapons) - { - if (npc.type == NPCID.TheDestroyer) - { - AssUtils.DropItemInstanced(npc, npc.Center, npc.Size, ModContent.ItemType(), - condition: delegate (NPC n, Player player) - { - return !DroneController.AllUnlocked(player); - }); - } - } + public override void OnKill(NPC npc) + { + if (ContentConfig.Instance.Weapons) + { + if (npc.type == NPCID.TheDestroyer) + { + AssUtils.DropItemInstanced(npc, npc.Center, npc.Size, ModContent.ItemType(), + condition: delegate (NPC n, Player player) + { + return !DroneController.AllUnlocked(player); + }); + } + } - GitgudData.Reset(npc); + GitgudData.Reset(npc); - if (npc.boss) - { - for (int i = 0; i < npc.playerInteraction.Length; i++) - { - if (!npc.playerInteraction[i]) - { - continue; - } + if (npc.boss) + { + for (int i = 0; i < npc.playerInteraction.Length; i++) + { + if (!npc.playerInteraction[i]) + { + continue; + } - Player player = Main.player[i]; + Player player = Main.player[i]; - if (!player.active) - { - continue; - } + if (!player.active) + { + continue; + } - player.GetModPlayer().SlainBoss(npc.type); - } - } - } + player.GetModPlayer().SlainBoss(npc.type); + } + } + } - public override void SetupShop(int type, Chest shop, ref int nextSlot) - { - if (ContentConfig.Instance.PlaceablesFunctional && type == NPCID.PartyGirl && NPC.downedSlimeKing) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - } - } + public override void SetupShop(int type, Chest shop, ref int nextSlot) + { + if (ContentConfig.Instance.PlaceablesFunctional && type == NPCID.PartyGirl && NPC.downedSlimeKing) + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + } + } - public override void SetupTravelShop(int[] shop, ref int nextSlot) - { - if (ContentConfig.Instance.OtherPets && Main.rand.NextBool(10)) - { - shop[nextSlot] = ModContent.ItemType(); - nextSlot++; - } + public override void SetupTravelShop(int[] shop, ref int nextSlot) + { + if (ContentConfig.Instance.OtherPets && Main.rand.NextBool(10)) + { + shop[nextSlot] = ModContent.ItemType(); + nextSlot++; + } - if (ContentConfig.Instance.OtherPets && Main.rand.NextBool(10)) - { - shop[nextSlot] = ModContent.ItemType(); - nextSlot++; - } - } - } + if (ContentConfig.Instance.OtherPets && Main.rand.NextBool(10)) + { + shop[nextSlot] = ModContent.ItemType(); + nextSlot++; + } + } + } } diff --git a/NPCs/GiantGrasshopper.cs b/NPCs/GiantGrasshopper.cs index f66970bc..c523ce77 100644 --- a/NPCs/GiantGrasshopper.cs +++ b/NPCs/GiantGrasshopper.cs @@ -1,4 +1,3 @@ -using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.Bestiary; @@ -9,79 +8,79 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.FriendlyNPCs)] - public class GiantGrasshopper : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Giant Grasshopper"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Derpling]; + [Content(ContentType.FriendlyNPCs)] + public class GiantGrasshopper : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Giant Grasshopper"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Derpling]; - NPCID.Sets.DebuffImmunitySets.Add(NPC.type, new NPCDebuffImmunityData - { - SpecificallyImmuneTo = new int[1] { - BuffID.Confused - } - }); + NPCID.Sets.DebuffImmunitySets.Add(NPC.type, new NPCDebuffImmunityData + { + SpecificallyImmuneTo = new int[1] { + BuffID.Confused + } + }); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - Frame = 0 - }; - NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; - } + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + Frame = 0 + }; + NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; + } - public override void SetDefaults() - { - NPC.width = 58; - NPC.height = 32; - NPC.damage = 1; - NPC.defense = 0; - NPC.lifeMax = 5; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath4; - NPC.value = 60f; - NPC.knockBackResist = 0.5f; - NPC.aiStyle = 41; - AIType = NPCID.Derpling; - AnimationType = NPCID.Derpling; - } + public override void SetDefaults() + { + NPC.width = 58; + NPC.height = 32; + NPC.damage = 1; + NPC.defense = 0; + NPC.lifeMax = 5; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath4; + NPC.value = 60f; + NPC.knockBackResist = 0.5f; + NPC.aiStyle = 41; + AIType = NPCID.Derpling; + AnimationType = NPCID.Derpling; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.OverworldDaySlime.Chance * 0.01f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.OverworldDaySlime.Chance * 0.01f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Grasshopper)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Grasshopper)); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("It can leap over entire bushes in a single bound.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("It can leap over entire bushes in a single bound.") + }); + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life <= 0) - { - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_01").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_02").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_02").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_03").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_03").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_03").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_03").Type, 1f); - } - } - } + if (NPC.life <= 0) + { + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_01").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_02").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_02").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_03").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_03").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_03").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGrasshopperGore_03").Type, 1f); + } + } + } } diff --git a/NPCs/GiantGrasshopperGold.cs b/NPCs/GiantGrasshopperGold.cs index 65bc2aa1..d289ca94 100644 --- a/NPCs/GiantGrasshopperGold.cs +++ b/NPCs/GiantGrasshopperGold.cs @@ -8,86 +8,86 @@ namespace AssortedCrazyThings.NPCs { - //TODO look into - //NPCID.Sets.GoldCrittersCollection - //NPCID.Sets.NormalGoldCritterBestiaryPriority - //bestiaryEntry.UIInfoProvider = new GoldCritterUICollectionInfoProvider - public class GiantGrasshopperGold : GiantGrasshopper - { - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.OverworldDaySlime.Chance * 0.001f; - } + //TODO look into + //NPCID.Sets.GoldCrittersCollection + //NPCID.Sets.NormalGoldCritterBestiaryPriority + //bestiaryEntry.UIInfoProvider = new GoldCritterUICollectionInfoProvider + public class GiantGrasshopperGold : GiantGrasshopper + { + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.OverworldDaySlime.Chance * 0.001f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.GoldGrasshopper)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.GoldGrasshopper)); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - //quickUnlock: true so only 1 kill is required to list everything about it - bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + //quickUnlock: true so only 1 kill is required to list everything about it + bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("Rarely, critters are found coated entirely in gold! Shopkeepers will pay handsomely for these, or you can show them off in cages!") //Vanilla text for most gold critters + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("Rarely, critters are found coated entirely in gold! Shopkeepers will pay handsomely for these, or you can show them off in cages!") //Vanilla text for most gold critters }); - } + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life > 0) - { - for (int i = 0; i < 10; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.Next(232, 234), hitDirection, -1f); - } - } - else - { - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_01").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_02").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_02").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_03").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_03").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_03").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_03").Type, 1f); - for (int i = 0; i < 20; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.Next(232, 234), 2 * hitDirection, -2f); - } - } - } + if (NPC.life > 0) + { + for (int i = 0; i < 10; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.Next(232, 234), hitDirection, -1f); + } + } + else + { + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_01").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_02").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_02").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_03").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_03").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_03").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("GiantGoldenGrasshopperGore_03").Type, 1f); + for (int i = 0; i < 20; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.Next(232, 234), 2 * hitDirection, -2f); + } + } + } - public override void PostAI() - { - //using Microsoft.Xna.Framework; - //change the NPC. to Projectile. if you port this to pets - Color color = Lighting.GetColor((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16); - if (color.R > 20 || color.B > 20 || color.G > 20) - { - int num = color.R; - if (color.G > num) - { - num = color.G; - } - if (color.B > num) - { - num = color.B; - } - num /= 30; - if (Main.rand.Next(300) < num) - { - Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 43, 0f, 0f, 254, new Color(255, 255, 0), 0.5f); - dust.velocity *= 0f; - } - } - } - } + public override void PostAI() + { + //using Microsoft.Xna.Framework; + //change the NPC. to Projectile. if you port this to pets + Color color = Lighting.GetColor((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16); + if (color.R > 20 || color.B > 20 || color.G > 20) + { + int num = color.R; + if (color.G > num) + { + num = color.G; + } + if (color.B > num) + { + num = color.B; + } + num /= 30; + if (Main.rand.Next(300) < num) + { + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 43, 0f, 0f, 254, new Color(255, 255, 0), 0.5f); + dust.velocity *= 0f; + } + } + } + } } diff --git a/NPCs/HarvesterGlobalNPC.cs b/NPCs/HarvesterGlobalNPC.cs index ce335694..10677ae7 100644 --- a/NPCs/HarvesterGlobalNPC.cs +++ b/NPCs/HarvesterGlobalNPC.cs @@ -1,5 +1,3 @@ -using AssortedCrazyThings.Base; -using AssortedCrazyThings.Items; using AssortedCrazyThings.NPCs.DungeonBird; using Terraria; using Terraria.ID; @@ -7,34 +5,34 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.Bosses)] - public class HarvesterGlobalNPC : AssGlobalNPC - { - public bool shouldSoulDrop = false; + [Content(ContentType.Bosses)] + public class HarvesterGlobalNPC : AssGlobalNPC + { + public bool shouldSoulDrop = false; - public override bool InstancePerEntity => true; + public override bool InstancePerEntity => true; - public override void ResetEffects(NPC npc) - { - shouldSoulDrop = false; - } + public override void ResetEffects(NPC npc) + { + shouldSoulDrop = false; + } - public override void OnKill(NPC npc) - { - //Soul spawn from dead enemies while harvester alive - if (shouldSoulDrop) - { - int soulType = ModContent.NPCType(); - if (npc.type != soulType) - { - //NewNPC starts looking for the first !active from 0 to 200 - int soulID = NPC.NewNPC(npc.GetSpawnSource_NPCHurt(), (int)npc.Center.X, (int)npc.Top.Y + DungeonSoulBase.hei / 2, soulType); - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, soulID); - } - } - } - } - } + public override void OnKill(NPC npc) + { + //Soul spawn from dead enemies while harvester alive + if (shouldSoulDrop) + { + int soulType = ModContent.NPCType(); + if (npc.type != soulType) + { + //NewNPC starts looking for the first !active from 0 to 200 + int soulID = NPC.NewNPC(npc.GetSpawnSource_NPCHurt(), (int)npc.Center.X, (int)npc.Top.Y + DungeonSoulBase.hei / 2, soulType); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, soulID); + } + } + } + } + } } diff --git a/NPCs/HornedSlime.cs b/NPCs/HornedSlime.cs index 8c299673..e436f999 100644 --- a/NPCs/HornedSlime.cs +++ b/NPCs/HornedSlime.cs @@ -9,71 +9,71 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class HornedSlime : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Horned Slime"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - } + [Content(ContentType.HostileNPCs)] + public class HornedSlime : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Horned Slime"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 36; - NPC.height = 32; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 25; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 25f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.alpha = 175; - NPC.color = new Color(240, 54, 115, 100); - NPC.catchItem = (short)ModContent.ItemType(); - NPC.lavaImmune = true; - } + public override void SetDefaults() + { + NPC.width = 36; + NPC.height = 32; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 25; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 25f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.alpha = 175; + NPC.color = new Color(240, 54, 115, 100); + NPC.catchItem = (short)ModContent.ItemType(); + NPC.lavaImmune = true; + } - public override void HitEffect(int hitDirection, double damage) - { - Color color = NPC.color; - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); - } - } - else - { - for (int i = 0; i < 40; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Color color = NPC.color; + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); + } + } + else + { + for (int i = 0; i < 40; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.Underworld.Chance * 0.015f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.Underworld.Chance * 0.015f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheUnderworld, - new FlavorTextBestiaryInfoElement("The horn isn't just for decoration; it is capable of dispersing heat, allowing the slime to remain gelatinous.") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheUnderworld, + new FlavorTextBestiaryInfoElement("The horn isn't just for decoration; it is capable of dispersing heat, allowing the slime to remain gelatinous.") + }); + } + } } diff --git a/NPCs/JoyousSlime.cs b/NPCs/JoyousSlime.cs index 49f94944..7b8775d0 100644 --- a/NPCs/JoyousSlime.cs +++ b/NPCs/JoyousSlime.cs @@ -9,85 +9,85 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.FriendlyNPCs)] - public class JoyousSlime : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Joyous Slime"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - } + [Content(ContentType.FriendlyNPCs)] + public class JoyousSlime : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Joyous Slime"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 36; - NPC.height = 32; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 25; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 25f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.friendly = true; - NPC.dontTakeDamageFromHostiles = true; - NPC.alpha = 175; - NPC.color = new Color(169, 141, 255, 100); - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 36; + NPC.height = 32; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 25; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 25f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.friendly = true; + NPC.dontTakeDamageFromHostiles = true; + NPC.alpha = 175; + NPC.color = new Color(169, 141, 255, 100); + NPC.catchItem = (short)ModContent.ItemType(); + } - public override bool? CanBeHitByItem(Player player, Item item) - { - return null; //TODO NPC return true - } + public override bool? CanBeHitByItem(Player player, Item item) + { + return null; //TODO NPC return true + } - public override bool? CanBeHitByProjectile(Projectile projectile) - { - return !projectile.minion; - } + public override bool? CanBeHitByProjectile(Projectile projectile) + { + return !projectile.minion; + } - public override void HitEffect(int hitDirection, double damage) - { - Color color = NPC.color; - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); - } - } - else - { - for (int i = 0; i < 40; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Color color = NPC.color; + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); + } + } + else + { + for (int i = 0; i < 40; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.OverworldDay.Chance * 0.015f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.OverworldDay.Chance * 0.015f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - //quickUnlock: true so only 1 kill is required to list everything about it - bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + //quickUnlock: true so only 1 kill is required to list everything about it + bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("A passive variant of slime with a friendly face. At night, it tries to be close to an equally friendly face.") - }); - } - } + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("A passive variant of slime with a friendly face. At night, it tries to be close to an equally friendly face.") + }); + } + } } diff --git a/NPCs/Meatball.cs b/NPCs/Meatball.cs index ab6dadfe..19a1d50f 100644 --- a/NPCs/Meatball.cs +++ b/NPCs/Meatball.cs @@ -8,80 +8,80 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class Meatball : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Meatball"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - } + [Content(ContentType.HostileNPCs)] + public class Meatball : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Meatball"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 36; - NPC.height = 26; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 20; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 20f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 36; + NPC.height = 26; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 20; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 20f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.catchItem = (short)ModContent.ItemType(); + } - public override void HitEffect(int hitDirection, double damage) - { - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, hitDirection, -1f); - } - } - else - { - for (int i = 0; i < 30; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 2 * hitDirection, -1f); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, hitDirection, -1f); + } + } + else + { + for (int i = 0; i < 30; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 2 * hitDirection, -1f); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (Main.hardMode) return SpawnCondition.Crimson.Chance * 0.04f; - return SpawnCondition.Crimson.Chance * 0.15f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (Main.hardMode) return SpawnCondition.Crimson.Chance * 0.04f; + return SpawnCondition.Crimson.Chance * 0.15f; + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCrimson, - new FlavorTextBestiaryInfoElement("A mass of bloody flesh with a single eye. The eye appears to be struggling in an attempt to escape.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCrimson, + new FlavorTextBestiaryInfoElement("A mass of bloody flesh with a single eye. The eye appears to be struggling in an attempt to escape.") + }); + } - public override void OnKill() - { - if (Main.rand.NextBool(10)) - { - int i = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)NPC.position.X, (int)NPC.position.Y - 16, ModContent.NPCType()); - if (Main.netMode == NetmodeID.Server && i < Main.maxNPCs) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); - } - } - } + public override void OnKill() + { + if (Main.rand.NextBool(10)) + { + int i = NPC.NewNPC(NPC.GetSpawnSource_NPCHurt(), (int)NPC.position.X, (int)NPC.position.Y - 16, ModContent.NPCType()); + if (Main.netMode == NetmodeID.Server && i < Main.maxNPCs) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); + } + } + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Vertebrae)); - } - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Vertebrae)); + } + } } diff --git a/NPCs/MeatballsEye.cs b/NPCs/MeatballsEye.cs index 9d06e2c1..ef6b832d 100644 --- a/NPCs/MeatballsEye.cs +++ b/NPCs/MeatballsEye.cs @@ -4,28 +4,28 @@ namespace AssortedCrazyThings.NPCs { - public class MeatballsEye : ChunkysMeatballsEyeBase - { - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); + public class MeatballsEye : ChunkysMeatballsEyeBase + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); - DisplayName.SetDefault("Meatball's Eye"); - } + DisplayName.SetDefault("Meatball's Eye"); + } - public override void SetDefaults() - { - base.SetDefaults(); + public override void SetDefaults() + { + base.SetDefaults(); - NPC.catchItem = (short)ModContent.ItemType(); - } + NPC.catchItem = (short)ModContent.ItemType(); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCrimson, - new FlavorTextBestiaryInfoElement("A minion of Cthulhu that was trapped in the Crimson. It hastily seeks out its older brother.") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheCrimson, + new FlavorTextBestiaryInfoElement("A minion of Cthulhu that was trapped in the Crimson. It hastily seeks out its older brother.") + }); + } + } } diff --git a/NPCs/Megalodon.cs b/NPCs/Megalodon.cs index 0c4a6c25..e55ffc36 100644 --- a/NPCs/Megalodon.cs +++ b/NPCs/Megalodon.cs @@ -9,90 +9,90 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class Megalodon : AssNPC - { - public static string name = "Megalodon"; - public static string message = "A Megalodon is approaching! Get out of the ocean!"; + [Content(ContentType.HostileNPCs)] + public class Megalodon : AssNPC + { + public static string name = "Megalodon"; + public static string message = "A Megalodon is approaching! Get out of the ocean!"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault(name); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Shark]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault(name); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Shark]; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - Position = new Vector2(66, 9f), //Position on the icon - PortraitPositionXOverride = 0, //Position on the portrait when clicked on - PortraitPositionYOverride = 9f, - IsWet = true - }; - NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; - } + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + Position = new Vector2(66, 9f), //Position on the icon + PortraitPositionXOverride = 0, //Position on the portrait when clicked on + PortraitPositionYOverride = 9f, + IsWet = true + }; + NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; + } - public override void SetDefaults() - { - NPC.width = 150; - NPC.height = 52; - NPC.damage = 150; - NPC.defense = 50; - NPC.lifeMax = 1000; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 10000f; - NPC.knockBackResist = 0f; - NPC.aiStyle = 16; - AIType = NPCID.Shark; - AnimationType = NPCID.Shark; - NPC.noGravity = true; - } + public override void SetDefaults() + { + NPC.width = 150; + NPC.height = 52; + NPC.damage = 150; + NPC.defense = 50; + NPC.lifeMax = 1000; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 10000f; + NPC.knockBackResist = 0f; + NPC.aiStyle = 16; + AIType = NPCID.Shark; + AnimationType = NPCID.Shark; + NPC.noGravity = true; + } - public override void FindFrame(int frameHeight) - { - if (NPC.wet) - { - NPC.frameCounter -= 0.4; - } - } + public override void FindFrame(int frameHeight) + { + if (NPC.wet) + { + NPC.frameCounter -= 0.4; + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (!NPC.AnyNPCs(NPC.type)) - { - return SpawnCondition.Ocean.Chance * 0.0005f; - } - else return 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (!NPC.AnyNPCs(NPC.type)) + { + return SpawnCondition.Ocean.Chance * 0.0005f; + } + else return 0f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType())); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType())); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - //quickUnlock: true so only 1 kill is required to list everything about it - bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + //quickUnlock: true so only 1 kill is required to list everything about it + bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Ocean, - new FlavorTextBestiaryInfoElement("Thought to be extinct, this ancient predator is as long-lived as its endless hunger.") - }); - } + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Ocean, + new FlavorTextBestiaryInfoElement("Thought to be extinct, this ancient predator is as long-lived as its endless hunger.") + }); + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life <= 0) - { - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("MegalodonGore_0").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("MegalodonGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("MegalodonGore_2").Type, 1f); - } - } - } + if (NPC.life <= 0) + { + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("MegalodonGore_0").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("MegalodonGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("MegalodonGore_2").Type, 1f); + } + } + } } diff --git a/NPCs/OceanSlime.cs b/NPCs/OceanSlime.cs index 50991bf7..d382c03b 100644 --- a/NPCs/OceanSlime.cs +++ b/NPCs/OceanSlime.cs @@ -11,119 +11,119 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class OceanSlime : AssNPC - { - private const int TotalNumberOfThese = 4; + [Content(ContentType.HostileNPCs)] + public class OceanSlime : AssNPC + { + private const int TotalNumberOfThese = 4; - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/OceanSlime_0"; //use fixed texture - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/OceanSlime_0"; //use fixed texture + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ocean Slime"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ocean Slime"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 36; - NPC.height = 36; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 25; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 25f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 36; + NPC.height = 36; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 25; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 25f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.catchItem = (short)ModContent.ItemType(); + } - public override void HitEffect(int hitDirection, double damage) - { - Color color = AiTexture switch - { - 1 => new Color(217, 216, 255, 100), - 2 => new Color(98, 148, 143, 100), - 3 => new Color(254, 180, 246, 100), - _ => new Color(65, 193, 247, 100), - }; - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); - } - } - else - { - for (int i = 0; i < 40; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Color color = AiTexture switch + { + 1 => new Color(217, 216, 255, 100), + 2 => new Color(98, 148, 143, 100), + 3 => new Color(254, 180, 246, 100), + _ => new Color(65, 193, 247, 100), + }; + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); + } + } + else + { + for (int i = 0; i < 40; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.Ocean.Chance * 0.015f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.Ocean.Chance * 0.015f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 0), ItemID.Gel)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 1), ItemID.BlackInk)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 2), ItemID.SharkFin)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 3), ItemID.PinkGel)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 0), ItemID.Gel)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 1), ItemID.BlackInk)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 2), ItemID.SharkFin)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 3), ItemID.PinkGel)); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Ocean, - new FlavorTextBestiaryInfoElement("Slimes that are lost to the sea are faced with two options; adapt, or be eaten. Luckily, these slimes taste bad.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Ocean, + new FlavorTextBestiaryInfoElement("Slimes that are lost to the sea are faced with two options; adapt, or be eaten. Luckily, these slimes taste bad.") + }); + } - public ref float AiTexture => ref NPC.ai[1]; + public ref float AiTexture => ref NPC.ai[1]; - public bool DecidedAiTexture - { - get => NPC.localAI[0] == 1f; - set => NPC.localAI[0] = value ? 1f : 0f; - } + public bool DecidedAiTexture + { + get => NPC.localAI[0] == 1f; + set => NPC.localAI[0] = value ? 1f : 0f; + } - public override bool PreAI() - { - if (AiTexture == 0 && !DecidedAiTexture && Main.netMode != NetmodeID.MultiplayerClient) - { - AiTexture = Main.rand.Next(TotalNumberOfThese); + public override bool PreAI() + { + if (AiTexture == 0 && !DecidedAiTexture && Main.netMode != NetmodeID.MultiplayerClient) + { + AiTexture = Main.rand.Next(TotalNumberOfThese); - DecidedAiTexture = true; - NPC.netUpdate = true; - } + DecidedAiTexture = true; + NPC.netUpdate = true; + } - return true; - } + return true; + } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/OceanSlime_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/OceanSlime_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + } } diff --git a/NPCs/SpawnOfOcram.cs b/NPCs/SpawnOfOcram.cs index 8615ba97..b2ae7957 100644 --- a/NPCs/SpawnOfOcram.cs +++ b/NPCs/SpawnOfOcram.cs @@ -12,92 +12,92 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class SpawnOfOcram : AssNPC - { - public const string name = "Spawn of Ocram"; - public const string message = "Spawn of Ocram has appeared!"; + [Content(ContentType.HostileNPCs)] + public class SpawnOfOcram : AssNPC + { + public const string name = "Spawn of Ocram"; + public const string message = "Spawn of Ocram has appeared!"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault(name); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Corruptor]; - //same as chaos elemental, tho for npcs you still have to manually draw it (PreDraw()) - NPCID.Sets.TrailingMode[NPC.type] = 3; - NPCID.Sets.TrailCacheLength[NPC.type] = 8; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault(name); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Corruptor]; + //same as chaos elemental, tho for npcs you still have to manually draw it (PreDraw()) + NPCID.Sets.TrailingMode[NPC.type] = 3; + NPCID.Sets.TrailCacheLength[NPC.type] = 8; + } - public override void SetDefaults() - { - NPC.width = 92; - NPC.height = 66; - NPC.damage = 95; - NPC.defense = 40; - NPC.lifeMax = 4200; - NPC.HitSound = SoundID.NPCHit14; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 0f; - NPC.knockBackResist = 0f; - NPC.aiStyle = -1; //5 - //AIType = NPCID.Corruptor; - AnimationType = NPCID.Corruptor; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.buffImmune[BuffID.Confused] = true; - } + public override void SetDefaults() + { + NPC.width = 92; + NPC.height = 66; + NPC.damage = 95; + NPC.defense = 40; + NPC.lifeMax = 4200; + NPC.HitSound = SoundID.NPCHit14; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 0f; + NPC.knockBackResist = 0f; + NPC.aiStyle = -1; //5 + //AIType = NPCID.Corruptor; + AnimationType = NPCID.Corruptor; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.buffImmune[BuffID.Confused] = true; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (NPC.downedGolemBoss && !NPC.AnyNPCs(ModContent.NPCType())) - { - return SpawnCondition.OverworldNightMonster.Chance * 0.005f; - } - return 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (NPC.downedGolemBoss && !NPC.AnyNPCs(ModContent.NPCType())) + { + return SpawnCondition.OverworldNightMonster.Chance * 0.005f; + } + return 0f; + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Times.NightTime, - new FlavorTextBestiaryInfoElement("An ancient being's offspring, once thought to have been lost to time.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Times.NightTime, + new FlavorTextBestiaryInfoElement("An ancient being's offspring, once thought to have been lost to time.") + }); + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Emerald)); - npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 5)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Emerald)); + npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), chanceDenominator: 5)); + } - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } - if (NPC.life <= 0) - { - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("SpawnOfOcramGore_2").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("SpawnOfOcramGore_1").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("SpawnOfOcramGore_0").Type, 1f); - } - } + if (NPC.life <= 0) + { + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("SpawnOfOcramGore_2").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("SpawnOfOcramGore_1").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("SpawnOfOcramGore_0").Type, 1f); + } + } - public override Color? GetAlpha(Color drawColor) - { - return new Color - { - R = Utils.Clamp(drawColor.R, 100, 255), - G = Utils.Clamp(drawColor.G, 100, 255), - B = Utils.Clamp(drawColor.B, 100, 255), - A = 255 - }; - } + public override Color? GetAlpha(Color drawColor) + { + return new Color + { + R = Utils.Clamp(drawColor.R, 100, 255), + G = Utils.Clamp(drawColor.G, 100, 255), + B = Utils.Clamp(drawColor.B, 100, 255), + A = 255 + }; + } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - /*Replica of titanium armor effect (Shadow dodge) + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + /*Replica of titanium armor effect (Shadow dodge) Color color = npc.GetAlpha(drawColor) * (0.5f); Vector2 position4 = npc.position; Vector2 drawOrigin = new Vector2(Terraria.GameContent.TextureAssets.Npc[npc.type].Value.Width * 0.5f, npc.height * 0.5f); @@ -114,205 +114,205 @@ public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color d spriteBatch.Draw(Terraria.GameContent.TextureAssets.Npc[npc.type].Value, drawPos, new npc.frame, color, npc.rotation, drawOrigin, npc.scale, SpriteEffects.None, 0f); */ - Texture2D texture = TextureAssets.Npc[NPC.type].Value; + Texture2D texture = TextureAssets.Npc[NPC.type].Value; - Vector2 drawOrigin = new Vector2(Terraria.GameContent.TextureAssets.Npc[NPC.type].Value.Width * 0.5f, NPC.height * 0.5f); - //the higher the k, the older the position - //Length is implicitely set in TrailCacheLength up there - //start from half the length so the origninal sprite isnt super blurred - for (int k = (NPC.oldPos.Length / 3); k < NPC.oldPos.Length; k++) - { - Vector2 drawPos = NPC.oldPos[k] - screenPos + drawOrigin + new Vector2(0f, NPC.gfxOffY); - Color color = NPC.GetAlpha(drawColor) * ((float)(NPC.oldPos.Length - k) / (2f * NPC.oldPos.Length)); - spriteBatch.Draw(texture, drawPos, NPC.frame, color, NPC.oldRot[k], drawOrigin, NPC.scale, SpriteEffects.None, 0f); - } - return true; - } + Vector2 drawOrigin = new Vector2(Terraria.GameContent.TextureAssets.Npc[NPC.type].Value.Width * 0.5f, NPC.height * 0.5f); + //the higher the k, the older the position + //Length is implicitely set in TrailCacheLength up there + //start from half the length so the origninal sprite isnt super blurred + for (int k = (NPC.oldPos.Length / 3); k < NPC.oldPos.Length; k++) + { + Vector2 drawPos = NPC.oldPos[k] - screenPos + drawOrigin + new Vector2(0f, NPC.gfxOffY); + Color color = NPC.GetAlpha(drawColor) * ((float)(NPC.oldPos.Length - k) / (2f * NPC.oldPos.Length)); + spriteBatch.Draw(texture, drawPos, NPC.frame, color, NPC.oldRot[k], drawOrigin, NPC.scale, SpriteEffects.None, 0f); + } + return true; + } - public ref float Timer => ref NPC.ai[0]; + public ref float Timer => ref NPC.ai[0]; - public ref float AttackTimer => ref NPC.localAI[0]; + public ref float AttackTimer => ref NPC.localAI[0]; - //Adapted from Vanilla, NPC type 94 Corruptor, AI type 5 - public override void AI() - { - if (NPC.target < 0 || NPC.target == 255 || Main.player[NPC.target].dead) - { - NPC.TargetClosest(); - } - Player player = Main.player[NPC.target]; + //Adapted from Vanilla, NPC type 94 Corruptor, AI type 5 + public override void AI() + { + if (NPC.target < 0 || NPC.target == 255 || Main.player[NPC.target].dead) + { + NPC.TargetClosest(); + } + Player player = Main.player[NPC.target]; - float num2 = 0.022f; - if (player.dead) - { - NPC.velocity.Y -= num2 * 2f; - if (NPC.timeLeft > 10) - { - NPC.timeLeft = 10; - return; - } - } + float num2 = 0.022f; + if (player.dead) + { + NPC.velocity.Y -= num2 * 2f; + if (NPC.timeLeft > 10) + { + NPC.timeLeft = 10; + return; + } + } - float num = 4.2f; - Vector2 vector = NPC.Center; - float num4 = player.Center.X; - float num5 = player.Center.Y; - num4 = (int)(num4 / 8f) * 8; - num5 = (int)(num5 / 8f) * 8; - vector.X = (int)(vector.X / 8f) * 8; - vector.Y = (int)(vector.Y / 8f) * 8; - num4 -= vector.X; - num5 -= vector.Y; - float num6 = (float)Math.Sqrt(num4 * num4 + num5 * num5); - float num7 = num6; - if (num6 == 0f) - { - num4 = NPC.velocity.X; - num5 = NPC.velocity.Y; - } - else - { - num6 = num / num6; - num4 *= num6; - num5 *= num6; - } - if (num7 > 100f) - { - Timer += 1f; - if (Timer > 0f) - { - NPC.velocity.Y += 0.023f; - } - else - { - NPC.velocity.Y -= 0.023f; - } - if (Timer < -100f || Timer > 100f) - { - NPC.velocity.X += 0.023f; - } - else - { - NPC.velocity.X -= 0.023f; - } - if (Timer > 200f) - { - Timer = -200f; - } - } - if (num7 < 150f) - { - NPC.velocity.X += num4 * 0.007f; - NPC.velocity.Y += num5 * 0.007f; - } - //if (player.dead) - //{ - // num4 = NPC.direction * num / 2f; - // num5 = (0f - num) / 2f; - //} - if (NPC.velocity.X < num4) - { - NPC.velocity.X += num2; - } - else if (NPC.velocity.X > num4) - { - NPC.velocity.X -= num2; - } - if (NPC.velocity.Y < num5) - { - NPC.velocity.Y += num2; - } - else if (NPC.velocity.Y > num5) - { - NPC.velocity.Y -= num2; - } - NPC.rotation = (float)Math.Atan2(num5, num4) - MathHelper.PiOver2; + float num = 4.2f; + Vector2 vector = NPC.Center; + float num4 = player.Center.X; + float num5 = player.Center.Y; + num4 = (int)(num4 / 8f) * 8; + num5 = (int)(num5 / 8f) * 8; + vector.X = (int)(vector.X / 8f) * 8; + vector.Y = (int)(vector.Y / 8f) * 8; + num4 -= vector.X; + num5 -= vector.Y; + float num6 = (float)Math.Sqrt(num4 * num4 + num5 * num5); + float num7 = num6; + if (num6 == 0f) + { + num4 = NPC.velocity.X; + num5 = NPC.velocity.Y; + } + else + { + num6 = num / num6; + num4 *= num6; + num5 *= num6; + } + if (num7 > 100f) + { + Timer += 1f; + if (Timer > 0f) + { + NPC.velocity.Y += 0.023f; + } + else + { + NPC.velocity.Y -= 0.023f; + } + if (Timer < -100f || Timer > 100f) + { + NPC.velocity.X += 0.023f; + } + else + { + NPC.velocity.X -= 0.023f; + } + if (Timer > 200f) + { + Timer = -200f; + } + } + if (num7 < 150f) + { + NPC.velocity.X += num4 * 0.007f; + NPC.velocity.Y += num5 * 0.007f; + } + //if (player.dead) + //{ + // num4 = NPC.direction * num / 2f; + // num5 = (0f - num) / 2f; + //} + if (NPC.velocity.X < num4) + { + NPC.velocity.X += num2; + } + else if (NPC.velocity.X > num4) + { + NPC.velocity.X -= num2; + } + if (NPC.velocity.Y < num5) + { + NPC.velocity.Y += num2; + } + else if (NPC.velocity.Y > num5) + { + NPC.velocity.Y -= num2; + } + NPC.rotation = (float)Math.Atan2(num5, num4) - MathHelper.PiOver2; - //doesn't seem to do anything because npc.notilecollide is set to false - //float num12 = 0.7f; - //if (npc.collideX) - //{ - // npc.netUpdate = true; - // npc.velocity.X = npc.oldVelocity.X * (0f - num12); - // if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - // { - // npc.velocity.X = 2f; - // } - // if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) - // { - // npc.velocity.X = -2f; - // } - //} - //if (npc.collideY) - //{ - // npc.netUpdate = true; - // npc.velocity.Y = npc.oldVelocity.Y * (0f - num12); - // if (npc.velocity.Y > 0f && (double)npc.velocity.Y < 1.5) - // { - // npc.velocity.Y = 2f; - // } - // if (npc.velocity.Y < 0f && (double)npc.velocity.Y > -1.5) - // { - // npc.velocity.Y = -2f; - // } - //} - if (NPC.wet) - { - if (NPC.velocity.Y > 0f) - { - NPC.velocity.Y *= 0.95f; - } - NPC.velocity.Y -= 0.3f; - if (NPC.velocity.Y < -2f) - { - NPC.velocity.Y = -2f; - } - } - if (Main.netMode != NetmodeID.MultiplayerClient && !player.dead) - { - if (NPC.justHit) - { - //makes it so it doesn't shoot projectiles when it's hit - //AttackTimer = 0f; - } - AttackTimer += 1f; - float shootDelay = 180f; - if (AttackTimer >= shootDelay) - { - AttackTimer = 0f; + //doesn't seem to do anything because npc.notilecollide is set to false + //float num12 = 0.7f; + //if (npc.collideX) + //{ + // npc.netUpdate = true; + // npc.velocity.X = npc.oldVelocity.X * (0f - num12); + // if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) + // { + // npc.velocity.X = 2f; + // } + // if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) + // { + // npc.velocity.X = -2f; + // } + //} + //if (npc.collideY) + //{ + // npc.netUpdate = true; + // npc.velocity.Y = npc.oldVelocity.Y * (0f - num12); + // if (npc.velocity.Y > 0f && (double)npc.velocity.Y < 1.5) + // { + // npc.velocity.Y = 2f; + // } + // if (npc.velocity.Y < 0f && (double)npc.velocity.Y > -1.5) + // { + // npc.velocity.Y = -2f; + // } + //} + if (NPC.wet) + { + if (NPC.velocity.Y > 0f) + { + NPC.velocity.Y *= 0.95f; + } + NPC.velocity.Y -= 0.3f; + if (NPC.velocity.Y < -2f) + { + NPC.velocity.Y = -2f; + } + } + if (Main.netMode != NetmodeID.MultiplayerClient && !player.dead) + { + if (NPC.justHit) + { + //makes it so it doesn't shoot projectiles when it's hit + //AttackTimer = 0f; + } + AttackTimer += 1f; + float shootDelay = 180f; + if (AttackTimer >= shootDelay) + { + AttackTimer = 0f; - int projectileDamage = 21; - int projectileType = ProjectileID.DemonSickle; - int projectileTravelTime = 70; - Vector2 center = NPC.Center; + int projectileDamage = 21; + int projectileType = ProjectileID.DemonSickle; + int projectileTravelTime = 70; + Vector2 center = NPC.Center; - Vector2 randomCenter = center + new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); - Vector2 toPlayer = player.DirectionFrom(randomCenter); - toPlayer *= 4; - int leftSickle = Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), center.X - NPC.width * 0.5f, center.Y, toPlayer.X, toPlayer.Y, projectileType, projectileDamage, 0f, Main.myPlayer); - Main.projectile[leftSickle].tileCollide = false; - Main.projectile[leftSickle].timeLeft = projectileTravelTime; + Vector2 randomCenter = center + new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); + Vector2 toPlayer = player.DirectionFrom(randomCenter); + toPlayer *= 4; + int leftSickle = Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), center.X - NPC.width * 0.5f, center.Y, toPlayer.X, toPlayer.Y, projectileType, projectileDamage, 0f, Main.myPlayer); + Main.projectile[leftSickle].tileCollide = false; + Main.projectile[leftSickle].timeLeft = projectileTravelTime; - randomCenter = center + new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); - toPlayer = player.DirectionFrom(randomCenter); - toPlayer *= 4; - int rightSickle = Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), center.X + NPC.width * 0.5f, center.Y, toPlayer.X, toPlayer.Y, projectileType, projectileDamage, 0f, Main.myPlayer); - Main.projectile[rightSickle].tileCollide = false; - Main.projectile[rightSickle].timeLeft = projectileTravelTime; + randomCenter = center + new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); + toPlayer = player.DirectionFrom(randomCenter); + toPlayer *= 4; + int rightSickle = Projectile.NewProjectile(NPC.GetSpawnSource_ForProjectile(), center.X + NPC.width * 0.5f, center.Y, toPlayer.X, toPlayer.Y, projectileType, projectileDamage, 0f, Main.myPlayer); + Main.projectile[rightSickle].tileCollide = false; + Main.projectile[rightSickle].timeLeft = projectileTravelTime; - //NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2) + npc.velocity.X), (int)(npc.position.Y + (float)(npc.height / 2) + npc.velocity.Y), 112); - //PROJECTILE IS ACTUALLY AN NPC AHAHAHAHAHAHAHAHHAAH - //https://terraria.gamepedia.com/Vile_Spit - } - } - // - // Main.dayTime || Main.player[npc.target].dead - // vvvvvvvvvvvv - if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) - { - NPC.netUpdate = true; - } - } - } + //NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2) + npc.velocity.X), (int)(npc.position.Y + (float)(npc.height / 2) + npc.velocity.Y), 112); + //PROJECTILE IS ACTUALLY AN NPC AHAHAHAHAHAHAHAHHAAH + //https://terraria.gamepedia.com/Vile_Spit + } + } + // + // Main.dayTime || Main.player[npc.target].dead + // vvvvvvvvvvvv + if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) + { + NPC.netUpdate = true; + } + } + } } diff --git a/NPCs/StingSlime.cs b/NPCs/StingSlime.cs index 5fee77ec..19b120ce 100644 --- a/NPCs/StingSlime.cs +++ b/NPCs/StingSlime.cs @@ -10,108 +10,108 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class StingSlime : AssNPC - { - private const int TotalNumberOfThese = 2; + [Content(ContentType.HostileNPCs)] + public class StingSlime : AssNPC + { + private const int TotalNumberOfThese = 2; - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/StingSlime_0"; //use fixed texture - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/StingSlime_0"; //use fixed texture + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sting Slime"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sting Slime"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 40; - NPC.height = 36; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 25; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 25f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 40; + NPC.height = 36; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 25; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 25f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.catchItem = (short)ModContent.ItemType(); + } - public override void HitEffect(int hitDirection, double damage) - { - Color color = AiTexture switch - { - 0 => new Color(152, 140, 166, 100), - _ => new Color(234, 173, 83, 100), - }; - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); - } - } - else - { - for (int i = 0; i < 40; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Color color = AiTexture switch + { + 0 => new Color(152, 140, 166, 100), + _ => new Color(234, 173, 83, 100), + }; + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); + } + } + else + { + for (int i = 0; i < 40; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.OverworldDayDesert.Chance * 0.3f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.OverworldDayDesert.Chance * 0.3f; + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Desert, - new FlavorTextBestiaryInfoElement("Bounce like a slime, sting like a scorpion.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Desert, + new FlavorTextBestiaryInfoElement("Bounce like a slime, sting like a scorpion.") + }); + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Stinger)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Stinger)); + } - public ref float AiTexture => ref NPC.ai[1]; + public ref float AiTexture => ref NPC.ai[1]; - public override bool PreAI() - { - if (AiTexture == 0 && NPC.localAI[0] == 0 && Main.netMode != NetmodeID.MultiplayerClient) - { - AiTexture = Main.rand.Next(TotalNumberOfThese); + public override bool PreAI() + { + if (AiTexture == 0 && NPC.localAI[0] == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + AiTexture = Main.rand.Next(TotalNumberOfThese); - NPC.localAI[0] = 1; - NPC.netUpdate = true; - } + NPC.localAI[0] = 1; + NPC.netUpdate = true; + } - return true; - } + return true; + } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/StingSlime_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/StingSlime_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + } } diff --git a/NPCs/StoneSoldier.cs b/NPCs/StoneSoldier.cs index f81d50cd..c4f5e00a 100644 --- a/NPCs/StoneSoldier.cs +++ b/NPCs/StoneSoldier.cs @@ -12,177 +12,177 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class StoneSoldier : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stone Soldier"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ArmedZombie]; - } - - public override void SetDefaults() - { - NPC.width = 18; - NPC.height = 40; - NPC.damage = 30; - NPC.defense = 16; - NPC.lifeMax = 50; - NPC.HitSound = SoundID.NPCHit41; - NPC.DeathSound = SoundID.NPCDeath52; - NPC.value = 60f; - NPC.knockBackResist = 0.35f; - NPC.aiStyle = 3; - AIType = NPCID.ArmedZombie; - AnimationType = NPCID.ArmedZombie; - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.Cavern.Chance * 0.04f; - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - if (Main.hardMode) NPC.lifeMax = NPC.lifeMax * 2; - } - - double bFrameCounter = 0; - int bFrameY = 0; - - public ref float SpawnedGem => ref NPC.ai[1]; - - public bool DecidedSpawnedGem - { - get => NPC.localAI[0] == 1f; - set => NPC.localAI[0] = value ? 1f : 0f; - } - - public override void FindFrame(int frameHeight) - { - if (NPC.IsABestiaryIconDummy) - { - AssExtensions.LoopAnimation(ref bFrameY, ref bFrameCounter, 8, 0, Main.npcFrameCount[NPC.type] - 1); - NPC.frame.Y = bFrameY * frameHeight; - } - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.StoneBlock, minimumDropped: 10, maximumDropped: 30)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 1), ItemID.Amethyst)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 2), ItemID.Topaz)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 3), ItemID.Sapphire)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 4), ItemID.Emerald)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 5), ItemID.Ruby)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 6), ItemID.Diamond)); - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Underground, - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Caverns, - new FlavorTextBestiaryInfoElement("Animate stone statues that have wandered from an ancient tomb. Their eyes are valuable.") - }); - } - - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } - - if (NPC.life <= 0) - { - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_01").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_02").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_03").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_04").Type, 1f); - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_04").Type, 1f); - } - - for (int i = 0; i < 15; i++) - { - if (Main.rand.NextFloat() < 0.6f) - { - Dust.NewDust(NPC.position - new Vector2(-20, 0), (NPC.width - 10) / 2, NPC.height, 1, 0f, 0f, 50, new Color(255, 255, 255), 1f); - } - } - } - - private float Gaussian(float x, float mean, float var = 1f) - { - return (float)((1 / Math.Sqrt(MathHelper.TwoPi * var)) * Math.Exp(-(x - mean) * (x - mean) / (2 * var))); - } - - public override bool PreAI() - { - if (SpawnedGem == 0 && !DecidedSpawnedGem && Main.netMode != NetmodeID.MultiplayerClient) - { - float heightFactor = (float)(NPC.position.Y - (16f * Main.rockLayer)) / (float)((Main.maxTilesY - 200 - Main.rockLayer) * 16f) * 6; - //0f == above rock layer - //3f == falfway down a hellavator - //6f == hell start - heightFactor = heightFactor > 6f ? 6f : heightFactor; - heightFactor = heightFactor < 0f ? 0f : heightFactor; - - float[] arr = new float[6]; // 0 to 5 - for (int j = 1; j < 7; j++) //1 to 6 - { - arr[j - 1] = Gaussian(j, heightFactor, 2f); - if (j > 1) arr[j - 1] += arr[j - 2]; //cumulative sum - } - - float sum = arr[arr.Length - 1]; - - for (int j = 1; j < 7; j++) - { - arr[j - 1] /= sum; - } - - float rand = Main.rand.NextFloat(); - for (int j = 1; j < 7; j++) - { - if (rand <= arr[j - 1]) //arr[6] is 1 - { - SpawnedGem = j; - break; - } - } - - DecidedSpawnedGem = true; - NPC.netUpdate = true; - } - - if (SpawnedGem != 0 && NPC.ai[3] == 1) - { - if (NPC.direction == 1) NPC.velocity.X += 0.09f; //0.02 - else NPC.velocity.X -= 0.09f; - } - - return true; - } - - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - //base sprite is 80x66 - //hitbox is 18x40 - int tex = (int)SpawnedGem; - if (tex <= 0 || tex > 6) - return; - - Texture2D texture = Mod.Assets.Request("NPCs/StoneSoldier_" + tex).Value; - Vector2 stupidOffset = new Vector2(0f, -8f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - drawColor = new Color((int)(drawColor.R * 1.2f + 40), (int)(drawColor.G * 1.2f + 40), (int)(drawColor.B * 1.2f + 40)); - drawColor.R = Math.Max(drawColor.R, (byte)100); - drawColor.G = Math.Max(drawColor.G, (byte)100); - drawColor.B = Math.Max(drawColor.B, (byte)100); - spriteBatch.Draw(texture, drawPos, new Rectangle?(texture.Bounds), drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - } - } + [Content(ContentType.HostileNPCs)] + public class StoneSoldier : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stone Soldier"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ArmedZombie]; + } + + public override void SetDefaults() + { + NPC.width = 18; + NPC.height = 40; + NPC.damage = 30; + NPC.defense = 16; + NPC.lifeMax = 50; + NPC.HitSound = SoundID.NPCHit41; + NPC.DeathSound = SoundID.NPCDeath52; + NPC.value = 60f; + NPC.knockBackResist = 0.35f; + NPC.aiStyle = 3; + AIType = NPCID.ArmedZombie; + AnimationType = NPCID.ArmedZombie; + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.Cavern.Chance * 0.04f; + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + if (Main.hardMode) NPC.lifeMax = NPC.lifeMax * 2; + } + + double bFrameCounter = 0; + int bFrameY = 0; + + public ref float SpawnedGem => ref NPC.ai[1]; + + public bool DecidedSpawnedGem + { + get => NPC.localAI[0] == 1f; + set => NPC.localAI[0] = value ? 1f : 0f; + } + + public override void FindFrame(int frameHeight) + { + if (NPC.IsABestiaryIconDummy) + { + AssExtensions.LoopAnimation(ref bFrameY, ref bFrameCounter, 8, 0, Main.npcFrameCount[NPC.type] - 1); + NPC.frame.Y = bFrameY * frameHeight; + } + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.StoneBlock, minimumDropped: 10, maximumDropped: 30)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 1), ItemID.Amethyst)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 2), ItemID.Topaz)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 3), ItemID.Sapphire)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 4), ItemID.Emerald)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 5), ItemID.Ruby)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 6), ItemID.Diamond)); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Underground, + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Caverns, + new FlavorTextBestiaryInfoElement("Animate stone statues that have wandered from an ancient tomb. Their eyes are valuable.") + }); + } + + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } + + if (NPC.life <= 0) + { + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_01").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_02").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_03").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_04").Type, 1f); + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("StoneSoldierGore_04").Type, 1f); + } + + for (int i = 0; i < 15; i++) + { + if (Main.rand.NextFloat() < 0.6f) + { + Dust.NewDust(NPC.position - new Vector2(-20, 0), (NPC.width - 10) / 2, NPC.height, 1, 0f, 0f, 50, new Color(255, 255, 255), 1f); + } + } + } + + private float Gaussian(float x, float mean, float var = 1f) + { + return (float)((1 / Math.Sqrt(MathHelper.TwoPi * var)) * Math.Exp(-(x - mean) * (x - mean) / (2 * var))); + } + + public override bool PreAI() + { + if (SpawnedGem == 0 && !DecidedSpawnedGem && Main.netMode != NetmodeID.MultiplayerClient) + { + float heightFactor = (float)(NPC.position.Y - (16f * Main.rockLayer)) / (float)((Main.maxTilesY - 200 - Main.rockLayer) * 16f) * 6; + //0f == above rock layer + //3f == falfway down a hellavator + //6f == hell start + heightFactor = heightFactor > 6f ? 6f : heightFactor; + heightFactor = heightFactor < 0f ? 0f : heightFactor; + + float[] arr = new float[6]; // 0 to 5 + for (int j = 1; j < 7; j++) //1 to 6 + { + arr[j - 1] = Gaussian(j, heightFactor, 2f); + if (j > 1) arr[j - 1] += arr[j - 2]; //cumulative sum + } + + float sum = arr[arr.Length - 1]; + + for (int j = 1; j < 7; j++) + { + arr[j - 1] /= sum; + } + + float rand = Main.rand.NextFloat(); + for (int j = 1; j < 7; j++) + { + if (rand <= arr[j - 1]) //arr[6] is 1 + { + SpawnedGem = j; + break; + } + } + + DecidedSpawnedGem = true; + NPC.netUpdate = true; + } + + if (SpawnedGem != 0 && NPC.ai[3] == 1) + { + if (NPC.direction == 1) NPC.velocity.X += 0.09f; //0.02 + else NPC.velocity.X -= 0.09f; + } + + return true; + } + + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + //base sprite is 80x66 + //hitbox is 18x40 + int tex = (int)SpawnedGem; + if (tex <= 0 || tex > 6) + return; + + Texture2D texture = Mod.Assets.Request("NPCs/StoneSoldier_" + tex).Value; + Vector2 stupidOffset = new Vector2(0f, -8f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + drawColor = new Color((int)(drawColor.R * 1.2f + 40), (int)(drawColor.G * 1.2f + 40), (int)(drawColor.B * 1.2f + 40)); + drawColor.R = Math.Max(drawColor.R, (byte)100); + drawColor.G = Math.Max(drawColor.G, (byte)100); + drawColor.B = Math.Max(drawColor.B, (byte)100); + spriteBatch.Draw(texture, drawPos, new Rectangle?(texture.Bounds), drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + } + } } diff --git a/NPCs/StrangeSlime.cs b/NPCs/StrangeSlime.cs index b1c5099a..3c99ac4c 100644 --- a/NPCs/StrangeSlime.cs +++ b/NPCs/StrangeSlime.cs @@ -10,111 +10,111 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class StrangeSlime : AssNPC - { - private const int TotalNumberOfThese = 4; + [Content(ContentType.HostileNPCs)] + public class StrangeSlime : AssNPC + { + private const int TotalNumberOfThese = 4; - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/StrangeSlime_0"; //use fixed texture - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/StrangeSlime_0"; //use fixed texture + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Strange Slime"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Strange Slime"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + } - public override void SetDefaults() - { - NPC.width = 36; - NPC.height = 62; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 25; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 25f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - } + public override void SetDefaults() + { + NPC.width = 36; + NPC.height = 62; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 25; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 25f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + } - public override void HitEffect(int hitDirection, double damage) - { - Color color = AiTexture switch - { - 0 => new Color(171, 96, 193, 100), - 1 => new Color(240, 180, 4, 100), - 2 => new Color(84, 116, 8, 100), - _ => new Color(25, 191, 83, 100), - }; - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); - } - } - else - { - for (int i = 0; i < 40; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Color color = AiTexture switch + { + 0 => new Color(171, 96, 193, 100), + 1 => new Color(240, 180, 4, 100), + 2 => new Color(84, 116, 8, 100), + _ => new Color(25, 191, 83, 100), + }; + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); + } + } + else + { + for (int i = 0; i < 40; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.OverworldDaySlime.Chance * 0.001f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.OverworldDaySlime.Chance * 0.001f; + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 0), ItemID.StrangePlant1)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 1), ItemID.StrangePlant2)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 2), ItemID.StrangePlant3)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 3), ItemID.StrangePlant4)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 0), ItemID.StrangePlant1)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 1), ItemID.StrangePlant2)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 2), ItemID.StrangePlant3)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 3), ItemID.StrangePlant4)); + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, - new FlavorTextBestiaryInfoElement("These peculiar slimes are host to strange plants, which grow for life. The slime always makes sure to keep it upright.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface, + new FlavorTextBestiaryInfoElement("These peculiar slimes are host to strange plants, which grow for life. The slime always makes sure to keep it upright.") + }); + } - public ref float AiTexture => ref NPC.ai[1]; + public ref float AiTexture => ref NPC.ai[1]; - public override bool PreAI() - { - if (AiTexture == 0 && NPC.localAI[0] == 0 && Main.netMode != NetmodeID.MultiplayerClient) - { - AiTexture = Main.rand.Next(TotalNumberOfThese); + public override bool PreAI() + { + if (AiTexture == 0 && NPC.localAI[0] == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + AiTexture = Main.rand.Next(TotalNumberOfThese); - NPC.localAI[0] = 1; - NPC.netUpdate = true; - } + NPC.localAI[0] = 1; + NPC.netUpdate = true; + } - return true; - } + return true; + } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/StrangeSlime_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/StrangeSlime_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + } } diff --git a/NPCs/TurtleSlime.cs b/NPCs/TurtleSlime.cs index 6a87948e..50aee310 100644 --- a/NPCs/TurtleSlime.cs +++ b/NPCs/TurtleSlime.cs @@ -10,80 +10,80 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class TurtleSlime : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Turtle Slime"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; - Main.npcCatchable[NPC.type] = true; - } + [Content(ContentType.HostileNPCs)] + public class TurtleSlime : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Turtle Slime"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.ToxicSludge]; + Main.npcCatchable[NPC.type] = true; + } - public override void SetDefaults() - { - NPC.width = 36; - NPC.height = 30; - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 25; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 25f; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = 1; - AIType = NPCID.ToxicSludge; - AnimationType = NPCID.ToxicSludge; - NPC.catchItem = (short)ModContent.ItemType(); - } + public override void SetDefaults() + { + NPC.width = 36; + NPC.height = 30; + NPC.damage = 7; + NPC.defense = 2; + NPC.lifeMax = 25; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 25f; + NPC.knockBackResist = 0.25f; + NPC.aiStyle = 1; + AIType = NPCID.ToxicSludge; + AnimationType = NPCID.ToxicSludge; + NPC.catchItem = (short)ModContent.ItemType(); + } - public override void HitEffect(int hitDirection, double damage) - { - Color color = new Color(114, 132, 51, 100); - if (NPC.life > 0) - { - for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); - } - } - else - { - for (int i = 0; i < 40; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Color color = new Color(114, 132, 51, 100); + if (NPC.life > 0) + { + for (int i = 0; i < damage / NPC.lifeMax * 100f; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, NPC.alpha, color); + } + } + else + { + for (int i = 0; i < 40; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, 2 * hitDirection, -2f, NPC.alpha, color); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.SurfaceJungle.Chance * 0.015f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.SurfaceJungle.Chance * 0.015f; + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, - new FlavorTextBestiaryInfoElement("Giant tortoises are known to shed part of their shell as they grow. These slimes collect those old fragments for protection.") - }); - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, + new FlavorTextBestiaryInfoElement("Giant tortoises are known to shed part of their shell as they grow. These slimes collect those old fragments for protection.") + }); + } - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); - } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.Common(ItemID.Gel)); + } - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = ModContent.Request(Texture + "_Glowmask").Value; - Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - Color fullColor = drawColor; - fullColor.A = 255; - spriteBatch.Draw(texture, drawPos, NPC.frame, fullColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = ModContent.Request(Texture + "_Glowmask").Value; + Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + Color fullColor = drawColor; + fullColor.A = 255; + spriteBatch.Draw(texture, drawPos, NPC.frame, fullColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + } + } } diff --git a/NPCs/WalkingTombstoneGolden.cs b/NPCs/WalkingTombstoneGolden.cs index 5f6dc029..d7bf508f 100644 --- a/NPCs/WalkingTombstoneGolden.cs +++ b/NPCs/WalkingTombstoneGolden.cs @@ -9,12 +9,12 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.HostileNPCs)] - public class WalkingTombstoneGolden : AssNPC - { - private const int TotalNumberOfThese = 5; + [Content(ContentType.HostileNPCs)] + public class WalkingTombstoneGolden : AssNPC + { + private const int TotalNumberOfThese = 5; - /* + /* * 0 = Tombstone * 1 = CrossGraveMarker * 2 = GraveMarker @@ -22,120 +22,120 @@ public class WalkingTombstoneGolden : AssNPC * 4 = Headstone */ - public override string Texture - { - get - { - return "AssortedCrazyThings/NPCs/WalkingTombstoneGolden_0"; //use fixed texture - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Walking Tombstone"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Crab]; - } - - public override void SetDefaults() - { - NPC.width = 36; - NPC.height = 46; - NPC.damage = 0; - NPC.defense = 10; - NPC.lifeMax = 40; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 75f; - NPC.knockBackResist = 0.5f; - NPC.aiStyle = 3; - AIType = NPCID.Crab; - AnimationType = NPCID.Crab; - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.Player.ZoneGraveyard ? 0.15f : 0f; //TODO adjust - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Times.NightTime, - new FlavorTextBestiaryInfoElement("Terrestrial crabs that have taken up a morbid and expensive form of camouflage.") - }); - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 0), ItemID.RichGravestone2)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 1), ItemID.RichGravestone1)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 2), ItemID.RichGravestone3)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 3), ItemID.RichGravestone4)); - npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 4), ItemID.RichGravestone5)); - } - - public override void PostAI() - { - if (NPC.HasValidTarget && Main.player[NPC.target] is Player player && !player.ZoneGraveyard) - { - if (NPC.velocity.X > 0 || NPC.velocity.X < 0) - { - NPC.velocity.X = 0; - } - NPC.ai[0] = 1f; - NPC.direction = 1; - NPC.frameCounter = 0; - } - - if (NPC.velocity.Y < 0) - { - NPC.velocity.Y = 0; - } - } - - public ref float AiTexture => ref NPC.ai[1]; - - public bool DecidedAiTexture - { - get => NPC.localAI[0] == 1f; - set => NPC.localAI[0] = value ? 1f : 0f; - } - - public override bool PreAI() - { - if (AiTexture == 0 && !DecidedAiTexture && Main.netMode != NetmodeID.MultiplayerClient) - { - AiTexture = Main.rand.Next(TotalNumberOfThese); - - DecidedAiTexture = true; - NPC.netUpdate = true; - } - - return true; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Texture2D texture = Mod.Assets.Request("NPCs/WalkingTombstoneGolden_" + AiTexture).Value; - Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); - Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; - spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); - return false; - } - - public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode == NetmodeID.Server) - { - return; - } - - if (NPC.life <= 0) - { - Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WalkingTombstoneGore_01").Type, 1f); - } - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/NPCs/WalkingTombstoneGolden_0"; //use fixed texture + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Walking Tombstone"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.Crab]; + } + + public override void SetDefaults() + { + NPC.width = 36; + NPC.height = 46; + NPC.damage = 0; + NPC.defense = 10; + NPC.lifeMax = 40; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 75f; + NPC.knockBackResist = 0.5f; + NPC.aiStyle = 3; + AIType = NPCID.Crab; + AnimationType = NPCID.Crab; + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return spawnInfo.Player.ZoneGraveyard ? 0.15f : 0f; //TODO adjust + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Times.NightTime, + new FlavorTextBestiaryInfoElement("Terrestrial crabs that have taken up a morbid and expensive form of camouflage.") + }); + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 0), ItemID.RichGravestone2)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 1), ItemID.RichGravestone1)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 2), ItemID.RichGravestone3)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 3), ItemID.RichGravestone4)); + npcLoot.Add(ItemDropRule.ByCondition(new MatchAppearanceCondition(1, 4), ItemID.RichGravestone5)); + } + + public override void PostAI() + { + if (NPC.HasValidTarget && Main.player[NPC.target] is Player player && !player.ZoneGraveyard) + { + if (NPC.velocity.X > 0 || NPC.velocity.X < 0) + { + NPC.velocity.X = 0; + } + NPC.ai[0] = 1f; + NPC.direction = 1; + NPC.frameCounter = 0; + } + + if (NPC.velocity.Y < 0) + { + NPC.velocity.Y = 0; + } + } + + public ref float AiTexture => ref NPC.ai[1]; + + public bool DecidedAiTexture + { + get => NPC.localAI[0] == 1f; + set => NPC.localAI[0] = value ? 1f : 0f; + } + + public override bool PreAI() + { + if (AiTexture == 0 && !DecidedAiTexture && Main.netMode != NetmodeID.MultiplayerClient) + { + AiTexture = Main.rand.Next(TotalNumberOfThese); + + DecidedAiTexture = true; + NPC.netUpdate = true; + } + + return true; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D texture = Mod.Assets.Request("NPCs/WalkingTombstoneGolden_" + AiTexture).Value; + Vector2 stupidOffset = new Vector2(0f, 4f + NPC.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(NPC.width * 0.5f, NPC.height * 0.5f); + Vector2 drawPos = NPC.position - screenPos + drawOrigin + stupidOffset; + spriteBatch.Draw(texture, drawPos, NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, effect, 0f); + return false; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode == NetmodeID.Server) + { + return; + } + + if (NPC.life <= 0) + { + Gore.NewGore(NPC.position, NPC.velocity, Mod.Find("WalkingTombstoneGore_01").Type, 1f); + } + } + } } diff --git a/NPCs/WyvernCampfireGlobalNPC.cs b/NPCs/WyvernCampfireGlobalNPC.cs index d2af7ed7..62d749e4 100644 --- a/NPCs/WyvernCampfireGlobalNPC.cs +++ b/NPCs/WyvernCampfireGlobalNPC.cs @@ -1,187 +1,187 @@ using Microsoft.Xna.Framework; using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.NPCs { - [Content(ContentType.PlaceablesFunctional)] - public class WyvernCampfireGlobalNPC : AssGlobalNPC - { - public override bool AppliesToEntity(NPC entity, bool lateInstantiation) - { - return lateInstantiation && entity.type >= NPCID.WyvernHead && entity.type <= NPCID.WyvernTail; - } - - public bool sentWyvernPacket = false; - - public override bool InstancePerEntity => true; - - - public const short fadeTimer = 254; - public short fadeTimerCount = 0; - - private void KillInstantly(NPC npc) - { - // These 3 lines instantly kill the npc without showing damage numbers, dropping loot, or playing DeathSound. Use this for instant deaths - npc.life = 0; - //npc.HitEffect(); - npc.active = false; - npc.netUpdate = true; - SoundEngine.PlaySound(SoundID.NPCDeath16, npc.position); // plays a fizzle sound - } - - private bool SlowDown(ref NPC npc) - { - //returns true if after SlowDown it still moves, false if it stands still - bool isMoving = !(npc.velocity.X == 0 && npc.velocity.Y == 0); - if (isMoving) - { - if (npc.velocity.X > 4f || npc.velocity.X < -4f) - { - npc.velocity.X *= 0.9f; - } - else - { - if (npc.velocity.X > 0.3f) - { - npc.velocity.X -= 0.5f; - } - else if (npc.velocity.X < -0.3f) - { - npc.velocity.X += 0.5f; - } - } - - if (npc.velocity.Y > 4f || npc.velocity.Y < -4f) - { - npc.velocity.Y *= 0.9f; - } - else - { - if (npc.velocity.Y > 0.3f) - { - npc.velocity.Y -= 0.5f; - } - else if (npc.velocity.Y < -0.3f) - { - npc.velocity.Y += 0.5f; - } - } - - if ((npc.velocity.X > 0f && npc.velocity.X < 0.3f) || (npc.velocity.X < 0f && npc.velocity.X > -0.3f)) - { - npc.velocity.X = 0f; - } - if ((npc.velocity.Y > 0f && npc.velocity.Y < 0.3f) || (npc.velocity.Y < 0f && npc.velocity.Y > -0.3f)) - { - npc.velocity.Y = 0f; - } - //Main.NewText("X" + npc.velocity.X); - //Main.NewText("Y" + npc.velocity.Y); - - //update isMoving again - isMoving = !(npc.velocity.X == 0 && npc.velocity.Y == 0); - } - - return isMoving; - } - - private void QuickWyvernDust(Vector2 pos, Color color, float fadeIn, float chance) - { - if (Main.rand.NextFloat() < chance) - { - int type = 15; - Dust dust = Dust.NewDustDirect(pos, 4, 4, type, 0f, 0f, 120, color, 2f); - dust.position = pos; - dust.velocity = new Vector2(Main.rand.NextFloat(-7, 7), Main.rand.NextFloat(-7, 7)); - dust.fadeIn = fadeIn; //3f - dust.noLight = true; - dust.noGravity = true; - } - } - - public Vector2 RotToNormal(float rotation) - { - return new Vector2((float)Math.Sin(rotation), (float)-Math.Cos(rotation)); - } - - public void FadeAway(ref short fadeTimerCount, ref NPC npc) - { - //14 segments each 42 coordinates apart == 580x580 rect around center of wyvern head - Rectangle rect = new Rectangle((int)npc.Center.X - 580, (int)npc.Center.Y - 580, 2 * 580, 2 * 580); - fadeTimerCount++; - for (short j = 0; j < Main.maxNPCs; j++) - { - NPC other = Main.npc[j]; - if (other.active && (other.type > NPCID.WyvernHead && other.type <= NPCID.WyvernTail)/* && NPCID.WyvernHead != Main.npc[j].type*/) - { - if (rect.Intersects(other.Hitbox)) - { - QuickWyvernDust(other.Center, Color.White, (float)(fadeTimerCount / 50f), 0.5f); - other.GetGlobalNPC().fadeTimerCount = fadeTimerCount; - } - } - } - - //dust infront of the head (because it so long) - Vector2 normal = 60 * RotToNormal(npc.rotation); - QuickWyvernDust(npc.Center + normal, Color.White, (float)(fadeTimerCount / 50f), 0.5f); - } - - public override Color? GetAlpha(NPC npc, Color drawColor) - { - if (fadeTimerCount > 0) - { - if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) - { - return drawColor * ((float)(fadeTimer - fadeTimerCount) / 255f); - } - } - return base.GetAlpha(npc, drawColor); - } - - public override bool PreAI(NPC npc) - { - if (Main.netMode != NetmodeID.Server) - { - //this section of code doesn't run on the server anyway cause wyvernCampfire only gets set on LocalPlayer - if (npc.type == NPCID.WyvernHead && Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].GetModPlayer().wyvernCampfire) - { - if (!sentWyvernPacket && Main.netMode == NetmodeID.MultiplayerClient) - { - sentWyvernPacket = true; - ModPacket packet = Mod.GetPacket(); - packet.Write((byte)AssMessageType.WyvernCampfireKill); - packet.Write(npc.whoAmI); - packet.Send(); - } - else if (Main.netMode == NetmodeID.SinglePlayer) - { - if (!SlowDown(ref npc)) - { - if (fadeTimerCount <= fadeTimer) - { - FadeAway(ref fadeTimerCount, ref npc); - } - else - { - fadeTimerCount = 0; - KillInstantly(npc); - } - return false; - } - else - { - fadeTimerCount = 0; - } - } - //id 87 == head -> id 92 == tail - } - } - return true; - } - } + [Content(ContentType.PlaceablesFunctional)] + public class WyvernCampfireGlobalNPC : AssGlobalNPC + { + public override bool AppliesToEntity(NPC entity, bool lateInstantiation) + { + return lateInstantiation && entity.type >= NPCID.WyvernHead && entity.type <= NPCID.WyvernTail; + } + + public bool sentWyvernPacket = false; + + public override bool InstancePerEntity => true; + + + public const short fadeTimer = 254; + public short fadeTimerCount = 0; + + private void KillInstantly(NPC npc) + { + // These 3 lines instantly kill the npc without showing damage numbers, dropping loot, or playing DeathSound. Use this for instant deaths + npc.life = 0; + //npc.HitEffect(); + npc.active = false; + npc.netUpdate = true; + SoundEngine.PlaySound(SoundID.NPCDeath16, npc.position); // plays a fizzle sound + } + + private bool SlowDown(ref NPC npc) + { + //returns true if after SlowDown it still moves, false if it stands still + bool isMoving = !(npc.velocity.X == 0 && npc.velocity.Y == 0); + if (isMoving) + { + if (npc.velocity.X > 4f || npc.velocity.X < -4f) + { + npc.velocity.X *= 0.9f; + } + else + { + if (npc.velocity.X > 0.3f) + { + npc.velocity.X -= 0.5f; + } + else if (npc.velocity.X < -0.3f) + { + npc.velocity.X += 0.5f; + } + } + + if (npc.velocity.Y > 4f || npc.velocity.Y < -4f) + { + npc.velocity.Y *= 0.9f; + } + else + { + if (npc.velocity.Y > 0.3f) + { + npc.velocity.Y -= 0.5f; + } + else if (npc.velocity.Y < -0.3f) + { + npc.velocity.Y += 0.5f; + } + } + + if ((npc.velocity.X > 0f && npc.velocity.X < 0.3f) || (npc.velocity.X < 0f && npc.velocity.X > -0.3f)) + { + npc.velocity.X = 0f; + } + if ((npc.velocity.Y > 0f && npc.velocity.Y < 0.3f) || (npc.velocity.Y < 0f && npc.velocity.Y > -0.3f)) + { + npc.velocity.Y = 0f; + } + //Main.NewText("X" + npc.velocity.X); + //Main.NewText("Y" + npc.velocity.Y); + + //update isMoving again + isMoving = !(npc.velocity.X == 0 && npc.velocity.Y == 0); + } + + return isMoving; + } + + private void QuickWyvernDust(Vector2 pos, Color color, float fadeIn, float chance) + { + if (Main.rand.NextFloat() < chance) + { + int type = 15; + Dust dust = Dust.NewDustDirect(pos, 4, 4, type, 0f, 0f, 120, color, 2f); + dust.position = pos; + dust.velocity = new Vector2(Main.rand.NextFloat(-7, 7), Main.rand.NextFloat(-7, 7)); + dust.fadeIn = fadeIn; //3f + dust.noLight = true; + dust.noGravity = true; + } + } + + public Vector2 RotToNormal(float rotation) + { + return new Vector2((float)Math.Sin(rotation), (float)-Math.Cos(rotation)); + } + + public void FadeAway(ref short fadeTimerCount, ref NPC npc) + { + //14 segments each 42 coordinates apart == 580x580 rect around center of wyvern head + Rectangle rect = new Rectangle((int)npc.Center.X - 580, (int)npc.Center.Y - 580, 2 * 580, 2 * 580); + fadeTimerCount++; + for (short j = 0; j < Main.maxNPCs; j++) + { + NPC other = Main.npc[j]; + if (other.active && (other.type > NPCID.WyvernHead && other.type <= NPCID.WyvernTail)/* && NPCID.WyvernHead != Main.npc[j].type*/) + { + if (rect.Intersects(other.Hitbox)) + { + QuickWyvernDust(other.Center, Color.White, (float)(fadeTimerCount / 50f), 0.5f); + other.GetGlobalNPC().fadeTimerCount = fadeTimerCount; + } + } + } + + //dust infront of the head (because it so long) + Vector2 normal = 60 * RotToNormal(npc.rotation); + QuickWyvernDust(npc.Center + normal, Color.White, (float)(fadeTimerCount / 50f), 0.5f); + } + + public override Color? GetAlpha(NPC npc, Color drawColor) + { + if (fadeTimerCount > 0) + { + if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) + { + return drawColor * ((float)(fadeTimer - fadeTimerCount) / 255f); + } + } + return base.GetAlpha(npc, drawColor); + } + + public override bool PreAI(NPC npc) + { + if (Main.netMode != NetmodeID.Server) + { + //this section of code doesn't run on the server anyway cause wyvernCampfire only gets set on LocalPlayer + if (npc.type == NPCID.WyvernHead && Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].GetModPlayer().wyvernCampfire) + { + if (!sentWyvernPacket && Main.netMode == NetmodeID.MultiplayerClient) + { + sentWyvernPacket = true; + ModPacket packet = Mod.GetPacket(); + packet.Write((byte)AssMessageType.WyvernCampfireKill); + packet.Write(npc.whoAmI); + packet.Send(); + } + else if (Main.netMode == NetmodeID.SinglePlayer) + { + if (!SlowDown(ref npc)) + { + if (fadeTimerCount <= fadeTimer) + { + FadeAway(ref fadeTimerCount, ref npc); + } + else + { + fadeTimerCount = 0; + KillInstantly(npc); + } + return false; + } + else + { + fadeTimerCount = 0; + } + } + //id 87 == head -> id 92 == tail + } + } + return true; + } + } } diff --git a/NPCs/YoungHarpy.cs b/NPCs/YoungHarpy.cs index 37c37b63..f998b462 100644 --- a/NPCs/YoungHarpy.cs +++ b/NPCs/YoungHarpy.cs @@ -8,66 +8,66 @@ namespace AssortedCrazyThings.NPCs { - [Content(ContentType.FriendlyNPCs)] - public class YoungHarpy : AssNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Young Harpy"); - Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.FlyingSnake]; - Main.npcCatchable[NPC.type] = true; - - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) - { - Position = new Vector2(0, 10f) - }; - NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; - } + [Content(ContentType.FriendlyNPCs)] + public class YoungHarpy : AssNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Young Harpy"); + Main.npcFrameCount[NPC.type] = Main.npcFrameCount[NPCID.FlyingSnake]; + Main.npcCatchable[NPC.type] = true; - public override void SetDefaults() - { - NPC.width = 30; - NPC.height = 30; - NPC.damage = 0; - NPC.defense = 1; - NPC.lifeMax = 5; - NPC.friendly = true; - NPC.dontTakeDamageFromHostiles = true; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = 60f; - NPC.knockBackResist = 0.5f; - NPC.aiStyle = 14; - NPC.noGravity = true; - AIType = NPCID.FlyingSnake; - AnimationType = NPCID.FlyingSnake; - NPC.catchItem = (short)ModContent.ItemType(); - } + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + { + Position = new Vector2(0, 10f) + }; + NPCID.Sets.NPCBestiaryDrawOffset[NPC.type] = value; + } - public override bool? CanBeHitByItem(Player player, Item item) - { - return null; //TODO NPC return true - } + public override void SetDefaults() + { + NPC.width = 30; + NPC.height = 30; + NPC.damage = 0; + NPC.defense = 1; + NPC.lifeMax = 5; + NPC.friendly = true; + NPC.dontTakeDamageFromHostiles = true; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = 60f; + NPC.knockBackResist = 0.5f; + NPC.aiStyle = 14; + NPC.noGravity = true; + AIType = NPCID.FlyingSnake; + AnimationType = NPCID.FlyingSnake; + NPC.catchItem = (short)ModContent.ItemType(); + } - public override bool? CanBeHitByProjectile(Projectile projectile) - { - return !projectile.minion; - } + public override bool? CanBeHitByItem(Player player, Item item) + { + return null; //TODO NPC return true + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return SpawnCondition.Sky.Chance * 0.05f; - } + public override bool? CanBeHitByProjectile(Projectile projectile) + { + return !projectile.minion; + } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - //quickUnlock: true so only 1 kill is required to list everything about it - bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return SpawnCondition.Sky.Chance * 0.05f; + } - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Sky, - new FlavorTextBestiaryInfoElement("Harpies are not inherently hostile. If they make a childhood friend, they'll always be friends.") - }); - } - } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + //quickUnlock: true so only 1 kill is required to list everything about it + bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPC.type], quickUnlock: true); + + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Sky, + new FlavorTextBestiaryInfoElement("Harpies are not inherently hostile. If they make a childhood friend, they'll always be friends.") + }); + } + } } diff --git a/PetPlayer.cs b/PetPlayer.cs index 3cb5b3fe..5f0b07a4 100644 --- a/PetPlayer.cs +++ b/PetPlayer.cs @@ -20,1219 +20,1219 @@ namespace AssortedCrazyThings { - [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] - public class PetPlayer : AssPlayerBase - { - private bool enteredWorld = false; - - private const int altTextureCountLoaded = 25; //IMPORTANT TO INCREMENT THIS EACH TIME A NEW ALT TEXTURE IS ADDED - - //Alt texture types - public byte mechFrogType = 0; - public byte petEyeType = 0; - public byte cursedSkullType = 0; - public byte youngWyvernType = 0; - public byte petFishronType = 0; - public byte petMoonType = 0; - public byte abeeminationType = 0; - public byte lilWrapsType = 0; - public byte vampireBatType = 0; - public byte pigronataType = 0; - public byte queenLarvaType = 0; - public byte miniAntlionType = 0; - public byte petGoldfishType = 0; - public byte skeletronHandType = 0; - public byte skeletronPrimeHandType = 0; - public byte petCultistType = 0; - public byte petAnomalocarisType = 0; - public byte dynamiteBunnyType = 0; - public byte wallFragmentType = 0; - public byte metroidPetType = 0; - public byte cuteLamiaPetType = 0; - - public byte oceanSlimeType = 0; - public byte stingSlimeType = 0; - public byte animatedTomeType = 0; - - public byte youngHarpyType = 0; - - //ALTERNATE - ////name pet texture - //public byte classNameType = 0; - - public bool CuteSlimeYellow = false; - public bool CuteSlimeXmas = false; - public bool CuteSlimeToxic = false; - public bool CuteSlimeSand = false; - public bool CuteSlimeRed = false; - public bool CuteSlimeRainbow = false; - public bool CuteSlimeQueen = false; - public bool CuteSlimePurple = false; - public bool CuteSlimePrincess = false; - public bool CuteSlimePink = false; - public bool CuteSlimeLava = false; - public bool CuteSlimeJungle = false; - public bool CuteSlimeIlluminant = false; - public bool CuteSlimeIce = false; - public bool CuteSlimeGreen = false; - public bool CuteSlimeDungeon = false; - public bool CuteSlimeCrimson = false; - public bool CuteSlimeCorrupt = false; - public bool CuteSlimeBlue = false; - public bool CuteSlimeBlack = false; - - public bool DrumstickElemental = false; - public bool SuspiciousNugget = false; - public bool MiniAntlion = false; - public bool LilWraps = false; - public bool PetFishron = false; - public bool RainbowSlime = false; - public bool PrinceSlime = false; - public bool IlluminantSlime = false; - public bool ChunkySlime = false; - public bool FairySlime = false; - public bool HornedSlime = false; - public bool JoyousSlime = false; - public bool MeatballSlime = false; - public bool OceanSlime = false; - public bool StingSlime = false; - public bool TurtleSlime = false; - public bool Pigronata = false; - public bool Abeemination = false; - public bool MiniMegalodon = false; - public bool YoungHarpy = false; - public bool CuteGastropod = false; - public bool YoungWyvern = false; - public bool BabyIchorSticker = false; - public bool LifelikeMechanicalFrog = false; - public bool ChunkyandMeatball = false; - public bool DemonHeart = false; - public bool BrainofConfusion = false; - public bool AlienHornet = false; - public bool DetachedHungry = false; - public bool BabyOcram = false; - public bool CursedSkull = false; - public bool BabyCrimera = false; - public bool VampireBat = false; - public bool TorturedSoul = false; - public bool EnchantedSword = false; - public bool Goblet = false; - public bool SoulLightPet = false; - public bool SoulLightPet2 = false; - public bool DocileDemonEye = false; - public bool QueenLarva = false; - public bool PetSun = false; - public bool PetMoon = false; - public bool WallFragment = false; - public bool TinyTwins = false; - public bool PetGoldfish = false; - public bool SkeletronHand = false; - public bool SkeletronPrimeHand = false; - public bool PetHarvester = false; - public bool PetGolemHead = false; - public bool TrueObservingEye = false; - public bool PetCultist = false; - public bool PetPlantera = false; - public bool PetEaterofWorlds = false; - public bool PetDestroyer = false; - public bool AnimatedTome = false; - public bool PetAnomalocaris = false; - public bool DynamiteBunny = false; - public bool FairySwarm = false; - public bool SwarmofCthulhu = false; - public bool PetQueenSlime = false; - public bool FailureSlime = false; - public bool GhostMartian = false; - public bool NumberMuncher = false; - public bool StrangeRobot = false; - public bool MetroidPet = false; - public bool CuteLamiaPet = false; - public bool TorchGodLightPet = false; - //ALTERNATE - //public bool ClassName = false; - - public override void ResetEffects() - { - CuteSlimeYellow = false; - CuteSlimeXmas = false; - CuteSlimeToxic = false; - CuteSlimeSand = false; - CuteSlimeRed = false; - CuteSlimeRainbow = false; - CuteSlimePrincess = false; - CuteSlimeQueen = false; - CuteSlimePurple = false; - CuteSlimePink = false; - CuteSlimeLava = false; - CuteSlimeJungle = false; - CuteSlimeIce = false; - CuteSlimeIlluminant = false; - CuteSlimeGreen = false; - CuteSlimeDungeon = false; - CuteSlimeCrimson = false; - CuteSlimeCorrupt = false; - CuteSlimeBlue = false; - CuteSlimeBlack = false; - - DrumstickElemental = false; - SuspiciousNugget = false; - MiniAntlion = false; - LilWraps = false; - PetFishron = false; - RainbowSlime = false; - PrinceSlime = false; - IlluminantSlime = false; - ChunkySlime = false; - FairySlime = false; - HornedSlime = false; - JoyousSlime = false; - MeatballSlime = false; - OceanSlime = false; - StingSlime = false; - TurtleSlime = false; - Pigronata = false; - Abeemination = false; - MiniMegalodon = false; - YoungHarpy = false; - CuteGastropod = false; - YoungWyvern = false; - BabyIchorSticker = false; - LifelikeMechanicalFrog = false; - ChunkyandMeatball = false; - DemonHeart = false; - BrainofConfusion = false; - AlienHornet = false; - DetachedHungry = false; - BabyOcram = false; - CursedSkull = false; - BabyCrimera = false; - VampireBat = false; - TorturedSoul = false; - EnchantedSword = false; - Goblet = false; - SoulLightPet = false; - SoulLightPet2 = false; - DocileDemonEye = false; - QueenLarva = false; - PetSun = false; - PetMoon = false; - WallFragment = false; - TinyTwins = false; - PetGoldfish = false; - SkeletronHand = false; - SkeletronPrimeHand = false; - PetHarvester = false; - PetGolemHead = false; - TrueObservingEye = false; - PetCultist = false; - PetPlantera = false; - PetEaterofWorlds = false; - PetDestroyer = false; - AnimatedTome = false; - PetAnomalocaris = false; - DynamiteBunny = false; - FairySwarm = false; - SwarmofCthulhu = false; - PetQueenSlime = false; - FailureSlime = false; - GhostMartian = false; - NumberMuncher = false; - StrangeRobot = false; - MetroidPet = false; - CuteLamiaPet = false; - TorchGodLightPet = false; - //ALTERNATE - //ClassName = false; - } - - /// - /// Returns true if this has been called the third time after two successful calls within 80 ticks - /// - public bool ThreeTimesUseTime() - { - uint diff = (uint)Math.Abs(Main.GameUpdateCount - lastTime); - if (diff > 40.0) - { - //19 - resetPetAccessories = false; - lastTime = Main.GameUpdateCount; - return false; //step one - } - - //step two and three have to be done in 40 ticks each - if (diff <= 40.0) - { - if (!resetPetAccessories) - { - lastTime = Main.GameUpdateCount; - resetPetAccessories = true; - return false; //step two - } - - //if program gets to here, it is about to return true - - if (resetPetAccessories) - { - resetPetAccessories = false; - return true; //step three - } - } - //should never get here anyway - return false; - } - - public override void SaveData(TagCompound tag) - { - SavePetAccessories(tag); - - TagCompound petTags = new() - { - { "mechFrogType", mechFrogType }, - { "petEyeType", petEyeType }, - { "cursedSkullType", cursedSkullType }, - { "youngWyvernType", youngWyvernType }, - { "petFishronType", petFishronType }, - { "petMoonType", petMoonType }, - { "abeeminationType", abeeminationType }, - { "lilWrapsType", lilWrapsType }, - { "vampireBatType", vampireBatType }, - { "pigronataType", pigronataType }, - { "queenLarvaType", queenLarvaType }, - { "miniAntlionType", miniAntlionType }, - { "petGoldfishType", petGoldfishType }, - { "skeletronHandType", skeletronHandType }, - { "skeletronPrimeHandType", skeletronPrimeHandType }, - { "petCultistType", petCultistType }, - { "petAnomalocarisType", petAnomalocarisType }, - { "dynamiteBunnyType", dynamiteBunnyType }, - { "wallFragmentType", wallFragmentType }, - { "metroidPetType", metroidPetType }, - { "cuteLamiaPetType", cuteLamiaPetType }, - - { "oceanSlimeType", oceanSlimeType }, - { "stingSlimeType", stingSlimeType }, - { "animatedTomeType", animatedTomeType }, - - { "youngHarpyType", youngHarpyType } - }; - - tag.Add("petTags", petTags); - } - - private void SavePetAccessories(TagCompound tag) - { - var petAccessoryIdentities = new List(); - - for (int i = 0; i < petAccessoriesBySlots.Length; i++) - { - var (id, altTextureIndex) = petAccessoriesBySlots[i]; - var modName = string.Empty; - var name = string.Empty; - var index = (byte)0; - if (id > 0) - { - var petAccessory = PetAccessory.GetAccessoryFromID((SlotType)(i + 1), id); - - modName = petAccessory.Mod.Name; - name = petAccessory.Name; - index = altTextureIndex; - } - - petAccessoryIdentities.Add(new PetAccessoryIdentity(modName, name, index)); - } - - if (petAccessoryIdentities.Count > 0) - { - tag.Add("petAccessoryIdentities", petAccessoryIdentities); - } - - if (unloadedPetAccessoryIdentities.Count > 0) - { - tag.Add("unloadedPetAccessoryIdentities", unloadedPetAccessoryIdentities); - } - } - - public override void LoadData(TagCompound tag) - { - string mainKey = "petAccessoryIdentities"; - string secondaryKey = "unloadedPetAccessoryIdentities"; - if (tag.ContainsKey(mainKey) || tag.ContainsKey(secondaryKey)) - { - LoadPetAccessories(tag, tag.GetList(mainKey).ToList(), tag.GetList(secondaryKey).ToList()); - } - - mainKey = "petTags"; - if (tag.ContainsKey(mainKey)) - { - var petTags = tag.Get(mainKey); - - mechFrogType = petTags.GetByte("mechFrogType"); - petEyeType = petTags.GetByte("petEyeType"); - cursedSkullType = petTags.GetByte("cursedSkullType"); - youngWyvernType = petTags.GetByte("youngWyvernType"); - petFishronType = petTags.GetByte("petFishronType"); - petMoonType = petTags.GetByte("petMoonType"); - abeeminationType = petTags.GetByte("abeeminationType"); - lilWrapsType = petTags.GetByte("lilWrapsType"); - vampireBatType = petTags.GetByte("vampireBatType"); - pigronataType = petTags.GetByte("pigronataType"); - queenLarvaType = petTags.GetByte("queenLarvaType"); - miniAntlionType = petTags.GetByte("miniAntlionType"); - petGoldfishType = petTags.GetByte("petGoldfishType"); - skeletronHandType = petTags.GetByte("skeletronHandType"); - skeletronPrimeHandType = petTags.GetByte("skeletronPrimeHandType"); - petCultistType = petTags.GetByte("petCultistType"); - petAnomalocarisType = petTags.GetByte("petAnomalocarisType"); - dynamiteBunnyType = petTags.GetByte("dynamiteBunnyType"); - wallFragmentType = petTags.GetByte("wallFragmentType"); - metroidPetType = petTags.GetByte("metroidPetType"); - cuteLamiaPetType = petTags.GetByte("cuteLamiaPetType"); - - oceanSlimeType = petTags.GetByte("oceanSlimeType"); - stingSlimeType = petTags.GetByte("stingSlimeType"); - animatedTomeType = petTags.GetByte("animatedTomeType"); - - youngHarpyType = petTags.GetByte("youngHarpyType"); - } - } - - private void LoadPetAccessories(TagCompound tag, List petAccessories, List unloadedPetAccessories) - { - //Keep same size as the loaded list - var emptyPetAccessory = new PetAccessoryIdentity(string.Empty, string.Empty, 0); - unloadedPetAccessoryIdentities = new(); - for (int i = 0; i < petAccessories.Count; i++) - { - unloadedPetAccessoryIdentities.Add(emptyPetAccessory); - } - - for (int i = 0; i < petAccessoriesBySlots.Length; i++) - { - var loadedPetAccessory = petAccessories[i]; - (string modName, string name, byte index) = loadedPetAccessory; - - bool hasUnloaded = unloadedPetAccessories.Count > 0; - - if (modName != string.Empty && name != string.Empty) - { - //Prioritize handling existing one - if (ModContent.TryFind(modName, name, out PetAccessory petAccessory)) - { - var id = petAccessory.ID; - petAccessoriesBySlots[i] = (id, index); - } - else - { - unloadedPetAccessoryIdentities[i] = loadedPetAccessory; - } - } - else if (hasUnloaded) - { - var unloadedPetAccessory = unloadedPetAccessories[i]; - (string unloadedModName, string unloadedName, byte unloadedIndex) = unloadedPetAccessory; - - if (unloadedModName != string.Empty && unloadedName != string.Empty) - { - //Fall back to unloaded one - if (ModContent.TryFind(unloadedModName, unloadedName, out PetAccessory petAccessory)) - { - var id = petAccessory.ID; - petAccessoriesBySlots[i] = (id, unloadedIndex); - } - else - { - unloadedPetAccessoryIdentities[i] = unloadedPetAccessory; - } - } - } - } - } - - public override void clientClone(ModPlayer clientClone) - { - PetPlayer clone = clientClone as PetPlayer; - - Array.Copy(petAccessoriesBySlots, clone.petAccessoriesBySlots, petAccessoriesBySlots.Length); - Array.Copy(lastPetAccessoriesBySlots, clone.lastPetAccessoriesBySlots, lastPetAccessoriesBySlots.Length); - Array.Copy(ClonedTypes, clone.ClonedTypes, ClonedTypes.Length); - } - - public override void SendClientChanges(ModPlayer clientPlayer) - { - PetPlayer clone = clientPlayer as PetPlayer; - PetPlayerChanges changes = PetPlayerChanges.None; - int index = 255; - - bool slotChanges = false; - for (int i = 0; i < petAccessoriesBySlots.Length; i++) - { - if (clone.petAccessoriesBySlots[i] != petAccessoriesBySlots[i]) - { - slotChanges = true; - break; - } - } - - if (slotChanges) - { - changes = PetPlayerChanges.Slots; - } - else - { - for (int i = 0; i < ClonedTypes.Length; i++) - { - if (clone.ClonedTypes[i] != ClonedTypes[i]) - { - changes = PetPlayerChanges.PetTypes; - index = i; - break; - } - } - } - - if (changes != PetPlayerChanges.None) SendClientChangesPacket(changes, index); - } - - public override void SyncPlayer(int toWho, int fromWho, bool newPlayer) - { - ModPacket packet = Mod.GetPacket(); - packet.Write((byte)AssMessageType.SyncPlayerVanity); - packet.Write((byte)Player.whoAmI); - //no "changes" packet - SendFieldValues(packet); - packet.Send(toWho, fromWho); - } - - private void SendFieldValues(ModPacket packet) - { - for (int i = 0; i < petAccessoriesBySlots.Length; i++) - { - var (id, altTextureIndex) = petAccessoriesBySlots[i]; - packet.Write((byte)id); - packet.Write((byte)altTextureIndex); - } - - for (int i = 0; i < ClonedTypes.Length; i++) - { - packet.Write((byte)ClonedTypes[i]); - } - } - - public void RecvSyncPlayerVanitySub(BinaryReader reader) - { - for (int i = 0; i < petAccessoriesBySlots.Length; i++) - { - byte id = reader.ReadByte(); - byte altTextureIndex = reader.ReadByte(); - petAccessoriesBySlots[i] = (id, altTextureIndex); - } - - for (int i = 0; i < ClonedTypes.Length; i++) - { - ClonedTypes[i] = reader.ReadByte(); - } - GetFromClonedTypes(); - } - - /// - /// Reads from reader to assign the player fields (Called in Mod.HandlePacket()) - /// - public void RecvClientChangesPacketSub(BinaryReader reader, byte changes, int index) - { - //AssUtils.Print("RecvClientChangesPacketSub " + changes + " index " + index + " from p " + player.whoAmI); - switch (changes) - { - case (byte)PetPlayerChanges.All: - RecvSyncPlayerVanitySub(reader); - break; - case (byte)PetPlayerChanges.Slots: - for (int i = 0; i < petAccessoriesBySlots.Length; i++) - { - byte id = reader.ReadByte(); - byte altTextureIndex = reader.ReadByte(); - petAccessoriesBySlots[i] = (id, altTextureIndex); - } - break; - case (byte)PetPlayerChanges.PetTypes: - byte type = reader.ReadByte(); - if (index >= 0 && index < ClonedTypes.Length) ClonedTypes[index] = type; - break; - default: //shouldn't get there hopefully - Mod.Logger.Debug("Received unspecified PetPlayerChanges Packet " + changes); - break; - } - GetFromClonedTypes(); - } - - /// - /// Sends the player fields either to clients or to the server. Called in Mod.HandlePacket() - /// (forwarding data from the server to other players) - /// - public void SendClientChangesPacketSub(byte changes, int index, int toClient = -1, int ignoreClient = -1) - { - //AssUtils.Print("SendClientChangesPacketSub " + changes + " index " + index + " from p " + player.whoAmI + ((Main.netMode == NetmodeID.MultiplayerClient)? " client":" server")); - ModPacket packet = Mod.GetPacket(); - packet.Write((byte)AssMessageType.ClientChangesVanity); - packet.Write((byte)Player.whoAmI); - packet.Write((byte)changes); - packet.Write((byte)index); - - switch (changes) - { - case (byte)PetPlayerChanges.All: - SendFieldValues(packet); - break; - case (byte)PetPlayerChanges.Slots: - for (int i = 0; i < petAccessoriesBySlots.Length; i++) - { - var (id, altTextureIndex) = petAccessoriesBySlots[i]; - packet.Write((byte)id); - packet.Write((byte)altTextureIndex); - } - break; - case (byte)PetPlayerChanges.PetTypes: - packet.Write((byte)ClonedTypes[index]); - break; - default: //shouldn't get there hopefully - Mod.Logger.Debug("Sending unspecified PetPlayerChanges " + changes); - break; - } - - packet.Send(toClient, ignoreClient); - } - - /// - /// Cliendside method to send the chances specified to the server. - /// Called in SendClientChanges() - /// - private void SendClientChangesPacket(PetPlayerChanges changes, int index = 255) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - SendClientChangesPacketSub((byte)changes, index); - } - } - - public override void OnEnterWorld(Player player) - { - enteredWorld = true; - } - - public override void PreUpdate() - { - if (Main.myPlayer == Player.whoAmI) - { - SetClonedTypes(); - } - - if (ContentConfig.Instance.CuteSlimes) - { - ValidateSlimePetIndex(); - - slimeHugsUpdatedThisTick = false; - - if (!createdSlimeHugs) - { - createdSlimeHugs = true; - - SlimeHugs = new List(); - SlimeHugs.AddRange(Mod.GetContent().Select(h => (SlimeHug)h.Clone())); //Fetch every loaded hug, create a new instance of it to use for this player - SlimeHugs.Sort((s1, s2) => s1.CompareTo(s2)); //Sort by cooldown, takes priority from high cooldown - } - } - } - - /// - /// Returns true if the player has a cute slime pet spawned - /// - public bool HasValidSlimePet(out SlimePet slimePet) - { - slimePet = null; - - if (!ContentConfig.Instance.CuteSlimes) - { - return false; - } - - if (slimePetIndex >= 0 && slimePetIndex < Main.maxProjectiles) - { - if (Main.projectile[slimePetIndex] is Projectile projectile) - { - if (projectile.active && projectile.owner == Player.whoAmI && SlimePets.TryGetPetFromProj(projectile.type, out slimePet)) - { - return true; - } - } - } - return false; - } - - #region Slime Pet Hug - public bool slimeHugsUpdatedThisTick = false; //Protection against multiple slime pets updating it at the same time - public const int HugDelaySuccess = 60 * 60 * 5; - public const int HugDelayFail = 60 * 60 * 3; - public int slimeHugTimer = -HugDelaySuccess / 2; //Global hug timer - public bool IsHugging => slimeHugTimer > 0; - - public List SlimeHugs { get; private set; } = new List(); - - public bool createdSlimeHugs = false; - public int slimePetIndex = -1; - - /// - /// Returns true if a slime hug of this type exists and is set to - /// - public bool TryGetSlimeHug(int type, out SlimeHug slimeHug) - { - slimeHug = null; - if (type == -1) return false; - slimeHug = SlimeHugs.FirstOrDefault(h => h.Type == type); - - return slimeHug != null; - } - - /// - /// Global condition under which hug cooldowns will be handled - /// - public static bool CanHandleCooldown(CuteSlimeBaseProj slime) - { - return slime.OnGround; - } - - /// - /// Check active state of the player for if he is legible to receive a hug - /// - public static bool IsHuggable(Player player) - { - return !player.mount.Active && !player.pulley && player.velocity.Y == 0f && player.itemAnimation == 0; - } - - /// - /// Resets the slime pet index if necessary - /// - private void ValidateSlimePetIndex() - { - if (!HasValidSlimePet(out _)) - { - slimePetIndex = -1; - } - } - - //In player: - //1. handle each hug timer in loop separately - //2. If conditions met for initiating a hug, choose a hug - //2a. If no hug chosen, return - //3. If hug chosen but conditions no longer met, fail and return - //4. Assign hug type - - //In projectile: - //5. Apply "appoach to player" AI, play prehug emote - //6. If close enough to player, set hug timer to hug duration - //7. Change AI to hugging, cancelling any other AI - //8. Decrement slimeHugTimer, cancel when 0 - //- Active hug is stored on the projectile (set through SetHugType) - public void UpdateSlimeHugs(CuteSlimeBaseProj slime) - { - if (!ContentConfig.Instance.CuteSlimes) - { - return; - } - - //This is called from within the current slime pet, as it is intertwined with its AI - if (slimePetIndex < 0) - { - //Bad call, reset timer - slimeHugTimer = -HugDelayFail; - return; - } - - if (slimeHugsUpdatedThisTick) - { - return; - } - - slime.oldHugType = slime.hugType; - - slimeHugsUpdatedThisTick = true; - - if (IsHugging) - { - //Handle timer during a hug - slimeHugTimer--; - if (slimeHugTimer == 0) - { - //Hug succeeded, set delay - slime.SetHugType(-1); - slimeHugTimer = -HugDelaySuccess; - } - } - else - { - if (slimeHugTimer < 0) - { - slimeHugTimer++; - } - } - - SlimeHug newHug = null; - foreach (var hug in SlimeHugs) - { - if (CanHandleCooldown(slime) && hug.HandleCooldown()) - { - if (hug.IsAvailable(slime, this)) - { - newHug = hug; - } - } - } - - if (slimeHugTimer != 0 || !IsHuggable(Player) || !slime.CanChooseHug(Player)) - { - return; - } - - if (newHug != null) //Atleast one off cooldown - { - if (slime.hugType != newHug.Type) - { - slime.SetHugType(newHug.Type); - newHug.ApplyCooldown(); - } - - if (!IsHuggable(Player)) - { - //Cancel sequence prematurely - slime.SetHugType(-1); - slimeHugTimer = -HugDelayFail; - return; - } - } - } - #endregion - - #region Slime Pet Vanity - private bool resetPetAccessories = false; - private uint lastTime = 0; - - public (byte id, byte altTextureIndex)[] petAccessoriesBySlots; - public (byte id, byte altTextureIndex)[] lastPetAccessoriesBySlots; - - public List unloadedPetAccessoryIdentities; - - public bool HasPetAccessories - { - get - { - for (int i = 0; i < petAccessoriesBySlots.Length; i++) - { - if (petAccessoriesBySlots[i].id > 0) - { - return true; - } - } - return false; - } - } - - /// - /// Adds the pet vanity accessory to the current pet - /// - public bool AddAccessory(PetAccessory petAccessory) - { - byte slotNumber = (byte)(petAccessory.Slot - 1); - - //id is between 0 and 255 - byte id = petAccessory.ID; - byte altTextureIndex = petAccessory.AltTextureIndex; - - (byte currentID, byte currentAltTextureIndex) = petAccessoriesBySlots[slotNumber]; - - //returns false if accessory was already equipped - if (id == currentID && altTextureIndex == currentAltTextureIndex) - { - return false; - } - - //else sets new - petAccessoriesBySlots[slotNumber] = (id, altTextureIndex); - - return true; - } - - /// - /// Deletes the pet vanity accessory on the current pet - /// - public void DelAccessory(PetAccessory petAccessory) - { - byte slotNumber = (byte)(petAccessory.Slot - 1); - petAccessoriesBySlots[slotNumber] = (0, 0); - } - - /// - /// Toggles the pet vanity acessory on the current pet - /// - public void ToggleAccessory(PetAccessory petAccessory) - { - if (petAccessory.Slot == SlotType.None) throw new Exception("Can't toggle accessory on reserved slot"); - if (!AddAccessory(petAccessory)) DelAccessory(petAccessory); - } - - /// - /// Returns the pet vanity accessory equipped in the specified SlotType of the current pet - /// - public bool TryGetAccessoryInSlot(byte slotNumber, out PetAccessory petAccessory) - { - petAccessory = null; - byte slot = slotNumber; - slotNumber -= 1; - - (byte id, byte altTextureIndex) = petAccessoriesBySlots[slotNumber]; - - if (id == 0) - { - return false; - } - - petAccessory = PetAccessory.GetAccessoryFromID((SlotType)slot, id); - petAccessory.AltTextureIndex = altTextureIndex; - - return petAccessory != null; - } - #endregion - - #region CircleUI - /// - /// Contains a list of CircleUIHandlers that are used in CircleUIStart/End in Mod - /// - public List CircleUIList; - - /// - /// Contains a list of pet type fields (assigned during Load() and every tick in PreUpdate(), - /// and read from in in Multiplayer whenever data is received). - /// Simplifies the saving/loading of tags - /// - public byte[] ClonedTypes; - - public static CircleUIConf GetLifelikeMechanicalFrogConf() - { - List> assets = new List>() { - AssUtils.Instance.Assets.Request("Projectiles/Pets/LifelikeMechanicalFrogProj"), - AssUtils.Instance.Assets.Request("Projectiles/Pets/LifelikeMechanicalFrogProjCrown") }; - - List tooltips = new List() { "Default", "Crowned" }; - - //no need for unlocked + toUnlock - return new CircleUIConf( - Main.projFrames[ModContent.ProjectileType()], - ModContent.ProjectileType(), - assets, null, tooltips, null); - } - - public static CircleUIConf GetDocileDemonEyeConf() - { - List tooltips = new List() { "Red", "Green", "Purple", - "Red Fractured", "Green Fractured", "Purple Fractured", - "Red Mechanical", "Green Mechanical", "Purple Mechanical", - "Red Laser", "Green Laser", "Purple Laser" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } - - public static CircleUIConf GetCursedSkullConf() - { - List tooltips = new List() { "Default", "Dragon" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } - - public static CircleUIConf GetYoungWyvernConf() - { - List tooltips = new List() { "Default", "Mythical", "Arch", "Arch (Legacy)" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } - - public static CircleUIConf GetPetFishronConf() - { - List tooltips = new List() { "Default", "Sharkron", "Sharknado" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } - - public static CircleUIConf GetPetMoonConf() - { - List tooltips = new List() { "Default", "Yellow", "Ringed", "Mythril", "Bright Blue", "Green", "Pink", "Orange", "Purple", }; //9 10 11 are contextual - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } + [Content(ConfigurationSystem.AllFlags, needsAllToFilter: true)] + public class PetPlayer : AssPlayerBase + { + private bool enteredWorld = false; + + private const int altTextureCountLoaded = 25; //IMPORTANT TO INCREMENT THIS EACH TIME A NEW ALT TEXTURE IS ADDED + + //Alt texture types + public byte mechFrogType = 0; + public byte petEyeType = 0; + public byte cursedSkullType = 0; + public byte youngWyvernType = 0; + public byte petFishronType = 0; + public byte petMoonType = 0; + public byte abeeminationType = 0; + public byte lilWrapsType = 0; + public byte vampireBatType = 0; + public byte pigronataType = 0; + public byte queenLarvaType = 0; + public byte miniAntlionType = 0; + public byte petGoldfishType = 0; + public byte skeletronHandType = 0; + public byte skeletronPrimeHandType = 0; + public byte petCultistType = 0; + public byte petAnomalocarisType = 0; + public byte dynamiteBunnyType = 0; + public byte wallFragmentType = 0; + public byte metroidPetType = 0; + public byte cuteLamiaPetType = 0; + + public byte oceanSlimeType = 0; + public byte stingSlimeType = 0; + public byte animatedTomeType = 0; + + public byte youngHarpyType = 0; + + //ALTERNATE + ////name pet texture + //public byte classNameType = 0; + + public bool CuteSlimeYellow = false; + public bool CuteSlimeXmas = false; + public bool CuteSlimeToxic = false; + public bool CuteSlimeSand = false; + public bool CuteSlimeRed = false; + public bool CuteSlimeRainbow = false; + public bool CuteSlimeQueen = false; + public bool CuteSlimePurple = false; + public bool CuteSlimePrincess = false; + public bool CuteSlimePink = false; + public bool CuteSlimeLava = false; + public bool CuteSlimeJungle = false; + public bool CuteSlimeIlluminant = false; + public bool CuteSlimeIce = false; + public bool CuteSlimeGreen = false; + public bool CuteSlimeDungeon = false; + public bool CuteSlimeCrimson = false; + public bool CuteSlimeCorrupt = false; + public bool CuteSlimeBlue = false; + public bool CuteSlimeBlack = false; + + public bool DrumstickElemental = false; + public bool SuspiciousNugget = false; + public bool MiniAntlion = false; + public bool LilWraps = false; + public bool PetFishron = false; + public bool RainbowSlime = false; + public bool PrinceSlime = false; + public bool IlluminantSlime = false; + public bool ChunkySlime = false; + public bool FairySlime = false; + public bool HornedSlime = false; + public bool JoyousSlime = false; + public bool MeatballSlime = false; + public bool OceanSlime = false; + public bool StingSlime = false; + public bool TurtleSlime = false; + public bool Pigronata = false; + public bool Abeemination = false; + public bool MiniMegalodon = false; + public bool YoungHarpy = false; + public bool CuteGastropod = false; + public bool YoungWyvern = false; + public bool BabyIchorSticker = false; + public bool LifelikeMechanicalFrog = false; + public bool ChunkyandMeatball = false; + public bool DemonHeart = false; + public bool BrainofConfusion = false; + public bool AlienHornet = false; + public bool DetachedHungry = false; + public bool BabyOcram = false; + public bool CursedSkull = false; + public bool BabyCrimera = false; + public bool VampireBat = false; + public bool TorturedSoul = false; + public bool EnchantedSword = false; + public bool Goblet = false; + public bool SoulLightPet = false; + public bool SoulLightPet2 = false; + public bool DocileDemonEye = false; + public bool QueenLarva = false; + public bool PetSun = false; + public bool PetMoon = false; + public bool WallFragment = false; + public bool TinyTwins = false; + public bool PetGoldfish = false; + public bool SkeletronHand = false; + public bool SkeletronPrimeHand = false; + public bool PetHarvester = false; + public bool PetGolemHead = false; + public bool TrueObservingEye = false; + public bool PetCultist = false; + public bool PetPlantera = false; + public bool PetEaterofWorlds = false; + public bool PetDestroyer = false; + public bool AnimatedTome = false; + public bool PetAnomalocaris = false; + public bool DynamiteBunny = false; + public bool FairySwarm = false; + public bool SwarmofCthulhu = false; + public bool PetQueenSlime = false; + public bool FailureSlime = false; + public bool GhostMartian = false; + public bool NumberMuncher = false; + public bool StrangeRobot = false; + public bool MetroidPet = false; + public bool CuteLamiaPet = false; + public bool TorchGodLightPet = false; + //ALTERNATE + //public bool ClassName = false; + + public override void ResetEffects() + { + CuteSlimeYellow = false; + CuteSlimeXmas = false; + CuteSlimeToxic = false; + CuteSlimeSand = false; + CuteSlimeRed = false; + CuteSlimeRainbow = false; + CuteSlimePrincess = false; + CuteSlimeQueen = false; + CuteSlimePurple = false; + CuteSlimePink = false; + CuteSlimeLava = false; + CuteSlimeJungle = false; + CuteSlimeIce = false; + CuteSlimeIlluminant = false; + CuteSlimeGreen = false; + CuteSlimeDungeon = false; + CuteSlimeCrimson = false; + CuteSlimeCorrupt = false; + CuteSlimeBlue = false; + CuteSlimeBlack = false; + + DrumstickElemental = false; + SuspiciousNugget = false; + MiniAntlion = false; + LilWraps = false; + PetFishron = false; + RainbowSlime = false; + PrinceSlime = false; + IlluminantSlime = false; + ChunkySlime = false; + FairySlime = false; + HornedSlime = false; + JoyousSlime = false; + MeatballSlime = false; + OceanSlime = false; + StingSlime = false; + TurtleSlime = false; + Pigronata = false; + Abeemination = false; + MiniMegalodon = false; + YoungHarpy = false; + CuteGastropod = false; + YoungWyvern = false; + BabyIchorSticker = false; + LifelikeMechanicalFrog = false; + ChunkyandMeatball = false; + DemonHeart = false; + BrainofConfusion = false; + AlienHornet = false; + DetachedHungry = false; + BabyOcram = false; + CursedSkull = false; + BabyCrimera = false; + VampireBat = false; + TorturedSoul = false; + EnchantedSword = false; + Goblet = false; + SoulLightPet = false; + SoulLightPet2 = false; + DocileDemonEye = false; + QueenLarva = false; + PetSun = false; + PetMoon = false; + WallFragment = false; + TinyTwins = false; + PetGoldfish = false; + SkeletronHand = false; + SkeletronPrimeHand = false; + PetHarvester = false; + PetGolemHead = false; + TrueObservingEye = false; + PetCultist = false; + PetPlantera = false; + PetEaterofWorlds = false; + PetDestroyer = false; + AnimatedTome = false; + PetAnomalocaris = false; + DynamiteBunny = false; + FairySwarm = false; + SwarmofCthulhu = false; + PetQueenSlime = false; + FailureSlime = false; + GhostMartian = false; + NumberMuncher = false; + StrangeRobot = false; + MetroidPet = false; + CuteLamiaPet = false; + TorchGodLightPet = false; + //ALTERNATE + //ClassName = false; + } + + /// + /// Returns true if this has been called the third time after two successful calls within 80 ticks + /// + public bool ThreeTimesUseTime() + { + uint diff = (uint)Math.Abs(Main.GameUpdateCount - lastTime); + if (diff > 40.0) + { + //19 + resetPetAccessories = false; + lastTime = Main.GameUpdateCount; + return false; //step one + } + + //step two and three have to be done in 40 ticks each + if (diff <= 40.0) + { + if (!resetPetAccessories) + { + lastTime = Main.GameUpdateCount; + resetPetAccessories = true; + return false; //step two + } + + //if program gets to here, it is about to return true + + if (resetPetAccessories) + { + resetPetAccessories = false; + return true; //step three + } + } + //should never get here anyway + return false; + } + + public override void SaveData(TagCompound tag) + { + SavePetAccessories(tag); + + TagCompound petTags = new() + { + { "mechFrogType", mechFrogType }, + { "petEyeType", petEyeType }, + { "cursedSkullType", cursedSkullType }, + { "youngWyvernType", youngWyvernType }, + { "petFishronType", petFishronType }, + { "petMoonType", petMoonType }, + { "abeeminationType", abeeminationType }, + { "lilWrapsType", lilWrapsType }, + { "vampireBatType", vampireBatType }, + { "pigronataType", pigronataType }, + { "queenLarvaType", queenLarvaType }, + { "miniAntlionType", miniAntlionType }, + { "petGoldfishType", petGoldfishType }, + { "skeletronHandType", skeletronHandType }, + { "skeletronPrimeHandType", skeletronPrimeHandType }, + { "petCultistType", petCultistType }, + { "petAnomalocarisType", petAnomalocarisType }, + { "dynamiteBunnyType", dynamiteBunnyType }, + { "wallFragmentType", wallFragmentType }, + { "metroidPetType", metroidPetType }, + { "cuteLamiaPetType", cuteLamiaPetType }, + + { "oceanSlimeType", oceanSlimeType }, + { "stingSlimeType", stingSlimeType }, + { "animatedTomeType", animatedTomeType }, + + { "youngHarpyType", youngHarpyType } + }; + + tag.Add("petTags", petTags); + } + + private void SavePetAccessories(TagCompound tag) + { + var petAccessoryIdentities = new List(); + + for (int i = 0; i < petAccessoriesBySlots.Length; i++) + { + var (id, altTextureIndex) = petAccessoriesBySlots[i]; + var modName = string.Empty; + var name = string.Empty; + var index = (byte)0; + if (id > 0) + { + var petAccessory = PetAccessory.GetAccessoryFromID((SlotType)(i + 1), id); + + modName = petAccessory.Mod.Name; + name = petAccessory.Name; + index = altTextureIndex; + } + + petAccessoryIdentities.Add(new PetAccessoryIdentity(modName, name, index)); + } + + if (petAccessoryIdentities.Count > 0) + { + tag.Add("petAccessoryIdentities", petAccessoryIdentities); + } + + if (unloadedPetAccessoryIdentities.Count > 0) + { + tag.Add("unloadedPetAccessoryIdentities", unloadedPetAccessoryIdentities); + } + } + + public override void LoadData(TagCompound tag) + { + string mainKey = "petAccessoryIdentities"; + string secondaryKey = "unloadedPetAccessoryIdentities"; + if (tag.ContainsKey(mainKey) || tag.ContainsKey(secondaryKey)) + { + LoadPetAccessories(tag, tag.GetList(mainKey).ToList(), tag.GetList(secondaryKey).ToList()); + } + + mainKey = "petTags"; + if (tag.ContainsKey(mainKey)) + { + var petTags = tag.Get(mainKey); + + mechFrogType = petTags.GetByte("mechFrogType"); + petEyeType = petTags.GetByte("petEyeType"); + cursedSkullType = petTags.GetByte("cursedSkullType"); + youngWyvernType = petTags.GetByte("youngWyvernType"); + petFishronType = petTags.GetByte("petFishronType"); + petMoonType = petTags.GetByte("petMoonType"); + abeeminationType = petTags.GetByte("abeeminationType"); + lilWrapsType = petTags.GetByte("lilWrapsType"); + vampireBatType = petTags.GetByte("vampireBatType"); + pigronataType = petTags.GetByte("pigronataType"); + queenLarvaType = petTags.GetByte("queenLarvaType"); + miniAntlionType = petTags.GetByte("miniAntlionType"); + petGoldfishType = petTags.GetByte("petGoldfishType"); + skeletronHandType = petTags.GetByte("skeletronHandType"); + skeletronPrimeHandType = petTags.GetByte("skeletronPrimeHandType"); + petCultistType = petTags.GetByte("petCultistType"); + petAnomalocarisType = petTags.GetByte("petAnomalocarisType"); + dynamiteBunnyType = petTags.GetByte("dynamiteBunnyType"); + wallFragmentType = petTags.GetByte("wallFragmentType"); + metroidPetType = petTags.GetByte("metroidPetType"); + cuteLamiaPetType = petTags.GetByte("cuteLamiaPetType"); + + oceanSlimeType = petTags.GetByte("oceanSlimeType"); + stingSlimeType = petTags.GetByte("stingSlimeType"); + animatedTomeType = petTags.GetByte("animatedTomeType"); + + youngHarpyType = petTags.GetByte("youngHarpyType"); + } + } + + private void LoadPetAccessories(TagCompound tag, List petAccessories, List unloadedPetAccessories) + { + //Keep same size as the loaded list + var emptyPetAccessory = new PetAccessoryIdentity(string.Empty, string.Empty, 0); + unloadedPetAccessoryIdentities = new(); + for (int i = 0; i < petAccessories.Count; i++) + { + unloadedPetAccessoryIdentities.Add(emptyPetAccessory); + } + + for (int i = 0; i < petAccessoriesBySlots.Length; i++) + { + var loadedPetAccessory = petAccessories[i]; + (string modName, string name, byte index) = loadedPetAccessory; + + bool hasUnloaded = unloadedPetAccessories.Count > 0; + + if (modName != string.Empty && name != string.Empty) + { + //Prioritize handling existing one + if (ModContent.TryFind(modName, name, out PetAccessory petAccessory)) + { + var id = petAccessory.ID; + petAccessoriesBySlots[i] = (id, index); + } + else + { + unloadedPetAccessoryIdentities[i] = loadedPetAccessory; + } + } + else if (hasUnloaded) + { + var unloadedPetAccessory = unloadedPetAccessories[i]; + (string unloadedModName, string unloadedName, byte unloadedIndex) = unloadedPetAccessory; + + if (unloadedModName != string.Empty && unloadedName != string.Empty) + { + //Fall back to unloaded one + if (ModContent.TryFind(unloadedModName, unloadedName, out PetAccessory petAccessory)) + { + var id = petAccessory.ID; + petAccessoriesBySlots[i] = (id, unloadedIndex); + } + else + { + unloadedPetAccessoryIdentities[i] = unloadedPetAccessory; + } + } + } + } + } + + public override void clientClone(ModPlayer clientClone) + { + PetPlayer clone = clientClone as PetPlayer; + + Array.Copy(petAccessoriesBySlots, clone.petAccessoriesBySlots, petAccessoriesBySlots.Length); + Array.Copy(lastPetAccessoriesBySlots, clone.lastPetAccessoriesBySlots, lastPetAccessoriesBySlots.Length); + Array.Copy(ClonedTypes, clone.ClonedTypes, ClonedTypes.Length); + } + + public override void SendClientChanges(ModPlayer clientPlayer) + { + PetPlayer clone = clientPlayer as PetPlayer; + PetPlayerChanges changes = PetPlayerChanges.None; + int index = 255; + + bool slotChanges = false; + for (int i = 0; i < petAccessoriesBySlots.Length; i++) + { + if (clone.petAccessoriesBySlots[i] != petAccessoriesBySlots[i]) + { + slotChanges = true; + break; + } + } + + if (slotChanges) + { + changes = PetPlayerChanges.Slots; + } + else + { + for (int i = 0; i < ClonedTypes.Length; i++) + { + if (clone.ClonedTypes[i] != ClonedTypes[i]) + { + changes = PetPlayerChanges.PetTypes; + index = i; + break; + } + } + } + + if (changes != PetPlayerChanges.None) SendClientChangesPacket(changes, index); + } + + public override void SyncPlayer(int toWho, int fromWho, bool newPlayer) + { + ModPacket packet = Mod.GetPacket(); + packet.Write((byte)AssMessageType.SyncPlayerVanity); + packet.Write((byte)Player.whoAmI); + //no "changes" packet + SendFieldValues(packet); + packet.Send(toWho, fromWho); + } + + private void SendFieldValues(ModPacket packet) + { + for (int i = 0; i < petAccessoriesBySlots.Length; i++) + { + var (id, altTextureIndex) = petAccessoriesBySlots[i]; + packet.Write((byte)id); + packet.Write((byte)altTextureIndex); + } + + for (int i = 0; i < ClonedTypes.Length; i++) + { + packet.Write((byte)ClonedTypes[i]); + } + } + + public void RecvSyncPlayerVanitySub(BinaryReader reader) + { + for (int i = 0; i < petAccessoriesBySlots.Length; i++) + { + byte id = reader.ReadByte(); + byte altTextureIndex = reader.ReadByte(); + petAccessoriesBySlots[i] = (id, altTextureIndex); + } + + for (int i = 0; i < ClonedTypes.Length; i++) + { + ClonedTypes[i] = reader.ReadByte(); + } + GetFromClonedTypes(); + } + + /// + /// Reads from reader to assign the player fields (Called in Mod.HandlePacket()) + /// + public void RecvClientChangesPacketSub(BinaryReader reader, byte changes, int index) + { + //AssUtils.Print("RecvClientChangesPacketSub " + changes + " index " + index + " from p " + player.whoAmI); + switch (changes) + { + case (byte)PetPlayerChanges.All: + RecvSyncPlayerVanitySub(reader); + break; + case (byte)PetPlayerChanges.Slots: + for (int i = 0; i < petAccessoriesBySlots.Length; i++) + { + byte id = reader.ReadByte(); + byte altTextureIndex = reader.ReadByte(); + petAccessoriesBySlots[i] = (id, altTextureIndex); + } + break; + case (byte)PetPlayerChanges.PetTypes: + byte type = reader.ReadByte(); + if (index >= 0 && index < ClonedTypes.Length) ClonedTypes[index] = type; + break; + default: //shouldn't get there hopefully + Mod.Logger.Debug("Received unspecified PetPlayerChanges Packet " + changes); + break; + } + GetFromClonedTypes(); + } + + /// + /// Sends the player fields either to clients or to the server. Called in Mod.HandlePacket() + /// (forwarding data from the server to other players) + /// + public void SendClientChangesPacketSub(byte changes, int index, int toClient = -1, int ignoreClient = -1) + { + //AssUtils.Print("SendClientChangesPacketSub " + changes + " index " + index + " from p " + player.whoAmI + ((Main.netMode == NetmodeID.MultiplayerClient)? " client":" server")); + ModPacket packet = Mod.GetPacket(); + packet.Write((byte)AssMessageType.ClientChangesVanity); + packet.Write((byte)Player.whoAmI); + packet.Write((byte)changes); + packet.Write((byte)index); + + switch (changes) + { + case (byte)PetPlayerChanges.All: + SendFieldValues(packet); + break; + case (byte)PetPlayerChanges.Slots: + for (int i = 0; i < petAccessoriesBySlots.Length; i++) + { + var (id, altTextureIndex) = petAccessoriesBySlots[i]; + packet.Write((byte)id); + packet.Write((byte)altTextureIndex); + } + break; + case (byte)PetPlayerChanges.PetTypes: + packet.Write((byte)ClonedTypes[index]); + break; + default: //shouldn't get there hopefully + Mod.Logger.Debug("Sending unspecified PetPlayerChanges " + changes); + break; + } + + packet.Send(toClient, ignoreClient); + } + + /// + /// Cliendside method to send the chances specified to the server. + /// Called in SendClientChanges() + /// + private void SendClientChangesPacket(PetPlayerChanges changes, int index = 255) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + SendClientChangesPacketSub((byte)changes, index); + } + } + + public override void OnEnterWorld(Player player) + { + enteredWorld = true; + } + + public override void PreUpdate() + { + if (Main.myPlayer == Player.whoAmI) + { + SetClonedTypes(); + } + + if (ContentConfig.Instance.CuteSlimes) + { + ValidateSlimePetIndex(); + + slimeHugsUpdatedThisTick = false; + + if (!createdSlimeHugs) + { + createdSlimeHugs = true; + + SlimeHugs = new List(); + SlimeHugs.AddRange(Mod.GetContent().Select(h => (SlimeHug)h.Clone())); //Fetch every loaded hug, create a new instance of it to use for this player + SlimeHugs.Sort((s1, s2) => s1.CompareTo(s2)); //Sort by cooldown, takes priority from high cooldown + } + } + } + + /// + /// Returns true if the player has a cute slime pet spawned + /// + public bool HasValidSlimePet(out SlimePet slimePet) + { + slimePet = null; + + if (!ContentConfig.Instance.CuteSlimes) + { + return false; + } + + if (slimePetIndex >= 0 && slimePetIndex < Main.maxProjectiles) + { + if (Main.projectile[slimePetIndex] is Projectile projectile) + { + if (projectile.active && projectile.owner == Player.whoAmI && SlimePets.TryGetPetFromProj(projectile.type, out slimePet)) + { + return true; + } + } + } + return false; + } + + #region Slime Pet Hug + public bool slimeHugsUpdatedThisTick = false; //Protection against multiple slime pets updating it at the same time + public const int HugDelaySuccess = 60 * 60 * 5; + public const int HugDelayFail = 60 * 60 * 3; + public int slimeHugTimer = -HugDelaySuccess / 2; //Global hug timer + public bool IsHugging => slimeHugTimer > 0; + + public List SlimeHugs { get; private set; } = new List(); + + public bool createdSlimeHugs = false; + public int slimePetIndex = -1; + + /// + /// Returns true if a slime hug of this type exists and is set to + /// + public bool TryGetSlimeHug(int type, out SlimeHug slimeHug) + { + slimeHug = null; + if (type == -1) return false; + slimeHug = SlimeHugs.FirstOrDefault(h => h.Type == type); + + return slimeHug != null; + } + + /// + /// Global condition under which hug cooldowns will be handled + /// + public static bool CanHandleCooldown(CuteSlimeBaseProj slime) + { + return slime.OnGround; + } + + /// + /// Check active state of the player for if he is legible to receive a hug + /// + public static bool IsHuggable(Player player) + { + return !player.mount.Active && !player.pulley && player.velocity.Y == 0f && player.itemAnimation == 0; + } + + /// + /// Resets the slime pet index if necessary + /// + private void ValidateSlimePetIndex() + { + if (!HasValidSlimePet(out _)) + { + slimePetIndex = -1; + } + } + + //In player: + //1. handle each hug timer in loop separately + //2. If conditions met for initiating a hug, choose a hug + //2a. If no hug chosen, return + //3. If hug chosen but conditions no longer met, fail and return + //4. Assign hug type + + //In projectile: + //5. Apply "appoach to player" AI, play prehug emote + //6. If close enough to player, set hug timer to hug duration + //7. Change AI to hugging, cancelling any other AI + //8. Decrement slimeHugTimer, cancel when 0 + //- Active hug is stored on the projectile (set through SetHugType) + public void UpdateSlimeHugs(CuteSlimeBaseProj slime) + { + if (!ContentConfig.Instance.CuteSlimes) + { + return; + } + + //This is called from within the current slime pet, as it is intertwined with its AI + if (slimePetIndex < 0) + { + //Bad call, reset timer + slimeHugTimer = -HugDelayFail; + return; + } + + if (slimeHugsUpdatedThisTick) + { + return; + } + + slime.oldHugType = slime.hugType; + + slimeHugsUpdatedThisTick = true; + + if (IsHugging) + { + //Handle timer during a hug + slimeHugTimer--; + if (slimeHugTimer == 0) + { + //Hug succeeded, set delay + slime.SetHugType(-1); + slimeHugTimer = -HugDelaySuccess; + } + } + else + { + if (slimeHugTimer < 0) + { + slimeHugTimer++; + } + } + + SlimeHug newHug = null; + foreach (var hug in SlimeHugs) + { + if (CanHandleCooldown(slime) && hug.HandleCooldown()) + { + if (hug.IsAvailable(slime, this)) + { + newHug = hug; + } + } + } + + if (slimeHugTimer != 0 || !IsHuggable(Player) || !slime.CanChooseHug(Player)) + { + return; + } + + if (newHug != null) //Atleast one off cooldown + { + if (slime.hugType != newHug.Type) + { + slime.SetHugType(newHug.Type); + newHug.ApplyCooldown(); + } + + if (!IsHuggable(Player)) + { + //Cancel sequence prematurely + slime.SetHugType(-1); + slimeHugTimer = -HugDelayFail; + return; + } + } + } + #endregion + + #region Slime Pet Vanity + private bool resetPetAccessories = false; + private uint lastTime = 0; + + public (byte id, byte altTextureIndex)[] petAccessoriesBySlots; + public (byte id, byte altTextureIndex)[] lastPetAccessoriesBySlots; + + public List unloadedPetAccessoryIdentities; + + public bool HasPetAccessories + { + get + { + for (int i = 0; i < petAccessoriesBySlots.Length; i++) + { + if (petAccessoriesBySlots[i].id > 0) + { + return true; + } + } + return false; + } + } + + /// + /// Adds the pet vanity accessory to the current pet + /// + public bool AddAccessory(PetAccessory petAccessory) + { + byte slotNumber = (byte)(petAccessory.Slot - 1); + + //id is between 0 and 255 + byte id = petAccessory.ID; + byte altTextureIndex = petAccessory.AltTextureIndex; + + (byte currentID, byte currentAltTextureIndex) = petAccessoriesBySlots[slotNumber]; + + //returns false if accessory was already equipped + if (id == currentID && altTextureIndex == currentAltTextureIndex) + { + return false; + } + + //else sets new + petAccessoriesBySlots[slotNumber] = (id, altTextureIndex); + + return true; + } + + /// + /// Deletes the pet vanity accessory on the current pet + /// + public void DelAccessory(PetAccessory petAccessory) + { + byte slotNumber = (byte)(petAccessory.Slot - 1); + petAccessoriesBySlots[slotNumber] = (0, 0); + } + + /// + /// Toggles the pet vanity acessory on the current pet + /// + public void ToggleAccessory(PetAccessory petAccessory) + { + if (petAccessory.Slot == SlotType.None) throw new Exception("Can't toggle accessory on reserved slot"); + if (!AddAccessory(petAccessory)) DelAccessory(petAccessory); + } + + /// + /// Returns the pet vanity accessory equipped in the specified SlotType of the current pet + /// + public bool TryGetAccessoryInSlot(byte slotNumber, out PetAccessory petAccessory) + { + petAccessory = null; + byte slot = slotNumber; + slotNumber -= 1; + + (byte id, byte altTextureIndex) = petAccessoriesBySlots[slotNumber]; + + if (id == 0) + { + return false; + } + + petAccessory = PetAccessory.GetAccessoryFromID((SlotType)slot, id); + petAccessory.AltTextureIndex = altTextureIndex; + + return petAccessory != null; + } + #endregion + + #region CircleUI + /// + /// Contains a list of CircleUIHandlers that are used in CircleUIStart/End in Mod + /// + public List CircleUIList; + + /// + /// Contains a list of pet type fields (assigned during Load() and every tick in PreUpdate(), + /// and read from in in Multiplayer whenever data is received). + /// Simplifies the saving/loading of tags + /// + public byte[] ClonedTypes; + + public static CircleUIConf GetLifelikeMechanicalFrogConf() + { + List> assets = new List>() { + AssUtils.Instance.Assets.Request("Projectiles/Pets/LifelikeMechanicalFrogProj"), + AssUtils.Instance.Assets.Request("Projectiles/Pets/LifelikeMechanicalFrogProjCrown") }; + + List tooltips = new List() { "Default", "Crowned" }; + + //no need for unlocked + toUnlock + return new CircleUIConf( + Main.projFrames[ModContent.ProjectileType()], + ModContent.ProjectileType(), + assets, null, tooltips, null); + } + + public static CircleUIConf GetDocileDemonEyeConf() + { + List tooltips = new List() { "Red", "Green", "Purple", + "Red Fractured", "Green Fractured", "Purple Fractured", + "Red Mechanical", "Green Mechanical", "Purple Mechanical", + "Red Laser", "Green Laser", "Purple Laser" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } + + public static CircleUIConf GetCursedSkullConf() + { + List tooltips = new List() { "Default", "Dragon" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } + + public static CircleUIConf GetYoungWyvernConf() + { + List tooltips = new List() { "Default", "Mythical", "Arch", "Arch (Legacy)" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } + + public static CircleUIConf GetPetFishronConf() + { + List tooltips = new List() { "Default", "Sharkron", "Sharknado" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } + + public static CircleUIConf GetPetMoonConf() + { + List tooltips = new List() { "Default", "Yellow", "Ringed", "Mythril", "Bright Blue", "Green", "Pink", "Orange", "Purple", }; //9 10 11 are contextual + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } - public static CircleUIConf GetYoungHarpyConf() - { - List tooltips = new List() { "Default", "Eagle", "Raven", "Dove", "Default (Legacy)", "Eagle (Legacy)", "Raven (Legacy)", "Dove (Legacy)" }; + public static CircleUIConf GetYoungHarpyConf() + { + List tooltips = new List() { "Default", "Eagle", "Raven", "Dove", "Default (Legacy)", "Eagle (Legacy)", "Raven (Legacy)", "Dove (Legacy)" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, 4f)); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, 4f)); + } - public static CircleUIConf GetAbeeminationConf() - { - List tooltips = new List() { "Default", "Snow Bee", "Oil Spill", "Missing Ingredients" }; + public static CircleUIConf GetAbeeminationConf() + { + List tooltips = new List() { "Default", "Snow Bee", "Oil Spill", "Missing Ingredients" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -4f)); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -4f)); + } - public static CircleUIConf GetLilWrapsConf() - { - List tooltips = new List() { "Default", "Dark", "Light", "Shadow", "Spectral" }; + public static CircleUIConf GetLilWrapsConf() + { + List tooltips = new List() { "Default", "Dark", "Light", "Shadow", "Spectral" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } - public static CircleUIConf GetVampireBatConf() - { - List tooltips = new List() { "Default", "Werebat" }; + public static CircleUIConf GetVampireBatConf() + { + List tooltips = new List() { "Default", "Werebat" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } - public static CircleUIConf GetPigronataConf() - { - List tooltips = new List() { "Default", "Winter", "Autumn", "Spring", "Summer", "Halloween", "Christmas" }; + public static CircleUIConf GetPigronataConf() + { + List tooltips = new List() { "Default", "Winter", "Autumn", "Spring", "Summer", "Halloween", "Christmas" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } - public static CircleUIConf GetQueenLarvaConf() - { - List tooltips = new List() { "Default", "Prawn Larva", "Unexpected Seed", "Big Kid Larva", "Where's The Baby?" }; + public static CircleUIConf GetQueenLarvaConf() + { + List tooltips = new List() { "Default", "Prawn Larva", "Unexpected Seed", "Big Kid Larva", "Where's The Baby?" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } - public static CircleUIConf GetOceanSlimeConf() - { - List tooltips = new List() { "Default", "Stupid Hat", "Gnarly Grin", "Flipped Jelly" }; + public static CircleUIConf GetOceanSlimeConf() + { + List tooltips = new List() { "Default", "Stupid Hat", "Gnarly Grin", "Flipped Jelly" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(1f, -4f)); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(1f, -4f)); + } - public static CircleUIConf GetStingSlimeConf() - { - List tooltips = new List() { "Black", "Orange" }; + public static CircleUIConf GetStingSlimeConf() + { + List tooltips = new List() { "Black", "Orange" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(1f, -4f)); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(1f, -4f)); + } - public static CircleUIConf GetMiniAntlionConf() - { - List tooltips = new List() { "Default", "Albino", "Larval" }; + public static CircleUIConf GetMiniAntlionConf() + { + List tooltips = new List() { "Default", "Albino", "Larval" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -4f)); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -4f)); + } - public static CircleUIConf PetGoldfishConf() - { - List tooltips = new List() { "Default", "Crimson", "Corruption", "Bunny" }; + public static CircleUIConf PetGoldfishConf() + { + List tooltips = new List() { "Default", "Crimson", "Corruption", "Bunny" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } - public static CircleUIConf GetSkeletronHandConf() - { - List tooltips = new List() { "Default", "OK-Hand", "Peace", "Rock It", "Fist" }; + public static CircleUIConf GetSkeletronHandConf() + { + List tooltips = new List() { "Default", "OK-Hand", "Peace", "Rock It", "Fist" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(2, -4f)); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(2, -4f)); + } - public static CircleUIConf GetSkeletronPrimeHandConf() - { - List tooltips = new List() { "Cannon", "Saw", "Vice", "Laser" }; + public static CircleUIConf GetSkeletronPrimeHandConf() + { + List tooltips = new List() { "Cannon", "Saw", "Vice", "Laser" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -4f)); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -4f)); + } - public static CircleUIConf GetPetCultistConf() - { - List tooltips = new List() { "Lunar", "Solar" }; + public static CircleUIConf GetPetCultistConf() + { + List tooltips = new List() { "Lunar", "Solar" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(1f, 0f)); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(1f, 0f)); + } - public static CircleUIConf GetAnimatedTomeConf() - { - List tooltips = new List() { "Green", "Blue", "Purple", "Pink", "Yellow", "Spell" }; + public static CircleUIConf GetAnimatedTomeConf() + { + List tooltips = new List() { "Green", "Blue", "Purple", "Pink", "Yellow", "Spell" }; - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } - public static CircleUIConf GetAnomalocarisConf() - { - List tooltips = new List() { "Wild", "Shrimpy", "Snippy" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } - - public static CircleUIConf GetDynamiteBunnyConf() - { - List tooltips = new List() { "White", "Corrupt", "Crimtane", "Angora", "Dutch", "Flemish", "Lop", "Silver", "Caerbannog" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -7f)); - } - - public static CircleUIConf GetWallFragmentConf() - { - List tooltips = new List() { "Default", "Chinese" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - } - - public static CircleUIConf GetMetroidPetConf() - { - List tooltips = new List() { "Metroid", "Failed Clone", "Convergent", "Irradiated", "Corrupted", "The Baby" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -2f)); - } - - public static CircleUIConf GetCuteLamiaPetConf() - { - List tooltips = new List() { "Dark", "Light", "Dropkick" }; - - return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, 0f)); - } - - //ALTERNATE - //public static CircleUIConf GetClassNameConf() - //{ - // List tooltips = new List() { "Default", "AltName1", "AltName2" }; - - // return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); - //} - - public override void Initialize() - { - ClonedTypes = new byte[altTextureCountLoaded]; - - mechFrogType = 0; - petEyeType = 0; - cursedSkullType = 0; - youngWyvernType = 0; - petFishronType = 0; - petMoonType = 0; - abeeminationType = 0; - lilWrapsType = 0; - vampireBatType = 0; - pigronataType = 0; - queenLarvaType = 0; - miniAntlionType = 0; - petGoldfishType = 0; - skeletronHandType = 0; - skeletronPrimeHandType = 0; - petCultistType = 0; - petAnomalocarisType = 0; - dynamiteBunnyType = 0; - wallFragmentType = 0; - metroidPetType = 0; - cuteLamiaPetType = 0; - - oceanSlimeType = 0; - stingSlimeType = 0; - animatedTomeType = 0; - - youngHarpyType = 0; - - petAccessoriesBySlots = new (byte, byte)[4]; //C# initializes the array as (0,0) - lastPetAccessoriesBySlots = new (byte, byte)[4]; - - unloadedPetAccessoryIdentities = new List(); - - SlimeHugs = new List(); - - //called before Load() - //needs to call new List() since Initialize() is called per player in the player select screen - - CircleUIList = new List(); - - if (ContentConfig.Instance.OtherPets) - { - CircleUIList.AddRange(new List - { - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => LifelikeMechanicalFrog, - uiConf: GetLifelikeMechanicalFrogConf, - onUIStart: () => mechFrogType, - onUIEnd: () => mechFrogType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => DocileDemonEye, - uiConf: GetDocileDemonEyeConf, - onUIStart: () => petEyeType, - onUIEnd: () => petEyeType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => CursedSkull, - uiConf: GetCursedSkullConf, - onUIStart: () => cursedSkullType, - onUIEnd: () => cursedSkullType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => YoungWyvern, - uiConf: GetYoungWyvernConf, - onUIStart: () => youngWyvernType, - onUIEnd: () => youngWyvernType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => PetMoon, - uiConf: GetPetMoonConf, - onUIStart: () => petMoonType, - onUIEnd: () => petMoonType = (byte)CircleUI.returned, - triggerLeft: false - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => Abeemination, - uiConf: GetAbeeminationConf, - onUIStart: () => abeeminationType, - onUIEnd: () => abeeminationType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => VampireBat, - uiConf: GetVampireBatConf, - onUIStart: () => vampireBatType, - onUIEnd: () => vampireBatType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => Pigronata, - uiConf: GetPigronataConf, - onUIStart: () => pigronataType, - onUIEnd: () => pigronataType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => PetGoldfish, - uiConf: PetGoldfishConf, - onUIStart: () => petGoldfishType, - onUIEnd: () => petGoldfishType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => PetAnomalocaris, - uiConf: GetAnomalocarisConf, - onUIStart: () => petAnomalocarisType, - onUIEnd: () => petAnomalocarisType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => DynamiteBunny, - uiConf: GetDynamiteBunnyConf, - onUIStart: () => dynamiteBunnyType, - onUIEnd: () => dynamiteBunnyType = (byte)CircleUI.returned - ), + public static CircleUIConf GetAnomalocarisConf() + { + List tooltips = new List() { "Wild", "Shrimpy", "Snippy" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } + + public static CircleUIConf GetDynamiteBunnyConf() + { + List tooltips = new List() { "White", "Corrupt", "Crimtane", "Angora", "Dutch", "Flemish", "Lop", "Silver", "Caerbannog" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -7f)); + } + + public static CircleUIConf GetWallFragmentConf() + { + List tooltips = new List() { "Default", "Chinese" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + } + + public static CircleUIConf GetMetroidPetConf() + { + List tooltips = new List() { "Metroid", "Failed Clone", "Convergent", "Irradiated", "Corrupted", "The Baby" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, -2f)); + } + + public static CircleUIConf GetCuteLamiaPetConf() + { + List tooltips = new List() { "Dark", "Light", "Dropkick" }; + + return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips, new Vector2(0f, 0f)); + } + + //ALTERNATE + //public static CircleUIConf GetClassNameConf() + //{ + // List tooltips = new List() { "Default", "AltName1", "AltName2" }; + + // return CircleUIHandler.PetConf(ModContent.ProjectileType(), tooltips); + //} + + public override void Initialize() + { + ClonedTypes = new byte[altTextureCountLoaded]; + + mechFrogType = 0; + petEyeType = 0; + cursedSkullType = 0; + youngWyvernType = 0; + petFishronType = 0; + petMoonType = 0; + abeeminationType = 0; + lilWrapsType = 0; + vampireBatType = 0; + pigronataType = 0; + queenLarvaType = 0; + miniAntlionType = 0; + petGoldfishType = 0; + skeletronHandType = 0; + skeletronPrimeHandType = 0; + petCultistType = 0; + petAnomalocarisType = 0; + dynamiteBunnyType = 0; + wallFragmentType = 0; + metroidPetType = 0; + cuteLamiaPetType = 0; + + oceanSlimeType = 0; + stingSlimeType = 0; + animatedTomeType = 0; + + youngHarpyType = 0; + + petAccessoriesBySlots = new (byte, byte)[4]; //C# initializes the array as (0,0) + lastPetAccessoriesBySlots = new (byte, byte)[4]; + + unloadedPetAccessoryIdentities = new List(); + + SlimeHugs = new List(); + + //called before Load() + //needs to call new List() since Initialize() is called per player in the player select screen + + CircleUIList = new List(); + + if (ContentConfig.Instance.OtherPets) + { + CircleUIList.AddRange(new List + { + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => LifelikeMechanicalFrog, + uiConf: GetLifelikeMechanicalFrogConf, + onUIStart: () => mechFrogType, + onUIEnd: () => mechFrogType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => DocileDemonEye, + uiConf: GetDocileDemonEyeConf, + onUIStart: () => petEyeType, + onUIEnd: () => petEyeType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => CursedSkull, + uiConf: GetCursedSkullConf, + onUIStart: () => cursedSkullType, + onUIEnd: () => cursedSkullType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => YoungWyvern, + uiConf: GetYoungWyvernConf, + onUIStart: () => youngWyvernType, + onUIEnd: () => youngWyvernType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => PetMoon, + uiConf: GetPetMoonConf, + onUIStart: () => petMoonType, + onUIEnd: () => petMoonType = (byte)CircleUI.returned, + triggerLeft: false + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => Abeemination, + uiConf: GetAbeeminationConf, + onUIStart: () => abeeminationType, + onUIEnd: () => abeeminationType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => VampireBat, + uiConf: GetVampireBatConf, + onUIStart: () => vampireBatType, + onUIEnd: () => vampireBatType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => Pigronata, + uiConf: GetPigronataConf, + onUIStart: () => pigronataType, + onUIEnd: () => pigronataType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => PetGoldfish, + uiConf: PetGoldfishConf, + onUIStart: () => petGoldfishType, + onUIEnd: () => petGoldfishType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => PetAnomalocaris, + uiConf: GetAnomalocarisConf, + onUIStart: () => petAnomalocarisType, + onUIEnd: () => petAnomalocarisType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => DynamiteBunny, + uiConf: GetDynamiteBunnyConf, + onUIStart: () => dynamiteBunnyType, + onUIEnd: () => dynamiteBunnyType = (byte)CircleUI.returned + ), //ALTERNATE // new CircleUIHandler( // triggerItem: ModContent.ItemType(), @@ -1243,220 +1243,220 @@ public override void Initialize() // needsSaving: true //), }); - } - - if (ContentConfig.Instance.DroppedPets) - { - int vanitySelector = ModContent.ItemType(); - CircleUIList.AddRange(new List() - { - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => QueenLarva, - uiConf: GetQueenLarvaConf, - onUIStart: () => queenLarvaType, - onUIEnd: () => queenLarvaType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => MiniAntlion, - uiConf: GetMiniAntlionConf, - onUIStart: () => miniAntlionType, - onUIEnd: () => miniAntlionType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => LilWraps, - uiConf: GetLilWrapsConf, - onUIStart: () => lilWrapsType, - onUIEnd: () => lilWrapsType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => WallFragment, - uiConf: GetWallFragmentConf, - onUIStart: () => wallFragmentType, - onUIEnd: () => wallFragmentType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => MetroidPet, - uiConf: GetMetroidPetConf, - onUIStart: () => metroidPetType, - onUIEnd: () => metroidPetType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => CuteLamiaPet, - uiConf: GetCuteLamiaPetConf, - onUIStart: () => cuteLamiaPetType, - onUIEnd: () => cuteLamiaPetType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => SkeletronHand, - uiConf: GetSkeletronHandConf, - onUIStart: () => skeletronHandType, - onUIEnd: () => skeletronHandType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => SkeletronPrimeHand, - uiConf: GetSkeletronPrimeHandConf, - onUIStart: () => skeletronPrimeHandType, - onUIEnd: () => skeletronPrimeHandType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => PetCultist, - uiConf: GetPetCultistConf, - onUIStart: () => petCultistType, - onUIEnd: () => petCultistType = (byte)CircleUI.returned, - triggerLeft: false - ), - new CircleUIHandler( - triggerItem: vanitySelector, - condition: () => PetFishron, - uiConf: GetPetFishronConf, - onUIStart: () => petFishronType, - onUIEnd: () => petFishronType = (byte)CircleUI.returned - ) - }); - } - - if (ContentConfig.Instance.HostileNPCs) - { - CircleUIList.AddRange(new List() - { - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => OceanSlime, - uiConf: GetOceanSlimeConf, - onUIStart: () => oceanSlimeType, - onUIEnd: () => oceanSlimeType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => StingSlime, - uiConf: GetStingSlimeConf, - onUIStart: () => stingSlimeType, - onUIEnd: () => stingSlimeType = (byte)CircleUI.returned - ), - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => AnimatedTome, - uiConf: GetAnimatedTomeConf, - onUIStart: () => animatedTomeType, - onUIEnd: () => animatedTomeType = (byte)CircleUI.returned - ) - }); - } - - if (ContentConfig.Instance.FriendlyNPCs) - { - CircleUIList.AddRange(new List() - { - new CircleUIHandler( - triggerItem: ModContent.ItemType(), - condition: () => YoungHarpy, - uiConf: GetYoungHarpyConf, - onUIStart: () => youngHarpyType, - onUIEnd: () => youngHarpyType = (byte)CircleUI.returned - ), - }); - } - - //after filling the list - for (int i = 0; i < CircleUIList.Count; i++) - { - CircleUIHandler circleUIHandler = CircleUIList[i]; - - //set the trigger list - circleUIHandler.AddTriggers(); - } - } - - /// - /// Called whenever something is received. - /// Sets the pet type of the corresponding entry of ClonedTypes - /// - public void GetFromClonedTypes() - { - //AssUtils.Print("set getfromclonedtypes p " + player.whoAmI + " " + mp); - int index = 0; - - mechFrogType = ClonedTypes[index++]; - petEyeType = ClonedTypes[index++]; - cursedSkullType = ClonedTypes[index++]; - youngWyvernType = ClonedTypes[index++]; - petFishronType = ClonedTypes[index++]; - petMoonType = ClonedTypes[index++]; - abeeminationType = ClonedTypes[index++]; - lilWrapsType = ClonedTypes[index++]; - vampireBatType = ClonedTypes[index++]; - pigronataType = ClonedTypes[index++]; - queenLarvaType = ClonedTypes[index++]; - miniAntlionType = ClonedTypes[index++]; - petGoldfishType = ClonedTypes[index++]; - skeletronHandType = ClonedTypes[index++]; - skeletronPrimeHandType = ClonedTypes[index++]; - petCultistType = ClonedTypes[index++]; - petAnomalocarisType = ClonedTypes[index++]; - dynamiteBunnyType = ClonedTypes[index++]; - wallFragmentType = ClonedTypes[index++]; - metroidPetType = ClonedTypes[index++]; - cuteLamiaPetType = ClonedTypes[index++]; - //ALTERNATE - //classNameType = ClonedTypes[index++]; - - oceanSlimeType = ClonedTypes[index++]; - stingSlimeType = ClonedTypes[index++]; - animatedTomeType = ClonedTypes[index++]; - - youngHarpyType = ClonedTypes[index++]; - } - - /// - /// Called in PreUpdate (which runs before OnEnterWorld, hence the check). - /// Sets each entry of ClonedTypes to the corresponding pet type - /// - public void SetClonedTypes() - { - if (enteredWorld) - { - int index = -1; - ClonedTypes[++index] = mechFrogType; - ClonedTypes[++index] = petEyeType; - ClonedTypes[++index] = cursedSkullType; - ClonedTypes[++index] = youngWyvernType; - ClonedTypes[++index] = petFishronType; - ClonedTypes[++index] = petMoonType; - ClonedTypes[++index] = abeeminationType; - ClonedTypes[++index] = lilWrapsType; - ClonedTypes[++index] = vampireBatType; - ClonedTypes[++index] = pigronataType; - ClonedTypes[++index] = queenLarvaType; - ClonedTypes[++index] = miniAntlionType; - ClonedTypes[++index] = petGoldfishType; - ClonedTypes[++index] = skeletronHandType; - ClonedTypes[++index] = skeletronPrimeHandType; - ClonedTypes[++index] = petCultistType; - ClonedTypes[++index] = petAnomalocarisType; - ClonedTypes[++index] = dynamiteBunnyType; - ClonedTypes[++index] = wallFragmentType; - ClonedTypes[++index] = metroidPetType; - ClonedTypes[++index] = cuteLamiaPetType; - - ClonedTypes[++index] = oceanSlimeType; - ClonedTypes[++index] = stingSlimeType; - ClonedTypes[++index] = animatedTomeType; - - ClonedTypes[++index] = youngHarpyType; - //ALTERNATE - //ClonedTypes[++index] = classNameType; - } - } - - #endregion - } + } + + if (ContentConfig.Instance.DroppedPets) + { + int vanitySelector = ModContent.ItemType(); + CircleUIList.AddRange(new List() + { + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => QueenLarva, + uiConf: GetQueenLarvaConf, + onUIStart: () => queenLarvaType, + onUIEnd: () => queenLarvaType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => MiniAntlion, + uiConf: GetMiniAntlionConf, + onUIStart: () => miniAntlionType, + onUIEnd: () => miniAntlionType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => LilWraps, + uiConf: GetLilWrapsConf, + onUIStart: () => lilWrapsType, + onUIEnd: () => lilWrapsType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => WallFragment, + uiConf: GetWallFragmentConf, + onUIStart: () => wallFragmentType, + onUIEnd: () => wallFragmentType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => MetroidPet, + uiConf: GetMetroidPetConf, + onUIStart: () => metroidPetType, + onUIEnd: () => metroidPetType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => CuteLamiaPet, + uiConf: GetCuteLamiaPetConf, + onUIStart: () => cuteLamiaPetType, + onUIEnd: () => cuteLamiaPetType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => SkeletronHand, + uiConf: GetSkeletronHandConf, + onUIStart: () => skeletronHandType, + onUIEnd: () => skeletronHandType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => SkeletronPrimeHand, + uiConf: GetSkeletronPrimeHandConf, + onUIStart: () => skeletronPrimeHandType, + onUIEnd: () => skeletronPrimeHandType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => PetCultist, + uiConf: GetPetCultistConf, + onUIStart: () => petCultistType, + onUIEnd: () => petCultistType = (byte)CircleUI.returned, + triggerLeft: false + ), + new CircleUIHandler( + triggerItem: vanitySelector, + condition: () => PetFishron, + uiConf: GetPetFishronConf, + onUIStart: () => petFishronType, + onUIEnd: () => petFishronType = (byte)CircleUI.returned + ) + }); + } + + if (ContentConfig.Instance.HostileNPCs) + { + CircleUIList.AddRange(new List() + { + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => OceanSlime, + uiConf: GetOceanSlimeConf, + onUIStart: () => oceanSlimeType, + onUIEnd: () => oceanSlimeType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => StingSlime, + uiConf: GetStingSlimeConf, + onUIStart: () => stingSlimeType, + onUIEnd: () => stingSlimeType = (byte)CircleUI.returned + ), + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => AnimatedTome, + uiConf: GetAnimatedTomeConf, + onUIStart: () => animatedTomeType, + onUIEnd: () => animatedTomeType = (byte)CircleUI.returned + ) + }); + } + + if (ContentConfig.Instance.FriendlyNPCs) + { + CircleUIList.AddRange(new List() + { + new CircleUIHandler( + triggerItem: ModContent.ItemType(), + condition: () => YoungHarpy, + uiConf: GetYoungHarpyConf, + onUIStart: () => youngHarpyType, + onUIEnd: () => youngHarpyType = (byte)CircleUI.returned + ), + }); + } + + //after filling the list + for (int i = 0; i < CircleUIList.Count; i++) + { + CircleUIHandler circleUIHandler = CircleUIList[i]; + + //set the trigger list + circleUIHandler.AddTriggers(); + } + } + + /// + /// Called whenever something is received. + /// Sets the pet type of the corresponding entry of ClonedTypes + /// + public void GetFromClonedTypes() + { + //AssUtils.Print("set getfromclonedtypes p " + player.whoAmI + " " + mp); + int index = 0; + + mechFrogType = ClonedTypes[index++]; + petEyeType = ClonedTypes[index++]; + cursedSkullType = ClonedTypes[index++]; + youngWyvernType = ClonedTypes[index++]; + petFishronType = ClonedTypes[index++]; + petMoonType = ClonedTypes[index++]; + abeeminationType = ClonedTypes[index++]; + lilWrapsType = ClonedTypes[index++]; + vampireBatType = ClonedTypes[index++]; + pigronataType = ClonedTypes[index++]; + queenLarvaType = ClonedTypes[index++]; + miniAntlionType = ClonedTypes[index++]; + petGoldfishType = ClonedTypes[index++]; + skeletronHandType = ClonedTypes[index++]; + skeletronPrimeHandType = ClonedTypes[index++]; + petCultistType = ClonedTypes[index++]; + petAnomalocarisType = ClonedTypes[index++]; + dynamiteBunnyType = ClonedTypes[index++]; + wallFragmentType = ClonedTypes[index++]; + metroidPetType = ClonedTypes[index++]; + cuteLamiaPetType = ClonedTypes[index++]; + //ALTERNATE + //classNameType = ClonedTypes[index++]; + + oceanSlimeType = ClonedTypes[index++]; + stingSlimeType = ClonedTypes[index++]; + animatedTomeType = ClonedTypes[index++]; + + youngHarpyType = ClonedTypes[index++]; + } + + /// + /// Called in PreUpdate (which runs before OnEnterWorld, hence the check). + /// Sets each entry of ClonedTypes to the corresponding pet type + /// + public void SetClonedTypes() + { + if (enteredWorld) + { + int index = -1; + ClonedTypes[++index] = mechFrogType; + ClonedTypes[++index] = petEyeType; + ClonedTypes[++index] = cursedSkullType; + ClonedTypes[++index] = youngWyvernType; + ClonedTypes[++index] = petFishronType; + ClonedTypes[++index] = petMoonType; + ClonedTypes[++index] = abeeminationType; + ClonedTypes[++index] = lilWrapsType; + ClonedTypes[++index] = vampireBatType; + ClonedTypes[++index] = pigronataType; + ClonedTypes[++index] = queenLarvaType; + ClonedTypes[++index] = miniAntlionType; + ClonedTypes[++index] = petGoldfishType; + ClonedTypes[++index] = skeletronHandType; + ClonedTypes[++index] = skeletronPrimeHandType; + ClonedTypes[++index] = petCultistType; + ClonedTypes[++index] = petAnomalocarisType; + ClonedTypes[++index] = dynamiteBunnyType; + ClonedTypes[++index] = wallFragmentType; + ClonedTypes[++index] = metroidPetType; + ClonedTypes[++index] = cuteLamiaPetType; + + ClonedTypes[++index] = oceanSlimeType; + ClonedTypes[++index] = stingSlimeType; + ClonedTypes[++index] = animatedTomeType; + + ClonedTypes[++index] = youngHarpyType; + //ALTERNATE + //ClonedTypes[++index] = classNameType; + } + } + + #endregion + } } diff --git a/Projectiles/EmpoweringBuffGlobalProjectile.cs b/Projectiles/EmpoweringBuffGlobalProjectile.cs index 72d3c95c..070b7b80 100644 --- a/Projectiles/EmpoweringBuffGlobalProjectile.cs +++ b/Projectiles/EmpoweringBuffGlobalProjectile.cs @@ -4,21 +4,21 @@ namespace AssortedCrazyThings.Projectiles { - [Content(ContentType.Bosses)] - public class EmpoweringBuffGlobalProjectile : AssGlobalProjectile - { - //public override bool InstancePerEntity => false; + [Content(ContentType.Bosses)] + public class EmpoweringBuffGlobalProjectile : AssGlobalProjectile + { + //public override bool InstancePerEntity => false; - public override void ModifyHitNPC(Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if ((projectile.minion || ProjectileID.Sets.MinionShot[projectile.type]) && projectile.friendly && projectile.damage > 0) - { - AssPlayer mPlayer = projectile.GetOwner().GetModPlayer(); - if (mPlayer.empoweringBuff) - { - damage += (int)(damage * mPlayer.empoweringStep * 0.25f); - } - } - } - } + public override void ModifyHitNPC(Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if ((projectile.minion || ProjectileID.Sets.MinionShot[projectile.type]) && projectile.friendly && projectile.damage > 0) + { + AssPlayer mPlayer = projectile.GetOwner().GetModPlayer(); + if (mPlayer.empoweringBuff) + { + damage += (int)(damage * mPlayer.empoweringStep * 0.25f); + } + } + } + } } diff --git a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulFrightMinion.cs b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulFrightMinion.cs index ce3a6ee0..5ce2c6c7 100644 --- a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulFrightMinion.cs +++ b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulFrightMinion.cs @@ -3,47 +3,47 @@ namespace AssortedCrazyThings.Projectiles.Minions.CompanionDungeonSouls { - public class CompanionDungeonSoulFrightMinion : CompanionDungeonSoulMinionBase - { - public override void SafeSetDefaults() - { - Projectile.minionSlots = 1f; - defdistanceFromTarget = 700f; - defdistancePlayerFarAway = 800f; - defdistancePlayerFarAwayWhenHasTarget = 1200f; - defdistanceToEnemyBeforeCanDash = 30f; //20f - defplayerFloatHeight = -60f; //-60f - defplayerCatchUpIdle = 300f; //300f - defbackToIdleFromNoclipping = 150f; //150f - defdashDelay = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell - defdistanceAttackNoclip = defdashDelay * 5f; - defstartDashRange = defdistanceToEnemyBeforeCanDash + 10f; //30f - defdashIntensity = 4f; //4f + public class CompanionDungeonSoulFrightMinion : CompanionDungeonSoulMinionBase + { + public override void SafeSetDefaults() + { + Projectile.minionSlots = 1f; + defdistanceFromTarget = 700f; + defdistancePlayerFarAway = 800f; + defdistancePlayerFarAwayWhenHasTarget = 1200f; + defdistanceToEnemyBeforeCanDash = 30f; //20f + defplayerFloatHeight = -60f; //-60f + defplayerCatchUpIdle = 300f; //300f + defbackToIdleFromNoclipping = 150f; //150f + defdashDelay = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell + defdistanceAttackNoclip = defdashDelay * 5f; + defstartDashRange = defdistanceToEnemyBeforeCanDash + 10f; //30f + defdashIntensity = 4f; //4f - veloFactorToEnemy = 7f; //8f - accFactorToEnemy = 16f; //41f + veloFactorToEnemy = 7f; //8f + accFactorToEnemy = 16f; //41f - veloFactorAfterDash = 7f; //4f - accFactorAfterDash = 16f; //41f + veloFactorAfterDash = 7f; //4f + accFactorAfterDash = 16f; //41f - defveloIdle = 2f; - defveloCatchUpIdle = 8f; - defveloNoclip = 12f; + defveloIdle = 2f; + defveloCatchUpIdle = 8f; + defveloNoclip = 12f; - dustColor = ItemID.BrightOrangeDye; - } + dustColor = ItemID.BrightOrangeDye; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - int rand = Main.rand.Next(10); - if (rand == 0) - { - target.AddBuff(BuffID.Ichor, 300); - } - else if (rand == 1) - { - target.AddBuff(BuffID.Poisoned, 300); - } - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + int rand = Main.rand.Next(10); + if (rand == 0) + { + target.AddBuff(BuffID.Ichor, 300); + } + else if (rand == 1) + { + target.AddBuff(BuffID.Poisoned, 300); + } + } + } } diff --git a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulMightMinion.cs b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulMightMinion.cs index ca98d107..809777b9 100644 --- a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulMightMinion.cs +++ b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulMightMinion.cs @@ -2,34 +2,34 @@ namespace AssortedCrazyThings.Projectiles.Minions.CompanionDungeonSouls { - public class CompanionDungeonSoulMightMinion : CompanionDungeonSoulMinionBase - { - public override void SafeSetDefaults() - { - Projectile.minionSlots = 1f; - defdistanceFromTarget = 700f; - defdistancePlayerFarAway = 800f; - defdistancePlayerFarAwayWhenHasTarget = 1200f; - defdistanceToEnemyBeforeCanDash = 200f; //20f - defplayerFloatHeight = -60f; //-60f - defplayerCatchUpIdle = 300f; //300f - defbackToIdleFromNoclipping = 150f; //150f - defdashDelay = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell - defdistanceAttackNoclip = defdistanceToEnemyBeforeCanDash + 100f; - defstartDashRange = defdistanceToEnemyBeforeCanDash + 400f; //30f - defdashIntensity = 8f; //4f + public class CompanionDungeonSoulMightMinion : CompanionDungeonSoulMinionBase + { + public override void SafeSetDefaults() + { + Projectile.minionSlots = 1f; + defdistanceFromTarget = 700f; + defdistancePlayerFarAway = 800f; + defdistancePlayerFarAwayWhenHasTarget = 1200f; + defdistanceToEnemyBeforeCanDash = 200f; //20f + defplayerFloatHeight = -60f; //-60f + defplayerCatchUpIdle = 300f; //300f + defbackToIdleFromNoclipping = 150f; //150f + defdashDelay = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell + defdistanceAttackNoclip = defdistanceToEnemyBeforeCanDash + 100f; + defstartDashRange = defdistanceToEnemyBeforeCanDash + 400f; //30f + defdashIntensity = 8f; //4f - veloFactorToEnemy = 8f; //8f - accFactorToEnemy = 10f; //41f + veloFactorToEnemy = 8f; //8f + accFactorToEnemy = 10f; //41f - veloFactorAfterDash = 4f; //4f - accFactorAfterDash = 41f; //41f + veloFactorAfterDash = 4f; //4f + accFactorAfterDash = 41f; //41f - defveloIdle = 4f; - defveloCatchUpIdle = 7f; - defveloNoclip = 13f; + defveloIdle = 4f; + defveloCatchUpIdle = 7f; + defveloNoclip = 13f; - dustColor = ItemID.BlueDye; - } - } + dustColor = ItemID.BlueDye; + } + } } diff --git a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulMinionBase.cs b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulMinionBase.cs index 57683e74..1e858812 100644 --- a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulMinionBase.cs +++ b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulMinionBase.cs @@ -11,441 +11,441 @@ namespace AssortedCrazyThings.Projectiles.Minions.CompanionDungeonSouls { - [Content(ContentType.Bosses)] - public abstract class CompanionDungeonSoulMinionBase : AssProjectile - { - private float sinY; - private int sincounter; - public int dustColor; - //more like an initializer (set minionSlots and timeLeft accordingly) - public bool isTemp = false; - - - //SetDefaults stuff - public float defdistanceFromTarget;// = 700f; - public float defdistancePlayerFarAway;// = 800f; - public float defdistancePlayerFarAwayWhenHasTarget;// = 1200f; - public float defdistanceToEnemyBeforeCanDash;// = 20f; //20f - public float defplayerFloatHeight;// = -60f; //-60f - public float defplayerCatchUpIdle;// = 300f; //300f - public float defbackToIdleFromNoclipping;// = 150f; //150f - public float defdashDelay;// = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell - public float defdistanceAttackNoclip; //defdashDelay * 5; only for prewol version - public float defstartDashRange;// = defdistanceToEnemyBeforeCanDash + 10f; //30f - public float defdashIntensity;// = 4f; //4f - - public float veloFactorToEnemy;// = 6f; //8f - public float accFactorToEnemy;// = 16f; //41f - - public float veloFactorAfterDash;// = 8f; //4f - public float accFactorAfterDash;// = 41f; //41f - - public float defveloIdle;// = 1f; - public float defveloCatchUpIdle;// = 8f; - public float defveloNoclip;// = 12f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Companion Soul"); - Main.projFrames[Projectile.type] = 6; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; - } - - public sealed override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.Spazmamini); - Projectile.width = 14; - Projectile.height = 24; - Projectile.aiStyle = -1; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Summon; - Projectile.minion = true; - Projectile.minionSlots = 0.5f; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 8; - - dustColor = 0; - - SafeSetDefaults(); - } - - public virtual void SafeSetDefaults() - { - - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write((bool)isTemp); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - isTemp = reader.ReadBoolean(); - } - - public override bool? CanCutTiles() - { - return false; - } - - public override bool MinionContactDamage() - { - return true; - } - - private void Draw() - { - if (AI_STATE == STATE_DASH) - { - Projectile.rotation = Projectile.velocity.X * 0.05f; - } - else - { - Projectile.rotation = 0; - } - - Projectile.LoopAnimation(4); - } - - public override bool PreDraw(ref Color lightColor) - { - return false; - } - - public override void PostDraw(Color lightColor) - { - lightColor = Projectile.GetAlpha(lightColor) * 0.99f; //1f is opaque - lightColor.R = Math.Max(lightColor.R, (byte)200); //100 for dark - lightColor.G = Math.Max(lightColor.G, (byte)200); - lightColor.B = Math.Max(lightColor.B, (byte)200); - - //the one that spawns on hit via SigilOfEmergency - if (Projectile.minionSlots == 0f && Projectile.timeLeft < 120) - { - lightColor = Projectile.GetAlpha(lightColor) * (Projectile.timeLeft / 120f); - } - - SpriteEffects effects = SpriteEffects.None; - Texture2D image = TextureAssets.Projectile[Projectile.type].Value; - - AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height - 10f + sinY); - Vector2 origin = bounds.Size() / 2; - - if (mPlayer.soulSaviorArmor && Projectile.minionSlots == 1f) - { - //Texture2D empoweredImage = Mod.Assets.Request("Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoul_Empowered").Value; - Texture2D empoweredImage = ModContent.Request(Texture + "_Empowered").Value; - - float addScale = (float)((Math.Sin((sincounter / 240f) * MathHelper.TwoPi) + 0.5f) * 0.1f); - Color color = Color.White * (0.1f + 3 * addScale); - Main.EntitySpriteDraw(empoweredImage, Projectile.position - Main.screenPosition + stupidOffset, bounds, color, Projectile.rotation, origin, Projectile.scale + 0.1f + addScale, effects, 0); - } - - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); - } - - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - if (mPlayer.soulSaviorArmor) - { - damage = (int)(1.3f * damage); - } - } - - private const float STATE_MAIN = 0f; - private const float STATE_NOCLIP = 1f; - private const float STATE_DASH = 2f; - - public float AI_STATE - { - get - { - return Projectile.ai[0]; - } - set - { - Projectile.ai[0] = value; - } - } - - public override void AI() - { - //AI_STATE == 0 : no target found, or found and approaching - //AI_STATE == 1 : noclipping to player - //AI_STATE == 2 : target found, dashing (includes delay after dash) - - Player player = Projectile.GetOwner(); - AssPlayer mPlayer = player.GetModPlayer(); - if (player.dead) - { - mPlayer.soulMinion = false; - } - - if (isTemp) - { - Projectile.minionSlots = 0f; - Projectile.timeLeft = 600; //10 seconds - isTemp = false; - } - - if (player.dead && Projectile.minionSlots == 0f) - { - Projectile.timeLeft = 0; //kill temporary soul when dead - } - - if (mPlayer.soulMinion && (Projectile.minionSlots == 0.5f || Projectile.minionSlots == 1f)) //if spawned naturally they will have 0.5f - { - Projectile.timeLeft = 2; - } - - float distanceFromTargetSQ = defdistanceFromTarget * defdistanceFromTarget; - - float overlapVelo = 0.04f; //0.05 - for (int i = 0; i < Main.maxProjectiles; i++) - { - //fix overlap with other minions - Projectile other = Main.projectile[i]; - if (i != Projectile.whoAmI && other.active && other.owner == Projectile.owner && Math.Abs(Projectile.position.X - other.position.X) + Math.Abs(Projectile.position.Y - other.position.Y) < Projectile.width) - { - if (Projectile.position.X < other.position.X) Projectile.velocity.X = Projectile.velocity.X - overlapVelo; - else Projectile.velocity.X = Projectile.velocity.X + overlapVelo; - - if (Projectile.position.Y < other.position.Y) Projectile.velocity.Y = Projectile.velocity.Y - overlapVelo; - else Projectile.velocity.Y = Projectile.velocity.Y + overlapVelo; - } - } - bool flag23 = false; - if (AI_STATE == STATE_DASH) //attack mode - - { - Projectile.friendly = true; - Projectile.ai[1] += 1f; - Projectile.extraUpdates = 1; - - if (Projectile.ai[1] > defdashDelay) //40f - { - Projectile.ai[1] = 1f; - AI_STATE = STATE_MAIN; - Projectile.extraUpdates = 0; - Projectile.numUpdates = 0; - Projectile.netUpdate = true; - } - else - { - flag23 = true; - } - } - - if (!flag23) - { - Vector2 targetCenter = Projectile.position; - bool foundTarget = false; - //if (AI_STATE != STATE_NOCLIP) - //{ - // projectile.tileCollide = false; //true - //} - //if (projectile.tileCollide && WorldGen.SolidTile(Framing.GetTileSafely((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16))) - //{ - // projectile.tileCollide = false; - //} - - //only target closest NPC if that NPC is some range (200f) maybe - - //NPC ownerMinionAttackTargetNPC3 = projectile.OwnerMinionAttackTargetNPC; - //if (ownerMinionAttackTargetNPC3 != null && ownerMinionAttackTargetNPC3.CanBeChasedBy(this)) - //{ - // float between = Vector2.Distance(ownerMinionAttackTargetNPC3.Center, projectile.Center); - // if (((Vector2.Distance(projectile.Center, vector40) > between && between < distance1) || !foundTarget) && - // Collision.CanHitLine(projectile.position, projectile.width, projectile.height, ownerMinionAttackTargetNPC3.position, ownerMinionAttackTargetNPC3.width, ownerMinionAttackTargetNPC3.height)) - // { - // distance1 = between; - // vector40 = ownerMinionAttackTargetNPC3.Center; - // foundTarget = true; - // } - //} - int targetIndex = -1; - if (!foundTarget) - { - for (int j = 0; j < Main.maxNPCs; j++) - { - NPC npc = Main.npc[j]; - if (npc.CanBeChasedBy()) - { - float betweenSQ = Projectile.DistanceSQ(npc.Center); - if (((Projectile.DistanceSQ(targetCenter) > betweenSQ && betweenSQ < distanceFromTargetSQ) || !foundTarget) && - //EITHER HE CAN SEE IT, OR THE TARGET IS (default case: 14) TILES AWAY BUT THE MINION IS INSIDE A TILE - //makes it so the soul can still attack if it dashed "through tiles" - (Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height) || - (betweenSQ < defdistanceAttackNoclip/* && Collision.SolidCollision(projectile.position, projectile.width, projectile.height)*/))) - { - distanceFromTargetSQ = betweenSQ; - targetCenter = npc.Center; - targetIndex = j; - foundTarget = true; - } - } - } - } - float distanceNoclip = defdistancePlayerFarAway; - if (foundTarget) - { - Projectile.friendly = true; - //Main.NewText(projectile.ai[1] + " " + Main.time); - distanceNoclip = defdistancePlayerFarAwayWhenHasTarget; - } - if (Vector2.Distance(player.Center, Projectile.Center) > distanceNoclip) //go to player - { - AI_STATE = STATE_NOCLIP; - Projectile.tileCollide = false; //true - Projectile.netUpdate = true; - } - if (foundTarget && AI_STATE == STATE_MAIN)//idek - { - Vector2 distanceToTargetVector = targetCenter - Projectile.Center; - float distanceToTarget = distanceToTargetVector.Length(); - distanceToTargetVector.Normalize(); - //Main.NewText(distanceToTarget); - if (distanceToTarget > defdistanceToEnemyBeforeCanDash) //200f //approach distance to enemy - { - //if its far away from it - //Main.NewText("first " + Main.time); - distanceToTargetVector *= veloFactorToEnemy; - Projectile.velocity = (Projectile.velocity * (accFactorToEnemy - 1) + distanceToTargetVector) / accFactorToEnemy; - } - else //slowdown after a dash - { - //if its close to the enemy - //Main.NewText("second " + distanceToTarget); - distanceToTargetVector *= 0f - veloFactorAfterDash; - Projectile.velocity = (Projectile.velocity * (accFactorAfterDash - 1) + distanceToTargetVector) / accFactorAfterDash; - } - } - else //!(foundTarget && AI_STATE == STATE_MAIN) - { - Projectile.friendly = false; - float veloIdle = defveloIdle; //6f - - Vector2 distanceToPlayerVector = player.Center - Projectile.Center + new Vector2(0f, defplayerFloatHeight); //at what height it floats above player - float distanceToPlayer = distanceToPlayerVector.Length(); - if (distanceToPlayer > defplayerCatchUpIdle) //8f - { - veloIdle = defveloCatchUpIdle; //8f - } - if (AI_STATE == STATE_NOCLIP) //noclipping - { - veloIdle = defveloNoclip; //15f - } - if (distanceToPlayer < defbackToIdleFromNoclipping && AI_STATE == STATE_NOCLIP && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - AI_STATE = STATE_MAIN; - Projectile.netUpdate = true; - } - if (distanceToPlayer > 2000f) //teleport to player it distance too big - { - Projectile.position = player.Center; - Projectile.netUpdate = true; - } - if (distanceToPlayer > 70f) //the immediate range around the player (when it passively floats about) - { - distanceToPlayerVector.Normalize(); - distanceToPlayerVector *= veloIdle; - float accIdle = 100f; //41f - Projectile.velocity = (Projectile.velocity * (accIdle - 1) + distanceToPlayerVector) / accIdle; - } - else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) - { - Projectile.velocity.X = -0.15f; - Projectile.velocity.Y = -0.05f; - } - } - - if (Projectile.ai[1] > 0f) - { - //projectile.ai[1] += 1f; - Projectile.ai[1] += Main.rand.Next(1, 4); - } - - if (Projectile.ai[1] > defdashDelay) - { - Projectile.ai[1] = 0f; - Projectile.netUpdate = true; - } - - if (AI_STATE == STATE_MAIN) - { - if ((Projectile.ai[1] == 0f & foundTarget) && distanceFromTargetSQ < defstartDashRange * defstartDashRange) //500f //DASH HERE YEEEEEEE - { - Projectile.ai[1] = 1f; - if (Main.myPlayer == Projectile.owner) - { - Vector2 targetVeloOffset = Main.npc[targetIndex].velocity; - - AI_STATE = STATE_DASH; - Vector2 value20 = targetCenter + targetVeloOffset * 5 - Projectile.Center; - value20.Normalize(); - Projectile.velocity = value20 * defdashIntensity; //8f - Projectile.netUpdate = true; - } - } - } - } - - Draw(); - - Lighting.AddLight(Projectile.Center, new Vector3(0.15f, 0.15f, 0.35f)); - - sincounter = sincounter > 120 ? 0 : sincounter + 1; - sinY = (float)((Math.Sin((sincounter / 120f) * MathHelper.TwoPi) - 1) * 10); - - //Generate visual dust - if (Main.rand.NextFloat() < 0.02f) - { - Vector2 position = new Vector2(Projectile.position.X + Projectile.width / 2, Projectile.position.Y + Projectile.height / 2 + sinY); - Dust dust = Dust.NewDustPerfect(position, 135, new Vector2(Main.rand.NextFloat(-0.3f, 0.3f), Main.rand.NextFloat(-1.5f, -1f)), 200, Color.LightGray, 1f); - dust.noGravity = false; - dust.noLight = true; - dust.fadeIn = Main.rand.NextFloat(0.8f, 1.1f); - - if (dustColor != 0) - { - dust.shader = GameShaders.Armor.GetSecondaryShader((byte)GameShaders.Armor.GetShaderIdFromItemId(dustColor), player); - } - } - - //Dust upon spawning - if (Projectile.localAI[0] < 60) - { - Projectile.localAI[0]++; - Vector2 position = new Vector2(Projectile.position.X + Projectile.width / 2, Projectile.position.Y + Projectile.height / 3 + sinY); - - if (Main.rand.NextFloat() < (60 - Projectile.localAI[0]) / 360f) - { - Dust dust = Dust.NewDustPerfect(position, 135, new Vector2(Main.rand.NextFloat(-0.3f, 0.3f), Main.rand.NextFloat(-1.5f, -1f)), 200, Color.LightGray, (60 - Projectile.localAI[0]) / 60f + 1f); - dust.noGravity = false; - dust.noLight = true; - dust.fadeIn = Main.rand.NextFloat(0.2f); - - if (dustColor != 0) - { - dust.shader = GameShaders.Armor.GetSecondaryShader((byte)GameShaders.Armor.GetShaderIdFromItemId(dustColor), player); - } - } - } - } - - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) - { - fallThrough = true; - return false; //true - } - } + [Content(ContentType.Bosses)] + public abstract class CompanionDungeonSoulMinionBase : AssProjectile + { + private float sinY; + private int sincounter; + public int dustColor; + //more like an initializer (set minionSlots and timeLeft accordingly) + public bool isTemp = false; + + + //SetDefaults stuff + public float defdistanceFromTarget;// = 700f; + public float defdistancePlayerFarAway;// = 800f; + public float defdistancePlayerFarAwayWhenHasTarget;// = 1200f; + public float defdistanceToEnemyBeforeCanDash;// = 20f; //20f + public float defplayerFloatHeight;// = -60f; //-60f + public float defplayerCatchUpIdle;// = 300f; //300f + public float defbackToIdleFromNoclipping;// = 150f; //150f + public float defdashDelay;// = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell + public float defdistanceAttackNoclip; //defdashDelay * 5; only for prewol version + public float defstartDashRange;// = defdistanceToEnemyBeforeCanDash + 10f; //30f + public float defdashIntensity;// = 4f; //4f + + public float veloFactorToEnemy;// = 6f; //8f + public float accFactorToEnemy;// = 16f; //41f + + public float veloFactorAfterDash;// = 8f; //4f + public float accFactorAfterDash;// = 41f; //41f + + public float defveloIdle;// = 1f; + public float defveloCatchUpIdle;// = 8f; + public float defveloNoclip;// = 12f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Companion Soul"); + Main.projFrames[Projectile.type] = 6; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; + } + + public sealed override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.Spazmamini); + Projectile.width = 14; + Projectile.height = 24; + Projectile.aiStyle = -1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Summon; + Projectile.minion = true; + Projectile.minionSlots = 0.5f; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 8; + + dustColor = 0; + + SafeSetDefaults(); + } + + public virtual void SafeSetDefaults() + { + + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write((bool)isTemp); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + isTemp = reader.ReadBoolean(); + } + + public override bool? CanCutTiles() + { + return false; + } + + public override bool MinionContactDamage() + { + return true; + } + + private void Draw() + { + if (AI_STATE == STATE_DASH) + { + Projectile.rotation = Projectile.velocity.X * 0.05f; + } + else + { + Projectile.rotation = 0; + } + + Projectile.LoopAnimation(4); + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + + public override void PostDraw(Color lightColor) + { + lightColor = Projectile.GetAlpha(lightColor) * 0.99f; //1f is opaque + lightColor.R = Math.Max(lightColor.R, (byte)200); //100 for dark + lightColor.G = Math.Max(lightColor.G, (byte)200); + lightColor.B = Math.Max(lightColor.B, (byte)200); + + //the one that spawns on hit via SigilOfEmergency + if (Projectile.minionSlots == 0f && Projectile.timeLeft < 120) + { + lightColor = Projectile.GetAlpha(lightColor) * (Projectile.timeLeft / 120f); + } + + SpriteEffects effects = SpriteEffects.None; + Texture2D image = TextureAssets.Projectile[Projectile.type].Value; + + AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height - 10f + sinY); + Vector2 origin = bounds.Size() / 2; + + if (mPlayer.soulSaviorArmor && Projectile.minionSlots == 1f) + { + //Texture2D empoweredImage = Mod.Assets.Request("Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoul_Empowered").Value; + Texture2D empoweredImage = ModContent.Request(Texture + "_Empowered").Value; + + float addScale = (float)((Math.Sin((sincounter / 240f) * MathHelper.TwoPi) + 0.5f) * 0.1f); + Color color = Color.White * (0.1f + 3 * addScale); + Main.EntitySpriteDraw(empoweredImage, Projectile.position - Main.screenPosition + stupidOffset, bounds, color, Projectile.rotation, origin, Projectile.scale + 0.1f + addScale, effects, 0); + } + + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + if (mPlayer.soulSaviorArmor) + { + damage = (int)(1.3f * damage); + } + } + + private const float STATE_MAIN = 0f; + private const float STATE_NOCLIP = 1f; + private const float STATE_DASH = 2f; + + public float AI_STATE + { + get + { + return Projectile.ai[0]; + } + set + { + Projectile.ai[0] = value; + } + } + + public override void AI() + { + //AI_STATE == 0 : no target found, or found and approaching + //AI_STATE == 1 : noclipping to player + //AI_STATE == 2 : target found, dashing (includes delay after dash) + + Player player = Projectile.GetOwner(); + AssPlayer mPlayer = player.GetModPlayer(); + if (player.dead) + { + mPlayer.soulMinion = false; + } + + if (isTemp) + { + Projectile.minionSlots = 0f; + Projectile.timeLeft = 600; //10 seconds + isTemp = false; + } + + if (player.dead && Projectile.minionSlots == 0f) + { + Projectile.timeLeft = 0; //kill temporary soul when dead + } + + if (mPlayer.soulMinion && (Projectile.minionSlots == 0.5f || Projectile.minionSlots == 1f)) //if spawned naturally they will have 0.5f + { + Projectile.timeLeft = 2; + } + + float distanceFromTargetSQ = defdistanceFromTarget * defdistanceFromTarget; + + float overlapVelo = 0.04f; //0.05 + for (int i = 0; i < Main.maxProjectiles; i++) + { + //fix overlap with other minions + Projectile other = Main.projectile[i]; + if (i != Projectile.whoAmI && other.active && other.owner == Projectile.owner && Math.Abs(Projectile.position.X - other.position.X) + Math.Abs(Projectile.position.Y - other.position.Y) < Projectile.width) + { + if (Projectile.position.X < other.position.X) Projectile.velocity.X = Projectile.velocity.X - overlapVelo; + else Projectile.velocity.X = Projectile.velocity.X + overlapVelo; + + if (Projectile.position.Y < other.position.Y) Projectile.velocity.Y = Projectile.velocity.Y - overlapVelo; + else Projectile.velocity.Y = Projectile.velocity.Y + overlapVelo; + } + } + bool flag23 = false; + if (AI_STATE == STATE_DASH) //attack mode + + { + Projectile.friendly = true; + Projectile.ai[1] += 1f; + Projectile.extraUpdates = 1; + + if (Projectile.ai[1] > defdashDelay) //40f + { + Projectile.ai[1] = 1f; + AI_STATE = STATE_MAIN; + Projectile.extraUpdates = 0; + Projectile.numUpdates = 0; + Projectile.netUpdate = true; + } + else + { + flag23 = true; + } + } + + if (!flag23) + { + Vector2 targetCenter = Projectile.position; + bool foundTarget = false; + //if (AI_STATE != STATE_NOCLIP) + //{ + // projectile.tileCollide = false; //true + //} + //if (projectile.tileCollide && WorldGen.SolidTile(Framing.GetTileSafely((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16))) + //{ + // projectile.tileCollide = false; + //} + + //only target closest NPC if that NPC is some range (200f) maybe + + //NPC ownerMinionAttackTargetNPC3 = projectile.OwnerMinionAttackTargetNPC; + //if (ownerMinionAttackTargetNPC3 != null && ownerMinionAttackTargetNPC3.CanBeChasedBy(this)) + //{ + // float between = Vector2.Distance(ownerMinionAttackTargetNPC3.Center, projectile.Center); + // if (((Vector2.Distance(projectile.Center, vector40) > between && between < distance1) || !foundTarget) && + // Collision.CanHitLine(projectile.position, projectile.width, projectile.height, ownerMinionAttackTargetNPC3.position, ownerMinionAttackTargetNPC3.width, ownerMinionAttackTargetNPC3.height)) + // { + // distance1 = between; + // vector40 = ownerMinionAttackTargetNPC3.Center; + // foundTarget = true; + // } + //} + int targetIndex = -1; + if (!foundTarget) + { + for (int j = 0; j < Main.maxNPCs; j++) + { + NPC npc = Main.npc[j]; + if (npc.CanBeChasedBy()) + { + float betweenSQ = Projectile.DistanceSQ(npc.Center); + if (((Projectile.DistanceSQ(targetCenter) > betweenSQ && betweenSQ < distanceFromTargetSQ) || !foundTarget) && + //EITHER HE CAN SEE IT, OR THE TARGET IS (default case: 14) TILES AWAY BUT THE MINION IS INSIDE A TILE + //makes it so the soul can still attack if it dashed "through tiles" + (Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height) || + (betweenSQ < defdistanceAttackNoclip/* && Collision.SolidCollision(projectile.position, projectile.width, projectile.height)*/))) + { + distanceFromTargetSQ = betweenSQ; + targetCenter = npc.Center; + targetIndex = j; + foundTarget = true; + } + } + } + } + float distanceNoclip = defdistancePlayerFarAway; + if (foundTarget) + { + Projectile.friendly = true; + //Main.NewText(projectile.ai[1] + " " + Main.time); + distanceNoclip = defdistancePlayerFarAwayWhenHasTarget; + } + if (Vector2.Distance(player.Center, Projectile.Center) > distanceNoclip) //go to player + { + AI_STATE = STATE_NOCLIP; + Projectile.tileCollide = false; //true + Projectile.netUpdate = true; + } + if (foundTarget && AI_STATE == STATE_MAIN)//idek + { + Vector2 distanceToTargetVector = targetCenter - Projectile.Center; + float distanceToTarget = distanceToTargetVector.Length(); + distanceToTargetVector.Normalize(); + //Main.NewText(distanceToTarget); + if (distanceToTarget > defdistanceToEnemyBeforeCanDash) //200f //approach distance to enemy + { + //if its far away from it + //Main.NewText("first " + Main.time); + distanceToTargetVector *= veloFactorToEnemy; + Projectile.velocity = (Projectile.velocity * (accFactorToEnemy - 1) + distanceToTargetVector) / accFactorToEnemy; + } + else //slowdown after a dash + { + //if its close to the enemy + //Main.NewText("second " + distanceToTarget); + distanceToTargetVector *= 0f - veloFactorAfterDash; + Projectile.velocity = (Projectile.velocity * (accFactorAfterDash - 1) + distanceToTargetVector) / accFactorAfterDash; + } + } + else //!(foundTarget && AI_STATE == STATE_MAIN) + { + Projectile.friendly = false; + float veloIdle = defveloIdle; //6f + + Vector2 distanceToPlayerVector = player.Center - Projectile.Center + new Vector2(0f, defplayerFloatHeight); //at what height it floats above player + float distanceToPlayer = distanceToPlayerVector.Length(); + if (distanceToPlayer > defplayerCatchUpIdle) //8f + { + veloIdle = defveloCatchUpIdle; //8f + } + if (AI_STATE == STATE_NOCLIP) //noclipping + { + veloIdle = defveloNoclip; //15f + } + if (distanceToPlayer < defbackToIdleFromNoclipping && AI_STATE == STATE_NOCLIP && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + AI_STATE = STATE_MAIN; + Projectile.netUpdate = true; + } + if (distanceToPlayer > 2000f) //teleport to player it distance too big + { + Projectile.position = player.Center; + Projectile.netUpdate = true; + } + if (distanceToPlayer > 70f) //the immediate range around the player (when it passively floats about) + { + distanceToPlayerVector.Normalize(); + distanceToPlayerVector *= veloIdle; + float accIdle = 100f; //41f + Projectile.velocity = (Projectile.velocity * (accIdle - 1) + distanceToPlayerVector) / accIdle; + } + else if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) + { + Projectile.velocity.X = -0.15f; + Projectile.velocity.Y = -0.05f; + } + } + + if (Projectile.ai[1] > 0f) + { + //projectile.ai[1] += 1f; + Projectile.ai[1] += Main.rand.Next(1, 4); + } + + if (Projectile.ai[1] > defdashDelay) + { + Projectile.ai[1] = 0f; + Projectile.netUpdate = true; + } + + if (AI_STATE == STATE_MAIN) + { + if ((Projectile.ai[1] == 0f & foundTarget) && distanceFromTargetSQ < defstartDashRange * defstartDashRange) //500f //DASH HERE YEEEEEEE + { + Projectile.ai[1] = 1f; + if (Main.myPlayer == Projectile.owner) + { + Vector2 targetVeloOffset = Main.npc[targetIndex].velocity; + + AI_STATE = STATE_DASH; + Vector2 value20 = targetCenter + targetVeloOffset * 5 - Projectile.Center; + value20.Normalize(); + Projectile.velocity = value20 * defdashIntensity; //8f + Projectile.netUpdate = true; + } + } + } + } + + Draw(); + + Lighting.AddLight(Projectile.Center, new Vector3(0.15f, 0.15f, 0.35f)); + + sincounter = sincounter > 120 ? 0 : sincounter + 1; + sinY = (float)((Math.Sin((sincounter / 120f) * MathHelper.TwoPi) - 1) * 10); + + //Generate visual dust + if (Main.rand.NextFloat() < 0.02f) + { + Vector2 position = new Vector2(Projectile.position.X + Projectile.width / 2, Projectile.position.Y + Projectile.height / 2 + sinY); + Dust dust = Dust.NewDustPerfect(position, 135, new Vector2(Main.rand.NextFloat(-0.3f, 0.3f), Main.rand.NextFloat(-1.5f, -1f)), 200, Color.LightGray, 1f); + dust.noGravity = false; + dust.noLight = true; + dust.fadeIn = Main.rand.NextFloat(0.8f, 1.1f); + + if (dustColor != 0) + { + dust.shader = GameShaders.Armor.GetSecondaryShader((byte)GameShaders.Armor.GetShaderIdFromItemId(dustColor), player); + } + } + + //Dust upon spawning + if (Projectile.localAI[0] < 60) + { + Projectile.localAI[0]++; + Vector2 position = new Vector2(Projectile.position.X + Projectile.width / 2, Projectile.position.Y + Projectile.height / 3 + sinY); + + if (Main.rand.NextFloat() < (60 - Projectile.localAI[0]) / 360f) + { + Dust dust = Dust.NewDustPerfect(position, 135, new Vector2(Main.rand.NextFloat(-0.3f, 0.3f), Main.rand.NextFloat(-1.5f, -1f)), 200, Color.LightGray, (60 - Projectile.localAI[0]) / 60f + 1f); + dust.noGravity = false; + dust.noLight = true; + dust.fadeIn = Main.rand.NextFloat(0.2f); + + if (dustColor != 0) + { + dust.shader = GameShaders.Armor.GetSecondaryShader((byte)GameShaders.Armor.GetShaderIdFromItemId(dustColor), player); + } + } + } + } + + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + fallThrough = true; + return false; //true + } + } } diff --git a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulPostWOFMinion.cs b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulPostWOFMinion.cs index 498799dc..e8594392 100644 --- a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulPostWOFMinion.cs +++ b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulPostWOFMinion.cs @@ -2,34 +2,34 @@ namespace AssortedCrazyThings.Projectiles.Minions.CompanionDungeonSouls { - public class CompanionDungeonSoulPostWOFMinion : CompanionDungeonSoulMinionBase - { - public override void SafeSetDefaults() - { - Projectile.minionSlots = 1f; - defdistanceFromTarget = 700f; - defdistancePlayerFarAway = 800f; - defdistancePlayerFarAwayWhenHasTarget = 1200f; - defdistanceToEnemyBeforeCanDash = 20f; //20f - defplayerFloatHeight = -60f; //-60f - defplayerCatchUpIdle = 300f; //300f - defbackToIdleFromNoclipping = 150f; //150f - defdashDelay = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell - defdistanceAttackNoclip = defdashDelay * 5f; - defstartDashRange = defdistanceToEnemyBeforeCanDash + 10f; //30f - defdashIntensity = 4f; //4f + public class CompanionDungeonSoulPostWOFMinion : CompanionDungeonSoulMinionBase + { + public override void SafeSetDefaults() + { + Projectile.minionSlots = 1f; + defdistanceFromTarget = 700f; + defdistancePlayerFarAway = 800f; + defdistancePlayerFarAwayWhenHasTarget = 1200f; + defdistanceToEnemyBeforeCanDash = 20f; //20f + defplayerFloatHeight = -60f; //-60f + defplayerCatchUpIdle = 300f; //300f + defbackToIdleFromNoclipping = 150f; //150f + defdashDelay = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell + defdistanceAttackNoclip = defdashDelay * 5f; + defstartDashRange = defdistanceToEnemyBeforeCanDash + 10f; //30f + defdashIntensity = 4f; //4f - veloFactorToEnemy = 6f; //8f - accFactorToEnemy = 16f; //41f + veloFactorToEnemy = 6f; //8f + accFactorToEnemy = 16f; //41f - veloFactorAfterDash = 8f; //4f - accFactorAfterDash = 41f; //41f + veloFactorAfterDash = 8f; //4f + accFactorAfterDash = 41f; //41f - defveloIdle = 1f; - defveloCatchUpIdle = 8f; - defveloNoclip = 12f; + defveloIdle = 1f; + defveloCatchUpIdle = 8f; + defveloNoclip = 12f; - dustColor = ItemID.PinkDye; - } - } + dustColor = ItemID.PinkDye; + } + } } diff --git a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulPreWOFMinion.cs b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulPreWOFMinion.cs index 5ffbf025..2cb0c2c6 100644 --- a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulPreWOFMinion.cs +++ b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulPreWOFMinion.cs @@ -1,32 +1,32 @@ namespace AssortedCrazyThings.Projectiles.Minions.CompanionDungeonSouls { - public class CompanionDungeonSoulPreWOFMinion : CompanionDungeonSoulMinionBase - { - public override void SafeSetDefaults() - { - defdistanceFromTarget = 700f; - defdistancePlayerFarAway = 800f; - defdistancePlayerFarAwayWhenHasTarget = 1200f; - defdistanceToEnemyBeforeCanDash = 20f; //20f - defplayerFloatHeight = -60f; //-60f - defplayerCatchUpIdle = 300f; //300f - defbackToIdleFromNoclipping = 150f; //150f - defdashDelay = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell - defdistanceAttackNoclip = defdashDelay * 5f; - defstartDashRange = defdistanceToEnemyBeforeCanDash + 10f; //30f - defdashIntensity = 4f; //4f + public class CompanionDungeonSoulPreWOFMinion : CompanionDungeonSoulMinionBase + { + public override void SafeSetDefaults() + { + defdistanceFromTarget = 700f; + defdistancePlayerFarAway = 800f; + defdistancePlayerFarAwayWhenHasTarget = 1200f; + defdistanceToEnemyBeforeCanDash = 20f; //20f + defplayerFloatHeight = -60f; //-60f + defplayerCatchUpIdle = 300f; //300f + defbackToIdleFromNoclipping = 150f; //150f + defdashDelay = 40f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell + defdistanceAttackNoclip = defdashDelay * 5f; + defstartDashRange = defdistanceToEnemyBeforeCanDash + 10f; //30f + defdashIntensity = 4f; //4f - veloFactorToEnemy = 6f; //8f - accFactorToEnemy = 16f; //41f + veloFactorToEnemy = 6f; //8f + accFactorToEnemy = 16f; //41f - veloFactorAfterDash = 8f; //4f - accFactorAfterDash = 41f; //41f + veloFactorAfterDash = 8f; //4f + accFactorAfterDash = 41f; //41f - defveloIdle = 1f; - defveloCatchUpIdle = 8f; - defveloNoclip = 12f; + defveloIdle = 1f; + defveloCatchUpIdle = 8f; + defveloNoclip = 12f; - dustColor = 0; - } - } + dustColor = 0; + } + } } diff --git a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulSightMinion.cs b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulSightMinion.cs index a0e3bc33..b66c50be 100644 --- a/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulSightMinion.cs +++ b/Projectiles/Minions/CompanionDungeonSouls/CompanionDungeonSoulSightMinion.cs @@ -3,44 +3,44 @@ namespace AssortedCrazyThings.Projectiles.Minions.CompanionDungeonSouls { - public class CompanionDungeonSoulSightMinion : CompanionDungeonSoulMinionBase - { - public override void SafeSetDefaults() - { - Projectile.minionSlots = 1f; - defdistanceFromTarget = 700f; - defdistancePlayerFarAway = 800f; - defdistancePlayerFarAwayWhenHasTarget = 1200f; - defdistanceToEnemyBeforeCanDash = 20f; //20f - defplayerFloatHeight = -60f; //-60f - defplayerCatchUpIdle = 300f; //300f - defbackToIdleFromNoclipping = 150f; //150f - defdashDelay = 20f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell - defdistanceAttackNoclip = defdashDelay * 5f; - defstartDashRange = defdistanceToEnemyBeforeCanDash + 10f; //30f - defdashIntensity = 1.5f; //4f + public class CompanionDungeonSoulSightMinion : CompanionDungeonSoulMinionBase + { + public override void SafeSetDefaults() + { + Projectile.minionSlots = 1f; + defdistanceFromTarget = 700f; + defdistancePlayerFarAway = 800f; + defdistancePlayerFarAwayWhenHasTarget = 1200f; + defdistanceToEnemyBeforeCanDash = 20f; //20f + defplayerFloatHeight = -60f; //-60f + defplayerCatchUpIdle = 300f; //300f + defbackToIdleFromNoclipping = 150f; //150f + defdashDelay = 20f; //time it stays in the "dashing" state after a dash, he dashes when he is in state 0 aswell + defdistanceAttackNoclip = defdashDelay * 5f; + defstartDashRange = defdistanceToEnemyBeforeCanDash + 10f; //30f + defdashIntensity = 1.5f; //4f - veloFactorToEnemy = 10f; //8f - accFactorToEnemy = 8f; //41f + veloFactorToEnemy = 10f; //8f + accFactorToEnemy = 8f; //41f - veloFactorAfterDash = 1f; //4f - accFactorAfterDash = 16f; //41f + veloFactorAfterDash = 1f; //4f + accFactorAfterDash = 16f; //41f - defveloIdle = 1f; - defveloCatchUpIdle = 8f; - defveloNoclip = 12f; + defveloIdle = 1f; + defveloCatchUpIdle = 8f; + defveloNoclip = 12f; - dustColor = ItemID.BrightGreenDye; + dustColor = ItemID.BrightGreenDye; - Projectile.idStaticNPCHitCooldown = 14; - } + Projectile.idStaticNPCHitCooldown = 14; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (Main.rand.NextBool(4)) - { - target.AddBuff(BuffID.CursedInferno, 120); - } - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (Main.rand.NextBool(4)) + { + target.AddBuff(BuffID.CursedInferno, 120); + } + } + } } diff --git a/Projectiles/Minions/Drones/BasicLaserDrone.cs b/Projectiles/Minions/Drones/BasicLaserDrone.cs index 01782082..3395b8ba 100644 --- a/Projectiles/Minions/Drones/BasicLaserDrone.cs +++ b/Projectiles/Minions/Drones/BasicLaserDrone.cs @@ -7,307 +7,307 @@ namespace AssortedCrazyThings.Projectiles.Minions.Drones { - /// - /// Fires a weak laser rapidly - /// - public class BasicLaserDrone : DroneBase - { - private static readonly string nameGlow = "Projectiles/Minions/Drones/" + "BasicLaserDrone_Glowmask"; - private static readonly string nameLower = "Projectiles/Minions/Drones/" + "BasicLaserDrone_Lower"; - private static readonly string nameLowerGlow = "Projectiles/Minions/Drones/" + "BasicLaserDrone_Lower_Glowmask"; - - private const int AttackDelay = 25; - private const int SearchDelay = 30; - - private const byte STATE_IDLE = 0; - private const byte STATE_TARGET_FOUND = 1; - private const byte STATE_TARGET_ACQUIRED = 2; - private const byte STATE_TARGET_FIRE = 3; - - private byte AI_STATE = 0; - private int Direction = -1; - private float addRotation; //same - private NPC Target; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Basic Laser Drone"); - Main.projFrames[Projectile.type] = 3; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 38; - Projectile.height = 30; - Projectile.alpha = 0; - Projectile.DamageType = DamageClass.Summon; - Projectile.minion = true; - Projectile.minionSlots = 1f; - } - - protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) - { - if (AI_STATE == STATE_TARGET_FIRE) - { - Projectile.frame = 2; - } - else if (AI_STATE == STATE_TARGET_FOUND || AI_STATE == STATE_TARGET_ACQUIRED) - { - Projectile.frame = 1; - } - else - { - Projectile.frame = 0; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 8f) + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); - - image = Mod.Assets.Request(nameGlow).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); - - Vector2 rotationOffset = new Vector2(0f, -2f); //-2f - drawPos += rotationOffset + new Vector2(0f, 2f); //lower sprite is offset by 2 because its too low, just a correction - drawOrigin += rotationOffset; - - //AssUtils.ShowDustAtPos(135, projectile.position + stupidOffset); - - //AssUtils.ShowDustAtPos(136, projectile.position + stupidOffset - drawOrigin); - - //rotation origin is (projectile.position + stupidOffset) - drawOrigin; //not including Main.screenPosition - image = Mod.Assets.Request(nameLower).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, addRotation, drawOrigin, 1f, effects, 0); - - image = Mod.Assets.Request(nameLowerGlow).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, addRotation, drawOrigin, 1f, effects, 0); - - return false; - } - - protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) - { - if (AI_STATE == STATE_TARGET_FIRE) - { - Vector2 between = Target.Center - Projectile.Center; - //between.Length(): 100 is "close", 1000 is "edge of screen" - //15.6f = 1000f / 64f - float magnitude = Utils.Clamp(between.Length() / 15.6f, 6f, 64f); - between.Normalize(); - Vector2 offset = between * magnitude; - offset.Y *= 0.5f; - offsetX += offset.X; - offsetY += (offset.Y > 0) ? -(32 - offset.Y) : 0; - } - return true; - } - - protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) - { - if (AI_STATE == STATE_TARGET_FIRE) - { - if (Main.rand.NextBool(3)) Counter++; - } - dmgModifier = 1.25f; - kbModifier = 1.25f; - } - - private string GetState(byte status) - { - switch (status) - { - case STATE_IDLE: return "idle"; - case STATE_TARGET_FOUND: return "found"; - case STATE_TARGET_ACQUIRED: return "aquired"; - case STATE_TARGET_FIRE: return "fire"; - } - return ""; - } - - protected override void CustomAI() - { - Player player = Projectile.GetOwner(); - //Main.NewText("State: " + GetState(AI_STATE)); - //Main.NewText("Counter: " + Counter); - - #region Handle State - int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 1000, ignoreTiles: true); - if (targetIndex != -1) - { - if (AI_STATE == STATE_IDLE) AI_STATE = STATE_TARGET_FOUND; - Target = Main.npc[targetIndex]; - - targetIndex = FindClosestTargetBelow(1000); - if (targetIndex != -1) - { - Target = Main.npc[targetIndex]; - if (AI_STATE != STATE_TARGET_FIRE) - { - AI_STATE = STATE_TARGET_ACQUIRED; - } - - if (AI_STATE == STATE_TARGET_ACQUIRED) - { - if (Counter > SearchDelay) - { - Counter = 0; - AI_STATE = STATE_TARGET_FIRE; - } - } - } - else - { - Counter = 0; - AI_STATE = STATE_TARGET_FOUND; - } - } - else - { - AI_STATE = STATE_IDLE; - } - - if (AI_STATE == STATE_IDLE || AI_STATE == STATE_TARGET_FOUND) - { - Direction = player.direction; - } - else //definitely has a target (may or may not shoot) - { - Direction = (Target.Center.X - Projectile.Center.X > 0f).ToDirectionInt(); - } - - if (AI_STATE == STATE_IDLE) Counter = 2 * MinionPos; - else Counter++; - - Projectile.spriteDirection = Projectile.direction = -Direction; - #endregion - - if (AI_STATE == STATE_TARGET_FIRE) - { - Vector2 shootOffset = new Vector2(Projectile.width / 2 + Projectile.spriteDirection * 4f, (Projectile.height - 2f) + sinY); - Vector2 shootOrigin = Projectile.position + shootOffset; - Vector2 target = Target.Center + new Vector2(0f, -5f); - - Vector2 between = target - shootOrigin; - shootOrigin += Vector2.Normalize(between) * 16f; //roughly tip of turret - - float rotationAmount = between.ToRotation(); - - if (Projectile.spriteDirection == 1) //adjust rotation based on direction - { - rotationAmount -= MathHelper.Pi; - if (rotationAmount > MathHelper.TwoPi) - { - rotationAmount = -rotationAmount; - } - } - - bool canShoot = true;/*shootOrigin.Y < target.Y + Target.height / 2 + 40;*/ - - if (Projectile.spriteDirection == -1) //reset canShoot properly if rotation is too much (aka target is too fast for the drone to catch up) - { - if (rotationAmount <= Projectile.rotation) - { - canShoot = false; - rotationAmount = Projectile.rotation; - } - } - else - { - if (rotationAmount <= Projectile.rotation - MathHelper.Pi) - { - canShoot = false; - rotationAmount = Projectile.rotation; - } - } - addRotation = addRotation.AngleLerp(rotationAmount, 0.1f); - - if (canShoot) //when target below drone - { - if (Counter > AttackDelay) - { - Counter = 0; - if (RealOwner) - { - if (targetIndex != -1 && !Collision.SolidCollision(shootOrigin, 1, 1)) - { - between = target + Target.velocity * 6f - shootOrigin; - between.Normalize(); - between *= 6f; - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), shootOrigin, between, ModContent.ProjectileType(), CustomDmg, CustomKB, Main.myPlayer); - - //projectile.netUpdate = true; - } - } - } - } - else - { - Counter = 0; - AI_STATE = STATE_TARGET_ACQUIRED; - } - } - else //if no target, addRotation should go down to projectile.rotation - { - //if addRotation is bigger than projectile.rotation by a small margin, reduce it down to projectile.rotation slowly - //if (Math.Abs(addRotation) > Math.Abs(projectile.rotation) + 0.006f) - //{ - // float rotDiff = projectile.rotation - addRotation; - // if (Math.Abs(rotDiff) < 0.005f) - // { - // addRotation = projectile.rotation; - // } - // else - // { - // addRotation += addRotation * -0.15f; - // } - //} - //else - //{ - // //fix rotation so it doesn't get adjusted anymore - // addRotation = projectile.rotation; - //} - addRotation = addRotation.AngleLerp(Projectile.rotation, 0.1f); - } - } - - - private int FindClosestTargetBelow(int range = 1000) - { - Player player = Projectile.GetOwner(); - int targetIndex = -1; - float distanceFromTarget = 100000f; - Vector2 targetCenter = Projectile.Center; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - if (npc.CanBeChasedBy()) - { - float between = Vector2.Distance(npc.Center, Projectile.Center); - if (((between < range && - Vector2.Distance(player.Center, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1) && - Projectile.Bottom.Y < npc.Top.Y + 40 && Collision.CanHitLine(Projectile.Center, 1, 1, npc.position, npc.width, npc.height)) - { - distanceFromTarget = between; - targetCenter = npc.Center; - targetIndex = k; - } - } - } - return (distanceFromTarget < range) ? targetIndex : -1; - } - } + /// + /// Fires a weak laser rapidly + /// + public class BasicLaserDrone : DroneBase + { + private static readonly string nameGlow = "Projectiles/Minions/Drones/" + "BasicLaserDrone_Glowmask"; + private static readonly string nameLower = "Projectiles/Minions/Drones/" + "BasicLaserDrone_Lower"; + private static readonly string nameLowerGlow = "Projectiles/Minions/Drones/" + "BasicLaserDrone_Lower_Glowmask"; + + private const int AttackDelay = 25; + private const int SearchDelay = 30; + + private const byte STATE_IDLE = 0; + private const byte STATE_TARGET_FOUND = 1; + private const byte STATE_TARGET_ACQUIRED = 2; + private const byte STATE_TARGET_FIRE = 3; + + private byte AI_STATE = 0; + private int Direction = -1; + private float addRotation; //same + private NPC Target; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Basic Laser Drone"); + Main.projFrames[Projectile.type] = 3; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 38; + Projectile.height = 30; + Projectile.alpha = 0; + Projectile.DamageType = DamageClass.Summon; + Projectile.minion = true; + Projectile.minionSlots = 1f; + } + + protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) + { + if (AI_STATE == STATE_TARGET_FIRE) + { + Projectile.frame = 2; + } + else if (AI_STATE == STATE_TARGET_FOUND || AI_STATE == STATE_TARGET_ACQUIRED) + { + Projectile.frame = 1; + } + else + { + Projectile.frame = 0; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 8f) + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); + + image = Mod.Assets.Request(nameGlow).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); + + Vector2 rotationOffset = new Vector2(0f, -2f); //-2f + drawPos += rotationOffset + new Vector2(0f, 2f); //lower sprite is offset by 2 because its too low, just a correction + drawOrigin += rotationOffset; + + //AssUtils.ShowDustAtPos(135, projectile.position + stupidOffset); + + //AssUtils.ShowDustAtPos(136, projectile.position + stupidOffset - drawOrigin); + + //rotation origin is (projectile.position + stupidOffset) - drawOrigin; //not including Main.screenPosition + image = Mod.Assets.Request(nameLower).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, addRotation, drawOrigin, 1f, effects, 0); + + image = Mod.Assets.Request(nameLowerGlow).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, addRotation, drawOrigin, 1f, effects, 0); + + return false; + } + + protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) + { + if (AI_STATE == STATE_TARGET_FIRE) + { + Vector2 between = Target.Center - Projectile.Center; + //between.Length(): 100 is "close", 1000 is "edge of screen" + //15.6f = 1000f / 64f + float magnitude = Utils.Clamp(between.Length() / 15.6f, 6f, 64f); + between.Normalize(); + Vector2 offset = between * magnitude; + offset.Y *= 0.5f; + offsetX += offset.X; + offsetY += (offset.Y > 0) ? -(32 - offset.Y) : 0; + } + return true; + } + + protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) + { + if (AI_STATE == STATE_TARGET_FIRE) + { + if (Main.rand.NextBool(3)) Counter++; + } + dmgModifier = 1.25f; + kbModifier = 1.25f; + } + + private string GetState(byte status) + { + switch (status) + { + case STATE_IDLE: return "idle"; + case STATE_TARGET_FOUND: return "found"; + case STATE_TARGET_ACQUIRED: return "aquired"; + case STATE_TARGET_FIRE: return "fire"; + } + return ""; + } + + protected override void CustomAI() + { + Player player = Projectile.GetOwner(); + //Main.NewText("State: " + GetState(AI_STATE)); + //Main.NewText("Counter: " + Counter); + + #region Handle State + int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 1000, ignoreTiles: true); + if (targetIndex != -1) + { + if (AI_STATE == STATE_IDLE) AI_STATE = STATE_TARGET_FOUND; + Target = Main.npc[targetIndex]; + + targetIndex = FindClosestTargetBelow(1000); + if (targetIndex != -1) + { + Target = Main.npc[targetIndex]; + if (AI_STATE != STATE_TARGET_FIRE) + { + AI_STATE = STATE_TARGET_ACQUIRED; + } + + if (AI_STATE == STATE_TARGET_ACQUIRED) + { + if (Counter > SearchDelay) + { + Counter = 0; + AI_STATE = STATE_TARGET_FIRE; + } + } + } + else + { + Counter = 0; + AI_STATE = STATE_TARGET_FOUND; + } + } + else + { + AI_STATE = STATE_IDLE; + } + + if (AI_STATE == STATE_IDLE || AI_STATE == STATE_TARGET_FOUND) + { + Direction = player.direction; + } + else //definitely has a target (may or may not shoot) + { + Direction = (Target.Center.X - Projectile.Center.X > 0f).ToDirectionInt(); + } + + if (AI_STATE == STATE_IDLE) Counter = 2 * MinionPos; + else Counter++; + + Projectile.spriteDirection = Projectile.direction = -Direction; + #endregion + + if (AI_STATE == STATE_TARGET_FIRE) + { + Vector2 shootOffset = new Vector2(Projectile.width / 2 + Projectile.spriteDirection * 4f, (Projectile.height - 2f) + sinY); + Vector2 shootOrigin = Projectile.position + shootOffset; + Vector2 target = Target.Center + new Vector2(0f, -5f); + + Vector2 between = target - shootOrigin; + shootOrigin += Vector2.Normalize(between) * 16f; //roughly tip of turret + + float rotationAmount = between.ToRotation(); + + if (Projectile.spriteDirection == 1) //adjust rotation based on direction + { + rotationAmount -= MathHelper.Pi; + if (rotationAmount > MathHelper.TwoPi) + { + rotationAmount = -rotationAmount; + } + } + + bool canShoot = true;/*shootOrigin.Y < target.Y + Target.height / 2 + 40;*/ + + if (Projectile.spriteDirection == -1) //reset canShoot properly if rotation is too much (aka target is too fast for the drone to catch up) + { + if (rotationAmount <= Projectile.rotation) + { + canShoot = false; + rotationAmount = Projectile.rotation; + } + } + else + { + if (rotationAmount <= Projectile.rotation - MathHelper.Pi) + { + canShoot = false; + rotationAmount = Projectile.rotation; + } + } + addRotation = addRotation.AngleLerp(rotationAmount, 0.1f); + + if (canShoot) //when target below drone + { + if (Counter > AttackDelay) + { + Counter = 0; + if (RealOwner) + { + if (targetIndex != -1 && !Collision.SolidCollision(shootOrigin, 1, 1)) + { + between = target + Target.velocity * 6f - shootOrigin; + between.Normalize(); + between *= 6f; + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), shootOrigin, between, ModContent.ProjectileType(), CustomDmg, CustomKB, Main.myPlayer); + + //projectile.netUpdate = true; + } + } + } + } + else + { + Counter = 0; + AI_STATE = STATE_TARGET_ACQUIRED; + } + } + else //if no target, addRotation should go down to projectile.rotation + { + //if addRotation is bigger than projectile.rotation by a small margin, reduce it down to projectile.rotation slowly + //if (Math.Abs(addRotation) > Math.Abs(projectile.rotation) + 0.006f) + //{ + // float rotDiff = projectile.rotation - addRotation; + // if (Math.Abs(rotDiff) < 0.005f) + // { + // addRotation = projectile.rotation; + // } + // else + // { + // addRotation += addRotation * -0.15f; + // } + //} + //else + //{ + // //fix rotation so it doesn't get adjusted anymore + // addRotation = projectile.rotation; + //} + addRotation = addRotation.AngleLerp(Projectile.rotation, 0.1f); + } + } + + + private int FindClosestTargetBelow(int range = 1000) + { + Player player = Projectile.GetOwner(); + int targetIndex = -1; + float distanceFromTarget = 100000f; + Vector2 targetCenter = Projectile.Center; + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + if (npc.CanBeChasedBy()) + { + float between = Vector2.Distance(npc.Center, Projectile.Center); + if (((between < range && + Vector2.Distance(player.Center, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1) && + Projectile.Bottom.Y < npc.Top.Y + 40 && Collision.CanHitLine(Projectile.Center, 1, 1, npc.position, npc.width, npc.height)) + { + distanceFromTarget = between; + targetCenter = npc.Center; + targetIndex = k; + } + } + } + return (distanceFromTarget < range) ? targetIndex : -1; + } + } } diff --git a/Projectiles/Minions/Drones/DroneBase.cs b/Projectiles/Minions/Drones/DroneBase.cs index ea2f5211..ca8b7aac 100644 --- a/Projectiles/Minions/Drones/DroneBase.cs +++ b/Projectiles/Minions/Drones/DroneBase.cs @@ -9,223 +9,223 @@ namespace AssortedCrazyThings.Projectiles.Minions.Drones { - /// - /// Uses ai[0] for a counter and ai[1] for the minion position. - /// LocalAI[0] & localAI[1] for the bobbing and a random number. - /// Bobbing (sinY) needs to be implemented manually in some draw hook - /// - [Content(ContentType.Weapons)] - public abstract class DroneBase : AssProjectile - { - - /// - /// Currently only used to make MinionPos 0 again. The assignment of MinionPos still depends on the array used in Shoot() - /// - public virtual bool IsCombatDrone - { - get - { - return true; - } - } - - /// - /// Custom MinionPos to determine position - /// - public int MinionPos - { - get - { - return (int)Projectile.ai[1]; - } - set - { - Projectile.ai[1] = value; - } - } - - /// - /// General purpose counter using ai[0] - /// - protected int Counter - { - get - { - return (int)Projectile.ai[0]; - } - set - { - Projectile.ai[0] = value; - } - } - - protected float Sincounter - { - get - { - return Projectile.localAI[0]; - } - set - { - Projectile.localAI[0] = value; - } - } - - protected byte RandomNumber - { - get - { - return (byte)Projectile.localAI[1]; - } - set - { - Projectile.localAI[1] = value; - } - } - - /// - /// Combined != Server and owner == myPlayer check - /// - protected bool RealOwner - { - get - { - return Main.netMode != NetmodeID.Server && Projectile.owner == Main.myPlayer; - } - } - - /// - /// Use this when spawning projectiles - /// - protected int CustomDmg - { - get - { - return (int)(Projectile.damage * dmgModifier); - } - } - - /// - /// Use this when spawning projectiles - /// - protected float CustomKB - { - get - { - return Projectile.knockBack * kbModifier; - } - } - - /// - /// Depends on projectile.localAI[0] - /// - protected float sinY = 0f; - private float dmgModifier = 1f; - private float kbModifier = 1f; - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write((byte)RandomNumber); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - RandomNumber = reader.ReadByte(); - } - - protected virtual void CustomAI() - { - - } - - protected virtual void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) - { - - } - - protected virtual void CheckActive() - { - Player player = Projectile.GetOwner(); - AssPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.droneControllerMinion = false; - } - if (modPlayer.droneControllerMinion) - { - Projectile.timeLeft = 2; - } - } - - /// - /// Bobbing logic. Implement sinY yourself. Return false to not let default AI calculate it - /// - protected virtual bool Bobbing() - { - return true; - } - - /// - /// Use to decide what happens when the player holds the Drone Controller. - /// Can be used to change damage and knockback, or internal timers - /// - protected virtual void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) - { - - } - - /// - /// Use to change any default values of the AI on the fly (called before Default AI is called). - /// Return false to prevent the default AI to run - /// - protected virtual bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) - { - return true; - } - - public sealed override void AI() - { - CheckActive(); - - #region Default AI - if (RandomNumber == 0) - { - RandomNumber = (byte)Main.rand.Next(1, 256); - } - - Player player = Projectile.GetOwner(); - Vector2 offset = new Vector2(-30, 20); //to offset FlickerwickPetAI to player.Center - offset += DroneController.GetPosition(Projectile, MinionPos); - - bool staticDirection = true; - bool reverseSide = false; - float veloXToRotationFactor = 0.5f + (RandomNumber / 255f - 0.5f) * 0.5f; - float veloSpeed = 1f + (RandomNumber / 255f - 0.5f) * 0.4f; - float offsetX = offset.X; - float offsetY = offset.Y; - bool run = ModifyDefaultAI(ref staticDirection, ref reverseSide, ref veloXToRotationFactor, ref veloSpeed, ref offsetX, ref offsetY); - if (run) - { - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, staticDirection: staticDirection, reverseSide: reverseSide, veloXToRotationFactor: veloXToRotationFactor, veloSpeed: veloSpeed, offsetX: offsetX, offsetY: offsetY); - Projectile.direction = Projectile.spriteDirection = -player.direction; - } - if (IsCombatDrone) player.numMinions--; //make it so it doesn't affect projectile.minionPos of non-drone minions - - #endregion - - dmgModifier = 1f; - kbModifier = 1f; - if (player.HeldItem.type == ModContent.ItemType()) - { - ModifyDroneControllerHeld(ref dmgModifier, ref kbModifier); - } - CustomAI(); - if (Bobbing()) - { - Sincounter = Sincounter > 240 ? 0 : Sincounter + 1; - sinY = (float)((Math.Sin(((Sincounter + MinionPos * 10f) / 120f) * MathHelper.TwoPi) - 1) * 4); - } - CustomFrame(); - } - } + /// + /// Uses ai[0] for a counter and ai[1] for the minion position. + /// LocalAI[0] & localAI[1] for the bobbing and a random number. + /// Bobbing (sinY) needs to be implemented manually in some draw hook + /// + [Content(ContentType.Weapons)] + public abstract class DroneBase : AssProjectile + { + + /// + /// Currently only used to make MinionPos 0 again. The assignment of MinionPos still depends on the array used in Shoot() + /// + public virtual bool IsCombatDrone + { + get + { + return true; + } + } + + /// + /// Custom MinionPos to determine position + /// + public int MinionPos + { + get + { + return (int)Projectile.ai[1]; + } + set + { + Projectile.ai[1] = value; + } + } + + /// + /// General purpose counter using ai[0] + /// + protected int Counter + { + get + { + return (int)Projectile.ai[0]; + } + set + { + Projectile.ai[0] = value; + } + } + + protected float Sincounter + { + get + { + return Projectile.localAI[0]; + } + set + { + Projectile.localAI[0] = value; + } + } + + protected byte RandomNumber + { + get + { + return (byte)Projectile.localAI[1]; + } + set + { + Projectile.localAI[1] = value; + } + } + + /// + /// Combined != Server and owner == myPlayer check + /// + protected bool RealOwner + { + get + { + return Main.netMode != NetmodeID.Server && Projectile.owner == Main.myPlayer; + } + } + + /// + /// Use this when spawning projectiles + /// + protected int CustomDmg + { + get + { + return (int)(Projectile.damage * dmgModifier); + } + } + + /// + /// Use this when spawning projectiles + /// + protected float CustomKB + { + get + { + return Projectile.knockBack * kbModifier; + } + } + + /// + /// Depends on projectile.localAI[0] + /// + protected float sinY = 0f; + private float dmgModifier = 1f; + private float kbModifier = 1f; + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write((byte)RandomNumber); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + RandomNumber = reader.ReadByte(); + } + + protected virtual void CustomAI() + { + + } + + protected virtual void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) + { + + } + + protected virtual void CheckActive() + { + Player player = Projectile.GetOwner(); + AssPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.droneControllerMinion = false; + } + if (modPlayer.droneControllerMinion) + { + Projectile.timeLeft = 2; + } + } + + /// + /// Bobbing logic. Implement sinY yourself. Return false to not let default AI calculate it + /// + protected virtual bool Bobbing() + { + return true; + } + + /// + /// Use to decide what happens when the player holds the Drone Controller. + /// Can be used to change damage and knockback, or internal timers + /// + protected virtual void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) + { + + } + + /// + /// Use to change any default values of the AI on the fly (called before Default AI is called). + /// Return false to prevent the default AI to run + /// + protected virtual bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) + { + return true; + } + + public sealed override void AI() + { + CheckActive(); + + #region Default AI + if (RandomNumber == 0) + { + RandomNumber = (byte)Main.rand.Next(1, 256); + } + + Player player = Projectile.GetOwner(); + Vector2 offset = new Vector2(-30, 20); //to offset FlickerwickPetAI to player.Center + offset += DroneController.GetPosition(Projectile, MinionPos); + + bool staticDirection = true; + bool reverseSide = false; + float veloXToRotationFactor = 0.5f + (RandomNumber / 255f - 0.5f) * 0.5f; + float veloSpeed = 1f + (RandomNumber / 255f - 0.5f) * 0.4f; + float offsetX = offset.X; + float offsetY = offset.Y; + bool run = ModifyDefaultAI(ref staticDirection, ref reverseSide, ref veloXToRotationFactor, ref veloSpeed, ref offsetX, ref offsetY); + if (run) + { + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, staticDirection: staticDirection, reverseSide: reverseSide, veloXToRotationFactor: veloXToRotationFactor, veloSpeed: veloSpeed, offsetX: offsetX, offsetY: offsetY); + Projectile.direction = Projectile.spriteDirection = -player.direction; + } + if (IsCombatDrone) player.numMinions--; //make it so it doesn't affect projectile.minionPos of non-drone minions + + #endregion + + dmgModifier = 1f; + kbModifier = 1f; + if (player.HeldItem.type == ModContent.ItemType()) + { + ModifyDroneControllerHeld(ref dmgModifier, ref kbModifier); + } + CustomAI(); + if (Bobbing()) + { + Sincounter = Sincounter > 240 ? 0 : Sincounter + 1; + sinY = (float)((Math.Sin(((Sincounter + MinionPos * 10f) / 120f) * MathHelper.TwoPi) - 1) * 4); + } + CustomFrame(); + } + } } diff --git a/Projectiles/Minions/Drones/HealingDrone.cs b/Projectiles/Minions/Drones/HealingDrone.cs index 12e1b86e..94a7707c 100644 --- a/Projectiles/Minions/Drones/HealingDrone.cs +++ b/Projectiles/Minions/Drones/HealingDrone.cs @@ -7,227 +7,227 @@ namespace AssortedCrazyThings.Projectiles.Minions.Drones { - /// - /// Heals the player if below max health. Heals faster when below 50% health - /// - public class HealingDrone : DroneBase - { - private static readonly string nameGlow = "Projectiles/Minions/Drones/" + "HealingDrone_Glowmask"; - private static readonly string nameLower = "Projectiles/Minions/Drones/" + "HealingDrone_Lower"; - private static readonly string nameLowerGlow = "Projectiles/Minions/Drones/" + "HealingDrone_Lower_Glowmask"; - private float addRotation; //same - private const int HealDelay = 80; - - private float HealCounter - { - get - { - return Projectile.ai[0]; - } - set - { - Projectile.ai[0] = value; - } - } - - private bool CanHeal - { - get - { - return Projectile.GetOwner().statLife < Projectile.GetOwner().statLifeMax2; - } - } - - public override bool IsCombatDrone - { - get - { - return false; - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Healing Drone"); - Main.projFrames[Projectile.type] = 3; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 38; - Projectile.height = 30; - Projectile.alpha = 0; - Projectile.minion = true; - Projectile.minionSlots = 1f; - } - - protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) - { - Player player = Projectile.GetOwner(); - - Vector2 lightPos = Projectile.position + new Vector2(Projectile.spriteDirection == 1 ? 0f : Projectile.width, Projectile.height / 2); - - if (player.statLife < player.statLifeMax2 / 2) - { - Lighting.AddLight(lightPos, new Vector3(153 / 700f, 63 / 700f, 66 / 700f)); - Projectile.frame = 2; - } - else if (CanHeal) - { - Lighting.AddLight(lightPos, new Vector3(240 / 700f, 198 / 700f, 0f)); - Projectile.frame = 1; - } - else - { - Lighting.AddLight(lightPos, new Vector3(124 / 700f, 251 / 700f, 34 / 700f)); - Projectile.frame = 0; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height - 8f + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); - - image = Mod.Assets.Request(nameGlow).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); - - Vector2 rotationOffset = new Vector2(0f, -2f); //-2f) - drawPos += rotationOffset; - drawOrigin += rotationOffset; - - //AssUtils.ShowDustAtPos(135, projectile.position + stupidOffset); - - //AssUtils.ShowDustAtPos(136, projectile.position + stupidOffset - drawOrigin); - - //rotation origin is (projectile.position + stupidOffset) - drawOrigin; //not including Main.screenPosition - image = Mod.Assets.Request(nameLower).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, addRotation, drawOrigin, 1f, effects, 0); - - image = Mod.Assets.Request(nameLowerGlow).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, addRotation, drawOrigin, 1f, effects, 0); - - return false; - } - - protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) - { - if (CanHeal) HealCounter += 0.333f; - } - - protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) - { - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, veloXToRotationFactor: 0.5f, offsetX: 16f, offsetY: CanHeal ? -16f : 4f); //2f - return false; - } - - protected override void CustomAI() - { - Player player = Projectile.GetOwner(); - - if (CanHeal) - { - Vector2 shootOffset = new Vector2(Projectile.width / 2 + Projectile.spriteDirection * 4f, (Projectile.height - 2f) + sinY); - Vector2 shootOrigin = Projectile.position + shootOffset; - Vector2 target = player.MountedCenter + new Vector2(0f, -5f); - - Vector2 between = target - shootOrigin; - shootOrigin += Vector2.Normalize(between) * 16f; //roughly tip of turret - target += -Vector2.Normalize(between) * 12f; //roughly center of head with a buffer - - float rotationAmount = between.ToRotation(); - - if (Projectile.spriteDirection == 1) //adjust rotation based on direction - { - rotationAmount -= MathHelper.Pi; - if (rotationAmount > MathHelper.TwoPi) - { - rotationAmount = -rotationAmount; - } - } - - bool canShoot = shootOrigin.Y < target.Y + player.height / 2; - - if (Projectile.spriteDirection == -1) //reset canShoot properly if rotation is too much (aka target is too fast for the drone to catch up) - { - if (rotationAmount <= Projectile.rotation) - { - canShoot = false; - rotationAmount = Projectile.rotation; - } - } - else - { - if (rotationAmount <= Projectile.rotation - MathHelper.Pi) - { - canShoot = false; - rotationAmount = Projectile.rotation; - } - } - addRotation = addRotation.AngleLerp(rotationAmount, 0.1f); - - if (canShoot) //when target below drone - { - HealCounter++; - int delay = HealDelay - (player.statLife < player.statLifeMax2 / 2 ? 20 : 0); - - if (HealCounter > delay) - { - HealCounter = 0; - int heal = 1; - player.statLife += heal; - //if it would be just clientside, test this: - //if (Main.netMode != NetmodeID.Singleplayer) NetMessage.SendData(MessageID.PlayerHealth, -1, -1, null, player.whoAmI); - player.HealEffect(heal, false); - AssUtils.QuickDustLine(61, shootOrigin, target, between.Length() / 3, Color.White, alpha: 120, scale: 2f); - } - - //if (Sincounter % delay == 30) //only shoot once every 1.333 or 1.5 seconds, when target below drone and when turret aligned properly - //{ - // int heal = 1; - // player.statLife += heal; - // player.HealEffect(heal, false); - //} - //if (Sincounter % delay == 35) - //{ - // AssUtils.QuickDustLine(61, shootOrigin, target, between.Length() / 3, Color.White, alpha: 120, scale: 2f); - //} - } - } - else //if above 50%, addRotation should go down to projectile.rotation - { - ////if addRotation is bigger than projectile.rotation by a small margin, reduce it down to projectile.rotation slowly - //if (Math.Abs(addRotation) > Math.Abs(projectile.rotation) + 0.006f) - //{ - // float rotDiff = projectile.rotation - addRotation; - // if (Math.Abs(rotDiff) < 0.005f) - // { - // addRotation = projectile.rotation; - // } - // else - // { - // addRotation += addRotation * -0.15f; - // } - //} - //else - //{ - // //fix rotation so it doesn't get adjusted anymore - // addRotation = projectile.rotation; - //} - addRotation = addRotation.AngleLerp(Projectile.rotation, 0.1f); - } - } - } + /// + /// Heals the player if below max health. Heals faster when below 50% health + /// + public class HealingDrone : DroneBase + { + private static readonly string nameGlow = "Projectiles/Minions/Drones/" + "HealingDrone_Glowmask"; + private static readonly string nameLower = "Projectiles/Minions/Drones/" + "HealingDrone_Lower"; + private static readonly string nameLowerGlow = "Projectiles/Minions/Drones/" + "HealingDrone_Lower_Glowmask"; + private float addRotation; //same + private const int HealDelay = 80; + + private float HealCounter + { + get + { + return Projectile.ai[0]; + } + set + { + Projectile.ai[0] = value; + } + } + + private bool CanHeal + { + get + { + return Projectile.GetOwner().statLife < Projectile.GetOwner().statLifeMax2; + } + } + + public override bool IsCombatDrone + { + get + { + return false; + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Healing Drone"); + Main.projFrames[Projectile.type] = 3; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 38; + Projectile.height = 30; + Projectile.alpha = 0; + Projectile.minion = true; + Projectile.minionSlots = 1f; + } + + protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) + { + Player player = Projectile.GetOwner(); + + Vector2 lightPos = Projectile.position + new Vector2(Projectile.spriteDirection == 1 ? 0f : Projectile.width, Projectile.height / 2); + + if (player.statLife < player.statLifeMax2 / 2) + { + Lighting.AddLight(lightPos, new Vector3(153 / 700f, 63 / 700f, 66 / 700f)); + Projectile.frame = 2; + } + else if (CanHeal) + { + Lighting.AddLight(lightPos, new Vector3(240 / 700f, 198 / 700f, 0f)); + Projectile.frame = 1; + } + else + { + Lighting.AddLight(lightPos, new Vector3(124 / 700f, 251 / 700f, 34 / 700f)); + Projectile.frame = 0; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height - 8f + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); + + image = Mod.Assets.Request(nameGlow).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); + + Vector2 rotationOffset = new Vector2(0f, -2f); //-2f) + drawPos += rotationOffset; + drawOrigin += rotationOffset; + + //AssUtils.ShowDustAtPos(135, projectile.position + stupidOffset); + + //AssUtils.ShowDustAtPos(136, projectile.position + stupidOffset - drawOrigin); + + //rotation origin is (projectile.position + stupidOffset) - drawOrigin; //not including Main.screenPosition + image = Mod.Assets.Request(nameLower).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, addRotation, drawOrigin, 1f, effects, 0); + + image = Mod.Assets.Request(nameLowerGlow).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, addRotation, drawOrigin, 1f, effects, 0); + + return false; + } + + protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) + { + if (CanHeal) HealCounter += 0.333f; + } + + protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) + { + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, veloXToRotationFactor: 0.5f, offsetX: 16f, offsetY: CanHeal ? -16f : 4f); //2f + return false; + } + + protected override void CustomAI() + { + Player player = Projectile.GetOwner(); + + if (CanHeal) + { + Vector2 shootOffset = new Vector2(Projectile.width / 2 + Projectile.spriteDirection * 4f, (Projectile.height - 2f) + sinY); + Vector2 shootOrigin = Projectile.position + shootOffset; + Vector2 target = player.MountedCenter + new Vector2(0f, -5f); + + Vector2 between = target - shootOrigin; + shootOrigin += Vector2.Normalize(between) * 16f; //roughly tip of turret + target += -Vector2.Normalize(between) * 12f; //roughly center of head with a buffer + + float rotationAmount = between.ToRotation(); + + if (Projectile.spriteDirection == 1) //adjust rotation based on direction + { + rotationAmount -= MathHelper.Pi; + if (rotationAmount > MathHelper.TwoPi) + { + rotationAmount = -rotationAmount; + } + } + + bool canShoot = shootOrigin.Y < target.Y + player.height / 2; + + if (Projectile.spriteDirection == -1) //reset canShoot properly if rotation is too much (aka target is too fast for the drone to catch up) + { + if (rotationAmount <= Projectile.rotation) + { + canShoot = false; + rotationAmount = Projectile.rotation; + } + } + else + { + if (rotationAmount <= Projectile.rotation - MathHelper.Pi) + { + canShoot = false; + rotationAmount = Projectile.rotation; + } + } + addRotation = addRotation.AngleLerp(rotationAmount, 0.1f); + + if (canShoot) //when target below drone + { + HealCounter++; + int delay = HealDelay - (player.statLife < player.statLifeMax2 / 2 ? 20 : 0); + + if (HealCounter > delay) + { + HealCounter = 0; + int heal = 1; + player.statLife += heal; + //if it would be just clientside, test this: + //if (Main.netMode != NetmodeID.Singleplayer) NetMessage.SendData(MessageID.PlayerHealth, -1, -1, null, player.whoAmI); + player.HealEffect(heal, false); + AssUtils.QuickDustLine(61, shootOrigin, target, between.Length() / 3, Color.White, alpha: 120, scale: 2f); + } + + //if (Sincounter % delay == 30) //only shoot once every 1.333 or 1.5 seconds, when target below drone and when turret aligned properly + //{ + // int heal = 1; + // player.statLife += heal; + // player.HealEffect(heal, false); + //} + //if (Sincounter % delay == 35) + //{ + // AssUtils.QuickDustLine(61, shootOrigin, target, between.Length() / 3, Color.White, alpha: 120, scale: 2f); + //} + } + } + else //if above 50%, addRotation should go down to projectile.rotation + { + ////if addRotation is bigger than projectile.rotation by a small margin, reduce it down to projectile.rotation slowly + //if (Math.Abs(addRotation) > Math.Abs(projectile.rotation) + 0.006f) + //{ + // float rotDiff = projectile.rotation - addRotation; + // if (Math.Abs(rotDiff) < 0.005f) + // { + // addRotation = projectile.rotation; + // } + // else + // { + // addRotation += addRotation * -0.15f; + // } + //} + //else + //{ + // //fix rotation so it doesn't get adjusted anymore + // addRotation = projectile.rotation; + //} + addRotation = addRotation.AngleLerp(Projectile.rotation, 0.1f); + } + } + } } diff --git a/Projectiles/Minions/Drones/HeavyLaserDrone.cs b/Projectiles/Minions/Drones/HeavyLaserDrone.cs index 6e25c8f3..a422e14c 100644 --- a/Projectiles/Minions/Drones/HeavyLaserDrone.cs +++ b/Projectiles/Minions/Drones/HeavyLaserDrone.cs @@ -5,444 +5,444 @@ using System; using System.IO; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.Projectiles.Minions.Drones { - /// - /// Fires a penetrating laser beam horizontally to the player with a very long delay. - /// Only recognizes enemies at around the y level of the player - /// - public class HeavyLaserDrone : DroneBase - { - private static readonly string nameGlow = "Projectiles/Minions/Drones/" + "HeavyLaserDrone_Glowmask"; - private static readonly string nameOverlay = "Projectiles/Minions/Drones/" + "HeavyLaserDrone_Overlay"; - - private const int AttackCooldown = 180; - private const int RecoilDuration = 60; - private const int SearchDelay = 90; //60 but incremented 1.5f - private const int ChargeDelay = 120; - private const int AnimationDuration = 32; - private const int AnimationFrameTime = 8; - - private const byte STATE_COOLDOWN = 0; - private const byte STATE_IDLE = 1; - private const byte STATE_CHARGE = 2; - private const byte STATE_RECOIL = 3; - - private byte AI_STATE = 0; - private byte PosInCharge = 0; - private int Direction = -1; - private float InitialDistance = 0; - - private Vector2 BarrelPos - { - get - { - Vector2 position = Projectile.Bottom; - position.Y += sinY; - return position; - } - } - - #region overlay - private int ChargeTimer = 0; - - private bool CanOverlay => ChargeTimer >= AnimationDuration && (Projectile.frame == 3 || Projectile.frame == 7); - - private float OverlayOpacity => (ChargeTimer - AnimationDuration) / (float)byte.MaxValue; - - private bool playedOverheatSound = false; - - private SoundEffectInstance overheatSound = null; - - private void IncreaseCharge() - { - if (ChargeTimer < byte.MaxValue) ChargeTimer++; - } - - private void DecreaseCharge() - { - if (ChargeTimer > 0) ChargeTimer--; - } - #endregion - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Heavy Laser Drone"); - Main.projFrames[Projectile.type] = 8; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 38; - Projectile.height = 30; - Projectile.alpha = 0; - Projectile.DamageType = DamageClass.Summon; - Projectile.minion = true; - Projectile.minionSlots = 1f; - } - - public override void SendExtraAI(BinaryWriter writer) - { - base.SendExtraAI(writer); - writer.Write((byte)AI_STATE); - writer.Write((byte)PosInCharge); - writer.Write((byte)ChargeTimer); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - base.ReceiveExtraAI(reader); - AI_STATE = reader.ReadByte(); - PosInCharge = reader.ReadByte(); - ChargeTimer = (int)reader.ReadByte(); - } - - protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) - { - if (AI_STATE == STATE_CHARGE) - { - if (ChargeTimer < AnimationDuration) - { - Projectile.frame = ChargeTimer / AnimationFrameTime; - } - else - { - Projectile.frame = 3; - } - } - else - { - if (ChargeTimer <= 0) - { - Projectile.frame = 0; - } - else if (ChargeTimer < AnimationDuration) - { - Projectile.frame = 4 + ChargeTimer / AnimationFrameTime; - } - else - { - Projectile.frame = 7; - } - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 8f) + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); - - image = Mod.Assets.Request(nameGlow).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); - - if (CanOverlay) - { - image = Mod.Assets.Request(nameOverlay).Value; - Main.EntitySpriteDraw(image, drawPos, image.Bounds, Color.White * OverlayOpacity, Projectile.rotation, drawOrigin, 1f, effects, 0); - } - - return false; - } - - protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) - { - dmgModifier = 1.1f; - kbModifier = 1.1f; - - if (AI_STATE == STATE_COOLDOWN) - { - Counter += Main.rand.Next(2); - } - } - - protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) - { - if (AI_STATE == STATE_CHARGE) - { - //offset x = 30 when facing right - offsetX = Direction == 1 ? -80 : 20; - offsetX += Math.Sign(offsetX) * PosInCharge * Projectile.width * 1.5f; - offsetY = 10; - veloSpeed = 0.5f; - } - else if (AI_STATE == STATE_RECOIL) - { - //150 to 50 is smooth, distance - Vector2 pos = new Vector2(offsetX, offsetY) - new Vector2(-30, 20); - //veloSpeed = (float)Math.Pow((double)Counter / AttackCooldown, 2) + 0.05f; - Vector2 distanceToTargetVector = (pos + Projectile.GetOwner().Center) - Projectile.Center; - float distanceToTarget = distanceToTargetVector.Length(); - if (Counter == 0) InitialDistance = distanceToTarget; - //Main.NewText("proper: " + distanceToTargetVector.Length()); - float magnitude = 1f + distanceToTargetVector.LengthSquared() / (InitialDistance * InitialDistance); - distanceToTargetVector.Normalize(); - distanceToTargetVector *= magnitude; - //-(Counter - AttackCooldown / 5) -> goes from 36 to 0 - float accel = Utils.Clamp(-(Counter - 36), 4, 20); - Projectile.velocity = (Projectile.velocity * (accel - 1) + distanceToTargetVector) / accel; - Projectile.rotation = Projectile.velocity.X * 0.05f; - return false; - } - return true; - } - - protected override bool Bobbing() - { - if (AI_STATE == STATE_CHARGE) - { - sinY = 0; - return false; - } - return true; - } - - protected override void CustomAI() - { - //Main.NewText("State: " + AI_STATE); - //Main.NewText("Counter: " + Counter); - //Main.NewText("Opacity: " + ChargeTimer); - //Main.NewText("Color: " + OverlayColor); - - #region Handle State - if (AI_STATE == STATE_COOLDOWN) - { - if (Counter > AttackCooldown) - { - Counter = 0; - //Main.NewText("Change from cooldown to idle"); - AI_STATE = STATE_IDLE; - if (RealOwner) Projectile.netUpdate = true; - } - //else stay in cooldown and wait for counter to reach - } - else if (AI_STATE == STATE_IDLE) - { - if (Counter > SearchDelay) - { - Counter = 0; - int targetIndex = FindClosestHorizontalTarget(); - if (targetIndex != -1) - { - PosInCharge = (byte)GetChargePosition(); - //Main.NewText("Change from idle to charge"); - AI_STATE = STATE_CHARGE; - if (RealOwner) Projectile.netUpdate = true; - } - //else stay in idle until target found - } - } - else if (AI_STATE == STATE_RECOIL) - { - if (Counter > RecoilDuration) - { - Counter = 0; - AI_STATE = STATE_COOLDOWN; - } - } - #endregion - - Counter += Main.rand.Next(1, AI_STATE != STATE_IDLE ? 2 : 3); - - if (AI_STATE == STATE_CHARGE) - { - int targetIndex = FindClosestHorizontalTarget(); - - Projectile.spriteDirection = Projectile.direction = -Direction; - - if (Counter <= ChargeDelay) - { - //if lose target - if (RealOwner && targetIndex == -1) - { - //Counter = 0; - //Main.NewText("Change from charge to idle cuz no target"); - AI_STATE = STATE_IDLE; - Projectile.netUpdate = true; - } - - float ratio = Counter / (float)ChargeDelay; - float otherRatio = 1f - ratio; - - //make sound - if (Projectile.soundDelay <= 0) - { - //TODO find some better sound to use - Projectile.soundDelay = 20; - float volume = FixVolume(0.7f + ratio * 0.5f); - float pitch = -0.1f + ratio * 0.4f; - SoundEngine.PlaySound(SoundID.Item, (int)Projectile.Center.X, (int)Projectile.Center.Y, SoundID.Item15.Style, volume, pitch); - //Main.PlaySound(SoundID.Item15.WithVolume(0.7f + (Counter / (float)ChargeDelay) * 0.5f), projectile.position); - //Main.NewText("volume : " + (0.7f + volumeCounter * 0.1f)); - } - - //spawn dust - for (int i = 0; i < 3; i++) - { - if (Main.rand.NextFloat() < ratio) - { - int dustType = 60; - //if facing left: + Direction * 48 - int height = (int)(9 * otherRatio) + 4; - Rectangle rect = new Rectangle((int)BarrelPos.X + Direction * (Direction == 1 ? 16 : 48), (int)BarrelPos.Y - height, 32, 2 * height); - Dust d = Dust.NewDustDirect(rect.TopLeft(), rect.Width, rect.Height, dustType); - d.noGravity = true; - d.velocity.X *= 0.75f; - d.velocity.Y *= (d.position.Y > rect.Center().Y).ToDirectionInt(); //y velocity goes "inwards" - d.velocity *= 3 * otherRatio; - } - } - } - else - { - if (RealOwner) - { - Counter = 0; - if (targetIndex != -1 && !Collision.SolidCollision(BarrelPos, 1, 1)) - { - Vector2 velocity = Main.npc[targetIndex].Center - BarrelPos; - velocity.Normalize(); - velocity *= 10f; - Projectile.velocity += -velocity * 0.75f; //recoil - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), BarrelPos, velocity, ModContent.ProjectileType(), CustomDmg, CustomKB, Main.myPlayer, 0f, 0f); - - AI_STATE = STATE_RECOIL; - ChargeTimer = byte.MaxValue; - Projectile.netUpdate = true; - } - if (targetIndex == -1) - { - //Main.NewText("Change from charge to idle"); - AI_STATE = STATE_IDLE; - Projectile.netUpdate = true; - } - } - } - } - - if (AI_STATE == STATE_CHARGE) - { - IncreaseCharge(); - } - else - { - DecreaseCharge(); - - if (CanOverlay && Main.rand.NextFloat() < OverlayOpacity * 0.5f) - { - Gore gore = Gore.NewGorePerfect(BarrelPos + new Vector2(Direction == 1 ? -8f : -Projectile.width - 4f, Direction == 1 ? -14f : -16f), Vector2.Zero, Main.rand.Next(61, 64)); - gore.position.X += Main.rand.NextFloat(8); - gore.scale *= 0.18f; - gore.velocity *= 0.6f; - } - } - - if (AI_STATE == STATE_RECOIL) - { - if (overheatSound == null && !playedOverheatSound) - { - float volume = FixVolume(1.5f); - overheatSound = SoundEngine.PlaySound(SoundID.Trackable, (int)Projectile.position.X, (int)Projectile.position.Y, 224, volume, 0.1f); - playedOverheatSound = true; - } - } - else - { - playedOverheatSound = false; - } - - if (overheatSound != null) - { - float f = 0.008f * Main.soundVolume; - if (overheatSound.Volume > f) - { - overheatSound.Volume -= f; - if (overheatSound.Volume < f) - { - overheatSound.Stop(); - } - } - if (overheatSound.State == SoundState.Stopped) - { - overheatSound = null; - } - } - } - - public static float FixVolume(float volume) - { - return Main.soundVolume * volume > 1 ? Main.soundVolume / volume : volume; - } - - private int FindClosestHorizontalTarget() - { - Player player = Projectile.GetOwner(); - int targetIndex = -1; - float distanceFromTarget = 100000f; - Vector2 targetCenter = player.Center; - float margin = 200; - int range = 1000; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - if (npc.CanBeChasedBy(Projectile)) - { - float between = Vector2.Distance(npc.Center, player.Center); - if (((between < range && - Vector2.Distance(player.Center, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1) && - Collision.CanHitLine(player.Center, 1, 1, npc.position, npc.width, npc.height)) - { - distanceFromTarget = between; - targetCenter = npc.Center; - targetIndex = k; - } - } - } - Direction = (targetCenter.X - player.Center.X > 0f).ToDirectionInt(); - float betweenY = targetCenter.Y - player.Top.Y; //bigger margin upwards - //Main.NewText("betweenY: " + betweenY); - return (Math.Abs(betweenY) < margin && distanceFromTarget < range) ? targetIndex : -1; - } - - /// - /// Called before switching to STATE_CHARGE. Returns the minionPos for the laser charge - /// - private int GetChargePosition() - { - int pos = 0; - int min = Main.maxProjectiles; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.owner == Projectile.owner && proj.ModProjectile is HeavyLaserDrone h) - { - if (h.AI_STATE == STATE_CHARGE) - { - byte projPos = h.PosInCharge; - min = Math.Min(min, projPos); - if (projPos > pos) pos = projPos; - } - //also works on itself but since AI_STATE is only switched to STATE_CHARGE AFTER this gets called it doesn't have an effect - } - } - if (min > 0) return 0; - - return pos + 1; - } - } + /// + /// Fires a penetrating laser beam horizontally to the player with a very long delay. + /// Only recognizes enemies at around the y level of the player + /// + public class HeavyLaserDrone : DroneBase + { + private static readonly string nameGlow = "Projectiles/Minions/Drones/" + "HeavyLaserDrone_Glowmask"; + private static readonly string nameOverlay = "Projectiles/Minions/Drones/" + "HeavyLaserDrone_Overlay"; + + private const int AttackCooldown = 180; + private const int RecoilDuration = 60; + private const int SearchDelay = 90; //60 but incremented 1.5f + private const int ChargeDelay = 120; + private const int AnimationDuration = 32; + private const int AnimationFrameTime = 8; + + private const byte STATE_COOLDOWN = 0; + private const byte STATE_IDLE = 1; + private const byte STATE_CHARGE = 2; + private const byte STATE_RECOIL = 3; + + private byte AI_STATE = 0; + private byte PosInCharge = 0; + private int Direction = -1; + private float InitialDistance = 0; + + private Vector2 BarrelPos + { + get + { + Vector2 position = Projectile.Bottom; + position.Y += sinY; + return position; + } + } + + #region overlay + private int ChargeTimer = 0; + + private bool CanOverlay => ChargeTimer >= AnimationDuration && (Projectile.frame == 3 || Projectile.frame == 7); + + private float OverlayOpacity => (ChargeTimer - AnimationDuration) / (float)byte.MaxValue; + + private bool playedOverheatSound = false; + + private SoundEffectInstance overheatSound = null; + + private void IncreaseCharge() + { + if (ChargeTimer < byte.MaxValue) ChargeTimer++; + } + + private void DecreaseCharge() + { + if (ChargeTimer > 0) ChargeTimer--; + } + #endregion + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heavy Laser Drone"); + Main.projFrames[Projectile.type] = 8; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 38; + Projectile.height = 30; + Projectile.alpha = 0; + Projectile.DamageType = DamageClass.Summon; + Projectile.minion = true; + Projectile.minionSlots = 1f; + } + + public override void SendExtraAI(BinaryWriter writer) + { + base.SendExtraAI(writer); + writer.Write((byte)AI_STATE); + writer.Write((byte)PosInCharge); + writer.Write((byte)ChargeTimer); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + base.ReceiveExtraAI(reader); + AI_STATE = reader.ReadByte(); + PosInCharge = reader.ReadByte(); + ChargeTimer = (int)reader.ReadByte(); + } + + protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) + { + if (AI_STATE == STATE_CHARGE) + { + if (ChargeTimer < AnimationDuration) + { + Projectile.frame = ChargeTimer / AnimationFrameTime; + } + else + { + Projectile.frame = 3; + } + } + else + { + if (ChargeTimer <= 0) + { + Projectile.frame = 0; + } + else if (ChargeTimer < AnimationDuration) + { + Projectile.frame = 4 + ChargeTimer / AnimationFrameTime; + } + else + { + Projectile.frame = 7; + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 8f) + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); + + image = Mod.Assets.Request(nameGlow).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); + + if (CanOverlay) + { + image = Mod.Assets.Request(nameOverlay).Value; + Main.EntitySpriteDraw(image, drawPos, image.Bounds, Color.White * OverlayOpacity, Projectile.rotation, drawOrigin, 1f, effects, 0); + } + + return false; + } + + protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) + { + dmgModifier = 1.1f; + kbModifier = 1.1f; + + if (AI_STATE == STATE_COOLDOWN) + { + Counter += Main.rand.Next(2); + } + } + + protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) + { + if (AI_STATE == STATE_CHARGE) + { + //offset x = 30 when facing right + offsetX = Direction == 1 ? -80 : 20; + offsetX += Math.Sign(offsetX) * PosInCharge * Projectile.width * 1.5f; + offsetY = 10; + veloSpeed = 0.5f; + } + else if (AI_STATE == STATE_RECOIL) + { + //150 to 50 is smooth, distance + Vector2 pos = new Vector2(offsetX, offsetY) - new Vector2(-30, 20); + //veloSpeed = (float)Math.Pow((double)Counter / AttackCooldown, 2) + 0.05f; + Vector2 distanceToTargetVector = (pos + Projectile.GetOwner().Center) - Projectile.Center; + float distanceToTarget = distanceToTargetVector.Length(); + if (Counter == 0) InitialDistance = distanceToTarget; + //Main.NewText("proper: " + distanceToTargetVector.Length()); + float magnitude = 1f + distanceToTargetVector.LengthSquared() / (InitialDistance * InitialDistance); + distanceToTargetVector.Normalize(); + distanceToTargetVector *= magnitude; + //-(Counter - AttackCooldown / 5) -> goes from 36 to 0 + float accel = Utils.Clamp(-(Counter - 36), 4, 20); + Projectile.velocity = (Projectile.velocity * (accel - 1) + distanceToTargetVector) / accel; + Projectile.rotation = Projectile.velocity.X * 0.05f; + return false; + } + return true; + } + + protected override bool Bobbing() + { + if (AI_STATE == STATE_CHARGE) + { + sinY = 0; + return false; + } + return true; + } + + protected override void CustomAI() + { + //Main.NewText("State: " + AI_STATE); + //Main.NewText("Counter: " + Counter); + //Main.NewText("Opacity: " + ChargeTimer); + //Main.NewText("Color: " + OverlayColor); + + #region Handle State + if (AI_STATE == STATE_COOLDOWN) + { + if (Counter > AttackCooldown) + { + Counter = 0; + //Main.NewText("Change from cooldown to idle"); + AI_STATE = STATE_IDLE; + if (RealOwner) Projectile.netUpdate = true; + } + //else stay in cooldown and wait for counter to reach + } + else if (AI_STATE == STATE_IDLE) + { + if (Counter > SearchDelay) + { + Counter = 0; + int targetIndex = FindClosestHorizontalTarget(); + if (targetIndex != -1) + { + PosInCharge = (byte)GetChargePosition(); + //Main.NewText("Change from idle to charge"); + AI_STATE = STATE_CHARGE; + if (RealOwner) Projectile.netUpdate = true; + } + //else stay in idle until target found + } + } + else if (AI_STATE == STATE_RECOIL) + { + if (Counter > RecoilDuration) + { + Counter = 0; + AI_STATE = STATE_COOLDOWN; + } + } + #endregion + + Counter += Main.rand.Next(1, AI_STATE != STATE_IDLE ? 2 : 3); + + if (AI_STATE == STATE_CHARGE) + { + int targetIndex = FindClosestHorizontalTarget(); + + Projectile.spriteDirection = Projectile.direction = -Direction; + + if (Counter <= ChargeDelay) + { + //if lose target + if (RealOwner && targetIndex == -1) + { + //Counter = 0; + //Main.NewText("Change from charge to idle cuz no target"); + AI_STATE = STATE_IDLE; + Projectile.netUpdate = true; + } + + float ratio = Counter / (float)ChargeDelay; + float otherRatio = 1f - ratio; + + //make sound + if (Projectile.soundDelay <= 0) + { + //TODO find some better sound to use + Projectile.soundDelay = 20; + float volume = FixVolume(0.7f + ratio * 0.5f); + float pitch = -0.1f + ratio * 0.4f; + SoundEngine.PlaySound(SoundID.Item, (int)Projectile.Center.X, (int)Projectile.Center.Y, SoundID.Item15.Style, volume, pitch); + //Main.PlaySound(SoundID.Item15.WithVolume(0.7f + (Counter / (float)ChargeDelay) * 0.5f), projectile.position); + //Main.NewText("volume : " + (0.7f + volumeCounter * 0.1f)); + } + + //spawn dust + for (int i = 0; i < 3; i++) + { + if (Main.rand.NextFloat() < ratio) + { + int dustType = 60; + //if facing left: + Direction * 48 + int height = (int)(9 * otherRatio) + 4; + Rectangle rect = new Rectangle((int)BarrelPos.X + Direction * (Direction == 1 ? 16 : 48), (int)BarrelPos.Y - height, 32, 2 * height); + Dust d = Dust.NewDustDirect(rect.TopLeft(), rect.Width, rect.Height, dustType); + d.noGravity = true; + d.velocity.X *= 0.75f; + d.velocity.Y *= (d.position.Y > rect.Center().Y).ToDirectionInt(); //y velocity goes "inwards" + d.velocity *= 3 * otherRatio; + } + } + } + else + { + if (RealOwner) + { + Counter = 0; + if (targetIndex != -1 && !Collision.SolidCollision(BarrelPos, 1, 1)) + { + Vector2 velocity = Main.npc[targetIndex].Center - BarrelPos; + velocity.Normalize(); + velocity *= 10f; + Projectile.velocity += -velocity * 0.75f; //recoil + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), BarrelPos, velocity, ModContent.ProjectileType(), CustomDmg, CustomKB, Main.myPlayer, 0f, 0f); + + AI_STATE = STATE_RECOIL; + ChargeTimer = byte.MaxValue; + Projectile.netUpdate = true; + } + if (targetIndex == -1) + { + //Main.NewText("Change from charge to idle"); + AI_STATE = STATE_IDLE; + Projectile.netUpdate = true; + } + } + } + } + + if (AI_STATE == STATE_CHARGE) + { + IncreaseCharge(); + } + else + { + DecreaseCharge(); + + if (CanOverlay && Main.rand.NextFloat() < OverlayOpacity * 0.5f) + { + Gore gore = Gore.NewGorePerfect(BarrelPos + new Vector2(Direction == 1 ? -8f : -Projectile.width - 4f, Direction == 1 ? -14f : -16f), Vector2.Zero, Main.rand.Next(61, 64)); + gore.position.X += Main.rand.NextFloat(8); + gore.scale *= 0.18f; + gore.velocity *= 0.6f; + } + } + + if (AI_STATE == STATE_RECOIL) + { + if (overheatSound == null && !playedOverheatSound) + { + float volume = FixVolume(1.5f); + overheatSound = SoundEngine.PlaySound(SoundID.Trackable, (int)Projectile.position.X, (int)Projectile.position.Y, 224, volume, 0.1f); + playedOverheatSound = true; + } + } + else + { + playedOverheatSound = false; + } + + if (overheatSound != null) + { + float f = 0.008f * Main.soundVolume; + if (overheatSound.Volume > f) + { + overheatSound.Volume -= f; + if (overheatSound.Volume < f) + { + overheatSound.Stop(); + } + } + if (overheatSound.State == SoundState.Stopped) + { + overheatSound = null; + } + } + } + + public static float FixVolume(float volume) + { + return Main.soundVolume * volume > 1 ? Main.soundVolume / volume : volume; + } + + private int FindClosestHorizontalTarget() + { + Player player = Projectile.GetOwner(); + int targetIndex = -1; + float distanceFromTarget = 100000f; + Vector2 targetCenter = player.Center; + float margin = 200; + int range = 1000; + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + if (npc.CanBeChasedBy(Projectile)) + { + float between = Vector2.Distance(npc.Center, player.Center); + if (((between < range && + Vector2.Distance(player.Center, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1) && + Collision.CanHitLine(player.Center, 1, 1, npc.position, npc.width, npc.height)) + { + distanceFromTarget = between; + targetCenter = npc.Center; + targetIndex = k; + } + } + } + Direction = (targetCenter.X - player.Center.X > 0f).ToDirectionInt(); + float betweenY = targetCenter.Y - player.Top.Y; //bigger margin upwards + //Main.NewText("betweenY: " + betweenY); + return (Math.Abs(betweenY) < margin && distanceFromTarget < range) ? targetIndex : -1; + } + + /// + /// Called before switching to STATE_CHARGE. Returns the minionPos for the laser charge + /// + private int GetChargePosition() + { + int pos = 0; + int min = Main.maxProjectiles; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.owner == Projectile.owner && proj.ModProjectile is HeavyLaserDrone h) + { + if (h.AI_STATE == STATE_CHARGE) + { + byte projPos = h.PosInCharge; + min = Math.Min(min, projPos); + if (projPos > pos) pos = projPos; + } + //also works on itself but since AI_STATE is only switched to STATE_CHARGE AFTER this gets called it doesn't have an effect + } + } + if (min > 0) return 0; + + return pos + 1; + } + } } diff --git a/Projectiles/Minions/Drones/HeavyLaserDroneLaser.cs b/Projectiles/Minions/Drones/HeavyLaserDroneLaser.cs index 38371637..a1d8893a 100644 --- a/Projectiles/Minions/Drones/HeavyLaserDroneLaser.cs +++ b/Projectiles/Minions/Drones/HeavyLaserDroneLaser.cs @@ -1,72 +1,72 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.Projectiles.Minions.Drones { - [Content(ContentType.Weapons)] - public class HeavyLaserDroneLaser : AssProjectile - { - //shot with magnitude 6 - private static readonly int LifeTime = 100; + [Content(ContentType.Weapons)] + public class HeavyLaserDroneLaser : AssProjectile + { + //shot with magnitude 6 + private static readonly int LifeTime = 100; - public override string Texture - { - get - { - return "AssortedCrazyThings/Empty"; - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/Empty"; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Laser Drone Laser"); - ProjectileID.Sets.MinionShot[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Laser Drone Laser"); + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.width = 8; - Projectile.height = 8; - Projectile.timeLeft = LifeTime; - Projectile.extraUpdates = LifeTime; - Projectile.hide = true; - Projectile.friendly = true; - Projectile.hostile = false; - Projectile.alpha = 255; //might not be needed - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.aiStyle = -1; - Projectile.DamageType = DamageClass.Summon; + public override void SetDefaults() + { + Projectile.width = 8; + Projectile.height = 8; + Projectile.timeLeft = LifeTime; + Projectile.extraUpdates = LifeTime; + Projectile.hide = true; + Projectile.friendly = true; + Projectile.hostile = false; + Projectile.alpha = 255; //might not be needed + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.aiStyle = -1; + Projectile.DamageType = DamageClass.Summon; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; - } + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + } - public override void AI() - { - if (Projectile.localAI[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item67, Projectile.position); //67, 94 - //75 for a weak laser - } - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 3f) - { - for (int i = 0; i < 4; i++) //3 - { - Vector2 pos = Projectile.position; - pos -= Projectile.velocity * (i * 0.25f); //0.3333 - int type = 60; //173 - Dust dust = Dust.NewDustDirect(pos, Projectile.width, Projectile.height, type, 0f, 0f, 0, default(Color), 1f); - //dust.position = pos; - dust.noGravity = true; - dust.scale = Main.rand.Next(70, 110) * 0.015f; - dust.velocity *= 0.2f; - } - } - } - } + public override void AI() + { + if (Projectile.localAI[0] == 0f) + { + SoundEngine.PlaySound(SoundID.Item67, Projectile.position); //67, 94 + //75 for a weak laser + } + Projectile.localAI[0] += 1f; + if (Projectile.localAI[0] > 3f) + { + for (int i = 0; i < 4; i++) //3 + { + Vector2 pos = Projectile.position; + pos -= Projectile.velocity * (i * 0.25f); //0.3333 + int type = 60; //173 + Dust dust = Dust.NewDustDirect(pos, Projectile.width, Projectile.height, type, 0f, 0f, 0, default(Color), 1f); + //dust.position = pos; + dust.noGravity = true; + dust.scale = Main.rand.Next(70, 110) * 0.015f; + dust.velocity *= 0.2f; + } + } + } + } } diff --git a/Projectiles/Minions/Drones/MissileDrone.cs b/Projectiles/Minions/Drones/MissileDrone.cs index 49b6bb9c..20509803 100644 --- a/Projectiles/Minions/Drones/MissileDrone.cs +++ b/Projectiles/Minions/Drones/MissileDrone.cs @@ -8,200 +8,200 @@ namespace AssortedCrazyThings.Projectiles.Minions.Drones { - /// - /// Fires a salvo of homing rockets with a long delay - /// - public class MissileDrone : DroneBase - { - private static readonly string nameGlow = "Projectiles/Minions/Drones/" + "MissileDrone_Glowmask"; - - public const int AttackCooldown = 360; //120 but incremented by 1.5f - public const int AttackDelay = 60; - public const int AttackDuration = 60; - - //in cooldown: lamps turn on in order for "charge up" - - private const byte STATE_COOLDOWN = 0; - private const byte STATE_IDLE = 1; - private const byte STATE_FIRING = 2; - - private byte AI_STATE = 0; - private int RocketNumber = 0; - - private Vector2 ShootOrigin - { - get - { - Vector2 position = Projectile.Top; - position.Y += sinY + 2f; - return position; - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Missile Drone"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 38; - Projectile.height = 30; - Projectile.alpha = 0; - Projectile.DamageType = DamageClass.Summon; - Projectile.minion = true; - Projectile.minionSlots = 1f; - } - - public override void SendExtraAI(BinaryWriter writer) - { - base.SendExtraAI(writer); - writer.Write((byte)AI_STATE); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - base.ReceiveExtraAI(reader); - AI_STATE = reader.ReadByte(); - } - - protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) - { - if (AI_STATE == STATE_FIRING) - { - if (RocketNumber > 0) - { - Projectile.frame = 3; - } - else - { - Projectile.frame = 2; - } - } - else if (AI_STATE == STATE_COOLDOWN) - { - Projectile.frame = 1; - } - else - { - Projectile.frame = 0; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 8f) + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); - - image = Mod.Assets.Request(nameGlow).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); - - return false; - } - - protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) - { - dmgModifier = 1.1f; - kbModifier = 1.1f; - - if (AI_STATE == STATE_COOLDOWN) - { - Counter += Main.rand.Next(2); - } - } - - protected override void CustomAI() - { - Player player = Projectile.GetOwner(); - //Main.NewText("##"); - //Main.NewText(AI_STATE); - - #region Handle State - if (AI_STATE == STATE_COOLDOWN) - { - if (Counter > AttackCooldown) - { - Counter = 0; - //Main.NewText("Change from cooldown to idle"); - AI_STATE = STATE_IDLE; - if (RealOwner) Projectile.netUpdate = true; - } - //else stay in cooldown and wait for counter to reach - } - else if (AI_STATE == STATE_IDLE) - { - if (Counter > AttackDelay) - { - Counter = 0; - int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 900); - if (targetIndex != -1) - { - Vector2 aboveCheck = new Vector2(0, -16 * 8); - if (Collision.CanHitLine(ShootOrigin, 1, 1, ShootOrigin + aboveCheck, 1, 1) && - Collision.CanHitLine(ShootOrigin + aboveCheck, 1, 1, ShootOrigin + aboveCheck + new Vector2(-16 * 5, 0), 1, 1) && - Collision.CanHitLine(ShootOrigin + aboveCheck, 1, 1, ShootOrigin + aboveCheck + new Vector2(16 * 5, 0), 1, 1)) - { - //Main.NewText("Change from idle to firing"); - AI_STATE = STATE_FIRING; - if (RealOwner) Projectile.netUpdate = true; - } - } - //else stay in idle until target found - } - } - else if (AI_STATE == STATE_FIRING) - { - if (Counter > AttackDuration) - { - Counter = 0; - RocketNumber = 0; - AI_STATE = STATE_COOLDOWN; - //no sync since this counts down automatically after STATE_FIRING - } - } - #endregion - - if (AI_STATE == STATE_FIRING) - { - int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 900); - - if (targetIndex != -1) - { - Projectile.direction = Projectile.spriteDirection = -(Main.npc[targetIndex].Center.X - player.Center.X > 0f).ToDirectionInt(); - if (RealOwner) - { - int firerate = AttackDelay / 4; - RocketNumber = Counter / firerate; - if (Counter % firerate == 0 && RocketNumber > 0 && RocketNumber < 4) - { - if (!Collision.SolidCollision(ShootOrigin, 1, 1)) - { - //Main.NewText(Counter); - Vector2 velocity = new Vector2(Main.rand.NextFloat(-1f, 1f) - Projectile.direction * 0.5f, -5); - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), ShootOrigin, velocity, ModContent.ProjectileType(), CustomDmg, CustomKB, Main.myPlayer); - Projectile.velocity.Y += 2f; - Projectile.netUpdate = true; - } - } - } - } - } - - Counter += Main.rand.Next(1, AI_STATE != STATE_IDLE ? 2 : 3); - } - } + /// + /// Fires a salvo of homing rockets with a long delay + /// + public class MissileDrone : DroneBase + { + private static readonly string nameGlow = "Projectiles/Minions/Drones/" + "MissileDrone_Glowmask"; + + public const int AttackCooldown = 360; //120 but incremented by 1.5f + public const int AttackDelay = 60; + public const int AttackDuration = 60; + + //in cooldown: lamps turn on in order for "charge up" + + private const byte STATE_COOLDOWN = 0; + private const byte STATE_IDLE = 1; + private const byte STATE_FIRING = 2; + + private byte AI_STATE = 0; + private int RocketNumber = 0; + + private Vector2 ShootOrigin + { + get + { + Vector2 position = Projectile.Top; + position.Y += sinY + 2f; + return position; + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Missile Drone"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 38; + Projectile.height = 30; + Projectile.alpha = 0; + Projectile.DamageType = DamageClass.Summon; + Projectile.minion = true; + Projectile.minionSlots = 1f; + } + + public override void SendExtraAI(BinaryWriter writer) + { + base.SendExtraAI(writer); + writer.Write((byte)AI_STATE); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + base.ReceiveExtraAI(reader); + AI_STATE = reader.ReadByte(); + } + + protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) + { + if (AI_STATE == STATE_FIRING) + { + if (RocketNumber > 0) + { + Projectile.frame = 3; + } + else + { + Projectile.frame = 2; + } + } + else if (AI_STATE == STATE_COOLDOWN) + { + Projectile.frame = 1; + } + else + { + Projectile.frame = 0; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 8f) + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); + + image = Mod.Assets.Request(nameGlow).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); + + return false; + } + + protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) + { + dmgModifier = 1.1f; + kbModifier = 1.1f; + + if (AI_STATE == STATE_COOLDOWN) + { + Counter += Main.rand.Next(2); + } + } + + protected override void CustomAI() + { + Player player = Projectile.GetOwner(); + //Main.NewText("##"); + //Main.NewText(AI_STATE); + + #region Handle State + if (AI_STATE == STATE_COOLDOWN) + { + if (Counter > AttackCooldown) + { + Counter = 0; + //Main.NewText("Change from cooldown to idle"); + AI_STATE = STATE_IDLE; + if (RealOwner) Projectile.netUpdate = true; + } + //else stay in cooldown and wait for counter to reach + } + else if (AI_STATE == STATE_IDLE) + { + if (Counter > AttackDelay) + { + Counter = 0; + int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 900); + if (targetIndex != -1) + { + Vector2 aboveCheck = new Vector2(0, -16 * 8); + if (Collision.CanHitLine(ShootOrigin, 1, 1, ShootOrigin + aboveCheck, 1, 1) && + Collision.CanHitLine(ShootOrigin + aboveCheck, 1, 1, ShootOrigin + aboveCheck + new Vector2(-16 * 5, 0), 1, 1) && + Collision.CanHitLine(ShootOrigin + aboveCheck, 1, 1, ShootOrigin + aboveCheck + new Vector2(16 * 5, 0), 1, 1)) + { + //Main.NewText("Change from idle to firing"); + AI_STATE = STATE_FIRING; + if (RealOwner) Projectile.netUpdate = true; + } + } + //else stay in idle until target found + } + } + else if (AI_STATE == STATE_FIRING) + { + if (Counter > AttackDuration) + { + Counter = 0; + RocketNumber = 0; + AI_STATE = STATE_COOLDOWN; + //no sync since this counts down automatically after STATE_FIRING + } + } + #endregion + + if (AI_STATE == STATE_FIRING) + { + int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 900); + + if (targetIndex != -1) + { + Projectile.direction = Projectile.spriteDirection = -(Main.npc[targetIndex].Center.X - player.Center.X > 0f).ToDirectionInt(); + if (RealOwner) + { + int firerate = AttackDelay / 4; + RocketNumber = Counter / firerate; + if (Counter % firerate == 0 && RocketNumber > 0 && RocketNumber < 4) + { + if (!Collision.SolidCollision(ShootOrigin, 1, 1)) + { + //Main.NewText(Counter); + Vector2 velocity = new Vector2(Main.rand.NextFloat(-1f, 1f) - Projectile.direction * 0.5f, -5); + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), ShootOrigin, velocity, ModContent.ProjectileType(), CustomDmg, CustomKB, Main.myPlayer); + Projectile.velocity.Y += 2f; + Projectile.netUpdate = true; + } + } + } + } + } + + Counter += Main.rand.Next(1, AI_STATE != STATE_IDLE ? 2 : 3); + } + } } diff --git a/Projectiles/Minions/Drones/MissileDroneRocket.cs b/Projectiles/Minions/Drones/MissileDroneRocket.cs index 4388d4c7..4341c4db 100644 --- a/Projectiles/Minions/Drones/MissileDroneRocket.cs +++ b/Projectiles/Minions/Drones/MissileDroneRocket.cs @@ -2,237 +2,237 @@ using Microsoft.Xna.Framework; using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.Projectiles.Minions.Drones { - [Content(ContentType.Weapons)] - public class MissileDroneRocket : AssProjectile - { - private bool justCollided = false; - private bool inflatedHitbox = false; - private const int inflationAmount = 80; + [Content(ContentType.Weapons)] + public class MissileDroneRocket : AssProjectile + { + private bool justCollided = false; + private bool inflatedHitbox = false; + private const int inflationAmount = 80; - public override string Texture - { - get - { - return "Terraria/Images/Projectile_" + ProjectileID.RocketIII; - } - } + public override string Texture + { + get + { + return "Terraria/Images/Projectile_" + ProjectileID.RocketIII; + } + } - public int FirstTarget - { - get - { - return (int)Projectile.localAI[1] - 1; - } - set - { - Projectile.localAI[1] = value + 1; - } - } + public int FirstTarget + { + get + { + return (int)Projectile.localAI[1] - 1; + } + set + { + Projectile.localAI[1] = value + 1; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Missile Drone Rocket"); - ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; - ProjectileID.Sets.MinionShot[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Missile Drone Rocket"); + ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } - public override void SetDefaults() - { - //projectile.CloneDefaults(ProjectileID.RocketIII); - Projectile.width = 14; - Projectile.height = 14; - Projectile.aiStyle = -1; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.timeLeft = 240; - Projectile.DamageType = DamageClass.Summon; + public override void SetDefaults() + { + //projectile.CloneDefaults(ProjectileID.RocketIII); + Projectile.width = 14; + Projectile.height = 14; + Projectile.aiStyle = -1; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 240; + Projectile.DamageType = DamageClass.Summon; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; - } + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + } - public override void Kill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - Projectile.position.X = Projectile.position.X + Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y + Projectile.height / 2; - Projectile.width = inflationAmount; - Projectile.height = inflationAmount; - Projectile.position.X = Projectile.position.X - Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; - for (int i = 0; i < 10; i++) //40 - { - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default(Color), 2f); - dust.velocity *= 2f; //3f - if (Main.rand.NextBool(2)) - { - dust.scale = 0.5f; - dust.fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int i = 0; i < 17; i++) //70 - { - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 3f); - dust.noGravity = true; - dust.velocity *= 4f; //5f - dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 2f); - dust.velocity *= 2f; - } - for (int i = 0; i < 2; i++) //3 - { - float scaleFactor10 = 0.33f; - if (i == 1) - { - scaleFactor10 = 0.66f; - } - if (i == 2) - { - scaleFactor10 = 1f; - } - Gore gore = Main.gore[Gore.NewGore(new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; - gore.velocity *= scaleFactor10; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - gore = Main.gore[Gore.NewGore(new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; - gore.velocity *= scaleFactor10; - gore.velocity.X += -1f; - gore.velocity.Y += 1f; - gore = Main.gore[Gore.NewGore(new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; - gore.velocity *= scaleFactor10; - gore.velocity.X += 1f; - gore.velocity.Y += -1f; - gore = Main.gore[Gore.NewGore(new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; - gore.velocity *= scaleFactor10; - gore.velocity.X += -1f; - gore.velocity.Y += -1f; - } - Projectile.position.X = Projectile.position.X + Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y + Projectile.height / 2; - Projectile.width = 10; - Projectile.height = 10; - Projectile.position.X = Projectile.position.X - Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; - } + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.Item14, Projectile.position); + Projectile.position.X = Projectile.position.X + Projectile.width / 2; + Projectile.position.Y = Projectile.position.Y + Projectile.height / 2; + Projectile.width = inflationAmount; + Projectile.height = inflationAmount; + Projectile.position.X = Projectile.position.X - Projectile.width / 2; + Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; + for (int i = 0; i < 10; i++) //40 + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default(Color), 2f); + dust.velocity *= 2f; //3f + if (Main.rand.NextBool(2)) + { + dust.scale = 0.5f; + dust.fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int i = 0; i < 17; i++) //70 + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 3f); + dust.noGravity = true; + dust.velocity *= 4f; //5f + dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 2f); + dust.velocity *= 2f; + } + for (int i = 0; i < 2; i++) //3 + { + float scaleFactor10 = 0.33f; + if (i == 1) + { + scaleFactor10 = 0.66f; + } + if (i == 2) + { + scaleFactor10 = 1f; + } + Gore gore = Main.gore[Gore.NewGore(new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X += 1f; + gore.velocity.Y += 1f; + gore = Main.gore[Gore.NewGore(new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X += -1f; + gore.velocity.Y += 1f; + gore = Main.gore[Gore.NewGore(new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X += 1f; + gore.velocity.Y += -1f; + gore = Main.gore[Gore.NewGore(new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X += -1f; + gore.velocity.Y += -1f; + } + Projectile.position.X = Projectile.position.X + Projectile.width / 2; + Projectile.position.Y = Projectile.position.Y + Projectile.height / 2; + Projectile.width = 10; + Projectile.height = 10; + Projectile.position.X = Projectile.position.X - Projectile.width / 2; + Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - if (!inflatedHitbox) justCollided = true; - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + if (!inflatedHitbox) justCollided = true; + return false; + } - //kind of a useless hack but I couldn't work out how vanilla makes the hitbox increase on tile collide - public override void ModifyDamageHitbox(ref Rectangle hitbox) - { - if (justCollided) - { - justCollided = false; - inflatedHitbox = true; - hitbox.Inflate(inflationAmount / 2, inflationAmount / 2); - Projectile.timeLeft = 3; - } - } + //kind of a useless hack but I couldn't work out how vanilla makes the hitbox increase on tile collide + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + if (justCollided) + { + justCollided = false; + inflatedHitbox = true; + hitbox.Inflate(inflationAmount / 2, inflationAmount / 2); + Projectile.timeLeft = 3; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (Projectile.timeLeft > 3) - { - Projectile.timeLeft = 3; - } - Projectile.direction = (target.Center.X < Projectile.Center.X).ToDirectionInt(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (Projectile.timeLeft > 3) + { + Projectile.timeLeft = 3; + } + Projectile.direction = (target.Center.X < Projectile.Center.X).ToDirectionInt(); + } - public override void AI() - { - if (Projectile.localAI[0] == 0) - { - SoundEngine.PlaySound(SoundID.Item66, Projectile.Center); //62, 66, 82, 88 - Projectile.localAI[0]++; - } - if (Projectile.owner == Main.myPlayer && Projectile.timeLeft <= 3) - { - Projectile.tileCollide = false; - Projectile.ai[1] = 0f; - Projectile.alpha = 255; + public override void AI() + { + if (Projectile.localAI[0] == 0) + { + SoundEngine.PlaySound(SoundID.Item66, Projectile.Center); //62, 66, 82, 88 + Projectile.localAI[0]++; + } + if (Projectile.owner == Main.myPlayer && Projectile.timeLeft <= 3) + { + Projectile.tileCollide = false; + Projectile.ai[1] = 0f; + Projectile.alpha = 255; - Projectile.position.X = Projectile.position.X + Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y + Projectile.height / 2; - Projectile.width = inflationAmount; - Projectile.height = inflationAmount; - Projectile.position.X = Projectile.position.X - Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; - Projectile.knockBack = 8f; - } - else - { - //8f - if (Projectile.ai[0] > 60 || Projectile.localAI[0] < 11) - { - Projectile.localAI[0]++; - for (int i = 0; i < 2; i++) - { - float xOff = 0f; - float yOff = 0f; - if (i == 1) - { - xOff = Projectile.velocity.X * 0.5f; - yOff = Projectile.velocity.Y * 0.5f; - } - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X + 3f + xOff, Projectile.position.Y + 3f + yOff) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default(Color), 1f); - dust.scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - dust.velocity *= 0.2f; - dust.noGravity = true; - dust = Dust.NewDustDirect(new Vector2(Projectile.position.X + 3f + xOff, Projectile.position.Y + 3f + yOff) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default(Color), 0.5f); - dust.fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - dust.velocity *= 0.05f; - } - } + Projectile.position.X = Projectile.position.X + Projectile.width / 2; + Projectile.position.Y = Projectile.position.Y + Projectile.height / 2; + Projectile.width = inflationAmount; + Projectile.height = inflationAmount; + Projectile.position.X = Projectile.position.X - Projectile.width / 2; + Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; + Projectile.knockBack = 8f; + } + else + { + //8f + if (Projectile.ai[0] > 60 || Projectile.localAI[0] < 11) + { + Projectile.localAI[0]++; + for (int i = 0; i < 2; i++) + { + float xOff = 0f; + float yOff = 0f; + if (i == 1) + { + xOff = Projectile.velocity.X * 0.5f; + yOff = Projectile.velocity.Y * 0.5f; + } + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X + 3f + xOff, Projectile.position.Y + 3f + yOff) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 6, 0f, 0f, 100, default(Color), 1f); + dust.scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + dust.velocity *= 0.2f; + dust.noGravity = true; + dust = Dust.NewDustDirect(new Vector2(Projectile.position.X + 3f + xOff, Projectile.position.Y + 3f + yOff) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, 31, 0f, 0f, 100, default(Color), 0.5f); + dust.fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + dust.velocity *= 0.05f; + } + } - #region Find Target - int targetIndex; - if (Projectile.ai[0] > 60) - { - targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 1200, ignoreTiles: true); - if (targetIndex != -1) - { - if (FirstTarget == -1) FirstTarget = targetIndex; - //only home in on the first target it finds - //(assuming during the rocket longevity there won't be another NPC spawning in distance with the same index) - if (FirstTarget == targetIndex) - { - Vector2 velocity = Main.npc[targetIndex].Center + Main.npc[targetIndex].velocity * 5f - Projectile.Center; - velocity.Normalize(); - velocity *= 6f; - //for that nice initial curving - //accel starts at 30, then goes down to 4 - float accel = Utils.Clamp(-(Projectile.ai[0] - 90), 4, 30); - Projectile.velocity = (Projectile.velocity * (accel - 1) + velocity) / accel; - } - } - } - else - { - Projectile.velocity.Y += 0.1f; //0.015f; - } - #endregion + #region Find Target + int targetIndex; + if (Projectile.ai[0] > 60) + { + targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 1200, ignoreTiles: true); + if (targetIndex != -1) + { + if (FirstTarget == -1) FirstTarget = targetIndex; + //only home in on the first target it finds + //(assuming during the rocket longevity there won't be another NPC spawning in distance with the same index) + if (FirstTarget == targetIndex) + { + Vector2 velocity = Main.npc[targetIndex].Center + Main.npc[targetIndex].velocity * 5f - Projectile.Center; + velocity.Normalize(); + velocity *= 6f; + //for that nice initial curving + //accel starts at 30, then goes down to 4 + float accel = Utils.Clamp(-(Projectile.ai[0] - 90), 4, 30); + Projectile.velocity = (Projectile.velocity * (accel - 1) + velocity) / accel; + } + } + } + else + { + Projectile.velocity.Y += 0.1f; //0.015f; + } + #endregion - //speedup - if (Math.Abs(Projectile.velocity.X) < 15f && Math.Abs(Projectile.velocity.Y) < 15f) - { - if (Projectile.ai[0] > 60) - { - Projectile.velocity *= 1.1f; - } - } - } - Projectile.ai[0] += 1f; - Projectile.rotation = Projectile.velocity.ToRotation() + 1.57f; - } - } + //speedup + if (Math.Abs(Projectile.velocity.X) < 15f && Math.Abs(Projectile.velocity.Y) < 15f) + { + if (Projectile.ai[0] > 60) + { + Projectile.velocity *= 1.1f; + } + } + } + Projectile.ai[0] += 1f; + Projectile.rotation = Projectile.velocity.ToRotation() + 1.57f; + } + } } diff --git a/Projectiles/Minions/Drones/ShieldDrone.cs b/Projectiles/Minions/Drones/ShieldDrone.cs index 97b90cf4..ad148092 100644 --- a/Projectiles/Minions/Drones/ShieldDrone.cs +++ b/Projectiles/Minions/Drones/ShieldDrone.cs @@ -7,218 +7,218 @@ namespace AssortedCrazyThings.Projectiles.Minions.Drones { - /// - /// Creates a damage reducing shield - /// Checks if its active for the player in AssPlayer.PreUpdate, then resets shield - /// - public class ShieldDrone : DroneBase - { - private static readonly string nameLamps = "Projectiles/Minions/Drones/" + "ShieldDrone_Lamps"; - private static readonly string nameLower = "Projectiles/Minions/Drones/" + "ShieldDrone_Lower"; - private float addRotation; //same - private const int ShieldDelay = 360; - private float LowerOutPercent = 0f; - - private float ShieldCounter - { - get - { - return Projectile.ai[0]; - } - set - { - Projectile.ai[0] = value; - } - } - - private bool CanShield - { - get - { - AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - return mPlayer.shieldDroneReduction < AssPlayer.shieldDroneReductionMax && LowerOutPercent == 1f; - } - } - - private int Stage - { - get - { - AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - return mPlayer.shieldDroneReduction / AssPlayer.ShieldIncreaseAmount; - } - } - - public override bool IsCombatDrone - { - get - { - return false; - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shield Drone"); - Main.projFrames[Projectile.type] = 6; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 34; - Projectile.height = 30; - Projectile.alpha = 0; - Projectile.minion = true; - Projectile.minionSlots = 1f; - } - - protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) - { - Projectile.frame = Stage; - - float intensity = 700f - 25f * Projectile.frame; - Vector2 lightPos = Projectile.Top + new Vector2(0f, sinY); - Vector3 lightCol = default; - if (Projectile.frame == 5) - { - lightCol = new Vector3(124, 251, 34); - } - else if (Projectile.frame > 2) - { - lightCol = new Vector3(200, 150, 0f); - } - else if (Projectile.frame > 0) - { - lightCol = new Vector3(153, 63, 66); - } - Lighting.AddLight(lightPos, lightCol / intensity); - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = Mod.Assets.Request(nameLower).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - - if (LowerOutPercent > 0f) - { - //Vector2 rotationOffset = new Vector2(0f, -16 + LowerOutPercent * 16); - Vector2 rotationOffset = new Vector2(0f, 16 * (LowerOutPercent - 1f)); - - //rotation origin is (projectile.position + stupidOffset) - drawOrigin; //not including Main.screenPosition - Main.EntitySpriteDraw(image, drawPos + rotationOffset, bounds, lightColor, addRotation, drawOrigin, 1f, effects, 0); - } - - image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); - - image = Mod.Assets.Request(nameLamps).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); - - - return false; - } - - protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) - { - if (CanShield) ShieldCounter += 0.333f; - } - - protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) - { - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, staticDirection: true, vanityPet: true, veloXToRotationFactor: 0.5f, offsetX: -30f, offsetY: -50f); - return false; - } - - protected override void CustomAI() - { - Player player = Projectile.GetOwner(); - AssPlayer mPlayer = player.GetModPlayer(); - - if (CanShield) - { - Vector2 shootOffset = new Vector2(0, sinY); - Vector2 shootOrigin = Projectile.Center + shootOffset; - Vector2 target = player.MountedCenter + new Vector2(0f, -5f); - - Vector2 between = target - shootOrigin; - shootOrigin += Vector2.Normalize(between) * 19f; //roughly tip of turret - target += -Vector2.Normalize(between) * 12f; //roughly center of head with a buffer - - float rotationAmount = between.ToRotation(); - - if (Projectile.spriteDirection == 1) //adjust rotation based on direction - { - rotationAmount -= MathHelper.PiOver2; - if (rotationAmount > MathHelper.TwoPi) - { - rotationAmount = -rotationAmount; - } - } - - bool canShoot = shootOrigin.Y < target.Y + player.height / 2; - - if (Projectile.spriteDirection == -1) //reset canShoot properly if rotation is too much (aka target is too fast for the drone to catch up) - { - if (rotationAmount <= Projectile.rotation) - { - canShoot = false; - rotationAmount = Projectile.rotation; - } - } - else - { - if (rotationAmount <= Projectile.rotation - MathHelper.Pi) - { - canShoot = false; - rotationAmount = Projectile.rotation; - } - } - addRotation = addRotation.AngleLerp(rotationAmount, 0.1f); - - if (canShoot) //when target below drone - { - ShieldCounter++; - - if (ShieldCounter > ShieldDelay) - { - ShieldCounter = 0; - if (RealOwner) mPlayer.shieldDroneReduction += AssPlayer.ShieldIncreaseAmount; - CombatText.NewText(player.getRect(), Color.LightBlue, AssPlayer.ShieldIncreaseAmount); - AssUtils.QuickDustLine(16, shootOrigin, target, between.Length() / 3, Color.White, alpha: 120, scale: 1.5f); - } - } - } - else //if fully shielded, addRotation should go down to projectile.rotation - { - addRotation = addRotation.AngleLerp(Projectile.rotation, 0.1f); - } - - if (Stage < 5) - { - if (LowerOutPercent < 1f) - { - LowerOutPercent += 0.015f; - if (LowerOutPercent > 1f) LowerOutPercent = 1f; - } - } - else - { - if (LowerOutPercent > 0f) - { - LowerOutPercent -= 0.015f; - if (LowerOutPercent < 0f) LowerOutPercent = 0f; - } - } - } - } + /// + /// Creates a damage reducing shield + /// Checks if its active for the player in AssPlayer.PreUpdate, then resets shield + /// + public class ShieldDrone : DroneBase + { + private static readonly string nameLamps = "Projectiles/Minions/Drones/" + "ShieldDrone_Lamps"; + private static readonly string nameLower = "Projectiles/Minions/Drones/" + "ShieldDrone_Lower"; + private float addRotation; //same + private const int ShieldDelay = 360; + private float LowerOutPercent = 0f; + + private float ShieldCounter + { + get + { + return Projectile.ai[0]; + } + set + { + Projectile.ai[0] = value; + } + } + + private bool CanShield + { + get + { + AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + return mPlayer.shieldDroneReduction < AssPlayer.shieldDroneReductionMax && LowerOutPercent == 1f; + } + } + + private int Stage + { + get + { + AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + return mPlayer.shieldDroneReduction / AssPlayer.ShieldIncreaseAmount; + } + } + + public override bool IsCombatDrone + { + get + { + return false; + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shield Drone"); + Main.projFrames[Projectile.type] = 6; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 34; + Projectile.height = 30; + Projectile.alpha = 0; + Projectile.minion = true; + Projectile.minionSlots = 1f; + } + + protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) + { + Projectile.frame = Stage; + + float intensity = 700f - 25f * Projectile.frame; + Vector2 lightPos = Projectile.Top + new Vector2(0f, sinY); + Vector3 lightCol = default; + if (Projectile.frame == 5) + { + lightCol = new Vector3(124, 251, 34); + } + else if (Projectile.frame > 2) + { + lightCol = new Vector3(200, 150, 0f); + } + else if (Projectile.frame > 0) + { + lightCol = new Vector3(153, 63, 66); + } + Lighting.AddLight(lightPos, lightCol / intensity); + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = Mod.Assets.Request(nameLower).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + + if (LowerOutPercent > 0f) + { + //Vector2 rotationOffset = new Vector2(0f, -16 + LowerOutPercent * 16); + Vector2 rotationOffset = new Vector2(0f, 16 * (LowerOutPercent - 1f)); + + //rotation origin is (projectile.position + stupidOffset) - drawOrigin; //not including Main.screenPosition + Main.EntitySpriteDraw(image, drawPos + rotationOffset, bounds, lightColor, addRotation, drawOrigin, 1f, effects, 0); + } + + image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); + + image = Mod.Assets.Request(nameLamps).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); + + + return false; + } + + protected override void ModifyDroneControllerHeld(ref float dmgModifier, ref float kbModifier) + { + if (CanShield) ShieldCounter += 0.333f; + } + + protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) + { + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, staticDirection: true, vanityPet: true, veloXToRotationFactor: 0.5f, offsetX: -30f, offsetY: -50f); + return false; + } + + protected override void CustomAI() + { + Player player = Projectile.GetOwner(); + AssPlayer mPlayer = player.GetModPlayer(); + + if (CanShield) + { + Vector2 shootOffset = new Vector2(0, sinY); + Vector2 shootOrigin = Projectile.Center + shootOffset; + Vector2 target = player.MountedCenter + new Vector2(0f, -5f); + + Vector2 between = target - shootOrigin; + shootOrigin += Vector2.Normalize(between) * 19f; //roughly tip of turret + target += -Vector2.Normalize(between) * 12f; //roughly center of head with a buffer + + float rotationAmount = between.ToRotation(); + + if (Projectile.spriteDirection == 1) //adjust rotation based on direction + { + rotationAmount -= MathHelper.PiOver2; + if (rotationAmount > MathHelper.TwoPi) + { + rotationAmount = -rotationAmount; + } + } + + bool canShoot = shootOrigin.Y < target.Y + player.height / 2; + + if (Projectile.spriteDirection == -1) //reset canShoot properly if rotation is too much (aka target is too fast for the drone to catch up) + { + if (rotationAmount <= Projectile.rotation) + { + canShoot = false; + rotationAmount = Projectile.rotation; + } + } + else + { + if (rotationAmount <= Projectile.rotation - MathHelper.Pi) + { + canShoot = false; + rotationAmount = Projectile.rotation; + } + } + addRotation = addRotation.AngleLerp(rotationAmount, 0.1f); + + if (canShoot) //when target below drone + { + ShieldCounter++; + + if (ShieldCounter > ShieldDelay) + { + ShieldCounter = 0; + if (RealOwner) mPlayer.shieldDroneReduction += AssPlayer.ShieldIncreaseAmount; + CombatText.NewText(player.getRect(), Color.LightBlue, AssPlayer.ShieldIncreaseAmount); + AssUtils.QuickDustLine(16, shootOrigin, target, between.Length() / 3, Color.White, alpha: 120, scale: 1.5f); + } + } + } + else //if fully shielded, addRotation should go down to projectile.rotation + { + addRotation = addRotation.AngleLerp(Projectile.rotation, 0.1f); + } + + if (Stage < 5) + { + if (LowerOutPercent < 1f) + { + LowerOutPercent += 0.015f; + if (LowerOutPercent > 1f) LowerOutPercent = 1f; + } + } + else + { + if (LowerOutPercent > 0f) + { + LowerOutPercent -= 0.015f; + if (LowerOutPercent < 0f) LowerOutPercent = 0f; + } + } + } + } } diff --git a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingDarts.cs b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingDarts.cs index b0a85777..337007ca 100644 --- a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingDarts.cs +++ b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingDarts.cs @@ -1,124 +1,124 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.Projectiles.Minions.GoblinUnderling { - [Content(ContentType.Weapons)] - public abstract class GoblinUnderlingDart : AssProjectile - { - public const float Gravity = 0.1f; - public const int TicksWithoutGravity = 15; - - public bool Spawned - { - get => Projectile.localAI[0] == 1f; - set => Projectile.localAI[0] = value ? 1 : 0; - } - - public int Timer - { - get => (int)Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Goblin Underling Dart"); - Main.projFrames[Projectile.type] = 1; - ProjectileID.Sets.MinionShot[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.WoodenArrowFriendly); - Projectile.aiStyle = -1; - Projectile.height = 12; - Projectile.width = 12; - Projectile.penetrate = 1; - Projectile.tileCollide = true; - Projectile.friendly = true; - Projectile.hostile = false; - Projectile.DamageType = DamageClass.Summon; - Projectile.timeLeft = 180; - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - return true; - } - - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - GoblinUnderlingSystem.CommonModifyHitNPC(Projectile, target, ref damage, ref knockback, ref hitDirection); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - foreach (var proj in GoblinUnderlingSystem.GetLocalGoblinUnderlings()) - { - if (proj.ModProjectile is GoblinUnderlingProj goblin) - { - if (!target.boss && goblin.OutOfCombat()) - { - GoblinUnderlingSystem.TryCreate(proj, GoblinUnderlingMessageSource.Attacking); - } - - goblin.SetInCombat(); - } - } - } - - public override void AI() - { - if (!Spawned) - { - Spawned = true; - - SoundEngine.PlaySound(SoundID.Item, (int)Projectile.Center.X, (int)Projectile.Center.Y, 1); - } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - - Timer++; - if (Timer >= TicksWithoutGravity) - { - Projectile.velocity.Y += Gravity; - if (Projectile.velocity.Y > 16f) - { - Projectile.velocity.Y = 16f; - } - } - - Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X <= 0).ToDirectionInt(); - } - } - - public class GoblinUnderlingDart_0 : GoblinUnderlingDart - { - - } - - public class GoblinUnderlingDart_1 : GoblinUnderlingDart - { - - } - - public class GoblinUnderlingDart_2 : GoblinUnderlingDart - { - - } - - public class GoblinUnderlingDart_3 : GoblinUnderlingDart - { - - } - - public class GoblinUnderlingDart_4 : GoblinUnderlingDart - { - - } + [Content(ContentType.Weapons)] + public abstract class GoblinUnderlingDart : AssProjectile + { + public const float Gravity = 0.1f; + public const int TicksWithoutGravity = 15; + + public bool Spawned + { + get => Projectile.localAI[0] == 1f; + set => Projectile.localAI[0] = value ? 1 : 0; + } + + public int Timer + { + get => (int)Projectile.ai[0]; + set => Projectile.ai[0] = value; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Goblin Underling Dart"); + Main.projFrames[Projectile.type] = 1; + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.WoodenArrowFriendly); + Projectile.aiStyle = -1; + Projectile.height = 12; + Projectile.width = 12; + Projectile.penetrate = 1; + Projectile.tileCollide = true; + Projectile.friendly = true; + Projectile.hostile = false; + Projectile.DamageType = DamageClass.Summon; + Projectile.timeLeft = 180; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + return true; + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + GoblinUnderlingSystem.CommonModifyHitNPC(Projectile, target, ref damage, ref knockback, ref hitDirection); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + foreach (var proj in GoblinUnderlingSystem.GetLocalGoblinUnderlings()) + { + if (proj.ModProjectile is GoblinUnderlingProj goblin) + { + if (!target.boss && goblin.OutOfCombat()) + { + GoblinUnderlingSystem.TryCreate(proj, GoblinUnderlingMessageSource.Attacking); + } + + goblin.SetInCombat(); + } + } + } + + public override void AI() + { + if (!Spawned) + { + Spawned = true; + + SoundEngine.PlaySound(SoundID.Item, (int)Projectile.Center.X, (int)Projectile.Center.Y, 1); + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + Timer++; + if (Timer >= TicksWithoutGravity) + { + Projectile.velocity.Y += Gravity; + if (Projectile.velocity.Y > 16f) + { + Projectile.velocity.Y = 16f; + } + } + + Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X <= 0).ToDirectionInt(); + } + } + + public class GoblinUnderlingDart_0 : GoblinUnderlingDart + { + + } + + public class GoblinUnderlingDart_1 : GoblinUnderlingDart + { + + } + + public class GoblinUnderlingDart_2 : GoblinUnderlingDart + { + + } + + public class GoblinUnderlingDart_3 : GoblinUnderlingDart + { + + } + + public class GoblinUnderlingDart_4 : GoblinUnderlingDart + { + + } } diff --git a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingGlobalNPC.cs b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingGlobalNPC.cs index dd8c901a..6efad31e 100644 --- a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingGlobalNPC.cs +++ b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingGlobalNPC.cs @@ -5,7 +5,7 @@ namespace AssortedCrazyThings.Projectiles.Minions.GoblinUnderling [Content(ContentType.Weapons)] public class GoblinUnderlingGlobalNPC : AssGlobalNPC { - public override void OnHitPlayer(NPC npc, Player target, int damage, bool crit) + public override void OnHitPlayer(NPC npc, Player target, int damage, bool crit) { if (target.whoAmI != Main.myPlayer) { diff --git a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingGlobalProjectile.cs b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingGlobalProjectile.cs index 0a34d8be..19852199 100644 --- a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingGlobalProjectile.cs +++ b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingGlobalProjectile.cs @@ -18,9 +18,9 @@ public override void OnHitPlayer(Projectile projectile, Player target, int damag } if (damage < target.statLifeMax2 * 0.2f) - { + { return; - } + } foreach (var proj in GoblinUnderlingSystem.GetLocalGoblinUnderlings()) { diff --git a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingPlayer.cs b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingPlayer.cs index e6082060..c72185c3 100644 --- a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingPlayer.cs +++ b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingPlayer.cs @@ -16,29 +16,29 @@ public class GoblinUnderlingPlayer : AssPlayerBase public bool firstSummon = true; - public override void Load() - { - On.Terraria.Player.Spawn += OnSpawnSummonGoblinUnderling; - } + public override void Load() + { + On.Terraria.Player.Spawn += OnSpawnSummonGoblinUnderling; + } - private static void OnSpawnSummonGoblinUnderling(On.Terraria.Player.orig_Spawn orig, Player player, PlayerSpawnContext context) - { + private static void OnSpawnSummonGoblinUnderling(On.Terraria.Player.orig_Spawn orig, Player player, PlayerSpawnContext context) + { orig(player, context); if (player.whoAmI == Main.myPlayer && context == PlayerSpawnContext.ReviveFromDeath || context == PlayerSpawnContext.SpawningIntoWorld) - { + { if (!ClientConfig.Instance.SatchelofGoodiesAutosummon) - { + { return; - } + } int index = player.FindItem(ModContent.ItemType()); if (index != -1) { Item item = player.inventory[index]; - int projType = item.shoot; - if (player.ownedProjectileCounts[projType] > 0) + int projType = item.shoot; + if (player.ownedProjectileCounts[projType] > 0) { //Mostly failsafe, but if minion still alive, kill it, to avoid duplicate for (int i = 0; i < Main.maxProjectiles; i++) @@ -60,7 +60,7 @@ private static void OnSpawnSummonGoblinUnderling(On.Terraria.Player.orig_Spawn o } } - public override void ResetEffects() + public override void ResetEffects() { prevHasValhallaArmorVisual = hasValhallaArmorVisual; hasValhallaArmorVisual = false; @@ -68,27 +68,27 @@ public override void ResetEffects() hasMinion = false; } - public override void OnEnterWorld(Player player) - { + public override void OnEnterWorld(Player player) + { GoblinUnderlingSystem.OnEnterWorld(player); } - public override void LoadData(TagCompound tag) - { + public override void LoadData(TagCompound tag) + { firstSummon = tag.GetBool("firstSummon"); - } + } - public override void SaveData(TagCompound tag) - { + public override void SaveData(TagCompound tag) + { tag.Set("firstSummon", firstSummon); - } + } - public override void UpdateVisibleVanityAccessories() + public override void UpdateVisibleVanityAccessories() { if (Main.myPlayer != Player.whoAmI) - { + { return; - } + } hasValhallaArmorVisual = Player.head == 210 && Player.body == 204 && Player.legs == 152; @@ -100,5 +100,5 @@ public override void UpdateVisibleVanityAccessories() } } } - } + } } diff --git a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingProj.cs b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingProj.cs index 1f158907..f9f14f4a 100644 --- a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingProj.cs +++ b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingProj.cs @@ -1,53 +1,53 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; using AssortedCrazyThings.Base; +using AssortedCrazyThings.Base.Handlers.UnreplaceableMinionWith0SlotsHandler; using Microsoft.Xna.Framework; -using System; using Microsoft.Xna.Framework.Graphics; -using AssortedCrazyThings.Base.Handlers.UnreplaceableMinionWith0SlotsHandler; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Minions.GoblinUnderling { - [Content(ContentType.Weapons)] - public class GoblinUnderlingProj : AssProjectile + [Content(ContentType.Weapons)] + public class GoblinUnderlingProj : AssProjectile { public const float Gravity = 0.4f; public const int StuckTimerMax = 3 * 60; public int stuckTimer = 0; - public int afkTimer = 0; + public int afkTimer = 0; - public int InCombatTimerMax = 5 * 60; - public int inCombatTimer = 0; + public int InCombatTimerMax = 5 * 60; + public int inCombatTimer = 0; public const int WeaponFrameCount = 4; - public override string Texture => "AssortedCrazyThings/Projectiles/Minions/GoblinUnderling/GoblinUnderlingProj_0"; + public override string Texture => "AssortedCrazyThings/Projectiles/Minions/GoblinUnderling/GoblinUnderlingProj_0"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Goblin Underling"); - Main.projFrames[Projectile.type] = 20; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Goblin Underling"); + Main.projFrames[Projectile.type] = 20; //Main.projPet[Projectile.type] = true; //Causes it do disappear on left/right clicks since MinionSacrificable is not set ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true; //ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; //Causes other minions to despawn on use - ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; + ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; UnreplaceableMinionWith0SlotsSystem.Add(Projectile.type); } - public override void SetDefaults() - { - Projectile.width = 24; - Projectile.height = 40; + public override void SetDefaults() + { + Projectile.width = 24; + Projectile.height = 40; - Projectile.aiStyle = -1; - Projectile.DamageType = DamageClass.Summon; + Projectile.aiStyle = -1; + Projectile.DamageType = DamageClass.Summon; Projectile.netImportant = true; - Projectile.minion = true; - Projectile.minionSlots = 0; //Multiple caveats with this + Projectile.minion = true; + Projectile.minionSlots = 0; //Multiple caveats with this Projectile.penetrate = -1; Projectile.timeLeft *= 5; Projectile.decidesManualFallThrough = true; @@ -55,17 +55,17 @@ public override void SetDefaults() Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 18; //Facilitates attack 5 * 4 duration (default pirates), dynamic in AI - } + } - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { - //No Main.projPet[Projectile.type] = true, so manually do the tile collision + //No Main.projPet[Projectile.type] = true, so manually do the tile collision Projectile.velocity = Collision.TileCollision(Projectile.position, Projectile.velocity, width, height, fallThrough, fallThrough); - return false; - } + return false; + } - public override bool ShouldUpdatePosition() + public override bool ShouldUpdatePosition() { //No Main.projPet[Projectile.type] = true, so manually do the slope collision and updating Vector2 velocity = Projectile.velocity; @@ -80,18 +80,18 @@ public override bool ShouldUpdatePosition() Projectile.position += velocity; if (Projectile.tileCollide) - { - Vector4 vector = Collision.SlopeCollision(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height, 0f, false); + { + Vector4 vector = Collision.SlopeCollision(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height, 0f, false); Projectile.position.X = vector.X; Projectile.position.Y = vector.Y; Projectile.velocity.X = vector.Z; Projectile.velocity.Y = vector.W; - } + } - return false; - } + return false; + } - public override bool OnTileCollide(Vector2 oldVelocity) + public override bool OnTileCollide(Vector2 oldVelocity) { //No Main.projPet[Projectile.type] = true, so manually prevent death on tile collision return false; @@ -99,18 +99,18 @@ public override bool OnTileCollide(Vector2 oldVelocity) public override bool PreDraw(ref Color lightColor) { - //Custom draw to just center on the hitbox - var tier = GoblinUnderlingSystem.GetCurrentTier(); - int texIndex = tier.texIndex; - Texture2D texture; - if (Main.myPlayer == Projectile.owner && !ClientConfig.Instance.SatchelofGoodiesVisibleArmor) - { - texture = GoblinUnderlingSystem.bodyAssets[0].Value; - } - else - { - texture = GoblinUnderlingSystem.bodyAssets[texIndex].Value; - } + //Custom draw to just center on the hitbox + var tier = GoblinUnderlingSystem.GetCurrentTier(); + int texIndex = tier.texIndex; + Texture2D texture; + if (Main.myPlayer == Projectile.owner && !ClientConfig.Instance.SatchelofGoodiesVisibleArmor) + { + texture = GoblinUnderlingSystem.bodyAssets[0].Value; + } + else + { + texture = GoblinUnderlingSystem.bodyAssets[texIndex].Value; + } Rectangle sourceRect = texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); Vector2 drawOrigin = sourceRect.Size() / 2f; @@ -119,13 +119,13 @@ public override bool PreDraw(ref Color lightColor) Vector2 drawPos = Projectile.position + Projectile.Size / 2f + new Vector2(0, Projectile.gfxOffY + 4f - 1f) - Main.screenPosition; Color color = lightColor; - float rotation = Projectile.rotation; - float scale = Projectile.scale; + float rotation = Projectile.rotation; + float scale = Projectile.scale; //No minion coloring, so use manual draw - Main.spriteBatch.Draw(texture, drawPos, sourceRect, color, rotation, drawOrigin, scale, spriteEffects, 0); + Main.spriteBatch.Draw(texture, drawPos, sourceRect, color, rotation, drawOrigin, scale, spriteEffects, 0); if (MeleeAttacking || RangedAttacking && tier.showMeleeDuringRanged) - { + { texture = GoblinUnderlingSystem.weaponAssets[texIndex].Value; sourceRect = texture.Frame(1, WeaponFrameCount, 0, AttackFrameNumber); drawOrigin = sourceRect.Size() / 2f; @@ -135,42 +135,42 @@ public override bool PreDraw(ref Color lightColor) return false; } - public override void ModifyDamageHitbox(ref Rectangle hitbox) - { - //Save original coordinates - int centerX = hitbox.Center.X; - int bottomY = hitbox.Bottom; + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + //Save original coordinates + int centerX = hitbox.Center.X; + int bottomY = hitbox.Bottom; - int increase = GoblinUnderlingSystem.GetCurrentTier().meleeAttackHitboxIncrease; - hitbox.Inflate(increase, increase / 2); //Top shouldn't grow as much, as its only going to grow upwards + int increase = GoblinUnderlingSystem.GetCurrentTier().meleeAttackHitboxIncrease; + hitbox.Inflate(increase, increase / 2); //Top shouldn't grow as much, as its only going to grow upwards - //Restore coordinates - hitbox.Y = bottomY - hitbox.Height; - hitbox.X = centerX - hitbox.Width / 2; - } + //Restore coordinates + hitbox.Y = bottomY - hitbox.Height; + hitbox.X = centerX - hitbox.Width / 2; + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - GoblinUnderlingSystem.CommonModifyHitNPC(Projectile, target, ref damage, ref knockback, ref hitDirection); - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + GoblinUnderlingSystem.CommonModifyHitNPC(Projectile, target, ref damage, ref knockback, ref hitDirection); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (!target.boss && OutOfCombat()) - { - GoblinUnderlingSystem.TryCreate(Projectile, GoblinUnderlingMessageSource.Attacking); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (!target.boss && OutOfCombat()) + { + GoblinUnderlingSystem.TryCreate(Projectile, GoblinUnderlingMessageSource.Attacking); + } - SetInCombat(); - } + SetInCombat(); + } - public override bool MinionContactDamage() - { - return true; - } + public override bool MinionContactDamage() + { + return true; + } public int State - { + { get => (int)Projectile.ai[0]; set => Projectile.ai[0] = value; } @@ -184,7 +184,7 @@ public int Timer public bool IdleOrMoving => State == 0; public bool Flying - { + { get => State == 1; set => State = value ? 1 : 0; } @@ -207,7 +207,7 @@ public bool GeneralAttacking set { if (!value) - { + { //Only allow false to disable attack State = 0; } @@ -221,174 +221,174 @@ public int AttackFrameNumber } public override bool PreAI() - { - Player player = Projectile.GetOwner(); - GoblinUnderlingPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.hasMinion = false; - } - if (modPlayer.hasMinion) - { - Projectile.timeLeft = 2; - } - - //Has to be in PreAI so that damage works in AI properly - SetScaledDamage(player); - - return true; - } - - public override void AI() + { + Player player = Projectile.GetOwner(); + GoblinUnderlingPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.hasMinion = false; + } + if (modPlayer.hasMinion) + { + Projectile.timeLeft = 2; + } + + //Has to be in PreAI so that damage works in AI properly + SetScaledDamage(player); + + return true; + } + + public override void AI() { Player player = Projectile.GetOwner(); - SetFrame(); //Has to be before due to velocity checks + SetFrame(); //Has to be before due to velocity checks UnderlingAI(player, out Vector2 idleLocation); DoIdleMessage(player, idleLocation); - HandleCombatState(); - - Projectile.localNPCHitCooldown = GetNextTimerValue(WeaponFrameCount) - 2; - } - - public void SetInCombat() - { - inCombatTimer = InCombatTimerMax; - - GoblinUnderlingSystem.PutMessageTypeOnCooldown(GoblinUnderlingMessageSource.Idle); - } - - public bool OutOfCombat() - { - return inCombatTimer == 0; - } - - private void HandleCombatState() - { - if (inCombatTimer > 0) - { - inCombatTimer--; - } - } - - private void SetScaledDamage(Player player) - { - var tier = GoblinUnderlingSystem.GetCurrentTier(); - - //Copied scaling from vanilla, but summoner is adjusted by our scaling - int originalDamage = Projectile.originalDamage; - StatModifier summoner = player.GetDamage(DamageClass.Summon); - - StatModifier tieredSummoner = summoner.CombineWith(new StatModifier(1f, tier.damageMult)); //Modification - - StatModifier allDamage = player.GetDamage(DamageClass.Generic); - - Projectile.damage = (int)allDamage.CombineWith(tieredSummoner).ApplyTo(originalDamage); - } - - private Vector2 GetIdleLocation(Player player) - { - //Projectile will align on the right side of the default location - Vector2 defaultLocation = player.Center; - int distIdle = 48; - int offset = Projectile.width / 2; - defaultLocation.X -= (player.width / 2) * player.direction; - if (player.direction == 1) - { - defaultLocation.X -= distIdle; - } - else if (player.direction == -1) - { - defaultLocation.X += distIdle + offset; - } - - //Check the tiles between default and player center, starting from default, for walkable tiles 5 tiles down - //If any are found, change defaultLocation.X to that coordinate, and return that. Otherwise, set location to the player center aswell - - //dir == 1 -> g___p> - //dir == -1 -> = startX && x <= endX) || (dir == -1 && x >= endX && x <= startX); x += dir) - { - for (int y = startY; y <= endY; y++) - { - //If atleast one of the tiles below the position are active and walkable - if (WorldGen.InWorld(x, y) && WorldGen.ActiveAndWalkableTile(x, y)) - { - defaultLocation.X = x * 16 + 8; - if (dir == 1) - { - defaultLocation.X += offset; //Quirk with how it always wants to align "right of" the location - } - return defaultLocation; - } - } - //scanX++; - } - - return player.Center; - } + HandleCombatState(); + + Projectile.localNPCHitCooldown = GetNextTimerValue(WeaponFrameCount) - 2; + } + + public void SetInCombat() + { + inCombatTimer = InCombatTimerMax; + + GoblinUnderlingSystem.PutMessageTypeOnCooldown(GoblinUnderlingMessageSource.Idle); + } + + public bool OutOfCombat() + { + return inCombatTimer == 0; + } + + private void HandleCombatState() + { + if (inCombatTimer > 0) + { + inCombatTimer--; + } + } + + private void SetScaledDamage(Player player) + { + var tier = GoblinUnderlingSystem.GetCurrentTier(); + + //Copied scaling from vanilla, but summoner is adjusted by our scaling + int originalDamage = Projectile.originalDamage; + StatModifier summoner = player.GetDamage(DamageClass.Summon); + + StatModifier tieredSummoner = summoner.CombineWith(new StatModifier(1f, tier.damageMult)); //Modification + + StatModifier allDamage = player.GetDamage(DamageClass.Generic); + + Projectile.damage = (int)allDamage.CombineWith(tieredSummoner).ApplyTo(originalDamage); + } + + private Vector2 GetIdleLocation(Player player) + { + //Projectile will align on the right side of the default location + Vector2 defaultLocation = player.Center; + int distIdle = 48; + int offset = Projectile.width / 2; + defaultLocation.X -= (player.width / 2) * player.direction; + if (player.direction == 1) + { + defaultLocation.X -= distIdle; + } + else if (player.direction == -1) + { + defaultLocation.X += distIdle + offset; + } + + //Check the tiles between default and player center, starting from default, for walkable tiles 5 tiles down + //If any are found, change defaultLocation.X to that coordinate, and return that. Otherwise, set location to the player center aswell + + //dir == 1 -> g___p> + //dir == -1 -> = startX && x <= endX) || (dir == -1 && x >= endX && x <= startX); x += dir) + { + for (int y = startY; y <= endY; y++) + { + //If atleast one of the tiles below the position are active and walkable + if (WorldGen.InWorld(x, y) && WorldGen.ActiveAndWalkableTile(x, y)) + { + defaultLocation.X = x * 16 + 8; + if (dir == 1) + { + defaultLocation.X += offset; //Quirk with how it always wants to align "right of" the location + } + return defaultLocation; + } + } + //scanX++; + } + + return player.Center; + } private void DoIdleMessage(Player player, Vector2 idleLocation) { if (Main.myPlayer != player.whoAmI) - { + { + return; + } + + var modPlayer = player.GetModPlayer(); + if (modPlayer.firstSummon) + { + if (GoblinUnderlingSystem.TryCreate(Projectile, GoblinUnderlingMessageSource.FirstSummon)) + { + modPlayer.firstSummon = false; + + return; + } + } + + if (Projectile.velocity.X == 0f && Projectile.oldVelocity.X == 0f && + Projectile.oldVelocity.Y == 0f) + { + afkTimer++; + } + else if (afkTimer > 0) + { + afkTimer -= 2; + } + + float distX = Math.Abs(idleLocation.X - Projectile.Center.X); + float distY = Math.Abs(idleLocation.Y - Projectile.Center.Y); + + if (!(!GeneralAttacking && !Flying && + afkTimer > 4 * 60 && + player.afkCounter > 4 * 60 && distX < 50 && distY < 32)) + { return; - } - - var modPlayer = player.GetModPlayer(); - if (modPlayer.firstSummon) - { - if (GoblinUnderlingSystem.TryCreate(Projectile, GoblinUnderlingMessageSource.FirstSummon)) - { - modPlayer.firstSummon = false; - - return; - } - } - - if (Projectile.velocity.X == 0f && Projectile.oldVelocity.X == 0f && - Projectile.oldVelocity.Y == 0f) - { - afkTimer++; - } - else if (afkTimer > 0) - { - afkTimer -= 2; - } - - float distX = Math.Abs(idleLocation.X - Projectile.Center.X); - float distY = Math.Abs(idleLocation.Y - Projectile.Center.Y); - - if (!(!GeneralAttacking && !Flying && - afkTimer > 4 * 60 && - player.afkCounter > 4 * 60 && distX < 50 && distY < 32)) - { - return; } - GoblinUnderlingSystem.TryCreate(Projectile, GoblinUnderlingMessageSource.Idle); - } + GoblinUnderlingSystem.TryCreate(Projectile, GoblinUnderlingMessageSource.Idle); + } private int GetNextTimerValue(int attackFrameCount) - { - GoblinUnderlingTier tier = GoblinUnderlingSystem.GetCurrentTier(); - int time = tier.meleeAttackInterval; + { + GoblinUnderlingTier tier = GoblinUnderlingSystem.GetCurrentTier(); + int time = tier.meleeAttackInterval; if (RangedAttacking) { - float ranged = tier.rangedAttackIntervalMultiplier * time * attackFrameCount; - return (int)ranged; + float ranged = tier.rangedAttackIntervalMultiplier * time * attackFrameCount; + return (int)ranged; } else { @@ -397,657 +397,657 @@ private int GetNextTimerValue(int attackFrameCount) } } - private void UnderlingAI(Player player, out Vector2 idleLocation) - { - var tier = GoblinUnderlingSystem.GetCurrentTier(); - - //if target is outside of meleeAttackRange (but inside globalAttackRange), minion stops moving horizontally - //on the edge of the meleeAttackRange, then initiates attacking behavior but with darts instead of sword - int meleeAttackRange = 400; //25 * 16 = 400 - int rangedAttackRangeFromProj = 256; //16 * 16 - float awayDistMax = 500f; - float awayDistYMax = 400f; //300, increased to reduce amount of "bouncing" when player is standing on far up tiles or hooked up - Vector2 destination = GetIdleLocation(player); - idleLocation = destination; - - if (Projectile.HandleStuck(destination.X, ref stuckTimer, StuckTimerMax)) - { - Flying = true; - Projectile.tileCollide = false; - } - - Projectile.shouldFallThrough = player.Bottom.Y - 12f > Projectile.Bottom.Y; - Projectile.friendly = false; - int attackCooldown = 0; - int attackFrameCount = WeaponFrameCount; - int nextTimerValue = GetNextTimerValue(attackFrameCount); - - int attackTarget = -1; - - static bool CustomEliminationCheck_Pirates(Entity otherEntity, int currentTarget) => true; - - bool checkBosses = false; - rangedAttackRangeFromProj *= 2; - int globalAttackRange = meleeAttackRange + rangedAttackRangeFromProj + Projectile.width; //800, calc same as below - if (IdleOrMoving) - { - Projectile.Minion_FindTargetInRange(globalAttackRange, ref attackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); - if (attackTarget > -1) - { - if (Main.npc[attackTarget].boss) - { - checkBosses = true; - } - } - } - - if (!checkBosses) - { - rangedAttackRangeFromProj /= 2; - globalAttackRange = meleeAttackRange + rangedAttackRangeFromProj + Projectile.width; - } - - if (Flying) - { - Projectile.tileCollide = false; - float velChange = 0.2f; - float toPlayerSpeed = 10f; - int maxLen = 200; - if (toPlayerSpeed < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - { - toPlayerSpeed = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - } - - Vector2 toPlayer = player.Center - Projectile.Center; - float len = toPlayer.Length(); - - AssAI.TeleportIfTooFar(Projectile, player.Center); - - if (len < maxLen && player.velocity.Y == 0f && Projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - //Reset back from flying - Flying = false; - Projectile.netUpdate = true; - if (Projectile.velocity.Y < -6f) - { - Projectile.velocity.Y = -6f; - } - } - - if (!(len < 60f)) - { - toPlayer.Normalize(); - toPlayer *= toPlayerSpeed; - if (Projectile.velocity.X < toPlayer.X) - { - Projectile.velocity.X += velChange; - if (Projectile.velocity.X < 0f) - { - Projectile.velocity.X += velChange * 1.5f; - } - } - - if (Projectile.velocity.X > toPlayer.X) - { - Projectile.velocity.X -= velChange; - if (Projectile.velocity.X > 0f) - { - Projectile.velocity.X -= velChange * 1.5f; - } - } - - if (Projectile.velocity.Y < toPlayer.Y) - { - Projectile.velocity.Y += velChange; - if (Projectile.velocity.Y < 0f) - { - Projectile.velocity.Y += velChange * 1.5f; - } - } - - if (Projectile.velocity.Y > toPlayer.Y) - { - Projectile.velocity.Y -= velChange; - if (Projectile.velocity.Y > 0f) - { - Projectile.velocity.Y -= velChange * 1.5f; - } - } - } - - if (Projectile.velocity.X != 0f) - { - Projectile.direction = Math.Sign(Projectile.velocity.X); - Projectile.spriteDirection = -Projectile.direction; - } - } - - if (GeneralAttacking && Timer < 0) - { - Projectile.friendly = false; - Timer += 1; - if (nextTimerValue >= 0) - { - Timer = 0; - GeneralAttacking = false; - Projectile.netUpdate = true; - return; - } - } - else if (GeneralAttacking) - { - if (MeleeAttacking) - { - Projectile.friendly = true; - } - - //Attacking animation - Projectile.spriteDirection = -Projectile.direction; - Projectile.rotation = 0f; - - int startAttackFrame = 12; - bool hasJumpingAttackFrames = true; - AttackFrameNumber = (int)(((float)nextTimerValue - Timer) / ((float)nextTimerValue / attackFrameCount)); - Projectile.frame = startAttackFrame + AttackFrameNumber; - - if (hasJumpingAttackFrames && Projectile.velocity.Y != 0f) - { - Projectile.frame += attackFrameCount; - } - - if (MeleeAttacking) - { - int newAttackTarget = -1; - Projectile.Minion_FindTargetInRange(globalAttackRange, ref newAttackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); - if (newAttackTarget != -1 && Timer > nextTimerValue * 0.8f) - { - if (Main.npc[newAttackTarget].Hitbox.Intersects(Projectile.Hitbox)) - { - Projectile.velocity.X *= Projectile.velocity.Y == 0f ? 0.75f : 0.85f; - } - } - } - else if (RangedAttacking) - { - Projectile.velocity.X *= Projectile.velocity.Y == 0f ? 0.75f : 0.85f; - - int newAttackTarget = -1; - Projectile.Minion_FindTargetInRange(globalAttackRange, ref newAttackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); - - if (newAttackTarget != -1) - { - NPC npc = Main.npc[newAttackTarget]; - Projectile.direction = (npc.Center.X - Projectile.Center.X >= 0f).ToDirectionInt(); - - if (Main.myPlayer == Projectile.owner && Timer == (int)(nextTimerValue * 0.75f)) - { - Vector2 position = Projectile.Center; - Vector2 targetPos = npc.Center + npc.velocity * 0.6f; - Vector2 vector = targetPos - position; - float speed = tier.rangedVelocity; - float mag = vector.Length(); - if (mag > speed) - { - mag = speed / mag; - vector *= mag; - } - - //We do a little hardcode - if (tier.rangedProjType != ModContent.ProjectileType()) - { - AssUtils.ModifyVelocityForGravity(position, targetPos, GoblinUnderlingDart.Gravity, ref vector, GoblinUnderlingDart.TicksWithoutGravity); - } - - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), position, vector, tier.rangedProjType, Projectile.damage, Projectile.knockBack, Projectile.owner); - } - } - } - - Projectile.velocity.Y += Gravity; - if (Projectile.velocity.Y > 10f) - { - Projectile.velocity.Y = 10f; - } - - Timer -= 1; - if (Timer <= 0) - { - if (attackCooldown <= 0) - { - Timer = 0; - GeneralAttacking = false; - Projectile.netUpdate = true; - return; - } - - Timer = -attackCooldown; - } - } - - if (attackTarget >= 0) - { - float toTargetMaxDist = 20f; - - NPC npc = Main.npc[attackTarget]; - destination = npc.Center; - if (Projectile.IsInRangeOfMeOrMyOwner(npc, globalAttackRange, out float projDistance, out float playerDistance, out bool _)) - { - //If target in range, handle fallthrough, jumping, and deciding when to initiate attack - Projectile.shouldFallThrough = npc.Center.Y > Projectile.Bottom.Y; - - //only go into melee if NPC is either grounded, or 4 blocks above standable ground - bool canGoMelee = npc.velocity.Y == 0f; - if (!canGoMelee) - { - int tilesToCheck = 4; - int npcY = (int)npc.Bottom.Y / 16; - int x = (int)npc.Bottom.X / 16; - - bool atleastOneSolid = false; - for (int y = npcY; y < npcY + tilesToCheck + 1; y++) - { - Tile tile = Framing.GetTileSafely(x, y); - - //If atleast one of the tiles below the NPC are active and walkable - if (WorldGen.InWorld(x, y) && WorldGen.ActiveAndWalkableTile(x, y)) - { - atleastOneSolid = true; - break; - } - } - - if (atleastOneSolid) - { - canGoMelee = true; - } - } - - bool allowJump = false; - if ((playerDistance <= meleeAttackRange || projDistance < 120f) && canGoMelee) - { - //Melee range - allowJump = true; - - if (projDistance < toTargetMaxDist || npc.Hitbox.Intersects(Projectile.Hitbox)) - { - float len = Projectile.velocity.Length(); - if (len > 10f) - { - Projectile.velocity /= len / 10f; - } - - MeleeAttacking = true; - } - } - else - { - //Ranged range - if (npc.noTileCollide || npc.noGravity) - { - //Should not try going through platforms if NPC is flying - Projectile.shouldFallThrough = false; - } - - //If enemy too far up, jump to try hitting it - if (npc.Bottom.Y + rangedAttackRangeFromProj * 1.2f < Projectile.Center.Y) - { - allowJump = true; - } - - if (projDistance < rangedAttackRangeFromProj) - { - RangedAttacking = true; - } - } - - if (allowJump) - { - bool canJump = Projectile.velocity.Y == 0f; - if (Projectile.wet && Projectile.velocity.Y > 0f && !Projectile.shouldFallThrough) - { - canJump = true; - } - - if (npc.Center.Y < Projectile.Center.Y - 20f && canJump) - { - float num25 = (npc.Center.Y - Projectile.Center.Y) * -1f; - float num26 = Gravity; - float velY = (float)Math.Sqrt(num25 * 2f * num26); - if (velY > 26f) - { - velY = 26f; - } - - Projectile.velocity.Y = -velY; - } - } - - //If an attack was decided - if (GeneralAttacking) - { - Timer = GetNextTimerValue(attackFrameCount); - - Projectile.netUpdate = true; - Projectile.direction = (npc.Center.X - Projectile.Center.X >= 0f).ToDirectionInt(); - } - } - } - - if (IdleOrMoving && attackTarget < 0) - { - if (player.rocketDelay2 > 0 && player.wings != 45) - { - Flying = true; - Projectile.netUpdate = true; - } - - Vector2 toPlayer = player.Center - Projectile.Center; - if (!AssAI.TeleportIfTooFar(Projectile, player.Center) && toPlayer.Length() > awayDistMax || Math.Abs(toPlayer.Y) > awayDistYMax) - { - Flying = true; - Projectile.netUpdate = true; - if (Projectile.velocity.Y > 0f && toPlayer.Y < 0f) - { - Projectile.velocity.Y = 0f; - } - - if (Projectile.velocity.Y < 0f && toPlayer.Y > 0f) - { - Projectile.velocity.Y = 0f; - } - } - } - - if (IdleOrMoving) - { - if (attackTarget < 0) - { - if (Projectile.Distance(player.Center) > 60f && Projectile.Distance(destination) > 60f && Math.Sign(destination.X - player.Center.X) != Math.Sign(Projectile.Center.X - player.Center.X)) - { - destination = player.Center; - } - - Rectangle rect = Utils.CenteredRectangle(destination, Projectile.Size); - for (int i = 0; i < 20; i++) - { - if (Collision.SolidCollision(rect.TopLeft(), rect.Width, rect.Height)) - { - break; - } - - rect.Y += 16; - destination.Y += 16f; - } - - Vector2 position = player.Center - Projectile.Size / 2f; - Vector2 postCollision = Collision.TileCollision(position, destination - player.Center, Projectile.width, Projectile.height); - destination = position + postCollision; - if (Projectile.Distance(destination) < 32f) - { - float distPlayerToDestination = player.Distance(destination); - if (player.Distance(Projectile.Center) < distPlayerToDestination) - { - destination = Projectile.Center; - } - } - - Vector2 fromDestToPlayer = player.Center - destination; - if (fromDestToPlayer.Length() > awayDistMax || Math.Abs(fromDestToPlayer.Y) > awayDistYMax) - { - Rectangle rect2 = Utils.CenteredRectangle(player.Center, Projectile.Size); - Vector2 fromPlayerToDest = destination - player.Center; - Vector2 topLeft = rect2.TopLeft(); - for (float i = 0f; i < 1f; i += 0.05f) - { - Vector2 newTopLeft = rect2.TopLeft() + fromPlayerToDest * i; - if (Collision.SolidCollision(rect2.TopLeft() + fromPlayerToDest * i, rect2.Width, rect2.Height)) - { - break; - } - - topLeft = newTopLeft; - } - - destination = topLeft + Projectile.Size / 2f; - } - } - - Projectile.tileCollide = true; - float velXChange = 0.5f; //0.5f - float velXChangeMargin = 4f; //4f - float velXChangeMax = 4f; //4f - float velXChangeSmall = 0.1f; - - if (attackTarget != -1) - { - //Formula: margin/max is 12.5 x change - velXChange = 1f * tier.movementSpeedMult; - velXChangeMargin = velXChange * 12.5f; - velXChangeMax = velXChangeMargin; - - //velXChange = 0.4f; //1f - //velXChangeMargin = 5f; //8f - //velXChangeMax = 5f; //8f - } - - if (velXChangeMax < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - { - velXChangeMax = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - velXChange = 0.7f; - } - - int xOff = 0; - bool canJumpOverTiles = false; - float toDestinationX = destination.X - Projectile.Center.X; - Vector2 toDestination = destination - Projectile.Center; - if (Math.Abs(toDestinationX) > 5f) - { - if (toDestinationX < 0f) - { - xOff = -1; - if (Projectile.velocity.X > -velXChangeMargin) - { - Projectile.velocity.X -= velXChange; - } - else - { - Projectile.velocity.X -= velXChangeSmall; - } - } - else - { - xOff = 1; - if (Projectile.velocity.X < velXChangeMargin) - { - Projectile.velocity.X += velXChange; - } - else - { - Projectile.velocity.X += velXChangeSmall; - } - } - } - else - { - Projectile.velocity.X *= 0.9f; - if (Math.Abs(Projectile.velocity.X) < velXChange * 2f) - { - Projectile.velocity.X = 0f; - } - } - - bool tryJumping = Math.Abs(toDestination.X) >= 64f || (toDestination.Y <= -48f && Math.Abs(toDestination.X) >= 8f); - if (xOff != 0 && tryJumping) - { - int x = (int)Projectile.Center.X / 16; - int startY = (int)Projectile.position.Y / 16; - x += xOff; - x += (int)Projectile.velocity.X; - for (int y = startY; y < startY + Projectile.height / 16 + 1; y++) - { - if (WorldGen.SolidTile(x, y)) - { - canJumpOverTiles = true; - } - } - } - - Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); - float nextVelocityY = Utils.GetLerpValue(0f, 100f, toDestination.Y, clamped: true) * Utils.GetLerpValue(-2f, -6f, Projectile.velocity.Y, clamped: true); - if (Projectile.velocity.Y == 0f && canJumpOverTiles) - { - for (int k = 0; k < 3; k++) - { - int x = (int)(Projectile.Center.X) / 16; - if (k == 0) - { - x = (int)Projectile.Left.X / 16; - } - - if (k == 2) - { - x = (int)(Projectile.Right.X) / 16; - } - - int y = (int)(Projectile.Bottom.Y) / 16; - if (!WorldGen.SolidTile(x, y) && !Main.tile[x, y].IsHalfBlock && Main.tile[x, y].Slope <= 0 && (!TileID.Sets.Platforms[Main.tile[x, y].TileType] || !Main.tile[x, y].HasTile || Main.tile[x, y].IsActuated)) - { - continue; - } - - try - { - x = (int)(Projectile.Center.X) / 16; - y = (int)(Projectile.Center.Y) / 16; - x += xOff; - x += (int)Projectile.velocity.X; - if (!WorldGen.SolidTile(x, y - 1) && !WorldGen.SolidTile(x, y - 2)) - { - Projectile.velocity.Y = -5.1f; - } - else if (!WorldGen.SolidTile(x, y - 2)) - { - Projectile.velocity.Y = -7.1f; - } - else if (WorldGen.SolidTile(x, y - 5)) - { - Projectile.velocity.Y = -11.1f; - } - else if (WorldGen.SolidTile(x, y - 4)) - { - Projectile.velocity.Y = -10.1f; - } - else - Projectile.velocity.Y = -9.1f; - } - catch - { - Projectile.velocity.Y = -9.1f; - } - } - - if (destination.Y - Projectile.Center.Y < -48f) - { - float height = destination.Y - Projectile.Center.Y; - height *= -1f; - if (height < 60f) - { - Projectile.velocity.Y = -6f; - } - else if (height < 80f) - { - Projectile.velocity.Y = -7f; - } - else if (height < 100f) - { - Projectile.velocity.Y = -8f; - } - else if (height < 120f) - { - Projectile.velocity.Y = -9f; - } - else if (height < 140f) - { - Projectile.velocity.Y = -10f; - } - else if (height < 160f) - { - Projectile.velocity.Y = -11f; - } - else if (height < 190f) - { - Projectile.velocity.Y = -12f; - } - else if (height < 210f) - { - Projectile.velocity.Y = -13f; - } - else if (height < 270f) - { - Projectile.velocity.Y = -14f; - } - else if (height < 310f) - { - Projectile.velocity.Y = -15f; - } - else - { - Projectile.velocity.Y = -16f; - } - } - - if (Projectile.wet && nextVelocityY == 0f) - { - Projectile.velocity.Y *= 2f; - } - } - - if (Projectile.velocity.X > velXChangeMax) - { - Projectile.velocity.X = velXChangeMax; - } - - if (Projectile.velocity.X < -velXChangeMax) - { - Projectile.velocity.X = -velXChangeMax; - } - - if (Projectile.velocity.X < 0f) - { - Projectile.direction = -1; - } - - if (Projectile.velocity.X > 0f) - { - Projectile.direction = 1; - } - - if (Projectile.velocity.X == 0f) - { - Projectile.direction = (player.Center.X > Projectile.Center.X).ToDirectionInt(); - } - - if (Projectile.velocity.X > velXChange && xOff == 1) - { - Projectile.direction = 1; - } - - if (Projectile.velocity.X < -velXChange && xOff == -1) - { - Projectile.direction = -1; - } - - Projectile.velocity.Y += Gravity + nextVelocityY * 1f; - if (Projectile.velocity.Y > 10f) - { - Projectile.velocity.Y = 10f; - } - } - - Projectile.spriteDirection = -Projectile.direction; - } - - private void SetFrame() + private void UnderlingAI(Player player, out Vector2 idleLocation) + { + var tier = GoblinUnderlingSystem.GetCurrentTier(); + + //if target is outside of meleeAttackRange (but inside globalAttackRange), minion stops moving horizontally + //on the edge of the meleeAttackRange, then initiates attacking behavior but with darts instead of sword + int meleeAttackRange = 400; //25 * 16 = 400 + int rangedAttackRangeFromProj = 256; //16 * 16 + float awayDistMax = 500f; + float awayDistYMax = 400f; //300, increased to reduce amount of "bouncing" when player is standing on far up tiles or hooked up + Vector2 destination = GetIdleLocation(player); + idleLocation = destination; + + if (Projectile.HandleStuck(destination.X, ref stuckTimer, StuckTimerMax)) + { + Flying = true; + Projectile.tileCollide = false; + } + + Projectile.shouldFallThrough = player.Bottom.Y - 12f > Projectile.Bottom.Y; + Projectile.friendly = false; + int attackCooldown = 0; + int attackFrameCount = WeaponFrameCount; + int nextTimerValue = GetNextTimerValue(attackFrameCount); + + int attackTarget = -1; + + static bool CustomEliminationCheck_Pirates(Entity otherEntity, int currentTarget) => true; + + bool checkBosses = false; + rangedAttackRangeFromProj *= 2; + int globalAttackRange = meleeAttackRange + rangedAttackRangeFromProj + Projectile.width; //800, calc same as below + if (IdleOrMoving) + { + Projectile.Minion_FindTargetInRange(globalAttackRange, ref attackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); + if (attackTarget > -1) + { + if (Main.npc[attackTarget].boss) + { + checkBosses = true; + } + } + } + + if (!checkBosses) + { + rangedAttackRangeFromProj /= 2; + globalAttackRange = meleeAttackRange + rangedAttackRangeFromProj + Projectile.width; + } + + if (Flying) + { + Projectile.tileCollide = false; + float velChange = 0.2f; + float toPlayerSpeed = 10f; + int maxLen = 200; + if (toPlayerSpeed < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + { + toPlayerSpeed = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + } + + Vector2 toPlayer = player.Center - Projectile.Center; + float len = toPlayer.Length(); + + AssAI.TeleportIfTooFar(Projectile, player.Center); + + if (len < maxLen && player.velocity.Y == 0f && Projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + //Reset back from flying + Flying = false; + Projectile.netUpdate = true; + if (Projectile.velocity.Y < -6f) + { + Projectile.velocity.Y = -6f; + } + } + + if (!(len < 60f)) + { + toPlayer.Normalize(); + toPlayer *= toPlayerSpeed; + if (Projectile.velocity.X < toPlayer.X) + { + Projectile.velocity.X += velChange; + if (Projectile.velocity.X < 0f) + { + Projectile.velocity.X += velChange * 1.5f; + } + } + + if (Projectile.velocity.X > toPlayer.X) + { + Projectile.velocity.X -= velChange; + if (Projectile.velocity.X > 0f) + { + Projectile.velocity.X -= velChange * 1.5f; + } + } + + if (Projectile.velocity.Y < toPlayer.Y) + { + Projectile.velocity.Y += velChange; + if (Projectile.velocity.Y < 0f) + { + Projectile.velocity.Y += velChange * 1.5f; + } + } + + if (Projectile.velocity.Y > toPlayer.Y) + { + Projectile.velocity.Y -= velChange; + if (Projectile.velocity.Y > 0f) + { + Projectile.velocity.Y -= velChange * 1.5f; + } + } + } + + if (Projectile.velocity.X != 0f) + { + Projectile.direction = Math.Sign(Projectile.velocity.X); + Projectile.spriteDirection = -Projectile.direction; + } + } + + if (GeneralAttacking && Timer < 0) + { + Projectile.friendly = false; + Timer += 1; + if (nextTimerValue >= 0) + { + Timer = 0; + GeneralAttacking = false; + Projectile.netUpdate = true; + return; + } + } + else if (GeneralAttacking) + { + if (MeleeAttacking) + { + Projectile.friendly = true; + } + + //Attacking animation + Projectile.spriteDirection = -Projectile.direction; + Projectile.rotation = 0f; + + int startAttackFrame = 12; + bool hasJumpingAttackFrames = true; + AttackFrameNumber = (int)(((float)nextTimerValue - Timer) / ((float)nextTimerValue / attackFrameCount)); + Projectile.frame = startAttackFrame + AttackFrameNumber; + + if (hasJumpingAttackFrames && Projectile.velocity.Y != 0f) + { + Projectile.frame += attackFrameCount; + } + + if (MeleeAttacking) + { + int newAttackTarget = -1; + Projectile.Minion_FindTargetInRange(globalAttackRange, ref newAttackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); + if (newAttackTarget != -1 && Timer > nextTimerValue * 0.8f) + { + if (Main.npc[newAttackTarget].Hitbox.Intersects(Projectile.Hitbox)) + { + Projectile.velocity.X *= Projectile.velocity.Y == 0f ? 0.75f : 0.85f; + } + } + } + else if (RangedAttacking) + { + Projectile.velocity.X *= Projectile.velocity.Y == 0f ? 0.75f : 0.85f; + + int newAttackTarget = -1; + Projectile.Minion_FindTargetInRange(globalAttackRange, ref newAttackTarget, skipIfCannotHitWithOwnBody: true, CustomEliminationCheck_Pirates); + + if (newAttackTarget != -1) + { + NPC npc = Main.npc[newAttackTarget]; + Projectile.direction = (npc.Center.X - Projectile.Center.X >= 0f).ToDirectionInt(); + + if (Main.myPlayer == Projectile.owner && Timer == (int)(nextTimerValue * 0.75f)) + { + Vector2 position = Projectile.Center; + Vector2 targetPos = npc.Center + npc.velocity * 0.6f; + Vector2 vector = targetPos - position; + float speed = tier.rangedVelocity; + float mag = vector.Length(); + if (mag > speed) + { + mag = speed / mag; + vector *= mag; + } + + //We do a little hardcode + if (tier.rangedProjType != ModContent.ProjectileType()) + { + AssUtils.ModifyVelocityForGravity(position, targetPos, GoblinUnderlingDart.Gravity, ref vector, GoblinUnderlingDart.TicksWithoutGravity); + } + + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), position, vector, tier.rangedProjType, Projectile.damage, Projectile.knockBack, Projectile.owner); + } + } + } + + Projectile.velocity.Y += Gravity; + if (Projectile.velocity.Y > 10f) + { + Projectile.velocity.Y = 10f; + } + + Timer -= 1; + if (Timer <= 0) + { + if (attackCooldown <= 0) + { + Timer = 0; + GeneralAttacking = false; + Projectile.netUpdate = true; + return; + } + + Timer = -attackCooldown; + } + } + + if (attackTarget >= 0) + { + float toTargetMaxDist = 20f; + + NPC npc = Main.npc[attackTarget]; + destination = npc.Center; + if (Projectile.IsInRangeOfMeOrMyOwner(npc, globalAttackRange, out float projDistance, out float playerDistance, out bool _)) + { + //If target in range, handle fallthrough, jumping, and deciding when to initiate attack + Projectile.shouldFallThrough = npc.Center.Y > Projectile.Bottom.Y; + + //only go into melee if NPC is either grounded, or 4 blocks above standable ground + bool canGoMelee = npc.velocity.Y == 0f; + if (!canGoMelee) + { + int tilesToCheck = 4; + int npcY = (int)npc.Bottom.Y / 16; + int x = (int)npc.Bottom.X / 16; + + bool atleastOneSolid = false; + for (int y = npcY; y < npcY + tilesToCheck + 1; y++) + { + Tile tile = Framing.GetTileSafely(x, y); + + //If atleast one of the tiles below the NPC are active and walkable + if (WorldGen.InWorld(x, y) && WorldGen.ActiveAndWalkableTile(x, y)) + { + atleastOneSolid = true; + break; + } + } + + if (atleastOneSolid) + { + canGoMelee = true; + } + } + + bool allowJump = false; + if ((playerDistance <= meleeAttackRange || projDistance < 120f) && canGoMelee) + { + //Melee range + allowJump = true; + + if (projDistance < toTargetMaxDist || npc.Hitbox.Intersects(Projectile.Hitbox)) + { + float len = Projectile.velocity.Length(); + if (len > 10f) + { + Projectile.velocity /= len / 10f; + } + + MeleeAttacking = true; + } + } + else + { + //Ranged range + if (npc.noTileCollide || npc.noGravity) + { + //Should not try going through platforms if NPC is flying + Projectile.shouldFallThrough = false; + } + + //If enemy too far up, jump to try hitting it + if (npc.Bottom.Y + rangedAttackRangeFromProj * 1.2f < Projectile.Center.Y) + { + allowJump = true; + } + + if (projDistance < rangedAttackRangeFromProj) + { + RangedAttacking = true; + } + } + + if (allowJump) + { + bool canJump = Projectile.velocity.Y == 0f; + if (Projectile.wet && Projectile.velocity.Y > 0f && !Projectile.shouldFallThrough) + { + canJump = true; + } + + if (npc.Center.Y < Projectile.Center.Y - 20f && canJump) + { + float num25 = (npc.Center.Y - Projectile.Center.Y) * -1f; + float num26 = Gravity; + float velY = (float)Math.Sqrt(num25 * 2f * num26); + if (velY > 26f) + { + velY = 26f; + } + + Projectile.velocity.Y = -velY; + } + } + + //If an attack was decided + if (GeneralAttacking) + { + Timer = GetNextTimerValue(attackFrameCount); + + Projectile.netUpdate = true; + Projectile.direction = (npc.Center.X - Projectile.Center.X >= 0f).ToDirectionInt(); + } + } + } + + if (IdleOrMoving && attackTarget < 0) + { + if (player.rocketDelay2 > 0 && player.wings != 45) + { + Flying = true; + Projectile.netUpdate = true; + } + + Vector2 toPlayer = player.Center - Projectile.Center; + if (!AssAI.TeleportIfTooFar(Projectile, player.Center) && toPlayer.Length() > awayDistMax || Math.Abs(toPlayer.Y) > awayDistYMax) + { + Flying = true; + Projectile.netUpdate = true; + if (Projectile.velocity.Y > 0f && toPlayer.Y < 0f) + { + Projectile.velocity.Y = 0f; + } + + if (Projectile.velocity.Y < 0f && toPlayer.Y > 0f) + { + Projectile.velocity.Y = 0f; + } + } + } + + if (IdleOrMoving) + { + if (attackTarget < 0) + { + if (Projectile.Distance(player.Center) > 60f && Projectile.Distance(destination) > 60f && Math.Sign(destination.X - player.Center.X) != Math.Sign(Projectile.Center.X - player.Center.X)) + { + destination = player.Center; + } + + Rectangle rect = Utils.CenteredRectangle(destination, Projectile.Size); + for (int i = 0; i < 20; i++) + { + if (Collision.SolidCollision(rect.TopLeft(), rect.Width, rect.Height)) + { + break; + } + + rect.Y += 16; + destination.Y += 16f; + } + + Vector2 position = player.Center - Projectile.Size / 2f; + Vector2 postCollision = Collision.TileCollision(position, destination - player.Center, Projectile.width, Projectile.height); + destination = position + postCollision; + if (Projectile.Distance(destination) < 32f) + { + float distPlayerToDestination = player.Distance(destination); + if (player.Distance(Projectile.Center) < distPlayerToDestination) + { + destination = Projectile.Center; + } + } + + Vector2 fromDestToPlayer = player.Center - destination; + if (fromDestToPlayer.Length() > awayDistMax || Math.Abs(fromDestToPlayer.Y) > awayDistYMax) + { + Rectangle rect2 = Utils.CenteredRectangle(player.Center, Projectile.Size); + Vector2 fromPlayerToDest = destination - player.Center; + Vector2 topLeft = rect2.TopLeft(); + for (float i = 0f; i < 1f; i += 0.05f) + { + Vector2 newTopLeft = rect2.TopLeft() + fromPlayerToDest * i; + if (Collision.SolidCollision(rect2.TopLeft() + fromPlayerToDest * i, rect2.Width, rect2.Height)) + { + break; + } + + topLeft = newTopLeft; + } + + destination = topLeft + Projectile.Size / 2f; + } + } + + Projectile.tileCollide = true; + float velXChange = 0.5f; //0.5f + float velXChangeMargin = 4f; //4f + float velXChangeMax = 4f; //4f + float velXChangeSmall = 0.1f; + + if (attackTarget != -1) + { + //Formula: margin/max is 12.5 x change + velXChange = 1f * tier.movementSpeedMult; + velXChangeMargin = velXChange * 12.5f; + velXChangeMax = velXChangeMargin; + + //velXChange = 0.4f; //1f + //velXChangeMargin = 5f; //8f + //velXChangeMax = 5f; //8f + } + + if (velXChangeMax < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + { + velXChangeMax = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + velXChange = 0.7f; + } + + int xOff = 0; + bool canJumpOverTiles = false; + float toDestinationX = destination.X - Projectile.Center.X; + Vector2 toDestination = destination - Projectile.Center; + if (Math.Abs(toDestinationX) > 5f) + { + if (toDestinationX < 0f) + { + xOff = -1; + if (Projectile.velocity.X > -velXChangeMargin) + { + Projectile.velocity.X -= velXChange; + } + else + { + Projectile.velocity.X -= velXChangeSmall; + } + } + else + { + xOff = 1; + if (Projectile.velocity.X < velXChangeMargin) + { + Projectile.velocity.X += velXChange; + } + else + { + Projectile.velocity.X += velXChangeSmall; + } + } + } + else + { + Projectile.velocity.X *= 0.9f; + if (Math.Abs(Projectile.velocity.X) < velXChange * 2f) + { + Projectile.velocity.X = 0f; + } + } + + bool tryJumping = Math.Abs(toDestination.X) >= 64f || (toDestination.Y <= -48f && Math.Abs(toDestination.X) >= 8f); + if (xOff != 0 && tryJumping) + { + int x = (int)Projectile.Center.X / 16; + int startY = (int)Projectile.position.Y / 16; + x += xOff; + x += (int)Projectile.velocity.X; + for (int y = startY; y < startY + Projectile.height / 16 + 1; y++) + { + if (WorldGen.SolidTile(x, y)) + { + canJumpOverTiles = true; + } + } + } + + Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); + float nextVelocityY = Utils.GetLerpValue(0f, 100f, toDestination.Y, clamped: true) * Utils.GetLerpValue(-2f, -6f, Projectile.velocity.Y, clamped: true); + if (Projectile.velocity.Y == 0f && canJumpOverTiles) + { + for (int k = 0; k < 3; k++) + { + int x = (int)(Projectile.Center.X) / 16; + if (k == 0) + { + x = (int)Projectile.Left.X / 16; + } + + if (k == 2) + { + x = (int)(Projectile.Right.X) / 16; + } + + int y = (int)(Projectile.Bottom.Y) / 16; + if (!WorldGen.SolidTile(x, y) && !Main.tile[x, y].IsHalfBlock && Main.tile[x, y].Slope <= 0 && (!TileID.Sets.Platforms[Main.tile[x, y].TileType] || !Main.tile[x, y].HasTile || Main.tile[x, y].IsActuated)) + { + continue; + } + + try + { + x = (int)(Projectile.Center.X) / 16; + y = (int)(Projectile.Center.Y) / 16; + x += xOff; + x += (int)Projectile.velocity.X; + if (!WorldGen.SolidTile(x, y - 1) && !WorldGen.SolidTile(x, y - 2)) + { + Projectile.velocity.Y = -5.1f; + } + else if (!WorldGen.SolidTile(x, y - 2)) + { + Projectile.velocity.Y = -7.1f; + } + else if (WorldGen.SolidTile(x, y - 5)) + { + Projectile.velocity.Y = -11.1f; + } + else if (WorldGen.SolidTile(x, y - 4)) + { + Projectile.velocity.Y = -10.1f; + } + else + Projectile.velocity.Y = -9.1f; + } + catch + { + Projectile.velocity.Y = -9.1f; + } + } + + if (destination.Y - Projectile.Center.Y < -48f) + { + float height = destination.Y - Projectile.Center.Y; + height *= -1f; + if (height < 60f) + { + Projectile.velocity.Y = -6f; + } + else if (height < 80f) + { + Projectile.velocity.Y = -7f; + } + else if (height < 100f) + { + Projectile.velocity.Y = -8f; + } + else if (height < 120f) + { + Projectile.velocity.Y = -9f; + } + else if (height < 140f) + { + Projectile.velocity.Y = -10f; + } + else if (height < 160f) + { + Projectile.velocity.Y = -11f; + } + else if (height < 190f) + { + Projectile.velocity.Y = -12f; + } + else if (height < 210f) + { + Projectile.velocity.Y = -13f; + } + else if (height < 270f) + { + Projectile.velocity.Y = -14f; + } + else if (height < 310f) + { + Projectile.velocity.Y = -15f; + } + else + { + Projectile.velocity.Y = -16f; + } + } + + if (Projectile.wet && nextVelocityY == 0f) + { + Projectile.velocity.Y *= 2f; + } + } + + if (Projectile.velocity.X > velXChangeMax) + { + Projectile.velocity.X = velXChangeMax; + } + + if (Projectile.velocity.X < -velXChangeMax) + { + Projectile.velocity.X = -velXChangeMax; + } + + if (Projectile.velocity.X < 0f) + { + Projectile.direction = -1; + } + + if (Projectile.velocity.X > 0f) + { + Projectile.direction = 1; + } + + if (Projectile.velocity.X == 0f) + { + Projectile.direction = (player.Center.X > Projectile.Center.X).ToDirectionInt(); + } + + if (Projectile.velocity.X > velXChange && xOff == 1) + { + Projectile.direction = 1; + } + + if (Projectile.velocity.X < -velXChange && xOff == -1) + { + Projectile.direction = -1; + } + + Projectile.velocity.Y += Gravity + nextVelocityY * 1f; + if (Projectile.velocity.Y > 10f) + { + Projectile.velocity.Y = 10f; + } + } + + Projectile.spriteDirection = -Projectile.direction; + } + + private void SetFrame() { //Idle, Jump, Walk, Walk, Walk, Walk, Walk, Walk, Walk, Walk, Walk, Walk, Attack, Attack, Attack, Attack. Jump Attack, Jump Attack, Jump Attack, Jump Attack if (Flying) @@ -1061,22 +1061,22 @@ private void SetFrame() //Propulsion dust float dustChance = Math.Clamp(Math.Abs(Projectile.velocity.Length()) / 3f, 0.5f, 1f); if (Main.rand.NextFloat() < dustChance) - { - int dirOffset = 0; - if (Projectile.direction == -1) - { - dirOffset = -4; - } - Vector2 dustOrigin = Projectile.Bottom + new Vector2(dirOffset, -4) - Projectile.velocity.SafeNormalize(Vector2.Zero) * 2; - - for (int i = 0; i < 2; i++) - { - Vector2 bootOffset = new Vector2((i == 0).ToDirectionInt() * 5, 0); - Dust dust = Dust.NewDustDirect(dustOrigin - Vector2.One * 2f + bootOffset, 4, 4, DustID.Cloud, -Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 50, default(Color), 1.3f); - dust.velocity.X *= 0.2f; - dust.velocity.Y *= 0.2f; - dust.noGravity = true; - } + { + int dirOffset = 0; + if (Projectile.direction == -1) + { + dirOffset = -4; + } + Vector2 dustOrigin = Projectile.Bottom + new Vector2(dirOffset, -4) - Projectile.velocity.SafeNormalize(Vector2.Zero) * 2; + + for (int i = 0; i < 2; i++) + { + Vector2 bootOffset = new Vector2((i == 0).ToDirectionInt() * 5, 0); + Dust dust = Dust.NewDustDirect(dustOrigin - Vector2.One * 2f + bootOffset, 4, 4, DustID.Cloud, -Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 50, default(Color), 1.3f); + dust.velocity.X *= 0.2f; + dust.velocity.Y *= 0.2f; + dust.noGravity = true; + } } } else @@ -1100,7 +1100,7 @@ private void SetFrame() } if (Projectile.frame > 11 || Projectile.frame < 2) - { + { Projectile.frame = 2; } } diff --git a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingSystem.cs b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingSystem.cs index 83a82e47..0dcdbcb7 100644 --- a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingSystem.cs +++ b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingSystem.cs @@ -52,7 +52,7 @@ public class GoblinUnderlingSystem : AssSystem public static Asset[] weaponAssets; public static GoblinUnderlingTier GetCurrentTier() - { + { return tiers[CurrentTierIndex]; } @@ -65,30 +65,30 @@ private static void RegisterMessage(GoblinUnderlingMessageSource source, List>(); - sourceToCooldowns = new Dictionary>(); - - RegisterMessage(GoblinUnderlingMessageSource.Idle, new List() - { - "I'm bored, boss!", - "I like hangin' out, boss!", - "Dis armor's too heavy...", - "You're a good boss, boss!", - "I look up to you, boss! Not because I'm short...well, mostly because I'm short!", - " Dat cloud looks like you, boss!", - "Da last boss I had was mean. You're nice!", - "Boss, what's your favorite food? I like those curved yellow things!", - "I got lotsa extra inventory space when I wear armor!", - "I don't like slimes. Dey get inside my armor, and it's sticky!", - "Boss, look! If I lay down, I can hide in da grass!", + private static void LoadMessages() + { + messageCooldownsByType = new float[(int)GoblinUnderlingMessageSource.Count]; + + sourceToMessages = new Dictionary>(); + sourceToCooldowns = new Dictionary>(); + + RegisterMessage(GoblinUnderlingMessageSource.Idle, new List() + { + "I'm bored, boss!", + "I like hangin' out, boss!", + "Dis armor's too heavy...", + "You're a good boss, boss!", + "I look up to you, boss! Not because I'm short...well, mostly because I'm short!", + " Dat cloud looks like you, boss!", + "Da last boss I had was mean. You're nice!", + "Boss, what's your favorite food? I like those curved yellow things!", + "I got lotsa extra inventory space when I wear armor!", + "I don't like slimes. Dey get inside my armor, and it's sticky!", + "Boss, look! If I lay down, I can hide in da grass!", "Dose otha' goblins are dumb. Dey should follow you too!", "Do you like me, boss?", }, - cooldown: () => Main.rand.Next(20, 40) * 60); + cooldown: () => Main.rand.Next(20, 40) * 60); RegisterMessage(GoblinUnderlingMessageSource.FirstSummon, new List() { @@ -97,89 +97,89 @@ private static void LoadMessages() //Always put that one on cooldown, as some bosses have fancy summoning ways where for example core and then parts spawn, all having boss RegisterMessage(GoblinUnderlingMessageSource.BossSpawnGeneric, new List() - { - "Uh oh!", "Dat's a biggun!", - "Boss, dat one's big!", - "I ain't afraid of nothin!", - "Boss, we got trouble!", - }, - cooldown: () => 10 * 60); - - RegisterMessage(GoblinUnderlingMessageSource.MoonlordSpawn, new List() - { - "We got dis, boss! Don't give up!", - }); - - RegisterMessage(GoblinUnderlingMessageSource.BetsySpawn, new List() - { - "Dat one's big! Dat means it has big guts!", - }); - - //Always put that one on cooldown, as some bosses have fancy defeat ways - RegisterMessage(GoblinUnderlingMessageSource.BossDefeatGeneric, new List() - { - "We did it, boss!", - "I knew you could do it!", - "Easy. Next!", - }, - cooldown: () => 10 * 60); - - RegisterMessage(GoblinUnderlingMessageSource.MoonlordDefeat, new List() - { - "Dat one was tough, but we're tougher!", - "I don't wanna see no more squid after dis...", - "Boss, you da best!", - }); - - RegisterMessage(GoblinUnderlingMessageSource.Attacking, new List() - { - "Gotcha!", - "I got dis one, boss!", - "I'm a goblin! If you beat me, you get 1 exp and 2 gold!", - "No one touches boss!", - }, - cooldown: () => 30 * 60); - - RegisterMessage(GoblinUnderlingMessageSource.PlayerHurt, new List() - { - "Don't hurt the boss!", - "You'll pay for dat!", - "You good, boss?!", - }, - cooldown: () => 60 * 60); - - RegisterMessage(GoblinUnderlingMessageSource.OOAStarts, new List() - { - "Dey'd be smart to join you, boss!", - "Let's beat deez chumps!", - }); - - RegisterMessage(GoblinUnderlingMessageSource.OOANewWave, new List() - { - "Boss, more chumps are coming!", - "More baddies!", - "Protect the shiny gem!", - "I won't let dem pass, boss!", - "Where do dey come from?!", - }); - - RegisterMessage(GoblinUnderlingMessageSource.OnValhallaArmorEquipped, new List() - { - "Lookin' spiffy, boss!", - }, - cooldown: () => 10 * 60); - - SpawnedNPCSystem.OnSpawnedNPC += OnSpawnedBoss; - - AssPlayer.OnSlainBoss += OnSlainBoss; - - On.Terraria.Main.ReportInvasionProgress += OnOOAStarts; - - //MP handled in HijackGetData - On.Terraria.GameContent.Events.DD2Event.SetEnemySpawningOnHold += OnOOANewWave_SP; - } - - private static void OnOOANewWave_SP(On.Terraria.GameContent.Events.DD2Event.orig_SetEnemySpawningOnHold orig, int forHowLong) + { + "Uh oh!", "Dat's a biggun!", + "Boss, dat one's big!", + "I ain't afraid of nothin!", + "Boss, we got trouble!", + }, + cooldown: () => 10 * 60); + + RegisterMessage(GoblinUnderlingMessageSource.MoonlordSpawn, new List() + { + "We got dis, boss! Don't give up!", + }); + + RegisterMessage(GoblinUnderlingMessageSource.BetsySpawn, new List() + { + "Dat one's big! Dat means it has big guts!", + }); + + //Always put that one on cooldown, as some bosses have fancy defeat ways + RegisterMessage(GoblinUnderlingMessageSource.BossDefeatGeneric, new List() + { + "We did it, boss!", + "I knew you could do it!", + "Easy. Next!", + }, + cooldown: () => 10 * 60); + + RegisterMessage(GoblinUnderlingMessageSource.MoonlordDefeat, new List() + { + "Dat one was tough, but we're tougher!", + "I don't wanna see no more squid after dis...", + "Boss, you da best!", + }); + + RegisterMessage(GoblinUnderlingMessageSource.Attacking, new List() + { + "Gotcha!", + "I got dis one, boss!", + "I'm a goblin! If you beat me, you get 1 exp and 2 gold!", + "No one touches boss!", + }, + cooldown: () => 30 * 60); + + RegisterMessage(GoblinUnderlingMessageSource.PlayerHurt, new List() + { + "Don't hurt the boss!", + "You'll pay for dat!", + "You good, boss?!", + }, + cooldown: () => 60 * 60); + + RegisterMessage(GoblinUnderlingMessageSource.OOAStarts, new List() + { + "Dey'd be smart to join you, boss!", + "Let's beat deez chumps!", + }); + + RegisterMessage(GoblinUnderlingMessageSource.OOANewWave, new List() + { + "Boss, more chumps are coming!", + "More baddies!", + "Protect the shiny gem!", + "I won't let dem pass, boss!", + "Where do dey come from?!", + }); + + RegisterMessage(GoblinUnderlingMessageSource.OnValhallaArmorEquipped, new List() + { + "Lookin' spiffy, boss!", + }, + cooldown: () => 10 * 60); + + SpawnedNPCSystem.OnSpawnedNPC += OnSpawnedBoss; + + AssPlayer.OnSlainBoss += OnSlainBoss; + + On.Terraria.Main.ReportInvasionProgress += OnOOAStarts; + + //MP handled in HijackGetData + On.Terraria.GameContent.Events.DD2Event.SetEnemySpawningOnHold += OnOOANewWave_SP; + } + + private static void OnOOANewWave_SP(On.Terraria.GameContent.Events.DD2Event.orig_SetEnemySpawningOnHold orig, int forHowLong) { orig(forHowLong); @@ -240,27 +240,27 @@ private static void FinalizeMessageData() //Has to be after tiers are assigned private static void LoadTextures() - { - if (!Main.dedServ) - { - bodyAssets = new Asset[TierCount]; - weaponAssets = new Asset[TierCount]; - - string body = "AssortedCrazyThings/Projectiles/Minions/GoblinUnderling/GoblinUnderlingProj_"; - string weapon = "AssortedCrazyThings/Projectiles/Minions/GoblinUnderling/GoblinUnderlingWeapon_"; - foreach (var tier in tiers) - { - int index = tier.texIndex; - bodyAssets[index] = ModContent.Request(body + index); - weaponAssets[index] = ModContent.Request(weapon + index); - } - } - } - - private static void LoadTiers() - { - tiers = new List - { + { + if (!Main.dedServ) + { + bodyAssets = new Asset[TierCount]; + weaponAssets = new Asset[TierCount]; + + string body = "AssortedCrazyThings/Projectiles/Minions/GoblinUnderling/GoblinUnderlingProj_"; + string weapon = "AssortedCrazyThings/Projectiles/Minions/GoblinUnderling/GoblinUnderlingWeapon_"; + foreach (var tier in tiers) + { + int index = tier.texIndex; + bodyAssets[index] = ModContent.Request(body + index); + weaponAssets[index] = ModContent.Request(weapon + index); + } + } + } + + private static void LoadTiers() + { + tiers = new List + { //Baseline values in Item/AI code //dmg kb ap sp m hb ran ransp /*Baseline*/ new GoblinUnderlingTier(0, () => true , ModContent.ProjectileType() , 1f , 1f , 0 , 0.3f , 6, 0 , 1.5f, 8f ), /*EoC*/ new GoblinUnderlingTier(1, () => NPC.downedBoss1 , ModContent.ProjectileType() , 1.25f, 1.2f, 0 , 0.35f, 6, 2 , 1.5f, 9f ), @@ -268,8 +268,8 @@ private static void LoadTiers() /*Skeletron*/new GoblinUnderlingTier(3, () => NPC.downedBoss3 , ModContent.ProjectileType() , 1.75f, 1.6f, 10, 0.45f, 5, 6 , 1.5f, 11f), /*Mechboss*/ new GoblinUnderlingTier(4, () => NPC.downedMechBossAny, ModContent.ProjectileType() , 3f , 1.8f, 10, 0.6f , 5, 6 , 1.5f, 12f), /*Plantera*/ new GoblinUnderlingTier(5, () => NPC.downedPlantBoss , ModContent.ProjectileType(), 3.5f , 2f , 10, 0.7f , 4, 10, 1f , 14f , true), - }; - } + }; + } private static void OnSlainBoss(Player player, int type) { @@ -367,7 +367,7 @@ private static void UpdateMessageCooldowns() { globalCooldown -= reduceAmount; if (globalCooldown < 0) - { + { globalCooldown = 0; } } @@ -389,19 +389,19 @@ private static void DetermineCurrentTier() { CurrentTierIndex = 0; for (int i = TierCount - 1; i >= 0; i--) - { + { //Start from last tier, prioritize var tier = tiers[i]; if (tier.condition()) - { + { CurrentTierIndex = i; break; - } + } } } public static void OnEnterWorld(Player player) - { + { if (player.whoAmI != Main.myPlayer) { return; @@ -447,9 +447,9 @@ public static void Create(Projectile projectile, GoblinUnderlingMessageSource so } if (ClientConfig.Instance.SatchelofGoodiesDialogueDisabled) - { + { return; - } + } PutMessageTypeOnCooldown(GoblinUnderlingMessageSource.Idle); //Always give idle message a cooldown @@ -551,28 +551,28 @@ public override void PostUpdatePlayers() DetermineCurrentTier(); } - public override bool HijackGetData(ref byte messageType, ref BinaryReader reader, int playerNumber) - { - bool ret = base.HijackGetData(ref messageType, ref reader, playerNumber); - - //MP client handle for OOANewWave - if (messageType == MessageID.CrystalInvasionSendWaitTime) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - int forHowLong = reader.ReadInt32(); - - if (forHowLong == 1800) - { - foreach (var proj in GetLocalGoblinUnderlings()) - { - TryCreate(proj, GoblinUnderlingMessageSource.OOANewWave); - } - } - } - } - - return ret; - } - } + public override bool HijackGetData(ref byte messageType, ref BinaryReader reader, int playerNumber) + { + bool ret = base.HijackGetData(ref messageType, ref reader, playerNumber); + + //MP client handle for OOANewWave + if (messageType == MessageID.CrystalInvasionSendWaitTime) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + int forHowLong = reader.ReadInt32(); + + if (forHowLong == 1800) + { + foreach (var proj in GetLocalGoblinUnderlings()) + { + TryCreate(proj, GoblinUnderlingMessageSource.OOANewWave); + } + } + } + } + + return ret; + } + } } diff --git a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingTerraBeam.cs b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingTerraBeam.cs index a6e46396..e6e409e9 100644 --- a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingTerraBeam.cs +++ b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingTerraBeam.cs @@ -1,172 +1,172 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.Projectiles.Minions.GoblinUnderling { - [Content(ContentType.Weapons)] - public class GoblinUnderlingTerraBeam : AssProjectile - { - public bool Spawned - { - get => Projectile.ai[1] == 1f; - set => Projectile.ai[1] = value ? 1 : 0; - } - - public int PulseTimer - { - get => (int)Projectile.localAI[0]; - set => Projectile.localAI[0] = value; - } - - public const int AppearTimerMax = 8; - public const int AppearTimerTransparentBefore = 2; - public const int AppearTimerTransition = AppearTimerMax - AppearTimerTransparentBefore; - public int AppearTimer - { - get => (int)Projectile.localAI[1]; - set => Projectile.localAI[1] = value; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Goblin Underling Terra Beam"); - Main.projFrames[Projectile.type] = 1; - ProjectileID.Sets.MinionShot[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - //Projectile.aiStyle = 27; - Projectile.penetrate = 3; - //Projectile.light = 0.5f; - Projectile.alpha = 255; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Summon; - Projectile.timeLeft = 120; - - DrawOriginOffsetX = -(Projectile.width / 2 - 32f / 2); - DrawOffsetX = (int)-DrawOriginOffsetX * 2; - - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - GoblinUnderlingSystem.CommonModifyHitNPC(Projectile, target, ref damage, ref knockback, ref hitDirection); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - Projectile.damage = (int)(Projectile.damage * 0.85f); - - foreach (var proj in GoblinUnderlingSystem.GetLocalGoblinUnderlings()) - { - if (proj.ModProjectile is GoblinUnderlingProj goblin) - { - if (!target.boss && goblin.OutOfCombat()) - { - GoblinUnderlingSystem.TryCreate(proj, GoblinUnderlingMessageSource.Attacking); - } - - goblin.SetInCombat(); - } - } - } - - public override Color? GetAlpha(Color lightColor) - { - if (AppearTimer >= AppearTimerMax) - { - return new Color(255, 255, 255, Projectile.alpha); - } - - if (AppearTimer < AppearTimerTransparentBefore) - { - return Color.Transparent; - } - - int c = (int)((AppearTimer - AppearTimerTransparentBefore) / (float)AppearTimerTransition * 255f); - return new Color(c, c, c, c); - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - SoundEngine.PlaySound(SoundID.Item10.WithVolume(0.7f), Projectile.Center); - - for (int i = 4; i < 16; i++) - { - float oldvelX = Projectile.oldVelocity.X * (15f / i) * 0.5f; - float oldVelY = Projectile.oldVelocity.Y * (15f / i) * 0.5f; - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.oldPosition.X - oldvelX, Projectile.oldPosition.Y - oldVelY), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default(Color), 1.3f); - dust.noGravity = true; - dust.velocity *= 0.3f; - dust = Dust.NewDustDirect(new Vector2(Projectile.oldPosition.X - oldvelX, Projectile.oldPosition.Y - oldVelY), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default(Color), 1.1f); - dust.velocity *= 0.04f; - } - - return base.OnTileCollide(oldVelocity); - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, new Vector3(0.1f, 0.5f, 0.3f)); - - if (Spawned) - { - Spawned = true; - SoundEngine.PlaySound(SoundID.Item60, Projectile.Center); - } - - if (AppearTimer > 5) - { - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X - Projectile.velocity.X * 2f + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y * 2f), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y * 0.5f, 100, default(Color), 1f); - dust.velocity *= -0.25f; - - dust = Dust.NewDustDirect(new Vector2(Projectile.position.X - Projectile.velocity.X * 2f + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y * 2f), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y * 0.5f, 100, default(Color), 1f); - dust.velocity *= -0.25f; - dust.position -= Projectile.velocity * 0.25f; - } - - if (AppearTimer < AppearTimerMax) - { - AppearTimer++; - } - else - { - if (PulseTimer == 0) - { - Projectile.scale -= 0.02f; - Projectile.alpha += 30; - if (Projectile.alpha >= 250) - { - Projectile.alpha = 255; - PulseTimer = 1; - } - } - else if (PulseTimer == 1) - { - Projectile.scale += 0.02f; - Projectile.alpha -= 30; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - PulseTimer = 0; - } - } - } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; - - if (Projectile.velocity.Y > 16f) - { - Projectile.velocity.Y = 16f; - } - } - } + [Content(ContentType.Weapons)] + public class GoblinUnderlingTerraBeam : AssProjectile + { + public bool Spawned + { + get => Projectile.ai[1] == 1f; + set => Projectile.ai[1] = value ? 1 : 0; + } + + public int PulseTimer + { + get => (int)Projectile.localAI[0]; + set => Projectile.localAI[0] = value; + } + + public const int AppearTimerMax = 8; + public const int AppearTimerTransparentBefore = 2; + public const int AppearTimerTransition = AppearTimerMax - AppearTimerTransparentBefore; + public int AppearTimer + { + get => (int)Projectile.localAI[1]; + set => Projectile.localAI[1] = value; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Goblin Underling Terra Beam"); + Main.projFrames[Projectile.type] = 1; + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 16; + //Projectile.aiStyle = 27; + Projectile.penetrate = 3; + //Projectile.light = 0.5f; + Projectile.alpha = 255; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Summon; + Projectile.timeLeft = 120; + + DrawOriginOffsetX = -(Projectile.width / 2 - 32f / 2); + DrawOffsetX = (int)-DrawOriginOffsetX * 2; + + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + GoblinUnderlingSystem.CommonModifyHitNPC(Projectile, target, ref damage, ref knockback, ref hitDirection); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Projectile.damage = (int)(Projectile.damage * 0.85f); + + foreach (var proj in GoblinUnderlingSystem.GetLocalGoblinUnderlings()) + { + if (proj.ModProjectile is GoblinUnderlingProj goblin) + { + if (!target.boss && goblin.OutOfCombat()) + { + GoblinUnderlingSystem.TryCreate(proj, GoblinUnderlingMessageSource.Attacking); + } + + goblin.SetInCombat(); + } + } + } + + public override Color? GetAlpha(Color lightColor) + { + if (AppearTimer >= AppearTimerMax) + { + return new Color(255, 255, 255, Projectile.alpha); + } + + if (AppearTimer < AppearTimerTransparentBefore) + { + return Color.Transparent; + } + + int c = (int)((AppearTimer - AppearTimerTransparentBefore) / (float)AppearTimerTransition * 255f); + return new Color(c, c, c, c); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + SoundEngine.PlaySound(SoundID.Item10.WithVolume(0.7f), Projectile.Center); + + for (int i = 4; i < 16; i++) + { + float oldvelX = Projectile.oldVelocity.X * (15f / i) * 0.5f; + float oldVelY = Projectile.oldVelocity.Y * (15f / i) * 0.5f; + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.oldPosition.X - oldvelX, Projectile.oldPosition.Y - oldVelY), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default(Color), 1.3f); + dust.noGravity = true; + dust.velocity *= 0.3f; + dust = Dust.NewDustDirect(new Vector2(Projectile.oldPosition.X - oldvelX, Projectile.oldPosition.Y - oldVelY), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default(Color), 1.1f); + dust.velocity *= 0.04f; + } + + return base.OnTileCollide(oldVelocity); + } + + public override void AI() + { + Lighting.AddLight(Projectile.Center, new Vector3(0.1f, 0.5f, 0.3f)); + + if (Spawned) + { + Spawned = true; + SoundEngine.PlaySound(SoundID.Item60, Projectile.Center); + } + + if (AppearTimer > 5) + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X - Projectile.velocity.X * 2f + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y * 2f), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y * 0.5f, 100, default(Color), 1f); + dust.velocity *= -0.25f; + + dust = Dust.NewDustDirect(new Vector2(Projectile.position.X - Projectile.velocity.X * 2f + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y * 2f), 8, 8, 107, Projectile.oldVelocity.X, Projectile.oldVelocity.Y * 0.5f, 100, default(Color), 1f); + dust.velocity *= -0.25f; + dust.position -= Projectile.velocity * 0.25f; + } + + if (AppearTimer < AppearTimerMax) + { + AppearTimer++; + } + else + { + if (PulseTimer == 0) + { + Projectile.scale -= 0.02f; + Projectile.alpha += 30; + if (Projectile.alpha >= 250) + { + Projectile.alpha = 255; + PulseTimer = 1; + } + } + else if (PulseTimer == 1) + { + Projectile.scale += 0.02f; + Projectile.alpha -= 30; + if (Projectile.alpha <= 0) + { + Projectile.alpha = 0; + PulseTimer = 0; + } + } + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; + + if (Projectile.velocity.Y > 16f) + { + Projectile.velocity.Y = 16f; + } + } + } } diff --git a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingTier.cs b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingTier.cs index 958823cf..347dd424 100644 --- a/Projectiles/Minions/GoblinUnderling/GoblinUnderlingTier.cs +++ b/Projectiles/Minions/GoblinUnderling/GoblinUnderlingTier.cs @@ -2,35 +2,35 @@ namespace AssortedCrazyThings.Projectiles.Minions.GoblinUnderling { - public record struct GoblinUnderlingTier - { - public int texIndex; - public Func condition; - public float damageMult; - public float knockbackMult; - public int armorPen; - public float movementSpeedMult; - public int meleeAttackInterval; - public int meleeAttackHitboxIncrease; - public float rangedAttackIntervalMultiplier; - public float rangedVelocity; - public int rangedProjType; - public bool showMeleeDuringRanged; + public record struct GoblinUnderlingTier + { + public int texIndex; + public Func condition; + public float damageMult; + public float knockbackMult; + public int armorPen; + public float movementSpeedMult; + public int meleeAttackInterval; + public int meleeAttackHitboxIncrease; + public float rangedAttackIntervalMultiplier; + public float rangedVelocity; + public int rangedProjType; + public bool showMeleeDuringRanged; - public GoblinUnderlingTier(int texIndex, Func condition, int rangedProjType, float damageMult = 1f, float knockbackMult = 1f, int armorPen = 0, float movementSpeedMult = 1f, int meleeAttackInterval = 4, int meleeAttackHitboxIncrease = 0, float rangedAttackIntervalMultiplier = 1.5f, float rangedVelocity = 10f, bool showMeleeDuringRanged = false) - { - this.texIndex = texIndex; - this.condition = condition; - this.damageMult = damageMult; - this.knockbackMult = knockbackMult; - this.armorPen = armorPen; - this.movementSpeedMult = movementSpeedMult; - this.meleeAttackInterval = meleeAttackInterval; - this.meleeAttackHitboxIncrease = meleeAttackHitboxIncrease; - this.rangedAttackIntervalMultiplier = rangedAttackIntervalMultiplier; - this.rangedVelocity = rangedVelocity; - this.rangedProjType = rangedProjType; - this.showMeleeDuringRanged = showMeleeDuringRanged; - } - } + public GoblinUnderlingTier(int texIndex, Func condition, int rangedProjType, float damageMult = 1f, float knockbackMult = 1f, int armorPen = 0, float movementSpeedMult = 1f, int meleeAttackInterval = 4, int meleeAttackHitboxIncrease = 0, float rangedAttackIntervalMultiplier = 1.5f, float rangedVelocity = 10f, bool showMeleeDuringRanged = false) + { + this.texIndex = texIndex; + this.condition = condition; + this.damageMult = damageMult; + this.knockbackMult = knockbackMult; + this.armorPen = armorPen; + this.movementSpeedMult = movementSpeedMult; + this.meleeAttackInterval = meleeAttackInterval; + this.meleeAttackHitboxIncrease = meleeAttackHitboxIncrease; + this.rangedAttackIntervalMultiplier = rangedAttackIntervalMultiplier; + this.rangedVelocity = rangedVelocity; + this.rangedProjType = rangedProjType; + this.showMeleeDuringRanged = showMeleeDuringRanged; + } + } } diff --git a/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingFired.cs b/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingFired.cs index 5baa1ac7..07206081 100644 --- a/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingFired.cs +++ b/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingFired.cs @@ -4,145 +4,145 @@ using Microsoft.Xna.Framework; using System.IO; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.Projectiles.Minions.MagicSlimeSlingStuff { - [Content(ContentType.Weapons)] - public class MagicSlimeSlingFired : AssProjectile - { - public byte ColorType = 0; - public Color Color = default(Color); + [Content(ContentType.Weapons)] + public class MagicSlimeSlingFired : AssProjectile + { + public byte ColorType = 0; + public Color Color = default(Color); - private void PreSync(Projectile proj) - { - if (proj.ModProjectile is MagicSlimeSlingMinionBase minion) - { - minion.ColorType = ColorType; - //ActualColor won't be synced, its assigned in send/recv - minion.Color = MagicSlimeSling.GetColor(minion.ColorType); - } - } + private void PreSync(Projectile proj) + { + if (proj.ModProjectile is MagicSlimeSlingMinionBase minion) + { + minion.ColorType = ColorType; + //ActualColor won't be synced, its assigned in send/recv + minion.Color = MagicSlimeSling.GetColor(minion.ColorType); + } + } - public override string Texture - { - get - { - return "Terraria/Images/Item_" + ItemID.Gel; - } - } + public override string Texture + { + get + { + return "Terraria/Images/Item_" + ItemID.Gel; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Magic Slime Sling Fired"); - Main.projFrames[Projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Magic Slime Sling Fired"); + Main.projFrames[Projectile.type] = 1; + } - public override void SetDefaults() - { - Projectile.netImportant = true; - Projectile.DamageType = DamageClass.Summon; - //Projectile.minion = true; - Projectile.friendly = true; - Projectile.minionSlots = 0f; - Projectile.width = 16; - Projectile.height = 14; - Projectile.aiStyle = -1; - Projectile.penetrate = 1; - Projectile.tileCollide = true; - Projectile.timeLeft = 180; - Projectile.alpha = 255; - } + public override void SetDefaults() + { + Projectile.netImportant = true; + Projectile.DamageType = DamageClass.Summon; + //Projectile.minion = true; + Projectile.friendly = true; + Projectile.minionSlots = 0f; + Projectile.width = 16; + Projectile.height = 14; + Projectile.aiStyle = -1; + Projectile.penetrate = 1; + Projectile.tileCollide = true; + Projectile.timeLeft = 180; + Projectile.alpha = 255; + } - public override Color? GetAlpha(Color lightColor) - { - if (Color == default(Color)) return lightColor; - return lightColor.MultiplyRGB(Color) * ((255 - Projectile.alpha) / 255f) * 0.7f; - } + public override Color? GetAlpha(Color lightColor) + { + if (Color == default(Color)) return lightColor; + return lightColor.MultiplyRGB(Color) * ((255 - Projectile.alpha) / 255f) * 0.7f; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write((byte)ColorType); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write((byte)ColorType); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - ColorType = reader.ReadByte(); - if (Color == default(Color)) Color = MagicSlimeSling.GetColor(ColorType); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + ColorType = reader.ReadByte(); + if (Color == default(Color)) Color = MagicSlimeSling.GetColor(ColorType); + } - public override void Kill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.NPCKilled, (int)Projectile.Center.X, (int)Projectile.Center.Y, SoundID.NPCDeath1.Style, 0.8f, 0.2f); - for (int i = 0; i < 15; i++) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 4, -Projectile.direction, -2f, 200, Color, 1f); - dust.velocity *= 0.4f; - } + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.NPCKilled, (int)Projectile.Center.X, (int)Projectile.Center.Y, SoundID.NPCDeath1.Style, 0.8f, 0.2f); + for (int i = 0; i < 15; i++) + { + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 4, -Projectile.direction, -2f, 200, Color, 1f); + dust.velocity *= 0.4f; + } - if (Projectile.active && Main.myPlayer == Projectile.owner) - { - Player player = Projectile.GetOwner(); - int sum = 0; - for (int i = 0; i < MagicSlimeSling.Types.Length; i++) - { - sum += player.ownedProjectileCounts[MagicSlimeSling.Types[i]]; - } - if (sum < (2 + player.maxMinions)) - { - int type = MagicSlimeSling.Types[ColorType]; - Vector2 velo = new Vector2(Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(-4, -2)); - velo += -Projectile.oldVelocity * 0.4f; - int index = AssUtils.NewProjectile(Projectile.GetProjectileSource_FromThis(), Projectile.Top, velo, type, Projectile.damage, Projectile.knockBack, preSync: PreSync); - Main.projectile[index].originalDamage = Projectile.originalDamage; - } - } - } + if (Projectile.active && Main.myPlayer == Projectile.owner) + { + Player player = Projectile.GetOwner(); + int sum = 0; + for (int i = 0; i < MagicSlimeSling.Types.Length; i++) + { + sum += player.ownedProjectileCounts[MagicSlimeSling.Types[i]]; + } + if (sum < (2 + player.maxMinions)) + { + int type = MagicSlimeSling.Types[ColorType]; + Vector2 velo = new Vector2(Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(-4, -2)); + velo += -Projectile.oldVelocity * 0.4f; + int index = AssUtils.NewProjectile(Projectile.GetProjectileSource_FromThis(), Projectile.Top, velo, type, Projectile.damage, Projectile.knockBack, preSync: PreSync); + Main.projectile[index].originalDamage = Projectile.originalDamage; + } + } + } - public override void AI() - { - if (Projectile.alpha > 0) - { - Projectile.alpha -= 15; - if (Projectile.alpha < 0) Projectile.alpha = 0; - } + public override void AI() + { + if (Projectile.alpha > 0) + { + Projectile.alpha -= 15; + if (Projectile.alpha < 0) Projectile.alpha = 0; + } - Projectile.rotation += Projectile.velocity.X * 0.05f; + Projectile.rotation += Projectile.velocity.X * 0.05f; - Projectile.velocity.Y += 0.15f; - if (Projectile.velocity.Y > 16f) - { - Projectile.velocity.Y = 16f; - } + Projectile.velocity.Y += 0.15f; + if (Projectile.velocity.Y > 16f) + { + Projectile.velocity.Y = 16f; + } - if (Projectile.alpha > 200) return; + if (Projectile.alpha > 200) return; - //colored sparkles - int dustType = Main.rand.Next(4); - if (dustType == 0) - { - dustType = ModContent.DustType(); - } - else if (dustType == 1) - { - dustType = ModContent.DustType(); - } - else if (dustType == 2) - { - dustType = ModContent.DustType(); - } - else - { - return; - } - // 8f is the shootspeed of the weapon shooting this projectile - if (Main.rand.NextFloat() < Projectile.velocity.Length() / 7f) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default(Color), 1.25f); - dust.velocity *= 0.1f; - } - } - } + //colored sparkles + int dustType = Main.rand.Next(4); + if (dustType == 0) + { + dustType = ModContent.DustType(); + } + else if (dustType == 1) + { + dustType = ModContent.DustType(); + } + else if (dustType == 2) + { + dustType = ModContent.DustType(); + } + else + { + return; + } + // 8f is the shootspeed of the weapon shooting this projectile + if (Main.rand.NextFloat() < Projectile.velocity.Length() / 7f) + { + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default(Color), 1.25f); + dust.velocity *= 0.1f; + } + } + } } diff --git a/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingMinion.cs b/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingMinion.cs index 86e3fcd8..0c10797c 100644 --- a/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingMinion.cs +++ b/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingMinion.cs @@ -2,180 +2,180 @@ using AssortedCrazyThings.Items.Weapons; using AssortedCrazyThings.Projectiles.Pets; using Microsoft.Xna.Framework; +using System.Collections.Generic; using System.IO; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; -using System.Collections.Generic; namespace AssortedCrazyThings.Projectiles.Minions.MagicSlimeSlingStuff { - [Content(ContentType.Weapons)] - public abstract class MagicSlimeSlingMinionBase : BabySlimeBase - { - private const int TimeLeft = 360; - - private const int PulsatingLimit = 30; - - private bool Increment = true; - - private bool Spawned = false; - - public byte ColorType = 0; - - public Color Color = default(Color); - - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingMinion"; - } - } - - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) - { - behindNPCs.Add(index); - } - - private int PulsatingCounter - { - get - { - return (int)Projectile.localAI[1]; - } - set - { - Projectile.localAI[1] = value; - } - } - - private float PulsatingAlpha - { - get - { - //0.7f to 1f when full TimeLeft, drops down to 0.7f - return 0.7f + ((float)PulsatingCounter / PulsatingLimit) * ((float)Projectile.timeLeft / TimeLeft); - } - } - - public override bool UseJumpingFrame => false; - - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Magic Slime Sling Minion"); - Main.projFrames[Projectile.type] = 2; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; - } - - public override void SafeSetDefaults() - { - Projectile.width = 24; - Projectile.height = 18; - - Projectile.DamageType = DamageClass.Summon; - Projectile.minion = true; - customMinionSlots = 0f; - Projectile.timeLeft = TimeLeft; - - DrawOriginOffsetY = 3; - DrawOffsetX = 0; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write((byte)ColorType); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - ColorType = reader.ReadByte(); - if (Color == default(Color)) Color = MagicSlimeSling.GetColor(ColorType); - } - - public override void Kill(int timeLeft) - { - for (int i = 0; i < 20; i++) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 4, -Projectile.direction, -2f, 200, Color, 1f); - dust.velocity *= 0.5f; - } - SoundEngine.PlaySound(SoundID.NPCDeath1.SoundId, (int)Projectile.Center.X, (int)Projectile.Center.Y, SoundID.NPCDeath1.Style, 0.7f, 0.2f); - } - - public override Color? GetAlpha(Color lightColor) - { - if (Color == default(Color)) return lightColor; - Color color = lightColor.MultiplyRGB(Color) * PulsatingAlpha; - if (color.A > 220) color.A = 220; - return color; - } - - public override void ModifyDamageHitbox(ref Rectangle hitbox) - { - hitbox.Inflate(6, 6); - hitbox.Y -= 6; - } - - public override void PostAI() - { - if (!Spawned) - { - Spawned = true; - SoundEngine.PlaySound(SoundID.Item9.SoundId, (int)Projectile.Center.X, (int)Projectile.Center.Y, SoundID.Item9.Style, 0.7f); - } - - if (Increment) - { - PulsatingCounter++; - if (PulsatingCounter >= PulsatingLimit) Increment = false; - } - else - { - PulsatingCounter--; - if (PulsatingCounter <= 0) Increment = true; - } - - if (Projectile.frame > 1) - { - Projectile.frame = 1; - } - - if (Projectile.ai[0] != 0) - { - int dustType = Main.rand.Next(4); - if (dustType == 0) - { - dustType = ModContent.DustType(); - } - else if (dustType == 1) - { - dustType = ModContent.DustType(); - } - else if (dustType == 2) - { - dustType = ModContent.DustType(); - } - else - { - return; - } - - if (Main.rand.NextFloat() < Projectile.velocity.Length() / 7f) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default(Color), 1.25f); - dust.velocity *= 0.1f; - } - } - } - } - - //Separate classes so projectile.usesIDStaticNPCImmunity works - public class MagicSlimeSlingMinion1 : MagicSlimeSlingMinionBase { } - - public class MagicSlimeSlingMinion2 : MagicSlimeSlingMinionBase { } - - public class MagicSlimeSlingMinion3 : MagicSlimeSlingMinionBase { } + [Content(ContentType.Weapons)] + public abstract class MagicSlimeSlingMinionBase : BabySlimeBase + { + private const int TimeLeft = 360; + + private const int PulsatingLimit = 30; + + private bool Increment = true; + + private bool Spawned = false; + + public byte ColorType = 0; + + public Color Color = default(Color); + + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Minions/MagicSlimeSlingStuff/MagicSlimeSlingMinion"; + } + } + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + behindNPCs.Add(index); + } + + private int PulsatingCounter + { + get + { + return (int)Projectile.localAI[1]; + } + set + { + Projectile.localAI[1] = value; + } + } + + private float PulsatingAlpha + { + get + { + //0.7f to 1f when full TimeLeft, drops down to 0.7f + return 0.7f + ((float)PulsatingCounter / PulsatingLimit) * ((float)Projectile.timeLeft / TimeLeft); + } + } + + public override bool UseJumpingFrame => false; + + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Magic Slime Sling Minion"); + Main.projFrames[Projectile.type] = 2; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; + } + + public override void SafeSetDefaults() + { + Projectile.width = 24; + Projectile.height = 18; + + Projectile.DamageType = DamageClass.Summon; + Projectile.minion = true; + customMinionSlots = 0f; + Projectile.timeLeft = TimeLeft; + + DrawOriginOffsetY = 3; + DrawOffsetX = 0; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write((byte)ColorType); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + ColorType = reader.ReadByte(); + if (Color == default(Color)) Color = MagicSlimeSling.GetColor(ColorType); + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 20; i++) + { + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 4, -Projectile.direction, -2f, 200, Color, 1f); + dust.velocity *= 0.5f; + } + SoundEngine.PlaySound(SoundID.NPCDeath1.SoundId, (int)Projectile.Center.X, (int)Projectile.Center.Y, SoundID.NPCDeath1.Style, 0.7f, 0.2f); + } + + public override Color? GetAlpha(Color lightColor) + { + if (Color == default(Color)) return lightColor; + Color color = lightColor.MultiplyRGB(Color) * PulsatingAlpha; + if (color.A > 220) color.A = 220; + return color; + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + hitbox.Inflate(6, 6); + hitbox.Y -= 6; + } + + public override void PostAI() + { + if (!Spawned) + { + Spawned = true; + SoundEngine.PlaySound(SoundID.Item9.SoundId, (int)Projectile.Center.X, (int)Projectile.Center.Y, SoundID.Item9.Style, 0.7f); + } + + if (Increment) + { + PulsatingCounter++; + if (PulsatingCounter >= PulsatingLimit) Increment = false; + } + else + { + PulsatingCounter--; + if (PulsatingCounter <= 0) Increment = true; + } + + if (Projectile.frame > 1) + { + Projectile.frame = 1; + } + + if (Projectile.ai[0] != 0) + { + int dustType = Main.rand.Next(4); + if (dustType == 0) + { + dustType = ModContent.DustType(); + } + else if (dustType == 1) + { + dustType = ModContent.DustType(); + } + else if (dustType == 2) + { + dustType = ModContent.DustType(); + } + else + { + return; + } + + if (Main.rand.NextFloat() < Projectile.velocity.Length() / 7f) + { + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default(Color), 1.25f); + dust.velocity *= 0.1f; + } + } + } + } + + //Separate classes so projectile.usesIDStaticNPCImmunity works + public class MagicSlimeSlingMinion1 : MagicSlimeSlingMinionBase { } + + public class MagicSlimeSlingMinion2 : MagicSlimeSlingMinionBase { } + + public class MagicSlimeSlingMinion3 : MagicSlimeSlingMinionBase { } } diff --git a/Projectiles/Minions/PetDestroyerDroneLaser.cs b/Projectiles/Minions/PetDestroyerDroneLaser.cs index ba551c50..39f84e02 100644 --- a/Projectiles/Minions/PetDestroyerDroneLaser.cs +++ b/Projectiles/Minions/PetDestroyerDroneLaser.cs @@ -1,61 +1,61 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.Projectiles.Minions { - [Content(ContentType.DroppedPets)] - public class PetDestroyerDroneLaser : AssProjectile - { - public override string Texture - { - get - { - return "Terraria/Images/Projectile_" + ProjectileID.MiniRetinaLaser; - } - } + [Content(ContentType.DroppedPets)] + public class PetDestroyerDroneLaser : AssProjectile + { + public override string Texture + { + get + { + return "Terraria/Images/Projectile_" + ProjectileID.MiniRetinaLaser; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pet Destroyer Laser"); - ProjectileID.Sets.MinionShot[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pet Destroyer Laser"); + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.MiniRetinaLaser); - Projectile.aiStyle = -1; - Projectile.penetrate = 1; - Projectile.alpha = 255; - Projectile.DamageType = DamageClass.Summon; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.MiniRetinaLaser); + Projectile.aiStyle = -1; + Projectile.penetrate = 1; + Projectile.alpha = 255; + Projectile.DamageType = DamageClass.Summon; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - SoundEngine.PlaySound(SoundID.Item10.WithVolume(0.5f), Projectile.position); - return true; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + SoundEngine.PlaySound(SoundID.Item10.WithVolume(0.5f), Projectile.position); + return true; + } - public override void AI() - { - if (Projectile.ai[1] == 0f) - { - Projectile.ai[1] = 1f; - SoundEngine.PlaySound(SoundID.Item12.WithVolume(0.5f), Projectile.position); - } + public override void AI() + { + if (Projectile.ai[1] == 0f) + { + Projectile.ai[1] = 1f; + SoundEngine.PlaySound(SoundID.Item12.WithVolume(0.5f), Projectile.position); + } - if (Projectile.alpha > 0) - { - Projectile.alpha -= 15; - } - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; - } - Projectile.rotation = Projectile.velocity.ToRotation() + 1.57f; - } - } + if (Projectile.alpha > 0) + { + Projectile.alpha -= 15; + } + if (Projectile.alpha < 0) + { + Projectile.alpha = 0; + } + Projectile.rotation = Projectile.velocity.ToRotation() + 1.57f; + } + } } diff --git a/Projectiles/Minions/PetGolemHeadFireball.cs b/Projectiles/Minions/PetGolemHeadFireball.cs index e46382ad..31b6304e 100644 --- a/Projectiles/Minions/PetGolemHeadFireball.cs +++ b/Projectiles/Minions/PetGolemHeadFireball.cs @@ -1,58 +1,58 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace AssortedCrazyThings.Projectiles.Minions { - [Content(ContentType.DroppedPets)] - public class PetGolemHeadFireball : AssProjectile - { - public override string Texture - { - get - { - return "Terraria/Images/Projectile_" + ProjectileID.Fireball; - } - } + [Content(ContentType.DroppedPets)] + public class PetGolemHeadFireball : AssProjectile + { + public override string Texture + { + get + { + return "Terraria/Images/Projectile_" + ProjectileID.Fireball; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pet Golem Head Fireball"); - ProjectileID.Sets.MinionShot[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pet Golem Head Fireball"); + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.Fireball); - Projectile.hostile = false; - Projectile.friendly = true; - Projectile.timeLeft = 300; - Projectile.penetrate = 1; - Projectile.DamageType = DamageClass.Summon; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.Fireball); + Projectile.hostile = false; + Projectile.friendly = true; + Projectile.timeLeft = 300; + Projectile.penetrate = 1; + Projectile.DamageType = DamageClass.Summon; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - //Main.PlaySound(0, projectile.position); - //Main.PlaySound(SoundID.Dig, (int)projectile.Center.X, (int)projectile.Center.Y, 0, 0.75f); - return true; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + //Main.PlaySound(0, projectile.position); + //Main.PlaySound(SoundID.Dig, (int)projectile.Center.X, (int)projectile.Center.Y, 0, 0.75f); + return true; + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - target.AddBuff(BuffID.OnFire, 240); - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + target.AddBuff(BuffID.OnFire, 240); + } - public override void AI() - { - if (Projectile.localAI[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item20, Projectile.position); - } - Projectile.localAI[0] += 1f; - } - } + public override void AI() + { + if (Projectile.localAI[0] == 0f) + { + SoundEngine.PlaySound(SoundID.Item20, Projectile.position); + } + Projectile.localAI[0] += 1f; + } + } } diff --git a/Projectiles/Minions/SlimePackMinion.cs b/Projectiles/Minions/SlimePackMinion.cs index b896dd0a..2f67adee 100644 --- a/Projectiles/Minions/SlimePackMinion.cs +++ b/Projectiles/Minions/SlimePackMinion.cs @@ -9,205 +9,205 @@ namespace AssortedCrazyThings.Projectiles.Minions { - [Content(ContentType.Weapons)] - //check this file for more info vvvvvvvv - public class SlimePackMinion : BabySlimeBase - { - public const int DefDamage = 26; - public const float DefKnockback = 4f; //same as slime staff x 2 - public const float SpikedIncrease = 0.4f; - - protected byte TotalNumberOfThese = 16; //16 for default, 13 for assorted, 16 for spiked - - protected string SlimeType = ""; - - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Minions/SlimePackMinions/SlimeMinion" + SlimeType + "_0"; //use fixed texture - } - } - - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Slime Pack Minion"); - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; - } - - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; - - Projectile.DamageType = DamageClass.Summon; - Projectile.minion = true; - - shootSpikes = false; - } - - public override void SendExtraAI(BinaryWriter writer) - { - //AssUtils.Print("send netupdate " + PickedTexture + " " + ShootTimer); - writer.Write((byte)PickedTexture); - //writer.Write((byte)ShootTimer); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - PickedTexture = reader.ReadByte(); - //ShootTimer = reader.ReadByte(); - //AssUtils.Print("recv netupdate " + PickedTexture + " " + ShootTimer); - } - - public override bool PreAI() - { - AssPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.slimePackMinion = false; - } - if (modPlayer.slimePackMinion) - { - Projectile.timeLeft = 2; - } - - if (Main.netMode != NetmodeID.Server && Main.myPlayer == Projectile.owner) - { - if (!HasTexture) - { - byte tex = (byte)Main.rand.Next(TotalNumberOfThese); - PickedTexture = tex; - Projectile.netUpdate = true; - } - } - - return true; - } - - public override bool PreDraw(ref Color lightColor) - { - //Rainbow is _5, Illuminant is _15 - if (HasTexture) - { - Texture2D image = Mod.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinion" + SlimeType + "_" + PickedTexture).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(0f, Projectile.gfxOffY - DrawOriginOffsetY); //gfxoffY is for when the projectile is on a slope or half brick - SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f); - Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; - - if (PickedTexture == 5 && SlimeType != "Assorted") - { - double cX = Projectile.Center.X + DrawOffsetX; - double cY = Projectile.Center.Y + DrawOriginOffsetY; - lightColor = Lighting.GetColor((int)(cX / 16), (int)(cY / 16), Main.DiscoColor * 1.2f); - } - - Color color = lightColor * ((255 - Projectile.alpha) / 255f); - - if (SlimeType == "Assorted" && (PickedTexture == 0 || - PickedTexture == 5 || - PickedTexture == 6 || - PickedTexture == 7 || - PickedTexture == 11)) color.A = 255; - - if (PickedTexture == 3 && SlimeType != "Assorted") //pinky - { - drawPos.Y += 7f; - Projectile.scale = 0.5f; - } - - Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); - } - return false; - } - - public override void PostDraw(Color lightColor) - { - if (HasTexture) - { - if ((PickedTexture == 15 && SlimeType != "Assorted") || (PickedTexture == 10 || PickedTexture == 12) && SlimeType == "Assorted") - { - Texture2D image = Mod.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinion" + SlimeType + "_" + PickedTexture + "_Glowmask").Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f); - Vector2 stupidOffset = new Vector2(0f, Projectile.gfxOffY - DrawOriginOffsetY); //gfxoffY is for when the projectile is on a slope or half brick - - if (PickedTexture == 15 && SlimeType != "Assorted") //illuminant slime - { - for (int k = Projectile.oldPos.Length - 1; k >= 0; k--) - { - //the higher the k, the older the position - //Length is implicitely set in TrailCacheLength up there - //start from half the length so the origninal sprite isnt super blurred - Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + drawOrigin + stupidOffset; - Color color = Projectile.GetAlpha(Color.White) * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length)) * ((255 - 80) / 255f); - color.A = (byte)(80 * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length))); - Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.oldRot[k], bounds.Size() / 2, Projectile.scale, effect, 0); - } - } - else if ((PickedTexture == 10 || PickedTexture == 12) && SlimeType == "Assorted") - { - Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; - Color fullColor = lightColor; - fullColor.A = 255; - Main.EntitySpriteDraw(image, drawPos, bounds, fullColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); - - if (PickedTexture == 10) - { - //Turtle - image = Mod.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinion" + SlimeType + "_" + PickedTexture + "_Glowmask2").Value; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); - } - } - } - } - } - } - - public class SlimePackAssortedMinion : SlimePackMinion - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Slime Pack Minion"); - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; - - //No trailing - } - - public override void SafeSetDefaults() - { - //used to set dimensions (if necessary) //also use to set projectile.minion - Projectile.width = 32; - Projectile.height = 30; - - Projectile.minion = true; - - SlimeType = "Assorted"; - TotalNumberOfThese = 13; - - shootSpikes = false; - } - } - - public class SlimePackSpikedMinion : SlimePackMinion - { - public override void SafeSetDefaults() - { - //used to set dimensions (if necessary) //also use to set projectile.minion - Projectile.width = 32; - Projectile.height = 30; - - SlimeType = "Spiked"; - TotalNumberOfThese = 16; - - shootSpikes = true; - } - } + [Content(ContentType.Weapons)] + //check this file for more info vvvvvvvv + public class SlimePackMinion : BabySlimeBase + { + public const int DefDamage = 26; + public const float DefKnockback = 4f; //same as slime staff x 2 + public const float SpikedIncrease = 0.4f; + + protected byte TotalNumberOfThese = 16; //16 for default, 13 for assorted, 16 for spiked + + protected string SlimeType = ""; + + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Minions/SlimePackMinions/SlimeMinion" + SlimeType + "_0"; //use fixed texture + } + } + + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Slime Pack Minion"); + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + } + + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; + + Projectile.DamageType = DamageClass.Summon; + Projectile.minion = true; + + shootSpikes = false; + } + + public override void SendExtraAI(BinaryWriter writer) + { + //AssUtils.Print("send netupdate " + PickedTexture + " " + ShootTimer); + writer.Write((byte)PickedTexture); + //writer.Write((byte)ShootTimer); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + PickedTexture = reader.ReadByte(); + //ShootTimer = reader.ReadByte(); + //AssUtils.Print("recv netupdate " + PickedTexture + " " + ShootTimer); + } + + public override bool PreAI() + { + AssPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.slimePackMinion = false; + } + if (modPlayer.slimePackMinion) + { + Projectile.timeLeft = 2; + } + + if (Main.netMode != NetmodeID.Server && Main.myPlayer == Projectile.owner) + { + if (!HasTexture) + { + byte tex = (byte)Main.rand.Next(TotalNumberOfThese); + PickedTexture = tex; + Projectile.netUpdate = true; + } + } + + return true; + } + + public override bool PreDraw(ref Color lightColor) + { + //Rainbow is _5, Illuminant is _15 + if (HasTexture) + { + Texture2D image = Mod.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinion" + SlimeType + "_" + PickedTexture).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Vector2 stupidOffset = new Vector2(0f, Projectile.gfxOffY - DrawOriginOffsetY); //gfxoffY is for when the projectile is on a slope or half brick + SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f); + Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; + + if (PickedTexture == 5 && SlimeType != "Assorted") + { + double cX = Projectile.Center.X + DrawOffsetX; + double cY = Projectile.Center.Y + DrawOriginOffsetY; + lightColor = Lighting.GetColor((int)(cX / 16), (int)(cY / 16), Main.DiscoColor * 1.2f); + } + + Color color = lightColor * ((255 - Projectile.alpha) / 255f); + + if (SlimeType == "Assorted" && (PickedTexture == 0 || + PickedTexture == 5 || + PickedTexture == 6 || + PickedTexture == 7 || + PickedTexture == 11)) color.A = 255; + + if (PickedTexture == 3 && SlimeType != "Assorted") //pinky + { + drawPos.Y += 7f; + Projectile.scale = 0.5f; + } + + Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); + } + return false; + } + + public override void PostDraw(Color lightColor) + { + if (HasTexture) + { + if ((PickedTexture == 15 && SlimeType != "Assorted") || (PickedTexture == 10 || PickedTexture == 12) && SlimeType == "Assorted") + { + Texture2D image = Mod.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinion" + SlimeType + "_" + PickedTexture + "_Glowmask").Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f); + Vector2 stupidOffset = new Vector2(0f, Projectile.gfxOffY - DrawOriginOffsetY); //gfxoffY is for when the projectile is on a slope or half brick + + if (PickedTexture == 15 && SlimeType != "Assorted") //illuminant slime + { + for (int k = Projectile.oldPos.Length - 1; k >= 0; k--) + { + //the higher the k, the older the position + //Length is implicitely set in TrailCacheLength up there + //start from half the length so the origninal sprite isnt super blurred + Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + drawOrigin + stupidOffset; + Color color = Projectile.GetAlpha(Color.White) * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length)) * ((255 - 80) / 255f); + color.A = (byte)(80 * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length))); + Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.oldRot[k], bounds.Size() / 2, Projectile.scale, effect, 0); + } + } + else if ((PickedTexture == 10 || PickedTexture == 12) && SlimeType == "Assorted") + { + Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; + Color fullColor = lightColor; + fullColor.A = 255; + Main.EntitySpriteDraw(image, drawPos, bounds, fullColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); + + if (PickedTexture == 10) + { + //Turtle + image = Mod.Assets.Request("Projectiles/Minions/SlimePackMinions/SlimeMinion" + SlimeType + "_" + PickedTexture + "_Glowmask2").Value; + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); + } + } + } + } + } + } + + public class SlimePackAssortedMinion : SlimePackMinion + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Slime Pack Minion"); + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + ProjectileID.Sets.CultistIsResistantTo[Projectile.type] = true; + + //No trailing + } + + public override void SafeSetDefaults() + { + //used to set dimensions (if necessary) //also use to set projectile.minion + Projectile.width = 32; + Projectile.height = 30; + + Projectile.minion = true; + + SlimeType = "Assorted"; + TotalNumberOfThese = 13; + + shootSpikes = false; + } + } + + public class SlimePackSpikedMinion : SlimePackMinion + { + public override void SafeSetDefaults() + { + //used to set dimensions (if necessary) //also use to set projectile.minion + Projectile.width = 32; + Projectile.height = 30; + + SlimeType = "Spiked"; + TotalNumberOfThese = 16; + + shootSpikes = true; + } + } } diff --git a/Projectiles/Minions/SlimePackMinionSpike.cs b/Projectiles/Minions/SlimePackMinionSpike.cs index dcee4176..3d9fac98 100644 --- a/Projectiles/Minions/SlimePackMinionSpike.cs +++ b/Projectiles/Minions/SlimePackMinionSpike.cs @@ -1,131 +1,131 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.ModLoader; using Terraria.Audio; using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Minions { - [Content(ContentType.Weapons)] - public class SlimePackMinionSpike : AssProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slime Pack Minion Spike"); - Main.projFrames[Projectile.type] = 16; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; - ProjectileID.Sets.MinionShot[Projectile.type] = true; - } + [Content(ContentType.Weapons)] + public class SlimePackMinionSpike : AssProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slime Pack Minion Spike"); + Main.projFrames[Projectile.type] = 16; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.WoodenArrowFriendly); - Projectile.aiStyle = 1; - Projectile.height = 12; - Projectile.width = 12; - Projectile.penetrate = 1; - Projectile.tileCollide = true; - Projectile.friendly = true; - Projectile.hostile = false; - Projectile.DamageType = DamageClass.Summon; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.WoodenArrowFriendly); + Projectile.aiStyle = 1; + Projectile.height = 12; + Projectile.width = 12; + Projectile.penetrate = 1; + Projectile.tileCollide = true; + Projectile.friendly = true; + Projectile.hostile = false; + Projectile.DamageType = DamageClass.Summon; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - return true; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + return true; + } - public byte PickedTexture - { - get - { - return (byte)Projectile.ai[1]; - } - set - { - Projectile.ai[1] = value; - } - } + public byte PickedTexture + { + get + { + return (byte)Projectile.ai[1]; + } + set + { + Projectile.ai[1] = value; + } + } - private Color ColorFromTexture(byte tex) - { - return tex switch - { - 0 => new Color(70, 70, 70), - 1 => new Color(90, 140, 255), - 2 => new Color(10, 180, 40), - 3 => new Color(255, 30, 90), - 4 => new Color(220, 70, 255), - 5 => new Color(110, 110, 110), - 6 => new Color(255, 90, 60), - 7 => new Color(150, 150, 10), - 8 => new Color(160, 70, 22), - 9 => new Color(210, 140, 100), - 10 => new Color(200, 250, 255), - 11 => new Color(80, 80, 140), - 12 => new Color(70, 50, 140), - 13 => new Color(100, 100, 200), - 14 => new Color(200, 99, 100), - 15 => new Color(255, 50, 230), - _ => default(Color), - }; - } + private Color ColorFromTexture(byte tex) + { + return tex switch + { + 0 => new Color(70, 70, 70), + 1 => new Color(90, 140, 255), + 2 => new Color(10, 180, 40), + 3 => new Color(255, 30, 90), + 4 => new Color(220, 70, 255), + 5 => new Color(110, 110, 110), + 6 => new Color(255, 90, 60), + 7 => new Color(150, 150, 10), + 8 => new Color(160, 70, 22), + 9 => new Color(210, 140, 100), + 10 => new Color(200, 250, 255), + 11 => new Color(80, 80, 140), + 12 => new Color(70, 50, 140), + 13 => new Color(100, 100, 200), + 14 => new Color(200, 99, 100), + 15 => new Color(255, 50, 230), + _ => default(Color), + }; + } - public override void PostAI() - { - //projectile.ai[1] used as color picker - if (Projectile.ai[0] < 2) //Uses Arrow AI decrement of ai[0] to play a sound - { - SoundEngine.PlaySound(SoundID.Item17, Projectile.Center); - } + public override void PostAI() + { + //projectile.ai[1] used as color picker + if (Projectile.ai[0] < 2) //Uses Arrow AI decrement of ai[0] to play a sound + { + SoundEngine.PlaySound(SoundID.Item17, Projectile.Center); + } - if (Main.rand.NextFloat() < 0.2f) - { - Vector2 randVelo = new Vector2(Main.rand.NextFloat(0.5f) - 0.25f, Main.rand.NextFloat(0.5f) - 0.25f) + Vector2.Normalize(Projectile.velocity) * 0.5f; - Dust dust = Dust.NewDustPerfect(Projectile.Center, 16, randVelo, 120, ColorFromTexture((byte)Projectile.ai[1]), 0.7f); - dust.fadeIn = 0f; - } - } + if (Main.rand.NextFloat() < 0.2f) + { + Vector2 randVelo = new Vector2(Main.rand.NextFloat(0.5f) - 0.25f, Main.rand.NextFloat(0.5f) - 0.25f) + Vector2.Normalize(Projectile.velocity) * 0.5f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, 16, randVelo, 120, ColorFromTexture((byte)Projectile.ai[1]), 0.7f); + dust.fadeIn = 0f; + } + } - public override bool PreDraw(ref Color lightColor) - { - if (PickedTexture > 15) PickedTexture = 15; //protection against prince slime - SpriteEffects effects = SpriteEffects.None; - Texture2D image = TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: PickedTexture); - Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f); + public override bool PreDraw(ref Color lightColor) + { + if (PickedTexture > 15) PickedTexture = 15; //protection against prince slime + SpriteEffects effects = SpriteEffects.None; + Texture2D image = TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: PickedTexture); + Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f); - if (PickedTexture == 5) - { - double cX = Projectile.Center.X + DrawOffsetX; - double cY = Projectile.Center.Y + DrawOriginOffsetY; - lightColor = Lighting.GetColor((int)(cX / 16), (int)(cY / 16), Main.DiscoColor * 1.2f); - } + if (PickedTexture == 5) + { + double cX = Projectile.Center.X + DrawOffsetX; + double cY = Projectile.Center.Y + DrawOriginOffsetY; + lightColor = Lighting.GetColor((int)(cX / 16), (int)(cY / 16), Main.DiscoColor * 1.2f); + } - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } + return false; + } - public override void PostDraw(Color lightColor) - { - if (PickedTexture == 15) - { - Texture2D image = Mod.Assets.Request("Projectiles/Minions/SlimePackMinionSpike_Glowmask").Value; - SpriteEffects effects = SpriteEffects.None; + public override void PostDraw(Color lightColor) + { + if (PickedTexture == 15) + { + Texture2D image = Mod.Assets.Request("Projectiles/Minions/SlimePackMinionSpike_Glowmask").Value; + SpriteEffects effects = SpriteEffects.None; - for (int k = Projectile.oldPos.Length - 1; k >= 0; k--) - { - Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f); - Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + stupidOffset; - Color color = Projectile.GetAlpha(Color.White) * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length)); - Main.EntitySpriteDraw(image, drawPos, image.Bounds, color, Projectile.rotation, image.Bounds.Size() / 2, Projectile.scale, effects, 0); - } - } - } - } + for (int k = Projectile.oldPos.Length - 1; k >= 0; k--) + { + Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f); + Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + stupidOffset; + Color color = Projectile.GetAlpha(Color.White) * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length)); + Main.EntitySpriteDraw(image, drawPos, image.Bounds, color, Projectile.rotation, image.Bounds.Size() / 2, Projectile.scale, effects, 0); + } + } + } + } } diff --git a/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterHandler.cs b/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterHandler.cs index 18f4cbb8..5b0155cd 100644 --- a/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterHandler.cs +++ b/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterHandler.cs @@ -10,227 +10,227 @@ namespace AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird { - [Content(ContentType.Bosses)] - public class BabyHarvesterHandler : AssSystem - { - public static int WhoAmICache { get; private set; } = Main.maxProjectiles; - public static bool HasWhoAmICache => WhoAmICache >= 0 && WhoAmICache < Main.maxProjectiles; - - public override void PostUpdateProjectiles() - { - TryFindBabyHarvester(out _, out int whoAmICache, fromCache: false); - WhoAmICache = whoAmICache; - - TrySpawnBabyHarvester(); - - ValidateBabyHarvester(); - - TryGiveSoulBuffToEnemies(); - } - - /// - /// Returns true if NPC isn't in soulbuffblacklist or is a worm body or tail - /// - private static bool EligibleToReceiveSoulBuff(NPC npc) - { - if (Array.BinarySearch(AssortedCrazyThings.soulBuffBlacklist, npc.type) >= 0) - { - return false; - } - return !AssUtils.IsWormBodyOrTail(npc); - } - - private static void TryGiveSoulBuffToEnemies() - { - if (TryFindBabyHarvester(out Projectile proj, out _) && - proj.ModProjectile is BabyHarvesterProj babyHarvester && babyHarvester.HasValidPlayerOwner) - { - GiveSoulBuffToNearbyNPCs(babyHarvester.Player, proj.Center); - } - else - { - int index = NPC.FindFirstNPC(AssortedCrazyThings.harvester); - if (index <= -1) - { - return; - } - else - { - var harvesterCenter = Main.npc[index].Center; - for (int i = 0; i < Main.maxPlayers; i++) - { - Player player = Main.player[i]; - - if (player.active && !player.dead) - { - GiveSoulBuffToNearbyNPCs(player, harvesterCenter); - } - } - } - } - } - - private static void GiveSoulBuffToNearbyNPCs(Player player, Vector2 position) - { - if (!IsTurningInvalidPlayer(player, out _) && (ValidPlayer(player) || player.DistanceSQ(position) < 2880 * 2880)) //one and a half screens or in suitable location - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy() && !npc.SpawnedFromStatue && - npc.type != AssortedCrazyThings.harvester && npc.DistanceSQ(player.Center) < 2880 * 2880 && - !npc.GetGlobalNPC().shouldSoulDrop) - { - if (EligibleToReceiveSoulBuff(npc)) - { - npc.AddBuff(ModContent.BuffType(), 60, true); - } - } - } - } - } - - public static bool TryFindBabyHarvester(out Projectile proj, out int index, bool fromCache = true) - { - proj = null; - index = Main.maxProjectiles; - - if (!fromCache) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile other = Main.projectile[i]; - - if (other.active && ValidProjectile(other)) - { - proj = other; - index = i; - break; - } - } - } - else if (HasWhoAmICache) - { - proj = Main.projectile[WhoAmICache]; - index = WhoAmICache; - } - - return proj != null; - } - - private static bool ValidProjectile(Projectile proj) - { - return proj.ModProjectile is BabyHarvesterProj; - } - - /// - /// This handles spawning/despawning, utilizing a delayed condition check to handle edge cases - /// - public static bool ValidPlayer(Player player) - { - return player.GetModPlayer().Valid; - } - - /// - /// True if the condition is about to turn false - /// - public static bool IsTurningInvalidPlayer(Player player, out int timeLeft) - { - return player.GetModPlayer().IsTurningInvalid(out timeLeft); - } - - private static void TrySpawnBabyHarvester() - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - return; - } - - if (HasWhoAmICache) - { - //Delete any possible duplicates - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - - if (proj.active && ValidProjectile(proj) && i != WhoAmICache) - { - //AssUtils.Print("deleted a duplicate"); - proj.Kill(); - } - } - - //Do not spawn - return; - } - - if (AssWorld.downedHarvester || NPC.AnyNPCs(AssortedCrazyThings.harvester)) - { - //Do not spawn another one if harvester is already slain or alive - return; - } - - //No alive baby harvester, spawn - for (int i = 0; i < Main.maxPlayers; i++) - { - Player player = Main.player[i]; - - if (player.active && !player.dead && ValidPlayer(player)) - { - //AssUtils.Print(Main.time + " spawning harvester"); - BabyHarvesterProj.Spawn(player); - AssWorld.Message("You hear a faint cawing from the dungeon.", Harvester.deathColor); - - break; - } - } - } - - private static void ValidateBabyHarvester() - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - return; - } - - if (!TryFindBabyHarvester(out Projectile proj, out _)) - { - return; - } - - if (!(proj.ModProjectile is BabyHarvesterProj babyHarvester && babyHarvester.HasValidPlayerOwner)) - { - return; - } - - //If current player dead or not suitable anymore - Player playerowner = babyHarvester.Player; - if (!playerowner.dead && ValidPlayer(playerowner)) - { - return; - } - - //Find new suitable player, reassign owner - bool found = false; - for (int i = 0; i < Main.maxPlayers; i++) - { - Player player = Main.player[i]; - - if (player.active && !player.dead && ValidPlayer(player)) - { - //AssUtils.Print($"{Main.time} assign new player to harvester from {babyHarvester.PlayerOwner} to {i}"); - babyHarvester.AssignPlayerOwner(i); - found = true; - break; - } - } - - //If not found, despawn - if (!found) - { - //AssUtils.Print("despawning harvester"); - proj.Kill(); - } - } - } + [Content(ContentType.Bosses)] + public class BabyHarvesterHandler : AssSystem + { + public static int WhoAmICache { get; private set; } = Main.maxProjectiles; + public static bool HasWhoAmICache => WhoAmICache >= 0 && WhoAmICache < Main.maxProjectiles; + + public override void PostUpdateProjectiles() + { + TryFindBabyHarvester(out _, out int whoAmICache, fromCache: false); + WhoAmICache = whoAmICache; + + TrySpawnBabyHarvester(); + + ValidateBabyHarvester(); + + TryGiveSoulBuffToEnemies(); + } + + /// + /// Returns true if NPC isn't in soulbuffblacklist or is a worm body or tail + /// + private static bool EligibleToReceiveSoulBuff(NPC npc) + { + if (Array.BinarySearch(AssortedCrazyThings.soulBuffBlacklist, npc.type) >= 0) + { + return false; + } + return !AssUtils.IsWormBodyOrTail(npc); + } + + private static void TryGiveSoulBuffToEnemies() + { + if (TryFindBabyHarvester(out Projectile proj, out _) && + proj.ModProjectile is BabyHarvesterProj babyHarvester && babyHarvester.HasValidPlayerOwner) + { + GiveSoulBuffToNearbyNPCs(babyHarvester.Player, proj.Center); + } + else + { + int index = NPC.FindFirstNPC(AssortedCrazyThings.harvester); + if (index <= -1) + { + return; + } + else + { + var harvesterCenter = Main.npc[index].Center; + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + + if (player.active && !player.dead) + { + GiveSoulBuffToNearbyNPCs(player, harvesterCenter); + } + } + } + } + } + + private static void GiveSoulBuffToNearbyNPCs(Player player, Vector2 position) + { + if (!IsTurningInvalidPlayer(player, out _) && (ValidPlayer(player) || player.DistanceSQ(position) < 2880 * 2880)) //one and a half screens or in suitable location + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy() && !npc.SpawnedFromStatue && + npc.type != AssortedCrazyThings.harvester && npc.DistanceSQ(player.Center) < 2880 * 2880 && + !npc.GetGlobalNPC().shouldSoulDrop) + { + if (EligibleToReceiveSoulBuff(npc)) + { + npc.AddBuff(ModContent.BuffType(), 60, true); + } + } + } + } + } + + public static bool TryFindBabyHarvester(out Projectile proj, out int index, bool fromCache = true) + { + proj = null; + index = Main.maxProjectiles; + + if (!fromCache) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile other = Main.projectile[i]; + + if (other.active && ValidProjectile(other)) + { + proj = other; + index = i; + break; + } + } + } + else if (HasWhoAmICache) + { + proj = Main.projectile[WhoAmICache]; + index = WhoAmICache; + } + + return proj != null; + } + + private static bool ValidProjectile(Projectile proj) + { + return proj.ModProjectile is BabyHarvesterProj; + } + + /// + /// This handles spawning/despawning, utilizing a delayed condition check to handle edge cases + /// + public static bool ValidPlayer(Player player) + { + return player.GetModPlayer().Valid; + } + + /// + /// True if the condition is about to turn false + /// + public static bool IsTurningInvalidPlayer(Player player, out int timeLeft) + { + return player.GetModPlayer().IsTurningInvalid(out timeLeft); + } + + private static void TrySpawnBabyHarvester() + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + return; + } + + if (HasWhoAmICache) + { + //Delete any possible duplicates + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + + if (proj.active && ValidProjectile(proj) && i != WhoAmICache) + { + //AssUtils.Print("deleted a duplicate"); + proj.Kill(); + } + } + + //Do not spawn + return; + } + + if (AssWorld.downedHarvester || NPC.AnyNPCs(AssortedCrazyThings.harvester)) + { + //Do not spawn another one if harvester is already slain or alive + return; + } + + //No alive baby harvester, spawn + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + + if (player.active && !player.dead && ValidPlayer(player)) + { + //AssUtils.Print(Main.time + " spawning harvester"); + BabyHarvesterProj.Spawn(player); + AssWorld.Message("You hear a faint cawing from the dungeon.", Harvester.deathColor); + + break; + } + } + } + + private static void ValidateBabyHarvester() + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + return; + } + + if (!TryFindBabyHarvester(out Projectile proj, out _)) + { + return; + } + + if (!(proj.ModProjectile is BabyHarvesterProj babyHarvester && babyHarvester.HasValidPlayerOwner)) + { + return; + } + + //If current player dead or not suitable anymore + Player playerowner = babyHarvester.Player; + if (!playerowner.dead && ValidPlayer(playerowner)) + { + return; + } + + //Find new suitable player, reassign owner + bool found = false; + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + + if (player.active && !player.dead && ValidPlayer(player)) + { + //AssUtils.Print($"{Main.time} assign new player to harvester from {babyHarvester.PlayerOwner} to {i}"); + babyHarvester.AssignPlayerOwner(i); + found = true; + break; + } + } + + //If not found, despawn + if (!found) + { + //AssUtils.Print("despawning harvester"); + proj.Kill(); + } + } + } } diff --git a/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterPlayer.cs b/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterPlayer.cs index e05e0a50..b61b530c 100644 --- a/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterPlayer.cs +++ b/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterPlayer.cs @@ -2,42 +2,42 @@ namespace AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird { - [Content(ContentType.Bosses)] - public class BabyHarvesterPlayer : AssPlayerBase - { - public const int TimeOutsideConditionMax = 300; - private int timeOutsideCondition = TimeOutsideConditionMax; //Set Valid to false by default + [Content(ContentType.Bosses)] + public class BabyHarvesterPlayer : AssPlayerBase + { + public const int TimeOutsideConditionMax = 300; + private int timeOutsideCondition = TimeOutsideConditionMax; //Set Valid to false by default - public bool Valid => timeOutsideCondition < TimeOutsideConditionMax; + public bool Valid => timeOutsideCondition < TimeOutsideConditionMax; - /// - /// Returns true if outside vanilla condition, with timeLeft being assigned the time left until it is fully counted as invalid (ending at 0) - /// - public bool IsTurningInvalid(out int timeLeft) - { - timeLeft = TimeOutsideConditionMax - timeOutsideCondition; + /// + /// Returns true if outside vanilla condition, with timeLeft being assigned the time left until it is fully counted as invalid (ending at 0) + /// + public bool IsTurningInvalid(out int timeLeft) + { + timeLeft = TimeOutsideConditionMax - timeOutsideCondition; - return timeOutsideCondition > 0; - } + return timeOutsideCondition > 0; + } - private bool VanillaCondition() - { - return Player.ZoneDungeon; - } + private bool VanillaCondition() + { + return Player.ZoneDungeon; + } - public override void PostUpdateEquips() - { - if (!VanillaCondition()) - { - if (timeOutsideCondition < TimeOutsideConditionMax) - { - timeOutsideCondition++; - } - } - else - { - timeOutsideCondition = 0; - } - } - } + public override void PostUpdateEquips() + { + if (!VanillaCondition()) + { + if (timeOutsideCondition < TimeOutsideConditionMax) + { + timeOutsideCondition++; + } + } + else + { + timeOutsideCondition = 0; + } + } + } } diff --git a/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterProj.cs b/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterProj.cs index 00f8a0fc..1e05a7cd 100644 --- a/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterProj.cs +++ b/Projectiles/NPCs/Bosses/DungeonBird/BabyHarvesterProj.cs @@ -16,882 +16,882 @@ namespace AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird { - //This projectile represents all 3 stages of the pre-harvester boss encounter - [Content(ContentType.Bosses)] - public class BabyHarvesterProj : AssProjectile - { - public class TierData - { - public int FrameSpeed { get; init; } = 4; - public int SoulsToNextTier { get; init; } = 1; - public int TransformationFrameCount { get; init; } = 1; - - public TierData() - { - - } - } - - //Synced - public int PlayerOwner { get; private set; } = Main.maxPlayers; - - public bool HasValidPlayerOwner => PlayerOwner >= 0 && PlayerOwner < Main.maxPlayers; - - public Player Player => Main.player[PlayerOwner]; - - public int SoulsEaten - { - get => (int)Projectile.ai[0]; - private set => Projectile.ai[0] = value; - } - - //Not synced, used for MP application of visuals - public int PrevSoulsEaten { get; private set; } - - public const int MaxTier = 3; - public int Tier - { - get - { - foreach (var item in SoulsEatenToTier) - { - if (SoulsEaten < item.Key) - { - return Math.Min(item.Value, MaxTier); - } - } - - return MaxTier; - } - } - - //Not synced, used for sequencing soul eating behavior and transformation - public float Timer { get; private set; } - - //If below 0, currently cooling down from previous transformation. above 0, current transformation ongoing - public int CurrentTrafoTier - { - get => (int)Projectile.ai[1]; - private set => Projectile.ai[1] = value; - } - - public bool TrafoInProgress => CurrentTrafoTier > 0; - - public bool TrafoInProgressVisual => TrafoInProgress && TrafoTimer >= Time_TrafoStart; - - public bool TrafoInCooldown => CurrentTrafoTier < 0; - - //Not synced, only used by the server - public int PrevTier - { - get => (int)Projectile.localAI[0] + 1; //Since ai is initialized as 0, tier should be 1 - private set => Projectile.localAI[0] = value - 1; - } - - //Not synced - public int TrafoFrameY - { - get => (int)Projectile.localAI[1]; - private set => Projectile.localAI[1] = value; - } - - //Not synced - public int TrafoTimer { get; private set; } - - /* + //This projectile represents all 3 stages of the pre-harvester boss encounter + [Content(ContentType.Bosses)] + public class BabyHarvesterProj : AssProjectile + { + public class TierData + { + public int FrameSpeed { get; init; } = 4; + public int SoulsToNextTier { get; init; } = 1; + public int TransformationFrameCount { get; init; } = 1; + + public TierData() + { + + } + } + + //Synced + public int PlayerOwner { get; private set; } = Main.maxPlayers; + + public bool HasValidPlayerOwner => PlayerOwner >= 0 && PlayerOwner < Main.maxPlayers; + + public Player Player => Main.player[PlayerOwner]; + + public int SoulsEaten + { + get => (int)Projectile.ai[0]; + private set => Projectile.ai[0] = value; + } + + //Not synced, used for MP application of visuals + public int PrevSoulsEaten { get; private set; } + + public const int MaxTier = 3; + public int Tier + { + get + { + foreach (var item in SoulsEatenToTier) + { + if (SoulsEaten < item.Key) + { + return Math.Min(item.Value, MaxTier); + } + } + + return MaxTier; + } + } + + //Not synced, used for sequencing soul eating behavior and transformation + public float Timer { get; private set; } + + //If below 0, currently cooling down from previous transformation. above 0, current transformation ongoing + public int CurrentTrafoTier + { + get => (int)Projectile.ai[1]; + private set => Projectile.ai[1] = value; + } + + public bool TrafoInProgress => CurrentTrafoTier > 0; + + public bool TrafoInProgressVisual => TrafoInProgress && TrafoTimer >= Time_TrafoStart; + + public bool TrafoInCooldown => CurrentTrafoTier < 0; + + //Not synced, only used by the server + public int PrevTier + { + get => (int)Projectile.localAI[0] + 1; //Since ai is initialized as 0, tier should be 1 + private set => Projectile.localAI[0] = value - 1; + } + + //Not synced + public int TrafoFrameY + { + get => (int)Projectile.localAI[1]; + private set => Projectile.localAI[1] = value; + } + + //Not synced + public int TrafoTimer { get; private set; } + + /* - Fly to soul, pause next to it for quarter of a second. Keeps flapping. - Absorb soul, remain stationary for 1 second. Keeps flapping. - When enough souls are absorbed to trigger transforming, remain stationary for 3 seconds before transforming. - After transforming, stay stationary for 2 seconds and prevents eating in that time. Keeps flapping. */ - public const int Time_PreSoulEat = 15; - public const int Time_PostSoulEat = Time_PreSoulEat + 60; - public const int Time_TrafoStart = 150; - public const int Time_TrafoCooldown = 120; - - public Color overlayColor = Color.White; - - private float fadingAuraAlphaIntensity = 0f; - private float fadingAuraScaleIntensity = 0f; - private int fadingAuraTimerMax = 0; - private int fadingAuraTimer = 0; - - private bool drawBehind = true; - private bool firstEmote = false; - private int hungryEmoteTimer = 0; - private int hungryEmoteTimerMax = 400; - - private int oldSoulTarget = Main.maxNPCs; - - public static Dictionary> SheetAssets; - public static Dictionary> WingAssets; - public static Dictionary> TransformationAssets; - public static Dictionary> TransformationWingAssets; - - //Transformations are indexed by the "from" tier in "from -> to" - public static Dictionary TierDatas; - private static Dictionary TierToSoulsEaten; - private static Dictionary SoulsEatenToTier; - - public static int Spawn(Player player) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - return Main.maxProjectiles; - } - - Vector2 position = player.Center; - position.X += Main.rand.NextFloat(-1980, 1980) / 2; - position.Y += 1000; - - return AssUtils.NewProjectile(new EntitySource_WorldEvent(), position, Vector2.Zero, ModContent.ProjectileType(), 0, 0, - preSync: (Projectile proj) => (proj.ModProjectile as BabyHarvesterProj).AssignPlayerOwner(player.whoAmI)); - } - - public override void Load() - { - if (!Main.dedServ) - { - SheetAssets = new Dictionary>(); - WingAssets = new Dictionary>(); - TransformationAssets = new Dictionary>(); - TransformationWingAssets = new Dictionary>(); - - for (int i = 1; i <= MaxTier; i++) - { - SheetAssets.Add(i, ModContent.Request(Texture + i + "_Sheet")); - } - - //1 has no wing glowmask - for (int i = 2; i <= MaxTier; i++) - { - WingAssets.Add(i, ModContent.Request(Texture + i + "_Sheet_Wings")); - } - - for (int i = 1; i <= MaxTier; i++) - { - TransformationAssets.Add(i, ModContent.Request(Texture + "_Transformation" + i)); - TransformationWingAssets.Add(i, ModContent.Request(Texture + "_Transformation" + i + "_Glowmask")); - } - } - - TierDatas = new Dictionary() - { - [1] = new TierData - { - FrameSpeed = 3, - SoulsToNextTier = 1, - TransformationFrameCount = 7, - }, - [2] = new TierData - { - FrameSpeed = 4, - SoulsToNextTier = 5, - TransformationFrameCount = 9, - }, - [3] = new TierData - { - FrameSpeed = 4, - SoulsToNextTier = 10, - TransformationFrameCount = 10, - }, - [4] = new TierData //Dummy tier, used to detect last tier switch into main form - { - SoulsToNextTier = 999 - }, - }; - - SoulsEatenToTier = new Dictionary(); - TierToSoulsEaten = new Dictionary(); - int soulsAccumulated = 0; - foreach (var data in TierDatas) - { - soulsAccumulated += data.Value.SoulsToNextTier; - SoulsEatenToTier.Add(soulsAccumulated, data.Key); - TierToSoulsEaten.Add(data.Key, soulsAccumulated); - } - } - - public override void Unload() - { - SheetAssets = null; - WingAssets = null; - TransformationAssets = null; - TransformationWingAssets = null; - - TierDatas = null; - SoulsEatenToTier = null; - TierToSoulsEaten = null; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Baby Bird"); - Main.projFrames[Projectile.type] = 5; - - ProjectileID.Sets.DontAttachHideToAlpha[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - Projectile.hide = true; - Projectile.aiStyle = -1; - Projectile.width = 32; - Projectile.height = 32; - Projectile.netImportant = true; - Projectile.timeLeft = int.MaxValue / 2; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write((byte)PlayerOwner); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - PlayerOwner = reader.ReadByte(); - } - - public void AssignPlayerOwner(int newPlayer) - { - bool sync = HasValidPlayerOwner; - - PlayerOwner = newPlayer; - - if (sync) - { - //If switching player, sync immediately - Projectile.NetSync(); - } - } - - public void AddSoulsEaten() - { - if (Main.myPlayer == Projectile.owner) - { - //AssUtils.Print(Main.time + " increased souls eaten"); - SoulsEaten++; - - //Has to be after SoulsEaten is modified - if (PrevTier < Tier) - { - //Initiate transformation - CurrentTrafoTier = PrevTier; - } - PrevTier = Tier; - - if (TierToSoulsEaten.TryGetValue(MaxTier, out var v)) - { - if (SoulsEaten >= v) - { - //Transform into last stage - CurrentTrafoTier = PrevTier; - } - } - - Projectile.NetSync(); - } - } - - private void HandleSoulEatingVisuals() - { - overlayColor = Color.Lerp(overlayColor, Color.White, 0.1f); - } - - private void SetFadingAura(int alphaTimer, float alphaIntensity = 0.8f, float scaleIntensity = 0.5f) - { - fadingAuraTimerMax = fadingAuraTimer = alphaTimer; - fadingAuraAlphaIntensity = alphaIntensity; - fadingAuraScaleIntensity = scaleIntensity; - } - - private void HandleFadingAura() - { - if (fadingAuraTimer > 0) - { - fadingAuraTimer--; - } - else - { - fadingAuraTimerMax = 0; - fadingAuraAlphaIntensity = 0f; - fadingAuraScaleIntensity = 0f; - } - } - - private void HandleWingDust() - { - if (TrafoInProgressVisual) - { - return; - } - - if (Tier == 1 || CurrentTrafoTier == 1) - { - return; - } - - if (!TierToSoulsEaten.TryGetValue(MaxTier, out var maxSoulsEaten)) - { - return; - } - - Vector2 offset = Vector2.Zero; - Vector2 size = Projectile.Size; - - if (CurrentTrafoTier != 2 && Tier == 3) - { - offset.X += Projectile.width; - float y = Projectile.frame switch - { - 0 => -Projectile.height / 1.5f, - 2 => Projectile.height / 1.5f, - _ => 0, - }; - offset.Y += y; - } - else - { - size += -Vector2.One * 6; - - offset.X += Projectile.width / 2f; - float y = Projectile.frame switch - { - 0 => -Projectile.height / 2.5f, - 2 => Projectile.height / 2.5f, - _ => 0, - }; - offset.Y += y; - } - - for (int i = -1; i <= 1; i += 2) - { - Vector2 dustCenter = Projectile.Center + new Vector2(offset.X * i, offset.Y).RotatedBy(Projectile.rotation); - Rectangle dustBox = Utils.CenteredRectangle(dustCenter, size); - - if (Main.rand.NextFloat() < 0.5f * (float)SoulsEaten / maxSoulsEaten) - { - Dust dust = Dust.NewDustDirect(dustBox.TopLeft(), dustBox.Width, dustBox.Height, 135, 0f, 0f, 0, default(Color), 1.5f); - dust.noGravity = true; - dust.noLight = true; - dust.velocity *= 0.3f; - if (Main.rand.NextBool(5)) - { - dust.fadeIn = 1f; - } - } - } - } - - private void HandleLeavingCondition() - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int time = 100; - if (BabyHarvesterHandler.IsTurningInvalidPlayer(Player, out int timeLeft)) - { - if (timeLeft % time == time - 1) //So it triggers at the start, and not close at the end - { - EmoteBubble.NewBubble(EmoteID.EmotionCry, new WorldUIAnchor(Projectile), time); - } - } - } - } - - private int SoulTargetClosest(float maxDistance = 1000f) - { - short closest = Main.maxNPCs; - Vector2 toSoul; - float oldDistance = maxDistance; - float newDistance; - for (short j = 0; j < Main.maxNPCs; j++) - { - //ignore souls if they are noclipping - NPC other = Main.npc[j]; - if (other.active && other.type == ModContent.NPCType()) - { - toSoul = other.Center - Projectile.Center; - newDistance = toSoul.Length(); - if (newDistance < oldDistance) - { - oldDistance = newDistance; - closest = j; - } - } - } - return closest; - } - - public override void AI() - { - if (!HasValidPlayerOwner) - { - Projectile.Kill(); - return; - } - //Player is now valid here - - if (!Player.active) - { - //Wait for revalidation (player disconnecting causes position of the player to be reset to 0,0, despawning the projectiles because its oob) - //If no other suitable player is found, it gets despawned by the handler - return; - } - - //Client the bird is attached to gives himself the buff - //Buff is cleared automatically from any player the bird is not following - if (Main.myPlayer == Player.whoAmI) - { - int buffType = ModContent.BuffType(); - if (!Player.HasBuff(buffType)) - { - Player.AddBuff(buffType, 1600); - } - } - - HandleSoulEatingVisuals(); - - HandleFadingAura(); - - HandleWingDust(); - - HandleLeavingCondition(); - - //Main.NewText("t: " + Tier); - //Main.NewText("c: " + CurrentTrafoTier); - - bool animate = true; - if (!TrafoInProgress) - { - if (!TrafoInCooldown) - { - RegularAI(); - } - else - { - //Main.NewText("in trafo cooldown " + CurrentTrafoTier); - CurrentTrafoTier++; - - if (CurrentTrafoTier < -30) - { - Projectile.velocity.Y = -0.025f; - } - } - } - else - { - animate = TransformationAI(); - } - - if (animate) - { - int frameSpeed = 4; - if (TierDatas.TryGetValue(Tier, out var data)) - { - frameSpeed = data.FrameSpeed; - } - - if (Projectile.velocity.LengthSquared() < 2 * 2) - { - frameSpeed++; - } - AssAI.ZephyrfishDraw(Projectile, frameSpeed); - } - } - - private void RegularAI() - { - drawBehind = true; - int soulTarget = Main.maxNPCs; - if (Timer <= Time_PreSoulEat) - { - //Main.NewText("in pre soul eat " + Timer); - soulTarget = SoulTargetClosest(); - } - if (soulTarget != Main.maxNPCs) - { - if (soulTarget != oldSoulTarget) - { - if (Tier == 1) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - EmoteBubble.NewBubble(EmoteID.ItemBugNet, new WorldUIAnchor(Projectile), 120); - } - } - } - oldSoulTarget = soulTarget; - - NPC soul = Main.npc[soulTarget]; - - Vector2 toSoul = soul.Center - Projectile.Center; - Vector2 offsetTier = Tier switch - { - 1 => new Vector2(30, -20), - 2 => new Vector2(40, -25), - 3 => new Vector2(50, -30), - _ => Vector2.Zero, - }; - offsetTier.X *= -Math.Sign(soul.Center.X - Player.Center.X); - - Vector2 soulPos = soul.Center + offsetTier; - Vector2 toSoulResting = soulPos - Projectile.Center; - float distanceSQ = toSoulResting.LengthSquared(); - - if (distanceSQ > 10 * 10) - { - //Approach soul - Timer = 0; - float speed = 8f; - float inertia = 16; - - if (distanceSQ < 100 * 100) - { - speed = 3f; - inertia = 3; - } - - Vector2 toSoulSpeed = toSoulResting.SafeNormalize(Vector2.UnitY) * speed; - Projectile.velocity = (Projectile.velocity * (inertia - 1) + toSoulSpeed) / inertia; - Projectile.direction = Math.Sign(toSoul.X); - Projectile.spriteDirection = Projectile.direction; - Projectile.rotation = Projectile.velocity.X * 0.05f; - } - else - { - //Next to soul - if (Tier == 1) - { - Timer += 0.2f; - } - else - { - Timer++; - } - Projectile.velocity *= 0.8f; - Projectile.rotation *= 0.8f; - - if (Math.Abs(Projectile.velocity.X) < 0.1f) - { - Projectile.netUpdate = true; - Projectile.velocity *= 0f; - Projectile.rotation = 0; - } - - if (Timer > Time_PreSoulEat) - { - //Destroy soul and spawn a homing projectile which increases the soul count - if (Main.myPlayer == Projectile.owner) - { - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), soul.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); - - //AssUtils.Print(Main.time + " spawned homing soul"); - } - - soul.life = 0; - soul.active = false; - soul.netUpdate = true; - - Projectile.netUpdate = true; - } - } - - } - else if (Timer == 0) - { - Vector2 offset = Vector2.Zero; - float veloFactor = 0.9f; - float sway = 1f; - bool random = true; - - if (Tier == 1) - { - if (!firstEmote) - { - firstEmote = true; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - EmoteBubble.NewBubble(EmoteID.BossSkeletron, new WorldUIAnchor(Projectile), 240); - } - } - - hungryEmoteTimer++; - if (hungryEmoteTimer > hungryEmoteTimerMax) - { - hungryEmoteTimer = 0; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - EmoteBubble.NewBubble(EmoteID.EmotionAlert, new WorldUIAnchor(Projectile), 120); - } - } - - offset = new Vector2(-60, 40); - veloFactor = 1f; - sway = 1.3f; - - drawBehind = Projectile.direction == 1; - - //if something: drawBehind = false - float rot = Projectile.velocity.ToRotation(); - if (Projectile.direction == 1) - { - rot = MathHelper.Pi - Math.Abs(rot); - } - //The above normalizes rot to number always around 0 - float thres = MathHelper.PiOver4 / 2; - - //attempt to "flatten" velocity, prefer moving horizontally - Rectangle flattenRect = Player.Hitbox; - flattenRect.Inflate(0, 20); - if (Projectile.Hitbox.Intersects(flattenRect) && rot > thres) - { - float by = 1 / 50f; - by *= Projectile.direction * Math.Sign(rot); - if (Projectile.direction == 1) - { - by *= -1; - } - Projectile.velocity = Projectile.velocity.RotatedBy(by); - - //Always keep min speed - float minSpeed = 2.4f; - if (Projectile.velocity.LengthSquared() < minSpeed * minSpeed) - { - Projectile.velocity = Utils.SafeNormalize(Projectile.velocity, Vector2.UnitY); - Projectile.velocity *= minSpeed; - } - } - } - - AssAI.ZephyrfishAI(Projectile, Player, veloFactor, sway, random, offsetX: offset.X, offsetY: offset.Y); - Projectile.spriteDirection = -Projectile.spriteDirection; - } - else - { - Timer++; - if (Timer > Time_PostSoulEat) - { - Timer = 0; - Projectile.netUpdate = true; - } - else - { - //Main.NewText("in post soul eat " + Timer); - } - } - } - - //Returns true if it should keep animating - private bool TransformationAI() - { - //Runs on all clients, does not need any syncing to stop - Projectile.velocity *= 0.4f; - Projectile.rotation *= 0.8f; - - if (CurrentTrafoTier == MaxTier) - { - Projectile.rotation = 0f; - } - - if (!TierDatas.TryGetValue(CurrentTrafoTier, out var data)) - { - return true; - } - - TrafoTimer++; - if (TrafoTimer <= Time_TrafoStart) - { - int thres = 50; - if (TrafoTimer % thres == 0) - { - int step = TrafoTimer / thres; - overlayColor = new Color(195, 247, 255) * (0.6f - 0.2f * step); - overlayColor.A = 255; - } - //Main.NewText("in trafo start " + TrafoTimer); - return true; - } - - int threshold = Time_TrafoStart; - if (TrafoTimer > 3 + threshold) - { - TrafoFrameY++; - TrafoTimer = threshold; - } - if (TrafoFrameY >= data.TransformationFrameCount) - { - Projectile.frame = 0; - Projectile.frameCounter = 0; - TrafoTimer = 0; - TrafoFrameY = 0; - - if (CurrentTrafoTier == MaxTier) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = AssortedCrazyThings.harvester; - if (!NPC.AnyNPCs(type)) - { - int yOffset = 62; //Manually adjusted - int index = NPC.NewNPC(new EntitySource_BossSpawn(Player), (int)Projectile.Center.X, (int)Projectile.Center.Y + yOffset, type); - if (index < Main.maxNPCs && Main.npc[index] is NPC npc && npc.ModNPC is Harvester harvester) - { - harvester.AI_State = Harvester.State_SpawnedByBaby; - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.SyncNPC, number: index); - } - } - - AssWorld.AwakeningMessage(Harvester.name + " has been awakened!"); - } - - Projectile.Kill(); - } - } - else - { - Vector2 dustOffset = new Vector2(0, 20); - Vector2 center = Projectile.Center; - for (int i = 0; i < 10 + CurrentTrafoTier * 10; i++) - { - Vector2 dustOffset2 = dustOffset.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.1f, 1f); - Dust dust = Dust.NewDustPerfect(center + dustOffset2, 59, newColor: Color.White, Scale: 2.1f); - dust.noLight = true; - dust.noGravity = true; - dust.fadeIn = Main.rand.NextFloat(0.2f, 0.8f); - dust.velocity = Utils.SafeNormalize(dust.position - center, Vector2.Zero) * 3; - } - - SoundEngine.PlaySound(SoundID.Item8, Projectile.Center); - } - - CurrentTrafoTier = -Time_TrafoCooldown; //Reset trafo - Projectile.netUpdate = true; - } - - return false; - } - - public override void PostAI() - { - if (PrevSoulsEaten < SoulsEaten) - { - //AssUtils.Print(Main.time + " souls eaten visuals"); - - overlayColor = new Color(195, 247, 255) * 0.7f; - overlayColor.A = 255; - SetFadingAura(30); - - SoundEngine.PlaySound(SoundID.Item8, Projectile.Center); - } - - PrevSoulsEaten = SoulsEaten; - } - - public override bool? CanCutTiles() - { - return false; - } - - public override void Kill(int timeLeft) - { - for (int i = 0; i < 20; i++) - { - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); - Dust dust = Main.dust[d]; - dust.noGravity = true; - dust.velocity *= 1.5f; - dust.scale = 1.3f; - } - } - - public override Color? GetAlpha(Color lightColor) - { - return Color.Lerp(lightColor, Color.White, 0.4f).MultiplyRGBA(overlayColor) * Projectile.Opacity; - } - - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) - { - (drawBehind ? behindNPCs : overPlayers).Add(index); - } - - public override bool PreDraw(ref Color lightColor) - { - //Custom draw to just center on the hitbox, as all birds share the same frame size (for seamless transformation) - Texture2D texture = null; - int frameCount = 1; - int frameY = 0; - int tier = TrafoInProgress ? CurrentTrafoTier : Tier; - if (TrafoInProgressVisual && TransformationAssets.TryGetValue(tier, out var trafoAsset)) - { - texture = trafoAsset.Value; - - if (TierDatas.TryGetValue(tier, out var data)) - { - frameCount = data.TransformationFrameCount; - } - frameY = TrafoFrameY; - } - else if (SheetAssets.TryGetValue(tier, out var asset)) - { - texture = asset.Value; - frameCount = Main.projFrames[Projectile.type]; - frameY = Projectile.frame; - } - - if (texture == null) - { - return false; - } - - Rectangle sourceRect = texture.Frame(1, frameCount, frameY: frameY); - Vector2 drawOrigin = sourceRect.Size() / 2f; - - SpriteEffects spriteEffects = Projectile.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - - Vector2 drawPos = Projectile.position + Projectile.Size / 2f + new Vector2(0, Projectile.gfxOffY + 4f - 1f) - Main.screenPosition; - Color color = Projectile.GetAlpha(lightColor); - - float rotation = Projectile.rotation; - float scale = Projectile.scale; - Main.EntitySpriteDraw(texture, drawPos, sourceRect, color, rotation, drawOrigin, scale, spriteEffects, 0); - - Texture2D wingTexture = null; - if (TrafoInProgressVisual && TransformationWingAssets.TryGetValue(tier, out var trafoWingAsset)) - { - wingTexture = trafoWingAsset.Value; - } - else if (WingAssets.TryGetValue(tier, out var wingAsset)) - { - wingTexture = wingAsset.Value; - } - - Color wingColor = Projectile.GetAlpha(Color.White); - if (wingTexture != null) - { - Main.EntitySpriteDraw(wingTexture, drawPos, sourceRect, wingColor, rotation, drawOrigin, scale, spriteEffects, 0); - } - - if (fadingAuraTimer > 0 && fadingAuraTimerMax > 0) - { - float fadeScale = fadingAuraTimer / (float)fadingAuraTimerMax; - float scaleInverse = 1f - fadeScale; - Color auraColor = color * fadeScale * fadingAuraAlphaIntensity; - Color auraWingColor = wingColor * fadeScale * fadingAuraAlphaIntensity; - float auraScale = scale + scaleInverse * fadingAuraScaleIntensity; - - Main.EntitySpriteDraw(texture, drawPos, sourceRect, auraColor, rotation, drawOrigin, scale, spriteEffects, 0); - - if (wingTexture != null) - { - Main.EntitySpriteDraw(wingTexture, drawPos, sourceRect, auraWingColor, rotation, drawOrigin, auraScale, spriteEffects, 0); - } - } - - return false; - } - } + public const int Time_PreSoulEat = 15; + public const int Time_PostSoulEat = Time_PreSoulEat + 60; + public const int Time_TrafoStart = 150; + public const int Time_TrafoCooldown = 120; + + public Color overlayColor = Color.White; + + private float fadingAuraAlphaIntensity = 0f; + private float fadingAuraScaleIntensity = 0f; + private int fadingAuraTimerMax = 0; + private int fadingAuraTimer = 0; + + private bool drawBehind = true; + private bool firstEmote = false; + private int hungryEmoteTimer = 0; + private int hungryEmoteTimerMax = 400; + + private int oldSoulTarget = Main.maxNPCs; + + public static Dictionary> SheetAssets; + public static Dictionary> WingAssets; + public static Dictionary> TransformationAssets; + public static Dictionary> TransformationWingAssets; + + //Transformations are indexed by the "from" tier in "from -> to" + public static Dictionary TierDatas; + private static Dictionary TierToSoulsEaten; + private static Dictionary SoulsEatenToTier; + + public static int Spawn(Player player) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + return Main.maxProjectiles; + } + + Vector2 position = player.Center; + position.X += Main.rand.NextFloat(-1980, 1980) / 2; + position.Y += 1000; + + return AssUtils.NewProjectile(new EntitySource_WorldEvent(), position, Vector2.Zero, ModContent.ProjectileType(), 0, 0, + preSync: (Projectile proj) => (proj.ModProjectile as BabyHarvesterProj).AssignPlayerOwner(player.whoAmI)); + } + + public override void Load() + { + if (!Main.dedServ) + { + SheetAssets = new Dictionary>(); + WingAssets = new Dictionary>(); + TransformationAssets = new Dictionary>(); + TransformationWingAssets = new Dictionary>(); + + for (int i = 1; i <= MaxTier; i++) + { + SheetAssets.Add(i, ModContent.Request(Texture + i + "_Sheet")); + } + + //1 has no wing glowmask + for (int i = 2; i <= MaxTier; i++) + { + WingAssets.Add(i, ModContent.Request(Texture + i + "_Sheet_Wings")); + } + + for (int i = 1; i <= MaxTier; i++) + { + TransformationAssets.Add(i, ModContent.Request(Texture + "_Transformation" + i)); + TransformationWingAssets.Add(i, ModContent.Request(Texture + "_Transformation" + i + "_Glowmask")); + } + } + + TierDatas = new Dictionary() + { + [1] = new TierData + { + FrameSpeed = 3, + SoulsToNextTier = 1, + TransformationFrameCount = 7, + }, + [2] = new TierData + { + FrameSpeed = 4, + SoulsToNextTier = 5, + TransformationFrameCount = 9, + }, + [3] = new TierData + { + FrameSpeed = 4, + SoulsToNextTier = 10, + TransformationFrameCount = 10, + }, + [4] = new TierData //Dummy tier, used to detect last tier switch into main form + { + SoulsToNextTier = 999 + }, + }; + + SoulsEatenToTier = new Dictionary(); + TierToSoulsEaten = new Dictionary(); + int soulsAccumulated = 0; + foreach (var data in TierDatas) + { + soulsAccumulated += data.Value.SoulsToNextTier; + SoulsEatenToTier.Add(soulsAccumulated, data.Key); + TierToSoulsEaten.Add(data.Key, soulsAccumulated); + } + } + + public override void Unload() + { + SheetAssets = null; + WingAssets = null; + TransformationAssets = null; + TransformationWingAssets = null; + + TierDatas = null; + SoulsEatenToTier = null; + TierToSoulsEaten = null; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Bird"); + Main.projFrames[Projectile.type] = 5; + + ProjectileID.Sets.DontAttachHideToAlpha[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + Projectile.hide = true; + Projectile.aiStyle = -1; + Projectile.width = 32; + Projectile.height = 32; + Projectile.netImportant = true; + Projectile.timeLeft = int.MaxValue / 2; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write((byte)PlayerOwner); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + PlayerOwner = reader.ReadByte(); + } + + public void AssignPlayerOwner(int newPlayer) + { + bool sync = HasValidPlayerOwner; + + PlayerOwner = newPlayer; + + if (sync) + { + //If switching player, sync immediately + Projectile.NetSync(); + } + } + + public void AddSoulsEaten() + { + if (Main.myPlayer == Projectile.owner) + { + //AssUtils.Print(Main.time + " increased souls eaten"); + SoulsEaten++; + + //Has to be after SoulsEaten is modified + if (PrevTier < Tier) + { + //Initiate transformation + CurrentTrafoTier = PrevTier; + } + PrevTier = Tier; + + if (TierToSoulsEaten.TryGetValue(MaxTier, out var v)) + { + if (SoulsEaten >= v) + { + //Transform into last stage + CurrentTrafoTier = PrevTier; + } + } + + Projectile.NetSync(); + } + } + + private void HandleSoulEatingVisuals() + { + overlayColor = Color.Lerp(overlayColor, Color.White, 0.1f); + } + + private void SetFadingAura(int alphaTimer, float alphaIntensity = 0.8f, float scaleIntensity = 0.5f) + { + fadingAuraTimerMax = fadingAuraTimer = alphaTimer; + fadingAuraAlphaIntensity = alphaIntensity; + fadingAuraScaleIntensity = scaleIntensity; + } + + private void HandleFadingAura() + { + if (fadingAuraTimer > 0) + { + fadingAuraTimer--; + } + else + { + fadingAuraTimerMax = 0; + fadingAuraAlphaIntensity = 0f; + fadingAuraScaleIntensity = 0f; + } + } + + private void HandleWingDust() + { + if (TrafoInProgressVisual) + { + return; + } + + if (Tier == 1 || CurrentTrafoTier == 1) + { + return; + } + + if (!TierToSoulsEaten.TryGetValue(MaxTier, out var maxSoulsEaten)) + { + return; + } + + Vector2 offset = Vector2.Zero; + Vector2 size = Projectile.Size; + + if (CurrentTrafoTier != 2 && Tier == 3) + { + offset.X += Projectile.width; + float y = Projectile.frame switch + { + 0 => -Projectile.height / 1.5f, + 2 => Projectile.height / 1.5f, + _ => 0, + }; + offset.Y += y; + } + else + { + size += -Vector2.One * 6; + + offset.X += Projectile.width / 2f; + float y = Projectile.frame switch + { + 0 => -Projectile.height / 2.5f, + 2 => Projectile.height / 2.5f, + _ => 0, + }; + offset.Y += y; + } + + for (int i = -1; i <= 1; i += 2) + { + Vector2 dustCenter = Projectile.Center + new Vector2(offset.X * i, offset.Y).RotatedBy(Projectile.rotation); + Rectangle dustBox = Utils.CenteredRectangle(dustCenter, size); + + if (Main.rand.NextFloat() < 0.5f * (float)SoulsEaten / maxSoulsEaten) + { + Dust dust = Dust.NewDustDirect(dustBox.TopLeft(), dustBox.Width, dustBox.Height, 135, 0f, 0f, 0, default(Color), 1.5f); + dust.noGravity = true; + dust.noLight = true; + dust.velocity *= 0.3f; + if (Main.rand.NextBool(5)) + { + dust.fadeIn = 1f; + } + } + } + } + + private void HandleLeavingCondition() + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int time = 100; + if (BabyHarvesterHandler.IsTurningInvalidPlayer(Player, out int timeLeft)) + { + if (timeLeft % time == time - 1) //So it triggers at the start, and not close at the end + { + EmoteBubble.NewBubble(EmoteID.EmotionCry, new WorldUIAnchor(Projectile), time); + } + } + } + } + + private int SoulTargetClosest(float maxDistance = 1000f) + { + short closest = Main.maxNPCs; + Vector2 toSoul; + float oldDistance = maxDistance; + float newDistance; + for (short j = 0; j < Main.maxNPCs; j++) + { + //ignore souls if they are noclipping + NPC other = Main.npc[j]; + if (other.active && other.type == ModContent.NPCType()) + { + toSoul = other.Center - Projectile.Center; + newDistance = toSoul.Length(); + if (newDistance < oldDistance) + { + oldDistance = newDistance; + closest = j; + } + } + } + return closest; + } + + public override void AI() + { + if (!HasValidPlayerOwner) + { + Projectile.Kill(); + return; + } + //Player is now valid here + + if (!Player.active) + { + //Wait for revalidation (player disconnecting causes position of the player to be reset to 0,0, despawning the projectiles because its oob) + //If no other suitable player is found, it gets despawned by the handler + return; + } + + //Client the bird is attached to gives himself the buff + //Buff is cleared automatically from any player the bird is not following + if (Main.myPlayer == Player.whoAmI) + { + int buffType = ModContent.BuffType(); + if (!Player.HasBuff(buffType)) + { + Player.AddBuff(buffType, 1600); + } + } + + HandleSoulEatingVisuals(); + + HandleFadingAura(); + + HandleWingDust(); + + HandleLeavingCondition(); + + //Main.NewText("t: " + Tier); + //Main.NewText("c: " + CurrentTrafoTier); + + bool animate = true; + if (!TrafoInProgress) + { + if (!TrafoInCooldown) + { + RegularAI(); + } + else + { + //Main.NewText("in trafo cooldown " + CurrentTrafoTier); + CurrentTrafoTier++; + + if (CurrentTrafoTier < -30) + { + Projectile.velocity.Y = -0.025f; + } + } + } + else + { + animate = TransformationAI(); + } + + if (animate) + { + int frameSpeed = 4; + if (TierDatas.TryGetValue(Tier, out var data)) + { + frameSpeed = data.FrameSpeed; + } + + if (Projectile.velocity.LengthSquared() < 2 * 2) + { + frameSpeed++; + } + AssAI.ZephyrfishDraw(Projectile, frameSpeed); + } + } + + private void RegularAI() + { + drawBehind = true; + int soulTarget = Main.maxNPCs; + if (Timer <= Time_PreSoulEat) + { + //Main.NewText("in pre soul eat " + Timer); + soulTarget = SoulTargetClosest(); + } + if (soulTarget != Main.maxNPCs) + { + if (soulTarget != oldSoulTarget) + { + if (Tier == 1) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + EmoteBubble.NewBubble(EmoteID.ItemBugNet, new WorldUIAnchor(Projectile), 120); + } + } + } + oldSoulTarget = soulTarget; + + NPC soul = Main.npc[soulTarget]; + + Vector2 toSoul = soul.Center - Projectile.Center; + Vector2 offsetTier = Tier switch + { + 1 => new Vector2(30, -20), + 2 => new Vector2(40, -25), + 3 => new Vector2(50, -30), + _ => Vector2.Zero, + }; + offsetTier.X *= -Math.Sign(soul.Center.X - Player.Center.X); + + Vector2 soulPos = soul.Center + offsetTier; + Vector2 toSoulResting = soulPos - Projectile.Center; + float distanceSQ = toSoulResting.LengthSquared(); + + if (distanceSQ > 10 * 10) + { + //Approach soul + Timer = 0; + float speed = 8f; + float inertia = 16; + + if (distanceSQ < 100 * 100) + { + speed = 3f; + inertia = 3; + } + + Vector2 toSoulSpeed = toSoulResting.SafeNormalize(Vector2.UnitY) * speed; + Projectile.velocity = (Projectile.velocity * (inertia - 1) + toSoulSpeed) / inertia; + Projectile.direction = Math.Sign(toSoul.X); + Projectile.spriteDirection = Projectile.direction; + Projectile.rotation = Projectile.velocity.X * 0.05f; + } + else + { + //Next to soul + if (Tier == 1) + { + Timer += 0.2f; + } + else + { + Timer++; + } + Projectile.velocity *= 0.8f; + Projectile.rotation *= 0.8f; + + if (Math.Abs(Projectile.velocity.X) < 0.1f) + { + Projectile.netUpdate = true; + Projectile.velocity *= 0f; + Projectile.rotation = 0; + } + + if (Timer > Time_PreSoulEat) + { + //Destroy soul and spawn a homing projectile which increases the soul count + if (Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), soul.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + + //AssUtils.Print(Main.time + " spawned homing soul"); + } + + soul.life = 0; + soul.active = false; + soul.netUpdate = true; + + Projectile.netUpdate = true; + } + } + + } + else if (Timer == 0) + { + Vector2 offset = Vector2.Zero; + float veloFactor = 0.9f; + float sway = 1f; + bool random = true; + + if (Tier == 1) + { + if (!firstEmote) + { + firstEmote = true; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + EmoteBubble.NewBubble(EmoteID.BossSkeletron, new WorldUIAnchor(Projectile), 240); + } + } + + hungryEmoteTimer++; + if (hungryEmoteTimer > hungryEmoteTimerMax) + { + hungryEmoteTimer = 0; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + EmoteBubble.NewBubble(EmoteID.EmotionAlert, new WorldUIAnchor(Projectile), 120); + } + } + + offset = new Vector2(-60, 40); + veloFactor = 1f; + sway = 1.3f; + + drawBehind = Projectile.direction == 1; + + //if something: drawBehind = false + float rot = Projectile.velocity.ToRotation(); + if (Projectile.direction == 1) + { + rot = MathHelper.Pi - Math.Abs(rot); + } + //The above normalizes rot to number always around 0 + float thres = MathHelper.PiOver4 / 2; + + //attempt to "flatten" velocity, prefer moving horizontally + Rectangle flattenRect = Player.Hitbox; + flattenRect.Inflate(0, 20); + if (Projectile.Hitbox.Intersects(flattenRect) && rot > thres) + { + float by = 1 / 50f; + by *= Projectile.direction * Math.Sign(rot); + if (Projectile.direction == 1) + { + by *= -1; + } + Projectile.velocity = Projectile.velocity.RotatedBy(by); + + //Always keep min speed + float minSpeed = 2.4f; + if (Projectile.velocity.LengthSquared() < minSpeed * minSpeed) + { + Projectile.velocity = Utils.SafeNormalize(Projectile.velocity, Vector2.UnitY); + Projectile.velocity *= minSpeed; + } + } + } + + AssAI.ZephyrfishAI(Projectile, Player, veloFactor, sway, random, offsetX: offset.X, offsetY: offset.Y); + Projectile.spriteDirection = -Projectile.spriteDirection; + } + else + { + Timer++; + if (Timer > Time_PostSoulEat) + { + Timer = 0; + Projectile.netUpdate = true; + } + else + { + //Main.NewText("in post soul eat " + Timer); + } + } + } + + //Returns true if it should keep animating + private bool TransformationAI() + { + //Runs on all clients, does not need any syncing to stop + Projectile.velocity *= 0.4f; + Projectile.rotation *= 0.8f; + + if (CurrentTrafoTier == MaxTier) + { + Projectile.rotation = 0f; + } + + if (!TierDatas.TryGetValue(CurrentTrafoTier, out var data)) + { + return true; + } + + TrafoTimer++; + if (TrafoTimer <= Time_TrafoStart) + { + int thres = 50; + if (TrafoTimer % thres == 0) + { + int step = TrafoTimer / thres; + overlayColor = new Color(195, 247, 255) * (0.6f - 0.2f * step); + overlayColor.A = 255; + } + //Main.NewText("in trafo start " + TrafoTimer); + return true; + } + + int threshold = Time_TrafoStart; + if (TrafoTimer > 3 + threshold) + { + TrafoFrameY++; + TrafoTimer = threshold; + } + if (TrafoFrameY >= data.TransformationFrameCount) + { + Projectile.frame = 0; + Projectile.frameCounter = 0; + TrafoTimer = 0; + TrafoFrameY = 0; + + if (CurrentTrafoTier == MaxTier) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = AssortedCrazyThings.harvester; + if (!NPC.AnyNPCs(type)) + { + int yOffset = 62; //Manually adjusted + int index = NPC.NewNPC(new EntitySource_BossSpawn(Player), (int)Projectile.Center.X, (int)Projectile.Center.Y + yOffset, type); + if (index < Main.maxNPCs && Main.npc[index] is NPC npc && npc.ModNPC is Harvester harvester) + { + harvester.AI_State = Harvester.State_SpawnedByBaby; + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.SyncNPC, number: index); + } + } + + AssWorld.AwakeningMessage(Harvester.name + " has been awakened!"); + } + + Projectile.Kill(); + } + } + else + { + Vector2 dustOffset = new Vector2(0, 20); + Vector2 center = Projectile.Center; + for (int i = 0; i < 10 + CurrentTrafoTier * 10; i++) + { + Vector2 dustOffset2 = dustOffset.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.1f, 1f); + Dust dust = Dust.NewDustPerfect(center + dustOffset2, 59, newColor: Color.White, Scale: 2.1f); + dust.noLight = true; + dust.noGravity = true; + dust.fadeIn = Main.rand.NextFloat(0.2f, 0.8f); + dust.velocity = Utils.SafeNormalize(dust.position - center, Vector2.Zero) * 3; + } + + SoundEngine.PlaySound(SoundID.Item8, Projectile.Center); + } + + CurrentTrafoTier = -Time_TrafoCooldown; //Reset trafo + Projectile.netUpdate = true; + } + + return false; + } + + public override void PostAI() + { + if (PrevSoulsEaten < SoulsEaten) + { + //AssUtils.Print(Main.time + " souls eaten visuals"); + + overlayColor = new Color(195, 247, 255) * 0.7f; + overlayColor.A = 255; + SetFadingAura(30); + + SoundEngine.PlaySound(SoundID.Item8, Projectile.Center); + } + + PrevSoulsEaten = SoulsEaten; + } + + public override bool? CanCutTiles() + { + return false; + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 20; i++) + { + int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); + Dust dust = Main.dust[d]; + dust.noGravity = true; + dust.velocity *= 1.5f; + dust.scale = 1.3f; + } + } + + public override Color? GetAlpha(Color lightColor) + { + return Color.Lerp(lightColor, Color.White, 0.4f).MultiplyRGBA(overlayColor) * Projectile.Opacity; + } + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + (drawBehind ? behindNPCs : overPlayers).Add(index); + } + + public override bool PreDraw(ref Color lightColor) + { + //Custom draw to just center on the hitbox, as all birds share the same frame size (for seamless transformation) + Texture2D texture = null; + int frameCount = 1; + int frameY = 0; + int tier = TrafoInProgress ? CurrentTrafoTier : Tier; + if (TrafoInProgressVisual && TransformationAssets.TryGetValue(tier, out var trafoAsset)) + { + texture = trafoAsset.Value; + + if (TierDatas.TryGetValue(tier, out var data)) + { + frameCount = data.TransformationFrameCount; + } + frameY = TrafoFrameY; + } + else if (SheetAssets.TryGetValue(tier, out var asset)) + { + texture = asset.Value; + frameCount = Main.projFrames[Projectile.type]; + frameY = Projectile.frame; + } + + if (texture == null) + { + return false; + } + + Rectangle sourceRect = texture.Frame(1, frameCount, frameY: frameY); + Vector2 drawOrigin = sourceRect.Size() / 2f; + + SpriteEffects spriteEffects = Projectile.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + Vector2 drawPos = Projectile.position + Projectile.Size / 2f + new Vector2(0, Projectile.gfxOffY + 4f - 1f) - Main.screenPosition; + Color color = Projectile.GetAlpha(lightColor); + + float rotation = Projectile.rotation; + float scale = Projectile.scale; + Main.EntitySpriteDraw(texture, drawPos, sourceRect, color, rotation, drawOrigin, scale, spriteEffects, 0); + + Texture2D wingTexture = null; + if (TrafoInProgressVisual && TransformationWingAssets.TryGetValue(tier, out var trafoWingAsset)) + { + wingTexture = trafoWingAsset.Value; + } + else if (WingAssets.TryGetValue(tier, out var wingAsset)) + { + wingTexture = wingAsset.Value; + } + + Color wingColor = Projectile.GetAlpha(Color.White); + if (wingTexture != null) + { + Main.EntitySpriteDraw(wingTexture, drawPos, sourceRect, wingColor, rotation, drawOrigin, scale, spriteEffects, 0); + } + + if (fadingAuraTimer > 0 && fadingAuraTimerMax > 0) + { + float fadeScale = fadingAuraTimer / (float)fadingAuraTimerMax; + float scaleInverse = 1f - fadeScale; + Color auraColor = color * fadeScale * fadingAuraAlphaIntensity; + Color auraWingColor = wingColor * fadeScale * fadingAuraAlphaIntensity; + float auraScale = scale + scaleInverse * fadingAuraScaleIntensity; + + Main.EntitySpriteDraw(texture, drawPos, sourceRect, auraColor, rotation, drawOrigin, scale, spriteEffects, 0); + + if (wingTexture != null) + { + Main.EntitySpriteDraw(wingTexture, drawPos, sourceRect, auraWingColor, rotation, drawOrigin, auraScale, spriteEffects, 0); + } + } + + return false; + } + } } diff --git a/Projectiles/NPCs/Bosses/DungeonBird/HarvesterAbsorbedSoul.cs b/Projectiles/NPCs/Bosses/DungeonBird/HarvesterAbsorbedSoul.cs index 05b95658..0c073779 100644 --- a/Projectiles/NPCs/Bosses/DungeonBird/HarvesterAbsorbedSoul.cs +++ b/Projectiles/NPCs/Bosses/DungeonBird/HarvesterAbsorbedSoul.cs @@ -1,138 +1,137 @@ -using AssortedCrazyThings.Base; using Microsoft.Xna.Framework; using Terraria; namespace AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird { - [Content(ContentType.Bosses)] - public class HarvesterAbsorbedSoul : AssProjectile - { - public override string Texture => "AssortedCrazyThings/Empty"; - - public int Timer - { - get => (int)Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Absorbed Soul"); - } - - public override void SetDefaults() - { - Projectile.width = 8; - Projectile.height = 8; - //Projectile.aiStyle = 122; - Projectile.hostile = true; - Projectile.alpha = 255; - Projectile.ignoreWater = true; - Projectile.timeLeft = 3600; - Projectile.tileCollide = false; - Projectile.penetrate = -1; - //Projectile.extraUpdates = 2; - } - - public override void AI() - { - if (!TryGetBabyHarvester(out BabyHarvesterProj babyHarvester)) - { - Projectile.active = false; - return; - } - - Movement(babyHarvester); - - Visuals(); - } - - private static bool TryGetBabyHarvester(out BabyHarvesterProj babyHarvester) - { - babyHarvester = null; - if (!BabyHarvesterHandler.TryFindBabyHarvester(out Projectile proj, out _)) - { - return false; - } - - if (!(proj.ModProjectile is BabyHarvesterProj babyHarvester2 && babyHarvester2.HasValidPlayerOwner)) - { - return false; - } - - babyHarvester = babyHarvester2; - return true; - } - - private void Movement(BabyHarvesterProj babyHarvester) - { - Projectile other = babyHarvester.Projectile; - Vector2 otherCenter = other.Center; - otherCenter.X += other.direction * 10; - Vector2 toHarvester = otherCenter - Projectile.Center; - - if (Projectile.localAI[0] == 0f) - { - //AssUtils.Print(Main.time + " appeared homing soul"); - - Projectile.localAI[0] = 1f; - - for (int i = 0; i < 20; i++) - { - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); - Dust dust = Main.dust[d]; - dust.noGravity = true; - dust.velocity *= 1.5f; - dust.scale = 1.3f; - } - - //Give it initial velocity bump up - Projectile.velocity.Y += -4; - } - else - { - Timer++; - if (Timer > 8) - { - toHarvester = toHarvester.SafeNormalize(Vector2.UnitX * Projectile.direction) * 10; - float inertia = 12; - Projectile.velocity = (Projectile.velocity * (inertia - 1) + toHarvester) / inertia; - } - } - - var hitbox = other.Hitbox; - hitbox.Inflate(0, -6); - if (Projectile.Hitbox.Intersects(hitbox)) - { - if (Main.myPlayer == Projectile.owner) - { - babyHarvester.AddSoulsEaten(); - } - - Projectile.Kill(); - } - } - - private void Visuals() - { - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); - Dust dust = Main.dust[d]; - dust.noGravity = true; - dust.scale = 1.3f; - } - - public override void Kill(int timeLeft) - { - //AssUtils.Print(Main.time + " killed homing soul"); - - for (int i = 0; i < 8; i++) - { - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); - Dust dust = Main.dust[d]; - dust.noGravity = true; - dust.velocity *= 1.3f; - dust.scale = 1.3f; - } - } - } + [Content(ContentType.Bosses)] + public class HarvesterAbsorbedSoul : AssProjectile + { + public override string Texture => "AssortedCrazyThings/Empty"; + + public int Timer + { + get => (int)Projectile.ai[0]; + set => Projectile.ai[0] = value; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Absorbed Soul"); + } + + public override void SetDefaults() + { + Projectile.width = 8; + Projectile.height = 8; + //Projectile.aiStyle = 122; + Projectile.hostile = true; + Projectile.alpha = 255; + Projectile.ignoreWater = true; + Projectile.timeLeft = 3600; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + //Projectile.extraUpdates = 2; + } + + public override void AI() + { + if (!TryGetBabyHarvester(out BabyHarvesterProj babyHarvester)) + { + Projectile.active = false; + return; + } + + Movement(babyHarvester); + + Visuals(); + } + + private static bool TryGetBabyHarvester(out BabyHarvesterProj babyHarvester) + { + babyHarvester = null; + if (!BabyHarvesterHandler.TryFindBabyHarvester(out Projectile proj, out _)) + { + return false; + } + + if (!(proj.ModProjectile is BabyHarvesterProj babyHarvester2 && babyHarvester2.HasValidPlayerOwner)) + { + return false; + } + + babyHarvester = babyHarvester2; + return true; + } + + private void Movement(BabyHarvesterProj babyHarvester) + { + Projectile other = babyHarvester.Projectile; + Vector2 otherCenter = other.Center; + otherCenter.X += other.direction * 10; + Vector2 toHarvester = otherCenter - Projectile.Center; + + if (Projectile.localAI[0] == 0f) + { + //AssUtils.Print(Main.time + " appeared homing soul"); + + Projectile.localAI[0] = 1f; + + for (int i = 0; i < 20; i++) + { + int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); + Dust dust = Main.dust[d]; + dust.noGravity = true; + dust.velocity *= 1.5f; + dust.scale = 1.3f; + } + + //Give it initial velocity bump up + Projectile.velocity.Y += -4; + } + else + { + Timer++; + if (Timer > 8) + { + toHarvester = toHarvester.SafeNormalize(Vector2.UnitX * Projectile.direction) * 10; + float inertia = 12; + Projectile.velocity = (Projectile.velocity * (inertia - 1) + toHarvester) / inertia; + } + } + + var hitbox = other.Hitbox; + hitbox.Inflate(0, -6); + if (Projectile.Hitbox.Intersects(hitbox)) + { + if (Main.myPlayer == Projectile.owner) + { + babyHarvester.AddSoulsEaten(); + } + + Projectile.Kill(); + } + } + + private void Visuals() + { + int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); + Dust dust = Main.dust[d]; + dust.noGravity = true; + dust.scale = 1.3f; + } + + public override void Kill(int timeLeft) + { + //AssUtils.Print(Main.time + " killed homing soul"); + + for (int i = 0; i < 8; i++) + { + int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); + Dust dust = Main.dust[d]; + dust.noGravity = true; + dust.velocity *= 1.3f; + dust.scale = 1.3f; + } + } + } } diff --git a/Projectiles/NPCs/Bosses/DungeonBird/HarvesterBone.cs b/Projectiles/NPCs/Bosses/DungeonBird/HarvesterBone.cs index cf5b1c65..0730bf54 100644 --- a/Projectiles/NPCs/Bosses/DungeonBird/HarvesterBone.cs +++ b/Projectiles/NPCs/Bosses/DungeonBird/HarvesterBone.cs @@ -1,45 +1,45 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.Audio; +using Terraria.ID; namespace AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird { - //used in BaseHarvester, same as bone, just applies slow - [Content(ContentType.Bosses)] - public class HarvesterBone : AssProjectile - { - public override string Texture - { - get - { - return "Terraria/Images/Projectile_" + ProjectileID.SkeletonBone; - } - } + //used in BaseHarvester, same as bone, just applies slow + [Content(ContentType.Bosses)] + public class HarvesterBone : AssProjectile + { + public override string Texture + { + get + { + return "Terraria/Images/Projectile_" + ProjectileID.SkeletonBone; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Harvester Bone"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Harvester Bone"); + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.SkeletonBone); - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.SkeletonBone); + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - SoundEngine.PlaySound(SoundID.Dig, Projectile.position); - return true; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + SoundEngine.PlaySound(SoundID.Dig, Projectile.position); + return true; + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - if (Main.rand.NextFloat() >= 0.5f) - { - target.AddBuff(BuffID.Slow, 90); //1 1/2 seconds, 50% chance - } - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + if (Main.rand.NextFloat() >= 0.5f) + { + target.AddBuff(BuffID.Slow, 90); //1 1/2 seconds, 50% chance + } + } + } } diff --git a/Projectiles/NPCs/Bosses/DungeonBird/HarvesterFracturedSoul.cs b/Projectiles/NPCs/Bosses/DungeonBird/HarvesterFracturedSoul.cs index 03aec070..d6124b53 100644 --- a/Projectiles/NPCs/Bosses/DungeonBird/HarvesterFracturedSoul.cs +++ b/Projectiles/NPCs/Bosses/DungeonBird/HarvesterFracturedSoul.cs @@ -1,150 +1,150 @@ +using AssortedCrazyThings.Base; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.Audio; -using AssortedCrazyThings.Base; +using Terraria.ID; namespace AssortedCrazyThings.Projectiles.NPCs.Bosses.DungeonBird { - [Content(ContentType.Bosses)] - public class HarvesterFracturedSoul : AssProjectile - { - public float MaxSpeed => Projectile.ai[0]; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Fractured Soul"); - - Main.projFrames[Projectile.type] = 4; - } - - public override void SetDefaults() - { - Projectile.aiStyle = -1; - Projectile.alpha = 255; - Projectile.hostile = true; - Projectile.tileCollide = false; - Projectile.timeLeft = 240; - - Projectile.width = 16; - Projectile.height = 16; - DrawOriginOffsetY = -12; - } - - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 255, 255, (int)Utils.WrappedLerp(0f, 255f, (Projectile.timeLeft % 40) / 40f)) * Projectile.Opacity; - } - - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) - { - width = 10; - height = 10; - - return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); - } - - public override void AI() - { - Movement(); - - Animation(); - - Visuals(); - } - - private void Movement() - { - int plr = Player.FindClosest(Projectile.Center, 1, 1); - Player target = Main.player[plr]; - - if (!Projectile.tileCollide && target.Center.Y < Projectile.Bottom.Y) - { - //similar to some weapons with things dropping from the sky - Projectile.tileCollide = true; - } - - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - - Projectile.ai[1] += 1f; - if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) - { - float speed = Projectile.velocity.Length(); - Vector2 toPlayer = target.Center - Projectile.Center; - toPlayer.Normalize(); - toPlayer *= speed; - Projectile.velocity = (Projectile.velocity * 24f + toPlayer) / 25f; - Projectile.velocity.Normalize(); - Projectile.velocity *= speed; - } - - float maxSpeed = MaxSpeed; - if (maxSpeed <= 0) - { - maxSpeed = 18; - } - if (Projectile.velocity.Length() < maxSpeed) - { - Projectile.velocity *= 1.02f; - } - } - - private void Visuals() - { - int y = DrawOriginOffsetY; - Dust dust = Dust.NewDustDirect(Projectile.position + new Vector2(0, y), Projectile.width, Projectile.height - y, 135, 0f, 0f, 0, default(Color), 1.5f); - dust.noGravity = true; - dust.noLight = true; - dust.velocity *= 0.65f; - if (Main.rand.NextBool(5)) - { - dust.fadeIn = 0.6f; - } - - if (Projectile.localAI[0] == 0f) - { - Projectile.localAI[0] = 1f; - SoundEngine.PlaySound(SoundID.Item8, Projectile.Center); - - for (int i = 0; i < 10; i++) - { - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, Projectile.velocity.X, Projectile.velocity.Y, 0, default(Color), 2f); - dust = Main.dust[d]; - dust.noGravity = true; - dust.velocity = Projectile.Center - dust.position; - dust.velocity.Normalize(); - dust.velocity *= -5f; - dust.velocity += Projectile.velocity / 2f; - } - } - } - - private void Animation() - { - if (Projectile.alpha > 0) - { - Projectile.alpha -= 30; - - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; - } - } - - Projectile.LoopAnimation(4); - } - - public override void Kill(int timeLeft) - { - SoundEngine.PlaySound(0, (int)Projectile.Center.X, (int)Projectile.Center.Y, 27); - for (int i = 0; i < 20; i++) - { - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); - Dust dust = Main.dust[d]; - dust.noGravity = true; - dust.velocity *= 1.3f; - dust.scale = 1.3f; - } - } - } + [Content(ContentType.Bosses)] + public class HarvesterFracturedSoul : AssProjectile + { + public float MaxSpeed => Projectile.ai[0]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fractured Soul"); + + Main.projFrames[Projectile.type] = 4; + } + + public override void SetDefaults() + { + Projectile.aiStyle = -1; + Projectile.alpha = 255; + Projectile.hostile = true; + Projectile.tileCollide = false; + Projectile.timeLeft = 240; + + Projectile.width = 16; + Projectile.height = 16; + DrawOriginOffsetY = -12; + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color(255, 255, 255, (int)Utils.WrappedLerp(0f, 255f, (Projectile.timeLeft % 40) / 40f)) * Projectile.Opacity; + } + + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + width = 10; + height = 10; + + return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); + } + + public override void AI() + { + Movement(); + + Animation(); + + Visuals(); + } + + private void Movement() + { + int plr = Player.FindClosest(Projectile.Center, 1, 1); + Player target = Main.player[plr]; + + if (!Projectile.tileCollide && target.Center.Y < Projectile.Bottom.Y) + { + //similar to some weapons with things dropping from the sky + Projectile.tileCollide = true; + } + + Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); + + Projectile.ai[1] += 1f; + if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) + { + float speed = Projectile.velocity.Length(); + Vector2 toPlayer = target.Center - Projectile.Center; + toPlayer.Normalize(); + toPlayer *= speed; + Projectile.velocity = (Projectile.velocity * 24f + toPlayer) / 25f; + Projectile.velocity.Normalize(); + Projectile.velocity *= speed; + } + + float maxSpeed = MaxSpeed; + if (maxSpeed <= 0) + { + maxSpeed = 18; + } + if (Projectile.velocity.Length() < maxSpeed) + { + Projectile.velocity *= 1.02f; + } + } + + private void Visuals() + { + int y = DrawOriginOffsetY; + Dust dust = Dust.NewDustDirect(Projectile.position + new Vector2(0, y), Projectile.width, Projectile.height - y, 135, 0f, 0f, 0, default(Color), 1.5f); + dust.noGravity = true; + dust.noLight = true; + dust.velocity *= 0.65f; + if (Main.rand.NextBool(5)) + { + dust.fadeIn = 0.6f; + } + + if (Projectile.localAI[0] == 0f) + { + Projectile.localAI[0] = 1f; + SoundEngine.PlaySound(SoundID.Item8, Projectile.Center); + + for (int i = 0; i < 10; i++) + { + int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, Projectile.velocity.X, Projectile.velocity.Y, 0, default(Color), 2f); + dust = Main.dust[d]; + dust.noGravity = true; + dust.velocity = Projectile.Center - dust.position; + dust.velocity.Normalize(); + dust.velocity *= -5f; + dust.velocity += Projectile.velocity / 2f; + } + } + } + + private void Animation() + { + if (Projectile.alpha > 0) + { + Projectile.alpha -= 30; + + if (Projectile.alpha < 0) + { + Projectile.alpha = 0; + } + } + + Projectile.LoopAnimation(4); + } + + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(0, (int)Projectile.Center.X, (int)Projectile.Center.Y, 27); + for (int i = 0; i < 20; i++) + { + int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100); + Dust dust = Main.dust[d]; + dust.noGravity = true; + dust.velocity *= 1.3f; + dust.scale = 1.3f; + } + } + } } diff --git a/Projectiles/Pets/AbeeminationProj.cs b/Projectiles/Pets/AbeeminationProj.cs index aca1cdba..73a150fa 100644 --- a/Projectiles/Pets/AbeeminationProj.cs +++ b/Projectiles/Pets/AbeeminationProj.cs @@ -6,62 +6,62 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.OtherPets)] - //check this file for more info vvvvvvvv - public class AbeeminationProj : BabySlimeBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/AbeeminationProj_0"; //temp - } - } + [Content(ContentType.OtherPets)] + //check this file for more info vvvvvvvv + public class AbeeminationProj : BabySlimeBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/AbeeminationProj_0"; //temp + } + } - public override bool UseJumpingFrame => false; + public override bool UseJumpingFrame => false; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Abeemination"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Abeemination"); + } - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.Abeemination = false; - } - if (modPlayer.Abeemination) - { - Projectile.timeLeft = 2; - } - return true; - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.Abeemination = false; + } + if (modPlayer.Abeemination) + { + Projectile.timeLeft = 2; + } + return true; + } - public override bool PreDraw(ref Color lightColor) - { - lightColor = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16), Color.White); - SpriteEffects effects = SpriteEffects.None; - if (Projectile.direction != -1) - { - effects = SpriteEffects.FlipHorizontally; - } - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/AbeeminationProj_" + mPlayer.abeeminationType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f/* + DrawOffsetX * 0.5f*/, Projectile.height * 0.5f + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + public override bool PreDraw(ref Color lightColor) + { + lightColor = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16), Color.White); + SpriteEffects effects = SpriteEffects.None; + if (Projectile.direction != -1) + { + effects = SpriteEffects.FlipHorizontally; + } + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/AbeeminationProj_" + mPlayer.abeeminationType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f/* + DrawOffsetX * 0.5f*/, Projectile.height * 0.5f + Projectile.gfxOffY); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/AlienHornetProj.cs b/Projectiles/Pets/AlienHornetProj.cs index 0c2d792e..bf4df6b5 100644 --- a/Projectiles/Pets/AlienHornetProj.cs +++ b/Projectiles/Pets/AlienHornetProj.cs @@ -7,58 +7,58 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class AlienHornetProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Alien Hornet"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public class AlienHornetProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Alien Hornet"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyHornet); - AIType = ProjectileID.BabyHornet; - Projectile.width = 38; - Projectile.height = 36; - Projectile.alpha = 0; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyHornet); + AIType = ProjectileID.BabyHornet; + Projectile.width = 38; + Projectile.height = 36; + Projectile.alpha = 0; + } - public override void PostDraw(Color drawColor) - { - Texture2D texture = Mod.Assets.Request("Projectiles/Pets/AlienHornetProj_Glowmask").Value; - Vector2 drawPos = Projectile.position - Main.screenPosition; - Rectangle frame = new Rectangle(0, 0, texture.Width, texture.Height / 4); - frame.Y = Projectile.frameCounter % 60; - if (frame.Y > 24) - { - frame.Y = 24; - } - frame.Y *= Projectile.height; - Main.EntitySpriteDraw(texture, drawPos, frame, Color.White * 0.7f, 0f, Vector2.Zero, 1f, Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); - } + public override void PostDraw(Color drawColor) + { + Texture2D texture = Mod.Assets.Request("Projectiles/Pets/AlienHornetProj_Glowmask").Value; + Vector2 drawPos = Projectile.position - Main.screenPosition; + Rectangle frame = new Rectangle(0, 0, texture.Width, texture.Height / 4); + frame.Y = Projectile.frameCounter % 60; + if (frame.Y > 24) + { + frame.Y = 24; + } + frame.Y *= Projectile.height; + Main.EntitySpriteDraw(texture, drawPos, frame, Color.White * 0.7f, 0f, Vector2.Zero, 1f, Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.hornet = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.hornet = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.AlienHornet = false; - } - if (modPlayer.AlienHornet) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.AlienHornet = false; + } + if (modPlayer.AlienHornet) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/AnimatedTomeProj.cs b/Projectiles/Pets/AnimatedTomeProj.cs index 7d3a721e..7302297c 100644 --- a/Projectiles/Pets/AnimatedTomeProj.cs +++ b/Projectiles/Pets/AnimatedTomeProj.cs @@ -7,66 +7,66 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class AnimatedTomeProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/AnimatedTomeProj_0"; //temp - } - } + public class AnimatedTomeProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/AnimatedTomeProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Animated Tome"); - Main.projFrames[Projectile.type] = 5; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Animated Tome"); + Main.projFrames[Projectile.type] = 5; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyHornet); - Projectile.width = 22; - Projectile.height = 18; - Projectile.aiStyle = -1; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyHornet); + Projectile.width = 22; + Projectile.height = 18; + Projectile.aiStyle = -1; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.AnimatedTome = false; - } - if (modPlayer.AnimatedTome) - { - Projectile.timeLeft = 2; - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.AnimatedTome = false; + } + if (modPlayer.AnimatedTome) + { + Projectile.timeLeft = 2; + } - if (!player.active) - { - Projectile.active = false; - return; - } + if (!player.active) + { + Projectile.active = false; + return; + } - AssAI.ZephyrfishAI(Projectile); - AssAI.ZephyrfishDraw(Projectile); - } + AssAI.ZephyrfishAI(Projectile); + AssAI.ZephyrfishDraw(Projectile); + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/AnimatedTomeProj_" + mPlayer.animatedTomeType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/AnimatedTomeProj_" + mPlayer.animatedTomeType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2 - Projectile.direction * 3f, Projectile.height / 2 + Projectile.gfxOffY); + Vector2 stupidOffset = new Vector2(Projectile.width / 2 - Projectile.direction * 3f, Projectile.height / 2 + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/Anomalocarisproj.cs b/Projectiles/Pets/Anomalocarisproj.cs index 9a9d4aa2..efb402d1 100644 --- a/Projectiles/Pets/Anomalocarisproj.cs +++ b/Projectiles/Pets/Anomalocarisproj.cs @@ -7,64 +7,64 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class AnomalocarisProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/AnomalocarisProj_0"; //temp - } - } + public class AnomalocarisProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/AnomalocarisProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Anomalocaris"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Anomalocaris"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetAnomalocaris = false; - } - if (modPlayer.PetAnomalocaris) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetAnomalocaris = false; + } + if (modPlayer.PetAnomalocaris) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/AnomalocarisProj_" + mPlayer.petAnomalocarisType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/AnomalocarisProj_" + mPlayer.petAnomalocarisType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + 2f + Projectile.gfxOffY); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + 2f + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/BabyCrimeraProj.cs b/Projectiles/Pets/BabyCrimeraProj.cs index 5ee50ddb..12c81878 100644 --- a/Projectiles/Pets/BabyCrimeraProj.cs +++ b/Projectiles/Pets/BabyCrimeraProj.cs @@ -4,44 +4,44 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class BabyCrimeraProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Baby Crimera"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - } + public class BabyCrimeraProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Crimera"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - AIType = ProjectileID.BabyEater; + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + AIType = ProjectileID.BabyEater; - Projectile.width = 34; - Projectile.height = 34; - } + Projectile.width = 34; + Projectile.height = 34; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.eater = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.eater = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.BabyCrimera = false; - } - if (modPlayer.BabyCrimera) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.BabyCrimera = false; + } + if (modPlayer.BabyCrimera) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/BabyIchorStickerProj.cs b/Projectiles/Pets/BabyIchorStickerProj.cs index d9a2f324..16ea1a06 100644 --- a/Projectiles/Pets/BabyIchorStickerProj.cs +++ b/Projectiles/Pets/BabyIchorStickerProj.cs @@ -4,49 +4,49 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class BabyIchorStickerProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Baby Ichor Sticker"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public class BabyIchorStickerProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Ichor Sticker"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyHornet); - AIType = ProjectileID.BabyHornet; - Projectile.width = 38; - Projectile.height = 44; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyHornet); + AIType = ProjectileID.BabyHornet; + Projectile.width = 38; + Projectile.height = 44; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.hornet = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.hornet = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.BabyIchorSticker = false; - } - if (modPlayer.BabyIchorSticker) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.BabyIchorSticker = false; + } + if (modPlayer.BabyIchorSticker) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - if (Projectile.frameCounter % 2 == Main.GameUpdateCount % 2) - { - //Make it animate 50% slower by skipping every second increase - Projectile.frameCounter--; - } - } - } + if (Projectile.frameCounter % 2 == Main.GameUpdateCount % 2) + { + //Make it animate 50% slower by skipping every second increase + Projectile.frameCounter--; + } + } + } } diff --git a/Projectiles/Pets/BabyOcramProj.cs b/Projectiles/Pets/BabyOcramProj.cs index 8da358c6..0ff0ab05 100644 --- a/Projectiles/Pets/BabyOcramProj.cs +++ b/Projectiles/Pets/BabyOcramProj.cs @@ -1,46 +1,45 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] - public class BabyOcramProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Baby Ocram"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] + public class BabyOcramProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Ocram"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.BabyOcram = false; - } - if (modPlayer.BabyOcram) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.BabyOcram = false; + } + if (modPlayer.BabyOcram) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/BabySlimeBase.cs b/Projectiles/Pets/BabySlimeBase.cs index 5edfa154..fecc1939 100644 --- a/Projectiles/Pets/BabySlimeBase.cs +++ b/Projectiles/Pets/BabySlimeBase.cs @@ -8,750 +8,750 @@ namespace AssortedCrazyThings.Projectiles.Pets { - /// - /// localAI[1] freely available - /// - public abstract class BabySlimeBase : AssProjectile - { - public const int StuckTimerMax = 3 * 60; - public int stuckTimer = 0; - - public bool shootSpikes = false; - private static readonly byte shootDelay = 60; //either +1 or +0 every tick, so effectively every 90 ticks - public byte flyingFrameSpeed = 6; - public byte walkingFrameSpeed = 20; - public float customMinionSlots = 1f; - public bool alignFront = false; - - public virtual bool UseJumpingFrame => true; - - public bool InAir => Projectile.ai[0] != 0f; - - public sealed override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = UseJumpingFrame ? 7 : 6; - Main.projPet[Projectile.type] = true; - - SafeSetStaticDefaults(); - } - - public virtual void SafeSetStaticDefaults() - { - - } - - public sealed override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabySlime); - Projectile.aiStyle = -1; //26 - //AIType = ProjectileID.BabySlime; - Projectile.alpha = 50; - - //set those in moresetdefaults in the projectile that inherits from this - //projectile.width = 38; - //projectile.height = 40; - - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; - Projectile.manualDirectionChange = true; - - flyingFrameSpeed = 6; - walkingFrameSpeed = 20; - - DrawOffsetX = -14; - DrawOriginOffsetY = -2; - - SafeSetDefaults(); - - Projectile.minionSlots = Projectile.minion ? customMinionSlots : 0f; - } - - public virtual void SafeSetDefaults() - { - //used to set dimensions (if necessary) - //also used to set projectile.minion - } - - public override bool MinionContactDamage() - { - return Projectile.minion; - } - - public override void AI() - { - BabySlimeAI(); - Draw(); - } - - public void Draw() - { - if (InAir) - { - int flyingFrameStart = UseJumpingFrame ? 3 : 2; - int flyingFrameEnd = Main.projFrames[Projectile.type] - 1; - - if (Projectile.velocity.X > 0.5f) - { - Projectile.spriteDirection = -1; - } - else if (Projectile.velocity.X < -0.5f) - { - Projectile.spriteDirection = 1; - } - - Projectile.frameCounter++; - if (Projectile.frameCounter > flyingFrameSpeed) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame < flyingFrameStart || Projectile.frame > flyingFrameEnd) - { - Projectile.frame = flyingFrameStart; - } - Projectile.rotation = Projectile.velocity.X * 0.1f; - } - else - { - if (Projectile.direction == -1) - { - Projectile.spriteDirection = 1; - } - if (Projectile.direction == 1) - { - Projectile.spriteDirection = -1; - } - - int walkingFrameEnd = 1; - - if (UseJumpingFrame && Projectile.velocity.Y != 0.4f) //Standing on the ground: Y == 0.4f as per AI - { - walkingFrameEnd++; - Projectile.frameCounter = 0; - Projectile.frame = 2; - } - - if (Projectile.velocity.Y >= 0f && Projectile.velocity.Y <= 0.8f) - { - if (Projectile.velocity.X == 0f) - { - Projectile.frameCounter++; - } - else - { - Projectile.frameCounter += 3; - } - } - else - { - Projectile.frameCounter += 5; - } - - if (Projectile.frameCounter >= walkingFrameSpeed) - { - Projectile.frameCounter -= walkingFrameSpeed; - Projectile.frame++; - } - - if (Projectile.frame > walkingFrameEnd) - { - Projectile.frame = 0; - } - - Projectile.rotation = 0f; - } - } - - public byte pickedTexture = 1; - - public byte PickedTexture - { - get - { - return (byte)(pickedTexture - 1); - } - set - { - pickedTexture = (byte)(value + 1); - } - } - - public bool HasTexture - { - get - { - return PickedTexture != 0; - } - } - - public int JumpTimer - { - get - { - return (int)Projectile.localAI[0]; - } - set - { - Projectile.localAI[0] = value; - } - } - - public byte ShootTimer - { - get - { - return (byte)Projectile.localAI[1]; - } - set - { - Projectile.localAI[1] = value; - } - } - int targetNPC = -1; - - public void BabySlimeAI() - { - bool left = false; - bool right = false; - bool flag3 = false; - bool flag4 = false; - - Player player = Projectile.GetOwner(); - - int initialOffset = Projectile.minion ? 10 : 25; - if (!Projectile.minion) Projectile.minionPos = 0; - int directionalOffset = 40 * (Projectile.minionPos + 1) * player.direction * -alignFront.ToDirectionInt(); - if (player.Center.X < Projectile.Center.X - initialOffset + directionalOffset) - { - left = true; - } - else if (player.Center.X > Projectile.Center.X + initialOffset + directionalOffset) - { - right = true; - } - - int totalOffset = initialOffset + directionalOffset; - if (Projectile.HandleStuck(player.Center.X + totalOffset, ref stuckTimer, StuckTimerMax)) - { - Projectile.ai[0] = 1f; - Projectile.tileCollide = false; - } - - if (Projectile.ai[1] == 0f) - { - int num38 = 500; - num38 += 40 * Projectile.minionPos; - if (JumpTimer > 0) - { - num38 += 600; - } - - if (player.rocketDelay2 > 0 && player.wings != 45) - { - Projectile.ai[0] = 1f; - } - - Vector2 center = Projectile.Center; - float x = player.Center.X - center.X; - float y = player.Center.Y - center.Y; - float distanceSQ = x * x + y * y; - if (distanceSQ > 2000f * 2000f) - { - Projectile.Center = player.Center; - } - else if (distanceSQ > num38 * num38 || (Math.Abs(y) > 300f && JumpTimer <= 0)) - { - if (y > 0f && Projectile.velocity.Y < 0f) - { - Projectile.velocity.Y = 0f; - } - if (y < 0f && Projectile.velocity.Y > 0f) - { - Projectile.velocity.Y = 0f; - } - Projectile.ai[0] = 1f; - } - } - - if (InAir) - { - float veloDelta = 0.2f; - int playerRange = 200; - - Projectile.tileCollide = false; - float desiredVeloX = player.Center.X - Projectile.Center.X; - - desiredVeloX -= 40 * player.direction; - - bool foundCloseTarget = false; - int targetIndex = -1; - - if (Projectile.minion) - { - float range = 700f; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - if (npc.CanBeChasedBy()) - { - float distance = Math.Abs(player.Center.X - npc.Center.X) + Math.Abs(player.Center.Y - npc.Center.Y); - if (distance < range) - { - if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - targetIndex = k; - } - foundCloseTarget = true; - break; - } - } - } - } - - if (!foundCloseTarget) - { - desiredVeloX -= 40 * Projectile.minionPos * player.direction; - } - if (foundCloseTarget && targetIndex >= 0) - { - Projectile.ai[0] = 0f; - } - - float desiredVeloY = player.Center.Y - Projectile.Center.Y; - - float between = (float)Math.Sqrt(desiredVeloX * desiredVeloX + desiredVeloY * desiredVeloY); - //float num54 = num52; - - if (between < playerRange && player.velocity.Y == 0f && Projectile.position.Y + Projectile.height <= player.position.Y + player.height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - Projectile.ai[0] = 0f; - if (Projectile.velocity.Y < -6f) - { - Projectile.velocity.Y = -6f; - } - } - if (between < 60f) - { - desiredVeloX = Projectile.velocity.X; - desiredVeloY = Projectile.velocity.Y; - } - else - { - between = 10f / between; - desiredVeloX *= between; - desiredVeloY *= between; - } - - if (Projectile.velocity.X < desiredVeloX) - { - Projectile.velocity.X += veloDelta; - if (Projectile.velocity.X < 0f) - { - Projectile.velocity.X += veloDelta * 1.5f; - } - } - if (Projectile.velocity.X > desiredVeloX) - { - Projectile.velocity.X -= veloDelta; - if (Projectile.velocity.X > 0f) - { - Projectile.velocity.X -= veloDelta * 1.5f; - } - } - if (Projectile.velocity.Y < desiredVeloY) - { - Projectile.velocity.Y += veloDelta; - if (Projectile.velocity.Y < 0f) - { - Projectile.velocity.Y += veloDelta * 1.5f; - } - } - if (Projectile.velocity.Y > desiredVeloY) - { - Projectile.velocity.Y -= veloDelta; - if (Projectile.velocity.Y > 0f) - { - Projectile.velocity.Y -= veloDelta * 1.5f; - } - } - - Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - } - else - { - float offset = 40 * Projectile.minionPos; - JumpTimer -= 1; - if (JumpTimer < 0) - { - JumpTimer = 0; - } - if (Projectile.ai[1] > 0f) - { - Projectile.ai[1] -= 1f; - } - else - { - float targetX = Projectile.position.X; - float targetY = Projectile.position.Y; - float distance = 100000f; - float otherDistance = distance; - targetNPC = -1; - - //------------------------------------------------------------------------------------ - //DISABLE MINION TARGETING------------------------------------------------------------ - //------------------------------------------------------------------------------------ - - if (Projectile.minion) - { - NPC ownerMinionAttackTargetNPC2 = Projectile.OwnerMinionAttackTargetNPC; - if (ownerMinionAttackTargetNPC2 != null && ownerMinionAttackTargetNPC2.CanBeChasedBy()) - { - float x = ownerMinionAttackTargetNPC2.Center.X; - float y = ownerMinionAttackTargetNPC2.Center.Y; - float num94 = Math.Abs(Projectile.Center.X - x) + Math.Abs(Projectile.Center.Y - y); - if (num94 < distance) - { - if (targetNPC == -1 && num94 <= otherDistance) - { - otherDistance = num94; - targetX = x; - targetY = y; - } - if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, ownerMinionAttackTargetNPC2.position, ownerMinionAttackTargetNPC2.width, ownerMinionAttackTargetNPC2.height)) - { - distance = num94; - targetX = x; - targetY = y; - targetNPC = ownerMinionAttackTargetNPC2.whoAmI; - } - } - } - if (targetNPC == -1) - { - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - if (npc.CanBeChasedBy()) - { - float npcX = npc.Center.X; - float npcY = npc.Center.Y; - float between = Math.Abs(Projectile.Center.X - npcX) + Math.Abs(Projectile.Center.Y - npcY); - if (between < distance) - { - if (targetNPC == -1 && between <= otherDistance) - { - otherDistance = between; - targetX = npcX; - targetY = npcY; - } - if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - distance = between; - targetX = npcX; - targetY = npcY; - targetNPC = k; - } - } - } - } - } - } - - if (targetNPC == -1 && otherDistance < distance) - { - distance = otherDistance; - } - - float num104 = 300f; - if (Projectile.position.Y > Main.worldSurface * 16.0) - { - num104 = 150f; - } - - if (distance < num104 + offset && targetNPC == -1) - { - float num105 = targetX - Projectile.Center.X; - if (num105 < -5f) - { - left = true; - right = false; - } - else if (num105 > 5f) - { - right = true; - left = false; - } - } - - //bool flag9 = false; - - if (targetNPC >= 0 && distance < 800f + offset) - { - Projectile.friendly = true; - JumpTimer = 60; - float distanceX = targetX - Projectile.Center.X; - if (distanceX < -10f) - { - left = true; - right = false; - } - else if (distanceX > 10f) - { - right = true; - left = false; - } - if (targetY < Projectile.Center.Y - 100f && distanceX > -50f && distanceX < 50f && Projectile.velocity.Y == 0f) - { - float distanceAbsY = Math.Abs(targetY - Projectile.Center.Y); - //jumping velocities - if (distanceAbsY < 100f) //120f - { - Projectile.velocity.Y = -10f; - } - else if (distanceAbsY < 210f) - { - Projectile.velocity.Y = -13f; - } - else if (distanceAbsY < 270f) - { - Projectile.velocity.Y = -15f; - } - else if (distanceAbsY < 310f) - { - Projectile.velocity.Y = -17f; - } - else if (distanceAbsY < 380f) - { - Projectile.velocity.Y = -18f; - } - } - - if (shootSpikes) - { - //PickedTexture * 3 makes it so theres a small offset for minion shooting based on their texture, which means that if you have different slimes out, - //they don't all shoot in sync - if (Projectile.owner == Main.myPlayer) - { - NPC npc = Main.npc[targetNPC]; - if (ShootTimer > (shootDelay + PickedTexture * 3) && distance < 200f && - Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - for (int k = 0; k < 3; k++) - { - Vector2 velo = new Vector2(k - 1, -2f); - velo.X *= 1f + Main.rand.Next(-40, 41) * 0.02f; - velo.Y *= 1f + Main.rand.Next(-40, 41) * 0.02f; - velo.Normalize(); - velo *= 3f + Main.rand.Next(-40, 41) * 0.01f; - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), Projectile.Center.X, Projectile.Bottom.Y - 8f, velo.X, velo.Y, ModContent.ProjectileType(), Projectile.damage / 2, 0f, Main.myPlayer, ai1: PickedTexture); - ShootTimer = (byte)(PickedTexture * 3); - } - } - } - if (ShootTimer <= shootDelay + PickedTexture * 3) ShootTimer = (byte)(ShootTimer + Main.rand.Next(2)); - } - } - else - { - Projectile.friendly = false; - } - } - - if (Projectile.ai[1] != 0f) - { - left = false; - right = false; - } - else if (JumpTimer == 0) - { - Projectile.direction = player.direction; - } - - Projectile.tileCollide = true; - - float veloXthreshold = 0.2f; - float maxVeloXthreshold = 6f; - - if (maxVeloXthreshold < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - { - veloXthreshold = 0.3f; - maxVeloXthreshold = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - } - - if (left) - { - if (Projectile.velocity.X > -3.5f) - { - Projectile.velocity.X -= veloXthreshold; - } - else - { - Projectile.velocity.X -= veloXthreshold * 0.25f; - } - } - else if (right) - { - if (Projectile.velocity.X < 3.5f) - { - Projectile.velocity.X += veloXthreshold; - } - else - { - Projectile.velocity.X += veloXthreshold * 0.25f; - } - } - else - { - Projectile.velocity.X *= 0.9f; - if (Projectile.velocity.X >= 0f - veloXthreshold && Projectile.velocity.X <= veloXthreshold) - { - Projectile.velocity.X = 0f; - } - } - - if (left | right) - { - int i = (int)Projectile.Center.X / 16; - int j = (int)Projectile.Center.Y / 16; - if (left) - { - i--; - } - if (right) - { - i++; - } - i += (int)Projectile.velocity.X; - if (WorldGen.SolidTile(i, j)) - { - flag4 = true; - } - } - if (player.position.Y + player.height - 8f > Projectile.position.Y + Projectile.height) - { - flag3 = true; - } - Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); - if (Projectile.velocity.Y == 0f) - { - if (!flag3 && (Projectile.velocity.X < 0f || Projectile.velocity.X > 0f)) - { - int i2 = (int)Projectile.Center.X / 16; - int j2 = (int)Projectile.Center.Y / 16 + 1; - if (left) - { - i2--; - } - if (right) - { - i2++; - } - WorldGen.SolidTile(i2, j2); - } - if (flag4) - { - int i = (int)Projectile.Center.X / 16; - int j = (int)Projectile.Bottom.Y / 16 + 1; - if (WorldGen.SolidTile(i, j) || Main.tile[i, j].IsHalfBlock || Main.tile[i, j].Slope > 0) - { - try - { - i = (int)Projectile.Center.X / 16; - j = (int)Projectile.Center.Y / 16; - if (left) - { - i--; - } - if (right) - { - i++; - } - i += (int)Projectile.velocity.X; - if (!WorldGen.SolidTile(i, j - 1) && !WorldGen.SolidTile(i, j - 2)) - { - Projectile.velocity.Y = -5.1f; - } - else if (!WorldGen.SolidTile(i, j - 2)) - { - Projectile.velocity.Y = -7.1f; - } - else if (WorldGen.SolidTile(i, j - 5)) - { - Projectile.velocity.Y = -11.1f; - } - else if (WorldGen.SolidTile(i, j - 4)) - { - Projectile.velocity.Y = -10.1f; - } - else - { - Projectile.velocity.Y = -9.1f; - } - } - catch - { - Projectile.velocity.Y = -9.1f; - } - } - } - else if (left | right) - { - Projectile.velocity.Y -= 6f; - } - } - if (Projectile.velocity.X > maxVeloXthreshold) - { - Projectile.velocity.X = maxVeloXthreshold; - } - if (Projectile.velocity.X < -maxVeloXthreshold) - { - Projectile.velocity.X = -maxVeloXthreshold; - } - if (Projectile.velocity.X != 0f) Projectile.direction = (Projectile.velocity.X > 0f).ToDirectionInt(); - if (Projectile.velocity.X > veloXthreshold && right) - { - Projectile.direction = 1; - } - if (Projectile.velocity.X < -veloXthreshold && left) - { - Projectile.direction = -1; - } - - if (Projectile.wet && Projectile.GetOwner().Bottom.Y < Projectile.Bottom.Y && JumpTimer == 0f) - { - if (Projectile.velocity.Y > -4f) - { - Projectile.velocity.Y -= 0.2f; - } - if (Projectile.velocity.Y > 0f) - { - Projectile.velocity.Y *= 0.95f; - } - } - else - { - Projectile.velocity.Y += 0.4f; - } - if (Projectile.velocity.Y > 10f) - { - Projectile.velocity.Y = 10f; - } - } - } - - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) - { - if (targetNPC != -1) - { - NPC target = Main.npc[targetNPC]; - Vector2 toTarget = Projectile.DirectionTo(target.Center); - fallThrough = target.Center.Y > Projectile.Bottom.Y && Math.Abs(toTarget.X) < 300; - } - else - { - fallThrough = false; - } - return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); - } - } + /// + /// localAI[1] freely available + /// + public abstract class BabySlimeBase : AssProjectile + { + public const int StuckTimerMax = 3 * 60; + public int stuckTimer = 0; + + public bool shootSpikes = false; + private static readonly byte shootDelay = 60; //either +1 or +0 every tick, so effectively every 90 ticks + public byte flyingFrameSpeed = 6; + public byte walkingFrameSpeed = 20; + public float customMinionSlots = 1f; + public bool alignFront = false; + + public virtual bool UseJumpingFrame => true; + + public bool InAir => Projectile.ai[0] != 0f; + + public sealed override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = UseJumpingFrame ? 7 : 6; + Main.projPet[Projectile.type] = true; + + SafeSetStaticDefaults(); + } + + public virtual void SafeSetStaticDefaults() + { + + } + + public sealed override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabySlime); + Projectile.aiStyle = -1; //26 + //AIType = ProjectileID.BabySlime; + Projectile.alpha = 50; + + //set those in moresetdefaults in the projectile that inherits from this + //projectile.width = 38; + //projectile.height = 40; + + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + Projectile.manualDirectionChange = true; + + flyingFrameSpeed = 6; + walkingFrameSpeed = 20; + + DrawOffsetX = -14; + DrawOriginOffsetY = -2; + + SafeSetDefaults(); + + Projectile.minionSlots = Projectile.minion ? customMinionSlots : 0f; + } + + public virtual void SafeSetDefaults() + { + //used to set dimensions (if necessary) + //also used to set projectile.minion + } + + public override bool MinionContactDamage() + { + return Projectile.minion; + } + + public override void AI() + { + BabySlimeAI(); + Draw(); + } + + public void Draw() + { + if (InAir) + { + int flyingFrameStart = UseJumpingFrame ? 3 : 2; + int flyingFrameEnd = Main.projFrames[Projectile.type] - 1; + + if (Projectile.velocity.X > 0.5f) + { + Projectile.spriteDirection = -1; + } + else if (Projectile.velocity.X < -0.5f) + { + Projectile.spriteDirection = 1; + } + + Projectile.frameCounter++; + if (Projectile.frameCounter > flyingFrameSpeed) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame < flyingFrameStart || Projectile.frame > flyingFrameEnd) + { + Projectile.frame = flyingFrameStart; + } + Projectile.rotation = Projectile.velocity.X * 0.1f; + } + else + { + if (Projectile.direction == -1) + { + Projectile.spriteDirection = 1; + } + if (Projectile.direction == 1) + { + Projectile.spriteDirection = -1; + } + + int walkingFrameEnd = 1; + + if (UseJumpingFrame && Projectile.velocity.Y != 0.4f) //Standing on the ground: Y == 0.4f as per AI + { + walkingFrameEnd++; + Projectile.frameCounter = 0; + Projectile.frame = 2; + } + + if (Projectile.velocity.Y >= 0f && Projectile.velocity.Y <= 0.8f) + { + if (Projectile.velocity.X == 0f) + { + Projectile.frameCounter++; + } + else + { + Projectile.frameCounter += 3; + } + } + else + { + Projectile.frameCounter += 5; + } + + if (Projectile.frameCounter >= walkingFrameSpeed) + { + Projectile.frameCounter -= walkingFrameSpeed; + Projectile.frame++; + } + + if (Projectile.frame > walkingFrameEnd) + { + Projectile.frame = 0; + } + + Projectile.rotation = 0f; + } + } + + public byte pickedTexture = 1; + + public byte PickedTexture + { + get + { + return (byte)(pickedTexture - 1); + } + set + { + pickedTexture = (byte)(value + 1); + } + } + + public bool HasTexture + { + get + { + return PickedTexture != 0; + } + } + + public int JumpTimer + { + get + { + return (int)Projectile.localAI[0]; + } + set + { + Projectile.localAI[0] = value; + } + } + + public byte ShootTimer + { + get + { + return (byte)Projectile.localAI[1]; + } + set + { + Projectile.localAI[1] = value; + } + } + int targetNPC = -1; + + public void BabySlimeAI() + { + bool left = false; + bool right = false; + bool flag3 = false; + bool flag4 = false; + + Player player = Projectile.GetOwner(); + + int initialOffset = Projectile.minion ? 10 : 25; + if (!Projectile.minion) Projectile.minionPos = 0; + int directionalOffset = 40 * (Projectile.minionPos + 1) * player.direction * -alignFront.ToDirectionInt(); + if (player.Center.X < Projectile.Center.X - initialOffset + directionalOffset) + { + left = true; + } + else if (player.Center.X > Projectile.Center.X + initialOffset + directionalOffset) + { + right = true; + } + + int totalOffset = initialOffset + directionalOffset; + if (Projectile.HandleStuck(player.Center.X + totalOffset, ref stuckTimer, StuckTimerMax)) + { + Projectile.ai[0] = 1f; + Projectile.tileCollide = false; + } + + if (Projectile.ai[1] == 0f) + { + int num38 = 500; + num38 += 40 * Projectile.minionPos; + if (JumpTimer > 0) + { + num38 += 600; + } + + if (player.rocketDelay2 > 0 && player.wings != 45) + { + Projectile.ai[0] = 1f; + } + + Vector2 center = Projectile.Center; + float x = player.Center.X - center.X; + float y = player.Center.Y - center.Y; + float distanceSQ = x * x + y * y; + if (distanceSQ > 2000f * 2000f) + { + Projectile.Center = player.Center; + } + else if (distanceSQ > num38 * num38 || (Math.Abs(y) > 300f && JumpTimer <= 0)) + { + if (y > 0f && Projectile.velocity.Y < 0f) + { + Projectile.velocity.Y = 0f; + } + if (y < 0f && Projectile.velocity.Y > 0f) + { + Projectile.velocity.Y = 0f; + } + Projectile.ai[0] = 1f; + } + } + + if (InAir) + { + float veloDelta = 0.2f; + int playerRange = 200; + + Projectile.tileCollide = false; + float desiredVeloX = player.Center.X - Projectile.Center.X; + + desiredVeloX -= 40 * player.direction; + + bool foundCloseTarget = false; + int targetIndex = -1; + + if (Projectile.minion) + { + float range = 700f; + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + if (npc.CanBeChasedBy()) + { + float distance = Math.Abs(player.Center.X - npc.Center.X) + Math.Abs(player.Center.Y - npc.Center.Y); + if (distance < range) + { + if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + { + targetIndex = k; + } + foundCloseTarget = true; + break; + } + } + } + } + + if (!foundCloseTarget) + { + desiredVeloX -= 40 * Projectile.minionPos * player.direction; + } + if (foundCloseTarget && targetIndex >= 0) + { + Projectile.ai[0] = 0f; + } + + float desiredVeloY = player.Center.Y - Projectile.Center.Y; + + float between = (float)Math.Sqrt(desiredVeloX * desiredVeloX + desiredVeloY * desiredVeloY); + //float num54 = num52; + + if (between < playerRange && player.velocity.Y == 0f && Projectile.position.Y + Projectile.height <= player.position.Y + player.height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + Projectile.ai[0] = 0f; + if (Projectile.velocity.Y < -6f) + { + Projectile.velocity.Y = -6f; + } + } + if (between < 60f) + { + desiredVeloX = Projectile.velocity.X; + desiredVeloY = Projectile.velocity.Y; + } + else + { + between = 10f / between; + desiredVeloX *= between; + desiredVeloY *= between; + } + + if (Projectile.velocity.X < desiredVeloX) + { + Projectile.velocity.X += veloDelta; + if (Projectile.velocity.X < 0f) + { + Projectile.velocity.X += veloDelta * 1.5f; + } + } + if (Projectile.velocity.X > desiredVeloX) + { + Projectile.velocity.X -= veloDelta; + if (Projectile.velocity.X > 0f) + { + Projectile.velocity.X -= veloDelta * 1.5f; + } + } + if (Projectile.velocity.Y < desiredVeloY) + { + Projectile.velocity.Y += veloDelta; + if (Projectile.velocity.Y < 0f) + { + Projectile.velocity.Y += veloDelta * 1.5f; + } + } + if (Projectile.velocity.Y > desiredVeloY) + { + Projectile.velocity.Y -= veloDelta; + if (Projectile.velocity.Y > 0f) + { + Projectile.velocity.Y -= veloDelta * 1.5f; + } + } + + Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); + } + else + { + float offset = 40 * Projectile.minionPos; + JumpTimer -= 1; + if (JumpTimer < 0) + { + JumpTimer = 0; + } + if (Projectile.ai[1] > 0f) + { + Projectile.ai[1] -= 1f; + } + else + { + float targetX = Projectile.position.X; + float targetY = Projectile.position.Y; + float distance = 100000f; + float otherDistance = distance; + targetNPC = -1; + + //------------------------------------------------------------------------------------ + //DISABLE MINION TARGETING------------------------------------------------------------ + //------------------------------------------------------------------------------------ + + if (Projectile.minion) + { + NPC ownerMinionAttackTargetNPC2 = Projectile.OwnerMinionAttackTargetNPC; + if (ownerMinionAttackTargetNPC2 != null && ownerMinionAttackTargetNPC2.CanBeChasedBy()) + { + float x = ownerMinionAttackTargetNPC2.Center.X; + float y = ownerMinionAttackTargetNPC2.Center.Y; + float num94 = Math.Abs(Projectile.Center.X - x) + Math.Abs(Projectile.Center.Y - y); + if (num94 < distance) + { + if (targetNPC == -1 && num94 <= otherDistance) + { + otherDistance = num94; + targetX = x; + targetY = y; + } + if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, ownerMinionAttackTargetNPC2.position, ownerMinionAttackTargetNPC2.width, ownerMinionAttackTargetNPC2.height)) + { + distance = num94; + targetX = x; + targetY = y; + targetNPC = ownerMinionAttackTargetNPC2.whoAmI; + } + } + } + if (targetNPC == -1) + { + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + if (npc.CanBeChasedBy()) + { + float npcX = npc.Center.X; + float npcY = npc.Center.Y; + float between = Math.Abs(Projectile.Center.X - npcX) + Math.Abs(Projectile.Center.Y - npcY); + if (between < distance) + { + if (targetNPC == -1 && between <= otherDistance) + { + otherDistance = between; + targetX = npcX; + targetY = npcY; + } + if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + { + distance = between; + targetX = npcX; + targetY = npcY; + targetNPC = k; + } + } + } + } + } + } + + if (targetNPC == -1 && otherDistance < distance) + { + distance = otherDistance; + } + + float num104 = 300f; + if (Projectile.position.Y > Main.worldSurface * 16.0) + { + num104 = 150f; + } + + if (distance < num104 + offset && targetNPC == -1) + { + float num105 = targetX - Projectile.Center.X; + if (num105 < -5f) + { + left = true; + right = false; + } + else if (num105 > 5f) + { + right = true; + left = false; + } + } + + //bool flag9 = false; + + if (targetNPC >= 0 && distance < 800f + offset) + { + Projectile.friendly = true; + JumpTimer = 60; + float distanceX = targetX - Projectile.Center.X; + if (distanceX < -10f) + { + left = true; + right = false; + } + else if (distanceX > 10f) + { + right = true; + left = false; + } + if (targetY < Projectile.Center.Y - 100f && distanceX > -50f && distanceX < 50f && Projectile.velocity.Y == 0f) + { + float distanceAbsY = Math.Abs(targetY - Projectile.Center.Y); + //jumping velocities + if (distanceAbsY < 100f) //120f + { + Projectile.velocity.Y = -10f; + } + else if (distanceAbsY < 210f) + { + Projectile.velocity.Y = -13f; + } + else if (distanceAbsY < 270f) + { + Projectile.velocity.Y = -15f; + } + else if (distanceAbsY < 310f) + { + Projectile.velocity.Y = -17f; + } + else if (distanceAbsY < 380f) + { + Projectile.velocity.Y = -18f; + } + } + + if (shootSpikes) + { + //PickedTexture * 3 makes it so theres a small offset for minion shooting based on their texture, which means that if you have different slimes out, + //they don't all shoot in sync + if (Projectile.owner == Main.myPlayer) + { + NPC npc = Main.npc[targetNPC]; + if (ShootTimer > (shootDelay + PickedTexture * 3) && distance < 200f && + Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + { + for (int k = 0; k < 3; k++) + { + Vector2 velo = new Vector2(k - 1, -2f); + velo.X *= 1f + Main.rand.Next(-40, 41) * 0.02f; + velo.Y *= 1f + Main.rand.Next(-40, 41) * 0.02f; + velo.Normalize(); + velo *= 3f + Main.rand.Next(-40, 41) * 0.01f; + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), Projectile.Center.X, Projectile.Bottom.Y - 8f, velo.X, velo.Y, ModContent.ProjectileType(), Projectile.damage / 2, 0f, Main.myPlayer, ai1: PickedTexture); + ShootTimer = (byte)(PickedTexture * 3); + } + } + } + if (ShootTimer <= shootDelay + PickedTexture * 3) ShootTimer = (byte)(ShootTimer + Main.rand.Next(2)); + } + } + else + { + Projectile.friendly = false; + } + } + + if (Projectile.ai[1] != 0f) + { + left = false; + right = false; + } + else if (JumpTimer == 0) + { + Projectile.direction = player.direction; + } + + Projectile.tileCollide = true; + + float veloXthreshold = 0.2f; + float maxVeloXthreshold = 6f; + + if (maxVeloXthreshold < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + { + veloXthreshold = 0.3f; + maxVeloXthreshold = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + } + + if (left) + { + if (Projectile.velocity.X > -3.5f) + { + Projectile.velocity.X -= veloXthreshold; + } + else + { + Projectile.velocity.X -= veloXthreshold * 0.25f; + } + } + else if (right) + { + if (Projectile.velocity.X < 3.5f) + { + Projectile.velocity.X += veloXthreshold; + } + else + { + Projectile.velocity.X += veloXthreshold * 0.25f; + } + } + else + { + Projectile.velocity.X *= 0.9f; + if (Projectile.velocity.X >= 0f - veloXthreshold && Projectile.velocity.X <= veloXthreshold) + { + Projectile.velocity.X = 0f; + } + } + + if (left | right) + { + int i = (int)Projectile.Center.X / 16; + int j = (int)Projectile.Center.Y / 16; + if (left) + { + i--; + } + if (right) + { + i++; + } + i += (int)Projectile.velocity.X; + if (WorldGen.SolidTile(i, j)) + { + flag4 = true; + } + } + if (player.position.Y + player.height - 8f > Projectile.position.Y + Projectile.height) + { + flag3 = true; + } + Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); + if (Projectile.velocity.Y == 0f) + { + if (!flag3 && (Projectile.velocity.X < 0f || Projectile.velocity.X > 0f)) + { + int i2 = (int)Projectile.Center.X / 16; + int j2 = (int)Projectile.Center.Y / 16 + 1; + if (left) + { + i2--; + } + if (right) + { + i2++; + } + WorldGen.SolidTile(i2, j2); + } + if (flag4) + { + int i = (int)Projectile.Center.X / 16; + int j = (int)Projectile.Bottom.Y / 16 + 1; + if (WorldGen.SolidTile(i, j) || Main.tile[i, j].IsHalfBlock || Main.tile[i, j].Slope > 0) + { + try + { + i = (int)Projectile.Center.X / 16; + j = (int)Projectile.Center.Y / 16; + if (left) + { + i--; + } + if (right) + { + i++; + } + i += (int)Projectile.velocity.X; + if (!WorldGen.SolidTile(i, j - 1) && !WorldGen.SolidTile(i, j - 2)) + { + Projectile.velocity.Y = -5.1f; + } + else if (!WorldGen.SolidTile(i, j - 2)) + { + Projectile.velocity.Y = -7.1f; + } + else if (WorldGen.SolidTile(i, j - 5)) + { + Projectile.velocity.Y = -11.1f; + } + else if (WorldGen.SolidTile(i, j - 4)) + { + Projectile.velocity.Y = -10.1f; + } + else + { + Projectile.velocity.Y = -9.1f; + } + } + catch + { + Projectile.velocity.Y = -9.1f; + } + } + } + else if (left | right) + { + Projectile.velocity.Y -= 6f; + } + } + if (Projectile.velocity.X > maxVeloXthreshold) + { + Projectile.velocity.X = maxVeloXthreshold; + } + if (Projectile.velocity.X < -maxVeloXthreshold) + { + Projectile.velocity.X = -maxVeloXthreshold; + } + if (Projectile.velocity.X != 0f) Projectile.direction = (Projectile.velocity.X > 0f).ToDirectionInt(); + if (Projectile.velocity.X > veloXthreshold && right) + { + Projectile.direction = 1; + } + if (Projectile.velocity.X < -veloXthreshold && left) + { + Projectile.direction = -1; + } + + if (Projectile.wet && Projectile.GetOwner().Bottom.Y < Projectile.Bottom.Y && JumpTimer == 0f) + { + if (Projectile.velocity.Y > -4f) + { + Projectile.velocity.Y -= 0.2f; + } + if (Projectile.velocity.Y > 0f) + { + Projectile.velocity.Y *= 0.95f; + } + } + else + { + Projectile.velocity.Y += 0.4f; + } + if (Projectile.velocity.Y > 10f) + { + Projectile.velocity.Y = 10f; + } + } + } + + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + if (targetNPC != -1) + { + NPC target = Main.npc[targetNPC]; + Vector2 toTarget = Projectile.DirectionTo(target.Center); + fallThrough = target.Center.Y > Projectile.Bottom.Y && Math.Abs(toTarget.X) < 300; + } + else + { + fallThrough = false; + } + return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); + } + } } diff --git a/Projectiles/Pets/BrainofConfusionProj.cs b/Projectiles/Pets/BrainofConfusionProj.cs index 16759e4a..c1ccf35e 100644 --- a/Projectiles/Pets/BrainofConfusionProj.cs +++ b/Projectiles/Pets/BrainofConfusionProj.cs @@ -1,45 +1,44 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class BrainofConfusionProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Brain of Confusion"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public class BrainofConfusionProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brain of Confusion"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.BrainofConfusion = false; - } - if (modPlayer.BrainofConfusion) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.BrainofConfusion = false; + } + if (modPlayer.BrainofConfusion) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/ChunkySlimeProj.cs b/Projectiles/Pets/ChunkySlimeProj.cs index 6dcd17e9..1fabeb0f 100644 --- a/Projectiles/Pets/ChunkySlimeProj.cs +++ b/Projectiles/Pets/ChunkySlimeProj.cs @@ -3,36 +3,36 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs)] - //check this file for more info vvvvvvvv - public class ChunkySlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("ChunkySlimeProj"); - } + [Content(ContentType.HostileNPCs)] + //check this file for more info vvvvvvvv + public class ChunkySlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("ChunkySlimeProj"); + } - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; - Projectile.alpha = 0; + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; + Projectile.alpha = 0; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.ChunkySlime = false; - } - if (modPlayer.ChunkySlime) - { - Projectile.timeLeft = 2; - } - return true; - } - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.ChunkySlime = false; + } + if (modPlayer.ChunkySlime) + { + Projectile.timeLeft = 2; + } + return true; + } + } } diff --git a/Projectiles/Pets/ChunkyandMeatball.cs b/Projectiles/Pets/ChunkyandMeatball.cs index 0ce92f18..3d46388c 100644 --- a/Projectiles/Pets/ChunkyandMeatball.cs +++ b/Projectiles/Pets/ChunkyandMeatball.cs @@ -1,99 +1,98 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs)] - public class ChunkyProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Chunky"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.HostileNPCs)] + public class ChunkyProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Chunky"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - AIType = ProjectileID.BabyEater; - Projectile.width = 22; - Projectile.height = 34; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + AIType = ProjectileID.BabyEater; + Projectile.width = 22; + Projectile.height = 34; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.eater = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.eater = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.ChunkyandMeatball = false; - } - if (modPlayer.ChunkyandMeatball) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.ChunkyandMeatball = false; + } + if (modPlayer.ChunkyandMeatball) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override void PostAI() - { - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X < 0).ToDirectionInt(); - } - } + public override void PostAI() + { + Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X < 0).ToDirectionInt(); + } + } - [Content(ContentType.HostileNPCs)] - public class MeatballProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Meatball"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.HostileNPCs)] + public class MeatballProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Meatball"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - AIType = ProjectileID.BabyEater; - Projectile.width = 22; - Projectile.height = 34; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + AIType = ProjectileID.BabyEater; + Projectile.width = 22; + Projectile.height = 34; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.eater = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.eater = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.ChunkyandMeatball = false; - } - if (modPlayer.ChunkyandMeatball) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.ChunkyandMeatball = false; + } + if (modPlayer.ChunkyandMeatball) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override void PostAI() - { - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X < 0).ToDirectionInt(); - } - } + public override void PostAI() + { + Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X < 0).ToDirectionInt(); + } + } } diff --git a/Projectiles/Pets/CompanionDungeonSoulPetProj.cs b/Projectiles/Pets/CompanionDungeonSoulPetProj.cs index e0c08e3a..3c293f83 100644 --- a/Projectiles/Pets/CompanionDungeonSoulPetProj.cs +++ b/Projectiles/Pets/CompanionDungeonSoulPetProj.cs @@ -10,163 +10,163 @@ namespace AssortedCrazyThings.Projectiles.Pets { - //Implementing classes at the bottom - [Content(ContentType.Bosses)] - public abstract class CompanionDungeonSoulPetProjBase : SimplePetProjBase - { - private int sincounter; - - public static Asset faceAsset; - - protected abstract ref bool GetBool(PetPlayer petPlayer); - - public virtual bool ReverseSide => false; - - public override void Load() - { - if (!Main.dedServ && faceAsset == null) - { - faceAsset = Mod.Assets.Request("Projectiles/Pets/CompanionDungeonSoulPetProj_Face"); - } - } - - public override void Unload() - { - faceAsset = null; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Companion Soul"); - Main.projFrames[Projectile.type] = 6; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 18; - Projectile.height = 28; - Projectile.alpha = 0; - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - float sinY = (float)((Math.Sin((sincounter / 120f) * MathHelper.TwoPi) - 1) * 10); - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 10f) + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - - float rotation = Projectile.rotation; - Vector2 origin = bounds.Size() / 2; - float scale = Projectile.scale; - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, rotation, origin, scale, effects, 0); - - image = faceAsset.Value; - Rectangle faceBounds = bounds; - faceBounds.Y = faceBounds.Height * GetFaceFrame(Projectile.GetOwner()); - Main.EntitySpriteDraw(image, drawPos, faceBounds, Color.White, rotation, origin, scale, effects, 0); - - return false; - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - - sincounter = sincounter > 120 ? 0 : sincounter + 1; - - ref bool petBool = ref GetBool(modPlayer); - if (player.dead) - { - petBool = false; - } - if (petBool) - { - Projectile.timeLeft = 2; - - AssAI.FlickerwickPetAI(Projectile, reverseSide: ReverseSide); - - AssAI.FlickerwickPetDraw(Projectile, frameCounterMaxFar: 4, frameCounterMaxClose: 7); - - Projectile.direction = Projectile.spriteDirection = -player.direction; - - Projectile.rotation = 0f; - } - } - - private int GetFaceFrame(Player player) - { - //Sorted by priority - //3: 25% health - //2: enemies nearby (60 tile radius) - //0: idle for long (2 minutes) - //5: idle for short (15 seconds) - //4: idle boss slain (1 minute ago) - //1: idle regular - - if (player.statLife <= player.statLifeMax2 * 0.25f) - { - return 3; - } - - AssPlayer aPlayer = player.GetModPlayer(); - aPlayer.needsNearbyEnemyNumber = true; - if (aPlayer.nearbyEnemyNumber >= 5) - { - return 2; - } - - if (player.afkCounter > 120 * 60) - { - return 0; - } - - if (player.afkCounter > 15 * 60) - { - return 5; - } - - if (aPlayer.HasSlainBossSecondsAgo(60)) - { - return 4; - } - - return 1; - } - } - - public class CompanionDungeonSoulPetProj : CompanionDungeonSoulPetProjBase - { - protected override ref bool GetBool(PetPlayer petPlayer) - { - return ref petPlayer.SoulLightPet; - } - - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); - - ProjectileID.Sets.LightPet[Projectile.type] = true; - } - } - - public class CompanionDungeonSoulPetProj2 : CompanionDungeonSoulPetProjBase - { - public override string Texture => "AssortedCrazyThings/Projectiles/Pets/CompanionDungeonSoulPetProj"; - - protected override ref bool GetBool(PetPlayer petPlayer) - { - return ref petPlayer.SoulLightPet2; - } - - public override bool ReverseSide => true; - } + //Implementing classes at the bottom + [Content(ContentType.Bosses)] + public abstract class CompanionDungeonSoulPetProjBase : SimplePetProjBase + { + private int sincounter; + + public static Asset faceAsset; + + protected abstract ref bool GetBool(PetPlayer petPlayer); + + public virtual bool ReverseSide => false; + + public override void Load() + { + if (!Main.dedServ && faceAsset == null) + { + faceAsset = Mod.Assets.Request("Projectiles/Pets/CompanionDungeonSoulPetProj_Face"); + } + } + + public override void Unload() + { + faceAsset = null; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Companion Soul"); + Main.projFrames[Projectile.type] = 6; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 18; + Projectile.height = 28; + Projectile.alpha = 0; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + float sinY = (float)((Math.Sin((sincounter / 120f) * MathHelper.TwoPi) - 1) * 10); + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 10f) + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + + float rotation = Projectile.rotation; + Vector2 origin = bounds.Size() / 2; + float scale = Projectile.scale; + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, rotation, origin, scale, effects, 0); + + image = faceAsset.Value; + Rectangle faceBounds = bounds; + faceBounds.Y = faceBounds.Height * GetFaceFrame(Projectile.GetOwner()); + Main.EntitySpriteDraw(image, drawPos, faceBounds, Color.White, rotation, origin, scale, effects, 0); + + return false; + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + + sincounter = sincounter > 120 ? 0 : sincounter + 1; + + ref bool petBool = ref GetBool(modPlayer); + if (player.dead) + { + petBool = false; + } + if (petBool) + { + Projectile.timeLeft = 2; + + AssAI.FlickerwickPetAI(Projectile, reverseSide: ReverseSide); + + AssAI.FlickerwickPetDraw(Projectile, frameCounterMaxFar: 4, frameCounterMaxClose: 7); + + Projectile.direction = Projectile.spriteDirection = -player.direction; + + Projectile.rotation = 0f; + } + } + + private int GetFaceFrame(Player player) + { + //Sorted by priority + //3: 25% health + //2: enemies nearby (60 tile radius) + //0: idle for long (2 minutes) + //5: idle for short (15 seconds) + //4: idle boss slain (1 minute ago) + //1: idle regular + + if (player.statLife <= player.statLifeMax2 * 0.25f) + { + return 3; + } + + AssPlayer aPlayer = player.GetModPlayer(); + aPlayer.needsNearbyEnemyNumber = true; + if (aPlayer.nearbyEnemyNumber >= 5) + { + return 2; + } + + if (player.afkCounter > 120 * 60) + { + return 0; + } + + if (player.afkCounter > 15 * 60) + { + return 5; + } + + if (aPlayer.HasSlainBossSecondsAgo(60)) + { + return 4; + } + + return 1; + } + } + + public class CompanionDungeonSoulPetProj : CompanionDungeonSoulPetProjBase + { + protected override ref bool GetBool(PetPlayer petPlayer) + { + return ref petPlayer.SoulLightPet; + } + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + + ProjectileID.Sets.LightPet[Projectile.type] = true; + } + } + + public class CompanionDungeonSoulPetProj2 : CompanionDungeonSoulPetProjBase + { + public override string Texture => "AssortedCrazyThings/Projectiles/Pets/CompanionDungeonSoulPetProj"; + + protected override ref bool GetBool(PetPlayer petPlayer) + { + return ref petPlayer.SoulLightPet2; + } + + public override bool ReverseSide => true; + } } diff --git a/Projectiles/Pets/CursedSkullProj.cs b/Projectiles/Pets/CursedSkullProj.cs index 8049eceb..9079f6c0 100644 --- a/Projectiles/Pets/CursedSkullProj.cs +++ b/Projectiles/Pets/CursedSkullProj.cs @@ -7,79 +7,79 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class CursedSkullProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/CursedSkullProj_0"; //temp - } - } + public class CursedSkullProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/CursedSkullProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cursed Skull"); - Main.projFrames[Projectile.type] = 3; - Main.projPet[Projectile.type] = true; - DrawOriginOffsetY = 2; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cursed Skull"); + Main.projFrames[Projectile.type] = 3; + Main.projPet[Projectile.type] = true; + DrawOriginOffsetY = 2; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.CursedSkull = false; - } - if (modPlayer.CursedSkull) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.CursedSkull = false; + } + if (modPlayer.CursedSkull) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override void PostAI() - { - if (Projectile.frame >= 3) Projectile.frame = 0; + public override void PostAI() + { + if (Projectile.frame >= 3) Projectile.frame = 0; - if (Projectile.Center.X - Projectile.GetOwner().Center.X > 0f) - { - Projectile.spriteDirection = 1; - } - else - { - Projectile.spriteDirection = -1; - } - } + if (Projectile.Center.X - Projectile.GetOwner().Center.X > 0f) + { + Projectile.spriteDirection = 1; + } + else + { + Projectile.spriteDirection = -1; + } + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/CursedSkullProj_" + mPlayer.cursedSkullType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/CursedSkullProj_" + mPlayer.cursedSkullType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + 2f + Projectile.gfxOffY); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + 2f + Projectile.gfxOffY); - //BEWARE, HERE THE COLOR IS Color.White INSTEAD OF lightColor - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, Color.White, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + //BEWARE, HERE THE COLOR IS Color.White INSTEAD OF lightColor + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, Color.White, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/CuteGastropodProj.cs b/Projectiles/Pets/CuteGastropodProj.cs index e6520772..7ed90739 100644 --- a/Projectiles/Pets/CuteGastropodProj.cs +++ b/Projectiles/Pets/CuteGastropodProj.cs @@ -4,42 +4,42 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.CuteSlimes)] - public class CuteGastropodProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cute Gastropod"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.CuteSlimes)] + public class CuteGastropodProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cute Gastropod"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.CuteGastropod = false; - } - if (modPlayer.CuteGastropod) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.CuteGastropod = false; + } + if (modPlayer.CuteGastropod) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/CuteLamiaPetProj.cs b/Projectiles/Pets/CuteLamiaPetProj.cs index 88ea0f65..3a604715 100644 --- a/Projectiles/Pets/CuteLamiaPetProj.cs +++ b/Projectiles/Pets/CuteLamiaPetProj.cs @@ -8,151 +8,151 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class CuteLamiaPetProj : SimplePetProjBase - { - private int frame2Counter = 0; - private int frame2 = 0; - public bool InAir => Projectile.ai[0] != 0f; - - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/CuteLamiaPetProj_0"; - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Small Snake"); - - Main.projFrames[Projectile.type] = 12; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyGrinch); - AIType = ProjectileID.BabyGrinch; - Projectile.width = 28; - Projectile.height = 40; - - DrawOriginOffsetY = -6; - DrawOriginOffsetX = 4; - } - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.grinch = false; // Relic from AIType - - GetFrame(); - - return true; - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.CuteLamiaPet = false; - } - if (modPlayer.CuteLamiaPet) - { - Projectile.timeLeft = 2; - } - } - - public override void PostAI() - { - Projectile.frameCounter = 0; - Projectile.frame = frame2; - - if (InAir) - { - //Rotate the direction it's moving, head forward - Projectile.rotation = Projectile.velocity.ToRotation(); - if (Projectile.spriteDirection == 1) - { - Projectile.rotation += MathHelper.Pi; - } - - Projectile.rotation -= Projectile.spriteDirection * MathHelper.PiOver2; - } - } - - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/CuteLamiaPetProj_" + mPlayer.cuteLamiaPetType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - float yOffset = -10f; - Vector2 stupidOffset = new Vector2(bounds.Width / 2, Projectile.height / 2 + Projectile.gfxOffY + 5f + yOffset); - - Vector2 origin = bounds.Size() / 2 - new Vector2(DrawOriginOffsetX, DrawOriginOffsetY - yOffset); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); - - return false; - } - - private void GetFrame() - { - if (!InAir) //not flying - { - if (Projectile.velocity.Y == 0f) - { - float xAbs = Math.Abs(Projectile.velocity.X); - if (Projectile.velocity.X == 0f) - { - frame2 = 0; - frame2Counter = 0; - } - else if (xAbs > 0.5f) - { - frame2Counter += (int)xAbs; - frame2Counter++; - if (frame2Counter > 14) //6 - { - frame2++; - frame2Counter = 0; - } - if (frame2 < 3 || frame2 > 7) //frame 3 to 7 is running - { - frame2 = 3; - } - } - else - { - frame2 = 0; //frame 0 is idle - frame2Counter = 7; - } - } - else if (Projectile.velocity.Y != 0f) - { - frame2Counter = 0; - frame2 = Projectile.velocity.Y > 0f ? 1 : 2;//frame 1 is jumping, frame 2 is falling - } - } - else //flying - { - frame2Counter++; - float speed = Projectile.velocity.LengthSquared() > 3f * 3f ? 4 : 6; - if (frame2Counter > speed) //6 - { - frame2++; - frame2Counter = 0; - } - - if (frame2 < 8 || frame2 > 11) - { - frame2 = 8; //flying frames 8 to 11 - } - } - } - } + [Content(ContentType.DroppedPets)] + public class CuteLamiaPetProj : SimplePetProjBase + { + private int frame2Counter = 0; + private int frame2 = 0; + public bool InAir => Projectile.ai[0] != 0f; + + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/CuteLamiaPetProj_0"; + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Small Snake"); + + Main.projFrames[Projectile.type] = 12; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyGrinch); + AIType = ProjectileID.BabyGrinch; + Projectile.width = 28; + Projectile.height = 40; + + DrawOriginOffsetY = -6; + DrawOriginOffsetX = 4; + } + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.grinch = false; // Relic from AIType + + GetFrame(); + + return true; + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.CuteLamiaPet = false; + } + if (modPlayer.CuteLamiaPet) + { + Projectile.timeLeft = 2; + } + } + + public override void PostAI() + { + Projectile.frameCounter = 0; + Projectile.frame = frame2; + + if (InAir) + { + //Rotate the direction it's moving, head forward + Projectile.rotation = Projectile.velocity.ToRotation(); + if (Projectile.spriteDirection == 1) + { + Projectile.rotation += MathHelper.Pi; + } + + Projectile.rotation -= Projectile.spriteDirection * MathHelper.PiOver2; + } + } + + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/CuteLamiaPetProj_" + mPlayer.cuteLamiaPetType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + float yOffset = -10f; + Vector2 stupidOffset = new Vector2(bounds.Width / 2, Projectile.height / 2 + Projectile.gfxOffY + 5f + yOffset); + + Vector2 origin = bounds.Size() / 2 - new Vector2(DrawOriginOffsetX, DrawOriginOffsetY - yOffset); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); + + return false; + } + + private void GetFrame() + { + if (!InAir) //not flying + { + if (Projectile.velocity.Y == 0f) + { + float xAbs = Math.Abs(Projectile.velocity.X); + if (Projectile.velocity.X == 0f) + { + frame2 = 0; + frame2Counter = 0; + } + else if (xAbs > 0.5f) + { + frame2Counter += (int)xAbs; + frame2Counter++; + if (frame2Counter > 14) //6 + { + frame2++; + frame2Counter = 0; + } + if (frame2 < 3 || frame2 > 7) //frame 3 to 7 is running + { + frame2 = 3; + } + } + else + { + frame2 = 0; //frame 0 is idle + frame2Counter = 7; + } + } + else if (Projectile.velocity.Y != 0f) + { + frame2Counter = 0; + frame2 = Projectile.velocity.Y > 0f ? 1 : 2;//frame 1 is jumping, frame 2 is falling + } + } + else //flying + { + frame2Counter++; + float speed = Projectile.velocity.LengthSquared() > 3f * 3f ? 4 : 6; + if (frame2Counter > speed) //6 + { + frame2++; + frame2Counter = 0; + } + + if (frame2 < 8 || frame2 > 11) + { + frame2 = 8; //flying frames 8 to 11 + } + } + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeBaseProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeBaseProj.cs index be47e02e..33eac5f7 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeBaseProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeBaseProj.cs @@ -14,528 +14,528 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - [Content(ContentType.CuteSlimes)] - public abstract class CuteSlimeBaseProj : SimplePetProjBase - { - private const string PetAccessoryFolder = "AssortedCrazyThings/Items/PetAccessories/"; - public const string Sheet = "_Sheet"; - public const string NoHair = "NoHair"; - public const string Addition = "Addition"; - public const string AccSheet = "_Draw"; - - public const int Projwidth = 28; - public const int Projheight = 32; - private const short clonedAIType = ProjectileID.PetLizard; - - public const int SheetCountX = 7; - public const int SheetCountY = 7; - - public const int DefaultX = 0; - public const int DefaultYIdleStart = 0; - public const int DefaultYIdleEnd = 1; - public const int DefaultYWalkStart = DefaultYIdleStart; - public const int DefaultYWalkEnd = DefaultYIdleEnd; - public const int DefaultYAir = 2; - public const int DefaultYFlyStart = 3; - public const int DefaultYFlyEnd = 6; - - public const int MeleeX = 1; - public const int MeleeYSwingStart = 0; - public const int MeleeYSwingEnd = 2; - - public const int BowX = 2; - public const int BowYDrawStart = 0; - public const int BowYDrawEnd = 3; - - public const int StaffX = 3; - public const int StaffYCast = 0; - public const int StaffYFlash = 1; - public const int StaffYStaff = 2; - - public const int SpikeX = 4; - public const int SpikeYStart = 0; - public const int SpikeYEnd = 1; - public const int SpikeYHug = 2; - - public const int TransformX = 5; - public const int TransformYStart = 0; - public const int TransformYEnd = 1; - - public const int SlimeX = 6; - public const int SlimeYIdleFirst = DefaultYIdleStart; - public const int SlimeYIdleLast = DefaultYIdleEnd; - public const int SlimeYWalkFirst = DefaultYIdleStart; - public const int SlimeYWalkLast = DefaultYIdleEnd; - public const int SlimeYAir = DefaultYAir; - public const int SlimeYFlyFirst = DefaultYFlyStart; - public const int SlimeYFlyLast = DefaultYFlyEnd; - - public static readonly int[] SheetCounts = new int[] { 7, 3, 4, 3, 3, 2, 7 }; - - protected int frameCounter = 0; - protected int frameX = 0; - protected int frameY = 0; - - public int oldHugType = -1; - public int hugType = -1; - - public static Dictionary> SheetAssets { get; private set; } - public static Dictionary> SheetNoHairAssets { get; private set; } - - /// - /// Values can be null if it does not exist - /// - public static Dictionary> SheetAdditionAssets { get; private set; } - /// - /// Values can be null if it does not exist - /// - public static Dictionary> SheetAdditionNoHairAssets { get; private set; } - - public override void Load() - { - if (SheetAssets == null) - SheetAssets = new Dictionary>(); - - if (SheetNoHairAssets == null) - SheetNoHairAssets = new Dictionary>(); - - if (SheetAdditionAssets == null) - SheetAdditionAssets = new Dictionary>(); - - if (SheetAdditionNoHairAssets == null) - SheetAdditionNoHairAssets = new Dictionary>(); - } - - public override void Unload() - { - SheetAssets = null; - - SheetNoHairAssets = null; - - SheetAdditionAssets = null; - - SheetAdditionNoHairAssets = null; - } - - public sealed override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 1; //Use dummy texture - Main.projPet[Projectile.type] = true; - - if (!Main.dedServ) - { - string sheetName = Texture + Sheet; - - //All of them have these - SheetAssets[Projectile.type] = ModContent.Request(sheetName); - - SheetNoHairAssets[Projectile.type] = ModContent.Request(sheetName + NoHair); - - //Only some have these - SheetAdditionAssets[Projectile.type] = GetTextureMaybeNull(sheetName + Addition); - - SheetAdditionNoHairAssets[Projectile.type] = GetTextureMaybeNull(sheetName + Addition + NoHair); - } - - SafeSetStaticDefaults(); - } - - private static Asset GetTextureMaybeNull(string name) - { - ModContent.RequestIfExists(name, out Asset asset); - - return asset; - } - - private void Animation(PetPlayer petPlayer) - { - if (petPlayer.IsHugging) - { - frameCounter = 0; - frameX = SpikeX; - frameY = SpikeYHug; - return; - } - - frameX = DefaultX; - - //readjusting the animation - if (InAir) - { - AssExtensions.LoopAnimationInt(ref frameY, ref frameCounter, 3, DefaultYFlyStart, DefaultYFlyEnd); - } - else - { - if (OnGround) - { - if (Idling) - { - //Idle - AssExtensions.LoopAnimationInt(ref frameY, ref frameCounter, 16, DefaultYIdleStart, DefaultYIdleEnd); - } - else if (Math.Abs(Projectile.velocity.X) > 0.1) - { - //Moving - frameCounter += (int)(Math.Abs(Projectile.velocity.X) * 0.25f); - AssExtensions.LoopAnimationInt(ref frameY, ref frameCounter, 6, DefaultYWalkStart, DefaultYWalkEnd); - } - else - { - frameY = DefaultYIdleEnd; - frameCounter = 0; - } - } - else //jumping/falling - { - frameCounter = 0; - frameY = DefaultYAir; - } - } - } - - //Clamps frames so they never point to invalid/blank frames - private void ClampFrames() - { - if (frameX < 0 || frameX >= SheetCountX) - { - frameX = 0; - } - - if (frameY < 0 || frameY >= SheetCounts[frameX]) - { - frameY = 0; - } - } - - public abstract ref bool PetBool(Player player); - - public virtual void SafeSetStaticDefaults() - { - - } - - public sealed override void SetDefaults() - { - Projectile.CloneDefaults(clonedAIType); - Projectile.width = Projwidth; - Projectile.height = Projheight; - AIType = clonedAIType; - //TODO revisit offsets - DrawOffsetX = -18; - DrawOriginOffsetY = -16; - - SafeSetDefaults(); - } - - public virtual void SafeSetDefaults() - { - - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write((byte)hugType); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - hugType = reader.ReadByte(); - } - - public sealed override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.lizard = false; - - ref bool petBool = ref PetBool(player); - if (player.dead) - { - petBool = false; - } - if (petBool) - { - Projectile.timeLeft = 2; - } - PetPlayer petPlayer = player.GetModPlayer(); - - if (SlimePets.TryGetPetFromProj(Projectile.type, out _)) - { - petPlayer.slimePetIndex = Projectile.whoAmI; - - petPlayer.UpdateSlimeHugs(this); - } - - Animation(petPlayer); - - ClampFrames(); - - HandleHugging(petPlayer); - - bool safe = SafePreAI(); - - if (petPlayer.IsHugging && petPlayer.TryGetSlimeHug(hugType, out SlimeHug hug)) - { - DoHugging(hug, petPlayer); - - return false; - } - - return safe; - } - - public virtual bool SafePreAI() - { - return true; - } - - public bool InAir => Projectile.ai[0] != 0f; - - public bool OnGround => Projectile.velocity.Y == 0; - - public bool Idling => OnGround && Projectile.velocity.X == 0f; - - public bool CanChooseHug(Player player) => OnGround && Collision.CanHit(Projectile, player); - - public sealed override void PostAI() - { - //DO NOT use the hook (ground logic is messed up with velocity.Y = 0.1f) - if (Projectile.velocity.Y != 0.1f) - { - Projectile.rotation = Projectile.velocity.X * 0.01f; - } - } - - /// - /// Executes the hug while it is ongoing (Excludes moving towards the hug) - /// - private void DoHugging(SlimeHug hug, PetPlayer petPlayer) - { - Player player = petPlayer.Player; - - //Turn away from slime - player.ChangeDir((player.Center.X > Projectile.Center.X).ToDirectionInt()); - //Turn slime in same direction as player - - //Lock position - Vector2 offset = new Vector2(-player.direction * 16, 0) + hug.GetHugOffset(this, petPlayer); - Projectile.velocity = Vector2.Zero; - Projectile.Bottom = player.Bottom + offset; - Projectile.spriteDirection = -player.direction; - } - - /// - /// Handles discovering if a hug is available, and starting/cancelling it - /// - private void HandleHugging(PetPlayer petPlayer) - { - Player player = petPlayer.Player; - - if (!petPlayer.TryGetSlimeHug(hugType, out SlimeHug hug)) - { - return; - } - - if (petPlayer.IsHugging && !PetPlayer.IsHuggable(player)) - { - //Cancel sequence prematurely - SetHugType(-1); - petPlayer.slimeHugTimer = -PetPlayer.HugDelayFail; - return; - } - - if (CanChooseHug(player) && hugType != -1) - { - if (oldHugType == -1) - { - int emoteIndex = hug.PreHugEmote; - if (emoteIndex > -1 && Main.netMode != NetmodeID.MultiplayerClient) - { - EmoteBubble.NewBubble(emoteIndex, new WorldUIAnchor(Projectile), hug.PreHugEmoteDuration); - } - } - - float distSQ = Projectile.DistanceSQ(player.Center); - - //Move towards player - int dir = (player.Center.X > Projectile.Center.X).ToDirectionInt(); - Projectile.velocity.X += dir * (distSQ > 40 * 40 ? 0.2f : 0.05f); - //Turn towards player - Projectile.spriteDirection = dir; - - if (distSQ < 20 * 20) - { - if (petPlayer.slimeHugTimer == 0) - { - petPlayer.slimeHugTimer = hug.HugDuration; - - int emoteIndex = hug.HugEmote; - if (emoteIndex > -1 && Main.netMode != NetmodeID.MultiplayerClient) //TODO test MP - { - EmoteBubble.NewBubble(emoteIndex, new WorldUIAnchor(Projectile), hug.HugEmoteDuration); - } - } - } - } - } - - public void SetHugType(int type) - { - hugType = type; - Projectile.netUpdate = true; - } - - public override bool PreDraw(ref Color drawColor) - { - DrawAccessories(drawColor, preDraw: true); - - DrawBaseSprite(drawColor); - - DrawAccessories(drawColor, preDraw: false); - return false; - } - - /// - /// Draws the base sprite. Picks the NoHair variant if needed - /// - private void DrawBaseSprite(Color drawColor) - { - PetPlayer pPlayer = Projectile.GetOwner().GetModPlayer(); - //check if it wears a "useNoHair" hat, then if it does, change the texture to that, - //otherwise use default one - bool useNoHair = false; - - if (pPlayer.TryGetAccessoryInSlot((byte)SlotType.Hat, out PetAccessory petAccessoryHat) && - petAccessoryHat.UseNoHair) //if it has a NoHair tex - { - useNoHair = true; - } - - bool drawPreAddition = true; - bool drawPostAddition = true; - - if (SlimePets.TryGetPetFromProj(Projectile.type, out SlimePet sPet)) - { - //handle if pre/post additions are drawn based on the slimePet(Pre/Post)AdditionSlot - for (byte slotNumber = 1; slotNumber < 5; slotNumber++) - { - if (pPlayer.TryGetAccessoryInSlot(slotNumber, out _)) - { - if (sPet.PreAdditionSlot == slotNumber) - drawPreAddition = false; - - if (sPet.PostAdditionSlot == slotNumber) - drawPostAddition = false; - } - } - } - else - { - //Can't receive any accessories, reset flag - useNoHair = false; - } - - bool drawnPreDraw = !drawPreAddition || SafePreDrawBaseSprite(drawColor, useNoHair); //do a pre-draw for rainbow and dungeon - - if (drawnPreDraw) - { - Texture2D texture = (useNoHair ? SheetNoHairAssets : SheetAssets)[Projectile.type].Value; - - if (texture == null) - { - return; - } - - Rectangle frameLocal = texture.Frame(SheetCountX, SheetCountY, frameX, frameY); - SpriteEffects effect = Projectile.spriteDirection != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(Projwidth * 0.5f, (texture.Height / SheetCountY) * 0.5f); - Vector2 stupidOffset = new Vector2(Projectile.type == ModContent.ProjectileType() ? -8f : 0f, Projectile.gfxOffY + DrawOriginOffsetY); - Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; - Color color = Projectile.GetAlpha(drawColor); - - Main.EntitySpriteDraw(texture, drawPos, frameLocal, color, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effect, 0); - } - - if (drawPostAddition) SafePostDrawBaseSprite(drawColor, useNoHair); //used for xmas bow, lava horn, princess crown and illuminant afterimage - } - - /// - /// Draw the pet specific PreDraw behind the base sprite - /// - public virtual bool SafePreDrawBaseSprite(Color drawColor, bool useNoHair) - { - return true; - } - - /// - /// Draw the pet specific PostDraw infront of the base sprite - /// - public virtual void SafePostDrawBaseSprite(Color drawColor, bool useNoHair) - { - - } - - /// - /// Draws the pet vanity accessories (behind or infront of the base sprite) - /// - private void DrawAccessories(Color drawColor, bool preDraw = false) - { - PetPlayer pPlayer = Projectile.GetOwner().GetModPlayer(); - bool isPet = SlimePets.TryGetPetFromProj(Projectile.type, out SlimePet sPet); - - string textureString; - string altTextureString; - Texture2D texture; - Rectangle frameLocal; - SpriteEffects effect; - Vector2 drawOrigin; - Vector2 stupidOffset; - Color color; - Vector2 originOffset; - Vector2 drawPos; - - List accessories = new(); - - for (byte slotNumber = 1; slotNumber < 5; slotNumber++) //0 is None, reserved - { - if (isPet && pPlayer.TryGetAccessoryInSlot(slotNumber, out PetAccessory petAccessory) && - !sPet.IsSlotTypeBlacklisted[slotNumber] && - (preDraw == petAccessory.PreDraw)) - { - accessories.Add(petAccessory); - } - } - - if (accessories.Count == 0) - { - return; - } - - int intended = Main.CurrentDrawnEntityShader; - Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); - - foreach (var petAccessory in accessories) - { - textureString = PetAccessoryFolder + petAccessory.Name; - altTextureString = petAccessory.HasAlts ? petAccessory.AltTextureSuffixes[petAccessory.AltTextureIndex] : ""; - - texture = ModContent.Request(textureString + altTextureString + AccSheet).Value; - - frameLocal = texture.Frame(SheetCountX, SheetCountY, frameX, frameY); - - //get necessary properties and parameters for draw - effect = Projectile.spriteDirection != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - drawOrigin = new Vector2(Projwidth * 0.5f, (texture.Height / SheetCountY) * 0.5f); - stupidOffset = new Vector2(Projectile.type == ModContent.ProjectileType() ? -8f : 0f, DrawOriginOffsetY + Projectile.gfxOffY); - color = drawColor * petAccessory.Opacity; - - originOffset = -petAccessory.Offset; - originOffset.X *= Math.Sign(Projectile.spriteDirection); - - drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; - Main.spriteBatch.Draw(texture, drawPos, frameLocal, color, Projectile.rotation, frameLocal.Size() / 2 + originOffset, Projectile.scale, effect, 0); - } - - Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); - } - } + [Content(ContentType.CuteSlimes)] + public abstract class CuteSlimeBaseProj : SimplePetProjBase + { + private const string PetAccessoryFolder = "AssortedCrazyThings/Items/PetAccessories/"; + public const string Sheet = "_Sheet"; + public const string NoHair = "NoHair"; + public const string Addition = "Addition"; + public const string AccSheet = "_Draw"; + + public const int Projwidth = 28; + public const int Projheight = 32; + private const short clonedAIType = ProjectileID.PetLizard; + + public const int SheetCountX = 7; + public const int SheetCountY = 7; + + public const int DefaultX = 0; + public const int DefaultYIdleStart = 0; + public const int DefaultYIdleEnd = 1; + public const int DefaultYWalkStart = DefaultYIdleStart; + public const int DefaultYWalkEnd = DefaultYIdleEnd; + public const int DefaultYAir = 2; + public const int DefaultYFlyStart = 3; + public const int DefaultYFlyEnd = 6; + + public const int MeleeX = 1; + public const int MeleeYSwingStart = 0; + public const int MeleeYSwingEnd = 2; + + public const int BowX = 2; + public const int BowYDrawStart = 0; + public const int BowYDrawEnd = 3; + + public const int StaffX = 3; + public const int StaffYCast = 0; + public const int StaffYFlash = 1; + public const int StaffYStaff = 2; + + public const int SpikeX = 4; + public const int SpikeYStart = 0; + public const int SpikeYEnd = 1; + public const int SpikeYHug = 2; + + public const int TransformX = 5; + public const int TransformYStart = 0; + public const int TransformYEnd = 1; + + public const int SlimeX = 6; + public const int SlimeYIdleFirst = DefaultYIdleStart; + public const int SlimeYIdleLast = DefaultYIdleEnd; + public const int SlimeYWalkFirst = DefaultYIdleStart; + public const int SlimeYWalkLast = DefaultYIdleEnd; + public const int SlimeYAir = DefaultYAir; + public const int SlimeYFlyFirst = DefaultYFlyStart; + public const int SlimeYFlyLast = DefaultYFlyEnd; + + public static readonly int[] SheetCounts = new int[] { 7, 3, 4, 3, 3, 2, 7 }; + + protected int frameCounter = 0; + protected int frameX = 0; + protected int frameY = 0; + + public int oldHugType = -1; + public int hugType = -1; + + public static Dictionary> SheetAssets { get; private set; } + public static Dictionary> SheetNoHairAssets { get; private set; } + + /// + /// Values can be null if it does not exist + /// + public static Dictionary> SheetAdditionAssets { get; private set; } + /// + /// Values can be null if it does not exist + /// + public static Dictionary> SheetAdditionNoHairAssets { get; private set; } + + public override void Load() + { + if (SheetAssets == null) + SheetAssets = new Dictionary>(); + + if (SheetNoHairAssets == null) + SheetNoHairAssets = new Dictionary>(); + + if (SheetAdditionAssets == null) + SheetAdditionAssets = new Dictionary>(); + + if (SheetAdditionNoHairAssets == null) + SheetAdditionNoHairAssets = new Dictionary>(); + } + + public override void Unload() + { + SheetAssets = null; + + SheetNoHairAssets = null; + + SheetAdditionAssets = null; + + SheetAdditionNoHairAssets = null; + } + + public sealed override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 1; //Use dummy texture + Main.projPet[Projectile.type] = true; + + if (!Main.dedServ) + { + string sheetName = Texture + Sheet; + + //All of them have these + SheetAssets[Projectile.type] = ModContent.Request(sheetName); + + SheetNoHairAssets[Projectile.type] = ModContent.Request(sheetName + NoHair); + + //Only some have these + SheetAdditionAssets[Projectile.type] = GetTextureMaybeNull(sheetName + Addition); + + SheetAdditionNoHairAssets[Projectile.type] = GetTextureMaybeNull(sheetName + Addition + NoHair); + } + + SafeSetStaticDefaults(); + } + + private static Asset GetTextureMaybeNull(string name) + { + ModContent.RequestIfExists(name, out Asset asset); + + return asset; + } + + private void Animation(PetPlayer petPlayer) + { + if (petPlayer.IsHugging) + { + frameCounter = 0; + frameX = SpikeX; + frameY = SpikeYHug; + return; + } + + frameX = DefaultX; + + //readjusting the animation + if (InAir) + { + AssExtensions.LoopAnimationInt(ref frameY, ref frameCounter, 3, DefaultYFlyStart, DefaultYFlyEnd); + } + else + { + if (OnGround) + { + if (Idling) + { + //Idle + AssExtensions.LoopAnimationInt(ref frameY, ref frameCounter, 16, DefaultYIdleStart, DefaultYIdleEnd); + } + else if (Math.Abs(Projectile.velocity.X) > 0.1) + { + //Moving + frameCounter += (int)(Math.Abs(Projectile.velocity.X) * 0.25f); + AssExtensions.LoopAnimationInt(ref frameY, ref frameCounter, 6, DefaultYWalkStart, DefaultYWalkEnd); + } + else + { + frameY = DefaultYIdleEnd; + frameCounter = 0; + } + } + else //jumping/falling + { + frameCounter = 0; + frameY = DefaultYAir; + } + } + } + + //Clamps frames so they never point to invalid/blank frames + private void ClampFrames() + { + if (frameX < 0 || frameX >= SheetCountX) + { + frameX = 0; + } + + if (frameY < 0 || frameY >= SheetCounts[frameX]) + { + frameY = 0; + } + } + + public abstract ref bool PetBool(Player player); + + public virtual void SafeSetStaticDefaults() + { + + } + + public sealed override void SetDefaults() + { + Projectile.CloneDefaults(clonedAIType); + Projectile.width = Projwidth; + Projectile.height = Projheight; + AIType = clonedAIType; + //TODO revisit offsets + DrawOffsetX = -18; + DrawOriginOffsetY = -16; + + SafeSetDefaults(); + } + + public virtual void SafeSetDefaults() + { + + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write((byte)hugType); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + hugType = reader.ReadByte(); + } + + public sealed override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.lizard = false; + + ref bool petBool = ref PetBool(player); + if (player.dead) + { + petBool = false; + } + if (petBool) + { + Projectile.timeLeft = 2; + } + PetPlayer petPlayer = player.GetModPlayer(); + + if (SlimePets.TryGetPetFromProj(Projectile.type, out _)) + { + petPlayer.slimePetIndex = Projectile.whoAmI; + + petPlayer.UpdateSlimeHugs(this); + } + + Animation(petPlayer); + + ClampFrames(); + + HandleHugging(petPlayer); + + bool safe = SafePreAI(); + + if (petPlayer.IsHugging && petPlayer.TryGetSlimeHug(hugType, out SlimeHug hug)) + { + DoHugging(hug, petPlayer); + + return false; + } + + return safe; + } + + public virtual bool SafePreAI() + { + return true; + } + + public bool InAir => Projectile.ai[0] != 0f; + + public bool OnGround => Projectile.velocity.Y == 0; + + public bool Idling => OnGround && Projectile.velocity.X == 0f; + + public bool CanChooseHug(Player player) => OnGround && Collision.CanHit(Projectile, player); + + public sealed override void PostAI() + { + //DO NOT use the hook (ground logic is messed up with velocity.Y = 0.1f) + if (Projectile.velocity.Y != 0.1f) + { + Projectile.rotation = Projectile.velocity.X * 0.01f; + } + } + + /// + /// Executes the hug while it is ongoing (Excludes moving towards the hug) + /// + private void DoHugging(SlimeHug hug, PetPlayer petPlayer) + { + Player player = petPlayer.Player; + + //Turn away from slime + player.ChangeDir((player.Center.X > Projectile.Center.X).ToDirectionInt()); + //Turn slime in same direction as player + + //Lock position + Vector2 offset = new Vector2(-player.direction * 16, 0) + hug.GetHugOffset(this, petPlayer); + Projectile.velocity = Vector2.Zero; + Projectile.Bottom = player.Bottom + offset; + Projectile.spriteDirection = -player.direction; + } + + /// + /// Handles discovering if a hug is available, and starting/cancelling it + /// + private void HandleHugging(PetPlayer petPlayer) + { + Player player = petPlayer.Player; + + if (!petPlayer.TryGetSlimeHug(hugType, out SlimeHug hug)) + { + return; + } + + if (petPlayer.IsHugging && !PetPlayer.IsHuggable(player)) + { + //Cancel sequence prematurely + SetHugType(-1); + petPlayer.slimeHugTimer = -PetPlayer.HugDelayFail; + return; + } + + if (CanChooseHug(player) && hugType != -1) + { + if (oldHugType == -1) + { + int emoteIndex = hug.PreHugEmote; + if (emoteIndex > -1 && Main.netMode != NetmodeID.MultiplayerClient) + { + EmoteBubble.NewBubble(emoteIndex, new WorldUIAnchor(Projectile), hug.PreHugEmoteDuration); + } + } + + float distSQ = Projectile.DistanceSQ(player.Center); + + //Move towards player + int dir = (player.Center.X > Projectile.Center.X).ToDirectionInt(); + Projectile.velocity.X += dir * (distSQ > 40 * 40 ? 0.2f : 0.05f); + //Turn towards player + Projectile.spriteDirection = dir; + + if (distSQ < 20 * 20) + { + if (petPlayer.slimeHugTimer == 0) + { + petPlayer.slimeHugTimer = hug.HugDuration; + + int emoteIndex = hug.HugEmote; + if (emoteIndex > -1 && Main.netMode != NetmodeID.MultiplayerClient) //TODO test MP + { + EmoteBubble.NewBubble(emoteIndex, new WorldUIAnchor(Projectile), hug.HugEmoteDuration); + } + } + } + } + } + + public void SetHugType(int type) + { + hugType = type; + Projectile.netUpdate = true; + } + + public override bool PreDraw(ref Color drawColor) + { + DrawAccessories(drawColor, preDraw: true); + + DrawBaseSprite(drawColor); + + DrawAccessories(drawColor, preDraw: false); + return false; + } + + /// + /// Draws the base sprite. Picks the NoHair variant if needed + /// + private void DrawBaseSprite(Color drawColor) + { + PetPlayer pPlayer = Projectile.GetOwner().GetModPlayer(); + //check if it wears a "useNoHair" hat, then if it does, change the texture to that, + //otherwise use default one + bool useNoHair = false; + + if (pPlayer.TryGetAccessoryInSlot((byte)SlotType.Hat, out PetAccessory petAccessoryHat) && + petAccessoryHat.UseNoHair) //if it has a NoHair tex + { + useNoHair = true; + } + + bool drawPreAddition = true; + bool drawPostAddition = true; + + if (SlimePets.TryGetPetFromProj(Projectile.type, out SlimePet sPet)) + { + //handle if pre/post additions are drawn based on the slimePet(Pre/Post)AdditionSlot + for (byte slotNumber = 1; slotNumber < 5; slotNumber++) + { + if (pPlayer.TryGetAccessoryInSlot(slotNumber, out _)) + { + if (sPet.PreAdditionSlot == slotNumber) + drawPreAddition = false; + + if (sPet.PostAdditionSlot == slotNumber) + drawPostAddition = false; + } + } + } + else + { + //Can't receive any accessories, reset flag + useNoHair = false; + } + + bool drawnPreDraw = !drawPreAddition || SafePreDrawBaseSprite(drawColor, useNoHair); //do a pre-draw for rainbow and dungeon + + if (drawnPreDraw) + { + Texture2D texture = (useNoHair ? SheetNoHairAssets : SheetAssets)[Projectile.type].Value; + + if (texture == null) + { + return; + } + + Rectangle frameLocal = texture.Frame(SheetCountX, SheetCountY, frameX, frameY); + SpriteEffects effect = Projectile.spriteDirection != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(Projwidth * 0.5f, (texture.Height / SheetCountY) * 0.5f); + Vector2 stupidOffset = new Vector2(Projectile.type == ModContent.ProjectileType() ? -8f : 0f, Projectile.gfxOffY + DrawOriginOffsetY); + Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; + Color color = Projectile.GetAlpha(drawColor); + + Main.EntitySpriteDraw(texture, drawPos, frameLocal, color, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effect, 0); + } + + if (drawPostAddition) SafePostDrawBaseSprite(drawColor, useNoHair); //used for xmas bow, lava horn, princess crown and illuminant afterimage + } + + /// + /// Draw the pet specific PreDraw behind the base sprite + /// + public virtual bool SafePreDrawBaseSprite(Color drawColor, bool useNoHair) + { + return true; + } + + /// + /// Draw the pet specific PostDraw infront of the base sprite + /// + public virtual void SafePostDrawBaseSprite(Color drawColor, bool useNoHair) + { + + } + + /// + /// Draws the pet vanity accessories (behind or infront of the base sprite) + /// + private void DrawAccessories(Color drawColor, bool preDraw = false) + { + PetPlayer pPlayer = Projectile.GetOwner().GetModPlayer(); + bool isPet = SlimePets.TryGetPetFromProj(Projectile.type, out SlimePet sPet); + + string textureString; + string altTextureString; + Texture2D texture; + Rectangle frameLocal; + SpriteEffects effect; + Vector2 drawOrigin; + Vector2 stupidOffset; + Color color; + Vector2 originOffset; + Vector2 drawPos; + + List accessories = new(); + + for (byte slotNumber = 1; slotNumber < 5; slotNumber++) //0 is None, reserved + { + if (isPet && pPlayer.TryGetAccessoryInSlot(slotNumber, out PetAccessory petAccessory) && + !sPet.IsSlotTypeBlacklisted[slotNumber] && + (preDraw == petAccessory.PreDraw)) + { + accessories.Add(petAccessory); + } + } + + if (accessories.Count == 0) + { + return; + } + + int intended = Main.CurrentDrawnEntityShader; + Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); + + foreach (var petAccessory in accessories) + { + textureString = PetAccessoryFolder + petAccessory.Name; + altTextureString = petAccessory.HasAlts ? petAccessory.AltTextureSuffixes[petAccessory.AltTextureIndex] : ""; + + texture = ModContent.Request(textureString + altTextureString + AccSheet).Value; + + frameLocal = texture.Frame(SheetCountX, SheetCountY, frameX, frameY); + + //get necessary properties and parameters for draw + effect = Projectile.spriteDirection != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + drawOrigin = new Vector2(Projwidth * 0.5f, (texture.Height / SheetCountY) * 0.5f); + stupidOffset = new Vector2(Projectile.type == ModContent.ProjectileType() ? -8f : 0f, DrawOriginOffsetY + Projectile.gfxOffY); + color = drawColor * petAccessory.Opacity; + + originOffset = -petAccessory.Offset; + originOffset.X *= Math.Sign(Projectile.spriteDirection); + + drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; + Main.spriteBatch.Draw(texture, drawPos, frameLocal, color, Projectile.rotation, frameLocal.Size() / 2 + originOffset, Projectile.scale, effect, 0); + } + + Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeBlackProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeBlackProj.cs index f74ba306..a183f0d5 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeBlackProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeBlackProj.cs @@ -2,19 +2,19 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeBlackProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeBlack; + public class CuteSlimeBlackProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeBlack; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Black Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Black Slime"); + } - public override void SafeSetDefaults() - { - //Projectile.scale = 0.9f; - Projectile.alpha = 75; - } - } + public override void SafeSetDefaults() + { + //Projectile.scale = 0.9f; + Projectile.alpha = 75; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeBlueProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeBlueProj.cs index 04beec07..b6b5b965 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeBlueProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeBlueProj.cs @@ -2,18 +2,18 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeBlueProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeBlue; + public class CuteSlimeBlueProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeBlue; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Blue Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Blue Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeCorruptProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeCorruptProj.cs index 131f1a34..6b0fe092 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeCorruptProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeCorruptProj.cs @@ -2,20 +2,20 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeCorruptProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeCorrupt; + public class CuteSlimeCorruptProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeCorrupt; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Corrupt Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Corrupt Slime"); + } - public override void SafeSetDefaults() - { - Projectile.scale = 1.2f; - Projectile.alpha = 75; - DrawOriginOffsetY = -14; - } - } + public override void SafeSetDefaults() + { + Projectile.scale = 1.2f; + Projectile.alpha = 75; + DrawOriginOffsetY = -14; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeCrimsonProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeCrimsonProj.cs index cf63a079..97ff7519 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeCrimsonProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeCrimsonProj.cs @@ -2,20 +2,20 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeCrimsonProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeCrimson; + public class CuteSlimeCrimsonProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeCrimson; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Crimson Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Crimson Slime"); + } - public override void SafeSetDefaults() - { - Projectile.scale = 1.2f; - Projectile.alpha = 75; - DrawOriginOffsetY = -14; - } - } + public override void SafeSetDefaults() + { + Projectile.scale = 1.2f; + Projectile.alpha = 75; + DrawOriginOffsetY = -14; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeDungeonProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeDungeonProj.cs index a49ec0cf..00ea9254 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeDungeonProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeDungeonProj.cs @@ -1,49 +1,47 @@ -using AssortedCrazyThings.Base; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeDungeonProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeDungeon; + public class CuteSlimeDungeonProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeDungeon; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Dungeon Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Dungeon Slime"); + } - public override void SafeSetDefaults() - { - Projectile.scale = 1.2f; - Projectile.alpha = 75; - DrawOriginOffsetY = -14; - } + public override void SafeSetDefaults() + { + Projectile.scale = 1.2f; + Projectile.alpha = 75; + DrawOriginOffsetY = -14; + } - public override bool SafePreDrawBaseSprite(Color lightColor, bool useNoHair) - { - var asset = SheetAdditionAssets[Projectile.type]; - if (asset == null) - { - return true; - } - int intended = Main.CurrentDrawnEntityShader; - Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); + public override bool SafePreDrawBaseSprite(Color lightColor, bool useNoHair) + { + var asset = SheetAdditionAssets[Projectile.type]; + if (asset == null) + { + return true; + } + int intended = Main.CurrentDrawnEntityShader; + Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); - SpriteEffects effects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - { - effects = SpriteEffects.FlipHorizontally; - } - Texture2D image = asset.Value; - Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); - Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, 10f + Projectile.gfxOffY); - Main.spriteBatch.Draw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); + SpriteEffects effects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + { + effects = SpriteEffects.FlipHorizontally; + } + Texture2D image = asset.Value; + Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); + Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, 10f + Projectile.gfxOffY); + Main.spriteBatch.Draw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); - Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); - return true; - } - } + Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); + return true; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeGreenProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeGreenProj.cs index 6b436974..491b47e6 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeGreenProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeGreenProj.cs @@ -2,19 +2,19 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeGreenProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeGreen; + public class CuteSlimeGreenProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeGreen; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Green Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Green Slime"); + } - public override void SafeSetDefaults() - { - //Projectile.scale = 0.9f; - Projectile.alpha = 75; - } - } + public override void SafeSetDefaults() + { + //Projectile.scale = 0.9f; + Projectile.alpha = 75; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeIceProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeIceProj.cs index 55cae1bc..6a491c67 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeIceProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeIceProj.cs @@ -2,18 +2,18 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeIceProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeIce; + public class CuteSlimeIceProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeIce; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Ice Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Ice Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeIlluminantProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeIlluminantProj.cs index 49bf39b0..4a96f529 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeIlluminantProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeIlluminantProj.cs @@ -2,49 +2,48 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeIlluminantProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeIlluminant; + public class CuteSlimeIlluminantProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeIlluminant; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Illuminant Slime"); - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Illuminant Slime"); + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + } - public override void SafeSetDefaults() - { - Projectile.alpha = 80; - } + public override void SafeSetDefaults() + { + Projectile.alpha = 80; + } - public override void SafePostDrawBaseSprite(Color drawColor, bool useNoHair) - { - var asset1 = SheetAdditionNoHairAssets[Projectile.type]; - var asset2 = SheetAdditionAssets[Projectile.type]; - if (asset1 == null || asset2 == null) - { - return; - } + public override void SafePostDrawBaseSprite(Color drawColor, bool useNoHair) + { + var asset1 = SheetAdditionNoHairAssets[Projectile.type]; + var asset2 = SheetAdditionAssets[Projectile.type]; + if (asset1 == null || asset2 == null) + { + return; + } - Texture2D image = (useNoHair ? asset1 : asset2).Value; - Rectangle bounds = image.Frame(SheetCountX, SheetCountY, frameX, frameY); + Texture2D image = (useNoHair ? asset1 : asset2).Value; + Rectangle bounds = image.Frame(SheetCountX, SheetCountY, frameX, frameY); - SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(-DrawOffsetX - 4f, Projectile.gfxOffY - DrawOriginOffsetY / 2 + 2f); - //the higher the k, the older the position - //Length is implicitely set in TrailCacheLength up there - for (int k = Projectile.oldPos.Length - 1; k >= 0; k--) - { - Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + drawOrigin; - Color color = Projectile.GetAlpha(Color.White) * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length)) * ((255 - Projectile.alpha) / 255f) * 0.5f; - color.A = (byte)(Projectile.alpha * ((Projectile.oldPos.Length - k) / Projectile.oldPos.Length)); - Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.oldRot[k], bounds.Size() / 2, Projectile.scale, effect, 0); - } - } - } + SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(-DrawOffsetX - 4f, Projectile.gfxOffY - DrawOriginOffsetY / 2 + 2f); + //the higher the k, the older the position + //Length is implicitely set in TrailCacheLength up there + for (int k = Projectile.oldPos.Length - 1; k >= 0; k--) + { + Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + drawOrigin; + Color color = Projectile.GetAlpha(Color.White) * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length)) * ((255 - Projectile.alpha) / 255f) * 0.5f; + color.A = (byte)(Projectile.alpha * ((Projectile.oldPos.Length - k) / Projectile.oldPos.Length)); + Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.oldRot[k], bounds.Size() / 2, Projectile.scale, effect, 0); + } + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeJungleProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeJungleProj.cs index 94f785b9..234cb792 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeJungleProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeJungleProj.cs @@ -2,19 +2,19 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeJungleProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeJungle; + public class CuteSlimeJungleProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeJungle; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Jungle Slime"); - DrawOffsetX = -18; - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Jungle Slime"); + DrawOffsetX = -18; + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeLavaProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeLavaProj.cs index 9b63713c..7f541165 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeLavaProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeLavaProj.cs @@ -1,54 +1,53 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeLavaProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeLava; + public class CuteSlimeLavaProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeLava; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Lava Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Lava Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } - public override void AI() - { - Vector2 pos = Projectile.BottomLeft - new Vector2(0f, Projheight); - Dust.NewDustDirect(pos, 28, Projheight, 6).noGravity = true; - } + public override void AI() + { + Vector2 pos = Projectile.BottomLeft - new Vector2(0f, Projheight); + Dust.NewDustDirect(pos, 28, Projheight, 6).noGravity = true; + } - public override Color? GetAlpha(Color drawColor) - { - drawColor = Color.White; - drawColor.A = 75; - return drawColor; - } + public override Color? GetAlpha(Color drawColor) + { + drawColor = Color.White; + drawColor.A = 75; + return drawColor; + } - public override void SafePostDrawBaseSprite(Color lightColor, bool useNoHair) - { - var asset = SheetAdditionAssets[Projectile.type]; - if (asset == null) - { - return; - } + public override void SafePostDrawBaseSprite(Color lightColor, bool useNoHair) + { + var asset = SheetAdditionAssets[Projectile.type]; + if (asset == null) + { + return; + } - SpriteEffects effects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - { - effects = SpriteEffects.FlipHorizontally; - } - Texture2D image = asset.Value; - Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); - Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, -6f - DrawOriginOffsetY + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); - } - } + SpriteEffects effects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + { + effects = SpriteEffects.FlipHorizontally; + } + Texture2D image = asset.Value; + Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); + Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, -6f - DrawOriginOffsetY + Projectile.gfxOffY); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimePinkProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimePinkProj.cs index 910e61af..7e1a5535 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimePinkProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimePinkProj.cs @@ -2,20 +2,20 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimePinkProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePink; + public class CuteSlimePinkProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePink; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Pink Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Pink Slime"); + } - public override void SafeSetDefaults() - { - //Projectile.scale = 0.8f; - Projectile.alpha = 75; - DrawOriginOffsetY = -21; - } - } + public override void SafeSetDefaults() + { + //Projectile.scale = 0.8f; + Projectile.alpha = 75; + DrawOriginOffsetY = -21; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimePrincessProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimePrincessProj.cs index e20d7069..93f32623 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimePrincessProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimePrincessProj.cs @@ -4,41 +4,41 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimePrincessProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePrincess; + public class CuteSlimePrincessProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePrincess; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Princess Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Princess Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } - public override void SafePostDrawBaseSprite(Color lightColor, bool useNoHair) - { - var asset = SheetAdditionAssets[Projectile.type]; - if (asset == null) - { - return; - } + public override void SafePostDrawBaseSprite(Color lightColor, bool useNoHair) + { + var asset = SheetAdditionAssets[Projectile.type]; + if (asset == null) + { + return; + } - int intended = Main.CurrentDrawnEntityShader; - Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); + int intended = Main.CurrentDrawnEntityShader; + Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); - SpriteEffects effects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - { - effects = SpriteEffects.FlipHorizontally; - } - Texture2D image = asset.Value; - Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); - Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, -6f - DrawOriginOffsetY + Projectile.gfxOffY); - Main.spriteBatch.Draw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); - Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); - } - } + SpriteEffects effects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + { + effects = SpriteEffects.FlipHorizontally; + } + Texture2D image = asset.Value; + Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); + Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, -6f - DrawOriginOffsetY + Projectile.gfxOffY); + Main.spriteBatch.Draw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); + Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimePurpleProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimePurpleProj.cs index 68c99306..2fdaa699 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimePurpleProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimePurpleProj.cs @@ -2,20 +2,20 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimePurpleProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePurple; + public class CuteSlimePurpleProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimePurple; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Purple Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Purple Slime"); + } - public override void SafeSetDefaults() - { - Projectile.scale = 1.2f; - Projectile.alpha = 75; - DrawOriginOffsetY = -14; - } - } + public override void SafeSetDefaults() + { + Projectile.scale = 1.2f; + Projectile.alpha = 75; + DrawOriginOffsetY = -14; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeQueenProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeQueenProj.cs index 4dd83d69..876298d9 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeQueenProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeQueenProj.cs @@ -4,42 +4,42 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - [Content(ContentType.CuteSlimes)] - public class CuteSlimeQueenProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeQueen; + [Content(ContentType.CuteSlimes)] + public class CuteSlimeQueenProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeQueen; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Queen Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Queen Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } - public override void SafePostDrawBaseSprite(Color lightColor, bool useNoHair) - { - var asset = SheetAdditionAssets[Projectile.type]; - if (asset == null) - { - return; - } + public override void SafePostDrawBaseSprite(Color lightColor, bool useNoHair) + { + var asset = SheetAdditionAssets[Projectile.type]; + if (asset == null) + { + return; + } - int intended = Main.CurrentDrawnEntityShader; - Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); + int intended = Main.CurrentDrawnEntityShader; + Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); - SpriteEffects effects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - { - effects = SpriteEffects.FlipHorizontally; - } - Texture2D image = asset.Value; - Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); - Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, -6f - DrawOriginOffsetY + Projectile.gfxOffY); - Main.spriteBatch.Draw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); - Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); - } - } + SpriteEffects effects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + { + effects = SpriteEffects.FlipHorizontally; + } + Texture2D image = asset.Value; + Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); + Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, -6f - DrawOriginOffsetY + Projectile.gfxOffY); + Main.spriteBatch.Draw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); + Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeRainbowProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeRainbowProj.cs index ba2d742b..6108d2da 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeRainbowProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeRainbowProj.cs @@ -1,42 +1,41 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeRainbowProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeRainbow; + public class CuteSlimeRainbowProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeRainbow; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Rainbow Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Rainbow Slime"); + } - public override void SafeSetDefaults() - { - Projectile.scale = 1.2f; - Projectile.alpha = 75; - DrawOriginOffsetY = -14; - } + public override void SafeSetDefaults() + { + Projectile.scale = 1.2f; + Projectile.alpha = 75; + DrawOriginOffsetY = -14; + } - public override bool SafePreDrawBaseSprite(Color lightColor, bool useNoHair) - { - double cX = Projectile.position.X + Projwidth * 2 + DrawOffsetX; - double cY = Projectile.position.Y + (Projheight - (DrawOriginOffsetY + 20f)) * 2; //20f for offset pre-draw, idk how and why - lightColor = Lighting.GetColor((int)(cX / 16), (int)(cY / 16), Main.DiscoColor * 1.2f); - lightColor *= (255f - Projectile.alpha) / 255f; - SpriteEffects effects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - { - effects = SpriteEffects.FlipHorizontally; - } - Texture2D image = (useNoHair ? SheetNoHairAssets : SheetAssets)[Projectile.type].Value; - Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); - Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, 6f + DrawOriginOffsetY + 20f + Projectile.gfxOffY); //20f for offset pre-draw, idk how and why - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + public override bool SafePreDrawBaseSprite(Color lightColor, bool useNoHair) + { + double cX = Projectile.position.X + Projwidth * 2 + DrawOffsetX; + double cY = Projectile.position.Y + (Projheight - (DrawOriginOffsetY + 20f)) * 2; //20f for offset pre-draw, idk how and why + lightColor = Lighting.GetColor((int)(cX / 16), (int)(cY / 16), Main.DiscoColor * 1.2f); + lightColor *= (255f - Projectile.alpha) / 255f; + SpriteEffects effects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + { + effects = SpriteEffects.FlipHorizontally; + } + Texture2D image = (useNoHair ? SheetNoHairAssets : SheetAssets)[Projectile.type].Value; + Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); + Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, 6f + DrawOriginOffsetY + 20f + Projectile.gfxOffY); //20f for offset pre-draw, idk how and why + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); + return false; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeRedProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeRedProj.cs index c7b1dcbd..766bbc34 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeRedProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeRedProj.cs @@ -2,18 +2,18 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeRedProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeRed; + public class CuteSlimeRedProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeRed; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Red Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Red Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeSandProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeSandProj.cs index 011746eb..1e34759a 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeSandProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeSandProj.cs @@ -2,18 +2,18 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeSandProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeSand; + public class CuteSlimeSandProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeSand; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Sand Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Sand Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 45; - } - } + public override void SafeSetDefaults() + { + Projectile.alpha = 45; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeToxicProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeToxicProj.cs index cd8caa53..8b326b87 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeToxicProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeToxicProj.cs @@ -2,18 +2,18 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeToxicProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeToxic; + public class CuteSlimeToxicProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeToxic; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Toxic Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Toxic Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeXmasProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeXmasProj.cs index fd050861..1a9f4b85 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeXmasProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeXmasProj.cs @@ -4,41 +4,41 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeXmasProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeXmas; + public class CuteSlimeXmasProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeXmas; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Christmas Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Christmas Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } - public override void SafePostDrawBaseSprite(Color lightColor, bool useNoHair) - { - var asset = SheetAdditionAssets[Projectile.type]; - if (asset == null) - { - return; - } + public override void SafePostDrawBaseSprite(Color lightColor, bool useNoHair) + { + var asset = SheetAdditionAssets[Projectile.type]; + if (asset == null) + { + return; + } - int intended = Main.CurrentDrawnEntityShader; - Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); + int intended = Main.CurrentDrawnEntityShader; + Main.instance.PrepareDrawnEntityDrawing(Projectile, 0); - SpriteEffects effects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - { - effects = SpriteEffects.FlipHorizontally; - } - Texture2D image = asset.Value; - Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); - Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, -6f - DrawOriginOffsetY + Projectile.gfxOffY); - Main.spriteBatch.Draw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); - Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); - } - } + SpriteEffects effects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + { + effects = SpriteEffects.FlipHorizontally; + } + Texture2D image = asset.Value; + Rectangle frameLocal = image.Frame(SheetCountX, SheetCountY, frameX, frameY); + Vector2 stupidOffset = new Vector2(Projwidth * 0.5f, -6f - DrawOriginOffsetY + Projectile.gfxOffY); + Main.spriteBatch.Draw(image, Projectile.position - Main.screenPosition + stupidOffset, frameLocal, lightColor, Projectile.rotation, frameLocal.Size() / 2, Projectile.scale, effects, 0); + Main.instance.PrepareDrawnEntityDrawing(Projectile, intended); + } + } } diff --git a/Projectiles/Pets/CuteSlimes/CuteSlimeYellowProj.cs b/Projectiles/Pets/CuteSlimes/CuteSlimeYellowProj.cs index 29dd7570..eb76fa4a 100644 --- a/Projectiles/Pets/CuteSlimes/CuteSlimeYellowProj.cs +++ b/Projectiles/Pets/CuteSlimes/CuteSlimeYellowProj.cs @@ -2,18 +2,18 @@ namespace AssortedCrazyThings.Projectiles.Pets.CuteSlimes { - public class CuteSlimeYellowProj : CuteSlimeBaseProj - { - public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeYellow; + public class CuteSlimeYellowProj : CuteSlimeBaseProj + { + public override ref bool PetBool(Player player) => ref player.GetModPlayer().CuteSlimeYellow; - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Cute Yellow Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cute Yellow Slime"); + } - public override void SafeSetDefaults() - { - Projectile.alpha = 75; - } - } + public override void SafeSetDefaults() + { + Projectile.alpha = 75; + } + } } diff --git a/Projectiles/Pets/DemonHeartProj.cs b/Projectiles/Pets/DemonHeartProj.cs index 158175c6..afd03e39 100644 --- a/Projectiles/Pets/DemonHeartProj.cs +++ b/Projectiles/Pets/DemonHeartProj.cs @@ -1,45 +1,44 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class DemonHeartProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Demon Heart"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public class DemonHeartProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Demon Heart"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.DemonHeart = false; - } - if (modPlayer.DemonHeart) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.DemonHeart = false; + } + if (modPlayer.DemonHeart) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/DetachedHungryProj.cs b/Projectiles/Pets/DetachedHungryProj.cs index 8dec09c3..4baece5d 100644 --- a/Projectiles/Pets/DetachedHungryProj.cs +++ b/Projectiles/Pets/DetachedHungryProj.cs @@ -1,45 +1,44 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class DetachedHungryProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Detached Hungry"); - Main.projFrames[Projectile.type] = 6; - Main.projPet[Projectile.type] = true; - } + public class DetachedHungryProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Detached Hungry"); + Main.projFrames[Projectile.type] = 6; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.DetachedHungry = false; - } - if (modPlayer.DetachedHungry) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.DetachedHungry = false; + } + if (modPlayer.DetachedHungry) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/DocileDemonEyeProj.cs b/Projectiles/Pets/DocileDemonEyeProj.cs index e03a0663..3efd9913 100644 --- a/Projectiles/Pets/DocileDemonEyeProj.cs +++ b/Projectiles/Pets/DocileDemonEyeProj.cs @@ -7,70 +7,70 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class DocileDemonEyeProj : SimplePetProjBase - { - public const byte TotalNumberOfThese = 12; + public class DocileDemonEyeProj : SimplePetProjBase + { + public const byte TotalNumberOfThese = 12; - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/DocileDemonEyeProj_0"; //temp - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/DocileDemonEyeProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Docile Demon Eye"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Docile Demon Eye"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - AIType = ProjectileID.BabyEater; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + AIType = ProjectileID.BabyEater; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.eater = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.eater = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.DocileDemonEye = false; - } - if (modPlayer.DocileDemonEye) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.DocileDemonEye = false; + } + if (modPlayer.DocileDemonEye) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/DocileDemonEyeProj_" + mPlayer.petEyeType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/DocileDemonEyeProj_" + mPlayer.petEyeType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } + return false; + } - public override void PostAI() - { - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X < 0).ToDirectionInt(); - } - } + public override void PostAI() + { + Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X < 0).ToDirectionInt(); + } + } } diff --git a/Projectiles/Pets/DrumstickElementalProj.cs b/Projectiles/Pets/DrumstickElementalProj.cs index eb17bd81..d3a5aeb7 100644 --- a/Projectiles/Pets/DrumstickElementalProj.cs +++ b/Projectiles/Pets/DrumstickElementalProj.cs @@ -1,45 +1,44 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class DrumstickElementalProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Drumstick Elemental"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public class DrumstickElementalProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Drumstick Elemental"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.DrumstickElemental = false; - } - if (modPlayer.DrumstickElemental) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.DrumstickElemental = false; + } + if (modPlayer.DrumstickElemental) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/DynamiteBunnyProj.cs b/Projectiles/Pets/DynamiteBunnyProj.cs index 91fb3b46..01eca86c 100644 --- a/Projectiles/Pets/DynamiteBunnyProj.cs +++ b/Projectiles/Pets/DynamiteBunnyProj.cs @@ -9,144 +9,144 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class DynamiteBunnyProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/DynamiteBunnyProj_0"; //temp - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Dynamite Bunny"); - Main.projFrames[Projectile.type] = Main.projFrames[ProjectileID.Bunny]; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.Bunny); - AIType = ProjectileID.Bunny; - DrawOriginOffsetY = -7; - } - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.bunny = false; // Relic from AIType - return true; - } - - public short prevDynamiteBunnyType = -1; - - public const int ExplosionTimerDecr = 4; - public const int ExplosionTimerMax = 255 + ExplosionTimerDecr * 60; - private int explosionTimer = 0; - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.DynamiteBunny = false; - } - if (modPlayer.DynamiteBunny) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - - if (explosionTimer > 0) - { - explosionTimer -= ExplosionTimerDecr; - - if (explosionTimer < 0) - { - explosionTimer = 0; - } - } - - Projectile.alpha = Math.Min(255, explosionTimer); - - byte dynamiteBunnyType = modPlayer.dynamiteBunnyType; - if (prevDynamiteBunnyType == -1) - { - prevDynamiteBunnyType = dynamiteBunnyType; - } - - if (prevDynamiteBunnyType != dynamiteBunnyType) - { - explosionTimer = ExplosionTimerMax; - - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - - for (int i = 0; i < 10; i++) //40 - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default(Color), 2f); - dust.velocity *= 2f; //3f - if (Main.rand.NextBool(2)) - { - dust.scale = 0.5f; - dust.fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int i = 0; i < 17; i++) //70 - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 3f); - dust.noGravity = true; - dust.velocity *= 4f; //5f - dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 2f); - dust.velocity *= 2f; - } - for (int i = 0; i < 2; i++) //3 - { - float scaleFactor10 = 0.33f; - if (i == 1) - { - scaleFactor10 = 0.66f; - } - if (i == 2) - { - scaleFactor10 = 1f; - } - Gore gore = Main.gore[Gore.NewGore(Projectile.Center - new Vector2(24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; - gore.velocity *= scaleFactor10; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - gore = Main.gore[Gore.NewGore(Projectile.Center - new Vector2(24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; - gore.velocity *= scaleFactor10; - gore.velocity.X += -1f; - gore.velocity.Y += 1f; - gore = Main.gore[Gore.NewGore(Projectile.Center - new Vector2(24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; - gore.velocity *= scaleFactor10; - gore.velocity.X += 1f; - gore.velocity.Y += -1f; - gore = Main.gore[Gore.NewGore(Projectile.Center - new Vector2(24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; - gore.velocity *= scaleFactor10; - gore.velocity.X += -1f; - gore.velocity.Y += -1f; - } - } - - prevDynamiteBunnyType = dynamiteBunnyType; - } - - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/DynamiteBunnyProj_" + mPlayer.dynamiteBunnyType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + DrawOriginOffsetY + Projectile.gfxOffY); - - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, Projectile.GetAlpha(lightColor), Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - - return false; - } - } + public class DynamiteBunnyProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/DynamiteBunnyProj_0"; //temp + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dynamite Bunny"); + Main.projFrames[Projectile.type] = Main.projFrames[ProjectileID.Bunny]; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.Bunny); + AIType = ProjectileID.Bunny; + DrawOriginOffsetY = -7; + } + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.bunny = false; // Relic from AIType + return true; + } + + public short prevDynamiteBunnyType = -1; + + public const int ExplosionTimerDecr = 4; + public const int ExplosionTimerMax = 255 + ExplosionTimerDecr * 60; + private int explosionTimer = 0; + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.DynamiteBunny = false; + } + if (modPlayer.DynamiteBunny) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + + if (explosionTimer > 0) + { + explosionTimer -= ExplosionTimerDecr; + + if (explosionTimer < 0) + { + explosionTimer = 0; + } + } + + Projectile.alpha = Math.Min(255, explosionTimer); + + byte dynamiteBunnyType = modPlayer.dynamiteBunnyType; + if (prevDynamiteBunnyType == -1) + { + prevDynamiteBunnyType = dynamiteBunnyType; + } + + if (prevDynamiteBunnyType != dynamiteBunnyType) + { + explosionTimer = ExplosionTimerMax; + + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + + for (int i = 0; i < 10; i++) //40 + { + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default(Color), 2f); + dust.velocity *= 2f; //3f + if (Main.rand.NextBool(2)) + { + dust.scale = 0.5f; + dust.fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int i = 0; i < 17; i++) //70 + { + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 3f); + dust.noGravity = true; + dust.velocity *= 4f; //5f + dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default(Color), 2f); + dust.velocity *= 2f; + } + for (int i = 0; i < 2; i++) //3 + { + float scaleFactor10 = 0.33f; + if (i == 1) + { + scaleFactor10 = 0.66f; + } + if (i == 2) + { + scaleFactor10 = 1f; + } + Gore gore = Main.gore[Gore.NewGore(Projectile.Center - new Vector2(24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X += 1f; + gore.velocity.Y += 1f; + gore = Main.gore[Gore.NewGore(Projectile.Center - new Vector2(24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X += -1f; + gore.velocity.Y += 1f; + gore = Main.gore[Gore.NewGore(Projectile.Center - new Vector2(24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X += 1f; + gore.velocity.Y += -1f; + gore = Main.gore[Gore.NewGore(Projectile.Center - new Vector2(24f), default(Vector2), Main.rand.Next(61, 64), 1f)]; + gore.velocity *= scaleFactor10; + gore.velocity.X += -1f; + gore.velocity.Y += -1f; + } + } + + prevDynamiteBunnyType = dynamiteBunnyType; + } + + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/DynamiteBunnyProj_" + mPlayer.dynamiteBunnyType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + DrawOriginOffsetY + Projectile.gfxOffY); + + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, Projectile.GetAlpha(lightColor), Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + + return false; + } + } } diff --git a/Projectiles/Pets/EnchantedSwordProj.cs b/Projectiles/Pets/EnchantedSwordProj.cs index bf9eb1f9..47c9d3d4 100644 --- a/Projectiles/Pets/EnchantedSwordProj.cs +++ b/Projectiles/Pets/EnchantedSwordProj.cs @@ -1,47 +1,46 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class EnchantedSwordProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Enchanted Sword"); - Main.projFrames[Projectile.type] = 8; - Main.projPet[Projectile.type] = true; - } + public class EnchantedSwordProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Enchanted Sword"); + Main.projFrames[Projectile.type] = 8; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.TikiSpirit); - AIType = ProjectileID.TikiSpirit; - Projectile.width = 26; - Projectile.height = 50; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.TikiSpirit); + AIType = ProjectileID.TikiSpirit; + Projectile.width = 26; + Projectile.height = 50; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.tiki = false; - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.tiki = false; + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.EnchantedSword = false; - } - if (modPlayer.EnchantedSword) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.EnchantedSword = false; + } + if (modPlayer.EnchantedSword) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/FailureSlimeProj.cs b/Projectiles/Pets/FailureSlimeProj.cs index da1b00d0..b8fbe8a7 100644 --- a/Projectiles/Pets/FailureSlimeProj.cs +++ b/Projectiles/Pets/FailureSlimeProj.cs @@ -1,38 +1,37 @@ using AssortedCrazyThings.Base; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - //check this file for more info vvvvvvvv - public class FailureSlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Failure Slime"); - } + //check this file for more info vvvvvvvv + public class FailureSlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Failure Slime"); + } - public override void SafeSetDefaults() - { - Projectile.width = 34; - Projectile.height = 30; - Projectile.alpha = 0; + public override void SafeSetDefaults() + { + Projectile.width = 34; + Projectile.height = 30; + Projectile.alpha = 0; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.FailureSlime = false; - } - if (modPlayer.FailureSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.FailureSlime = false; + } + if (modPlayer.FailureSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + } } diff --git a/Projectiles/Pets/FairySlimeProj.cs b/Projectiles/Pets/FairySlimeProj.cs index defeebe8..089fd8d9 100644 --- a/Projectiles/Pets/FairySlimeProj.cs +++ b/Projectiles/Pets/FairySlimeProj.cs @@ -1,38 +1,37 @@ using AssortedCrazyThings.Base; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.FriendlyNPCs)] - //check this file for more info vvvvvvvv - public class FairySlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Fairy Slime"); - } + [Content(ContentType.FriendlyNPCs)] + //check this file for more info vvvvvvvv + public class FairySlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Fairy Slime"); + } - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.FairySlime = false; - } - if (modPlayer.FairySlime) - { - Projectile.timeLeft = 2; - } - return true; - } - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.FairySlime = false; + } + if (modPlayer.FairySlime) + { + Projectile.timeLeft = 2; + } + return true; + } + } } diff --git a/Projectiles/Pets/FairySwarmProj.cs b/Projectiles/Pets/FairySwarmProj.cs index ebc92d21..a03b30dd 100644 --- a/Projectiles/Pets/FairySwarmProj.cs +++ b/Projectiles/Pets/FairySwarmProj.cs @@ -1,42 +1,41 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class FairySwarmProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Fairy Swarm"); - Main.projFrames[Projectile.type] = 1; //The texture is a dummy - Main.projPet[Projectile.type] = true; - } + public class FairySwarmProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fairy Swarm"); + Main.projFrames[Projectile.type] = 1; //The texture is a dummy + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - Projectile.alpha = 255; - Projectile.hide = true; - Projectile.aiStyle = -1; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + Projectile.alpha = 255; + Projectile.hide = true; + Projectile.aiStyle = -1; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.FairySwarm = false; - } - if (modPlayer.FairySwarm) - { - Projectile.timeLeft = 2; - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.FairySwarm = false; + } + if (modPlayer.FairySwarm) + { + Projectile.timeLeft = 2; + } - Projectile.Center = player.Center; - Projectile.gfxOffY = player.gfxOffY; - } - } + Projectile.Center = player.Center; + Projectile.gfxOffY = player.gfxOffY; + } + } } diff --git a/Projectiles/Pets/GhostMartianProj.cs b/Projectiles/Pets/GhostMartianProj.cs index ad604573..87131989 100644 --- a/Projectiles/Pets/GhostMartianProj.cs +++ b/Projectiles/Pets/GhostMartianProj.cs @@ -5,66 +5,65 @@ using Terraria; using Terraria.GameContent; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class GhostMartianProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ghost Martian"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public class GhostMartianProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ghost Martian"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 22; - Projectile.height = 42; - Projectile.alpha = 70; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 22; + Projectile.height = 42; + Projectile.alpha = 70; + } - private const int sincounterMax = 130; - private int sincounter; + private const int sincounterMax = 130; + private int sincounter; - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = TextureAssets.Projectile[Type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = TextureAssets.Projectile[Type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - float sinY = (float)((Math.Sin(((float)sincounter / sincounterMax) * MathHelper.TwoPi) - 1) * 2); + float sinY = (float)((Math.Sin(((float)sincounter / sincounterMax) * MathHelper.TwoPi) - 1) * 2); - Vector2 stupidOffset = new Vector2(image.Width / 2, Projectile.height / 2 + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 stupidOffset = new Vector2(image.Width / 2, Projectile.height / 2 + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, 0f, bounds.Size() / 2, 1f, Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); - return false; - } + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, 0f, bounds.Size() / 2, 1f, Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + return false; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); - sincounter = sincounter > sincounterMax ? 0 : sincounter + 1; + sincounter = sincounter > sincounterMax ? 0 : sincounter + 1; - if (player.dead) - { - modPlayer.GhostMartian = false; - } - if (modPlayer.GhostMartian) - { - Projectile.timeLeft = 2; + if (player.dead) + { + modPlayer.GhostMartian = false; + } + if (modPlayer.GhostMartian) + { + Projectile.timeLeft = 2; - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, offsetX: -6f, offsetY: 6f); + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, offsetX: -6f, offsetY: 6f); - Projectile.spriteDirection = (player.Center.X <= Projectile.Center.X).ToDirectionInt(); + Projectile.spriteDirection = (player.Center.X <= Projectile.Center.X).ToDirectionInt(); - AssAI.FlickerwickPetDraw(Projectile, frameCounterMaxFar: 4, frameCounterMaxClose: 10); - } - } - } + AssAI.FlickerwickPetDraw(Projectile, frameCounterMaxFar: 4, frameCounterMaxClose: 10); + } + } + } } diff --git a/Projectiles/Pets/GobletProj.cs b/Projectiles/Pets/GobletProj.cs index bbe76e4c..6ae588e4 100644 --- a/Projectiles/Pets/GobletProj.cs +++ b/Projectiles/Pets/GobletProj.cs @@ -1,126 +1,123 @@ using AssortedCrazyThings.Base; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class GobletProj : SimplePetProjBase - { - private int frame2Counter = 0; - private int frame2 = 0; + [Content(ContentType.DroppedPets)] + public class GobletProj : SimplePetProjBase + { + private int frame2Counter = 0; + private int frame2 = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Goblet"); - Main.projFrames[Projectile.type] = 12; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Goblet"); + Main.projFrames[Projectile.type] = 12; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyGrinch); - AIType = ProjectileID.BabyGrinch; - Projectile.width = 24; //40 for flying - Projectile.height = 38; - DrawOriginOffsetY = 4; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyGrinch); + AIType = ProjectileID.BabyGrinch; + Projectile.width = 24; //40 for flying + Projectile.height = 38; + DrawOriginOffsetY = 4; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.grinch = false; // Relic from AIType + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.grinch = false; // Relic from AIType - GetFrame(); + GetFrame(); - return true; - } + return true; + } - public bool InAir => Projectile.ai[0] != 0f; + public bool InAir => Projectile.ai[0] != 0f; - private void GetFrame() - { - if (!InAir) //not flying - { - if (Projectile.velocity.Y == 0f) - { - float xAbs = Math.Abs(Projectile.velocity.X); - if (Projectile.velocity.X == 0f) - { - frame2 = 0; - frame2Counter = 0; - } - else if (xAbs > 0.5f) - { - frame2Counter += (int)xAbs; - frame2Counter++; - if (frame2Counter > 20) //6 - { - frame2++; - frame2Counter = 0; - } - if (frame2 > 6) //frame 1 to 6 is running - { - frame2 = 1; - } - } - else - { - frame2 = 0; //frame 0 is idle - frame2Counter = 10; - } - } - else if (Projectile.velocity.Y != 0f) - { - frame2Counter = 0; - frame2 = 7; //frame 7 is jumping - } - //projectile.velocity.Y += 0.4f; - //if (projectile.velocity.Y > 10f) - //{ - // projectile.velocity.Y = 10f; - //} - } - else //flying - { - if (Projectile.velocity.X <= 0) Projectile.direction = -1; - else Projectile.direction = 1; - frame2Counter++; - if (Projectile.velocity.Length() > 3.6f) Projectile.velocity *= 0.97f; - if (frame2Counter > 4) - { - frame2++; - frame2Counter = 0; - } - if (frame2 < 8 || frame2 > 11) - { - frame2 = 8; - } - Projectile.rotation = Projectile.velocity.X * 0.01f; - } - } + private void GetFrame() + { + if (!InAir) //not flying + { + if (Projectile.velocity.Y == 0f) + { + float xAbs = Math.Abs(Projectile.velocity.X); + if (Projectile.velocity.X == 0f) + { + frame2 = 0; + frame2Counter = 0; + } + else if (xAbs > 0.5f) + { + frame2Counter += (int)xAbs; + frame2Counter++; + if (frame2Counter > 20) //6 + { + frame2++; + frame2Counter = 0; + } + if (frame2 > 6) //frame 1 to 6 is running + { + frame2 = 1; + } + } + else + { + frame2 = 0; //frame 0 is idle + frame2Counter = 10; + } + } + else if (Projectile.velocity.Y != 0f) + { + frame2Counter = 0; + frame2 = 7; //frame 7 is jumping + } + //projectile.velocity.Y += 0.4f; + //if (projectile.velocity.Y > 10f) + //{ + // projectile.velocity.Y = 10f; + //} + } + else //flying + { + if (Projectile.velocity.X <= 0) Projectile.direction = -1; + else Projectile.direction = 1; + frame2Counter++; + if (Projectile.velocity.Length() > 3.6f) Projectile.velocity *= 0.97f; + if (frame2Counter > 4) + { + frame2++; + frame2Counter = 0; + } + if (frame2 < 8 || frame2 > 11) + { + frame2 = 8; + } + Projectile.rotation = Projectile.velocity.X * 0.01f; + } + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.Goblet = false; - } - if (modPlayer.Goblet) - { - Projectile.timeLeft = 2; - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.Goblet = false; + } + if (modPlayer.Goblet) + { + Projectile.timeLeft = 2; + } + } - public override void PostAI() - { - Projectile.frame = frame2; - } - } + public override void PostAI() + { + Projectile.frame = frame2; + } + } } diff --git a/Projectiles/Pets/HornedSlimeProj.cs b/Projectiles/Pets/HornedSlimeProj.cs index 6a684b04..cafb7e75 100644 --- a/Projectiles/Pets/HornedSlimeProj.cs +++ b/Projectiles/Pets/HornedSlimeProj.cs @@ -1,38 +1,37 @@ using AssortedCrazyThings.Base; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs)] - //check this file for more info vvvvvvvv - public class HornedSlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Horned Slime"); - } + [Content(ContentType.HostileNPCs)] + //check this file for more info vvvvvvvv + public class HornedSlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Horned Slime"); + } - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.HornedSlime = false; - } - if (modPlayer.HornedSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.HornedSlime = false; + } + if (modPlayer.HornedSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + } } diff --git a/Projectiles/Pets/IlluminantSlimeProj.cs b/Projectiles/Pets/IlluminantSlimeProj.cs index eb687cd4..0fbc4247 100644 --- a/Projectiles/Pets/IlluminantSlimeProj.cs +++ b/Projectiles/Pets/IlluminantSlimeProj.cs @@ -7,56 +7,56 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - //check this file for more info vvvvvvvv - public class IlluminantSlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Illuminant Slime"); - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; - } + [Content(ContentType.DroppedPets)] + //check this file for more info vvvvvvvv + public class IlluminantSlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Illuminant Slime"); + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + } - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; - Projectile.alpha = 80; + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; + Projectile.alpha = 80; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.IlluminantSlime = false; - } - if (modPlayer.IlluminantSlime) - { - Projectile.timeLeft = 2; - } - return true; - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.IlluminantSlime = false; + } + if (modPlayer.IlluminantSlime) + { + Projectile.timeLeft = 2; + } + return true; + } - public override void PostDraw(Color drawColor) - { - Texture2D image = Mod.Assets.Request("Projectiles/Pets/IlluminantSlimeProj_Glowmask").Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override void PostDraw(Color drawColor) + { + Texture2D image = Mod.Assets.Request("Projectiles/Pets/IlluminantSlimeProj_Glowmask").Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2((Projectile.width - DrawOffsetX) * 0.5f - 5, Projectile.height * 0.5f + Projectile.gfxOffY); - //the higher the k, the older the position - //Length is implicitely set in TrailCacheLength up there - for (int k = Projectile.oldPos.Length - 1; k >= 0; k--) - { - Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + drawOrigin; - Color color = Projectile.GetAlpha(Color.White) * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length)) * ((255 - Projectile.alpha) / 255f); - color.A = (byte)(Projectile.alpha * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length))); - Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.oldRot[k], bounds.Size() / 2, Projectile.scale, effect, 0); - } - } - } + SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2((Projectile.width - DrawOffsetX) * 0.5f - 5, Projectile.height * 0.5f + Projectile.gfxOffY); + //the higher the k, the older the position + //Length is implicitely set in TrailCacheLength up there + for (int k = Projectile.oldPos.Length - 1; k >= 0; k--) + { + Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + drawOrigin; + Color color = Projectile.GetAlpha(Color.White) * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length)) * ((255 - Projectile.alpha) / 255f); + color.A = (byte)(Projectile.alpha * ((Projectile.oldPos.Length - k) / (1f * Projectile.oldPos.Length))); + Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.oldRot[k], bounds.Size() / 2, Projectile.scale, effect, 0); + } + } + } } diff --git a/Projectiles/Pets/JoyousSlimeProj.cs b/Projectiles/Pets/JoyousSlimeProj.cs index 1370c58e..c04a68ab 100644 --- a/Projectiles/Pets/JoyousSlimeProj.cs +++ b/Projectiles/Pets/JoyousSlimeProj.cs @@ -1,38 +1,37 @@ using AssortedCrazyThings.Base; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.FriendlyNPCs)] - //check this file for more info vvvvvvvv - public class JoyousSlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Joyous Slime"); - } + [Content(ContentType.FriendlyNPCs)] + //check this file for more info vvvvvvvv + public class JoyousSlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Joyous Slime"); + } - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.JoyousSlime = false; - } - if (modPlayer.JoyousSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.JoyousSlime = false; + } + if (modPlayer.JoyousSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + } } diff --git a/Projectiles/Pets/LifelikeMechanicalFrogProj.cs b/Projectiles/Pets/LifelikeMechanicalFrogProj.cs index 60e58796..39148ec9 100644 --- a/Projectiles/Pets/LifelikeMechanicalFrogProj.cs +++ b/Projectiles/Pets/LifelikeMechanicalFrogProj.cs @@ -7,57 +7,57 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class LifelikeMechanicalFrogProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Lifelike Mechanical Frog"); - Main.projFrames[Projectile.type] = 8; - Main.projPet[Projectile.type] = true; - DrawOriginOffsetY = 1; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.Bunny); - AIType = ProjectileID.Bunny; - Projectile.width = 18; - Projectile.height = 20; - } - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.bunny = false; // Relic from AIType - return true; - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.LifelikeMechanicalFrog = false; - } - if (modPlayer.LifelikeMechanicalFrog) - { - Projectile.timeLeft = 2; - } - } - - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/LifelikeMechanicalFrogProj" + (mPlayer.mechFrogType == 1 ? "Crown" : "")).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + DrawOriginOffsetY + Projectile.gfxOffY); - - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - - return false; - } - } + public class LifelikeMechanicalFrogProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Lifelike Mechanical Frog"); + Main.projFrames[Projectile.type] = 8; + Main.projPet[Projectile.type] = true; + DrawOriginOffsetY = 1; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.Bunny); + AIType = ProjectileID.Bunny; + Projectile.width = 18; + Projectile.height = 20; + } + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.bunny = false; // Relic from AIType + return true; + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.LifelikeMechanicalFrog = false; + } + if (modPlayer.LifelikeMechanicalFrog) + { + Projectile.timeLeft = 2; + } + } + + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/LifelikeMechanicalFrogProj" + (mPlayer.mechFrogType == 1 ? "Crown" : "")).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + DrawOriginOffsetY + Projectile.gfxOffY); + + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + + return false; + } + } } diff --git a/Projectiles/Pets/LilWrapsProj.cs b/Projectiles/Pets/LilWrapsProj.cs index a57fc629..4504bf34 100644 --- a/Projectiles/Pets/LilWrapsProj.cs +++ b/Projectiles/Pets/LilWrapsProj.cs @@ -8,135 +8,135 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class LilWrapsProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/LilWrapsProj_0"; //temp - } - } + [Content(ContentType.DroppedPets)] + public class LilWrapsProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/LilWrapsProj_0"; //temp + } + } - private int frame2Counter = 0; - private int frame2 = 0; + private int frame2Counter = 0; + private int frame2 = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Lil' Wraps"); - Main.projFrames[Projectile.type] = 12; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Lil' Wraps"); + Main.projFrames[Projectile.type] = 12; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyGrinch); - AIType = ProjectileID.BabyGrinch; - Projectile.width = 24; - Projectile.height = 40; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyGrinch); + AIType = ProjectileID.BabyGrinch; + Projectile.width = 24; + Projectile.height = 40; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.grinch = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.grinch = false; // Relic from AIType + return true; + } - private void GetFrame() - { - if (Projectile.ai[0] == 0) //not flying - { - if (Projectile.velocity.Y == 0f) - { - float xAbs = Math.Abs(Projectile.velocity.X); - if (Projectile.velocity.X == 0f) - { - frame2 = 0; - frame2Counter = 0; - } - else if (xAbs > 0.5f) - { - frame2Counter += (int)(2 * xAbs); - frame2Counter++; - if (frame2Counter > 20) //6 - { - frame2++; - frame2Counter = 0; - } - if (frame2 > 6) //frame 1 to 6 is running - { - frame2 = 1; - } - } - else - { - frame2 = 0; //frame 0 is idle - frame2Counter = 10; - } - } - else if (Projectile.velocity.Y != 0f) - { - frame2Counter = 0; - frame2 = 7; //frame 7 is jumping - } - //projectile.velocity.Y += 0.4f; - //if (projectile.velocity.Y > 10f) - //{ - // projectile.velocity.Y = 10f; - //} - } - else //flying - { - if (Projectile.velocity.X <= 0) Projectile.direction = -1; - else Projectile.direction = 1; - frame2Counter++; - if (Projectile.velocity.Length() > 3.6f) Projectile.velocity *= 0.97f; - if (frame2Counter > 4) - { - frame2++; - frame2Counter = 0; - } - if (frame2 < 8 || frame2 > 11) - { - frame2 = 8; - } - Projectile.rotation = Projectile.velocity.X * 0.01f; - } - } + private void GetFrame() + { + if (Projectile.ai[0] == 0) //not flying + { + if (Projectile.velocity.Y == 0f) + { + float xAbs = Math.Abs(Projectile.velocity.X); + if (Projectile.velocity.X == 0f) + { + frame2 = 0; + frame2Counter = 0; + } + else if (xAbs > 0.5f) + { + frame2Counter += (int)(2 * xAbs); + frame2Counter++; + if (frame2Counter > 20) //6 + { + frame2++; + frame2Counter = 0; + } + if (frame2 > 6) //frame 1 to 6 is running + { + frame2 = 1; + } + } + else + { + frame2 = 0; //frame 0 is idle + frame2Counter = 10; + } + } + else if (Projectile.velocity.Y != 0f) + { + frame2Counter = 0; + frame2 = 7; //frame 7 is jumping + } + //projectile.velocity.Y += 0.4f; + //if (projectile.velocity.Y > 10f) + //{ + // projectile.velocity.Y = 10f; + //} + } + else //flying + { + if (Projectile.velocity.X <= 0) Projectile.direction = -1; + else Projectile.direction = 1; + frame2Counter++; + if (Projectile.velocity.Length() > 3.6f) Projectile.velocity *= 0.97f; + if (frame2Counter > 4) + { + frame2++; + frame2Counter = 0; + } + if (frame2 < 8 || frame2 > 11) + { + frame2 = 8; + } + Projectile.rotation = Projectile.velocity.X * 0.01f; + } + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.LilWraps = false; - } - if (modPlayer.LilWraps) - { - Projectile.timeLeft = 2; - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.LilWraps = false; + } + if (modPlayer.LilWraps) + { + Projectile.timeLeft = 2; + } + } - public override bool PreDraw(ref Color lightColor) - { - if (Main.hasFocus) GetFrame(); + public override bool PreDraw(ref Color lightColor) + { + if (Main.hasFocus) GetFrame(); - lightColor = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16), Color.White); - SpriteEffects effects = SpriteEffects.None; - if (Projectile.direction != -1) - { - effects = SpriteEffects.FlipHorizontally; - } - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/LilWrapsProj_" + mPlayer.lilWrapsType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: frame2); - Vector2 stupidOffset = new Vector2(10f, 23f + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + lightColor = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16), Color.White); + SpriteEffects effects = SpriteEffects.None; + if (Projectile.direction != -1) + { + effects = SpriteEffects.FlipHorizontally; + } + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/LilWrapsProj_" + mPlayer.lilWrapsType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: frame2); + Vector2 stupidOffset = new Vector2(10f, 23f + Projectile.gfxOffY); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/MeatballSlimeProj.cs b/Projectiles/Pets/MeatballSlimeProj.cs index ad3fc8de..b0b566a0 100644 --- a/Projectiles/Pets/MeatballSlimeProj.cs +++ b/Projectiles/Pets/MeatballSlimeProj.cs @@ -1,39 +1,38 @@ using AssortedCrazyThings.Base; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs)] - //check this file for more info vvvvvvvv - public class MeatballSlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Meatball Slime"); - } + [Content(ContentType.HostileNPCs)] + //check this file for more info vvvvvvvv + public class MeatballSlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Meatball Slime"); + } - public override void SafeSetDefaults() - { - Projectile.width = 34; - Projectile.height = 30; - Projectile.alpha = 0; + public override void SafeSetDefaults() + { + Projectile.width = 34; + Projectile.height = 30; + Projectile.alpha = 0; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.MeatballSlime = false; - } - if (modPlayer.MeatballSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.MeatballSlime = false; + } + if (modPlayer.MeatballSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + } } diff --git a/Projectiles/Pets/MetroidPetProj.cs b/Projectiles/Pets/MetroidPetProj.cs index 21fd8d43..ef631b8f 100644 --- a/Projectiles/Pets/MetroidPetProj.cs +++ b/Projectiles/Pets/MetroidPetProj.cs @@ -7,67 +7,67 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class MetroidPetProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/MetroidPetProj_0"; //temp - } - } + [Content(ContentType.DroppedPets)] + public class MetroidPetProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/MetroidPetProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Metroid"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Metroid"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - AIType = ProjectileID.BabyEater; - Projectile.aiStyle = -1; - Projectile.width = 40; - Projectile.height = 38; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + AIType = ProjectileID.BabyEater; + Projectile.aiStyle = -1; + Projectile.width = 40; + Projectile.height = 38; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.MetroidPet = false; - } - if (modPlayer.MetroidPet) - { - Projectile.timeLeft = 2; - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.MetroidPet = false; + } + if (modPlayer.MetroidPet) + { + Projectile.timeLeft = 2; + } - AssAI.BabyEaterAI(Projectile, velocityFactor: 1.5f, sway: 0.6f); - AssAI.BabyEaterDraw(Projectile); + AssAI.BabyEaterAI(Projectile, velocityFactor: 1.5f, sway: 0.6f); + AssAI.BabyEaterDraw(Projectile); - Projectile.rotation = 0f; - } + Projectile.rotation = 0f; + } - public override bool PreDraw(ref Color lightColor) - { - Player player = Projectile.GetOwner(); - - PetPlayer mPlayer = player.GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/MetroidPetProj_" + mPlayer.metroidPetType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + Player player = Projectile.GetOwner(); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - drawOrigin.Y += Projectile.height / 2; + PetPlayer mPlayer = player.GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/MetroidPetProj_" + mPlayer.metroidPetType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, SpriteEffects.None, 0); - return false; - } - } + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + drawOrigin.Y += Projectile.height / 2; + + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, SpriteEffects.None, 0); + return false; + } + } } diff --git a/Projectiles/Pets/MiniAntlionProj.cs b/Projectiles/Pets/MiniAntlionProj.cs index 0aad5ad4..ca797ad8 100644 --- a/Projectiles/Pets/MiniAntlionProj.cs +++ b/Projectiles/Pets/MiniAntlionProj.cs @@ -8,141 +8,141 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class MiniAntlionProj : SimplePetProjBase - { - private int frame2Counter = 0; - private int frame2 = 0; - public bool InAir => Projectile.ai[0] != 0f; - - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/MiniAntlionProj_0"; - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Baby Antlion"); - - Main.projFrames[Projectile.type] = 11; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyGrinch); - AIType = ProjectileID.BabyGrinch; - Projectile.width = 34; - Projectile.height = 24; - - DrawOriginOffsetY = -6; - } - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.grinch = false; // Relic from AIType - - GetFrame(); - - return true; - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.MiniAntlion = false; - } - if (modPlayer.MiniAntlion) - { - Projectile.timeLeft = 2; - } - } - - public override void PostAI() - { - Projectile.frameCounter = 0; - Projectile.frame = frame2; - - if (InAir) - { - Projectile.rotation = Projectile.velocity.X * 0.055f; - } - } - - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/MiniAntlionProj_" + mPlayer.miniAntlionType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - Vector2 stupidOffset = new Vector2(bounds.Width / 2, Projectile.height / 2 + Projectile.gfxOffY + 5f); - - Vector2 origin = bounds.Size() / 2 - new Vector2(0, DrawOriginOffsetY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); - - return false; - } - - private void GetFrame() - { - if (!InAir) //not flying - { - if (Projectile.velocity.Y == 0f) - { - float xAbs = Math.Abs(Projectile.velocity.X); - if (Projectile.velocity.X == 0f) - { - frame2 = 0; - frame2Counter = 0; - } - else if (xAbs > 0.5f) - { - frame2Counter += (int)xAbs; - frame2Counter++; - if (frame2Counter > 13) //6 - { - frame2++; - frame2Counter = 0; - } - if (frame2 < 2 || frame2 > 6) //frame 2 to 6 is running - { - frame2 = 2; - } - } - else - { - frame2 = 0; //frame 0 is idle - frame2Counter = 7; - } - } - else if (Projectile.velocity.Y != 0f) - { - frame2Counter = 0; - frame2 = 1; //frame 1 is jumping - } - } - else //flying - { - frame2Counter++; - if (frame2Counter > 1) //6 - { - frame2++; - frame2Counter = 0; - } - - if (frame2 < 7 || frame2 > 10) - { - frame2 = 7; //flying frames 7 to 10 - } - } - } - } + [Content(ContentType.DroppedPets)] + public class MiniAntlionProj : SimplePetProjBase + { + private int frame2Counter = 0; + private int frame2 = 0; + public bool InAir => Projectile.ai[0] != 0f; + + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/MiniAntlionProj_0"; + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Antlion"); + + Main.projFrames[Projectile.type] = 11; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyGrinch); + AIType = ProjectileID.BabyGrinch; + Projectile.width = 34; + Projectile.height = 24; + + DrawOriginOffsetY = -6; + } + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.grinch = false; // Relic from AIType + + GetFrame(); + + return true; + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.MiniAntlion = false; + } + if (modPlayer.MiniAntlion) + { + Projectile.timeLeft = 2; + } + } + + public override void PostAI() + { + Projectile.frameCounter = 0; + Projectile.frame = frame2; + + if (InAir) + { + Projectile.rotation = Projectile.velocity.X * 0.055f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/MiniAntlionProj_" + mPlayer.miniAntlionType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + Vector2 stupidOffset = new Vector2(bounds.Width / 2, Projectile.height / 2 + Projectile.gfxOffY + 5f); + + Vector2 origin = bounds.Size() / 2 - new Vector2(0, DrawOriginOffsetY); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); + + return false; + } + + private void GetFrame() + { + if (!InAir) //not flying + { + if (Projectile.velocity.Y == 0f) + { + float xAbs = Math.Abs(Projectile.velocity.X); + if (Projectile.velocity.X == 0f) + { + frame2 = 0; + frame2Counter = 0; + } + else if (xAbs > 0.5f) + { + frame2Counter += (int)xAbs; + frame2Counter++; + if (frame2Counter > 13) //6 + { + frame2++; + frame2Counter = 0; + } + if (frame2 < 2 || frame2 > 6) //frame 2 to 6 is running + { + frame2 = 2; + } + } + else + { + frame2 = 0; //frame 0 is idle + frame2Counter = 7; + } + } + else if (Projectile.velocity.Y != 0f) + { + frame2Counter = 0; + frame2 = 1; //frame 1 is jumping + } + } + else //flying + { + frame2Counter++; + if (frame2Counter > 1) //6 + { + frame2++; + frame2Counter = 0; + } + + if (frame2 < 7 || frame2 > 10) + { + frame2 = 7; //flying frames 7 to 10 + } + } + } + } } diff --git a/Projectiles/Pets/MiniMegalodonProj.cs b/Projectiles/Pets/MiniMegalodonProj.cs index b164baaa..15d27bb4 100644 --- a/Projectiles/Pets/MiniMegalodonProj.cs +++ b/Projectiles/Pets/MiniMegalodonProj.cs @@ -1,51 +1,50 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] - public class MiniMegalodonProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mini Megalodon"); - Main.projFrames[Projectile.type] = 8; - Main.projPet[Projectile.type] = true; - DrawOffsetX = -4; - DrawOriginOffsetY = -8; - } + [Content(ContentType.HostileNPCs | ContentType.DroppedPets)] + public class MiniMegalodonProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mini Megalodon"); + Main.projFrames[Projectile.type] = 8; + Main.projPet[Projectile.type] = true; + DrawOffsetX = -4; + DrawOriginOffsetY = -8; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.EyeSpring); - Projectile.aiStyle = -1; - Projectile.width = 32; - Projectile.height = 24; - //AIType = ProjectileID.EyeSpring; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.EyeSpring); + Projectile.aiStyle = -1; + Projectile.width = 32; + Projectile.height = 24; + //AIType = ProjectileID.EyeSpring; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.eyeSpring = false; - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.eyeSpring = false; + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.MiniMegalodon = false; - } - if (modPlayer.MiniMegalodon) - { - Projectile.timeLeft = 2; - } - AssAI.EyeSpringAI(Projectile, flyForever: false); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.MiniMegalodon = false; + } + if (modPlayer.MiniMegalodon) + { + Projectile.timeLeft = 2; + } + AssAI.EyeSpringAI(Projectile, flyForever: false); + } + } } diff --git a/Projectiles/Pets/NumberMuncherProj.cs b/Projectiles/Pets/NumberMuncherProj.cs index 701566f0..4dca241e 100644 --- a/Projectiles/Pets/NumberMuncherProj.cs +++ b/Projectiles/Pets/NumberMuncherProj.cs @@ -6,127 +6,127 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class NumberMuncherProj : SimplePetProjBase - { - private int frame2Counter = 0; - private int frame2 = 0; - public bool InAir => Projectile.ai[0] != 0f; + public class NumberMuncherProj : SimplePetProjBase + { + private int frame2Counter = 0; + private int frame2 = 0; + public bool InAir => Projectile.ai[0] != 0f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Number Muncher"); - Main.projFrames[Projectile.type] = 10; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Number Muncher"); + Main.projFrames[Projectile.type] = 10; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyGrinch); - AIType = ProjectileID.BabyGrinch; - Projectile.width = 20; - Projectile.height = 22; + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyGrinch); + AIType = ProjectileID.BabyGrinch; + Projectile.width = 20; + Projectile.height = 22; - DrawOriginOffsetY = -2; - } + DrawOriginOffsetY = -2; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.grinch = false; // Relic from AIType + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.grinch = false; // Relic from AIType - GetFrame(); + GetFrame(); - return true; - } + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.NumberMuncher = false; - } - if (modPlayer.NumberMuncher) - { - Projectile.timeLeft = 2; - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.NumberMuncher = false; + } + if (modPlayer.NumberMuncher) + { + Projectile.timeLeft = 2; + } + } - public override void PostAI() - { - Projectile.frameCounter = 0; - Projectile.frame = frame2; + public override void PostAI() + { + Projectile.frameCounter = 0; + Projectile.frame = frame2; - if (InAir) - { - //Rotate the direction it's moving, head forward - Projectile.rotation = Projectile.velocity.ToRotation(); - if (Projectile.spriteDirection == 1) - { - Projectile.rotation += MathHelper.Pi; - } + if (InAir) + { + //Rotate the direction it's moving, head forward + Projectile.rotation = Projectile.velocity.ToRotation(); + if (Projectile.spriteDirection == 1) + { + Projectile.rotation += MathHelper.Pi; + } - Projectile.rotation -= Projectile.spriteDirection * MathHelper.PiOver2; + Projectile.rotation -= Projectile.spriteDirection * MathHelper.PiOver2; - //Propulsion dust - float dustChance = Math.Clamp(Math.Abs(Projectile.velocity.Length()) / 5f, 0.3f, 0.9f); - if (Main.rand.NextFloat() < dustChance) - { - Vector2 dustOrigin = Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.Zero) * 12; - Dust dust = Dust.NewDustDirect(dustOrigin - Vector2.One * 4f, 8, 8, DustID.Cloud, -Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 50, default(Color), 1.7f); - dust.velocity.X *= 0.2f; - dust.velocity.Y *= 0.2f; - dust.noGravity = true; - } - } - } + //Propulsion dust + float dustChance = Math.Clamp(Math.Abs(Projectile.velocity.Length()) / 5f, 0.3f, 0.9f); + if (Main.rand.NextFloat() < dustChance) + { + Vector2 dustOrigin = Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.Zero) * 12; + Dust dust = Dust.NewDustDirect(dustOrigin - Vector2.One * 4f, 8, 8, DustID.Cloud, -Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 50, default(Color), 1.7f); + dust.velocity.X *= 0.2f; + dust.velocity.Y *= 0.2f; + dust.noGravity = true; + } + } + } - private void GetFrame() - { - if (!InAir) //not flying - { - if (Projectile.velocity.Y == 0f) - { - float xAbs = Math.Abs(Projectile.velocity.X); - if (Projectile.velocity.X == 0f) - { - frame2 = 0; - frame2Counter = 0; - } - else if (xAbs > 0.5f) - { - frame2Counter += (int)xAbs; - frame2Counter++; - if (frame2Counter > 20) //6 - { - frame2++; - frame2Counter = 0; - } - if (frame2 > 9) //frame 2 to 9 is running - { - frame2 = 2; - } - } - else - { - frame2 = 0; //frame 0 is idle - frame2Counter = 10; - } - } - else if (Projectile.velocity.Y != 0f) - { - frame2Counter = 0; - frame2 = 1; //frame 1 is jumping - } - } - else //flying - { - if (frame2 != 1) - { - frame2 = 1; //flying frame 1 - } - } - } - } + private void GetFrame() + { + if (!InAir) //not flying + { + if (Projectile.velocity.Y == 0f) + { + float xAbs = Math.Abs(Projectile.velocity.X); + if (Projectile.velocity.X == 0f) + { + frame2 = 0; + frame2Counter = 0; + } + else if (xAbs > 0.5f) + { + frame2Counter += (int)xAbs; + frame2Counter++; + if (frame2Counter > 20) //6 + { + frame2++; + frame2Counter = 0; + } + if (frame2 > 9) //frame 2 to 9 is running + { + frame2 = 2; + } + } + else + { + frame2 = 0; //frame 0 is idle + frame2Counter = 10; + } + } + else if (Projectile.velocity.Y != 0f) + { + frame2Counter = 0; + frame2 = 1; //frame 1 is jumping + } + } + else //flying + { + if (frame2 != 1) + { + frame2 = 1; //flying frame 1 + } + } + } + } } diff --git a/Projectiles/Pets/OceanSlimeProj.cs b/Projectiles/Pets/OceanSlimeProj.cs index 25cb6ab3..91ab4b6d 100644 --- a/Projectiles/Pets/OceanSlimeProj.cs +++ b/Projectiles/Pets/OceanSlimeProj.cs @@ -6,62 +6,62 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs)] - //check this file for more info vvvvvvvv - public class OceanSlimeProj : BabySlimeBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/OceanSlimeProj_0"; - } - } + [Content(ContentType.HostileNPCs)] + //check this file for more info vvvvvvvv + public class OceanSlimeProj : BabySlimeBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/OceanSlimeProj_0"; + } + } - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Ocean Slime"); - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Ocean Slime"); + } - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; - Projectile.minion = false; - } + Projectile.minion = false; + } - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.OceanSlime = false; - } - if (modPlayer.OceanSlime) - { - Projectile.timeLeft = 2; - } - return true; - } + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.OceanSlime = false; + } + if (modPlayer.OceanSlime) + { + Projectile.timeLeft = 2; + } + return true; + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/OceanSlimeProj_" + mPlayer.oceanSlimeType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/OceanSlimeProj_" + mPlayer.oceanSlimeType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); - if (mPlayer.oceanSlimeType == 0) - { - lightColor *= (255f - Projectile.alpha) / 255f; - } + if (mPlayer.oceanSlimeType == 0) + { + lightColor *= (255f - Projectile.alpha) / 255f; + } - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/PetCultistProj.cs b/Projectiles/Pets/PetCultistProj.cs index 5b650ab3..a9d20045 100644 --- a/Projectiles/Pets/PetCultistProj.cs +++ b/Projectiles/Pets/PetCultistProj.cs @@ -8,159 +8,159 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class PetCultistProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/PetCultistProj_0"; //temp - } - } - - private float sinY; //depends on projectile.ai[1], no need to sync - - private ref float Sincounter => ref Projectile.ai[1]; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Dwarf Cultist"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.LightPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - Projectile.aiStyle = -1; - Projectile.width = 20; - Projectile.height = 26; - Projectile.tileCollide = false; - } - - private void CustomDraw() - { - //frame 0: idle - //frame 0 to 3: loop back and forth while healing - Player player = Projectile.GetOwner(); - - if (player.statLife < player.statLifeMax2 / 2) - { - Lighting.AddLight(player.Center, Color.White.ToVector3() * 0.5f); - Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.5f); - } - - if (Projectile.velocity.Length() < 6f && player.statLife < player.statLifeMax2 / 2) - { - Projectile.frameCounter++; - if (Projectile.frameCounter <= 30) - { - Projectile.frame = 0; - } - else if (Projectile.frameCounter <= 35) - { - Projectile.frame = 1; - } - else if (Projectile.frameCounter <= 40) - { - Projectile.frame = 2; - } - else if (Projectile.frameCounter <= 70) - { - Projectile.frame = 3; - } - else if (Projectile.frameCounter <= 75) - { - Projectile.frame = 2; - } - else if (Projectile.frameCounter <= 80) - { - Projectile.frame = 1; - } - else - { - Projectile.frameCounter = 0; - } - } - else - { - Projectile.frameCounter = 0; - Projectile.frame = 0; - } - } - - private void CustomAI() - { - Player player = Projectile.GetOwner(); - - Sincounter = Sincounter >= 240 ? 0 : Sincounter + 1; - sinY = (float)((Math.Sin((Sincounter / 120f) * MathHelper.TwoPi) - 1) * 4); - - if (Projectile.velocity.LengthSquared() < 6f * 6f && player.statLife < player.statLifeMax2 / 2) - { - if (Sincounter % 80 == 30) - { - int heal = 1; - player.statLife += heal; - player.HealEffect(heal, false); - } - Vector2 spawnOffset = new Vector2(Projectile.width * 0.5f, -20f + Projectile.height * 0.5f); - Vector2 spawnPos = Projectile.position + spawnOffset; - - Dust dust = Dust.NewDustPerfect(spawnPos, 175, new Vector2(Main.rand.NextFloat(-0.5f, 0.5f), Main.rand.NextFloat(-0.5f, 0.5f))); - dust.noGravity = true; - dust.fadeIn = 1.2f; - - //basically remaps player health from (max / 2) to 0 => 0.1f to 0.9f - float halfLife = player.statLifeMax2 / 2; - float complicatedFormula = ((halfLife - player.statLife) * 0.8f) / (halfLife / 2) + 0.1f; - - if (Main.rand.NextFloat() < complicatedFormula) - { - spawnOffset = new Vector2(0f, -20f); - spawnPos = Projectile.position + spawnOffset; - dust = Dust.NewDustDirect(new Vector2(spawnPos.X, spawnPos.Y), Projectile.width, Projectile.height, 175, 0f, 0f, 0, default(Color), 1.5f); - dust.noGravity = true; - dust.fadeIn = 1f; - dust.velocity = Vector2.Normalize(player.MountedCenter - new Vector2(0f, player.height / 2) - (Projectile.Center + spawnOffset)) * (Main.rand.NextFloat() + 5f) + Projectile.velocity * 1.5f; - } - } - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetCultist = false; - } - if (modPlayer.PetCultist) - { - Projectile.timeLeft = 2; - } - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, veloXToRotationFactor: 0.5f, offsetX: 16f, offsetY: (player.statLife < player.statLifeMax2 / 2) ? -26f : 2f); - - CustomAI(); - CustomDraw(); - } - - public override bool PreDraw(ref Color lightColor) - { - SpriteEffects effects = SpriteEffects.None; - if (Projectile.spriteDirection != 1) - { - effects = SpriteEffects.FlipHorizontally; - } - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetCultistProj_" + mPlayer.petCultistType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f - Projectile.gfxOffY + sinY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - - return false; - } - } + [Content(ContentType.DroppedPets)] + public class PetCultistProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/PetCultistProj_0"; //temp + } + } + + private float sinY; //depends on projectile.ai[1], no need to sync + + private ref float Sincounter => ref Projectile.ai[1]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dwarf Cultist"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.LightPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + Projectile.aiStyle = -1; + Projectile.width = 20; + Projectile.height = 26; + Projectile.tileCollide = false; + } + + private void CustomDraw() + { + //frame 0: idle + //frame 0 to 3: loop back and forth while healing + Player player = Projectile.GetOwner(); + + if (player.statLife < player.statLifeMax2 / 2) + { + Lighting.AddLight(player.Center, Color.White.ToVector3() * 0.5f); + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.5f); + } + + if (Projectile.velocity.Length() < 6f && player.statLife < player.statLifeMax2 / 2) + { + Projectile.frameCounter++; + if (Projectile.frameCounter <= 30) + { + Projectile.frame = 0; + } + else if (Projectile.frameCounter <= 35) + { + Projectile.frame = 1; + } + else if (Projectile.frameCounter <= 40) + { + Projectile.frame = 2; + } + else if (Projectile.frameCounter <= 70) + { + Projectile.frame = 3; + } + else if (Projectile.frameCounter <= 75) + { + Projectile.frame = 2; + } + else if (Projectile.frameCounter <= 80) + { + Projectile.frame = 1; + } + else + { + Projectile.frameCounter = 0; + } + } + else + { + Projectile.frameCounter = 0; + Projectile.frame = 0; + } + } + + private void CustomAI() + { + Player player = Projectile.GetOwner(); + + Sincounter = Sincounter >= 240 ? 0 : Sincounter + 1; + sinY = (float)((Math.Sin((Sincounter / 120f) * MathHelper.TwoPi) - 1) * 4); + + if (Projectile.velocity.LengthSquared() < 6f * 6f && player.statLife < player.statLifeMax2 / 2) + { + if (Sincounter % 80 == 30) + { + int heal = 1; + player.statLife += heal; + player.HealEffect(heal, false); + } + Vector2 spawnOffset = new Vector2(Projectile.width * 0.5f, -20f + Projectile.height * 0.5f); + Vector2 spawnPos = Projectile.position + spawnOffset; + + Dust dust = Dust.NewDustPerfect(spawnPos, 175, new Vector2(Main.rand.NextFloat(-0.5f, 0.5f), Main.rand.NextFloat(-0.5f, 0.5f))); + dust.noGravity = true; + dust.fadeIn = 1.2f; + + //basically remaps player health from (max / 2) to 0 => 0.1f to 0.9f + float halfLife = player.statLifeMax2 / 2; + float complicatedFormula = ((halfLife - player.statLife) * 0.8f) / (halfLife / 2) + 0.1f; + + if (Main.rand.NextFloat() < complicatedFormula) + { + spawnOffset = new Vector2(0f, -20f); + spawnPos = Projectile.position + spawnOffset; + dust = Dust.NewDustDirect(new Vector2(spawnPos.X, spawnPos.Y), Projectile.width, Projectile.height, 175, 0f, 0f, 0, default(Color), 1.5f); + dust.noGravity = true; + dust.fadeIn = 1f; + dust.velocity = Vector2.Normalize(player.MountedCenter - new Vector2(0f, player.height / 2) - (Projectile.Center + spawnOffset)) * (Main.rand.NextFloat() + 5f) + Projectile.velocity * 1.5f; + } + } + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetCultist = false; + } + if (modPlayer.PetCultist) + { + Projectile.timeLeft = 2; + } + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, veloXToRotationFactor: 0.5f, offsetX: 16f, offsetY: (player.statLife < player.statLifeMax2 / 2) ? -26f : 2f); + + CustomAI(); + CustomDraw(); + } + + public override bool PreDraw(ref Color lightColor) + { + SpriteEffects effects = SpriteEffects.None; + if (Projectile.spriteDirection != 1) + { + effects = SpriteEffects.FlipHorizontally; + } + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetCultistProj_" + mPlayer.petCultistType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f - Projectile.gfxOffY + sinY); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + + return false; + } + } } diff --git a/Projectiles/Pets/PetDestroyer.cs b/Projectiles/Pets/PetDestroyer.cs index d6b0ddc9..3533a9aa 100644 --- a/Projectiles/Pets/PetDestroyer.cs +++ b/Projectiles/Pets/PetDestroyer.cs @@ -9,263 +9,263 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public abstract class PetDestroyerBase : SimplePetProjBase - { - public static int[] wormTypes; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tiny Destroyer"); - Main.projFrames[Projectile.type] = 1; - Main.projPet[Projectile.type] = true; - //ProjectileID.Sets.DontAttachHideToAlpha[projectile.type] = true; //doesn't work for some reason with hide = true - //ProjectileID.Sets.NeedsUUID[projectile.type] = true; - } - - public override void SetDefaults() - { - AssAI.StardustDragonSetDefaults(Projectile, size: HITBOX_SIZE, minion: false); - Projectile.alpha = 0; - } - - public const int NUMBER_OF_BODY_SEGMENTS = 6; - - //default 24 - public const int HITBOX_SIZE = 24; - - //default 16 - public const int DISTANCE_BETWEEN_SEGMENTS = 25; - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetDestroyer = false; - } - if (modPlayer.PetDestroyer) - { - Projectile.timeLeft = 2; - } - - if (Projectile.type != ModContent.ProjectileType()) - { - AssAI.StardustDragonAI(Projectile, wormTypes, DISTANCE_BETWEEN_SEGMENTS); - } - else - { - AssAI.BabyEaterAI(Projectile, originOffset: new Vector2(0f, -100f)); - if (Projectile.owner == Main.myPlayer && Math.Sign(Projectile.oldVelocity.X) != Math.Sign(Projectile.velocity.X)) - { - Projectile.netUpdate = true; - } - //float scaleFactor = MathHelper.Clamp(projectile.localAI[0], 0f, 50f); - //projectile.scale = 1f + scaleFactor * 0.01f; - - Projectile.rotation = Projectile.velocity.ToRotation() + 1.57079637f; - Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); - } - } - - public override bool PreDraw(ref Color lightColor) - { - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Vector2 drawPos = Projectile.Center + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Rectangle drawRect = texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color color = Projectile.GetAlpha(lightColor); - Vector2 drawOrigin = drawRect.Size() / 2f; - - //alpha5.A /= 2; - - Main.EntitySpriteDraw(texture, drawPos, drawRect, color, Projectile.rotation, drawOrigin, Projectile.scale, effects, 0); - - texture = Mod.Assets.Request("Projectiles/Pets/" + Name + "_Glowmask").Value; - Main.EntitySpriteDraw(texture, drawPos, drawRect, Color.White, Projectile.rotation, drawOrigin, Projectile.scale, effects, 0); - - return false; - } - } - - public class PetDestroyerHead : PetDestroyerBase { } - - public class PetDestroyerBody1 : PetDestroyerBase { } - - public class PetDestroyerBody2 : PetDestroyerBase { } - - public class PetDestroyerTail : PetDestroyerBase { } - - public class PetDestroyerProbe : SimplePetProjBase - { - //since the index might be different between clients, using ai[] for it will break stuff - public int ParentIndex - { - get - { - return (int)Projectile.localAI[0] - 1; - } - set - { - Projectile.localAI[0] = value + 1; - } - } - - public int AttackCounter - { - get - { - return (int)Projectile.ai[1]; - } - set - { - Projectile.ai[1] = value; - } - } - - public float rot; - - public const int AttackDelay = 90; - - private const int LaserDamage = 8; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tiny Destroyer Probe"); - Main.projFrames[Projectile.type] = 1; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - Projectile.netImportant = true; - Projectile.aiStyle = -1; - Projectile.width = 20; - Projectile.height = 18; - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetDestroyer = false; - } - if (modPlayer.PetDestroyer) - { - Projectile.timeLeft = 2; - } - - #region Find Parent - //set parent when spawned - - int parentType = Projectile.identity % 2 == 0 ? ModContent.ProjectileType() : ModContent.ProjectileType(); - if (ParentIndex < 0) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile p = Main.projectile[i]; - if (p.active && p.type == parentType && Projectile.owner == p.owner) - { - ParentIndex = i; - //projectile.netUpdate = true; - break; - } - } - } - - //if something goes wrong, abort mission - if (ParentIndex < 0) - { - Projectile.Kill(); - return; - } - Projectile parent = Main.projectile[ParentIndex]; - #endregion - - //offsets to the drones - Vector2 between = parent.Center - Projectile.Center; - float offsetX = (between.X < 0f).ToDirectionInt() * 60f; - float offsetY = 60; - - AssAI.TeleportIfTooFar(Projectile, parent.Center); - - if (!parent.active) - { - Projectile.active = false; - return; - } - - AssAI.ZephyrfishAI(Projectile, parent: parent, velocityFactor: 1f, random: false, swapSides: 1, offsetX: offsetX, offsetY: offsetY); - - int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 500); - - if (Main.myPlayer == Projectile.owner) - { - //safe random increase so the modulo still goes to 0 properly - bool closeToAttackDelay = (AttackCounter % AttackDelay) == AttackDelay - 1; - AttackCounter += Main.rand.Next(1, closeToAttackDelay ? 2 : 3); - if (AttackCounter % AttackDelay == 0) - { - if (targetIndex != -1 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - if (AttackCounter == AttackDelay) AttackCounter += AttackDelay; - Vector2 position = Projectile.Center; - NPC target = Main.npc[targetIndex]; - Vector2 velocity = target.Center + target.velocity * 5f - Projectile.Center; - velocity.Normalize(); - velocity *= 7f; - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), position, velocity, ModContent.ProjectileType(), LaserDamage, 2f, Main.myPlayer, 0f, 0f); - Projectile.netUpdate = true; - //decide not to update parent, instead, parent updates itself - //parent.netUpdate = true; - } - else - { - if (AttackCounter > AttackDelay) - { - AttackCounter -= AttackDelay; - Projectile.netUpdate = true; - //parent.netUpdate = true; - } - } - AttackCounter -= AttackDelay; - } - } - - if (targetIndex != -1) - { - rot = (Main.npc[targetIndex].Center - Projectile.Center).ToRotation(); - } - else - { - rot = rot.AngleLerp(Projectile.velocity.ToRotation(), 0.1f); - } - - Projectile.rotation = rot; - Projectile.direction = Projectile.spriteDirection = -1; - } - - public override bool PreDraw(ref Color lightColor) - { - SpriteEffects effects = Projectile.spriteDirection != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetDestroyerProbe").Value; - Rectangle bounds = image.Bounds; - bounds.Y = Projectile.frame * bounds.Height; - Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f - Projectile.gfxOffY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 origin = bounds.Size() / 2; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); - - image = Mod.Assets.Request("Projectiles/Pets/PetDestroyerProbe_Glowmask").Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, origin, Projectile.scale, effects, 0); - - return false; - } - } + [Content(ContentType.DroppedPets)] + public abstract class PetDestroyerBase : SimplePetProjBase + { + public static int[] wormTypes; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tiny Destroyer"); + Main.projFrames[Projectile.type] = 1; + Main.projPet[Projectile.type] = true; + //ProjectileID.Sets.DontAttachHideToAlpha[projectile.type] = true; //doesn't work for some reason with hide = true + //ProjectileID.Sets.NeedsUUID[projectile.type] = true; + } + + public override void SetDefaults() + { + AssAI.StardustDragonSetDefaults(Projectile, size: HITBOX_SIZE, minion: false); + Projectile.alpha = 0; + } + + public const int NUMBER_OF_BODY_SEGMENTS = 6; + + //default 24 + public const int HITBOX_SIZE = 24; + + //default 16 + public const int DISTANCE_BETWEEN_SEGMENTS = 25; + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetDestroyer = false; + } + if (modPlayer.PetDestroyer) + { + Projectile.timeLeft = 2; + } + + if (Projectile.type != ModContent.ProjectileType()) + { + AssAI.StardustDragonAI(Projectile, wormTypes, DISTANCE_BETWEEN_SEGMENTS); + } + else + { + AssAI.BabyEaterAI(Projectile, originOffset: new Vector2(0f, -100f)); + if (Projectile.owner == Main.myPlayer && Math.Sign(Projectile.oldVelocity.X) != Math.Sign(Projectile.velocity.X)) + { + Projectile.netUpdate = true; + } + //float scaleFactor = MathHelper.Clamp(projectile.localAI[0], 0f, 50f); + //projectile.scale = 1f + scaleFactor * 0.01f; + + Projectile.rotation = Projectile.velocity.ToRotation() + 1.57079637f; + Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); + } + } + + public override bool PreDraw(ref Color lightColor) + { + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 drawPos = Projectile.Center + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle drawRect = texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color color = Projectile.GetAlpha(lightColor); + Vector2 drawOrigin = drawRect.Size() / 2f; + + //alpha5.A /= 2; + + Main.EntitySpriteDraw(texture, drawPos, drawRect, color, Projectile.rotation, drawOrigin, Projectile.scale, effects, 0); + + texture = Mod.Assets.Request("Projectiles/Pets/" + Name + "_Glowmask").Value; + Main.EntitySpriteDraw(texture, drawPos, drawRect, Color.White, Projectile.rotation, drawOrigin, Projectile.scale, effects, 0); + + return false; + } + } + + public class PetDestroyerHead : PetDestroyerBase { } + + public class PetDestroyerBody1 : PetDestroyerBase { } + + public class PetDestroyerBody2 : PetDestroyerBase { } + + public class PetDestroyerTail : PetDestroyerBase { } + + public class PetDestroyerProbe : SimplePetProjBase + { + //since the index might be different between clients, using ai[] for it will break stuff + public int ParentIndex + { + get + { + return (int)Projectile.localAI[0] - 1; + } + set + { + Projectile.localAI[0] = value + 1; + } + } + + public int AttackCounter + { + get + { + return (int)Projectile.ai[1]; + } + set + { + Projectile.ai[1] = value; + } + } + + public float rot; + + public const int AttackDelay = 90; + + private const int LaserDamage = 8; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tiny Destroyer Probe"); + Main.projFrames[Projectile.type] = 1; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + Projectile.netImportant = true; + Projectile.aiStyle = -1; + Projectile.width = 20; + Projectile.height = 18; + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetDestroyer = false; + } + if (modPlayer.PetDestroyer) + { + Projectile.timeLeft = 2; + } + + #region Find Parent + //set parent when spawned + + int parentType = Projectile.identity % 2 == 0 ? ModContent.ProjectileType() : ModContent.ProjectileType(); + if (ParentIndex < 0) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p.active && p.type == parentType && Projectile.owner == p.owner) + { + ParentIndex = i; + //projectile.netUpdate = true; + break; + } + } + } + + //if something goes wrong, abort mission + if (ParentIndex < 0) + { + Projectile.Kill(); + return; + } + Projectile parent = Main.projectile[ParentIndex]; + #endregion + + //offsets to the drones + Vector2 between = parent.Center - Projectile.Center; + float offsetX = (between.X < 0f).ToDirectionInt() * 60f; + float offsetY = 60; + + AssAI.TeleportIfTooFar(Projectile, parent.Center); + + if (!parent.active) + { + Projectile.active = false; + return; + } + + AssAI.ZephyrfishAI(Projectile, parent: parent, velocityFactor: 1f, random: false, swapSides: 1, offsetX: offsetX, offsetY: offsetY); + + int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 500); + + if (Main.myPlayer == Projectile.owner) + { + //safe random increase so the modulo still goes to 0 properly + bool closeToAttackDelay = (AttackCounter % AttackDelay) == AttackDelay - 1; + AttackCounter += Main.rand.Next(1, closeToAttackDelay ? 2 : 3); + if (AttackCounter % AttackDelay == 0) + { + if (targetIndex != -1 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + if (AttackCounter == AttackDelay) AttackCounter += AttackDelay; + Vector2 position = Projectile.Center; + NPC target = Main.npc[targetIndex]; + Vector2 velocity = target.Center + target.velocity * 5f - Projectile.Center; + velocity.Normalize(); + velocity *= 7f; + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), position, velocity, ModContent.ProjectileType(), LaserDamage, 2f, Main.myPlayer, 0f, 0f); + Projectile.netUpdate = true; + //decide not to update parent, instead, parent updates itself + //parent.netUpdate = true; + } + else + { + if (AttackCounter > AttackDelay) + { + AttackCounter -= AttackDelay; + Projectile.netUpdate = true; + //parent.netUpdate = true; + } + } + AttackCounter -= AttackDelay; + } + } + + if (targetIndex != -1) + { + rot = (Main.npc[targetIndex].Center - Projectile.Center).ToRotation(); + } + else + { + rot = rot.AngleLerp(Projectile.velocity.ToRotation(), 0.1f); + } + + Projectile.rotation = rot; + Projectile.direction = Projectile.spriteDirection = -1; + } + + public override bool PreDraw(ref Color lightColor) + { + SpriteEffects effects = Projectile.spriteDirection != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetDestroyerProbe").Value; + Rectangle bounds = image.Bounds; + bounds.Y = Projectile.frame * bounds.Height; + Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f - Projectile.gfxOffY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 origin = bounds.Size() / 2; + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); + + image = Mod.Assets.Request("Projectiles/Pets/PetDestroyerProbe_Glowmask").Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, origin, Projectile.scale, effects, 0); + + return false; + } + } } diff --git a/Projectiles/Pets/PetEaterOfWorlds.cs b/Projectiles/Pets/PetEaterOfWorlds.cs index 91aedf0f..49ffa150 100644 --- a/Projectiles/Pets/PetEaterOfWorlds.cs +++ b/Projectiles/Pets/PetEaterOfWorlds.cs @@ -6,86 +6,86 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public abstract class PetEaterofWorldsBase : SimplePetProjBase - { - public static int[] wormTypes; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tiny Eater of Worlds"); - Main.projFrames[Projectile.type] = 1; - Main.projPet[Projectile.type] = true; - //ProjectileID.Sets.DontAttachHideToAlpha[projectile.type] = true; //doesn't work for some reason with hide = true - //ProjectileID.Sets.NeedsUUID[projectile.type] = true; - } - - public override void SetDefaults() - { - AssAI.StardustDragonSetDefaults(Projectile, size: HITBOX_SIZE, minion: false); - Projectile.alpha = 0; - } - - //default 2 - public const int NUMBER_OF_BODY_SEGMENTS = 5; - - //default 24 - public const int HITBOX_SIZE = 24; - - //default 16 - public const int DISTANCE_BETWEEN_SEGMENTS = 17; - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetEaterofWorlds = false; - } - if (modPlayer.PetEaterofWorlds) - { - Projectile.timeLeft = 2; - } - - if (Projectile.type != ModContent.ProjectileType()) - { - AssAI.StardustDragonAI(Projectile, wormTypes, DISTANCE_BETWEEN_SEGMENTS); - } - else - { - AssAI.BabyEaterAI(Projectile); - //float scaleFactor = MathHelper.Clamp(projectile.localAI[0], 0f, 50f); - //projectile.scale = 1f + scaleFactor * 0.01f; - - Projectile.rotation = Projectile.velocity.ToRotation() + 1.57079637f; - Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); - } - } - - public override bool PreDraw(ref Color lightColor) - { - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Vector2 drawPos = Projectile.Center + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Rectangle drawRect = texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); - Color color = Projectile.GetAlpha(lightColor); - Vector2 drawOrigin = drawRect.Size() / 2f; - - //alpha5.A /= 2; - - Main.EntitySpriteDraw(texture, drawPos, drawRect, color, Projectile.rotation, drawOrigin, Projectile.scale, effects, 0); - - return false; - } - } - - public class PetEaterofWorldsHead : PetEaterofWorldsBase { } - - public class PetEaterofWorldsBody1 : PetEaterofWorldsBase { } - - public class PetEaterofWorldsBody2 : PetEaterofWorldsBase { } - - public class PetEaterofWorldsTail : PetEaterofWorldsBase { } + [Content(ContentType.DroppedPets)] + public abstract class PetEaterofWorldsBase : SimplePetProjBase + { + public static int[] wormTypes; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tiny Eater of Worlds"); + Main.projFrames[Projectile.type] = 1; + Main.projPet[Projectile.type] = true; + //ProjectileID.Sets.DontAttachHideToAlpha[projectile.type] = true; //doesn't work for some reason with hide = true + //ProjectileID.Sets.NeedsUUID[projectile.type] = true; + } + + public override void SetDefaults() + { + AssAI.StardustDragonSetDefaults(Projectile, size: HITBOX_SIZE, minion: false); + Projectile.alpha = 0; + } + + //default 2 + public const int NUMBER_OF_BODY_SEGMENTS = 5; + + //default 24 + public const int HITBOX_SIZE = 24; + + //default 16 + public const int DISTANCE_BETWEEN_SEGMENTS = 17; + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetEaterofWorlds = false; + } + if (modPlayer.PetEaterofWorlds) + { + Projectile.timeLeft = 2; + } + + if (Projectile.type != ModContent.ProjectileType()) + { + AssAI.StardustDragonAI(Projectile, wormTypes, DISTANCE_BETWEEN_SEGMENTS); + } + else + { + AssAI.BabyEaterAI(Projectile); + //float scaleFactor = MathHelper.Clamp(projectile.localAI[0], 0f, 50f); + //projectile.scale = 1f + scaleFactor * 0.01f; + + Projectile.rotation = Projectile.velocity.ToRotation() + 1.57079637f; + Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); + } + } + + public override bool PreDraw(ref Color lightColor) + { + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 drawPos = Projectile.Center + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle drawRect = texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Color color = Projectile.GetAlpha(lightColor); + Vector2 drawOrigin = drawRect.Size() / 2f; + + //alpha5.A /= 2; + + Main.EntitySpriteDraw(texture, drawPos, drawRect, color, Projectile.rotation, drawOrigin, Projectile.scale, effects, 0); + + return false; + } + } + + public class PetEaterofWorldsHead : PetEaterofWorldsBase { } + + public class PetEaterofWorldsBody1 : PetEaterofWorldsBase { } + + public class PetEaterofWorldsBody2 : PetEaterofWorldsBase { } + + public class PetEaterofWorldsTail : PetEaterofWorldsBase { } } diff --git a/Projectiles/Pets/PetFishronProj.cs b/Projectiles/Pets/PetFishronProj.cs index 8ab529dd..22d0b687 100644 --- a/Projectiles/Pets/PetFishronProj.cs +++ b/Projectiles/Pets/PetFishronProj.cs @@ -7,67 +7,67 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class PetFishronProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/PetFishronProj_0"; //temp - } - } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mini Fishron"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.DroppedPets)] + public class PetFishronProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/PetFishronProj_0"; //temp + } + } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mini Fishron"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - Projectile.width = 54; - Projectile.height = 30; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + Projectile.width = 54; + Projectile.height = 30; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetFishron = false; - } - if (modPlayer.PetFishron) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetFishron = false; + } + if (modPlayer.PetFishron) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - SpriteEffects effects = SpriteEffects.None; - if (Projectile.spriteDirection != 1) - { - effects = SpriteEffects.FlipHorizontally; - } - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetFishronProj_" + mPlayer.petFishronType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f - Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + public override bool PreDraw(ref Color lightColor) + { + SpriteEffects effects = SpriteEffects.None; + if (Projectile.spriteDirection != 1) + { + effects = SpriteEffects.FlipHorizontally; + } + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetFishronProj_" + mPlayer.petFishronType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f - Projectile.gfxOffY); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/PetGoldfishProj.cs b/Projectiles/Pets/PetGoldfishProj.cs index dbde2be0..3925f0bf 100644 --- a/Projectiles/Pets/PetGoldfishProj.cs +++ b/Projectiles/Pets/PetGoldfishProj.cs @@ -9,339 +9,339 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class PetGoldfishProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/PetGoldfishProj_0"; //temp - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pet Goldfish"); - Main.projFrames[Projectile.type] = 10; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyGrinch); - Projectile.height = 24; - Projectile.width = 24; - AIType = ProjectileID.BabyGrinch; - } - - private bool Swimming { get { return Projectile.GetOwner().wet; } } - - /// - /// Player owner direction - /// - private int Direction { get; set; } - - private int Timer { get; set; } - - private int SavedIndex - { - get - { - return (int)Projectile.ai[1]; - } - set - { - Projectile.ai[1] = value; - } - } - - private const int Width = 8; - private const int Height = 4; - - private Point16 GetTilePosFromIndex(int index, Player player) - { - int indexX = index % Width; - int indexY = index / Width; - indexX *= Direction; - - Point16 startingPos = GetStartingPos(player); - int tileX = startingPos.X + indexX; - int tileY = startingPos.Y + indexY; - return new Point16(tileX, tileY); - } - - private Point16 GetStartingPos(Player player) - { - Point16 playerOrigin = new Point16((int)(player.Center.X / 16), (int)(player.Bottom.Y / 16)); - return new Point16(playerOrigin.X + (Direction * -(Width / 2)), playerOrigin.Y - Height); - } - - private void UpdateSavedIndex(Player player) - { - if (Timer > 30) - { - Timer = 0; - for (int index = 0; index < Width * Height; index++) - { - Direction = player.direction; - Point16 tilePos = GetTilePosFromIndex(index, player); - if (Framing.GetTileSafely(tilePos.X, tilePos.Y).LiquidAmount == 255 && Framing.GetTileSafely(tilePos.X, tilePos.Y - 1).LiquidAmount == 255 && Framing.GetTileSafely(tilePos.X - player.direction, tilePos.Y).LiquidAmount == 255) - { - SavedIndex = index; - break; - } - SavedIndex = -1; - } - - //DEBUG - //for (int index = 0; index < Width * Height; index++) - //{ - // Point16 tilePos = GetTilePosFromIndex(index, player); - // AssUtils.DrawDustAtPos(new Vector2(tilePos.X, tilePos.Y) * 16); - //} - } - } - - private Vector2 GetDesiredCenter(Player player) - { - /* checked area is given by Width and Height, starting at startingPos as top left/right corner (depending on player direction) + public class PetGoldfishProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/PetGoldfishProj_0"; //temp + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pet Goldfish"); + Main.projFrames[Projectile.type] = 10; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyGrinch); + Projectile.height = 24; + Projectile.width = 24; + AIType = ProjectileID.BabyGrinch; + } + + private bool Swimming { get { return Projectile.GetOwner().wet; } } + + /// + /// Player owner direction + /// + private int Direction { get; set; } + + private int Timer { get; set; } + + private int SavedIndex + { + get + { + return (int)Projectile.ai[1]; + } + set + { + Projectile.ai[1] = value; + } + } + + private const int Width = 8; + private const int Height = 4; + + private Point16 GetTilePosFromIndex(int index, Player player) + { + int indexX = index % Width; + int indexY = index / Width; + indexX *= Direction; + + Point16 startingPos = GetStartingPos(player); + int tileX = startingPos.X + indexX; + int tileY = startingPos.Y + indexY; + return new Point16(tileX, tileY); + } + + private Point16 GetStartingPos(Player player) + { + Point16 playerOrigin = new Point16((int)(player.Center.X / 16), (int)(player.Bottom.Y / 16)); + return new Point16(playerOrigin.X + (Direction * -(Width / 2)), playerOrigin.Y - Height); + } + + private void UpdateSavedIndex(Player player) + { + if (Timer > 30) + { + Timer = 0; + for (int index = 0; index < Width * Height; index++) + { + Direction = player.direction; + Point16 tilePos = GetTilePosFromIndex(index, player); + if (Framing.GetTileSafely(tilePos.X, tilePos.Y).LiquidAmount == 255 && Framing.GetTileSafely(tilePos.X, tilePos.Y - 1).LiquidAmount == 255 && Framing.GetTileSafely(tilePos.X - player.direction, tilePos.Y).LiquidAmount == 255) + { + SavedIndex = index; + break; + } + SavedIndex = -1; + } + + //DEBUG + //for (int index = 0; index < Width * Height; index++) + //{ + // Point16 tilePos = GetTilePosFromIndex(index, player); + // AssUtils.DrawDustAtPos(new Vector2(tilePos.X, tilePos.Y) * 16); + //} + } + } + + private Vector2 GetDesiredCenter(Player player) + { + /* checked area is given by Width and Height, starting at startingPos as top left/right corner (depending on player direction) * * +-4 : -4 from player.bottom * * start checking at +-8 */ - Vector2 desiredCenter = new Vector2(0f, player.width / 2); - Point16 playerOrigin = new Point16((int)(player.Center.X / 16), (int)(player.Bottom.Y / 16)); - - UpdateSavedIndex(player); - - if (SavedIndex != -1) - { - Point16 point = GetTilePosFromIndex(SavedIndex, player); - //DEBUG - //AssUtils.DrawDustAtPos(point.ToWorldCoordinates(0, 0), 1); - - //player.direction * 8 makes it so it has some space to swim, instead of constantly being stuck against a wall if there is one - desiredCenter = point.ToWorldCoordinates(player.direction * 8, 8) - playerOrigin.ToWorldCoordinates(0, 0); - } - - return desiredCenter; - } - - private void SwimmingZephyrfishAI() - { - Player player = Projectile.GetOwner(); - if (!player.active) - { - Projectile.active = false; - return; - } - Timer++; - - if (Projectile.wet) - { - Projectile.tileCollide = true; - } - else - { - Projectile.tileCollide = false; - } - - float num17 = 0.3f; - int num18 = 100; - Vector2 between = player.Center - Projectile.Center; - - between += GetDesiredCenter(player) + new Vector2(Main.rand.Next(-10, 21), Main.rand.Next(-10, 21)); - - float distance = between.Length(); - if (distance < num18 && player.velocity.Y == 0f && Projectile.position.Y + Projectile.height <= player.position.Y + player.height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - if (Projectile.velocity.Y < -6f) - { - Projectile.velocity.Y = -6f; - } - } - if (distance < 50f) - { - if (Math.Abs(Projectile.velocity.X) > 2f || Math.Abs(Projectile.velocity.Y) > 2f) - { - Projectile.velocity *= 0.99f; - } - num17 = 0.01f; - } - else - { - if (distance < 100f) - { - num17 = 0.1f; - } - if (distance > 300f) - { - num17 = 0.4f; - } - between.Normalize(); - between *= 6f; - } - if (Projectile.velocity.X < between.X) - { - Projectile.velocity.X = Projectile.velocity.X + num17; - if (num17 > 0.05f && Projectile.velocity.X < 0f) - { - Projectile.velocity.X = Projectile.velocity.X + num17; - } - } - if (Projectile.velocity.X > between.X) - { - Projectile.velocity.X = Projectile.velocity.X - num17; - if (num17 > 0.05f && Projectile.velocity.X > 0f) - { - Projectile.velocity.X = Projectile.velocity.X - num17; - } - } - if (Projectile.velocity.Y < between.Y) - { - Projectile.velocity.Y = Projectile.velocity.Y + num17; - if (num17 > 0.05f && Projectile.velocity.Y < 0f) - { - Projectile.velocity.Y = Projectile.velocity.Y + num17 * 2f; - } - } - if (Projectile.velocity.Y > between.Y) - { - Projectile.velocity.Y = Projectile.velocity.Y - num17; - if (num17 > 0.05f && Projectile.velocity.Y > 0f) - { - Projectile.velocity.Y = Projectile.velocity.Y - num17 * 2f; - } - } - - //fix, direction gets set automatically by tmodloader based on velocity.X for some reason - if (Projectile.velocity.X > 0.25f) - { - Projectile.ai[0] = -1; - } - else if (Projectile.velocity.X < -0.25f) - { - Projectile.ai[0] = 1; - } - Projectile.direction = (int)-Projectile.ai[0]; - Projectile.spriteDirection = Projectile.direction; - - Projectile.rotation = Projectile.velocity.X * 0.05f; - } - - private void GetFrame() - { - if (Swimming) - { - frame2Counter++; - if (frame2Counter > 5) - { - frame2++; - frame2Counter = 0; - } - if (frame2 < 6 || frame2 > 9) - { - frame2 = 6; - } - return; - } - - if (Projectile.ai[0] == 0) //not flying - { - if (Projectile.velocity.Y == 0f) - { - float xAbs = Math.Abs(Projectile.velocity.X); - if (Projectile.velocity.X == 0f) - { - frame2 = 0; - frame2Counter = 0; - } - else if (xAbs > 0.5f) - { - frame2Counter += (int)(2 * xAbs); - frame2Counter++; - if (frame2Counter > 20) //6 - { - frame2++; - frame2Counter = 0; - } - if (frame2 > 5) //frame 1 to 5 is running - { - frame2 = 1; - } - } - else - { - frame2 = 0; //frame 0 is idle - frame2Counter = 10; - } - } - else if (Projectile.velocity.Y != 0f) - { - frame2Counter = 0; - frame2 = 1; //frame 1 is jumping - } - } - else //flying - { - if (Projectile.velocity.X <= 0) Projectile.direction = -1; - else Projectile.direction = 1; - frame2Counter++; - if (Projectile.velocity.Length() > 3.6f) Projectile.velocity *= 0.97f; - if (frame2Counter > 4) - { - frame2++; - frame2Counter = 0; - } - if (frame2 < 6 || frame2 > 9) - { - frame2 = 6; - } - Projectile.rotation = Projectile.velocity.X * 0.02f; - } - } - - private int frame2Counter = 0; - private int frame2 = 0; - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetGoldfish = false; - } - if (modPlayer.PetGoldfish) - { - Projectile.timeLeft = 2; - } - - if (Swimming) - { - SwimmingZephyrfishAI(); - return false; - } - Timer = 0; - Projectile.ai[1] = 0; //reset from ZephyrfishAI(); - - return true; - } - - public override bool PreDraw(ref Color lightColor) - { - if (Main.hasFocus) GetFrame(); - - lightColor = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16), Color.White); - SpriteEffects effects = Projectile.direction != -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetGoldfishProj_" + mPlayer.petGoldfishType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: frame2); - Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f - 2 + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - - return false; - } - } + Vector2 desiredCenter = new Vector2(0f, player.width / 2); + Point16 playerOrigin = new Point16((int)(player.Center.X / 16), (int)(player.Bottom.Y / 16)); + + UpdateSavedIndex(player); + + if (SavedIndex != -1) + { + Point16 point = GetTilePosFromIndex(SavedIndex, player); + //DEBUG + //AssUtils.DrawDustAtPos(point.ToWorldCoordinates(0, 0), 1); + + //player.direction * 8 makes it so it has some space to swim, instead of constantly being stuck against a wall if there is one + desiredCenter = point.ToWorldCoordinates(player.direction * 8, 8) - playerOrigin.ToWorldCoordinates(0, 0); + } + + return desiredCenter; + } + + private void SwimmingZephyrfishAI() + { + Player player = Projectile.GetOwner(); + if (!player.active) + { + Projectile.active = false; + return; + } + Timer++; + + if (Projectile.wet) + { + Projectile.tileCollide = true; + } + else + { + Projectile.tileCollide = false; + } + + float num17 = 0.3f; + int num18 = 100; + Vector2 between = player.Center - Projectile.Center; + + between += GetDesiredCenter(player) + new Vector2(Main.rand.Next(-10, 21), Main.rand.Next(-10, 21)); + + float distance = between.Length(); + if (distance < num18 && player.velocity.Y == 0f && Projectile.position.Y + Projectile.height <= player.position.Y + player.height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + if (Projectile.velocity.Y < -6f) + { + Projectile.velocity.Y = -6f; + } + } + if (distance < 50f) + { + if (Math.Abs(Projectile.velocity.X) > 2f || Math.Abs(Projectile.velocity.Y) > 2f) + { + Projectile.velocity *= 0.99f; + } + num17 = 0.01f; + } + else + { + if (distance < 100f) + { + num17 = 0.1f; + } + if (distance > 300f) + { + num17 = 0.4f; + } + between.Normalize(); + between *= 6f; + } + if (Projectile.velocity.X < between.X) + { + Projectile.velocity.X = Projectile.velocity.X + num17; + if (num17 > 0.05f && Projectile.velocity.X < 0f) + { + Projectile.velocity.X = Projectile.velocity.X + num17; + } + } + if (Projectile.velocity.X > between.X) + { + Projectile.velocity.X = Projectile.velocity.X - num17; + if (num17 > 0.05f && Projectile.velocity.X > 0f) + { + Projectile.velocity.X = Projectile.velocity.X - num17; + } + } + if (Projectile.velocity.Y < between.Y) + { + Projectile.velocity.Y = Projectile.velocity.Y + num17; + if (num17 > 0.05f && Projectile.velocity.Y < 0f) + { + Projectile.velocity.Y = Projectile.velocity.Y + num17 * 2f; + } + } + if (Projectile.velocity.Y > between.Y) + { + Projectile.velocity.Y = Projectile.velocity.Y - num17; + if (num17 > 0.05f && Projectile.velocity.Y > 0f) + { + Projectile.velocity.Y = Projectile.velocity.Y - num17 * 2f; + } + } + + //fix, direction gets set automatically by tmodloader based on velocity.X for some reason + if (Projectile.velocity.X > 0.25f) + { + Projectile.ai[0] = -1; + } + else if (Projectile.velocity.X < -0.25f) + { + Projectile.ai[0] = 1; + } + Projectile.direction = (int)-Projectile.ai[0]; + Projectile.spriteDirection = Projectile.direction; + + Projectile.rotation = Projectile.velocity.X * 0.05f; + } + + private void GetFrame() + { + if (Swimming) + { + frame2Counter++; + if (frame2Counter > 5) + { + frame2++; + frame2Counter = 0; + } + if (frame2 < 6 || frame2 > 9) + { + frame2 = 6; + } + return; + } + + if (Projectile.ai[0] == 0) //not flying + { + if (Projectile.velocity.Y == 0f) + { + float xAbs = Math.Abs(Projectile.velocity.X); + if (Projectile.velocity.X == 0f) + { + frame2 = 0; + frame2Counter = 0; + } + else if (xAbs > 0.5f) + { + frame2Counter += (int)(2 * xAbs); + frame2Counter++; + if (frame2Counter > 20) //6 + { + frame2++; + frame2Counter = 0; + } + if (frame2 > 5) //frame 1 to 5 is running + { + frame2 = 1; + } + } + else + { + frame2 = 0; //frame 0 is idle + frame2Counter = 10; + } + } + else if (Projectile.velocity.Y != 0f) + { + frame2Counter = 0; + frame2 = 1; //frame 1 is jumping + } + } + else //flying + { + if (Projectile.velocity.X <= 0) Projectile.direction = -1; + else Projectile.direction = 1; + frame2Counter++; + if (Projectile.velocity.Length() > 3.6f) Projectile.velocity *= 0.97f; + if (frame2Counter > 4) + { + frame2++; + frame2Counter = 0; + } + if (frame2 < 6 || frame2 > 9) + { + frame2 = 6; + } + Projectile.rotation = Projectile.velocity.X * 0.02f; + } + } + + private int frame2Counter = 0; + private int frame2 = 0; + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetGoldfish = false; + } + if (modPlayer.PetGoldfish) + { + Projectile.timeLeft = 2; + } + + if (Swimming) + { + SwimmingZephyrfishAI(); + return false; + } + Timer = 0; + Projectile.ai[1] = 0; //reset from ZephyrfishAI(); + + return true; + } + + public override bool PreDraw(ref Color lightColor) + { + if (Main.hasFocus) GetFrame(); + + lightColor = Lighting.GetColor((int)(Projectile.Center.X / 16), (int)(Projectile.Center.Y / 16), Color.White); + SpriteEffects effects = Projectile.direction != -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetGoldfishProj_" + mPlayer.petGoldfishType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: frame2); + Vector2 stupidOffset = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f - 2 + Projectile.gfxOffY); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + + return false; + } + } } diff --git a/Projectiles/Pets/PetGolemHeadProj.cs b/Projectiles/Pets/PetGolemHeadProj.cs index d538ff81..8b30fd93 100644 --- a/Projectiles/Pets/PetGolemHeadProj.cs +++ b/Projectiles/Pets/PetGolemHeadProj.cs @@ -11,134 +11,134 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class PetGolemHeadProj : DroneBase - { - public const int AttackDelay = 60; - - private const int FireballDamage = 20; - - public override bool IsCombatDrone - { - get - { - return false; - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Replica Golem Head"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - DrawOriginOffsetY = -10; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - Projectile.aiStyle = -1; - Projectile.width = 38; - Projectile.height = 38; - Projectile.tileCollide = false; - } - - protected override void CheckActive() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetGolemHead = false; - } - if (modPlayer.PetGolemHead) - { - Projectile.timeLeft = 2; - } - } - - protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) - { - if (Counter > AttackDelay) - { - if (Counter < (int)(AttackDelay * 1.5f)) - { - Projectile.frame = 1; - } - else - { - Projectile.frame = 0; - } - } - else - { - Projectile.frame = 0; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Sincounter = Sincounter > 360 ? 0 : Sincounter + 1; - sinY = (float)((Math.Sin((Sincounter / 180f) * MathHelper.TwoPi) - 1) * 4); - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); - Main.EntitySpriteDraw(ModContent.Request(Texture + "_Glowmask").Value, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); - - return false; - } - - protected override bool Bobbing() - { - return false; - } - - protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) - { - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, staticDirection: true, veloSpeed: 0.5f, offsetX: -30f, offsetY: -100f); - return false; - } - - protected override void CustomAI() - { - Projectile.rotation = 0f; - - Counter++; - if (Counter % AttackDelay == 0) - { - if (Main.myPlayer == Projectile.owner) - { - int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 600); - if (targetIndex != -1 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - if (Counter == AttackDelay) Counter += AttackDelay; - Vector2 position = Projectile.Center; - position.Y += 6f; - Vector2 velocity = Main.npc[targetIndex].Center + Main.npc[targetIndex].velocity * 5f - position; - velocity.Normalize(); - velocity *= 7f; - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), position, velocity, ModContent.ProjectileType(), FireballDamage, 2f, Main.myPlayer, 0f, 0f); - Projectile.netUpdate = true; - } - else - { - if (Counter > AttackDelay) - { - Counter -= AttackDelay; - Projectile.netUpdate = true; - } - } - } - Counter -= AttackDelay; - } - } - } + [Content(ContentType.DroppedPets)] + public class PetGolemHeadProj : DroneBase + { + public const int AttackDelay = 60; + + private const int FireballDamage = 20; + + public override bool IsCombatDrone + { + get + { + return false; + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Replica Golem Head"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + DrawOriginOffsetY = -10; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + Projectile.aiStyle = -1; + Projectile.width = 38; + Projectile.height = 38; + Projectile.tileCollide = false; + } + + protected override void CheckActive() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetGolemHead = false; + } + if (modPlayer.PetGolemHead) + { + Projectile.timeLeft = 2; + } + } + + protected override void CustomFrame(int frameCounterMaxFar = 4, int frameCounterMaxClose = 8) + { + if (Counter > AttackDelay) + { + if (Counter < (int)(AttackDelay * 1.5f)) + { + Projectile.frame = 1; + } + else + { + Projectile.frame = 0; + } + } + else + { + Projectile.frame = 0; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Sincounter = Sincounter > 360 ? 0 : Sincounter + 1; + sinY = (float)((Math.Sin((Sincounter / 180f) * MathHelper.TwoPi) - 1) * 4); + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); + Main.EntitySpriteDraw(ModContent.Request(Texture + "_Glowmask").Value, drawPos, bounds, Color.White, Projectile.rotation, drawOrigin, 1f, effects, 0); + + return false; + } + + protected override bool Bobbing() + { + return false; + } + + protected override bool ModifyDefaultAI(ref bool staticDirection, ref bool reverseSide, ref float veloXToRotationFactor, ref float veloSpeed, ref float offsetX, ref float offsetY) + { + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, staticDirection: true, veloSpeed: 0.5f, offsetX: -30f, offsetY: -100f); + return false; + } + + protected override void CustomAI() + { + Projectile.rotation = 0f; + + Counter++; + if (Counter % AttackDelay == 0) + { + if (Main.myPlayer == Projectile.owner) + { + int targetIndex = AssAI.FindTarget(Projectile, Projectile.Center, 600); + if (targetIndex != -1 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + if (Counter == AttackDelay) Counter += AttackDelay; + Vector2 position = Projectile.Center; + position.Y += 6f; + Vector2 velocity = Main.npc[targetIndex].Center + Main.npc[targetIndex].velocity * 5f - position; + velocity.Normalize(); + velocity *= 7f; + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), position, velocity, ModContent.ProjectileType(), FireballDamage, 2f, Main.myPlayer, 0f, 0f); + Projectile.netUpdate = true; + } + else + { + if (Counter > AttackDelay) + { + Counter -= AttackDelay; + Projectile.netUpdate = true; + } + } + } + Counter -= AttackDelay; + } + } + } } diff --git a/Projectiles/Pets/PetHarvesterProj.cs b/Projectiles/Pets/PetHarvesterProj.cs index 90c6d574..6c5c8518 100644 --- a/Projectiles/Pets/PetHarvesterProj.cs +++ b/Projectiles/Pets/PetHarvesterProj.cs @@ -8,64 +8,64 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.Bosses)] - public class PetHarvesterProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stubborn Bird"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.Bosses)] + public class PetHarvesterProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stubborn Bird"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetHarvester = false; - } - if (modPlayer.PetHarvester) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetHarvester = false; + } + if (modPlayer.PetHarvester) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + public override bool PreDraw(ref Color lightColor) + { + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Main.instance.LoadProjectile(Projectile.type); + Main.instance.LoadProjectile(Projectile.type); - Texture2D image = TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Texture2D image = TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 origin = bounds.Size() / 2; + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 origin = bounds.Size() / 2; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, origin, Projectile.scale, effects, 0); - image = ModContent.Request(GlowTexture).Value; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, origin, Projectile.scale, effects, 0); + image = ModContent.Request(GlowTexture).Value; + Main.EntitySpriteDraw(image, drawPos, bounds, Color.White, Projectile.rotation, origin, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/PetMoonProj.cs b/Projectiles/Pets/PetMoonProj.cs index cfe13347..10c9fd55 100644 --- a/Projectiles/Pets/PetMoonProj.cs +++ b/Projectiles/Pets/PetMoonProj.cs @@ -7,102 +7,102 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class PetMoonProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/PetMoonProj_0"; //temp - } - } + public class PetMoonProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/PetMoonProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Personal Moon"); - Main.projFrames[Projectile.type] = 8; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.LightPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Personal Moon"); + Main.projFrames[Projectile.type] = 8; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.LightPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 40; - Projectile.height = 40; - Projectile.alpha = 0; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 40; + Projectile.height = 40; + Projectile.alpha = 0; + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - Projectile.frame = Main.moonPhase; + Projectile.frame = Main.moonPhase; - if (Projectile.frame == 4 || Main.eclipse) - { - //Invisible - return false; - } + if (Projectile.frame == 4 || Main.eclipse) + { + //Invisible + return false; + } - //int texture = Main.moonType; //0, 1 and 2 - int texture = mPlayer.petMoonType; - if (Main.pumpkinMoon) - { - texture = 9; - } - else if (Main.snowMoon) - { - texture = 10; - } - else if (WorldGen.drunkWorldGen) - { - texture = 11; - } + //int texture = Main.moonType; //0, 1 and 2 + int texture = mPlayer.petMoonType; + if (Main.pumpkinMoon) + { + texture = 9; + } + else if (Main.snowMoon) + { + texture = 10; + } + else if (WorldGen.drunkWorldGen) + { + texture = 11; + } - Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetMoonProj_" + texture).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetMoonProj_" + texture).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height - 18f); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height - 18f); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Main.EntitySpriteDraw(image, drawPos, bounds, Color.LightGray, 0f, bounds.Size() / 2, 1f, SpriteEffects.None, 0); - return false; - } + Main.EntitySpriteDraw(image, drawPos, bounds, Color.LightGray, 0f, bounds.Size() / 2, 1f, SpriteEffects.None, 0); + return false; + } - public override void AI() - { - Vector3 lightVector = Vector3.One * 0.6f; - float lightFactor = 1f; - //0 is 1f, 4 is not drawn at all - if (Projectile.frame == 1 || Projectile.frame == 7) - { - lightFactor = 0.85f; - } - else if (Projectile.frame == 2 || Projectile.frame == 6) - { - lightFactor = 0.7f; - } - else if (Projectile.frame == 3 || Projectile.frame == 5) - { - lightFactor = 0.55f; - } + public override void AI() + { + Vector3 lightVector = Vector3.One * 0.6f; + float lightFactor = 1f; + //0 is 1f, 4 is not drawn at all + if (Projectile.frame == 1 || Projectile.frame == 7) + { + lightFactor = 0.85f; + } + else if (Projectile.frame == 2 || Projectile.frame == 6) + { + lightFactor = 0.7f; + } + else if (Projectile.frame == 3 || Projectile.frame == 5) + { + lightFactor = 0.55f; + } - Lighting.AddLight(Projectile.Center, lightVector * lightFactor); + Lighting.AddLight(Projectile.Center, lightVector * lightFactor); - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetMoon = false; - } - if (modPlayer.PetMoon) - { - Projectile.timeLeft = 2; + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetMoon = false; + } + if (modPlayer.PetMoon) + { + Projectile.timeLeft = 2; - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, offsetX: 20f, offsetY: -32f); - } - } - } + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, offsetX: 20f, offsetY: -32f); + } + } + } } diff --git a/Projectiles/Pets/PetPlanteraProj.cs b/Projectiles/Pets/PetPlanteraProj.cs index 931691b9..4ccf2b73 100644 --- a/Projectiles/Pets/PetPlanteraProj.cs +++ b/Projectiles/Pets/PetPlanteraProj.cs @@ -1,270 +1,268 @@ using AssortedCrazyThings.Base; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - //cannot be dyed since it counts as a minion and deals damage - [Content(ContentType.DroppedPets)] - public class PetPlanteraProj : SimplePetProjBase - { - public const int ContactDamage = 20; - public const int ImmunityCooldown = 60; + //cannot be dyed since it counts as a minion and deals damage + [Content(ContentType.DroppedPets)] + public class PetPlanteraProj : SimplePetProjBase + { + public const int ContactDamage = 20; + public const int ImmunityCooldown = 60; - private const float STATE_IDLE = 0f; - private const float STATE_ATTACK = 1f; + private const float STATE_IDLE = 0f; + private const float STATE_ATTACK = 1f; - public float AI_STATE - { - get - { - return Projectile.ai[0]; - } - set - { - Projectile.ai[0] = value; - } - } + public float AI_STATE + { + get + { + return Projectile.ai[0]; + } + set + { + Projectile.ai[0] = value; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plantera Sprout"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plantera Sprout"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - Projectile.width = 36; - Projectile.height = 36; - Projectile.friendly = true; - Projectile.minion = false; //only determines the damage type - //minion = false to prevent it from being "replaced" after casting other summons and then spawning its tentacles again - Projectile.minionSlots = 0f; - Projectile.penetrate = -1; - Projectile.aiStyle = -1; + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + Projectile.width = 36; + Projectile.height = 36; + Projectile.friendly = true; + Projectile.minion = false; //only determines the damage type + //minion = false to prevent it from being "replaced" after casting other summons and then spawning its tentacles again + Projectile.minionSlots = 0f; + Projectile.penetrate = -1; + Projectile.aiStyle = -1; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = ImmunityCooldown; - } + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = ImmunityCooldown; + } - public override bool? CanCutTiles() - { - return false; - } + public override bool? CanCutTiles() + { + return false; + } - public override bool MinionContactDamage() - { - return true; - } + public override bool MinionContactDamage() + { + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetPlantera = false; - } - if (modPlayer.PetPlantera) - { - Projectile.timeLeft = 2; - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetPlantera = false; + } + if (modPlayer.PetPlantera) + { + Projectile.timeLeft = 2; + } - #region Handle State - int targetIndex = AssAI.FindTarget(Projectile, player.Center, 300); //check for player surrounding - if (targetIndex == -1) - { - if (AI_STATE == STATE_ATTACK) - { - targetIndex = AssAI.FindTarget(Projectile, player.Center, 400); //check for player surrounding - if (targetIndex == -1) - { - AI_STATE = STATE_IDLE; - Projectile.netUpdate = true; - } - } - else - { - //keep idling - } - } - else //target found - { - if (AI_STATE == STATE_IDLE) - { - AI_STATE = STATE_ATTACK; - Projectile.netUpdate = true; - } - else - { - //keep attacking - } - } - #endregion + #region Handle State + int targetIndex = AssAI.FindTarget(Projectile, player.Center, 300); //check for player surrounding + if (targetIndex == -1) + { + if (AI_STATE == STATE_ATTACK) + { + targetIndex = AssAI.FindTarget(Projectile, player.Center, 400); //check for player surrounding + if (targetIndex == -1) + { + AI_STATE = STATE_IDLE; + Projectile.netUpdate = true; + } + } + else + { + //keep idling + } + } + else //target found + { + if (AI_STATE == STATE_IDLE) + { + AI_STATE = STATE_ATTACK; + Projectile.netUpdate = true; + } + else + { + //keep attacking + } + } + #endregion - #region Act Upon State - if (AI_STATE == STATE_IDLE) - { - Projectile.friendly = false; - AssAI.BabyEaterAI(Projectile, originOffset: new Vector2(0f, -60f)); + #region Act Upon State + if (AI_STATE == STATE_IDLE) + { + Projectile.friendly = false; + AssAI.BabyEaterAI(Projectile, originOffset: new Vector2(0f, -60f)); - AssAI.BabyEaterDraw(Projectile); - Projectile.rotation += 3.14159f; - } - else //STATE_ATTACK - { - Projectile.friendly = true; + AssAI.BabyEaterDraw(Projectile); + Projectile.rotation += 3.14159f; + } + else //STATE_ATTACK + { + Projectile.friendly = true; - if (targetIndex != -1) - { - NPC npc = Main.npc[targetIndex]; - Vector2 distanceToTargetVector = npc.Center - Projectile.Center; - float distanceToTarget = distanceToTargetVector.Length(); + if (targetIndex != -1) + { + NPC npc = Main.npc[targetIndex]; + Vector2 distanceToTargetVector = npc.Center - Projectile.Center; + float distanceToTarget = distanceToTargetVector.Length(); - if (distanceToTarget > 30f) - { - distanceToTargetVector.Normalize(); - distanceToTargetVector *= 8f; - Projectile.velocity = (Projectile.velocity * (16f - 1) + distanceToTargetVector) / 16f; + if (distanceToTarget > 30f) + { + distanceToTargetVector.Normalize(); + distanceToTargetVector *= 8f; + Projectile.velocity = (Projectile.velocity * (16f - 1) + distanceToTargetVector) / 16f; - Projectile.rotation = distanceToTargetVector.ToRotation() + 1.57f; - } - } + Projectile.rotation = distanceToTargetVector.ToRotation() + 1.57f; + } + } - AssAI.BabyEaterDraw(Projectile, 4); - } - #endregion - } + AssAI.BabyEaterDraw(Projectile, 4); + } + #endregion + } - public override bool PreDraw(ref Color lightColor) - { - int tentacleCount = 0; + public override bool PreDraw(ref Color lightColor) + { + int tentacleCount = 0; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile projectile = Main.projectile[i]; - if (projectile.active && Projectile.owner == projectile.owner && projectile.type == ModContent.ProjectileType()) - { - AssUtils.DrawTether("AssortedCrazyThings/Projectiles/Pets/PetPlanteraProj_Chain", projectile.Center, Projectile.Center); - tentacleCount++; - } - if (tentacleCount >= 4) break; - } - AssUtils.DrawTether("AssortedCrazyThings/Projectiles/Pets/PetPlanteraProj_Chain", Projectile.GetOwner().Center, Projectile.Center); - return true; - } - } + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile projectile = Main.projectile[i]; + if (projectile.active && Projectile.owner == projectile.owner && projectile.type == ModContent.ProjectileType()) + { + AssUtils.DrawTether("AssortedCrazyThings/Projectiles/Pets/PetPlanteraProj_Chain", projectile.Center, Projectile.Center); + tentacleCount++; + } + if (tentacleCount >= 4) break; + } + AssUtils.DrawTether("AssortedCrazyThings/Projectiles/Pets/PetPlanteraProj_Chain", Projectile.GetOwner().Center, Projectile.Center); + return true; + } + } - [Content(ContentType.DroppedPets)] - public class PetPlanteraProjTentacle : SimplePetProjBase - { - //since the index might be different between clients, using ai[] for it will break stuff - public int ParentIndex - { - get - { - return (int)Projectile.localAI[0] - 1; - } - set - { - Projectile.localAI[0] = value + 1; - } - } + [Content(ContentType.DroppedPets)] + public class PetPlanteraProjTentacle : SimplePetProjBase + { + //since the index might be different between clients, using ai[] for it will break stuff + public int ParentIndex + { + get + { + return (int)Projectile.localAI[0] - 1; + } + set + { + Projectile.localAI[0] = value + 1; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mean Seed Tentacle"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mean Seed Tentacle"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - Projectile.aiStyle = -1; - Projectile.width = 14; //14 - Projectile.height = 19; //19 - //gets set in the buff - //projectile.damage = 1; //to prevent dyes from working on it - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + Projectile.aiStyle = -1; + Projectile.width = 14; //14 + Projectile.height = 19; //19 + //gets set in the buff + //projectile.damage = 1; //to prevent dyes from working on it + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetPlantera = false; - } - if (modPlayer.PetPlantera) - { - Projectile.timeLeft = 2; - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetPlantera = false; + } + if (modPlayer.PetPlantera) + { + Projectile.timeLeft = 2; + } - #region Find Parent - //set parent when spawned - if (ParentIndex < 0) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Projectile.owner == Main.projectile[i].owner) - { - ParentIndex = i; - //projectile.netUpdate = true; - break; - } - } - } + #region Find Parent + //set parent when spawned + if (ParentIndex < 0) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Projectile.owner == Main.projectile[i].owner) + { + ParentIndex = i; + //projectile.netUpdate = true; + break; + } + } + } - //if something goes wrong, abort mission - if (ParentIndex < 0 || (ParentIndex > -1 && Main.projectile[ParentIndex].type != ModContent.ProjectileType())) - { - Projectile.Kill(); - return; - } - #endregion + //if something goes wrong, abort mission + if (ParentIndex < 0 || (ParentIndex > -1 && Main.projectile[ParentIndex].type != ModContent.ProjectileType())) + { + Projectile.Kill(); + return; + } + #endregion - //offsets so the tentacles are distributed evenly - float offsetX = 0; - float offsetY = 0; - switch (Projectile.whoAmI % 4) - { - case 0: - offsetX = -120 + Main.rand.Next(20); - offsetY = 0; - break; - case 1: - offsetX = -120 + Main.rand.Next(20); - offsetY = 120; - break; - case 2: - offsetX = 0 - Main.rand.Next(20); - offsetY = 120; - break; - default: //case 3 - break; - } + //offsets so the tentacles are distributed evenly + float offsetX = 0; + float offsetY = 0; + switch (Projectile.whoAmI % 4) + { + case 0: + offsetX = -120 + Main.rand.Next(20); + offsetY = 0; + break; + case 1: + offsetX = -120 + Main.rand.Next(20); + offsetY = 120; + break; + case 2: + offsetX = 0 - Main.rand.Next(20); + offsetY = 120; + break; + default: //case 3 + break; + } - Projectile parent = Main.projectile[ParentIndex]; - if (!parent.active) - { - Projectile.active = false; - return; - } + Projectile parent = Main.projectile[ParentIndex]; + if (!parent.active) + { + Projectile.active = false; + return; + } - //velocityFactor: 1.5f + (projectile.whoAmI % 4) * 0.8f so all tentacles don't share the same movement - AssAI.ZephyrfishAI(Projectile, parent: parent, velocityFactor: 1.5f + (Projectile.whoAmI % 4) * 0.8f, random: true, swapSides: 1, offsetX: offsetX, offsetY: offsetY); - Vector2 between = parent.Center - Projectile.Center; - Projectile.spriteDirection = 1; - Projectile.rotation = between.ToRotation(); + //velocityFactor: 1.5f + (projectile.whoAmI % 4) * 0.8f so all tentacles don't share the same movement + AssAI.ZephyrfishAI(Projectile, parent: parent, velocityFactor: 1.5f + (Projectile.whoAmI % 4) * 0.8f, random: true, swapSides: 1, offsetX: offsetX, offsetY: offsetY); + Vector2 between = parent.Center - Projectile.Center; + Projectile.spriteDirection = 1; + Projectile.rotation = between.ToRotation(); - AssAI.ZephyrfishDraw(Projectile, 3 + Main.rand.Next(3)); - } - } + AssAI.ZephyrfishDraw(Projectile, 3 + Main.rand.Next(3)); + } + } } diff --git a/Projectiles/Pets/PetQueenSlimeProj.cs b/Projectiles/Pets/PetQueenSlimeProj.cs index 0d940e45..dc842727 100644 --- a/Projectiles/Pets/PetQueenSlimeProj.cs +++ b/Projectiles/Pets/PetQueenSlimeProj.cs @@ -5,125 +5,125 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class PetQueenSlimeAirProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slime Sibling"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - Projectile.width = 20; - Projectile.height = 20; - } - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetQueenSlime = false; - } - if (modPlayer.PetQueenSlime) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } - - [Content(ContentType.DroppedPets)] - public abstract class PetQueenSlimeGroundProj : BabySlimeBase - { - const int period = 70; - protected bool front; - - protected int timer = 0; - - public override bool UseJumpingFrame => false; - - public PetQueenSlimeGroundProj(bool front) - { - this.front = front; - } - - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Slime Sibling"); - } - - public override void SafeSetDefaults() - { - Projectile.minion = false; - - Projectile.width = 20; - Projectile.height = 18; - Projectile.hide = true; - - DrawOriginOffsetY = 0; - DrawOffsetX = -20; - } - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetQueenSlime = false; - } - if (modPlayer.PetQueenSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - - public override void PostAI() - { - timer = (timer + 1) % period; - - alignFront = (timer - period / 2) > 0; - if (!front) - { - alignFront = !alignFront; - } - } - - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) - { - (alignFront ? overPlayers : behindProjectiles).Add(index); - } - } - - public class PetQueenSlimeGround1Proj : PetQueenSlimeGroundProj - { - public PetQueenSlimeGround1Proj() : base(true) - { - - } - } - - public class PetQueenSlimeGround2Proj : PetQueenSlimeGroundProj - { - - public PetQueenSlimeGround2Proj() : base(false) - { - - } - } + [Content(ContentType.DroppedPets)] + public class PetQueenSlimeAirProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slime Sibling"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + Projectile.width = 20; + Projectile.height = 20; + } + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetQueenSlime = false; + } + if (modPlayer.PetQueenSlime) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } + + [Content(ContentType.DroppedPets)] + public abstract class PetQueenSlimeGroundProj : BabySlimeBase + { + const int period = 70; + protected bool front; + + protected int timer = 0; + + public override bool UseJumpingFrame => false; + + public PetQueenSlimeGroundProj(bool front) + { + this.front = front; + } + + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Slime Sibling"); + } + + public override void SafeSetDefaults() + { + Projectile.minion = false; + + Projectile.width = 20; + Projectile.height = 18; + Projectile.hide = true; + + DrawOriginOffsetY = 0; + DrawOffsetX = -20; + } + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetQueenSlime = false; + } + if (modPlayer.PetQueenSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + + public override void PostAI() + { + timer = (timer + 1) % period; + + alignFront = (timer - period / 2) > 0; + if (!front) + { + alignFront = !alignFront; + } + } + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + (alignFront ? overPlayers : behindProjectiles).Add(index); + } + } + + public class PetQueenSlimeGround1Proj : PetQueenSlimeGroundProj + { + public PetQueenSlimeGround1Proj() : base(true) + { + + } + } + + public class PetQueenSlimeGround2Proj : PetQueenSlimeGroundProj + { + + public PetQueenSlimeGround2Proj() : base(false) + { + + } + } } diff --git a/Projectiles/Pets/PetSunProj.cs b/Projectiles/Pets/PetSunProj.cs index e9126d7a..6c0fd667 100644 --- a/Projectiles/Pets/PetSunProj.cs +++ b/Projectiles/Pets/PetSunProj.cs @@ -7,82 +7,82 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class PetSunProj : SimplePetProjBase - { - private float coronaRotation = 0f; - private const float coronaRotationSpeed = 0.008f; + public class PetSunProj : SimplePetProjBase + { + private float coronaRotation = 0f; + private const float coronaRotationSpeed = 0.008f; - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/PetSunProj_0"; //temp - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/PetSunProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Personal Sun"); - Main.projFrames[Projectile.type] = 1; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.LightPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Personal Sun"); + Main.projFrames[Projectile.type] = 1; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.LightPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 54; - Projectile.height = 54; - Projectile.alpha = 0; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 54; + Projectile.height = 54; + Projectile.alpha = 0; + } - public override bool PreDraw(ref Color lightColor) - { - Lighting.AddLight(Projectile.Center, Vector3.One); + public override bool PreDraw(ref Color lightColor) + { + Lighting.AddLight(Projectile.Center, Vector3.One); - int texture = 0; - if (Main.eclipse) //takes priority - { - texture = 2; - } - else if (Projectile.GetOwner().head == 12) - { - texture = 1; - } + int texture = 0; + if (Main.eclipse) //takes priority + { + texture = 2; + } + else if (Projectile.GetOwner().head == 12) + { + texture = 1; + } - Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetSunProj_" + texture).Value; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/PetSunProj_" + texture).Value; - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height - 28f); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height - 28f); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Texture2D corona = Mod.Assets.Request("Projectiles/Pets/PetSunProj_Corona").Value; - Main.EntitySpriteDraw(corona, drawPos, image.Bounds, Color.White, coronaRotation, image.Bounds.Size() / 2, 1f, SpriteEffects.None, 0); + Texture2D corona = Mod.Assets.Request("Projectiles/Pets/PetSunProj_Corona").Value; + Main.EntitySpriteDraw(corona, drawPos, image.Bounds, Color.White, coronaRotation, image.Bounds.Size() / 2, 1f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(image, drawPos, image.Bounds, Color.White, 0f, image.Bounds.Size() / 2, 1f, SpriteEffects.None, 0); - return false; - } + Main.EntitySpriteDraw(image, drawPos, image.Bounds, Color.White, 0f, image.Bounds.Size() / 2, 1f, SpriteEffects.None, 0); + return false; + } - public override void AI() - { - coronaRotation += coronaRotationSpeed; - if (coronaRotation > MathHelper.TwoPi) - { - coronaRotation %= MathHelper.TwoPi; - } + public override void AI() + { + coronaRotation += coronaRotationSpeed; + if (coronaRotation > MathHelper.TwoPi) + { + coronaRotation %= MathHelper.TwoPi; + } - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.PetSun = false; - } - if (modPlayer.PetSun) - { - Projectile.timeLeft = 2; + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.PetSun = false; + } + if (modPlayer.PetSun) + { + Projectile.timeLeft = 2; - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, offsetX: 20f, offsetY: -32f); - } - } - } + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, offsetX: 20f, offsetY: -32f); + } + } + } } diff --git a/Projectiles/Pets/PigronataProj.cs b/Projectiles/Pets/PigronataProj.cs index fb5446f5..ec7c5b36 100644 --- a/Projectiles/Pets/PigronataProj.cs +++ b/Projectiles/Pets/PigronataProj.cs @@ -7,65 +7,65 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class PigronataProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/PigronataProj_0"; //temp - } - } + public class PigronataProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/PigronataProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pigronata"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pigronata"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - Projectile.width = 44; - Projectile.height = 34; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + Projectile.width = 44; + Projectile.height = 34; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.Pigronata = false; - } - if (modPlayer.Pigronata) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.Pigronata = false; + } + if (modPlayer.Pigronata) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/PigronataProj_" + mPlayer.pigronataType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/PigronataProj_" + mPlayer.pigronataType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/PrinceSlimeProj.cs b/Projectiles/Pets/PrinceSlimeProj.cs index 0788b898..8c90ee6f 100644 --- a/Projectiles/Pets/PrinceSlimeProj.cs +++ b/Projectiles/Pets/PrinceSlimeProj.cs @@ -6,50 +6,50 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - //check this file for more info vvvvvvvv - public class PrinceSlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Prince Slime"); - } - - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; - - Projectile.minion = false; - } - - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.PrinceSlime = false; - } - if (modPlayer.PrinceSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - - public override void PostDraw(Color drawColor) - { - Texture2D image = Mod.Assets.Request("Projectiles/Pets/PrinceSlimeProj_Glowmask").Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - Vector2 stupidOffset = new Vector2(0f, Projectile.gfxOffY - DrawOriginOffsetY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f + DrawOriginOffsetY); - Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; - - drawColor.A = 255; - - Main.EntitySpriteDraw(image, drawPos, bounds, drawColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); - } - } + [Content(ContentType.DroppedPets)] + //check this file for more info vvvvvvvv + public class PrinceSlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Prince Slime"); + } + + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; + + Projectile.minion = false; + } + + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.PrinceSlime = false; + } + if (modPlayer.PrinceSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + + public override void PostDraw(Color drawColor) + { + Texture2D image = Mod.Assets.Request("Projectiles/Pets/PrinceSlimeProj_Glowmask").Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + Vector2 stupidOffset = new Vector2(0f, Projectile.gfxOffY - DrawOriginOffsetY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f + DrawOriginOffsetY); + Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; + + drawColor.A = 255; + + Main.EntitySpriteDraw(image, drawPos, bounds, drawColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); + } + } } diff --git a/Projectiles/Pets/QueenLarvaProj.cs b/Projectiles/Pets/QueenLarvaProj.cs index 2888fab7..be6b91a0 100644 --- a/Projectiles/Pets/QueenLarvaProj.cs +++ b/Projectiles/Pets/QueenLarvaProj.cs @@ -8,69 +8,69 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class QueenLarvaProj : SimplePetProjBase - { - private int sincounter; + [Content(ContentType.DroppedPets)] + public class QueenLarvaProj : SimplePetProjBase + { + private int sincounter; - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/QueenLarvaProj_0"; //temp - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/QueenLarvaProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Queen Bee Larva"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Queen Bee Larva"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 28; - Projectile.height = 34; - Projectile.alpha = 0; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 28; + Projectile.height = 34; + Projectile.alpha = 0; + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/QueenLarvaProj_" + mPlayer.queenLarvaType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/QueenLarvaProj_" + mPlayer.queenLarvaType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - float sinY = (float)((Math.Sin((sincounter / 150f) * MathHelper.TwoPi) - 1) * 2); + float sinY = (float)((Math.Sin((sincounter / 150f) * MathHelper.TwoPi) - 1) * 2); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 20f) + sinY); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 stupidOffset = new Vector2(Projectile.width / 2, (Projectile.height - 20f) + sinY); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, 0f, bounds.Size() / 2, 1f, SpriteEffects.None, 0); - return false; - } + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, 0f, bounds.Size() / 2, 1f, SpriteEffects.None, 0); + return false; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); - sincounter = sincounter > 150 ? 0 : sincounter + 1; + sincounter = sincounter > 150 ? 0 : sincounter + 1; - if (player.dead) - { - modPlayer.QueenLarva = false; - } - if (modPlayer.QueenLarva) - { - Projectile.timeLeft = 2; + if (player.dead) + { + modPlayer.QueenLarva = false; + } + if (modPlayer.QueenLarva) + { + Projectile.timeLeft = 2; - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, offsetX: 16f, offsetY: 10f); + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, offsetX: 16f, offsetY: 10f); - AssAI.FlickerwickPetDraw(Projectile, frameCounterMaxFar: 4, frameCounterMaxClose: 10); - } - } - } + AssAI.FlickerwickPetDraw(Projectile, frameCounterMaxFar: 4, frameCounterMaxClose: 10); + } + } + } } diff --git a/Projectiles/Pets/RainbowSlimeProj.cs b/Projectiles/Pets/RainbowSlimeProj.cs index dff9a07e..83f090c3 100644 --- a/Projectiles/Pets/RainbowSlimeProj.cs +++ b/Projectiles/Pets/RainbowSlimeProj.cs @@ -2,58 +2,57 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - //check this file for more info vvvvvvvv - public class RainbowSlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Rainbow Slime"); - } - - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; - - Projectile.minion = false; - } - - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.RainbowSlime = false; - } - if (modPlayer.RainbowSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - - public override bool PreDraw(ref Color drawColor) - { - Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(0f, Projectile.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f + Projectile.gfxOffY); - Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; - - double cX = Projectile.Center.X + DrawOffsetX; - double cY = Projectile.Center.Y + DrawOriginOffsetY; - drawColor = Lighting.GetColor((int)(cX / 16), (int)(cY / 16), Main.DiscoColor * 1.2f); - - Color color = drawColor * ((255 - Projectile.alpha) / 255f); - - Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); - return false; - } - } + [Content(ContentType.DroppedPets)] + //check this file for more info vvvvvvvv + public class RainbowSlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Rainbow Slime"); + } + + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; + + Projectile.minion = false; + } + + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.RainbowSlime = false; + } + if (modPlayer.RainbowSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + + public override bool PreDraw(ref Color drawColor) + { + Texture2D image = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Vector2 stupidOffset = new Vector2(0f, Projectile.gfxOffY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f + Projectile.gfxOffY); + Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; + + double cX = Projectile.Center.X + DrawOffsetX; + double cY = Projectile.Center.Y + DrawOriginOffsetY; + drawColor = Lighting.GetColor((int)(cX / 16), (int)(cY / 16), Main.DiscoColor * 1.2f); + + Color color = drawColor * ((255 - Projectile.alpha) / 255f); + + Main.EntitySpriteDraw(image, drawPos, bounds, color, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effect, 0); + return false; + } + } } diff --git a/Projectiles/Pets/SimplePetProjBase.cs b/Projectiles/Pets/SimplePetProjBase.cs index 889ca706..4ff274ab 100644 --- a/Projectiles/Pets/SimplePetProjBase.cs +++ b/Projectiles/Pets/SimplePetProjBase.cs @@ -1,8 +1,8 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.OtherPets)] - public abstract class SimplePetProjBase : AssProjectile - { + [Content(ContentType.OtherPets)] + public abstract class SimplePetProjBase : AssProjectile + { - } + } } diff --git a/Projectiles/Pets/SkeletronHandProj.cs b/Projectiles/Pets/SkeletronHandProj.cs index 2aa0dae7..bfec2a2b 100644 --- a/Projectiles/Pets/SkeletronHandProj.cs +++ b/Projectiles/Pets/SkeletronHandProj.cs @@ -7,75 +7,75 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class SkeletronHandProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/SkeletronHandProj_0"; //temp - } - } + [Content(ContentType.DroppedPets)] + public class SkeletronHandProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/SkeletronHandProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Skeletron Pet Hand"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - DrawOriginOffsetY = -8; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Skeletron Pet Hand"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + DrawOriginOffsetY = -8; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - AIType = ProjectileID.BabyEater; - Projectile.aiStyle = -1; - Projectile.width = 24; - Projectile.height = 32; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + AIType = ProjectileID.BabyEater; + Projectile.aiStyle = -1; + Projectile.width = 24; + Projectile.height = 32; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.SkeletronHand = false; - } - if (modPlayer.SkeletronHand) - { - Projectile.timeLeft = 2; - } - AssAI.BabyEaterAI(Projectile, sway: 0.8f); - AssAI.BabyEaterDraw(Projectile); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.SkeletronHand = false; + } + if (modPlayer.SkeletronHand) + { + Projectile.timeLeft = 2; + } + AssAI.BabyEaterAI(Projectile, sway: 0.8f); + AssAI.BabyEaterDraw(Projectile); + } - public override void PostAI() - { - Projectile.rotation = Projectile.velocity.X * -0.08f; - //projectile.rotation = projectile.velocity.ToRotation() + 1.57f; - } + public override void PostAI() + { + Projectile.rotation = Projectile.velocity.X * -0.08f; + //projectile.rotation = projectile.velocity.ToRotation() + 1.57f; + } - public override bool PreDraw(ref Color lightColor) - { - Player player = Projectile.GetOwner(); - AssUtils.DrawSkeletronLikeArms("AssortedCrazyThings/Projectiles/Pets/SkeletronHand_Arm", Projectile.Center, player.Center + new Vector2(0, player.gfxOffY), selfPad: Projectile.height / 2, centerPad: -20f, direction: 0); + public override bool PreDraw(ref Color lightColor) + { + Player player = Projectile.GetOwner(); + AssUtils.DrawSkeletronLikeArms("AssortedCrazyThings/Projectiles/Pets/SkeletronHand_Arm", Projectile.Center, player.Center + new Vector2(0, player.gfxOffY), selfPad: Projectile.height / 2, centerPad: -20f, direction: 0); - PetPlayer mPlayer = player.GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/SkeletronHandProj_" + mPlayer.skeletronHandType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + PetPlayer mPlayer = player.GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/SkeletronHandProj_" + mPlayer.skeletronHandType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - drawOrigin.Y += Projectile.height / 2; + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + drawOrigin.Y += Projectile.height / 2; - float betweenX = player.Center.X - Projectile.Center.X; - SpriteEffects effects = betweenX < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + float betweenX = player.Center.X - Projectile.Center.X; + SpriteEffects effects = betweenX < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); - return false; - } - } + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); + return false; + } + } } diff --git a/Projectiles/Pets/SkeletronPrimeHandProj.cs b/Projectiles/Pets/SkeletronPrimeHandProj.cs index 996e9267..2aab741c 100644 --- a/Projectiles/Pets/SkeletronPrimeHandProj.cs +++ b/Projectiles/Pets/SkeletronPrimeHandProj.cs @@ -7,71 +7,71 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class SkeletronPrimeHandProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/SkeletronPrimeHandProj_0"; //temp - } - } + [Content(ContentType.DroppedPets)] + public class SkeletronPrimeHandProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/SkeletronPrimeHandProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Skeletron Prime Pet Hand"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - DrawOriginOffsetY = -8; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Skeletron Prime Pet Hand"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + DrawOriginOffsetY = -8; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - AIType = ProjectileID.BabyEater; - Projectile.aiStyle = -1; - Projectile.width = 24; - Projectile.height = 32; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + AIType = ProjectileID.BabyEater; + Projectile.aiStyle = -1; + Projectile.width = 24; + Projectile.height = 32; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.SkeletronPrimeHand = false; - } - if (modPlayer.SkeletronPrimeHand) - { - Projectile.timeLeft = 2; - } - AssAI.BabyEaterAI(Projectile, sway: 0.8f); - AssAI.BabyEaterDraw(Projectile); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.SkeletronPrimeHand = false; + } + if (modPlayer.SkeletronPrimeHand) + { + Projectile.timeLeft = 2; + } + AssAI.BabyEaterAI(Projectile, sway: 0.8f); + AssAI.BabyEaterDraw(Projectile); + } - public override void PostAI() - { - Projectile.rotation = Projectile.velocity.X * -0.08f; - } + public override void PostAI() + { + Projectile.rotation = Projectile.velocity.X * -0.08f; + } - public override bool PreDraw(ref Color lightColor) - { - Player player = Projectile.GetOwner(); - AssUtils.DrawSkeletronLikeArms("AssortedCrazyThings/Projectiles/Pets/SkeletronPrimeHand_Arm", Projectile.Center, player.Center + new Vector2(0, player.gfxOffY), selfPad: Projectile.height / 2, centerPad: -20f, direction: 0); + public override bool PreDraw(ref Color lightColor) + { + Player player = Projectile.GetOwner(); + AssUtils.DrawSkeletronLikeArms("AssortedCrazyThings/Projectiles/Pets/SkeletronPrimeHand_Arm", Projectile.Center, player.Center + new Vector2(0, player.gfxOffY), selfPad: Projectile.height / 2, centerPad: -20f, direction: 0); - PetPlayer mPlayer = player.GetModPlayer(); - Texture2D image = Mod.Assets.Request("Projectiles/Pets/SkeletronPrimeHandProj_" + mPlayer.skeletronPrimeHandType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + PetPlayer mPlayer = player.GetModPlayer(); + Texture2D image = Mod.Assets.Request("Projectiles/Pets/SkeletronPrimeHandProj_" + mPlayer.skeletronPrimeHandType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; - drawOrigin.Y += Projectile.height / 2; + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; + drawOrigin.Y += Projectile.height / 2; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, SpriteEffects.None, 0); - return false; - } - } + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin, 1f, SpriteEffects.None, 0); + return false; + } + } } diff --git a/Projectiles/Pets/StingSlimeProj.cs b/Projectiles/Pets/StingSlimeProj.cs index 58cf513d..99364ae7 100644 --- a/Projectiles/Pets/StingSlimeProj.cs +++ b/Projectiles/Pets/StingSlimeProj.cs @@ -6,57 +6,57 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs)] - //check this file for more info vvvvvvvv - public class StingSlimeProj : BabySlimeBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/StingSlimeProj_0"; - } - } - - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Sting Slime"); - } - - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; - - Projectile.minion = false; - } - - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.StingSlime = false; - } - if (modPlayer.StingSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/StingSlimeProj_" + mPlayer.stingSlimeType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); - - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - - return false; - } - } + [Content(ContentType.HostileNPCs)] + //check this file for more info vvvvvvvv + public class StingSlimeProj : BabySlimeBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/StingSlimeProj_0"; + } + } + + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Sting Slime"); + } + + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; + + Projectile.minion = false; + } + + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.StingSlime = false; + } + if (modPlayer.StingSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/StingSlimeProj_" + mPlayer.stingSlimeType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); + + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + + return false; + } + } } diff --git a/Projectiles/Pets/StrangeRobotProj.cs b/Projectiles/Pets/StrangeRobotProj.cs index c7efbf10..8d62cfd2 100644 --- a/Projectiles/Pets/StrangeRobotProj.cs +++ b/Projectiles/Pets/StrangeRobotProj.cs @@ -10,230 +10,230 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class StrangeRobotProj : SimplePetProjBase - { - private int frame2Counter = 0; - private int frame2 = 0; - - private int faceFrame = 0; - private int faceFrameCounter = 0; - private const int faceFrameSpeed = 6; - private const int faceFrameCount = 4; - - private int bobbingCounter = 0; - private const int bobbingCounterMax = 2; - private bool bobbing = false; - private const float bobAmonut = 1f; //Code bobbing, 1f is half a terraria pixel - - /// - /// Only has frames - /// - private static Asset faceAsset; - private static Asset fireAsset; - private static Asset rearAsset; - private static Asset frontAsset; - - public override void Load() - { - if (!Main.dedServ) - { - faceAsset = ModContent.Request(Texture + "_Face"); - fireAsset = ModContent.Request(Texture + "_Fire"); - rearAsset = ModContent.Request(Texture + "_RearWheel"); - frontAsset = ModContent.Request(Texture + "_FrontWheel"); - } - } - - public override void Unload() - { - faceAsset = null; - fireAsset = null; - rearAsset = null; - frontAsset = null; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Strange Robot"); - Main.projFrames[Projectile.type] = 5; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyGrinch); - Projectile.width = 32; - Projectile.height = 38; - AIType = ProjectileID.BabyGrinch; - DrawOriginOffsetY = 2; - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = fireAsset.Value; //Use a sprite with all 5 frames - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - Vector2 stupidOffset = new Vector2(0, Projectile.gfxOffY); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(bounds.Width / 2, Projectile.height / 2); - Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; - Vector2 origin = bounds.Size() / 2 - new Vector2(0, DrawOriginOffsetY); //PROPER WAY OF USING DrawOriginOffsetY I THINK - float rotation = Projectile.rotation; - float scale = Projectile.scale; - Color white = Color.White * Projectile.Opacity; - - bool flying = Projectile.frame == 3 || Projectile.frame == 4; - bool jumping = Projectile.frame == 2; - if (flying) - { - //Fire - Main.EntitySpriteDraw(image, drawPos, bounds, white, rotation, origin, scale, effects, 0); - } - - //Rear - image = rearAsset.Value; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, rotation, origin, scale, effects, 0); - - //Body - image = TextureAssets.Projectile[Type].Value; - Vector2 bodyDrawPos = drawPos; - if (!flying) - { - bodyDrawPos.Y += bobbing ? -bobAmonut : 0f; - } - Main.EntitySpriteDraw(image, bodyDrawPos, bounds, lightColor, rotation, origin, scale, effects, 0); - - //Front - image = frontAsset.Value; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, rotation, origin, scale, effects, 0); - - //Face - image = faceAsset.Value; - Rectangle faceBounds = bounds; - faceBounds.Y = faceBounds.Height * faceFrame; - if (flying || jumping) - { - faceBounds.Y += 2; - } - - Main.EntitySpriteDraw(image, bodyDrawPos, faceBounds, white, rotation, origin, scale, effects, 0); - - return false; - } - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.grinch = false; // Relic from AIType - - GetFrame(); - - return true; - } - - public bool InAir => Projectile.ai[0] != 0f; - - private void GetFrame() - { - faceFrameCounter++; - if (faceFrameCounter >= faceFrameSpeed) - { - faceFrameCounter = 0; - faceFrame++; - if (faceFrame >= faceFrameCount) - { - faceFrame = 0; - } - } - - if (!InAir) //not flying - { - if (Projectile.velocity.Y == 0f) - { - float xAbs = Math.Abs(Projectile.velocity.X); - if (Projectile.velocity.X == 0f) - { - frame2 = 0; - frame2Counter = 0; - } - else if (xAbs > 0.5f) - { - frame2Counter += Math.Min((int)xAbs, 2); - frame2Counter++; - if (frame2Counter > 12) //6 - { - bobbingCounter++; - if (bobbingCounter >= bobbingCounterMax) - { - bobbingCounter = 0; - bobbing = !bobbing; - } - frame2++; - frame2Counter = 0; - } - if (frame2 > 1) //frame 0 to 1 is running - { - frame2 = 0; - } - } - else - { - frame2 = 0; //frame 0 is idle - frame2Counter = 6; - } - } - else if (Projectile.velocity.Y != 0f) - { - frame2 = 2; //frame 2 is jumping - frame2Counter = 0; - } - } - else //flying - { - frame2Counter++; - if (frame2Counter > 6) //6 - { - frame2++; - frame2Counter = 0; - } - - if (frame2 < 3 || frame2 > 4) //frame 3 to 4 are flying - { - frame2 = 3; - } - - Projectile.rotation = Projectile.velocity.X * 0.04f; - - //Propulsion dust - float dustChance = Math.Clamp(Math.Abs(Projectile.velocity.Length()) / 5f, 0.3f, 0.9f); - if (Main.rand.NextFloat() < dustChance) - { - Vector2 dustOrigin = Projectile.Center + Vector2.UnitY.RotatedBy(Projectile.rotation) * 12; - Dust dust = Dust.NewDustDirect(dustOrigin - Vector2.One * 4f, 8, 8, DustID.Torch, -Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f + 5f, 50, default(Color), 1.7f); - dust.noLightEmittence = true; - dust.velocity.X *= 0.2f; - dust.noGravity = true; - } - } - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.StrangeRobot = false; - } - if (modPlayer.StrangeRobot) - { - Projectile.timeLeft = 2; - } - } - - public override void PostAI() - { - Projectile.frame = frame2; - } - } + public class StrangeRobotProj : SimplePetProjBase + { + private int frame2Counter = 0; + private int frame2 = 0; + + private int faceFrame = 0; + private int faceFrameCounter = 0; + private const int faceFrameSpeed = 6; + private const int faceFrameCount = 4; + + private int bobbingCounter = 0; + private const int bobbingCounterMax = 2; + private bool bobbing = false; + private const float bobAmonut = 1f; //Code bobbing, 1f is half a terraria pixel + + /// + /// Only has frames + /// + private static Asset faceAsset; + private static Asset fireAsset; + private static Asset rearAsset; + private static Asset frontAsset; + + public override void Load() + { + if (!Main.dedServ) + { + faceAsset = ModContent.Request(Texture + "_Face"); + fireAsset = ModContent.Request(Texture + "_Fire"); + rearAsset = ModContent.Request(Texture + "_RearWheel"); + frontAsset = ModContent.Request(Texture + "_FrontWheel"); + } + } + + public override void Unload() + { + faceAsset = null; + fireAsset = null; + rearAsset = null; + frontAsset = null; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Strange Robot"); + Main.projFrames[Projectile.type] = 5; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyGrinch); + Projectile.width = 32; + Projectile.height = 38; + AIType = ProjectileID.BabyGrinch; + DrawOriginOffsetY = 2; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = fireAsset.Value; //Use a sprite with all 5 frames + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + Vector2 stupidOffset = new Vector2(0, Projectile.gfxOffY); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(bounds.Width / 2, Projectile.height / 2); + Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; + Vector2 origin = bounds.Size() / 2 - new Vector2(0, DrawOriginOffsetY); //PROPER WAY OF USING DrawOriginOffsetY I THINK + float rotation = Projectile.rotation; + float scale = Projectile.scale; + Color white = Color.White * Projectile.Opacity; + + bool flying = Projectile.frame == 3 || Projectile.frame == 4; + bool jumping = Projectile.frame == 2; + if (flying) + { + //Fire + Main.EntitySpriteDraw(image, drawPos, bounds, white, rotation, origin, scale, effects, 0); + } + + //Rear + image = rearAsset.Value; + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, rotation, origin, scale, effects, 0); + + //Body + image = TextureAssets.Projectile[Type].Value; + Vector2 bodyDrawPos = drawPos; + if (!flying) + { + bodyDrawPos.Y += bobbing ? -bobAmonut : 0f; + } + Main.EntitySpriteDraw(image, bodyDrawPos, bounds, lightColor, rotation, origin, scale, effects, 0); + + //Front + image = frontAsset.Value; + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, rotation, origin, scale, effects, 0); + + //Face + image = faceAsset.Value; + Rectangle faceBounds = bounds; + faceBounds.Y = faceBounds.Height * faceFrame; + if (flying || jumping) + { + faceBounds.Y += 2; + } + + Main.EntitySpriteDraw(image, bodyDrawPos, faceBounds, white, rotation, origin, scale, effects, 0); + + return false; + } + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.grinch = false; // Relic from AIType + + GetFrame(); + + return true; + } + + public bool InAir => Projectile.ai[0] != 0f; + + private void GetFrame() + { + faceFrameCounter++; + if (faceFrameCounter >= faceFrameSpeed) + { + faceFrameCounter = 0; + faceFrame++; + if (faceFrame >= faceFrameCount) + { + faceFrame = 0; + } + } + + if (!InAir) //not flying + { + if (Projectile.velocity.Y == 0f) + { + float xAbs = Math.Abs(Projectile.velocity.X); + if (Projectile.velocity.X == 0f) + { + frame2 = 0; + frame2Counter = 0; + } + else if (xAbs > 0.5f) + { + frame2Counter += Math.Min((int)xAbs, 2); + frame2Counter++; + if (frame2Counter > 12) //6 + { + bobbingCounter++; + if (bobbingCounter >= bobbingCounterMax) + { + bobbingCounter = 0; + bobbing = !bobbing; + } + frame2++; + frame2Counter = 0; + } + if (frame2 > 1) //frame 0 to 1 is running + { + frame2 = 0; + } + } + else + { + frame2 = 0; //frame 0 is idle + frame2Counter = 6; + } + } + else if (Projectile.velocity.Y != 0f) + { + frame2 = 2; //frame 2 is jumping + frame2Counter = 0; + } + } + else //flying + { + frame2Counter++; + if (frame2Counter > 6) //6 + { + frame2++; + frame2Counter = 0; + } + + if (frame2 < 3 || frame2 > 4) //frame 3 to 4 are flying + { + frame2 = 3; + } + + Projectile.rotation = Projectile.velocity.X * 0.04f; + + //Propulsion dust + float dustChance = Math.Clamp(Math.Abs(Projectile.velocity.Length()) / 5f, 0.3f, 0.9f); + if (Main.rand.NextFloat() < dustChance) + { + Vector2 dustOrigin = Projectile.Center + Vector2.UnitY.RotatedBy(Projectile.rotation) * 12; + Dust dust = Dust.NewDustDirect(dustOrigin - Vector2.One * 4f, 8, 8, DustID.Torch, -Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f + 5f, 50, default(Color), 1.7f); + dust.noLightEmittence = true; + dust.velocity.X *= 0.2f; + dust.noGravity = true; + } + } + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.StrangeRobot = false; + } + if (modPlayer.StrangeRobot) + { + Projectile.timeLeft = 2; + } + } + + public override void PostAI() + { + Projectile.frame = frame2; + } + } } diff --git a/Projectiles/Pets/SuspiciousNuggetProj.cs b/Projectiles/Pets/SuspiciousNuggetProj.cs index 3d7c20b5..10a5920c 100644 --- a/Projectiles/Pets/SuspiciousNuggetProj.cs +++ b/Projectiles/Pets/SuspiciousNuggetProj.cs @@ -2,109 +2,108 @@ using System; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class SuspiciousNuggetProj : SimplePetProjBase - { - private int frame2Counter = 0; - private int frame2 = 0; - private float rot2 = 0; + public class SuspiciousNuggetProj : SimplePetProjBase + { + private int frame2Counter = 0; + private int frame2 = 0; + private float rot2 = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Suspicious Nugget"); - Main.projFrames[Projectile.type] = 8; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Suspicious Nugget"); + Main.projFrames[Projectile.type] = 8; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyGrinch); - Projectile.width = 22; - Projectile.height = 22; - AIType = ProjectileID.BabyRedPanda; - DrawOriginOffsetY = -4; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyGrinch); + Projectile.width = 22; + Projectile.height = 22; + AIType = ProjectileID.BabyRedPanda; + DrawOriginOffsetY = -4; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.grinch = false; // Relic from AIType + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.grinch = false; // Relic from AIType - GetFrame(); + GetFrame(); - return true; - } + return true; + } - public bool InAir => Projectile.ai[0] != 0f; + public bool InAir => Projectile.ai[0] != 0f; - private void GetFrame() - { - if (!InAir) //not flying - { - rot2 = 0; - if (Projectile.velocity.Y == 0f) - { - float xAbs = Math.Abs(Projectile.velocity.X); - if (Projectile.velocity.X == 0f) - { - frame2 = 0; - frame2Counter = 0; - } - else if (xAbs > 0.5f) - { - frame2Counter += (int)xAbs; - frame2Counter++; - if (frame2Counter > 12) //6 - { - frame2++; - frame2Counter = 0; - } - if (frame2 > 6) //frame 1 to 6 is running - { - frame2 = 1; - } - } - else - { - frame2 = 0; //frame 0 is idle - frame2Counter = 6; - } - } - else if (Projectile.velocity.Y != 0f) - { - frame2Counter = 0; - frame2 = 4; //frame 4 is jumping - } - } - else //flying - { - rot2 += -Projectile.spriteDirection * 0.1f; - frame2Counter = 0; - frame2 = 7; //frame 7 is flying - } - } + private void GetFrame() + { + if (!InAir) //not flying + { + rot2 = 0; + if (Projectile.velocity.Y == 0f) + { + float xAbs = Math.Abs(Projectile.velocity.X); + if (Projectile.velocity.X == 0f) + { + frame2 = 0; + frame2Counter = 0; + } + else if (xAbs > 0.5f) + { + frame2Counter += (int)xAbs; + frame2Counter++; + if (frame2Counter > 12) //6 + { + frame2++; + frame2Counter = 0; + } + if (frame2 > 6) //frame 1 to 6 is running + { + frame2 = 1; + } + } + else + { + frame2 = 0; //frame 0 is idle + frame2Counter = 6; + } + } + else if (Projectile.velocity.Y != 0f) + { + frame2Counter = 0; + frame2 = 4; //frame 4 is jumping + } + } + else //flying + { + rot2 += -Projectile.spriteDirection * 0.1f; + frame2Counter = 0; + frame2 = 7; //frame 7 is flying + } + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.SuspiciousNugget = false; - } - if (modPlayer.SuspiciousNugget) - { - Projectile.timeLeft = 2; - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.SuspiciousNugget = false; + } + if (modPlayer.SuspiciousNugget) + { + Projectile.timeLeft = 2; + } + } - public override void PostAI() - { - Projectile.frame = frame2; - Projectile.rotation = rot2; - } - } + public override void PostAI() + { + Projectile.frame = frame2; + Projectile.rotation = rot2; + } + } } diff --git a/Projectiles/Pets/SwarmofCthulhuProj.cs b/Projectiles/Pets/SwarmofCthulhuProj.cs index 982e7ad9..0ee77da7 100644 --- a/Projectiles/Pets/SwarmofCthulhuProj.cs +++ b/Projectiles/Pets/SwarmofCthulhuProj.cs @@ -1,43 +1,42 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class SwarmofCthulhuProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Swarm of Cthulhu"); - Main.projFrames[Projectile.type] = 1; //Dummy - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.DroppedPets)] + public class SwarmofCthulhuProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Swarm of Cthulhu"); + Main.projFrames[Projectile.type] = 1; //Dummy + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - Projectile.alpha = 255; - Projectile.hide = true; - Projectile.aiStyle = -1; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + Projectile.alpha = 255; + Projectile.hide = true; + Projectile.aiStyle = -1; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.SwarmofCthulhu = false; - } - if (modPlayer.SwarmofCthulhu) - { - Projectile.timeLeft = 2; - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.SwarmofCthulhu = false; + } + if (modPlayer.SwarmofCthulhu) + { + Projectile.timeLeft = 2; + } - Projectile.Center = player.Center; - Projectile.gfxOffY = player.gfxOffY; - } - } + Projectile.Center = player.Center; + Projectile.gfxOffY = player.gfxOffY; + } + } } diff --git a/Projectiles/Pets/TinyTwinsProj.cs b/Projectiles/Pets/TinyTwinsProj.cs index c26ff18b..e6946b13 100644 --- a/Projectiles/Pets/TinyTwinsProj.cs +++ b/Projectiles/Pets/TinyTwinsProj.cs @@ -6,122 +6,122 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class TinySpazmatismProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tiny Spazmatism"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - DrawOriginOffsetY = -10; - } + [Content(ContentType.DroppedPets)] + public class TinySpazmatismProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tiny Spazmatism"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + DrawOriginOffsetY = -10; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - Projectile.aiStyle = -1; - //AIType = ProjectileID.BabyEater; - Projectile.width = 30; - Projectile.height = 30; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + Projectile.aiStyle = -1; + //AIType = ProjectileID.BabyEater; + Projectile.width = 30; + Projectile.height = 30; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.eater = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.eater = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.TinyTwins = false; - } - if (modPlayer.TinyTwins) - { - Projectile.timeLeft = 2; - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.TinyTwins = false; + } + if (modPlayer.TinyTwins) + { + Projectile.timeLeft = 2; + } - AssAI.BabyEaterAI(Projectile, velocityFactor: 1.5f, sway: 0.5f); - AssAI.BabyEaterDraw(Projectile); + AssAI.BabyEaterAI(Projectile, velocityFactor: 1.5f, sway: 0.5f); + AssAI.BabyEaterDraw(Projectile); - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile projectile = Main.projectile[i]; - if (projectile.active && Projectile.owner == projectile.owner && projectile.type == ModContent.ProjectileType()) - { - AssUtils.DrawTether("AssortedCrazyThings/Projectiles/Pets/TinyTwinsProj_Chain", Projectile.Center, projectile.Center); - break; - } - } - return true; - } + public override bool PreDraw(ref Color lightColor) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile projectile = Main.projectile[i]; + if (projectile.active && Projectile.owner == projectile.owner && projectile.type == ModContent.ProjectileType()) + { + AssUtils.DrawTether("AssortedCrazyThings/Projectiles/Pets/TinyTwinsProj_Chain", Projectile.Center, projectile.Center); + break; + } + } + return true; + } - public override void PostAI() - { - Vector2 between = Projectile.Center - Projectile.GetOwner().Center; - Projectile.rotation = between.ToRotation() + 1.57f; - Projectile.spriteDirection = Projectile.direction = -(between.X < 0).ToDirectionInt(); - } - } + public override void PostAI() + { + Vector2 between = Projectile.Center - Projectile.GetOwner().Center; + Projectile.rotation = between.ToRotation() + 1.57f; + Projectile.spriteDirection = Projectile.direction = -(between.X < 0).ToDirectionInt(); + } + } - [Content(ContentType.DroppedPets)] - public class TinyRetinazerProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tiny Retinazer"); - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - DrawOriginOffsetY = -10; - } + [Content(ContentType.DroppedPets)] + public class TinyRetinazerProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tiny Retinazer"); + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + DrawOriginOffsetY = -10; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - Projectile.width = 30; - Projectile.height = 30; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + Projectile.width = 30; + Projectile.height = 30; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.TinyTwins = false; - } - if (modPlayer.TinyTwins) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.TinyTwins = false; + } + if (modPlayer.TinyTwins) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override void PostAI() - { - if (Projectile.frame > 1) Projectile.frame = 0; + public override void PostAI() + { + if (Projectile.frame > 1) Projectile.frame = 0; - Vector2 between = Projectile.Center - Projectile.GetOwner().Center; - Projectile.rotation = between.ToRotation() + 1.57f; - Projectile.spriteDirection = Projectile.direction = -(between.X < 0).ToDirectionInt(); - } - } + Vector2 between = Projectile.Center - Projectile.GetOwner().Center; + Projectile.rotation = between.ToRotation() + 1.57f; + Projectile.spriteDirection = Projectile.direction = -(between.X < 0).ToDirectionInt(); + } + } } diff --git a/Projectiles/Pets/TorchGodLightPetProj.cs b/Projectiles/Pets/TorchGodLightPetProj.cs index 12eec4f9..93c5025d 100644 --- a/Projectiles/Pets/TorchGodLightPetProj.cs +++ b/Projectiles/Pets/TorchGodLightPetProj.cs @@ -13,364 +13,364 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class TorchGodLightPetProj : SimplePetProjBase - { - private static Asset flameAsset; - - public const int itemFlameCountMax = 5; - public int itemFlameCount = itemFlameCountMax; - public Vector2[] itemFlamePos = new Vector2[6]; - public readonly Color flameColor = new Color(75, 75, 75, 0); - - public float rotation2 = 0f; - - private const int yCounterMax = 140; - private int yCounter; //Cos - - private const int rotCounterMax = 140; - private int rotCounter; //Sin - - private const int scanTorchesTimerMax = 20; - private int scanTorchesTimer = 0; - - private bool HasTorchTarget => TorchTarget != Point16.Zero; - - private Point16 TorchTarget - { - get => new Point16((short)Projectile.ai[0], (short)Projectile.ai[1]); - set - { - Projectile.ai[0] = value.X; - Projectile.ai[1] = value.Y; - } - } - - //Needs sync - private bool CanPlaceTorches - { - get => Projectile.localAI[0] == 1f; - set => Projectile.localAI[0] = value ? 1f : 0f; - } - - private void ResetTorchTarget() - { - TorchTarget = Point16.Zero; - Projectile.netUpdate = true; - } - - public override void Load() - { - if (!Main.dedServ) - { - flameAsset = ModContent.Request(Texture + "_Glowmask"); - } - } - - public override void Unload() - { - flameAsset = null; - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Godly Torch"); - Main.projFrames[Projectile.type] = 7; - Main.projPet[Projectile.type] = true; - ProjectileID.Sets.LightPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.DD2PetGhost); - Projectile.aiStyle = -1; - Projectile.width = 12; - Projectile.height = 24; - Projectile.alpha = 0; - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = TextureAssets.Projectile[Type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - float offY = (float)((Math.Cos(((float)yCounter / yCounterMax) * MathHelper.TwoPi) - 1) * 3); - Vector2 stupidOffset = new Vector2(image.Width / 2, Projectile.height / 2 - Projectile.gfxOffY + offY); - Vector2 rotationalOffset = new Vector2(0f, -8f); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset - rotationalOffset; - - Vector2 origin = bounds.Size() / 2 - rotationalOffset; - float rotation = Projectile.rotation; - float scale = Projectile.scale; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, rotation, origin, scale, SpriteEffects.None, 0); - - image = flameAsset.Value; - for (int i = 0; i < itemFlamePos.Length; i++) - { - Vector2 flameDrawPos = drawPos + itemFlamePos[i]; - Main.EntitySpriteDraw(image, flameDrawPos, bounds, flameColor, rotation, origin, scale, SpriteEffects.None, 0); - } - - return false; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write((bool)CanPlaceTorches); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - CanPlaceTorches = reader.ReadBoolean(); - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.TorchGodLightPet = false; - } - if (modPlayer.TorchGodLightPet) - { - Projectile.timeLeft = 2; - - - rotCounter = rotCounter > rotCounterMax ? 0 : rotCounter + 1; - yCounter = yCounter > yCounterMax ? 0 : yCounter + 1; - - SetItemFlamePos(); - - if (CheckAllowPlacingTorches(player)) - { - FindTorchTarget(player); - } - - Lighting.AddLight(Projectile.Center, Color.Lerp(Color.White, Color.OrangeRed, 0.2f).ToVector3()); - - if (HasTorchTarget && player.HasItem(ItemID.Torch)) - { - PlaceTorchAI(player); - } - else - { - //Stay close to player - AssAI.FlickerwickPetAI(Projectile, lightPet: true, lightDust: false, offsetX: 0f, offsetY: 0f); - - rotation2 = (float)((Math.Sin(((float)yCounter / yCounterMax) * MathHelper.TwoPi)) * 0.18f); - Projectile.rotation = rotation2; - } - } - } - - - private bool CheckAllowPlacingTorches(Player player) - { - if (Main.myPlayer == player.whoAmI) - { - CanPlaceTorches = Main.SmartCursorIsUsed; - Projectile.netUpdate = true; - } - - return CanPlaceTorches; - } - - private void SetItemFlamePos() - { - //Copied from vanilla flame draw for player held torches - if (Main.netMode != NetmodeID.Server) - { - itemFlameCount--; - if (itemFlameCount <= 0) - { - itemFlameCount = itemFlameCountMax; - for (int k = 0; k < itemFlamePos.Length; k++) - { - itemFlamePos[k].X = Main.rand.Next(-10, 11) * 0.15f; - itemFlamePos[k].Y = Main.rand.Next(-10, 1) * 0.35f; - } - } - } - } - - private void FindTorchTarget(Player player) - { - if (HasTorchTarget || !CanPlaceTorches) - { - return; - } - - scanTorchesTimer++; - if (scanTorchesTimer >= scanTorchesTimerMax) - { - scanTorchesTimer = 0; - - const int radius = 8; - - int playerX = (int)(player.Center.X / 16); - int playerY = (int)(player.Center.Y / 16); - int rangeMinX = playerX - radius; - int rangeMaxX = playerX + radius; - int rangeMinY = playerY - radius; - int rangeMaxY = playerY + radius; - - //If any torch in radius of player, don't place - for (int i = rangeMinX; i <= rangeMaxX; i++) - { - for (int j = rangeMinY; j <= rangeMaxY; j++) - { - Tile tile = Framing.GetTileSafely(i, j); - if (tile.TileType > 0 && TileID.Sets.Torch[tile.TileType]) - { - return; - } - } - } - - int intendedTorchItem = player.BiomeTorchHoldStyle(ItemID.Torch); - bool notWaterTorch = !ItemID.Sets.WaterTorches[intendedTorchItem]; //Doesn't matter here since input param is default torch - - //Look for tiles to place a torch on - List> targets = new(); - for (int i = rangeMinX; i <= rangeMaxX; i++) - { - for (int j = rangeMinY; j <= rangeMaxY; j++) - { - Tile tile = Framing.GetTileSafely(i, j); - if (tile.HasTile /*&& !TileID.Sets.BreakableWhenPlacing[tile.TileType] && (!Main.tileCut[tile.TileType] || tile.TileType == TileID.ImmatureHerbs || tile.TileType == TileID.MatureHerbs)*/) - { - continue; - } - - Tile tileLeft = Framing.GetTileSafely(i - 1, j); - Tile tileRight = Framing.GetTileSafely(i + 1, j); - Tile tileBottom = Framing.GetTileSafely(i, j + 1); //Does not place ontop of platforms (just like vanilla smart cursor) - - if ((!notWaterTorch || tile.LiquidAmount <= 0) && - (tile.WallType > 0 || - (tileLeft.HasTile && (tileLeft.Slope == 0 || (int)tileLeft.Slope % 2 != 1) && - ( - (Main.tileSolid[tileLeft.TileType] && !Main.tileNoAttach[tileLeft.TileType] && !Main.tileSolidTop[tileLeft.TileType] && !TileID.Sets.NotReallySolid[tileLeft.TileType]) - || TileID.Sets.IsBeam[tileLeft.TileType] || - (WorldGen.IsTreeType(tileLeft.TileType) && WorldGen.IsTreeType(Framing.GetTileSafely(i - 1, j - 1).TileType) && WorldGen.IsTreeType(Framing.GetTileSafely(i - 1, j + 1).TileType)) - ) - ) || - (tileRight.HasTile && (tileRight.Slope == 0 || (int)tileRight.Slope % 2 != 0) && - ( - (Main.tileSolid[tileRight.TileType] && !Main.tileNoAttach[tileRight.TileType] && !Main.tileSolidTop[tileRight.TileType] && !TileID.Sets.NotReallySolid[tileRight.TileType]) - || TileID.Sets.IsBeam[tileRight.TileType] || - (WorldGen.IsTreeType(tileRight.TileType) && WorldGen.IsTreeType(Framing.GetTileSafely(i + 1, j - 1).TileType) && WorldGen.IsTreeType(Framing.GetTileSafely(i + 1, j + 1).TileType)) - ) - ) || - (tileBottom.HasTile && Main.tileSolid[tileBottom.TileType] && !Main.tileNoAttach[tileBottom.TileType] && (!Main.tileSolidTop[tileBottom.TileType] || (TileID.Sets.Platforms[tileBottom.TileType] && tileBottom.Slope == 0)) - && !TileID.Sets.NotReallySolid[tileBottom.TileType] && !tileBottom.IsHalfBlock && tileBottom.Slope == 0) - ) - && !TileID.Sets.Torch[tile.TileType]) - { - targets.Add(new Tuple(i, j)); - } - } - } - - int finalX = -1; - int finalY = -1; - if (targets.Count > 0) - { - float maxDist = -1f; - Tuple finalTuple = targets[0]; - for (int m = 0; m < targets.Count; m++) - { - Tuple tuple = targets[m]; - float dist = Vector2.Distance(new Vector2(tuple.Item1, tuple.Item2) * 16f + Vector2.One * 8f, player.Center); - if (maxDist == -1f || (dist < maxDist && dist > 32)) - { - maxDist = dist; - finalTuple = tuple; - } - } - - if (Collision.InTileBounds(finalTuple.Item1, finalTuple.Item2, rangeMinX, rangeMinY, rangeMaxX, rangeMaxY)) - { - finalX = finalTuple.Item1; - finalY = finalTuple.Item2; - } - } - - if (finalX == -1 || finalY == -1) - { - return; - } - - TorchTarget = new Point16(finalX, finalY); - } - } - - private void PlaceTorchAI(Player player) - { - AssAI.TeleportIfTooFar(Projectile, player.Center); - - Vector2 targetPos = new Vector2(TorchTarget.X, TorchTarget.Y) * 16; - - Vector2 toTargetPos = targetPos - Projectile.Center; - float dist = toTargetPos.Length(); - Vector2 normalized = toTargetPos.SafeNormalize(Vector2.Zero); - - float acc; - float speed; - - if (dist > 200) - { - acc = 3f; - speed = 20f; - } - else if (dist > 64) - { - acc = 5f; - speed = 15f; - } - else - { - acc = 8f; - speed = 6f; - } - - Projectile.velocity = (Projectile.velocity * (acc - 1) + normalized * speed) / acc; - - if (dist < 14f) - { - PlaceTorchAtTarget(player); - } - } - - private void PlaceTorchAtTarget(Player player) - { - if (!HasTorchTarget) - { - return; - } - - if (player.ConsumeItem(ItemID.Torch)) - { - if (Main.myPlayer == player.whoAmI) - { - short x = TorchTarget.X; - short y = TorchTarget.Y; - ushort type = TileID.Torches; - - int placeStyle = 0; - if (player.UsingBiomeTorches) - { - placeStyle = player.BiomeTorchPlaceStyle(placeStyle); - } - - if (WorldGen.PlaceTile(x, y, type, style: placeStyle)) - { - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 1, x, y, type, placeStyle); - } - } - } - - ResetTorchTarget(); - } - } + public class TorchGodLightPetProj : SimplePetProjBase + { + private static Asset flameAsset; + + public const int itemFlameCountMax = 5; + public int itemFlameCount = itemFlameCountMax; + public Vector2[] itemFlamePos = new Vector2[6]; + public readonly Color flameColor = new Color(75, 75, 75, 0); + + public float rotation2 = 0f; + + private const int yCounterMax = 140; + private int yCounter; //Cos + + private const int rotCounterMax = 140; + private int rotCounter; //Sin + + private const int scanTorchesTimerMax = 20; + private int scanTorchesTimer = 0; + + private bool HasTorchTarget => TorchTarget != Point16.Zero; + + private Point16 TorchTarget + { + get => new Point16((short)Projectile.ai[0], (short)Projectile.ai[1]); + set + { + Projectile.ai[0] = value.X; + Projectile.ai[1] = value.Y; + } + } + + //Needs sync + private bool CanPlaceTorches + { + get => Projectile.localAI[0] == 1f; + set => Projectile.localAI[0] = value ? 1f : 0f; + } + + private void ResetTorchTarget() + { + TorchTarget = Point16.Zero; + Projectile.netUpdate = true; + } + + public override void Load() + { + if (!Main.dedServ) + { + flameAsset = ModContent.Request(Texture + "_Glowmask"); + } + } + + public override void Unload() + { + flameAsset = null; + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Godly Torch"); + Main.projFrames[Projectile.type] = 7; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.LightPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.DD2PetGhost); + Projectile.aiStyle = -1; + Projectile.width = 12; + Projectile.height = 24; + Projectile.alpha = 0; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = TextureAssets.Projectile[Type].Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + float offY = (float)((Math.Cos(((float)yCounter / yCounterMax) * MathHelper.TwoPi) - 1) * 3); + Vector2 stupidOffset = new Vector2(image.Width / 2, Projectile.height / 2 - Projectile.gfxOffY + offY); + Vector2 rotationalOffset = new Vector2(0f, -8f); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset - rotationalOffset; + + Vector2 origin = bounds.Size() / 2 - rotationalOffset; + float rotation = Projectile.rotation; + float scale = Projectile.scale; + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, rotation, origin, scale, SpriteEffects.None, 0); + + image = flameAsset.Value; + for (int i = 0; i < itemFlamePos.Length; i++) + { + Vector2 flameDrawPos = drawPos + itemFlamePos[i]; + Main.EntitySpriteDraw(image, flameDrawPos, bounds, flameColor, rotation, origin, scale, SpriteEffects.None, 0); + } + + return false; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write((bool)CanPlaceTorches); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + CanPlaceTorches = reader.ReadBoolean(); + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.TorchGodLightPet = false; + } + if (modPlayer.TorchGodLightPet) + { + Projectile.timeLeft = 2; + + + rotCounter = rotCounter > rotCounterMax ? 0 : rotCounter + 1; + yCounter = yCounter > yCounterMax ? 0 : yCounter + 1; + + SetItemFlamePos(); + + if (CheckAllowPlacingTorches(player)) + { + FindTorchTarget(player); + } + + Lighting.AddLight(Projectile.Center, Color.Lerp(Color.White, Color.OrangeRed, 0.2f).ToVector3()); + + if (HasTorchTarget && player.HasItem(ItemID.Torch)) + { + PlaceTorchAI(player); + } + else + { + //Stay close to player + AssAI.FlickerwickPetAI(Projectile, lightPet: true, lightDust: false, offsetX: 0f, offsetY: 0f); + + rotation2 = (float)((Math.Sin(((float)yCounter / yCounterMax) * MathHelper.TwoPi)) * 0.18f); + Projectile.rotation = rotation2; + } + } + } + + + private bool CheckAllowPlacingTorches(Player player) + { + if (Main.myPlayer == player.whoAmI) + { + CanPlaceTorches = Main.SmartCursorIsUsed; + Projectile.netUpdate = true; + } + + return CanPlaceTorches; + } + + private void SetItemFlamePos() + { + //Copied from vanilla flame draw for player held torches + if (Main.netMode != NetmodeID.Server) + { + itemFlameCount--; + if (itemFlameCount <= 0) + { + itemFlameCount = itemFlameCountMax; + for (int k = 0; k < itemFlamePos.Length; k++) + { + itemFlamePos[k].X = Main.rand.Next(-10, 11) * 0.15f; + itemFlamePos[k].Y = Main.rand.Next(-10, 1) * 0.35f; + } + } + } + } + + private void FindTorchTarget(Player player) + { + if (HasTorchTarget || !CanPlaceTorches) + { + return; + } + + scanTorchesTimer++; + if (scanTorchesTimer >= scanTorchesTimerMax) + { + scanTorchesTimer = 0; + + const int radius = 8; + + int playerX = (int)(player.Center.X / 16); + int playerY = (int)(player.Center.Y / 16); + int rangeMinX = playerX - radius; + int rangeMaxX = playerX + radius; + int rangeMinY = playerY - radius; + int rangeMaxY = playerY + radius; + + //If any torch in radius of player, don't place + for (int i = rangeMinX; i <= rangeMaxX; i++) + { + for (int j = rangeMinY; j <= rangeMaxY; j++) + { + Tile tile = Framing.GetTileSafely(i, j); + if (tile.TileType > 0 && TileID.Sets.Torch[tile.TileType]) + { + return; + } + } + } + + int intendedTorchItem = player.BiomeTorchHoldStyle(ItemID.Torch); + bool notWaterTorch = !ItemID.Sets.WaterTorches[intendedTorchItem]; //Doesn't matter here since input param is default torch + + //Look for tiles to place a torch on + List> targets = new(); + for (int i = rangeMinX; i <= rangeMaxX; i++) + { + for (int j = rangeMinY; j <= rangeMaxY; j++) + { + Tile tile = Framing.GetTileSafely(i, j); + if (tile.HasTile /*&& !TileID.Sets.BreakableWhenPlacing[tile.TileType] && (!Main.tileCut[tile.TileType] || tile.TileType == TileID.ImmatureHerbs || tile.TileType == TileID.MatureHerbs)*/) + { + continue; + } + + Tile tileLeft = Framing.GetTileSafely(i - 1, j); + Tile tileRight = Framing.GetTileSafely(i + 1, j); + Tile tileBottom = Framing.GetTileSafely(i, j + 1); //Does not place ontop of platforms (just like vanilla smart cursor) + + if ((!notWaterTorch || tile.LiquidAmount <= 0) && + (tile.WallType > 0 || + (tileLeft.HasTile && (tileLeft.Slope == 0 || (int)tileLeft.Slope % 2 != 1) && + ( + (Main.tileSolid[tileLeft.TileType] && !Main.tileNoAttach[tileLeft.TileType] && !Main.tileSolidTop[tileLeft.TileType] && !TileID.Sets.NotReallySolid[tileLeft.TileType]) + || TileID.Sets.IsBeam[tileLeft.TileType] || + (WorldGen.IsTreeType(tileLeft.TileType) && WorldGen.IsTreeType(Framing.GetTileSafely(i - 1, j - 1).TileType) && WorldGen.IsTreeType(Framing.GetTileSafely(i - 1, j + 1).TileType)) + ) + ) || + (tileRight.HasTile && (tileRight.Slope == 0 || (int)tileRight.Slope % 2 != 0) && + ( + (Main.tileSolid[tileRight.TileType] && !Main.tileNoAttach[tileRight.TileType] && !Main.tileSolidTop[tileRight.TileType] && !TileID.Sets.NotReallySolid[tileRight.TileType]) + || TileID.Sets.IsBeam[tileRight.TileType] || + (WorldGen.IsTreeType(tileRight.TileType) && WorldGen.IsTreeType(Framing.GetTileSafely(i + 1, j - 1).TileType) && WorldGen.IsTreeType(Framing.GetTileSafely(i + 1, j + 1).TileType)) + ) + ) || + (tileBottom.HasTile && Main.tileSolid[tileBottom.TileType] && !Main.tileNoAttach[tileBottom.TileType] && (!Main.tileSolidTop[tileBottom.TileType] || (TileID.Sets.Platforms[tileBottom.TileType] && tileBottom.Slope == 0)) + && !TileID.Sets.NotReallySolid[tileBottom.TileType] && !tileBottom.IsHalfBlock && tileBottom.Slope == 0) + ) + && !TileID.Sets.Torch[tile.TileType]) + { + targets.Add(new Tuple(i, j)); + } + } + } + + int finalX = -1; + int finalY = -1; + if (targets.Count > 0) + { + float maxDist = -1f; + Tuple finalTuple = targets[0]; + for (int m = 0; m < targets.Count; m++) + { + Tuple tuple = targets[m]; + float dist = Vector2.Distance(new Vector2(tuple.Item1, tuple.Item2) * 16f + Vector2.One * 8f, player.Center); + if (maxDist == -1f || (dist < maxDist && dist > 32)) + { + maxDist = dist; + finalTuple = tuple; + } + } + + if (Collision.InTileBounds(finalTuple.Item1, finalTuple.Item2, rangeMinX, rangeMinY, rangeMaxX, rangeMaxY)) + { + finalX = finalTuple.Item1; + finalY = finalTuple.Item2; + } + } + + if (finalX == -1 || finalY == -1) + { + return; + } + + TorchTarget = new Point16(finalX, finalY); + } + } + + private void PlaceTorchAI(Player player) + { + AssAI.TeleportIfTooFar(Projectile, player.Center); + + Vector2 targetPos = new Vector2(TorchTarget.X, TorchTarget.Y) * 16; + + Vector2 toTargetPos = targetPos - Projectile.Center; + float dist = toTargetPos.Length(); + Vector2 normalized = toTargetPos.SafeNormalize(Vector2.Zero); + + float acc; + float speed; + + if (dist > 200) + { + acc = 3f; + speed = 20f; + } + else if (dist > 64) + { + acc = 5f; + speed = 15f; + } + else + { + acc = 8f; + speed = 6f; + } + + Projectile.velocity = (Projectile.velocity * (acc - 1) + normalized * speed) / acc; + + if (dist < 14f) + { + PlaceTorchAtTarget(player); + } + } + + private void PlaceTorchAtTarget(Player player) + { + if (!HasTorchTarget) + { + return; + } + + if (player.ConsumeItem(ItemID.Torch)) + { + if (Main.myPlayer == player.whoAmI) + { + short x = TorchTarget.X; + short y = TorchTarget.Y; + ushort type = TileID.Torches; + + int placeStyle = 0; + if (player.UsingBiomeTorches) + { + placeStyle = player.BiomeTorchPlaceStyle(placeStyle); + } + + if (WorldGen.PlaceTile(x, y, type, style: placeStyle)) + { + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 1, x, y, type, placeStyle); + } + } + } + + ResetTorchTarget(); + } + } } diff --git a/Projectiles/Pets/TorturedSoulProj.cs b/Projectiles/Pets/TorturedSoulProj.cs index 87daed7d..0680b58b 100644 --- a/Projectiles/Pets/TorturedSoulProj.cs +++ b/Projectiles/Pets/TorturedSoulProj.cs @@ -1,45 +1,44 @@ using AssortedCrazyThings.Base; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Pets { - public class TorturedSoulProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tortured Soul"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public class TorturedSoulProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tortured Soul"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.TorturedSoul = false; - } - if (modPlayer.TorturedSoul) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.TorturedSoul = false; + } + if (modPlayer.TorturedSoul) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } + } } diff --git a/Projectiles/Pets/TrueObservingEyeProj.cs b/Projectiles/Pets/TrueObservingEyeProj.cs index 33deca75..57182c0c 100644 --- a/Projectiles/Pets/TrueObservingEyeProj.cs +++ b/Projectiles/Pets/TrueObservingEyeProj.cs @@ -8,74 +8,74 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public class TrueObservingEyeProj : SimplePetProjBase - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("True Observing Eye"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.DroppedPets)] + public class TrueObservingEyeProj : SimplePetProjBase + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("True Observing Eye"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - Projectile.aiStyle = -1; - Projectile.width = 12; - Projectile.height = 12; - Projectile.tileCollide = false; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + Projectile.aiStyle = -1; + Projectile.width = 12; + Projectile.height = 12; + Projectile.tileCollide = false; + } - public override bool PreDraw(ref Color lightColor) - { - Texture2D image = TextureAssets.Projectile[Projectile.type].Value; + public override bool PreDraw(ref Color lightColor) + { + Texture2D image = TextureAssets.Projectile[Projectile.type].Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 eyeCenter = new Vector2(0f, 12f); + Vector2 eyeCenter = new Vector2(0f, 12f); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2); - Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; - Vector2 drawOrigin = bounds.Size() / 2; + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2); + Vector2 drawPos = Projectile.position - Main.screenPosition + stupidOffset; + Vector2 drawOrigin = bounds.Size() / 2; - Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin - eyeCenter, 1f, effects, 0); + Main.EntitySpriteDraw(image, drawPos, bounds, lightColor, Projectile.rotation, drawOrigin - eyeCenter, 1f, effects, 0); - //Draw Eye + //Draw Eye - image = ModContent.Request(Texture + "_Eye").Value; + image = ModContent.Request(Texture + "_Eye").Value; - Vector2 between = Projectile.GetOwner().Center - (Projectile.position + stupidOffset); - //between.Length(): 94 is "idle", 200 is very fast following - //28.5f = 200f / 7f - float magnitude = Utils.Clamp(between.Length() / 28.5f, 1.3f, 7f); + Vector2 between = Projectile.GetOwner().Center - (Projectile.position + stupidOffset); + //between.Length(): 94 is "idle", 200 is very fast following + //28.5f = 200f / 7f + float magnitude = Utils.Clamp(between.Length() / 28.5f, 1.3f, 7f); - between.Normalize(); - between *= magnitude; + between.Normalize(); + between *= magnitude; - drawPos += between; - drawOrigin = image.Bounds.Size() / 2; - Main.EntitySpriteDraw(image, drawPos, image.Bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); + drawPos += between; + drawOrigin = image.Bounds.Size() / 2; + Main.EntitySpriteDraw(image, drawPos, image.Bounds, lightColor, Projectile.rotation, drawOrigin, 1f, effects, 0); - return false; - } + return false; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.TrueObservingEye = false; - } - if (modPlayer.TrueObservingEye) - { - Projectile.timeLeft = 2; - } - AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, veloSpeed: 0.5f, offsetX: 20f, offsetY: -60f); - AssAI.FlickerwickPetDraw(Projectile, 6, 8); - } - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.TrueObservingEye = false; + } + if (modPlayer.TrueObservingEye) + { + Projectile.timeLeft = 2; + } + AssAI.FlickerwickPetAI(Projectile, lightPet: false, lightDust: false, reverseSide: true, veloSpeed: 0.5f, offsetX: 20f, offsetY: -60f); + AssAI.FlickerwickPetDraw(Projectile, 6, 8); + } + } } diff --git a/Projectiles/Pets/TurtleSlimeProj.cs b/Projectiles/Pets/TurtleSlimeProj.cs index a193d193..56e30223 100644 --- a/Projectiles/Pets/TurtleSlimeProj.cs +++ b/Projectiles/Pets/TurtleSlimeProj.cs @@ -6,55 +6,55 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.HostileNPCs)] - //check this file for more info vvvvvvvv - public class TurtleSlimeProj : BabySlimeBase - { - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Turtle Slime"); - } - - public override void SafeSetDefaults() - { - Projectile.width = 32; - Projectile.height = 30; - - Projectile.minion = false; - } - - public override bool PreAI() - { - PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); - if (Projectile.GetOwner().dead) - { - modPlayer.TurtleSlime = false; - } - if (modPlayer.TurtleSlime) - { - Projectile.timeLeft = 2; - } - return true; - } - - public override void PostDraw(Color drawColor) - { - Texture2D image = Mod.Assets.Request("Projectiles/Pets/TurtleSlimeProj_Glowmask").Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - Vector2 stupidOffset = new Vector2(0, Projectile.gfxOffY - DrawOriginOffsetY); //gfxoffY is for when the npc is on a slope or half brick - SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f + DrawOriginOffsetY); - Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; - - Color fullColor = drawColor; - fullColor.A = 255; - - Vector2 origin = bounds.Size() / 2; - Main.EntitySpriteDraw(image, drawPos, bounds, fullColor, Projectile.rotation, origin, Projectile.scale, effect, 0); - - image = Mod.Assets.Request("Projectiles/Pets/TurtleSlimeProj_Glowmask2").Value; - Main.EntitySpriteDraw(image, drawPos, bounds, drawColor, Projectile.rotation, origin, Projectile.scale, effect, 0); - } - } + [Content(ContentType.HostileNPCs)] + //check this file for more info vvvvvvvv + public class TurtleSlimeProj : BabySlimeBase + { + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Turtle Slime"); + } + + public override void SafeSetDefaults() + { + Projectile.width = 32; + Projectile.height = 30; + + Projectile.minion = false; + } + + public override bool PreAI() + { + PetPlayer modPlayer = Projectile.GetOwner().GetModPlayer(); + if (Projectile.GetOwner().dead) + { + modPlayer.TurtleSlime = false; + } + if (modPlayer.TurtleSlime) + { + Projectile.timeLeft = 2; + } + return true; + } + + public override void PostDraw(Color drawColor) + { + Texture2D image = Mod.Assets.Request("Projectiles/Pets/TurtleSlimeProj_Glowmask").Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + Vector2 stupidOffset = new Vector2(0, Projectile.gfxOffY - DrawOriginOffsetY); //gfxoffY is for when the npc is on a slope or half brick + SpriteEffects effect = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 drawOrigin = new Vector2(Projectile.width * 0.5f, Projectile.height * 0.5f + DrawOriginOffsetY); + Vector2 drawPos = Projectile.position - Main.screenPosition + drawOrigin + stupidOffset; + + Color fullColor = drawColor; + fullColor.A = 255; + + Vector2 origin = bounds.Size() / 2; + Main.EntitySpriteDraw(image, drawPos, bounds, fullColor, Projectile.rotation, origin, Projectile.scale, effect, 0); + + image = Mod.Assets.Request("Projectiles/Pets/TurtleSlimeProj_Glowmask2").Value; + Main.EntitySpriteDraw(image, drawPos, bounds, drawColor, Projectile.rotation, origin, Projectile.scale, effect, 0); + } + } } diff --git a/Projectiles/Pets/VampireBatProj.cs b/Projectiles/Pets/VampireBatProj.cs index 3f627df3..4afaa7cc 100644 --- a/Projectiles/Pets/VampireBatProj.cs +++ b/Projectiles/Pets/VampireBatProj.cs @@ -7,64 +7,64 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class VampireBatProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/VampireBatProj_0"; //temp - } - } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Vampire Bat"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public class VampireBatProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/VampireBatProj_0"; //temp + } + } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Vampire Bat"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ZephyrFish); - AIType = ProjectileID.ZephyrFish; - Projectile.width = 46; - Projectile.height = 40; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ZephyrFish); + AIType = ProjectileID.ZephyrFish; + Projectile.width = 46; + Projectile.height = 40; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.zephyrfish = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.zephyrfish = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.VampireBat = false; - } - if (modPlayer.VampireBat) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.VampireBat = false; + } + if (modPlayer.VampireBat) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/VampireBatProj_" + mPlayer.vampireBatType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/VampireBatProj_" + mPlayer.vampireBatType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2 + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/WallFragmentCombined.cs b/Projectiles/Pets/WallFragmentCombined.cs index 2c3121d5..69017cff 100644 --- a/Projectiles/Pets/WallFragmentCombined.cs +++ b/Projectiles/Pets/WallFragmentCombined.cs @@ -7,105 +7,105 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.DroppedPets)] - public abstract class WallFragmentProjBase : SimplePetProjBase - { - public sealed override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 2; - Main.projPet[Projectile.type] = true; - } + [Content(ContentType.DroppedPets)] + public abstract class WallFragmentProjBase : SimplePetProjBase + { + public sealed override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 2; + Main.projPet[Projectile.type] = true; + } - public virtual void SafeSetStaticDefaults() - { + public virtual void SafeSetStaticDefaults() + { - } + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyEater); - AIType = ProjectileID.BabyEater; - Projectile.width = 26; - Projectile.height = 40; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyEater); + AIType = ProjectileID.BabyEater; + Projectile.width = 26; + Projectile.height = 40; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.eater = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.eater = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.WallFragment = false; - } - if (modPlayer.WallFragment) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.WallFragment = false; + } + if (modPlayer.WallFragment) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/" + Name + "_" + mPlayer.wallFragmentType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/" + Name + "_" + mPlayer.wallFragmentType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2); + Vector2 stupidOffset = new Vector2(Projectile.width / 2, Projectile.height / 2); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } - public class WallFragmentMouth : WallFragmentProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/WallFragmentMouth_0"; //temp - } - } + public class WallFragmentMouth : WallFragmentProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/WallFragmentMouth_0"; //temp + } + } - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Wall Mouth"); - } - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Wall Mouth"); + } + } - public class WallFragmentEye1 : WallFragmentProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/WallFragmentEye1_0"; //temp - } - } + public class WallFragmentEye1 : WallFragmentProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/WallFragmentEye1_0"; //temp + } + } - public override void SafeSetStaticDefaults() - { - DisplayName.SetDefault("Wall Eye"); - } - } + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Wall Eye"); + } + } - public class WallFragmentEye2 : WallFragmentEye1 - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/WallFragmentEye2_0"; //temp - } - } - } + public class WallFragmentEye2 : WallFragmentEye1 + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/WallFragmentEye2_0"; //temp + } + } + } } diff --git a/Projectiles/Pets/YoungHarpyProj.cs b/Projectiles/Pets/YoungHarpyProj.cs index 21d45d2a..434245d4 100644 --- a/Projectiles/Pets/YoungHarpyProj.cs +++ b/Projectiles/Pets/YoungHarpyProj.cs @@ -7,64 +7,64 @@ namespace AssortedCrazyThings.Projectiles.Pets { - [Content(ContentType.FriendlyNPCs)] - public class YoungHarpyProj : SimplePetProjBase - { - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/YoungHarpyProj_0"; //temp - } - } + [Content(ContentType.FriendlyNPCs)] + public class YoungHarpyProj : SimplePetProjBase + { + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/YoungHarpyProj_0"; //temp + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Young Harpy"); - Main.projFrames[Projectile.type] = 4; - Main.projPet[Projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Young Harpy"); + Main.projFrames[Projectile.type] = 4; + Main.projPet[Projectile.type] = true; + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BabyHornet); - AIType = ProjectileID.BabyHornet; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BabyHornet); + AIType = ProjectileID.BabyHornet; + } - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.hornet = false; // Relic from AIType - return true; - } + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.hornet = false; // Relic from AIType + return true; + } - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.YoungHarpy = false; - } - if (modPlayer.YoungHarpy) - { - Projectile.timeLeft = 2; - } - AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); - } + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.YoungHarpy = false; + } + if (modPlayer.YoungHarpy) + { + Projectile.timeLeft = 2; + } + AssAI.TeleportIfTooFar(Projectile, player.MountedCenter); + } - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/YoungHarpyProj_" + mPlayer.youngHarpyType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/YoungHarpyProj_" + mPlayer.youngHarpyType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - Vector2 stupidOffset = new Vector2(Projectile.width / 2 + DrawOffsetX, Projectile.height / 2 + Projectile.gfxOffY); + Vector2 stupidOffset = new Vector2(Projectile.width / 2 + DrawOffsetX, Projectile.height / 2 + Projectile.gfxOffY); - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Pets/YoungWyvernProj.cs b/Projectiles/Pets/YoungWyvernProj.cs index c105dd5b..c23fadce 100644 --- a/Projectiles/Pets/YoungWyvernProj.cs +++ b/Projectiles/Pets/YoungWyvernProj.cs @@ -8,179 +8,179 @@ namespace AssortedCrazyThings.Projectiles.Pets { - public class YoungWyvernProj : SimplePetProjBase - { - public int frame = 0; - public int frameCounter = 0; - - public bool InAir => Projectile.ai[0] != 0f; - - public override string Texture - { - get - { - return "AssortedCrazyThings/Projectiles/Pets/YoungWyvernProj_0"; //temp - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Young Wyvern"); - Main.projFrames[Projectile.type] = 12; - Main.projPet[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.BlackCat); - DrawOffsetX = -6; - Projectile.width = 44; - Projectile.height = 30; - AIType = ProjectileID.BlackCat; - } - - public override bool PreAI() - { - Player player = Projectile.GetOwner(); - player.blackCat = false; // Relic from AIType - return true; - } - - public override void AI() - { - Player player = Projectile.GetOwner(); - PetPlayer modPlayer = player.GetModPlayer(); - if (player.dead) - { - modPlayer.YoungWyvern = false; - } - if (modPlayer.YoungWyvern) - { - Projectile.timeLeft = 2; - } - - //BLACK CAT - //bool flag11 = Projectile.position.X - Projectile.oldPosition.X == 0f; - //if (InAir) - //{ - // rotation = base.Projectile.velocity.X * 0.05f; - // frameCounter++; - // if (frameCounter >= 6) - // { - // frame++; - // frameCounter = 0; - // } - - // if (frame > 10) - // frame = 6; - - // if (frame < 6) - // frame = 6; - //} - //else - //{ - // if (base.Projectile.velocity.Y >= 0f && (double)base.Projectile.velocity.Y <= 0.8) - // { - // if (flag11) - // { - // frame = 0; - // frameCounter = 0; - // } - // else if ((double)base.Projectile.velocity.X < -0.8 || (double)base.Projectile.velocity.X > 0.8) - // { - // frameCounter += (int)Math.Abs(base.Projectile.velocity.X); - // frameCounter++; - // if (frameCounter > 8) - // { - // frame++; - // frameCounter = 0; - // } - - // if (frame > 5) - // frame = 2; - // } - // else - // { - // frame = 0; - // frameCounter = 0; - // } - // } - // else - // { - // frameCounter = 0; - // frame = 1; - // } - //} - } - - public override void PostAI() - { - //Black cat AI values, so we have to check those - if (!InAir) - { - //DESERT TIGER - int lastFrame = 8; //frame #8 onwards is flying - - //if (fancy desert tigers) - // lastFrame = 10; - - //Projectile.rotation = 0f; - if (Projectile.velocity.Y >= 0f && Projectile.velocity.Y <= 0.8f) - { - if (Projectile.position.X - Projectile.oldPosition.X == 0f) - { - frame = 0; - frameCounter = 0; - } - else if (Math.Abs(Projectile.velocity.X) >= 0.5f) - { - frameCounter += (int)Math.Abs(Projectile.velocity.X); - frameCounter++; - if (frameCounter > 10) - { - frame++; - frameCounter = 0; - } - - if (frame >= lastFrame || frame < 2) - frame = 2; - } - else - { - frame = 0; - frameCounter = 0; - } - } - else if (Projectile.velocity.Y != 0f) - { - frameCounter = 0; - frame = 1; - //if (fancy desert tigers) - // frame = 9; - } - } - else - { - Projectile.spriteDirection = (Projectile.velocity.X <= 0f).ToDirectionInt(); - - AssExtensions.LoopAnimationInt(ref frame, ref frameCounter, 6, 8, Main.projFrames[Projectile.type] - 1); - } - - Projectile.frame = frame; - } - - public override bool PreDraw(ref Color lightColor) - { - PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - SpriteEffects effects = Projectile.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D image = Mod.Assets.Request("Projectiles/Pets/YoungWyvernProj_" + mPlayer.youngWyvernType).Value; - Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); - - Vector2 stupidOffset = new Vector2(Projectile.width / 2 + DrawOffsetX, Projectile.height / 2 + Projectile.gfxOffY + 4f); - - Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); - - return false; - } - } + public class YoungWyvernProj : SimplePetProjBase + { + public int frame = 0; + public int frameCounter = 0; + + public bool InAir => Projectile.ai[0] != 0f; + + public override string Texture + { + get + { + return "AssortedCrazyThings/Projectiles/Pets/YoungWyvernProj_0"; //temp + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Young Wyvern"); + Main.projFrames[Projectile.type] = 12; + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.BlackCat); + DrawOffsetX = -6; + Projectile.width = 44; + Projectile.height = 30; + AIType = ProjectileID.BlackCat; + } + + public override bool PreAI() + { + Player player = Projectile.GetOwner(); + player.blackCat = false; // Relic from AIType + return true; + } + + public override void AI() + { + Player player = Projectile.GetOwner(); + PetPlayer modPlayer = player.GetModPlayer(); + if (player.dead) + { + modPlayer.YoungWyvern = false; + } + if (modPlayer.YoungWyvern) + { + Projectile.timeLeft = 2; + } + + //BLACK CAT + //bool flag11 = Projectile.position.X - Projectile.oldPosition.X == 0f; + //if (InAir) + //{ + // rotation = base.Projectile.velocity.X * 0.05f; + // frameCounter++; + // if (frameCounter >= 6) + // { + // frame++; + // frameCounter = 0; + // } + + // if (frame > 10) + // frame = 6; + + // if (frame < 6) + // frame = 6; + //} + //else + //{ + // if (base.Projectile.velocity.Y >= 0f && (double)base.Projectile.velocity.Y <= 0.8) + // { + // if (flag11) + // { + // frame = 0; + // frameCounter = 0; + // } + // else if ((double)base.Projectile.velocity.X < -0.8 || (double)base.Projectile.velocity.X > 0.8) + // { + // frameCounter += (int)Math.Abs(base.Projectile.velocity.X); + // frameCounter++; + // if (frameCounter > 8) + // { + // frame++; + // frameCounter = 0; + // } + + // if (frame > 5) + // frame = 2; + // } + // else + // { + // frame = 0; + // frameCounter = 0; + // } + // } + // else + // { + // frameCounter = 0; + // frame = 1; + // } + //} + } + + public override void PostAI() + { + //Black cat AI values, so we have to check those + if (!InAir) + { + //DESERT TIGER + int lastFrame = 8; //frame #8 onwards is flying + + //if (fancy desert tigers) + // lastFrame = 10; + + //Projectile.rotation = 0f; + if (Projectile.velocity.Y >= 0f && Projectile.velocity.Y <= 0.8f) + { + if (Projectile.position.X - Projectile.oldPosition.X == 0f) + { + frame = 0; + frameCounter = 0; + } + else if (Math.Abs(Projectile.velocity.X) >= 0.5f) + { + frameCounter += (int)Math.Abs(Projectile.velocity.X); + frameCounter++; + if (frameCounter > 10) + { + frame++; + frameCounter = 0; + } + + if (frame >= lastFrame || frame < 2) + frame = 2; + } + else + { + frame = 0; + frameCounter = 0; + } + } + else if (Projectile.velocity.Y != 0f) + { + frameCounter = 0; + frame = 1; + //if (fancy desert tigers) + // frame = 9; + } + } + else + { + Projectile.spriteDirection = (Projectile.velocity.X <= 0f).ToDirectionInt(); + + AssExtensions.LoopAnimationInt(ref frame, ref frameCounter, 6, 8, Main.projFrames[Projectile.type] - 1); + } + + Projectile.frame = frame; + } + + public override bool PreDraw(ref Color lightColor) + { + PetPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + SpriteEffects effects = Projectile.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D image = Mod.Assets.Request("Projectiles/Pets/YoungWyvernProj_" + mPlayer.youngWyvernType).Value; + Rectangle bounds = image.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); + + Vector2 stupidOffset = new Vector2(Projectile.width / 2 + DrawOffsetX, Projectile.height / 2 + Projectile.gfxOffY + 4f); + + Main.EntitySpriteDraw(image, Projectile.position - Main.screenPosition + stupidOffset, bounds, lightColor, Projectile.rotation, bounds.Size() / 2, Projectile.scale, effects, 0); + + return false; + } + } } diff --git a/Projectiles/Tools/ExtendoNetBaseProj.cs b/Projectiles/Tools/ExtendoNetBaseProj.cs index d4e1a432..7a549849 100644 --- a/Projectiles/Tools/ExtendoNetBaseProj.cs +++ b/Projectiles/Tools/ExtendoNetBaseProj.cs @@ -5,112 +5,112 @@ namespace AssortedCrazyThings.Projectiles.Tools { - [Content(ContentType.Tools)] - abstract public class ExtendoNetBaseProj : AssProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("EXTENDO!"); - } + [Content(ContentType.Tools)] + abstract public class ExtendoNetBaseProj : AssProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("EXTENDO!"); + } - protected float initialSpeed = 10f; - protected float extendSpeed = 2.5f; - protected float retractSpeed = 2.3f; + protected float initialSpeed = 10f; + protected float extendSpeed = 2.5f; + protected float retractSpeed = 2.3f; - public override void SetDefaults() - { - Projectile.width = 28; - Projectile.height = 28; - Projectile.aiStyle = 19; - Projectile.penetrate = -1; - Projectile.scale = 1f; + public override void SetDefaults() + { + Projectile.width = 28; + Projectile.height = 28; + Projectile.aiStyle = 19; + Projectile.penetrate = -1; + Projectile.scale = 1f; - Projectile.hide = true; - Projectile.ownerHitCheck = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.tileCollide = false; - Projectile.friendly = true; - } + Projectile.hide = true; + Projectile.ownerHitCheck = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.tileCollide = false; + Projectile.friendly = true; + } - public override bool? CanCutTiles() - { - return false; - } + public override bool? CanCutTiles() + { + return false; + } - public float MovementFactor - { - get { return Projectile.ai[0]; } - set { Projectile.ai[0] = value; } - } + public float MovementFactor + { + get { return Projectile.ai[0]; } + set { Projectile.ai[0] = value; } + } - // It appears that for this AI, only the ai0 field is used! - public override void AI() - { - // Since we access the owner player instance so much, it's useful to create a helper local variable for this - // Sadly, Projectile/ModProjectile does not have its own - Player projOwner = Projectile.GetOwner(); - // Here we set some of the projectile's owner properties, such as held item and itemtime, along with projectile direction and position based on the player - Vector2 ownerMountedCenter = projOwner.RotatedRelativePoint(projOwner.MountedCenter, true); - Projectile.direction = projOwner.direction; - Projectile.spriteDirection = -Projectile.direction; - projOwner.heldProj = Projectile.whoAmI; - projOwner.itemTime = projOwner.itemAnimation; - Projectile.position.X = ownerMountedCenter.X - (float)(Projectile.width / 2); - Projectile.position.Y = ownerMountedCenter.Y - (float)(Projectile.height / 2); - // As long as the player isn't frozen, the spear can move - if (!projOwner.frozen) - { - if (MovementFactor == 0f) // When initially thrown out, the ai0 will be 0f - { - MovementFactor = initialSpeed; // Make sure the spear moves forward when initially thrown out - Projectile.netUpdate = true; // Make sure to netUpdate this spear - } - if (projOwner.itemAnimation < projOwner.itemAnimationMax / 3) // Somewhere along the item animation, make sure the spear moves back - { - MovementFactor -= retractSpeed; - } - else // Otherwise, increase the movement factor - { - MovementFactor += extendSpeed; - } - } - // Change the spear position based off of the velocity and the movementFactor - Projectile.position += Projectile.velocity * MovementFactor; - // When we reach the end of the animation, we can kill the spear projectile - if (projOwner.itemAnimation == 0) - { - Projectile.Kill(); - } - // Apply proper rotation, with an offset of 135 degrees due to the sprite's rotation, notice the usage of MathHelper, use this class! - // MathHelper.ToRadians(xx degrees here) - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); - // Offset by 90 degrees here - if (Projectile.spriteDirection == -1) - { - Projectile.rotation -= MathHelper.ToRadians(90f); - } + // It appears that for this AI, only the ai0 field is used! + public override void AI() + { + // Since we access the owner player instance so much, it's useful to create a helper local variable for this + // Sadly, Projectile/ModProjectile does not have its own + Player projOwner = Projectile.GetOwner(); + // Here we set some of the projectile's owner properties, such as held item and itemtime, along with projectile direction and position based on the player + Vector2 ownerMountedCenter = projOwner.RotatedRelativePoint(projOwner.MountedCenter, true); + Projectile.direction = projOwner.direction; + Projectile.spriteDirection = -Projectile.direction; + projOwner.heldProj = Projectile.whoAmI; + projOwner.itemTime = projOwner.itemAnimation; + Projectile.position.X = ownerMountedCenter.X - (float)(Projectile.width / 2); + Projectile.position.Y = ownerMountedCenter.Y - (float)(Projectile.height / 2); + // As long as the player isn't frozen, the spear can move + if (!projOwner.frozen) + { + if (MovementFactor == 0f) // When initially thrown out, the ai0 will be 0f + { + MovementFactor = initialSpeed; // Make sure the spear moves forward when initially thrown out + Projectile.netUpdate = true; // Make sure to netUpdate this spear + } + if (projOwner.itemAnimation < projOwner.itemAnimationMax / 3) // Somewhere along the item animation, make sure the spear moves back + { + MovementFactor -= retractSpeed; + } + else // Otherwise, increase the movement factor + { + MovementFactor += extendSpeed; + } + } + // Change the spear position based off of the velocity and the movementFactor + Projectile.position += Projectile.velocity * MovementFactor; + // When we reach the end of the animation, we can kill the spear projectile + if (projOwner.itemAnimation == 0) + { + Projectile.Kill(); + } + // Apply proper rotation, with an offset of 135 degrees due to the sprite's rotation, notice the usage of MathHelper, use this class! + // MathHelper.ToRadians(xx degrees here) + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); + // Offset by 90 degrees here + if (Projectile.spriteDirection == -1) + { + Projectile.rotation -= MathHelper.ToRadians(90f); + } - if (Main.myPlayer == Projectile.owner) - { - Vector2 between = projOwner.Center - Projectile.Center; - between.Normalize(); - Rectangle hitboxMod = new Rectangle(Projectile.Hitbox.X + (int)(between.X * Projectile.width * 1.3f), - Projectile.Hitbox.Y + (int)(between.Y * Projectile.height * 1.3f), - Projectile.width, - Projectile.height); + if (Main.myPlayer == Projectile.owner) + { + Vector2 between = projOwner.Center - Projectile.Center; + between.Normalize(); + Rectangle hitboxMod = new Rectangle(Projectile.Hitbox.X + (int)(between.X * Projectile.width * 1.3f), + Projectile.Hitbox.Y + (int)(between.Y * Projectile.height * 1.3f), + Projectile.width, + Projectile.height); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.active && npc.catchItem > 0) - { - if (hitboxMod.Intersects(npc.getRect())/* && (Main.npc[i].noTileCollide || projOwner.CanHit(Main.npc[i]))*/) - { - NPC.CatchNPC(i, Projectile.owner); - } - } - } - } - } - } + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active && npc.catchItem > 0) + { + if (hitboxMod.Intersects(npc.getRect())/* && (Main.npc[i].noTileCollide || projOwner.CanHit(Main.npc[i]))*/) + { + NPC.CatchNPC(i, Projectile.owner); + } + } + } + } + } + } } diff --git a/Projectiles/Tools/ExtendoNetGoldenProj.cs b/Projectiles/Tools/ExtendoNetGoldenProj.cs index ce8ea764..1bcab2a5 100644 --- a/Projectiles/Tools/ExtendoNetGoldenProj.cs +++ b/Projectiles/Tools/ExtendoNetGoldenProj.cs @@ -1,19 +1,19 @@ namespace AssortedCrazyThings.Projectiles.Tools { - public class ExtendoNetGoldenProj : ExtendoNetBaseProj - { - public override void SetDefaults() - { - base.SetDefaults(); - Projectile.scale = 1.3f; - initialSpeed = 13f; - extendSpeed = 4f; - retractSpeed = 3.6f; - } + public class ExtendoNetGoldenProj : ExtendoNetBaseProj + { + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.scale = 1.3f; + initialSpeed = 13f; + extendSpeed = 4f; + retractSpeed = 3.6f; + } - public override bool? CanCutTiles() - { - return true; - } - } + public override bool? CanCutTiles() + { + return true; + } + } } diff --git a/Projectiles/Tools/ExtendoNetRegularProj.cs b/Projectiles/Tools/ExtendoNetRegularProj.cs index e06abdf7..acb4f751 100644 --- a/Projectiles/Tools/ExtendoNetRegularProj.cs +++ b/Projectiles/Tools/ExtendoNetRegularProj.cs @@ -1,7 +1,7 @@ namespace AssortedCrazyThings.Projectiles.Tools { - public class ExtendoNetRegularProj : ExtendoNetBaseProj - { + public class ExtendoNetRegularProj : ExtendoNetBaseProj + { - } + } } diff --git a/Projectiles/Weapons/CandleDustDummy.cs b/Projectiles/Weapons/CandleDustDummy.cs index d57fe1f8..d097bfa8 100644 --- a/Projectiles/Weapons/CandleDustDummy.cs +++ b/Projectiles/Weapons/CandleDustDummy.cs @@ -2,105 +2,104 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace AssortedCrazyThings.Projectiles.Weapons { - //used in EverburningGlobalItem for creating candle dust - //TODO figure out dust spam with sling - [Content(ContentType.Accessories)] - public class CandleDustDummy : AssProjectile - { - private static readonly int LifeTime = 10; - - public override string Texture - { - get - { - return "Terraria/Images/Projectile_" + ProjectileID.WoodenArrowFriendly; - } - } - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Candle Dust Dummy"); - } - - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.WoodenArrowFriendly); - Projectile.timeLeft = LifeTime; - Projectile.hide = true; - //projectile.alpha = 255; - Projectile.tileCollide = false; - } - - //ai 0 is the timer until the arrow starts dropping (caps at 15) - //ai 1 unused - public override bool PreAI() - { - AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); - - bool[] buffs = new bool[] { - mPlayer.everburningCandleBuff, - mPlayer.everburningCursedCandleBuff, - mPlayer.everfrozenCandleBuff, - mPlayer.everburningShadowflameCandleBuff}; - - int[] types = new int[] { - 6, - 75, - 59, - 62}; - - Color[] colors = new Color[] { - new Color(255, 255, 255), - new Color(255, 255, 255), - new Color(255, 255, 255), - new Color(196, 0, 255)}; - - //projectile.alpha = 255; - - //projectile.ai[0] = 0; //fly straight - //kinda cheaty since the arrow AI makes itself only visible after a few ticks, so no need to make alpha - //if timeLeft is only between 2 and 0 - - int[] randomindex = new int[] { 0, 1, 2, 3 }; - - int buffCount = 0; - - for (int t = 0; t < randomindex.Length; t++) - { - //shuffle indexes (purely visual so different dusts overlap) - int tmp = randomindex[t]; - int r = Main.rand.Next(t, randomindex.Length); - randomindex[t] = randomindex[r]; - randomindex[r] = tmp; - - //check number of enabled buffs (to reduce number of particles when spammed) - if (buffs[t]) buffCount++; - } - - for (int i = 0; i < randomindex.Length; i++) - { - if (buffs[randomindex[i]] && Projectile.ai[0] < 2) - { - for (int k = 0; k < 10 - (int)(buffCount * 1.75f); k++) //spawn less dusts if more buffs active - { - if (Main.rand.NextFloat() < 0.8f) - { - float rand = Main.rand.NextFloat(0.7f, 1.3f); - Vector2 cm = Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(10)); - Vector2 velo = cm * rand; - Dust dust = Dust.NewDustPerfect(Projectile.position, types[randomindex[i]], velo, 100 * (int)(Projectile.ai[0] + 1f), colors[randomindex[i]], 2.368421f); - dust.noGravity = true; - dust.noLight = true; - } - } - } - } - - return true; - } - } + //used in EverburningGlobalItem for creating candle dust + //TODO figure out dust spam with sling + [Content(ContentType.Accessories)] + public class CandleDustDummy : AssProjectile + { + private static readonly int LifeTime = 10; + + public override string Texture + { + get + { + return "Terraria/Images/Projectile_" + ProjectileID.WoodenArrowFriendly; + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Candle Dust Dummy"); + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.WoodenArrowFriendly); + Projectile.timeLeft = LifeTime; + Projectile.hide = true; + //projectile.alpha = 255; + Projectile.tileCollide = false; + } + + //ai 0 is the timer until the arrow starts dropping (caps at 15) + //ai 1 unused + public override bool PreAI() + { + AssPlayer mPlayer = Projectile.GetOwner().GetModPlayer(); + + bool[] buffs = new bool[] { + mPlayer.everburningCandleBuff, + mPlayer.everburningCursedCandleBuff, + mPlayer.everfrozenCandleBuff, + mPlayer.everburningShadowflameCandleBuff}; + + int[] types = new int[] { + 6, + 75, + 59, + 62}; + + Color[] colors = new Color[] { + new Color(255, 255, 255), + new Color(255, 255, 255), + new Color(255, 255, 255), + new Color(196, 0, 255)}; + + //projectile.alpha = 255; + + //projectile.ai[0] = 0; //fly straight + //kinda cheaty since the arrow AI makes itself only visible after a few ticks, so no need to make alpha + //if timeLeft is only between 2 and 0 + + int[] randomindex = new int[] { 0, 1, 2, 3 }; + + int buffCount = 0; + + for (int t = 0; t < randomindex.Length; t++) + { + //shuffle indexes (purely visual so different dusts overlap) + int tmp = randomindex[t]; + int r = Main.rand.Next(t, randomindex.Length); + randomindex[t] = randomindex[r]; + randomindex[r] = tmp; + + //check number of enabled buffs (to reduce number of particles when spammed) + if (buffs[t]) buffCount++; + } + + for (int i = 0; i < randomindex.Length; i++) + { + if (buffs[randomindex[i]] && Projectile.ai[0] < 2) + { + for (int k = 0; k < 10 - (int)(buffCount * 1.75f); k++) //spawn less dusts if more buffs active + { + if (Main.rand.NextFloat() < 0.8f) + { + float rand = Main.rand.NextFloat(0.7f, 1.3f); + Vector2 cm = Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(10)); + Vector2 velo = cm * rand; + Dust dust = Dust.NewDustPerfect(Projectile.position, types[randomindex[i]], velo, 100 * (int)(Projectile.ai[0] + 1f), colors[randomindex[i]], 2.368421f); + dust.noGravity = true; + dust.noLight = true; + } + } + } + } + + return true; + } + } } diff --git a/Projectiles/Weapons/GuideVoodoorangProj.cs b/Projectiles/Weapons/GuideVoodoorangProj.cs index cff4a3a4..bbeec5b3 100644 --- a/Projectiles/Weapons/GuideVoodoorangProj.cs +++ b/Projectiles/Weapons/GuideVoodoorangProj.cs @@ -1,62 +1,62 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.Audio; +using Terraria.ID; namespace AssortedCrazyThings.Projectiles.Weapons { - [Content(ContentType.Weapons)] - public class GuideVoodoorangProj : AssProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Guide Voodoorang"); - } + [Content(ContentType.Weapons)] + public class GuideVoodoorangProj : AssProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Guide Voodoorang"); + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.WoodenBoomerang); - Projectile.height = 22; - Projectile.width = 30; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.WoodenBoomerang); + Projectile.height = 22; + Projectile.width = 30; + } - public static int type = 0; + public static int type = 0; - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - SoundEngine.PlaySound(SoundID.PlayerHit, Projectile.position); //player hurt sound - return true; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + SoundEngine.PlaySound(SoundID.PlayerHit, Projectile.position); //player hurt sound + return true; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - SoundEngine.PlaySound(SoundID.PlayerHit, Projectile.position); //player hurt sound - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + SoundEngine.PlaySound(SoundID.PlayerHit, Projectile.position); //player hurt sound + } - public override void PostAI() - { - if (Projectile.lavaWet) - { - if (Main.netMode != NetmodeID.MultiplayerClient && !NPC.AnyNPCs(NPCID.WallofFlesh)) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == NPCID.Guide) - { - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, i, 9999f, 10f, -Main.npc[i].direction); - } - Main.npc[i].StrikeNPCNoInteraction(9999, 10f, -Main.npc[i].direction); - NPC.SpawnWOF(Projectile.position); + public override void PostAI() + { + if (Projectile.lavaWet) + { + if (Main.netMode != NetmodeID.MultiplayerClient && !NPC.AnyNPCs(NPCID.WallofFlesh)) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == NPCID.Guide) + { + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, i, 9999f, 10f, -Main.npc[i].direction); + } + Main.npc[i].StrikeNPCNoInteraction(9999, 10f, -Main.npc[i].direction); + NPC.SpawnWOF(Projectile.position); - Projectile.Kill(); - //item itself doesn't get deleted but only works when the guide is in the world anyway - } - } - } - } - } - } + Projectile.Kill(); + //item itself doesn't get deleted but only works when the guide is in the world anyway + } + } + } + } + } + } } diff --git a/Projectiles/Weapons/LegendaryWoodenSwordProj.cs b/Projectiles/Weapons/LegendaryWoodenSwordProj.cs index 3f39a450..e6c8f36f 100644 --- a/Projectiles/Weapons/LegendaryWoodenSwordProj.cs +++ b/Projectiles/Weapons/LegendaryWoodenSwordProj.cs @@ -6,145 +6,145 @@ namespace AssortedCrazyThings.Projectiles.Weapons { - [Content(ContentType.Weapons)] - public class LegendaryWoodenSwordProj : AssProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Legendary Wooden Sword"); - } - - public override void SetDefaults() - { - //Projectile.CloneDefaults(ProjectileID.IronShortswordStab); - Projectile.Size = new Vector2(18); //This sets width and height to the same value (important when projectiles can rotate) - Projectile.aiStyle = -1; //Use our own AI to customize how it behaves, if you don't want that, keep this at 161 - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.scale = 1f; - Projectile.ownerHitCheck = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.extraUpdates = 1; //Update 1+extraUpdates times per tick - Projectile.timeLeft = 360; //this value does not matter since we manually kill it earlier, it just has to be higher than the duration we use in AI - Projectile.hide = true; - } - - public int Timer - { - get => (int)Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - - public float CollisionWidth => 10f * Projectile.scale; - - public const int fadeInDuration = 7; - public const int fadeOutDuration = 4; - - public const int totalDuration = 16; - - public override void AI() - { - Player player = Projectile.GetOwner(); - - Timer += 1; - if (Timer >= totalDuration) - { - Projectile.Kill(); - return; - } - else - { - player.heldProj = Projectile.whoAmI; - } - - //Fade in and out - //GetLerpValue returns a value between 0f and 1f - if clamped is true - representing how far Timer got along the "distance" defined by the first two parameters - //The first call handles the fade in, the second one the fade out. - //Notice the second call's parameters are swapped, this means the result will be reverted - Projectile.Opacity = Utils.GetLerpValue(0f, fadeInDuration, Timer, clamped: true) * Utils.GetLerpValue(totalDuration, totalDuration - fadeOutDuration, Timer, clamped: true); - - //Keep locked onto the player, but extend further based on the given velocity - Vector2 playerCenter = player.RotatedRelativePoint(player.MountedCenter, reverseRotation: false, addGfxOffY: false); - Projectile.Center = playerCenter + Projectile.velocity * (Timer - 1f); - - //Set spriteDirection based on moving left or right. Left -1, right 1 - Projectile.spriteDirection = (Vector2.Dot(Projectile.velocity, Vector2.UnitX) >= 0f).ToDirectionInt(); - - //Point towards where it is moving, applied offset for top right of the sprite respecting spriteDirection - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 - MathHelper.PiOver4 * Projectile.spriteDirection; - - if (Main.rand.NextBool(2)) - { - //162 for "sparks" - //169 for just light - int dustType = 169; - Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 10f, Projectile.width, Projectile.height, dustType, 100, Scale: 1.25f); - dust.noGravity = true; - dust.velocity = Projectile.velocity * 0.3f; - } - - SetVisualOffsets(); - } - - private void SetVisualOffsets() - { - const int halfWidth = 32 / 2; - const int halfHeight = 32 / 2; - //7 comes from: 32/2 - 18/2 == 16 - 9 - - //Vanilla configuration for "hitbox in middle of sprite" - //X : -7 - //OX: 0 - //OY: -7 - DrawOffsetX = -(halfWidth - Projectile.width / 2); - DrawOriginOffsetX = 0; - DrawOriginOffsetY = -(halfHeight - Projectile.height / 2); - - //Vanilla configuration for "hitbox towards the end" - //if (Projectile.spriteDirection == 1) - //{ - //sDir 1: (aka hitbox top right) - //X : 7 - //OX: -14 - //OY: 0 - //DrawOriginOffsetX = -(Projectile.width / 2 - halfWidth); - //DrawOffsetX = (int)-DrawOriginOffsetX * 2; - //DrawOriginOffsetY = 0; - //} - //else - //{ - //sDir -1: (aka hitbox top left) - //X : 0 - //OX: -7 - //OY: 0 - //DrawOriginOffsetX = (Projectile.width / 2 - halfWidth); - //DrawOffsetX = 0; - //DrawOriginOffsetY = 0; - //} - } - - public override bool ShouldUpdatePosition() - { - //Update Projectile.Center manually - return false; - } - - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Vector2 start = Projectile.Center; - Vector2 end = start + Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 10f; - Utils.PlotTileLine(start, end, CollisionWidth, DelegateMethods.CutTiles); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - //shootSpeed is 2.1f for reference, so this is basically plotting 12 pixels ahead from the center - Vector2 start = Projectile.Center; - Vector2 end = start + Projectile.velocity * 6f; - float collisionPoint = 0f; //Don't need that variable, but required as parameter - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, CollisionWidth, ref collisionPoint); - } - } + [Content(ContentType.Weapons)] + public class LegendaryWoodenSwordProj : AssProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Legendary Wooden Sword"); + } + + public override void SetDefaults() + { + //Projectile.CloneDefaults(ProjectileID.IronShortswordStab); + Projectile.Size = new Vector2(18); //This sets width and height to the same value (important when projectiles can rotate) + Projectile.aiStyle = -1; //Use our own AI to customize how it behaves, if you don't want that, keep this at 161 + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.ownerHitCheck = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.extraUpdates = 1; //Update 1+extraUpdates times per tick + Projectile.timeLeft = 360; //this value does not matter since we manually kill it earlier, it just has to be higher than the duration we use in AI + Projectile.hide = true; + } + + public int Timer + { + get => (int)Projectile.ai[0]; + set => Projectile.ai[0] = value; + } + + public float CollisionWidth => 10f * Projectile.scale; + + public const int fadeInDuration = 7; + public const int fadeOutDuration = 4; + + public const int totalDuration = 16; + + public override void AI() + { + Player player = Projectile.GetOwner(); + + Timer += 1; + if (Timer >= totalDuration) + { + Projectile.Kill(); + return; + } + else + { + player.heldProj = Projectile.whoAmI; + } + + //Fade in and out + //GetLerpValue returns a value between 0f and 1f - if clamped is true - representing how far Timer got along the "distance" defined by the first two parameters + //The first call handles the fade in, the second one the fade out. + //Notice the second call's parameters are swapped, this means the result will be reverted + Projectile.Opacity = Utils.GetLerpValue(0f, fadeInDuration, Timer, clamped: true) * Utils.GetLerpValue(totalDuration, totalDuration - fadeOutDuration, Timer, clamped: true); + + //Keep locked onto the player, but extend further based on the given velocity + Vector2 playerCenter = player.RotatedRelativePoint(player.MountedCenter, reverseRotation: false, addGfxOffY: false); + Projectile.Center = playerCenter + Projectile.velocity * (Timer - 1f); + + //Set spriteDirection based on moving left or right. Left -1, right 1 + Projectile.spriteDirection = (Vector2.Dot(Projectile.velocity, Vector2.UnitX) >= 0f).ToDirectionInt(); + + //Point towards where it is moving, applied offset for top right of the sprite respecting spriteDirection + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 - MathHelper.PiOver4 * Projectile.spriteDirection; + + if (Main.rand.NextBool(2)) + { + //162 for "sparks" + //169 for just light + int dustType = 169; + Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 10f, Projectile.width, Projectile.height, dustType, 100, Scale: 1.25f); + dust.noGravity = true; + dust.velocity = Projectile.velocity * 0.3f; + } + + SetVisualOffsets(); + } + + private void SetVisualOffsets() + { + const int halfWidth = 32 / 2; + const int halfHeight = 32 / 2; + //7 comes from: 32/2 - 18/2 == 16 - 9 + + //Vanilla configuration for "hitbox in middle of sprite" + //X : -7 + //OX: 0 + //OY: -7 + DrawOffsetX = -(halfWidth - Projectile.width / 2); + DrawOriginOffsetX = 0; + DrawOriginOffsetY = -(halfHeight - Projectile.height / 2); + + //Vanilla configuration for "hitbox towards the end" + //if (Projectile.spriteDirection == 1) + //{ + //sDir 1: (aka hitbox top right) + //X : 7 + //OX: -14 + //OY: 0 + //DrawOriginOffsetX = -(Projectile.width / 2 - halfWidth); + //DrawOffsetX = (int)-DrawOriginOffsetX * 2; + //DrawOriginOffsetY = 0; + //} + //else + //{ + //sDir -1: (aka hitbox top left) + //X : 0 + //OX: -7 + //OY: 0 + //DrawOriginOffsetX = (Projectile.width / 2 - halfWidth); + //DrawOffsetX = 0; + //DrawOriginOffsetY = 0; + //} + } + + public override bool ShouldUpdatePosition() + { + //Update Projectile.Center manually + return false; + } + + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 start = Projectile.Center; + Vector2 end = start + Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 10f; + Utils.PlotTileLine(start, end, CollisionWidth, DelegateMethods.CutTiles); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + //shootSpeed is 2.1f for reference, so this is basically plotting 12 pixels ahead from the center + Vector2 start = Projectile.Center; + Vector2 end = start + Projectile.velocity * 6f; + float collisionPoint = 0f; //Don't need that variable, but required as parameter + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, CollisionWidth, ref collisionPoint); + } + } } diff --git a/Projectiles/Weapons/PlagueOfToadsCloud.cs b/Projectiles/Weapons/PlagueOfToadsCloud.cs index 8c68628f..cffa22b6 100644 --- a/Projectiles/Weapons/PlagueOfToadsCloud.cs +++ b/Projectiles/Weapons/PlagueOfToadsCloud.cs @@ -4,91 +4,91 @@ namespace AssortedCrazyThings.Projectiles.Weapons { - [Content(ContentType.Weapons)] - public class PlagueOfToadsCloud : AssProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plague of Toads Cloud"); - Main.projFrames[Projectile.type] = 6; - } + [Content(ContentType.Weapons)] + public class PlagueOfToadsCloud : AssProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plague of Toads Cloud"); + Main.projFrames[Projectile.type] = 6; + } - public override void SetDefaults() - { - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.width = 54; - Projectile.height = 28; - Projectile.aiStyle = -1; - Projectile.penetrate = -1; - } + public override void SetDefaults() + { + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.width = 54; + Projectile.height = 28; + Projectile.aiStyle = -1; + Projectile.penetrate = -1; + } - public override void AI() - { - Projectile.frameCounter++; - if (Projectile.frameCounter > 8) - { - Projectile.frameCounter = 0; - Projectile.frame++; - if (Projectile.frame > 5) - { - Projectile.frame = 0; - } - } - Projectile.ai[1] += 1f; - if (Projectile.ai[1] >= 7200f) - { - Projectile.alpha += 5; - if (Projectile.alpha > 255) - { - Projectile.alpha = 255; - Projectile.Kill(); - } - } - else - { - Projectile.ai[0] += 1f; - //8f - if (Projectile.ai[0] > 21f) - { - Projectile.ai[0] = 0f; - if (Projectile.owner == Main.myPlayer) - { - int rainSpawnX = (int)(Projectile.position.X + 14f + Main.rand.Next(Projectile.width - 28)); - int rainSpawnY = (int)(Projectile.position.Y + Projectile.height + 4f); - //speedY = 5f; - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), rainSpawnX, rainSpawnY, 0f, 2f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, Main.rand.Next(5), Main.rand.NextFloat(0.005f, 0.015f)); - } - } - } - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] >= 10f) - { - Projectile.localAI[0] = 0f; - int cloudCount = 0; - int cloudIndex = -1; - float cloudAi1 = 0f; - for (int i = 0; i < Main.maxProjectiles; i++) - { - //check for both crimson rod and plague of toads cloud - Projectile other = Main.projectile[i]; - if (other.active && other.owner == Projectile.owner && (other.type == Projectile.type || other.type == ProjectileID.BloodCloudRaining) && other.ai[1] < 3600f) - { - cloudCount++; - if (other.ai[1] > cloudAi1) - { - cloudIndex = i; - cloudAi1 = other.ai[1]; - } - } - } - if (cloudCount > -1) - { - Projectile projectile = Main.projectile[cloudIndex]; - projectile.netUpdate = true; - projectile.ai[1] = 36000f; - } - } - } - } + public override void AI() + { + Projectile.frameCounter++; + if (Projectile.frameCounter > 8) + { + Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame > 5) + { + Projectile.frame = 0; + } + } + Projectile.ai[1] += 1f; + if (Projectile.ai[1] >= 7200f) + { + Projectile.alpha += 5; + if (Projectile.alpha > 255) + { + Projectile.alpha = 255; + Projectile.Kill(); + } + } + else + { + Projectile.ai[0] += 1f; + //8f + if (Projectile.ai[0] > 21f) + { + Projectile.ai[0] = 0f; + if (Projectile.owner == Main.myPlayer) + { + int rainSpawnX = (int)(Projectile.position.X + 14f + Main.rand.Next(Projectile.width - 28)); + int rainSpawnY = (int)(Projectile.position.Y + Projectile.height + 4f); + //speedY = 5f; + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), rainSpawnX, rainSpawnY, 0f, 2f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, Main.rand.Next(5), Main.rand.NextFloat(0.005f, 0.015f)); + } + } + } + Projectile.localAI[0] += 1f; + if (Projectile.localAI[0] >= 10f) + { + Projectile.localAI[0] = 0f; + int cloudCount = 0; + int cloudIndex = -1; + float cloudAi1 = 0f; + for (int i = 0; i < Main.maxProjectiles; i++) + { + //check for both crimson rod and plague of toads cloud + Projectile other = Main.projectile[i]; + if (other.active && other.owner == Projectile.owner && (other.type == Projectile.type || other.type == ProjectileID.BloodCloudRaining) && other.ai[1] < 3600f) + { + cloudCount++; + if (other.ai[1] > cloudAi1) + { + cloudIndex = i; + cloudAi1 = other.ai[1]; + } + } + } + if (cloudCount > -1) + { + Projectile projectile = Main.projectile[cloudIndex]; + projectile.netUpdate = true; + projectile.ai[1] = 36000f; + } + } + } + } } diff --git a/Projectiles/Weapons/PlagueOfToadsFired.cs b/Projectiles/Weapons/PlagueOfToadsFired.cs index 74b055e0..4f1960e7 100644 --- a/Projectiles/Weapons/PlagueOfToadsFired.cs +++ b/Projectiles/Weapons/PlagueOfToadsFired.cs @@ -4,74 +4,74 @@ namespace AssortedCrazyThings.Projectiles.Weapons { - [Content(ContentType.Weapons)] - public class PlagueOfToadsFired : AssProjectile - { - public override string Texture - { - get - { - return "Terraria/Images/Projectile_" + ProjectileID.RainCloudMoving; - } - } + [Content(ContentType.Weapons)] + public class PlagueOfToadsFired : AssProjectile + { + public override string Texture + { + get + { + return "Terraria/Images/Projectile_" + ProjectileID.RainCloudMoving; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plague of Toads Fired"); - Main.projFrames[Projectile.type] = 4; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plague of Toads Fired"); + Main.projFrames[Projectile.type] = 4; + } - public override void SetDefaults() - { - Projectile.netImportant = true; - Projectile.width = 8; - Projectile.height = 8; - Projectile.aiStyle = -1; - Projectile.penetrate = -1; - Projectile.tileCollide = true; - } + public override void SetDefaults() + { + Projectile.netImportant = true; + Projectile.width = 8; + Projectile.height = 8; + Projectile.aiStyle = -1; + Projectile.penetrate = -1; + Projectile.tileCollide = true; + } - public override void Kill(int timeLeft) - { - if (Projectile.active && Main.myPlayer == Projectile.owner) - { - Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - } - } + public override void Kill(int timeLeft) + { + if (Projectile.active && Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + } - public override void AI() - { - float destinationX = Projectile.ai[0]; - float destinationY = Projectile.ai[1]; - if (destinationX != 0f && destinationY != 0f) - { - bool reachedX = false; - bool reachedY = false; - if ((Projectile.velocity.X < 0f && Projectile.Center.X < destinationX) || (Projectile.velocity.X > 0f && Projectile.Center.X > destinationX)) - { - reachedX = true; - } - if ((Projectile.velocity.Y < 0f && Projectile.Center.Y < destinationY) || (Projectile.velocity.Y > 0f && Projectile.Center.Y > destinationY)) - { - reachedY = true; - } - if (reachedX & reachedY) - { - Projectile.Kill(); - } - } - Projectile.rotation += Projectile.velocity.X * 0.02f; - Projectile.frameCounter++; - if (Projectile.frameCounter > 4) - { - Projectile.frameCounter = 0; - Projectile.frame++; - if (Projectile.frame > 3) - { - Projectile.frame = 0; - return; - } - } - } - } + public override void AI() + { + float destinationX = Projectile.ai[0]; + float destinationY = Projectile.ai[1]; + if (destinationX != 0f && destinationY != 0f) + { + bool reachedX = false; + bool reachedY = false; + if ((Projectile.velocity.X < 0f && Projectile.Center.X < destinationX) || (Projectile.velocity.X > 0f && Projectile.Center.X > destinationX)) + { + reachedX = true; + } + if ((Projectile.velocity.Y < 0f && Projectile.Center.Y < destinationY) || (Projectile.velocity.Y > 0f && Projectile.Center.Y > destinationY)) + { + reachedY = true; + } + if (reachedX & reachedY) + { + Projectile.Kill(); + } + } + Projectile.rotation += Projectile.velocity.X * 0.02f; + Projectile.frameCounter++; + if (Projectile.frameCounter > 4) + { + Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame > 3) + { + Projectile.frame = 0; + return; + } + } + } + } } diff --git a/Projectiles/Weapons/PlagueOfToadsProj.cs b/Projectiles/Weapons/PlagueOfToadsProj.cs index 887c338c..51923ea0 100644 --- a/Projectiles/Weapons/PlagueOfToadsProj.cs +++ b/Projectiles/Weapons/PlagueOfToadsProj.cs @@ -4,42 +4,42 @@ namespace AssortedCrazyThings.Projectiles.Weapons { - [Content(ContentType.Weapons)] - public class PlagueOfToadsProj : AssProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plague of Toads Fired"); - Main.projFrames[Projectile.type] = 1; - } + [Content(ContentType.Weapons)] + public class PlagueOfToadsProj : AssProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plague of Toads Fired"); + Main.projFrames[Projectile.type] = 1; + } - public override void SetDefaults() - { - Projectile.ignoreWater = true; - Projectile.width = 18; - Projectile.height = 18; - Projectile.aiStyle = -1; - Projectile.friendly = true; - Projectile.penetrate = 1; //-1 - Projectile.timeLeft = 300; - Projectile.scale = 1f; - Projectile.DamageType = DamageClass.Magic; - Projectile.extraUpdates = 1; - Projectile.alpha = 50; - } + public override void SetDefaults() + { + Projectile.ignoreWater = true; + Projectile.width = 18; + Projectile.height = 18; + Projectile.aiStyle = -1; + Projectile.friendly = true; + Projectile.penetrate = 1; //-1 + Projectile.timeLeft = 300; + Projectile.scale = 1f; + Projectile.DamageType = DamageClass.Magic; + Projectile.extraUpdates = 1; + Projectile.alpha = 50; + } - public override void Kill(int timeLeft) - { - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.Center.X, Projectile.Bottom.Y - 2f), 2, 2, 154, 0f, 0f, 38, Color.LightGreen, 1f); - dust.velocity = new Vector2(Main.rand.NextFloat(2) - 1f, Main.rand.NextFloat(2) - 1f); - dust.scale = 0.95f; - } + public override void Kill(int timeLeft) + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.Center.X, Projectile.Bottom.Y - 2f), 2, 2, 154, 0f, 0f, 38, Color.LightGreen, 1f); + dust.velocity = new Vector2(Main.rand.NextFloat(2) - 1f, Main.rand.NextFloat(2) - 1f); + dust.scale = 0.95f; + } - public override void AI() - { - Projectile.spriteDirection = ((int)Projectile.ai[0] % 2 == 0) ? 1 : -1; - Projectile.rotation -= Projectile.spriteDirection * 2.5f * Projectile.ai[1]; - Projectile.velocity.Y *= 1.005f + (Projectile.ai[0] / 1000); - } - } + public override void AI() + { + Projectile.spriteDirection = ((int)Projectile.ai[0] % 2 == 0) ? 1 : -1; + Projectile.rotation -= Projectile.spriteDirection * 2.5f * Projectile.ai[1]; + Projectile.velocity.Y *= 1.005f + (Projectile.ai[0] / 1000); + } + } } diff --git a/Projectiles/Weapons/PocketSandProj.cs b/Projectiles/Weapons/PocketSandProj.cs index e47f0c45..2a3347b3 100644 --- a/Projectiles/Weapons/PocketSandProj.cs +++ b/Projectiles/Weapons/PocketSandProj.cs @@ -5,71 +5,71 @@ namespace AssortedCrazyThings.Projectiles.Weapons { - [Content(ContentType.Weapons)] - public class PocketSandProj : AssProjectile - { - private static readonly int LifeTime = 30; + [Content(ContentType.Weapons)] + public class PocketSandProj : AssProjectile + { + private static readonly int LifeTime = 30; - public override string Texture - { - get - { - return "AssortedCrazyThings/Empty"; - } - } + public override string Texture + { + get + { + return "AssortedCrazyThings/Empty"; + } + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pocket Sand"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pocket Sand"); + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ThrowingKnife); - Projectile.aiStyle = 2; //6 for powder, 2 for throwing knife - Projectile.height = 20; - Projectile.width = 20; - Projectile.timeLeft = LifeTime; - Projectile.tileCollide = true; - Projectile.friendly = true; - Projectile.hostile = false; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ThrowingKnife); + Projectile.aiStyle = 2; //6 for powder, 2 for throwing knife + Projectile.height = 20; + Projectile.width = 20; + Projectile.timeLeft = LifeTime; + Projectile.tileCollide = true; + Projectile.friendly = true; + Projectile.hostile = false; + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (Main.rand.NextFloat() >= .50f) - { - target.AddBuff(BuffID.Confused, 120); //2 seconds, 50% chance - } - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (Main.rand.NextFloat() >= .50f) + { + target.AddBuff(BuffID.Confused, 120); //2 seconds, 50% chance + } + } - private void SpawnSandDust(Color color, Rectangle hitbox, Player player, float velox) - { - //the thick no-outline one that spreads - Dust dust = Dust.NewDustDirect(new Vector2((float)hitbox.X, (float)(hitbox.Y - player.height / 2)), hitbox.Width, hitbox.Height, 102, player.velocity.X * 0.2f + (Main.rand.NextBool() ? velox : -velox), player.velocity.Y * 0.2f, 150, color, 1f); - dust.noGravity = false; - dust.fadeIn = 0.8f; - //the outline one - dust = Dust.NewDustDirect(new Vector2((float)hitbox.X, (float)(hitbox.Y - player.height / 2)), hitbox.Width, hitbox.Height, 32, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 200, color, 0.8f); - dust.noGravity = true; - } + private void SpawnSandDust(Color color, Rectangle hitbox, Player player, float velox) + { + //the thick no-outline one that spreads + Dust dust = Dust.NewDustDirect(new Vector2((float)hitbox.X, (float)(hitbox.Y - player.height / 2)), hitbox.Width, hitbox.Height, 102, player.velocity.X * 0.2f + (Main.rand.NextBool() ? velox : -velox), player.velocity.Y * 0.2f, 150, color, 1f); + dust.noGravity = false; + dust.fadeIn = 0.8f; + //the outline one + dust = Dust.NewDustDirect(new Vector2((float)hitbox.X, (float)(hitbox.Y - player.height / 2)), hitbox.Width, hitbox.Height, 32, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 200, color, 0.8f); + dust.noGravity = true; + } - public override void ModifyDamageHitbox(ref Rectangle hitbox) - { - //increase hitbox used in colliding with NPCs while projectile life depletes - hitbox.Width += (int)((LifeTime - Projectile.timeLeft) * 1.5f); - hitbox.Height += (int)((LifeTime - Projectile.timeLeft) * 1.5f); - hitbox.X -= (int)((LifeTime - Projectile.timeLeft) * 1.5f / 2f); - hitbox.Y -= (int)((LifeTime - Projectile.timeLeft) * 1.5f / 2f); - } + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + //increase hitbox used in colliding with NPCs while projectile life depletes + hitbox.Width += (int)((LifeTime - Projectile.timeLeft) * 1.5f); + hitbox.Height += (int)((LifeTime - Projectile.timeLeft) * 1.5f); + hitbox.X -= (int)((LifeTime - Projectile.timeLeft) * 1.5f / 2f); + hitbox.Y -= (int)((LifeTime - Projectile.timeLeft) * 1.5f / 2f); + } - public override void PostAI() - { - //dont spawn the dust instantly when projectile spawns, give it 1/12th of a second - if (Projectile.timeLeft < LifeTime - 5) - { - SpawnSandDust(Color.White, Projectile.Hitbox, Projectile.GetOwner(), (LifeTime - Projectile.timeLeft) * 0.1f); - } - } - } + public override void PostAI() + { + //dont spawn the dust instantly when projectile spawns, give it 1/12th of a second + if (Projectile.timeLeft < LifeTime - 5) + { + SpawnSandDust(Color.White, Projectile.Hitbox, Projectile.GetOwner(), (LifeTime - Projectile.timeLeft) * 0.1f); + } + } + } } diff --git a/Projectiles/Weapons/SpazmatismFire.cs b/Projectiles/Weapons/SpazmatismFire.cs index 0117bb0e..5330ec38 100644 --- a/Projectiles/Weapons/SpazmatismFire.cs +++ b/Projectiles/Weapons/SpazmatismFire.cs @@ -3,30 +3,30 @@ namespace AssortedCrazyThings.Projectiles.Weapons { - [Content(ContentType.Weapons)] - public class SpazmatismFire : AssProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("'Handle with care'"); - } + [Content(ContentType.Weapons)] + public class SpazmatismFire : AssProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("'Handle with care'"); + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.EyeFire); - Projectile.aiStyle = 23; - Projectile.friendly = true; - Projectile.hostile = false; - //adding this makes the game select the AI that is meant for the Spazmatism cursed fire ai - AIType = ProjectileID.EyeFire; - } + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.EyeFire); + Projectile.aiStyle = 23; + Projectile.friendly = true; + Projectile.hostile = false; + //adding this makes the game select the AI that is meant for the Spazmatism cursed fire ai + AIType = ProjectileID.EyeFire; + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (Main.rand.NextFloat() >= .66f) - { - target.AddBuff(BuffID.CursedInferno, 180); //three full seconds, 33% chance - } - } - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (Main.rand.NextFloat() >= .66f) + { + target.AddBuff(BuffID.CursedInferno, 180); //three full seconds, 33% chance + } + } + } } diff --git a/Projectiles/Weapons/TrueLegendaryWoodenSwordProj.cs b/Projectiles/Weapons/TrueLegendaryWoodenSwordProj.cs index b1ccf51a..43f00382 100644 --- a/Projectiles/Weapons/TrueLegendaryWoodenSwordProj.cs +++ b/Projectiles/Weapons/TrueLegendaryWoodenSwordProj.cs @@ -1,69 +1,69 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.Audio; +using Terraria.ID; namespace AssortedCrazyThings.Projectiles.Weapons { - [Content(ContentType.Weapons)] - public class TrueLegendaryWoodenSwordProj : AssProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("True Legendary Wooden Sword"); - } + [Content(ContentType.Weapons)] + public class TrueLegendaryWoodenSwordProj : AssProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("True Legendary Wooden Sword"); + } - public override void SetDefaults() - { - Projectile.CloneDefaults(ProjectileID.ThrowingKnife); - Projectile.aiStyle = 2; //6 for powder, 2 for throwing knife - Projectile.height = 20; - Projectile.width = 20; - Projectile.alpha = 255; - //Projectile.penetrate = 2; - Projectile.tileCollide = true; - Projectile.friendly = true; - Projectile.hostile = false; + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.ThrowingKnife); + Projectile.aiStyle = 2; //6 for powder, 2 for throwing knife + Projectile.height = 20; + Projectile.width = 20; + Projectile.alpha = 255; + //Projectile.penetrate = 2; + Projectile.tileCollide = true; + Projectile.friendly = true; + Projectile.hostile = false; - //DrawOriginOffsetX = 0; - //DrawOffsetX = (int)0; - DrawOriginOffsetX = -(Projectile.width / 2 - 60f / 2); - DrawOffsetX = (int)-DrawOriginOffsetX * 2; - } + //DrawOriginOffsetX = 0; + //DrawOffsetX = (int)0; + DrawOriginOffsetX = -(Projectile.width / 2 - 60f / 2); + DrawOffsetX = (int)-DrawOriginOffsetX * 2; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - for (int i = 0; i < 10; i++) - { - Dust dust = Dust.NewDustDirect(Projectile.position - Vector2.Normalize(Projectile.velocity) * 30f, 50, 50, 169, Projectile.velocity.X, Projectile.velocity.Y, 100, Color.White, 1.25f); - dust.noGravity = true; - } - SoundEngine.PlaySound(SoundID.Dig, Projectile.position); - return true; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + for (int i = 0; i < 10; i++) + { + Dust dust = Dust.NewDustDirect(Projectile.position - Vector2.Normalize(Projectile.velocity) * 30f, 50, 50, 169, Projectile.velocity.X, Projectile.velocity.Y, 100, Color.White, 1.25f); + dust.noGravity = true; + } + SoundEngine.PlaySound(SoundID.Dig, Projectile.position); + return true; + } - public override void PostAI() - { - if (Projectile.ai[0] < 15) Projectile.ai[0] = 15; - if (Projectile.alpha > 0) - { - Projectile.alpha -= 25; - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; - } - } - else - { - //162 for "sparks" - //169 for just light - int dustType = 169; - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.Hitbox.X, Projectile.Hitbox.Y) - Vector2.Normalize(Projectile.velocity) * 40f, Projectile.Hitbox.Width, Projectile.Hitbox.Height, dustType, Projectile.velocity.X, Projectile.velocity.Y, 100, Color.White, 1.25f); - dust.noGravity = true; - } - Projectile.rotation = Projectile.velocity.ToRotation() + 0.785f; - //projectile.rotation = 0; - } - } + public override void PostAI() + { + if (Projectile.ai[0] < 15) Projectile.ai[0] = 15; + if (Projectile.alpha > 0) + { + Projectile.alpha -= 25; + if (Projectile.alpha < 0) + { + Projectile.alpha = 0; + } + } + else + { + //162 for "sparks" + //169 for just light + int dustType = 169; + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.Hitbox.X, Projectile.Hitbox.Y) - Vector2.Normalize(Projectile.velocity) * 40f, Projectile.Hitbox.Width, Projectile.Hitbox.Height, dustType, Projectile.velocity.X, Projectile.velocity.Y, 100, Color.White, 1.25f); + dust.noGravity = true; + } + Projectile.rotation = Projectile.velocity.ToRotation() + 0.785f; + //projectile.rotation = 0; + } + } } diff --git a/Tiles/CuteSlimeStatueTile.cs b/Tiles/CuteSlimeStatueTile.cs index 2ed3a898..43aa8474 100644 --- a/Tiles/CuteSlimeStatueTile.cs +++ b/Tiles/CuteSlimeStatueTile.cs @@ -10,111 +10,111 @@ namespace AssortedCrazyThings.Tiles { - [Content(ContentType.PlaceablesFunctional | ContentType.CuteSlimes)] - public class CuteSlimeStatueTile : DroppableTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileObsidianKill[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - //TileObjectData.newTile.StyleWrapLimit = 2; - //TileObjectData.newTile.StyleMultiplier = 2; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(1, 2); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 18 }; - - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; // allows to place it facing the same way as the player - TileObjectData.addAlternate(1); // facing right will use the second texture style - TileObjectData.addTile(Type); + [Content(ContentType.PlaceablesFunctional | ContentType.CuteSlimes)] + public class CuteSlimeStatueTile : DroppableTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileObsidianKill[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + //TileObjectData.newTile.StyleWrapLimit = 2; + //TileObjectData.newTile.StyleMultiplier = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 18 }; - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Statue"); - AddMapEntry(new Color(144, 148, 144), name); - DustType = 11; - } + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; // allows to place it facing the same way as the player + TileObjectData.addAlternate(1); // facing right will use the second texture style + TileObjectData.addTile(Type); - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ItemType); - } + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Statue"); + AddMapEntry(new Color(144, 148, 144), name); + DustType = 11; + } - private bool MechSpawn(float x, float y, int[] types) - { - int total = 0; - int veryClose = 0; - int fairlyClose = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.active && Array.IndexOf(types, npc.type) != -1) - { - total++; - float distance = new Vector2(x, y).Length(); - if (distance < 200) - { - veryClose++; - } - if (distance < 600f) - { - fairlyClose++; - } - } - } - if (veryClose < 3 && fairlyClose < 6) - { - return total < 10; - } - return false; - } + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ItemType); + } - private int CheckSpawns(float x, float y) - { - int npcType = -1; - if (MechSpawn(x, y, SlimePets.slimePetRegularNPCs.ToArray())) - { - npcType = Main.rand.Next(SlimePets.slimePetRegularNPCs.ToArray()); - } - return npcType; - } + private bool MechSpawn(float x, float y, int[] types) + { + int total = 0; + int veryClose = 0; + int fairlyClose = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active && Array.IndexOf(types, npc.type) != -1) + { + total++; + float distance = new Vector2(x, y).Length(); + if (distance < 200) + { + veryClose++; + } + if (distance < 600f) + { + fairlyClose++; + } + } + } + if (veryClose < 3 && fairlyClose < 6) + { + return total < 10; + } + return false; + } - public override void HitWire(int i, int j) - { - // Find the coordinates of top left tile square through math - Tile tile = Main.tile[i, j]; - int x = i - tile.TileFrameX / 18 % 36; - int y = j - tile.TileFrameY / 18; + private int CheckSpawns(float x, float y) + { + int npcType = -1; + if (MechSpawn(x, y, SlimePets.slimePetRegularNPCs.ToArray())) + { + npcType = Main.rand.Next(SlimePets.slimePetRegularNPCs.ToArray()); + } + return npcType; + } - Wiring.SkipWire(x, y); - Wiring.SkipWire(x, y + 1); - Wiring.SkipWire(x, y + 2); - Wiring.SkipWire(x + 1, y); - Wiring.SkipWire(x + 1, y + 1); - Wiring.SkipWire(x + 1, y + 2); + public override void HitWire(int i, int j) + { + // Find the coordinates of top left tile square through math + Tile tile = Main.tile[i, j]; + int x = i - tile.TileFrameX / 18 % 36; + int y = j - tile.TileFrameY / 18; - // We add 16 to x to spawn right between the 2 tiles. We also want to right on the ground in the y direction. - int spawnX = x * 16 + 16; - int spawnY = (y + 3) * 16; + Wiring.SkipWire(x, y); + Wiring.SkipWire(x, y + 1); + Wiring.SkipWire(x, y + 2); + Wiring.SkipWire(x + 1, y); + Wiring.SkipWire(x + 1, y + 1); + Wiring.SkipWire(x + 1, y + 2); - int npcIndex = -1; - int npcType = CheckSpawns(spawnX, spawnY); - // 30 is the time before it can be used again. - if (npcType != -1 && Wiring.CheckMech(x, y, 30)) - { - npcIndex = NPC.NewNPC(Wiring.GetNPCSource(i, j), spawnX, spawnY - 8, npcType); - } - if (npcIndex >= 0) - { - NPC npc = Main.npc[npcIndex]; - npc.value = 0f; - npc.npcSlots = 0f; - // Prevents Loot if NPCID.Sets.NoEarlymodeLootWhenSpawnedFromStatue and !Main.HardMode or NPCID.Sets.StatueSpawnedDropRarity != -1 and NextFloat() >= NPCID.Sets.StatueSpawnedDropRarity or killed by traps. - // Prevents CatchNPC - npc.SpawnedFromStatue = true; - } - } - } + // We add 16 to x to spawn right between the 2 tiles. We also want to right on the ground in the y direction. + int spawnX = x * 16 + 16; + int spawnY = (y + 3) * 16; + + int npcIndex = -1; + int npcType = CheckSpawns(spawnX, spawnY); + // 30 is the time before it can be used again. + if (npcType != -1 && Wiring.CheckMech(x, y, 30)) + { + npcIndex = NPC.NewNPC(Wiring.GetNPCSource(i, j), spawnX, spawnY - 8, npcType); + } + if (npcIndex >= 0) + { + NPC npc = Main.npc[npcIndex]; + npc.value = 0f; + npc.npcSlots = 0f; + // Prevents Loot if NPCID.Sets.NoEarlymodeLootWhenSpawnedFromStatue and !Main.HardMode or NPCID.Sets.StatueSpawnedDropRarity != -1 and NextFloat() >= NPCID.Sets.StatueSpawnedDropRarity or killed by traps. + // Prevents CatchNPC + npc.SpawnedFromStatue = true; + } + } + } } diff --git a/Tiles/HarvesterRelicTile.cs b/Tiles/HarvesterRelicTile.cs index 6531679a..a728bc18 100644 --- a/Tiles/HarvesterRelicTile.cs +++ b/Tiles/HarvesterRelicTile.cs @@ -2,8 +2,8 @@ namespace AssortedCrazyThings.Tiles { - public class HarvesterRelicTile : RelicTileBase - { - public override string Extra => "AssortedCrazyThings/Tiles/HarvesterRelicTile"; - } + public class HarvesterRelicTile : RelicTileBase + { + public override string Extra => "AssortedCrazyThings/Tiles/HarvesterRelicTile"; + } } diff --git a/Tiles/HarvesterTrophyTile.cs b/Tiles/HarvesterTrophyTile.cs index 8ef983a1..1995581f 100644 --- a/Tiles/HarvesterTrophyTile.cs +++ b/Tiles/HarvesterTrophyTile.cs @@ -8,25 +8,25 @@ namespace AssortedCrazyThings.Tiles { - [Content(ContentType.Bosses)] - public class HarvesterTrophyTile : DroppableTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; - TileID.Sets.FramesOnKillWall[Type] = true; + [Content(ContentType.Bosses)] + public class HarvesterTrophyTile : DroppableTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + TileID.Sets.FramesOnKillWall[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); - TileObjectData.addTile(Type); + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); + TileObjectData.addTile(Type); - AddMapEntry(new Color(120, 85, 60), Language.GetText("MapObject.Trophy")); - DustType = 7; - } + AddMapEntry(new Color(120, 85, 60), Language.GetText("MapObject.Trophy")); + DustType = 7; + } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemType); - } - } + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemType); + } + } } diff --git a/Tiles/Paintings/FieldsOfJoy.cs b/Tiles/Paintings/FieldsOfJoy.cs index d6b48ec3..322ddf71 100644 --- a/Tiles/Paintings/FieldsOfJoy.cs +++ b/Tiles/Paintings/FieldsOfJoy.cs @@ -1,5 +1,4 @@ using AssortedCrazyThings.Items.Placeable.Paintings; -using Terraria.ModLoader; namespace AssortedCrazyThings.Tiles.Paintings { diff --git a/Tiles/Paintings/PretentiousRock.cs b/Tiles/Paintings/PretentiousRock.cs index 2e8a7527..c912c257 100644 --- a/Tiles/Paintings/PretentiousRock.cs +++ b/Tiles/Paintings/PretentiousRock.cs @@ -1,5 +1,4 @@ using AssortedCrazyThings.Items.Placeable.Paintings; -using Terraria.ModLoader; namespace AssortedCrazyThings.Tiles.Paintings { diff --git a/Tiles/Paintings/SCP099.cs b/Tiles/Paintings/SCP099.cs index 7abe8a5d..faf7318a 100644 --- a/Tiles/Paintings/SCP099.cs +++ b/Tiles/Paintings/SCP099.cs @@ -1,5 +1,4 @@ using AssortedCrazyThings.Items.Placeable.Paintings; -using Terraria.ModLoader; namespace AssortedCrazyThings.Tiles.Paintings { diff --git a/Tiles/Paintings/SCP3515.cs b/Tiles/Paintings/SCP3515.cs index b8980e37..e9608242 100644 --- a/Tiles/Paintings/SCP3515.cs +++ b/Tiles/Paintings/SCP3515.cs @@ -1,5 +1,4 @@ using AssortedCrazyThings.Items.Placeable.Paintings; -using Terraria.ModLoader; namespace AssortedCrazyThings.Tiles.Paintings { diff --git a/Tiles/RelicTileBase.cs b/Tiles/RelicTileBase.cs index b9e54c10..596441be 100644 --- a/Tiles/RelicTileBase.cs +++ b/Tiles/RelicTileBase.cs @@ -1,149 +1,149 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; using Terraria; using Terraria.DataStructures; +using Terraria.Enums; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -using Microsoft.Xna.Framework.Graphics; -using Terraria.Enums; -using System; -using ReLogic.Content; -using Terraria.Localization; namespace AssortedCrazyThings.Tiles { - [Content(ContentType.Bosses)] //Relic on a non-boss is not a thing - public abstract class RelicTileBase : DroppableTile where T : ModItem - { - //Every relic has its own extra floating part, should be 50x50 - public abstract string Extra { get; } - - //All relics use the same pedestal texture - public override string Texture => "AssortedCrazyThings/Tiles/RelicTileBase_ACT"; - - public Asset ExtraAsset; - - public override void Unload() - { - //Unload the special texture displayed on the pedestal - ExtraAsset = null; - } - - public override void SetStaticDefaults() - { - if (!Main.dedServ) - { - //Cache the special texture displayed on the pedestal - ExtraAsset = ModContent.Request(Extra); - } - - Main.tileShine[Type] = 400; //Responsible for golden particles - Main.tileFrameImportant[Type] = true; //Any multitile requires this - TileID.Sets.InteractibleByNPCs[Type] = true; //Town NPCs will behave differently when this tile is nearby - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); //Relics are 3x4 - TileObjectData.newTile.LavaDeath = false; //Does not break when lava touches it - TileObjectData.newTile.DrawYOffset = 2; //So the tile sinks into the ground - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; //Player faces to the left - TileObjectData.newTile.StyleHorizontal = false; //Based on how the alternate sprites are positioned on the sprite (by default, true) - - //If you decide to make your tile the same way vanilla does (one tile, different place styles), you need these, aswell as the code in SetDrawPositions - //TileObjectData.newTile.StyleWrapLimitVisualOverride = 2; - //TileObjectData.newTile.StyleMultiplier = 2; - //TileObjectData.newTile.StyleWrapLimit = 2; - //TileObjectData.newTile.styleLineSkipVisualOverride = 0; - - //Register an alternate tile data with flipped direction - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); //Copy everything from above, saves us some code - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; //Player faces to the right - TileObjectData.addAlternate(1); - - //Register the tile data itself - TileObjectData.addTile(Type); - - //Register map name and color - //"MapObject.Relic" refers to the translation key for the vanilla "Relic" text - AddMapEntry(new Color(233, 207, 94), Language.GetText("MapObject.Relic")); - } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemType); - } - - public override bool CreateDust(int i, int j, ref int type) - { - return false; - } - - //public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - //{ - // //Only required If you decide to make your tile the same way vanilla does (one tile, different place styles), you need this - - // //This preserves its original frameX/Y which is required for determining the correct texture floating on the pedestal, but makes it draw properly - // tileFrameX %= 18 * 3; //Clamps the frameX - // tileFrameY %= 18 * 4 * 2; //Clamps the frameY (two horizontal aligned place styles, hence * 2) - //} - - public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) - { - //Since this tile does not have the hovering part on its sheet, we have to animate it ourselves - //Therefore we register the top-left of the tile as a "special point" - //This allows us to draw things in SpecialDraw - if (drawData.tileFrameX % (18 * 3) == 0 && drawData.tileFrameY % (18 * 4) == 0) - { - Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); - } - } - - public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) - { - //This is lighting-mode specific, always include this if you draw tiles manually - Vector2 offScreen = new Vector2(Main.offScreenRange); - if (Main.drawToScreen) - { - offScreen = Vector2.Zero; - } - - //Take the tile, check if it actually exists and is ours - Point p = new Point(i, j); - Tile tile = Main.tile[p.X, p.Y]; - if (tile != null && tile.HasTile && tile.TileFrameX % (18 * 3) == 0 && tile.TileFrameX % (18 * 4) == 0) - { - //Get the initial draw parameters - Texture2D texture = ExtraAsset.Value; - - int frameY = tile.TileFrameX / (18 * 3); - int horizontalFrames = 1; - int verticalFrames = 1; //Increase this number to match the amount of frames you have on your extra sheet - Rectangle frame = texture.Frame(horizontalFrames, verticalFrames, 0, frameY); - - Vector2 origin = frame.Size() / 2f; - Vector2 worldPos = p.ToWorldCoordinates(24f, 64f); - - Color color = Lighting.GetColor(p.X, p.Y); - - bool direction = tile.TileFrameY / (18 * 4) != 0; //This is related to the alternate tile data we registered before - SpriteEffects effects = direction ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - //Some math magic to make it smoothly move up and down over time - const float TwoPi = (float)Math.PI * 2f; - float offset = (float)Math.Sin(Main.GlobalTimeWrappedHourly * TwoPi / 5f); - Vector2 drawPos = worldPos + offScreen - Main.screenPosition + new Vector2(0f, -40f) + new Vector2(0f, offset * 4f); - - //Draw the main texture - spriteBatch.Draw(texture, drawPos, frame, color, 0f, origin, 1f, effects, 0f); - - //Draw the periodic glow effect - float scale = (float)Math.Sin(Main.GlobalTimeWrappedHourly * TwoPi / 2f) * 0.3f + 0.7f; - Color effectColor = color; - effectColor.A = 0; - effectColor = effectColor * 0.1f * scale; - for (float num5 = 0f; num5 < 1f; num5 += 355f / (678f * (float)Math.PI)) - { - spriteBatch.Draw(texture, drawPos + (TwoPi * num5).ToRotationVector2() * (6f + offset * 2f), frame, effectColor, 0f, origin, 1f, effects, 0f); - } - } - } - } + [Content(ContentType.Bosses)] //Relic on a non-boss is not a thing + public abstract class RelicTileBase : DroppableTile where T : ModItem + { + //Every relic has its own extra floating part, should be 50x50 + public abstract string Extra { get; } + + //All relics use the same pedestal texture + public override string Texture => "AssortedCrazyThings/Tiles/RelicTileBase_ACT"; + + public Asset ExtraAsset; + + public override void Unload() + { + //Unload the special texture displayed on the pedestal + ExtraAsset = null; + } + + public override void SetStaticDefaults() + { + if (!Main.dedServ) + { + //Cache the special texture displayed on the pedestal + ExtraAsset = ModContent.Request(Extra); + } + + Main.tileShine[Type] = 400; //Responsible for golden particles + Main.tileFrameImportant[Type] = true; //Any multitile requires this + TileID.Sets.InteractibleByNPCs[Type] = true; //Town NPCs will behave differently when this tile is nearby + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); //Relics are 3x4 + TileObjectData.newTile.LavaDeath = false; //Does not break when lava touches it + TileObjectData.newTile.DrawYOffset = 2; //So the tile sinks into the ground + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; //Player faces to the left + TileObjectData.newTile.StyleHorizontal = false; //Based on how the alternate sprites are positioned on the sprite (by default, true) + + //If you decide to make your tile the same way vanilla does (one tile, different place styles), you need these, aswell as the code in SetDrawPositions + //TileObjectData.newTile.StyleWrapLimitVisualOverride = 2; + //TileObjectData.newTile.StyleMultiplier = 2; + //TileObjectData.newTile.StyleWrapLimit = 2; + //TileObjectData.newTile.styleLineSkipVisualOverride = 0; + + //Register an alternate tile data with flipped direction + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); //Copy everything from above, saves us some code + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; //Player faces to the right + TileObjectData.addAlternate(1); + + //Register the tile data itself + TileObjectData.addTile(Type); + + //Register map name and color + //"MapObject.Relic" refers to the translation key for the vanilla "Relic" text + AddMapEntry(new Color(233, 207, 94), Language.GetText("MapObject.Relic")); + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemType); + } + + public override bool CreateDust(int i, int j, ref int type) + { + return false; + } + + //public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + //{ + // //Only required If you decide to make your tile the same way vanilla does (one tile, different place styles), you need this + + // //This preserves its original frameX/Y which is required for determining the correct texture floating on the pedestal, but makes it draw properly + // tileFrameX %= 18 * 3; //Clamps the frameX + // tileFrameY %= 18 * 4 * 2; //Clamps the frameY (two horizontal aligned place styles, hence * 2) + //} + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + //Since this tile does not have the hovering part on its sheet, we have to animate it ourselves + //Therefore we register the top-left of the tile as a "special point" + //This allows us to draw things in SpecialDraw + if (drawData.tileFrameX % (18 * 3) == 0 && drawData.tileFrameY % (18 * 4) == 0) + { + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); + } + } + + public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) + { + //This is lighting-mode specific, always include this if you draw tiles manually + Vector2 offScreen = new Vector2(Main.offScreenRange); + if (Main.drawToScreen) + { + offScreen = Vector2.Zero; + } + + //Take the tile, check if it actually exists and is ours + Point p = new Point(i, j); + Tile tile = Main.tile[p.X, p.Y]; + if (tile != null && tile.HasTile && tile.TileFrameX % (18 * 3) == 0 && tile.TileFrameX % (18 * 4) == 0) + { + //Get the initial draw parameters + Texture2D texture = ExtraAsset.Value; + + int frameY = tile.TileFrameX / (18 * 3); + int horizontalFrames = 1; + int verticalFrames = 1; //Increase this number to match the amount of frames you have on your extra sheet + Rectangle frame = texture.Frame(horizontalFrames, verticalFrames, 0, frameY); + + Vector2 origin = frame.Size() / 2f; + Vector2 worldPos = p.ToWorldCoordinates(24f, 64f); + + Color color = Lighting.GetColor(p.X, p.Y); + + bool direction = tile.TileFrameY / (18 * 4) != 0; //This is related to the alternate tile data we registered before + SpriteEffects effects = direction ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + //Some math magic to make it smoothly move up and down over time + const float TwoPi = (float)Math.PI * 2f; + float offset = (float)Math.Sin(Main.GlobalTimeWrappedHourly * TwoPi / 5f); + Vector2 drawPos = worldPos + offScreen - Main.screenPosition + new Vector2(0f, -40f) + new Vector2(0f, offset * 4f); + + //Draw the main texture + spriteBatch.Draw(texture, drawPos, frame, color, 0f, origin, 1f, effects, 0f); + + //Draw the periodic glow effect + float scale = (float)Math.Sin(Main.GlobalTimeWrappedHourly * TwoPi / 2f) * 0.3f + 0.7f; + Color effectColor = color; + effectColor.A = 0; + effectColor = effectColor * 0.1f * scale; + for (float num5 = 0f; num5 < 1f; num5 += 355f / (678f * (float)Math.PI)) + { + spriteBatch.Draw(texture, drawPos + (TwoPi * num5).ToRotationVector2() * (6f + offset * 2f), frame, effectColor, 0f, origin, 1f, effects, 0f); + } + } + } + } } diff --git a/Tiles/SlimeBeaconTile.cs b/Tiles/SlimeBeaconTile.cs index fea75fbd..ce9bed5f 100644 --- a/Tiles/SlimeBeaconTile.cs +++ b/Tiles/SlimeBeaconTile.cs @@ -1,89 +1,89 @@ using AssortedCrazyThings.Items.Placeable; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; +using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Terraria.GameContent.ObjectInteractions; namespace AssortedCrazyThings.Tiles { - [Content(ContentType.PlaceablesFunctional)] - public class SlimeBeaconTile : DroppableTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileSolid[Type] = false; - TileID.Sets.HasOutlines[Type] = true; - TileID.Sets.DisableSmartCursor[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(1, 2); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 18 }; - TileObjectData.addTile(Type); - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Slime Beacon"); - AddMapEntry(new Color(75, 139, 166), name); - DustType = 1; - AnimationFrameHeight = 56; - } + [Content(ContentType.PlaceablesFunctional)] + public class SlimeBeaconTile : DroppableTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileID.Sets.HasOutlines[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 18 }; + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Slime Beacon"); + AddMapEntry(new Color(75, 139, 166), name); + DustType = 1; + AnimationFrameHeight = 56; + } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ItemType); - AssWorld.DisableSlimeRainSky(); - } + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ItemType); + AssWorld.DisableSlimeRainSky(); + } - //you need these four things for the outline to work: - //_Highlight.png - //TileID.Sets.HasOutlines[Type] = true; - //TileID.Sets.DisableSmartCursor[Type] = true; - //and this hook - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) - { - return true; - } + //you need these four things for the outline to work: + //_Highlight.png + //TileID.Sets.HasOutlines[Type] = true; + //TileID.Sets.DisableSmartCursor[Type] = true; + //and this hook + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return true; + } - public override void AnimateTile(ref int frame, ref int frameCounter) - { - if (AssWorld.slimeRainSky || Main.slimeRain) - { - if (++frameCounter >= 8) - { - frameCounter = 0; - frame = (++frame - 1) % 8 + 1; //go from frame 1 to 8 - } - } - else - { - frame = 0; - } - } + public override void AnimateTile(ref int frame, ref int frameCounter) + { + if (AssWorld.slimeRainSky || Main.slimeRain) + { + if (++frameCounter >= 8) + { + frameCounter = 0; + frame = (++frame - 1) % 8 + 1; //go from frame 1 to 8 + } + } + else + { + frame = 0; + } + } - public override bool RightClick(int i, int j) - { - SoundEngine.PlaySound(SoundID.Mech, i * 16, j * 16, 0); - if (Main.netMode == NetmodeID.MultiplayerClient) - { - CombatText.NewText(Main.LocalPlayer.getRect(), new Color(255, 100, 30, 255), "NOT IN MULTIPLAYER"); - } - else - { - AssWorld.ToggleSlimeRainSky(); - } - return true; - } + public override bool RightClick(int i, int j) + { + SoundEngine.PlaySound(SoundID.Mech, i * 16, j * 16, 0); + if (Main.netMode == NetmodeID.MultiplayerClient) + { + CombatText.NewText(Main.LocalPlayer.getRect(), new Color(255, 100, 30, 255), "NOT IN MULTIPLAYER"); + } + else + { + AssWorld.ToggleSlimeRainSky(); + } + return true; + } - public override void MouseOver(int i, int j) - { - Player player = Main.LocalPlayer; - player.mouseInterface = true; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = ItemType; - } - } + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.mouseInterface = true; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ItemType; + } + } } diff --git a/Tiles/StarRodTile.cs b/Tiles/StarRodTile.cs index f7b9d4a2..9b392487 100644 --- a/Tiles/StarRodTile.cs +++ b/Tiles/StarRodTile.cs @@ -1,363 +1,363 @@ +using AssortedCrazyThings.Base; +using AssortedCrazyThings.Buffs; using AssortedCrazyThings.Items.Placeable; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Enums; -using Terraria.Audio; -using ReLogic.Content; -using Microsoft.Xna.Framework.Graphics; -using AssortedCrazyThings.Base; -using AssortedCrazyThings.Buffs; -using System; -using Terraria.GameContent.ObjectInteractions; namespace AssortedCrazyThings.Tiles { - //Classes handling player nearby state below - [Content(ContentType.PlaceablesFunctional)] - public class StarRodTile : DroppableTile - { - public const int Height = 4; - public const int TotalHeight = 18 * Height; - public const int Width = 2; - public const int TotalWidth = 18 * Width; - - public static Asset glowmaskAsset; - public static Asset pulseAsset; - - public override void Load() - { - if (!Main.dedServ) - { - glowmaskAsset = ModContent.Request(Texture + "_Glowmask"); - pulseAsset = ModContent.Request(Texture + "_Pulse"); - } - } - - public override void Unload() - { - glowmaskAsset = null; - pulseAsset = null; - } - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileSolid[Type] = false; - Main.tileLavaDeath[Type] = false; - TileID.Sets.HasOutlines[Type] = true; - TileID.Sets.DisableSmartCursor[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); - TileObjectData.newTile.Height = Height; - TileObjectData.newTile.Origin = new Point16(Width - 1, Height - 1); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; - TileObjectData.newTile.AnchorInvalidTiles = new[] { 127 }; - TileObjectData.newTile.DrawYOffset = 2; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = false; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); - TileObjectData.addTile(Type); - - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Star Rod"); - AddMapEntry(new Color(75, 80, 75), name); - DustType = 1; - } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, TotalWidth, TotalHeight, ItemType); - } - - //you need these four things for the outline to work: - //_Highlight.png - //TileID.Sets.HasOutlines[Type] = true; - //TileID.Sets.DisableSmartCursor[Type] = true; - //and this hook - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) - { - return true; - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - Tile tile = Main.tile[i, j]; - tileFrameY = (short)(tile.TileFrameY % TotalHeight); - } - - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Tile tile = Main.tile[i, j]; - Texture2D texture = Main.instance.TilesRenderer.GetTileDrawTexture(tile, i, j); - Vector2 zero = new Vector2(Main.offScreenRange); - if (Main.drawToScreen) - { - zero = Vector2.Zero; - } - - int width = 16; - int height = 16; - int offsetY = 2; - short frameX = tile.TileFrameX; - short frameY = tile.TileFrameY; - - TileLoader.SetDrawPositions(i, j, ref width, ref offsetY, ref height, ref frameX, ref frameY); - - Color color = Lighting.GetColor(i, j); - Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; - pos.Y += offsetY; - Rectangle frame = new Rectangle(frameX, frameY, width, height); - spriteBatch.Draw(texture, pos, frame, color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); - - //Draw glowmask - bool isEnabled = IsEnabled(i, j); - if (isEnabled) - { - spriteBatch.Draw(glowmaskAsset.Value, pos, frame, Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); - } - - //Draw pulse - if (CanBeActive(i, j)) - { - //Main.GlobalTimeWrappedHourly basically counts in full seconds. 1f = 1 second - Color pulseColor = Color.White; - float colorMult = (float)Math.Sin(Main.GlobalTimeWrappedHourly / 2.5f * MathHelper.TwoPi) * 0.5f + 0.5f; - colorMult *= 0.5f; //by default from 0 to 0.5f - - if (isEnabled) - { - colorMult *= 1.4f; - colorMult += 0.3f; - } - pulseColor *= colorMult; - pulseColor.A = Math.Max((byte)100, pulseColor.A); //So its pulsating visibly even when fully lighted - - spriteBatch.Draw(pulseAsset.Value, pos, frame, pulseColor, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); - } - - AssUtils.DrawTileHighlight(spriteBatch, i, j, Type, color, pos, frame); - - return false; - } - - public override bool RightClick(int i, int j) - { - SoundEngine.PlaySound(SoundID.Mech, i * 16, j * 16, 0); - HitWire(i, j); - return true; - } - - public override void HitWire(int i, int j) - { - int x = i - Main.tile[i, j].TileFrameX / 18 % Width; - int y = j - Main.tile[i, j].TileFrameY / 18 % Height; - int change = TotalHeight; //frameY stores the state - if (!IsEnabled(x, y)) - { - change = -change; - } - - Tile tile; - for (int l = x; l < x + Width; l++) - { - for (int m = y; m < y + Height; m++) - { - tile = Framing.GetTileSafely(l, m); - if (tile.HasTile && tile.TileType == Type) - { - tile.TileFrameY = (short)(tile.TileFrameY + change); - } - } - } - - if (Wiring.running) - { - Wiring.SkipWire(x, y + 0); - Wiring.SkipWire(x, y + 1); - Wiring.SkipWire(x, y + 2); - Wiring.SkipWire(x, y + 3); - Wiring.SkipWire(x + 1, y + 0); - Wiring.SkipWire(x + 1, y + 1); - Wiring.SkipWire(x + 1, y + 2); - Wiring.SkipWire(x + 1, y + 3); - } - NetMessage.SendTileSquare(-1, x, y + 2, 4); - } - - public override void MouseOver(int i, int j) - { - Player player = Main.LocalPlayer; - player.mouseInterface = true; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = ItemType; - } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (IsEnabled(i, j) && CanBeActive(i, j)) - { - Main.LocalPlayer.GetModPlayer().starRodTileNearby = true; - } - } - - /// - /// If the tile is able to do its thing (regardless of state) - /// - private static bool CanBeActive(int i, int j) - { - return !Main.dayTime && j < Main.worldSurface; - } - - /// - /// If the tile is enabled (by default or by the player on right click) - /// - private static bool IsEnabled(int i, int j) - { - return Main.tile[i, j].TileFrameY < TotalHeight; - } - } - - [Content(ContentType.PlaceablesFunctional)] - public class StarRodModSystem : AssSystem - { - public override void ResetNearbyTileEffects() - { - Main.LocalPlayer.GetModPlayer().starRodTileNearby = false; - } - } - - //Responsible for x-axis repositioning spawned falling star spawners towards a suitable location - [Content(ContentType.PlaceablesFunctional)] - public class StarRodGlobalProjectile : AssGlobalProjectile - { - public const float DetectionDistX = 1920 * 5; //5 screens in either direction - - public override bool AppliesToEntity(Projectile entity, bool lateInstantiation) - { - return entity.type == ProjectileID.FallingStarSpawner; - } - - public override bool InstancePerEntity => true; - - private bool firstTick = false; - - public override bool PreAI(Projectile projectile) - { - //Modified event rate messes with the timer increment, need safer detection (at the start of AI) - if (firstTick) - { - return true; - } - firstTick = true; - - if (projectile.owner != Main.myPlayer) - { - return true; - } - - if (!TryGetRedirectX(projectile, DetectionDistX, out float redirectX, out _)) - { - return true; - } - - projectile.position.X = redirectX; - if (Math.Abs(projectile.velocity.X) > 2.5f) - { - //Anything above this would land outside the screen, so reduce it - projectile.velocity.X *= 0.5f; - } - - return true; - } - - private static bool TryGetRedirectX(Projectile projectile, float detectionDistX, out float redirectX, out float distX) - { - redirectX = 0; - - //Find nearest player in range of a star rod - float maxDistX = float.MaxValue; - distX = float.MaxValue; - for (int i = 0; i < Main.maxPlayers; i++) - { - Player player = Main.player[i]; - if (!player.active || player.dead) - { - continue; - } - - if (!player.GetModPlayer().starRodTileWorking) - { - continue; - } - - distX = Math.Abs(projectile.Center.X - player.Center.X); - if (distX < maxDistX && distX < detectionDistX) - { - maxDistX = distX; - redirectX = player.Center.X; - } - } - - return redirectX != 0; - } - - //For reference. Spawned by the server - //private void VanillaFallingStarSpawnerAI(Projectile projectile) - //{ - // if (Main.dayTime) - // { - // projectile.Kill(); - // return; - // } - - // projectile.ai[0] += (float)Main.desiredWorldEventsUpdateRate; - // if (projectile.localAI[0] == 0f && Main.netMode != 2) - // { - // projectile.localAI[0] = 1f; - // if ((double)Main.LocalPlayer.position.Y < Main.worldSurface * 16.0) - // Star.StarFall(projectile.position.X); - // } - - // if (projectile.owner != Main.myPlayer || !(projectile.ai[0] >= 180f)) - // return; - - // if (projectile.ai[1] > -1f) - // { - // projectile.velocity.X *= 0.35f; - // if (projectile.Center.X < Main.player[(int)projectile.ai[1]].Center.X) - // projectile.velocity.X = Math.Abs(projectile.velocity.X); - // else - // projectile.velocity.X = 0f - Math.Abs(projectile.velocity.X); - // } - - // Projectile.NewProjectile(projectile.GetProjectileSource_FromThis(), projectile.position.X, projectile.position.Y, projectile.velocity.X, projectile.velocity.Y, 12, 1000, 10f, Main.myPlayer); - // projectile.Kill(); - //} - } - - [Content(ContentType.PlaceablesFunctional)] - public class StarRodModPlayer : AssPlayerBase - { - public bool starRodTileNearby = false; //Reset in ModSystem, clientside - - public bool starRodTileWorking = false; //All-side, set by the buff - - public override void ResetEffects() - { - starRodTileWorking = false; - } - - public override void PreUpdateBuffs() - { - if (starRodTileNearby) - { - Player.AddBuff(ModContent.BuffType(), 2, quiet: false); - } - } - } + //Classes handling player nearby state below + [Content(ContentType.PlaceablesFunctional)] + public class StarRodTile : DroppableTile + { + public const int Height = 4; + public const int TotalHeight = 18 * Height; + public const int Width = 2; + public const int TotalWidth = 18 * Width; + + public static Asset glowmaskAsset; + public static Asset pulseAsset; + + public override void Load() + { + if (!Main.dedServ) + { + glowmaskAsset = ModContent.Request(Texture + "_Glowmask"); + pulseAsset = ModContent.Request(Texture + "_Pulse"); + } + } + + public override void Unload() + { + glowmaskAsset = null; + pulseAsset = null; + } + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLavaDeath[Type] = false; + TileID.Sets.HasOutlines[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); + TileObjectData.newTile.Height = Height; + TileObjectData.newTile.Origin = new Point16(Width - 1, Height - 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.AnchorInvalidTiles = new[] { 127 }; + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.addTile(Type); + + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Star Rod"); + AddMapEntry(new Color(75, 80, 75), name); + DustType = 1; + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, TotalWidth, TotalHeight, ItemType); + } + + //you need these four things for the outline to work: + //_Highlight.png + //TileID.Sets.HasOutlines[Type] = true; + //TileID.Sets.DisableSmartCursor[Type] = true; + //and this hook + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return true; + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + Tile tile = Main.tile[i, j]; + tileFrameY = (short)(tile.TileFrameY % TotalHeight); + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + Tile tile = Main.tile[i, j]; + Texture2D texture = Main.instance.TilesRenderer.GetTileDrawTexture(tile, i, j); + Vector2 zero = new Vector2(Main.offScreenRange); + if (Main.drawToScreen) + { + zero = Vector2.Zero; + } + + int width = 16; + int height = 16; + int offsetY = 2; + short frameX = tile.TileFrameX; + short frameY = tile.TileFrameY; + + TileLoader.SetDrawPositions(i, j, ref width, ref offsetY, ref height, ref frameX, ref frameY); + + Color color = Lighting.GetColor(i, j); + Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; + pos.Y += offsetY; + Rectangle frame = new Rectangle(frameX, frameY, width, height); + spriteBatch.Draw(texture, pos, frame, color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + + //Draw glowmask + bool isEnabled = IsEnabled(i, j); + if (isEnabled) + { + spriteBatch.Draw(glowmaskAsset.Value, pos, frame, Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + } + + //Draw pulse + if (CanBeActive(i, j)) + { + //Main.GlobalTimeWrappedHourly basically counts in full seconds. 1f = 1 second + Color pulseColor = Color.White; + float colorMult = (float)Math.Sin(Main.GlobalTimeWrappedHourly / 2.5f * MathHelper.TwoPi) * 0.5f + 0.5f; + colorMult *= 0.5f; //by default from 0 to 0.5f + + if (isEnabled) + { + colorMult *= 1.4f; + colorMult += 0.3f; + } + pulseColor *= colorMult; + pulseColor.A = Math.Max((byte)100, pulseColor.A); //So its pulsating visibly even when fully lighted + + spriteBatch.Draw(pulseAsset.Value, pos, frame, pulseColor, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + } + + AssUtils.DrawTileHighlight(spriteBatch, i, j, Type, color, pos, frame); + + return false; + } + + public override bool RightClick(int i, int j) + { + SoundEngine.PlaySound(SoundID.Mech, i * 16, j * 16, 0); + HitWire(i, j); + return true; + } + + public override void HitWire(int i, int j) + { + int x = i - Main.tile[i, j].TileFrameX / 18 % Width; + int y = j - Main.tile[i, j].TileFrameY / 18 % Height; + int change = TotalHeight; //frameY stores the state + if (!IsEnabled(x, y)) + { + change = -change; + } + + Tile tile; + for (int l = x; l < x + Width; l++) + { + for (int m = y; m < y + Height; m++) + { + tile = Framing.GetTileSafely(l, m); + if (tile.HasTile && tile.TileType == Type) + { + tile.TileFrameY = (short)(tile.TileFrameY + change); + } + } + } + + if (Wiring.running) + { + Wiring.SkipWire(x, y + 0); + Wiring.SkipWire(x, y + 1); + Wiring.SkipWire(x, y + 2); + Wiring.SkipWire(x, y + 3); + Wiring.SkipWire(x + 1, y + 0); + Wiring.SkipWire(x + 1, y + 1); + Wiring.SkipWire(x + 1, y + 2); + Wiring.SkipWire(x + 1, y + 3); + } + NetMessage.SendTileSquare(-1, x, y + 2, 4); + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.mouseInterface = true; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ItemType; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (IsEnabled(i, j) && CanBeActive(i, j)) + { + Main.LocalPlayer.GetModPlayer().starRodTileNearby = true; + } + } + + /// + /// If the tile is able to do its thing (regardless of state) + /// + private static bool CanBeActive(int i, int j) + { + return !Main.dayTime && j < Main.worldSurface; + } + + /// + /// If the tile is enabled (by default or by the player on right click) + /// + private static bool IsEnabled(int i, int j) + { + return Main.tile[i, j].TileFrameY < TotalHeight; + } + } + + [Content(ContentType.PlaceablesFunctional)] + public class StarRodModSystem : AssSystem + { + public override void ResetNearbyTileEffects() + { + Main.LocalPlayer.GetModPlayer().starRodTileNearby = false; + } + } + + //Responsible for x-axis repositioning spawned falling star spawners towards a suitable location + [Content(ContentType.PlaceablesFunctional)] + public class StarRodGlobalProjectile : AssGlobalProjectile + { + public const float DetectionDistX = 1920 * 5; //5 screens in either direction + + public override bool AppliesToEntity(Projectile entity, bool lateInstantiation) + { + return entity.type == ProjectileID.FallingStarSpawner; + } + + public override bool InstancePerEntity => true; + + private bool firstTick = false; + + public override bool PreAI(Projectile projectile) + { + //Modified event rate messes with the timer increment, need safer detection (at the start of AI) + if (firstTick) + { + return true; + } + firstTick = true; + + if (projectile.owner != Main.myPlayer) + { + return true; + } + + if (!TryGetRedirectX(projectile, DetectionDistX, out float redirectX, out _)) + { + return true; + } + + projectile.position.X = redirectX; + if (Math.Abs(projectile.velocity.X) > 2.5f) + { + //Anything above this would land outside the screen, so reduce it + projectile.velocity.X *= 0.5f; + } + + return true; + } + + private static bool TryGetRedirectX(Projectile projectile, float detectionDistX, out float redirectX, out float distX) + { + redirectX = 0; + + //Find nearest player in range of a star rod + float maxDistX = float.MaxValue; + distX = float.MaxValue; + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (!player.active || player.dead) + { + continue; + } + + if (!player.GetModPlayer().starRodTileWorking) + { + continue; + } + + distX = Math.Abs(projectile.Center.X - player.Center.X); + if (distX < maxDistX && distX < detectionDistX) + { + maxDistX = distX; + redirectX = player.Center.X; + } + } + + return redirectX != 0; + } + + //For reference. Spawned by the server + //private void VanillaFallingStarSpawnerAI(Projectile projectile) + //{ + // if (Main.dayTime) + // { + // projectile.Kill(); + // return; + // } + + // projectile.ai[0] += (float)Main.desiredWorldEventsUpdateRate; + // if (projectile.localAI[0] == 0f && Main.netMode != 2) + // { + // projectile.localAI[0] = 1f; + // if ((double)Main.LocalPlayer.position.Y < Main.worldSurface * 16.0) + // Star.StarFall(projectile.position.X); + // } + + // if (projectile.owner != Main.myPlayer || !(projectile.ai[0] >= 180f)) + // return; + + // if (projectile.ai[1] > -1f) + // { + // projectile.velocity.X *= 0.35f; + // if (projectile.Center.X < Main.player[(int)projectile.ai[1]].Center.X) + // projectile.velocity.X = Math.Abs(projectile.velocity.X); + // else + // projectile.velocity.X = 0f - Math.Abs(projectile.velocity.X); + // } + + // Projectile.NewProjectile(projectile.GetProjectileSource_FromThis(), projectile.position.X, projectile.position.Y, projectile.velocity.X, projectile.velocity.Y, 12, 1000, 10f, Main.myPlayer); + // projectile.Kill(); + //} + } + + [Content(ContentType.PlaceablesFunctional)] + public class StarRodModPlayer : AssPlayerBase + { + public bool starRodTileNearby = false; //Reset in ModSystem, clientside + + public bool starRodTileWorking = false; //All-side, set by the buff + + public override void ResetEffects() + { + starRodTileWorking = false; + } + + public override void PreUpdateBuffs() + { + if (starRodTileNearby) + { + Player.AddBuff(ModContent.BuffType(), 2, quiet: false); + } + } + } } diff --git a/Tiles/VanityDresserTile.cs b/Tiles/VanityDresserTile.cs index 05c45592..5b5ea5c3 100644 --- a/Tiles/VanityDresserTile.cs +++ b/Tiles/VanityDresserTile.cs @@ -9,70 +9,70 @@ namespace AssortedCrazyThings.Tiles { - [Content(ContentType.PlaceablesFunctional | ContentType.DroppedPets | ContentType.OtherPets, needsAllToFilter: true)] - public class VanityDresserTile : DroppableTile - { - public override void SetStaticDefaults() - { - Main.tileSolidTop[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new[] { 16, 16 }; - TileObjectData.newTile.AnchorInvalidTiles = new[] { 127 }; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); - TileObjectData.addTile(Type); - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Costume Dresser"); - AddMapEntry(new Color(200, 200, 200), name); - DustType = 11; - TileID.Sets.DisableSmartCursor[Type] = true; - } + [Content(ContentType.PlaceablesFunctional | ContentType.DroppedPets | ContentType.OtherPets, needsAllToFilter: true)] + public class VanityDresserTile : DroppableTile + { + public override void SetStaticDefaults() + { + Main.tileSolidTop[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileLavaDeath[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16 }; + TileObjectData.newTile.AnchorInvalidTiles = new[] { 127 }; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.addTile(Type); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Costume Dresser"); + AddMapEntry(new Color(200, 200, 200), name); + DustType = 11; + TileID.Sets.DisableSmartCursor[Type] = true; + } - private void MouseOverCombined(bool close) - { - Player player = Main.LocalPlayer; - player.mouseInterface = true; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = ModContent.ItemType(); - player.GetModPlayer().mouseoveredDresser = true; - if (close && player.itemAnimation == 0) - { - // "\n[c/"+ (Color.Orange * (Main.mouseTextColor / 255f)).Hex3() + ":\nCostume Dresser]" doesnt work cause chat tags are broken with escape characters - player.cursorItemIconText = "\nCostume Dresser" - + "\nLeft Click to change your Pet's appearance" - + "\nRight Click to change your Light Pet's appearance"; - if (player.HeldItem.type != ItemID.None) - { - player.cursorItemIconText += "\nFor this to work properly, don't have any item selected"; - } - } - } + private void MouseOverCombined(bool close) + { + Player player = Main.LocalPlayer; + player.mouseInterface = true; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + player.GetModPlayer().mouseoveredDresser = true; + if (close && player.itemAnimation == 0) + { + // "\n[c/"+ (Color.Orange * (Main.mouseTextColor / 255f)).Hex3() + ":\nCostume Dresser]" doesnt work cause chat tags are broken with escape characters + player.cursorItemIconText = "\nCostume Dresser" + + "\nLeft Click to change your Pet's appearance" + + "\nRight Click to change your Light Pet's appearance"; + if (player.HeldItem.type != ItemID.None) + { + player.cursorItemIconText += "\nFor this to work properly, don't have any item selected"; + } + } + } - public override void MouseOverFar(int i, int j) - { - MouseOverCombined(false); - } + public override void MouseOverFar(int i, int j) + { + MouseOverCombined(false); + } - public override void MouseOver(int i, int j) - { - MouseOverCombined(true); - } + public override void MouseOver(int i, int j) + { + MouseOverCombined(true); + } - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 48, 32, ItemType); - } - } + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 48, 32, ItemType); + } + } } diff --git a/Tiles/WyvernCampfireTile.cs b/Tiles/WyvernCampfireTile.cs index 4de80ccf..6d042737 100644 --- a/Tiles/WyvernCampfireTile.cs +++ b/Tiles/WyvernCampfireTile.cs @@ -3,174 +3,173 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; namespace AssortedCrazyThings.Tiles { - [Content(ContentType.PlaceablesFunctional)] - public class WyvernCampfireTile : DroppableTile - { - private const int maxFrames = 8; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileSolid[Type] = false; - Main.tileLighted[Type] = true; - Main.tileWaterDeath[Type] = true; - Main.tileLavaDeath[Type] = true; - TileID.Sets.HasOutlines[Type] = true; - TileID.Sets.DisableSmartCursor[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.WaterDeath = true; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.NotAllowed; - TileObjectData.newTile.LavaPlacement = LiquidPlacement.NotAllowed; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.DrawYOffset = 2; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16 }; - TileObjectData.addTile(Type); - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Wyvern Campfire"); - AddMapEntry(new Color(105, 105, 105), name); - DustType = -1; - AnimationFrameHeight = 36; - AdjTiles = new int[] { TileID.Campfire }; - } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemType); - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - Tile tile = Main.tile[i, j]; - if (tile.TileFrameY == 0) - { - r = 0.54f; - g = 0.76f; - b = 1.3f; - } - } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (closer && Main.tile[i, j].TileFrameY < AnimationFrameHeight) - { - Main.LocalPlayer.GetModPlayer().wyvernCampfire = true; - Main.SceneMetrics.HasCampfire = true; - } - } - - //you need these four things for the outline to work: - //_Highlight.png - //TileID.Sets.HasOutlines[Type] = true; - //TileID.Sets.DisableSmartCursor[Type] = true; - //and this hook - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) - { - return true; - } - - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frame = Main.tileFrame[TileID.Campfire]; - frameCounter = Main.tileFrameCounter[TileID.Campfire]; - } - - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Tile tile = Main.tile[i, j]; - Texture2D texture = Main.instance.TilesRenderer.GetTileDrawTexture(tile, i, j); - Vector2 zero = new Vector2(Main.offScreenRange); - if (Main.drawToScreen) - { - zero = Vector2.Zero; - } - //int height = 16; - int height = tile.TileFrameY == 18 ? 18 : 16; - int animate = AnimationFrameHeight * (maxFrames - 1); - if (tile.TileFrameY < AnimationFrameHeight) - { - animate = Main.tileFrame[Type] * AnimationFrameHeight; - } - Color color = Lighting.GetColor(i, j); - Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; - pos.Y += 2; - Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height); - spriteBatch.Draw(texture, pos, frame, color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); - - AssUtils.DrawTileHighlight(spriteBatch, i, j, Type, color, pos, frame); - - if (tile.TileFrameY == 0 && Main.rand.NextBool() && !Main.gamePaused && Main.instance.IsActive && (!Lighting.UpdateEveryFrame || Main.rand.NextBool(4))) - { - Dust dust = Dust.NewDustDirect(new Vector2(i * 16 + 2, j * 16 - 4), 4, 8, 31, 0f, 0f, 100); - dust.alpha += Main.rand.Next(100); - dust.velocity *= 0.2f; - dust.velocity.Y -= 0.5f + Main.rand.Next(10) * 0.1f; - dust.fadeIn = 0.5f + Main.rand.Next(10) * 0.1f; - } - - return false; - } - - public override void MouseOver(int i, int j) - { - Player player = Main.LocalPlayer; - player.mouseInterface = true; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = ItemType; - } - - public override bool RightClick(int i, int j) - { - SoundEngine.PlaySound(SoundID.Mech, i * 16, j * 16, 0); - HitWire(i, j); - return true; - } - - public override void HitWire(int i, int j) - { - int x = i - Main.tile[i, j].TileFrameX / 18 % 3; - int y = j - Main.tile[i, j].TileFrameY / 18 % 2; - int change = AnimationFrameHeight; - if (Main.tile[x, y].TileFrameY >= AnimationFrameHeight) - { - change = -AnimationFrameHeight; - } - - Tile tile; - for (int l = x; l < x + 3; l++) - { - for (int m = y; m < y + 2; m++) - { - tile = Framing.GetTileSafely(l, m); - if (tile.HasTile && tile.TileType == Type) - { - tile.TileFrameY = (short)(tile.TileFrameY + change); - } - } - } - - if (Wiring.running) - { - Wiring.SkipWire(x, y); - Wiring.SkipWire(x, y + 1); - Wiring.SkipWire(x + 1, y); - Wiring.SkipWire(x + 1, y + 1); - Wiring.SkipWire(x + 2, y); - Wiring.SkipWire(x + 2, y + 1); - } - NetMessage.SendTileSquare(-1, x + 1, y, 3); - } - } + [Content(ContentType.PlaceablesFunctional)] + public class WyvernCampfireTile : DroppableTile + { + private const int maxFrames = 8; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + Main.tileWaterDeath[Type] = true; + Main.tileLavaDeath[Type] = true; + TileID.Sets.HasOutlines[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.WaterDeath = true; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.NotAllowed; + TileObjectData.newTile.LavaPlacement = LiquidPlacement.NotAllowed; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16 }; + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Wyvern Campfire"); + AddMapEntry(new Color(105, 105, 105), name); + DustType = -1; + AnimationFrameHeight = 36; + AdjTiles = new int[] { TileID.Campfire }; + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemType); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + Tile tile = Main.tile[i, j]; + if (tile.TileFrameY == 0) + { + r = 0.54f; + g = 0.76f; + b = 1.3f; + } + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (closer && Main.tile[i, j].TileFrameY < AnimationFrameHeight) + { + Main.LocalPlayer.GetModPlayer().wyvernCampfire = true; + Main.SceneMetrics.HasCampfire = true; + } + } + + //you need these four things for the outline to work: + //_Highlight.png + //TileID.Sets.HasOutlines[Type] = true; + //TileID.Sets.DisableSmartCursor[Type] = true; + //and this hook + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return true; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frame = Main.tileFrame[TileID.Campfire]; + frameCounter = Main.tileFrameCounter[TileID.Campfire]; + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + Tile tile = Main.tile[i, j]; + Texture2D texture = Main.instance.TilesRenderer.GetTileDrawTexture(tile, i, j); + Vector2 zero = new Vector2(Main.offScreenRange); + if (Main.drawToScreen) + { + zero = Vector2.Zero; + } + //int height = 16; + int height = tile.TileFrameY == 18 ? 18 : 16; + int animate = AnimationFrameHeight * (maxFrames - 1); + if (tile.TileFrameY < AnimationFrameHeight) + { + animate = Main.tileFrame[Type] * AnimationFrameHeight; + } + Color color = Lighting.GetColor(i, j); + Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; + pos.Y += 2; + Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height); + spriteBatch.Draw(texture, pos, frame, color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + + AssUtils.DrawTileHighlight(spriteBatch, i, j, Type, color, pos, frame); + + if (tile.TileFrameY == 0 && Main.rand.NextBool() && !Main.gamePaused && Main.instance.IsActive && (!Lighting.UpdateEveryFrame || Main.rand.NextBool(4))) + { + Dust dust = Dust.NewDustDirect(new Vector2(i * 16 + 2, j * 16 - 4), 4, 8, 31, 0f, 0f, 100); + dust.alpha += Main.rand.Next(100); + dust.velocity *= 0.2f; + dust.velocity.Y -= 0.5f + Main.rand.Next(10) * 0.1f; + dust.fadeIn = 0.5f + Main.rand.Next(10) * 0.1f; + } + + return false; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.mouseInterface = true; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ItemType; + } + + public override bool RightClick(int i, int j) + { + SoundEngine.PlaySound(SoundID.Mech, i * 16, j * 16, 0); + HitWire(i, j); + return true; + } + + public override void HitWire(int i, int j) + { + int x = i - Main.tile[i, j].TileFrameX / 18 % 3; + int y = j - Main.tile[i, j].TileFrameY / 18 % 2; + int change = AnimationFrameHeight; + if (Main.tile[x, y].TileFrameY >= AnimationFrameHeight) + { + change = -AnimationFrameHeight; + } + + Tile tile; + for (int l = x; l < x + 3; l++) + { + for (int m = y; m < y + 2; m++) + { + tile = Framing.GetTileSafely(l, m); + if (tile.HasTile && tile.TileType == Type) + { + tile.TileFrameY = (short)(tile.TileFrameY + change); + } + } + } + + if (Wiring.running) + { + Wiring.SkipWire(x, y); + Wiring.SkipWire(x, y + 1); + Wiring.SkipWire(x + 1, y); + Wiring.SkipWire(x + 1, y + 1); + Wiring.SkipWire(x + 2, y); + Wiring.SkipWire(x + 2, y + 1); + } + NetMessage.SendTileSquare(-1, x + 1, y, 3); + } + } } diff --git a/UI/CircleUI.cs b/UI/CircleUI.cs index 3f83ed8d..496005ed 100644 --- a/UI/CircleUI.cs +++ b/UI/CircleUI.cs @@ -4,272 +4,271 @@ using System; using Terraria; using Terraria.GameContent; -using Terraria.ModLoader; using Terraria.UI; using Terraria.UI.Chat; namespace AssortedCrazyThings.UI { - //TODO redo that - //Huge credit to Muzuwi (with permission): https://github.com/Muzuwi/AmmoboxPlus/blob/master/AmmoboxUI.cs - /// - /// UI that is used to select something out of a list of things, opened via item - /// - public class CircleUI : UIState - { - internal const int NONE = -1; - - /// - /// Circle diameter - /// - internal const int mainDiameter = 36; - - /// - /// Circle radius - /// - internal const int mainRadius = mainDiameter / 2; - - /// - /// Is the UI visible? - /// - internal static bool visible = false; - - /// - /// Spawn position, i.e. mouse position at UI start - /// - internal static Vector2 spawnPosition = default(Vector2); - - /// - /// Trigger item type - /// - internal static int triggerItemType = -1; - - /// - /// Trigger item type - /// - internal static bool triggeredFromDresser = false; - - /// - /// Which thing is currently highlighted? - /// - internal static int returned = NONE; - - /// - /// Which thing was the previously selected one? - /// - internal static int currentSelected = NONE; - - /// - /// Which button was it activated with - /// - internal static bool openedWithLeft = false; - - /// - /// Fade in animation when opening the UI - /// - internal static float fadeIn = 0; - - /// - /// Holds data about what to draw - /// - internal static CircleUIConf UIConf; - - /// - /// Spawn position offset to top left corner of that to draw the icons - /// - private Vector2 TopLeftCorner - { - get - { - return spawnPosition - new Vector2(mainRadius, mainRadius); - } - } - - //Update, unused - public override void Update(GameTime gameTime) - { - base.Update(gameTime); - } - - //Draw - protected override void DrawSelf(SpriteBatch spriteBatch) - { - base.DrawSelf(spriteBatch); - Main.LocalPlayer.mouseInterface = true; - Main.LocalPlayer.cursorItemIconID = 0; - Main.LocalPlayer.cursorItemIconText = ""; - - //48 - int outerRadius = 48; - if (UIConf.CircleAmount > 5) outerRadius += 5 * (UIConf.CircleAmount - 5); //increase by 5 after having more than 5 options, starts getting clumped at about 24 circles - if (fadeIn < outerRadius) outerRadius = (int)(fadeIn += (float)outerRadius / 10); - - double angleSteps = 2.0d / UIConf.CircleAmount; - int done; - //done --> ID of currently drawn circle - for (done = 0; done < UIConf.CircleAmount; done++) - { - double x = outerRadius * Math.Sin(angleSteps * done * Math.PI); - double y = outerRadius * -Math.Cos(angleSteps * done * Math.PI); - - Rectangle bgRect = new Rectangle((int)(TopLeftCorner.X + x), (int)(TopLeftCorner.Y + y), mainDiameter, mainDiameter); - //Check if mouse is within the circle checked - bool isMouseWithin = CheckMouseWithinWheel(Main.MouseScreen, spawnPosition, mainRadius, UIConf.CircleAmount, done); - - //Actually draw the bg circle - Color drawColor = Color.White; - if (!UIConf.Unlocked[done]) - { - drawColor = Color.DarkRed; - } - else if (done == currentSelected) - { - drawColor = Color.Gray; - } - Main.spriteBatch.Draw(TextureAssets.WireUi[isMouseWithin ? 1 : 0].Value, bgRect, drawColor); - - //Draw sprites over the icons - Texture2D texture = UIConf.Assets[done].Value; - int width = texture.Width; - int height = texture.Height; - if (UIConf.SpritesheetDivider > 0) height /= UIConf.SpritesheetDivider; - Rectangle projRect = new Rectangle((int)(spawnPosition.X + x) - (width / 2), (int)(spawnPosition.Y + y) - (height / 2), width, height); - projRect.X += (int)UIConf.DrawOffset.X; - projRect.Y += (int)UIConf.DrawOffset.Y; - - drawColor = Color.White; - if (done == currentSelected || !UIConf.Unlocked[done]) drawColor = Color.Gray; - - Rectangle sourceRect = new Rectangle(0, 0, width, height); - - Main.spriteBatch.Draw(texture, projRect, sourceRect, drawColor); - - if (isMouseWithin) - { - if (UIConf.Unlocked[done]) - { - //set the "returned" new type - returned = done; - } - else - { - //if hovering over a locked thing, don't return anything new - returned = currentSelected; - } - } - } - - //Draw held item bg circle - Rectangle outputRect = new Rectangle((int)TopLeftCorner.X, (int)TopLeftCorner.Y, mainDiameter, mainDiameter); - - bool middle = CheckMouseWithinCircle(Main.MouseScreen, mainRadius, spawnPosition); - - Main.spriteBatch.Draw(TextureAssets.WireUi[middle ? 1 : 0].Value, outputRect, Color.White); - - //Draw trigger item inside circle - if (triggerItemType != -1) - { - Asset asset = TextureAssets.Item[triggerItemType]; - int finalWidth = asset.Width()/* / 2*/; - int finalHeight = asset.Height()/* / 2*/; - Rectangle outputItemRect = new Rectangle((int)spawnPosition.X - (finalWidth / 2), (int)spawnPosition.Y - (finalHeight / 2), finalWidth, finalHeight); - //outputWeaponRect.Inflate(4, 4); - Main.spriteBatch.Draw(asset.Value, outputItemRect, Color.White); - } - - if (middle) - { - //if hovering over the middle, don't return anything new - returned = currentSelected; - } - - //extra loop so tooltips are always drawn after the circles - for (done = 0; done < UIConf.CircleAmount; done++) - { - bool isMouseWithin = CheckMouseWithinWheel(Main.MouseScreen, spawnPosition, mainRadius, UIConf.CircleAmount, done); - string tooltip = UIConf.Unlocked[done] ? UIConf.Tooltips[done] : UIConf.ToUnlock[done]; - - //if there is a "to unlock" message, prefix it - tooltip = (!UIConf.Unlocked[done] && UIConf.ToUnlock[done] != "") ? ("To unlock: " + tooltip) : tooltip; - - if (isMouseWithin) - { - //Draw the tooltip - Color fontColor = Color.White; - Vector2 mousePos = new Vector2(Main.mouseX, Main.mouseY); - ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, tooltip, mousePos + new Vector2(16, 16), fontColor, 0, Vector2.Zero, Vector2.One); - } - } - } - - /// - /// Check if the mouse cursor is within the radius around the position specified by center - /// - internal static bool CheckMouseWithinCircle(Vector2 mousePos, int radius, Vector2 center) - { - return ((mousePos.X - center.X) * (mousePos.X - center.X) + (mousePos.Y - center.Y) * (mousePos.Y - center.Y)) <= radius * radius; - } - - /// - /// Checks if the mouse cursor is currently inside the segment specified by the arguments. Decided by angle (radius only matters for the inner element). - /// - internal static bool CheckMouseWithinWheel(Vector2 mousePos, Vector2 center, int innerRadius, int pieceCount, int elementNumber) - { - //Check if mouse cursor is outside the inner circle - bool outsideInner = !CheckMouseWithinCircle(mousePos, innerRadius, center); - - double step = 360 / pieceCount; - //finalOffset *= 180 / Math.PI; - double finalOffset = -step / 2; - - double beginAngle = (finalOffset + step * elementNumber) % 360; - double endAngle = (beginAngle + step) % 360; - if (beginAngle < 0) beginAngle = 360 + beginAngle; - - //Calculate x,y coords on outer circle - double calculatedAngle = Math.Atan2(mousePos.X - center.X, -(mousePos.Y - center.Y)); - calculatedAngle = calculatedAngle * 180 / Math.PI; - - if (calculatedAngle < 0) - { - calculatedAngle = 360 + calculatedAngle; - } - - bool insideSegment = false; - //(calculatedAngle <= endAngle && calculatedAngle >= beginAngle); - if (beginAngle < endAngle) - { - if (beginAngle < calculatedAngle && calculatedAngle < endAngle) - { - insideSegment = true; - } - } - else - { - if (calculatedAngle > beginAngle && calculatedAngle > endAngle) - { - insideSegment = true; - } - if (calculatedAngle < beginAngle && calculatedAngle < endAngle) - { - insideSegment = true; - } - } - - return outsideInner && insideSegment; - } - - /// - /// Called when the UI is about to appear - /// - public static void Start(int triggerType, bool triggerLeft, bool fromDresser) - { - visible = true; - spawnPosition = Main.MouseScreen; - triggerItemType = triggerType; - openedWithLeft = triggerLeft; - triggeredFromDresser = fromDresser; - fadeIn = 0; - } - } + //TODO redo that + //Huge credit to Muzuwi (with permission): https://github.com/Muzuwi/AmmoboxPlus/blob/master/AmmoboxUI.cs + /// + /// UI that is used to select something out of a list of things, opened via item + /// + public class CircleUI : UIState + { + internal const int NONE = -1; + + /// + /// Circle diameter + /// + internal const int mainDiameter = 36; + + /// + /// Circle radius + /// + internal const int mainRadius = mainDiameter / 2; + + /// + /// Is the UI visible? + /// + internal static bool visible = false; + + /// + /// Spawn position, i.e. mouse position at UI start + /// + internal static Vector2 spawnPosition = default(Vector2); + + /// + /// Trigger item type + /// + internal static int triggerItemType = -1; + + /// + /// Trigger item type + /// + internal static bool triggeredFromDresser = false; + + /// + /// Which thing is currently highlighted? + /// + internal static int returned = NONE; + + /// + /// Which thing was the previously selected one? + /// + internal static int currentSelected = NONE; + + /// + /// Which button was it activated with + /// + internal static bool openedWithLeft = false; + + /// + /// Fade in animation when opening the UI + /// + internal static float fadeIn = 0; + + /// + /// Holds data about what to draw + /// + internal static CircleUIConf UIConf; + + /// + /// Spawn position offset to top left corner of that to draw the icons + /// + private Vector2 TopLeftCorner + { + get + { + return spawnPosition - new Vector2(mainRadius, mainRadius); + } + } + + //Update, unused + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + } + + //Draw + protected override void DrawSelf(SpriteBatch spriteBatch) + { + base.DrawSelf(spriteBatch); + Main.LocalPlayer.mouseInterface = true; + Main.LocalPlayer.cursorItemIconID = 0; + Main.LocalPlayer.cursorItemIconText = ""; + + //48 + int outerRadius = 48; + if (UIConf.CircleAmount > 5) outerRadius += 5 * (UIConf.CircleAmount - 5); //increase by 5 after having more than 5 options, starts getting clumped at about 24 circles + if (fadeIn < outerRadius) outerRadius = (int)(fadeIn += (float)outerRadius / 10); + + double angleSteps = 2.0d / UIConf.CircleAmount; + int done; + //done --> ID of currently drawn circle + for (done = 0; done < UIConf.CircleAmount; done++) + { + double x = outerRadius * Math.Sin(angleSteps * done * Math.PI); + double y = outerRadius * -Math.Cos(angleSteps * done * Math.PI); + + Rectangle bgRect = new Rectangle((int)(TopLeftCorner.X + x), (int)(TopLeftCorner.Y + y), mainDiameter, mainDiameter); + //Check if mouse is within the circle checked + bool isMouseWithin = CheckMouseWithinWheel(Main.MouseScreen, spawnPosition, mainRadius, UIConf.CircleAmount, done); + + //Actually draw the bg circle + Color drawColor = Color.White; + if (!UIConf.Unlocked[done]) + { + drawColor = Color.DarkRed; + } + else if (done == currentSelected) + { + drawColor = Color.Gray; + } + Main.spriteBatch.Draw(TextureAssets.WireUi[isMouseWithin ? 1 : 0].Value, bgRect, drawColor); + + //Draw sprites over the icons + Texture2D texture = UIConf.Assets[done].Value; + int width = texture.Width; + int height = texture.Height; + if (UIConf.SpritesheetDivider > 0) height /= UIConf.SpritesheetDivider; + Rectangle projRect = new Rectangle((int)(spawnPosition.X + x) - (width / 2), (int)(spawnPosition.Y + y) - (height / 2), width, height); + projRect.X += (int)UIConf.DrawOffset.X; + projRect.Y += (int)UIConf.DrawOffset.Y; + + drawColor = Color.White; + if (done == currentSelected || !UIConf.Unlocked[done]) drawColor = Color.Gray; + + Rectangle sourceRect = new Rectangle(0, 0, width, height); + + Main.spriteBatch.Draw(texture, projRect, sourceRect, drawColor); + + if (isMouseWithin) + { + if (UIConf.Unlocked[done]) + { + //set the "returned" new type + returned = done; + } + else + { + //if hovering over a locked thing, don't return anything new + returned = currentSelected; + } + } + } + + //Draw held item bg circle + Rectangle outputRect = new Rectangle((int)TopLeftCorner.X, (int)TopLeftCorner.Y, mainDiameter, mainDiameter); + + bool middle = CheckMouseWithinCircle(Main.MouseScreen, mainRadius, spawnPosition); + + Main.spriteBatch.Draw(TextureAssets.WireUi[middle ? 1 : 0].Value, outputRect, Color.White); + + //Draw trigger item inside circle + if (triggerItemType != -1) + { + Asset asset = TextureAssets.Item[triggerItemType]; + int finalWidth = asset.Width()/* / 2*/; + int finalHeight = asset.Height()/* / 2*/; + Rectangle outputItemRect = new Rectangle((int)spawnPosition.X - (finalWidth / 2), (int)spawnPosition.Y - (finalHeight / 2), finalWidth, finalHeight); + //outputWeaponRect.Inflate(4, 4); + Main.spriteBatch.Draw(asset.Value, outputItemRect, Color.White); + } + + if (middle) + { + //if hovering over the middle, don't return anything new + returned = currentSelected; + } + + //extra loop so tooltips are always drawn after the circles + for (done = 0; done < UIConf.CircleAmount; done++) + { + bool isMouseWithin = CheckMouseWithinWheel(Main.MouseScreen, spawnPosition, mainRadius, UIConf.CircleAmount, done); + string tooltip = UIConf.Unlocked[done] ? UIConf.Tooltips[done] : UIConf.ToUnlock[done]; + + //if there is a "to unlock" message, prefix it + tooltip = (!UIConf.Unlocked[done] && UIConf.ToUnlock[done] != "") ? ("To unlock: " + tooltip) : tooltip; + + if (isMouseWithin) + { + //Draw the tooltip + Color fontColor = Color.White; + Vector2 mousePos = new Vector2(Main.mouseX, Main.mouseY); + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, tooltip, mousePos + new Vector2(16, 16), fontColor, 0, Vector2.Zero, Vector2.One); + } + } + } + + /// + /// Check if the mouse cursor is within the radius around the position specified by center + /// + internal static bool CheckMouseWithinCircle(Vector2 mousePos, int radius, Vector2 center) + { + return ((mousePos.X - center.X) * (mousePos.X - center.X) + (mousePos.Y - center.Y) * (mousePos.Y - center.Y)) <= radius * radius; + } + + /// + /// Checks if the mouse cursor is currently inside the segment specified by the arguments. Decided by angle (radius only matters for the inner element). + /// + internal static bool CheckMouseWithinWheel(Vector2 mousePos, Vector2 center, int innerRadius, int pieceCount, int elementNumber) + { + //Check if mouse cursor is outside the inner circle + bool outsideInner = !CheckMouseWithinCircle(mousePos, innerRadius, center); + + double step = 360 / pieceCount; + //finalOffset *= 180 / Math.PI; + double finalOffset = -step / 2; + + double beginAngle = (finalOffset + step * elementNumber) % 360; + double endAngle = (beginAngle + step) % 360; + if (beginAngle < 0) beginAngle = 360 + beginAngle; + + //Calculate x,y coords on outer circle + double calculatedAngle = Math.Atan2(mousePos.X - center.X, -(mousePos.Y - center.Y)); + calculatedAngle = calculatedAngle * 180 / Math.PI; + + if (calculatedAngle < 0) + { + calculatedAngle = 360 + calculatedAngle; + } + + bool insideSegment = false; + //(calculatedAngle <= endAngle && calculatedAngle >= beginAngle); + if (beginAngle < endAngle) + { + if (beginAngle < calculatedAngle && calculatedAngle < endAngle) + { + insideSegment = true; + } + } + else + { + if (calculatedAngle > beginAngle && calculatedAngle > endAngle) + { + insideSegment = true; + } + if (calculatedAngle < beginAngle && calculatedAngle < endAngle) + { + insideSegment = true; + } + } + + return outsideInner && insideSegment; + } + + /// + /// Called when the UI is about to appear + /// + public static void Start(int triggerType, bool triggerLeft, bool fromDresser) + { + visible = true; + spawnPosition = Main.MouseScreen; + triggerItemType = triggerType; + openedWithLeft = triggerLeft; + triggeredFromDresser = fromDresser; + fadeIn = 0; + } + } } diff --git a/UI/CircleUIConf.cs b/UI/CircleUIConf.cs index 3e8be8e3..8f1116ab 100644 --- a/UI/CircleUIConf.cs +++ b/UI/CircleUIConf.cs @@ -9,150 +9,150 @@ namespace AssortedCrazyThings.UI { - /// - /// Contains Information about the data and the actions necessary to open/close/act upon the data in the Circle UI - /// - /// - /// - public class CircleUIHandler - { - /// - /// List that contains the trigger items (when using right click) from all CircleUIHandlers combined - /// (makes the check easier on the CPU each tick since most Handlers share the trigger item) - /// - public static List TriggerListRight = new List(); - /// - /// List that contains the trigger items (when using left click) from all CircleUIHandlers combined - /// (makes the check easier on the CPU each tick since most Handlers share the trigger item) - /// - public static List TriggerListLeft = new List(); - - /// - /// Item it is used with - /// - public int TriggerItem { get; private set; } - - /// - /// If the UI even opens if the condition is met - /// - public Func Condition { get; private set; } - - //all these three things get called when their respective condition returns true - /// - /// Holds data about what to draw - /// - public Func UIConf { get; private set; } - - /// - /// Assigns the CircleUI the selected thing - /// - public Func OnUIStart { get; private set; } - - /// - /// Does things when the UI closes - /// - public Action OnUIEnd { get; private set; } - - //optional arguments - /// - /// If the UI opens on left click (false if right click) - /// - public bool TriggerLeft { get; private set; } - - public CircleUIHandler(int triggerItem, Func condition, Func uiConf, Func onUIStart, Action onUIEnd, bool triggerLeft = true) - { - TriggerItem = triggerItem; - Condition = condition; - UIConf = uiConf; - OnUIStart = onUIStart; - OnUIEnd = onUIEnd; - TriggerLeft = triggerLeft; - } - - /// - /// creates a simplified conf specific for pets - /// - public static CircleUIConf PetConf(string name, List tooltips, Vector2 drawOffset = default) - { - //uses VanitySelector as the triggerItem - //order of tooltips must be the same as the order of textures (0, 1, 2 etc) - - List> assets = new List>(); - for (int i = 0; i < tooltips.Count; i++) - { - assets.Add(AssUtils.Instance.Assets.Request("Projectiles/Pets/" + name + "_" + i)); - } - - int type = AssUtils.Instance.Find(name).Type; - - return new CircleUIConf(Main.projFrames[type], type, assets: assets, tooltips: tooltips, drawOffset: drawOffset); - } - - public static CircleUIConf PetConf(int type, List tooltips, Vector2 drawOffset = default) - { - return PetConf(ModContent.GetModProjectile(type).Name, tooltips, drawOffset); - } - - /// - /// Add trigger item for the UI to check for when holding the item type - /// - public void AddTriggers() - { - int triggerItemType = TriggerItem; - var list = TriggerLeft ? TriggerListLeft : TriggerListRight; - if (!list.Contains(triggerItemType)) - { - list.Add(triggerItemType); - } - } - } - - /// - /// Contains data for displaying the Circle UI - /// - public class CircleUIConf - { - public List> Assets { get; private set; } - public List Unlocked { get; private set; } //all true if just selection - public List Tooltips { get; private set; } //atleast "", only shown when unlocked - public List ToUnlock { get; private set; } //atleast "", only shown when !unlocked - public Vector2 DrawOffset { get; private set; } //if the preview is off from the selection, offsets it - - public int CircleAmount { get; private set; } //amount of spawned circles - - public int SpritesheetDivider { get; private set; } //divider of spritesheet height (if needed) - - public int AdditionalInfo { get; private set; } //mainly used for passing the projectile type atm - - public CircleUIConf(int spritesheetDivider = 0, int additionalInfo = -1, List> assets = null, List unlocked = null, List tooltips = null, List toUnlock = null, Vector2 drawOffset = default) - { - if (assets == null || assets.Count <= 0) throw new Exception("'textureNames' has to be specified or has to contain at least one element"); - else CircleAmount = assets.Count; - - //Test if textures exist - //foreach (string texture in textureNames) - //{ - // if (ModContent.Request(texture) == null) throw new Exception("'texture' " + texture + " doesn't exist. Is it spelled correctly?"); - //} - - if (unlocked == null) AssUtils.FillWithDefault(ref unlocked, true, CircleAmount); - - if (tooltips == null) AssUtils.FillWithDefault(ref tooltips, "", CircleAmount); - - if (toUnlock == null) AssUtils.FillWithDefault(ref toUnlock, "", CircleAmount); - - if (CircleAmount != unlocked.Count || - CircleAmount != tooltips.Count || - CircleAmount != toUnlock.Count) throw new Exception("Atleast one of the specified lists isn't the same length as textureNames"); - - SpritesheetDivider = spritesheetDivider; - AdditionalInfo = additionalInfo; - - Assets = new List>(assets); - Unlocked = new List(unlocked); - Tooltips = new List(tooltips); - ToUnlock = new List(toUnlock); - DrawOffset = drawOffset; - } - } + /// + /// Contains Information about the data and the actions necessary to open/close/act upon the data in the Circle UI + /// + /// + /// + public class CircleUIHandler + { + /// + /// List that contains the trigger items (when using right click) from all CircleUIHandlers combined + /// (makes the check easier on the CPU each tick since most Handlers share the trigger item) + /// + public static List TriggerListRight = new List(); + /// + /// List that contains the trigger items (when using left click) from all CircleUIHandlers combined + /// (makes the check easier on the CPU each tick since most Handlers share the trigger item) + /// + public static List TriggerListLeft = new List(); + + /// + /// Item it is used with + /// + public int TriggerItem { get; private set; } + + /// + /// If the UI even opens if the condition is met + /// + public Func Condition { get; private set; } + + //all these three things get called when their respective condition returns true + /// + /// Holds data about what to draw + /// + public Func UIConf { get; private set; } + + /// + /// Assigns the CircleUI the selected thing + /// + public Func OnUIStart { get; private set; } + + /// + /// Does things when the UI closes + /// + public Action OnUIEnd { get; private set; } + + //optional arguments + /// + /// If the UI opens on left click (false if right click) + /// + public bool TriggerLeft { get; private set; } + + public CircleUIHandler(int triggerItem, Func condition, Func uiConf, Func onUIStart, Action onUIEnd, bool triggerLeft = true) + { + TriggerItem = triggerItem; + Condition = condition; + UIConf = uiConf; + OnUIStart = onUIStart; + OnUIEnd = onUIEnd; + TriggerLeft = triggerLeft; + } + + /// + /// creates a simplified conf specific for pets + /// + public static CircleUIConf PetConf(string name, List tooltips, Vector2 drawOffset = default) + { + //uses VanitySelector as the triggerItem + //order of tooltips must be the same as the order of textures (0, 1, 2 etc) + + List> assets = new List>(); + for (int i = 0; i < tooltips.Count; i++) + { + assets.Add(AssUtils.Instance.Assets.Request("Projectiles/Pets/" + name + "_" + i)); + } + + int type = AssUtils.Instance.Find(name).Type; + + return new CircleUIConf(Main.projFrames[type], type, assets: assets, tooltips: tooltips, drawOffset: drawOffset); + } + + public static CircleUIConf PetConf(int type, List tooltips, Vector2 drawOffset = default) + { + return PetConf(ModContent.GetModProjectile(type).Name, tooltips, drawOffset); + } + + /// + /// Add trigger item for the UI to check for when holding the item type + /// + public void AddTriggers() + { + int triggerItemType = TriggerItem; + var list = TriggerLeft ? TriggerListLeft : TriggerListRight; + if (!list.Contains(triggerItemType)) + { + list.Add(triggerItemType); + } + } + } + + /// + /// Contains data for displaying the Circle UI + /// + public class CircleUIConf + { + public List> Assets { get; private set; } + public List Unlocked { get; private set; } //all true if just selection + public List Tooltips { get; private set; } //atleast "", only shown when unlocked + public List ToUnlock { get; private set; } //atleast "", only shown when !unlocked + public Vector2 DrawOffset { get; private set; } //if the preview is off from the selection, offsets it + + public int CircleAmount { get; private set; } //amount of spawned circles + + public int SpritesheetDivider { get; private set; } //divider of spritesheet height (if needed) + + public int AdditionalInfo { get; private set; } //mainly used for passing the projectile type atm + + public CircleUIConf(int spritesheetDivider = 0, int additionalInfo = -1, List> assets = null, List unlocked = null, List tooltips = null, List toUnlock = null, Vector2 drawOffset = default) + { + if (assets == null || assets.Count <= 0) throw new Exception("'textureNames' has to be specified or has to contain at least one element"); + else CircleAmount = assets.Count; + + //Test if textures exist + //foreach (string texture in textureNames) + //{ + // if (ModContent.Request(texture) == null) throw new Exception("'texture' " + texture + " doesn't exist. Is it spelled correctly?"); + //} + + if (unlocked == null) AssUtils.FillWithDefault(ref unlocked, true, CircleAmount); + + if (tooltips == null) AssUtils.FillWithDefault(ref tooltips, "", CircleAmount); + + if (toUnlock == null) AssUtils.FillWithDefault(ref toUnlock, "", CircleAmount); + + if (CircleAmount != unlocked.Count || + CircleAmount != tooltips.Count || + CircleAmount != toUnlock.Count) throw new Exception("Atleast one of the specified lists isn't the same length as textureNames"); + + SpritesheetDivider = spritesheetDivider; + AdditionalInfo = additionalInfo; + + Assets = new List>(assets); + Unlocked = new List(unlocked); + Tooltips = new List(tooltips); + ToUnlock = new List(toUnlock); + DrawOffset = drawOffset; + } + } } diff --git a/UI/EnhancedHunterUI.cs b/UI/EnhancedHunterUI.cs index b84f8b52..3f8777db 100644 --- a/UI/EnhancedHunterUI.cs +++ b/UI/EnhancedHunterUI.cs @@ -1,5 +1,4 @@ using AssortedCrazyThings.Base; -using AssortedCrazyThings.NPCs.DungeonBird; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -8,302 +7,301 @@ using Terraria; using Terraria.GameContent; using Terraria.ID; -using Terraria.ModLoader; using Terraria.UI; namespace AssortedCrazyThings.UI { - class EnhancedHunterUI : UIState - { - //Is the UI visible? - internal static bool visible = false; + class EnhancedHunterUI : UIState + { + //Is the UI visible? + internal static bool visible = false; - internal static List type; + internal static List type; - internal static List bossHeadIndex; + internal static List bossHeadIndex; - internal static List drawPos; + internal static List drawPos; - internal static List drawRotation; + internal static List drawRotation; - internal static List drawLOS; + internal static List drawLOS; - internal static List drawColor; + internal static List drawColor; - internal static Asset arrowTexture; //<- = null in Mod.Unload() + internal static Asset arrowTexture; //<- = null in Mod.Unload() - internal static int[] blacklistNPCs; + internal static int[] blacklistNPCs; - public override void OnInitialize() - { - type = new List(); - bossHeadIndex = new List(); - drawPos = new List(); - drawRotation = new List(); - drawLOS = new List(); - drawColor = new List(); - arrowTexture = AssUtils.Instance.Assets.Request("UI/UIArrow"); + public override void OnInitialize() + { + type = new List(); + bossHeadIndex = new List(); + drawPos = new List(); + drawRotation = new List(); + drawLOS = new List(); + drawColor = new List(); + arrowTexture = AssUtils.Instance.Assets.Request("UI/UIArrow"); - List blacklistNPCsList = new List() - { - NPCID.Bee, - NPCID.BeeSmall, - NPCID.Creeper, - NPCID.ChaosBall, + List blacklistNPCsList = new List() + { + NPCID.Bee, + NPCID.BeeSmall, + NPCID.Creeper, + NPCID.ChaosBall, //NPCID.EaterofWorldsBody, //NPCID.EaterofWorldsTail, NPCID.Golem, - NPCID.GolemFistLeft, - NPCID.GolemFistRight, - NPCID.MartianSaucerCannon, - NPCID.MartianSaucerTurret, - NPCID.MoonLordCore, - NPCID.MoonLordHand, - NPCID.MoonLordHead, - NPCID.MoonLordFreeEye, - NPCID.PlanterasHook, - NPCID.PlanterasTentacle, - NPCID.PrimeCannon, - NPCID.PrimeLaser, - NPCID.PrimeSaw, - NPCID.PrimeVice, - NPCID.Probe, - NPCID.SkeletronHand, - NPCID.TheHungry, - NPCID.TheHungryII, - NPCID.VileSpit, - NPCID.WallofFleshEye, - NPCID.WaterSphere, - }; - - blacklistNPCs = blacklistNPCsList.ToArray(); - - Array.Sort(blacklistNPCs); - } - - private bool SetDrawPos() - { - type.Clear(); - bossHeadIndex.Clear(); - drawPos.Clear(); - drawRotation.Clear(); - drawLOS.Clear(); - drawColor.Clear(); - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - - if (type.Count < 20 && //limit to 20 drawn at all times - npc.active && !npc.friendly && npc.damage > 0 && npc.lifeMax > 5 && - !npc.dontCountMe && !npc.hide && !npc.dontTakeDamage && - Array.BinarySearch(blacklistNPCs, npc.type) < 0 && - !AssUtils.IsWormBodyOrTail(npc)) - { - Vector2 between = npc.Center - Main.LocalPlayer.Center; - //screen "radius" is 960, "diameter" is 1920 - int diameter = 1300 * 3; //radar range, basically two screens wide - - if (between.Length() < diameter / 2) - { - - int ltype = npc.type; - Vector2 ldrawPos = Vector2.Zero; - - //when to draw the icon, has to be PendingResolutionWidth/Height because ScreenWidth/Height doesn't work in this case - - //rectangle at which the npc ISN'T rendered (so its sprite won't draw aswell as the NPC itself) - - //independent of resolution, but scales with zoom factor - - float zoomFactorX = 0.25f * AssUISystem.ZoomFactor.X; - float zoomFactorY = 0.25f * AssUISystem.ZoomFactor.Y; - //for some reason with small hitbox NPCs, it starts drawing closer to the player than it should when zoomed in too much - if (zoomFactorX > 0.175f) zoomFactorX = 0.175f; - if (zoomFactorY > 0.175f) zoomFactorY = 0.175f; - - int rectPosX = (int)(Main.screenPosition.X + (Main.PendingResolutionWidth * zoomFactorX)); - int rectPosY = (int)(Main.screenPosition.Y + (Main.PendingResolutionHeight * zoomFactorY)); - int rectWidth = (int)(Main.PendingResolutionWidth * (1 - 2f * zoomFactorX)); - int rectHeight = (int)(Main.PendingResolutionHeight * (1 - 2f * zoomFactorY)); - - //padding for npc height - Rectangle rectangle = new Rectangle(rectPosX - npc.width / 2, - rectPosY - npc.height / 2, - rectWidth + npc.width, - rectHeight + npc.height); - - if (!rectangle.Intersects(npc.getRect())) - { - if (between.X == 0f) between.X = 0.0001f; //protection against division by zero - if (between.Y == 0f) between.Y = 0.0001f; //protection against NaN - - if (Main.LocalPlayer.gravDir != 1f) - { - between.Y = -between.Y; - } - - float slope = between.Y / between.X; - - Vector2 pad = new Vector2 - ( - (Main.screenWidth + npc.width) / 2, - (Main.screenHeight + npc.height) / 2 - ); - - //first iteration - - if (between.Y > 0) //target below player - { - //use lower border which is positive - if (between.Y > pad.Y) - { - ldrawPos.Y = pad.Y; - } - else - { - ldrawPos.Y = between.Y; - } - } - else //target above player - { - //use upper border which is negative - if (between.Y < -pad.Y) - { - ldrawPos.Y = -pad.Y; - } - else - { - ldrawPos.Y = between.Y; - } - } - ldrawPos.X = ldrawPos.Y / slope; - - //second iteration - - if (ldrawPos.X > 0) //if x is outside the right edge - { - //use right border which is positive - if (ldrawPos.X > pad.X) - { - ldrawPos.X = pad.X; - } - } - else if (ldrawPos.X <= 0) //if x is outside the left edge - { - //use left border which is negative - if (ldrawPos.X <= -pad.X) - { - ldrawPos.X = -pad.X; - } - } - ldrawPos.Y = ldrawPos.X * slope; - - //revert offset - ldrawPos += new Vector2(pad.X, pad.Y); - - //since we were operating based on Center to Center, we need to put the drawPos back to position instead - ldrawPos -= new Vector2(npc.width / 2, npc.height / 2); - - //get boss head texture if it has one and use that instead of the NPC texture - int lbossHeadIndex = -1; - if (npc.GetBossHeadTextureIndex() >= 0 && npc.GetBossHeadTextureIndex() < TextureAssets.NpcHeadBoss.Length) - { - lbossHeadIndex = npc.GetBossHeadTextureIndex(); - } - - //get color if NPC has any - drawColor.Add(npc.color); - - type.Add(ltype); - bossHeadIndex.Add(lbossHeadIndex); - drawPos.Add(ldrawPos); - drawRotation.Add(between.ToRotation()); - drawLOS.Add(Collision.CanHitLine(Main.LocalPlayer.position, Main.LocalPlayer.width, Main.LocalPlayer.height, npc.position, npc.width, npc.height)); - } - } - } - } - return type.Count > 0; - } - - //Update - public override void Update(GameTime gameTime) - { - if (!visible) return; - base.Update(gameTime); - - //do stuff - SetDrawPos(); - } - - //Draw - protected override void DrawSelf(SpriteBatch spriteBatch) - { - if (!visible) return; - base.DrawSelf(spriteBatch); - - for (int i = 0; i < type.Count; i++) - { - Vector2 ldrawPos = drawPos[i]; //contains npc.Center basically, but for screenpos - Texture2D tex = TextureAssets.Npc[type[i]].Value; - - //scale image down to max 64x64, only one of them needs to be max - int tempWidth = tex.Width; - int tempHeight = tex.Height / Main.npcFrameCount[type[i]]; - float scaleFactor = (float)64 / ((tempWidth > tempHeight) ? tempWidth : tempHeight); - if (scaleFactor > 0.75f) //because when fully zoomed out, the texture isn't actually drawn in 1:1 scale onto the screen - { - scaleFactor = 0.75f; //only scale down, don't scale up - } - int finalWidth = (int)(tempWidth * scaleFactor); - int finalHeight = (int)(tempHeight * scaleFactor); - - //if it's a boss, draw the head texture instead, no scaling - if (bossHeadIndex[i] != -1) - { - tex = TextureAssets.NpcHeadBoss[bossHeadIndex[i]].Value; - tempWidth = tex.Width; - tempHeight = tex.Height; - finalWidth = tex.Width; - finalHeight = tex.Height; - } - int arrowPad = 10; - - //adjust pos if outside of screen, more padding for arrow - if (ldrawPos.X >= Main.screenWidth - finalWidth - arrowPad) ldrawPos.X = Main.screenWidth - finalWidth - arrowPad; - if (ldrawPos.X <= finalWidth + arrowPad) ldrawPos.X = finalWidth + arrowPad; - if (ldrawPos.Y >= Main.screenHeight - finalHeight - arrowPad) ldrawPos.Y = Main.screenHeight - finalHeight - arrowPad; - if (ldrawPos.Y <= finalHeight + arrowPad) ldrawPos.Y = finalHeight + arrowPad; - - ////adjust pos if outside of screen, more padding - //if (ldrawPos.X >= Main.screenWidth - finalWidth * 1.25f) ldrawPos.X = Main.screenWidth - finalWidth * 1.25f; - //if (ldrawPos.X <= finalWidth * 1.25f) ldrawPos.X = finalWidth * 1.25f; - //if (ldrawPos.Y >= Main.screenHeight - finalHeight * 1.25f) ldrawPos.Y = Main.screenHeight - finalHeight * 1.25f; - //if (ldrawPos.Y <= finalHeight * 1.25f) ldrawPos.Y = finalHeight * 1.25f; - - //create rect around center - Rectangle outputRect = new Rectangle((int)ldrawPos.X - (finalWidth / 2), (int)ldrawPos.Y - (finalHeight / 2), finalWidth, finalHeight); - - //set color overlay if NPC has one - Color color = Color.LightGray; - if (drawColor[i] != default(Color)) - { - color = new Color( - Math.Max(drawColor[i].R - 25, 50), - Math.Max(drawColor[i].G - 25, 50), - Math.Max(drawColor[i].B - 25, 50), - Math.Max((byte)(drawColor[i].A * 1.5f), (byte)75)); - } - color *= drawLOS[i] ? 0.75f : 0.5f; - Main.spriteBatch.Draw(tex, outputRect, new Rectangle(0, 0, tempWidth, tempHeight), color); - - //draw Arrow - Vector2 stupidOffset = drawRotation[i].ToRotationVector2() * 24f; - Vector2 drawPosArrow = ldrawPos + stupidOffset; - color = drawLOS[i] ? Color.Green * 0.75f : Color.Red * 0.75f; - color.A = 150; - Main.spriteBatch.Draw(arrowTexture.Value, drawPosArrow, null, color, drawRotation[i], arrowTexture.Frame().Size() / 2, 1f, SpriteEffects.None, 0f); - } - } - } + NPCID.GolemFistLeft, + NPCID.GolemFistRight, + NPCID.MartianSaucerCannon, + NPCID.MartianSaucerTurret, + NPCID.MoonLordCore, + NPCID.MoonLordHand, + NPCID.MoonLordHead, + NPCID.MoonLordFreeEye, + NPCID.PlanterasHook, + NPCID.PlanterasTentacle, + NPCID.PrimeCannon, + NPCID.PrimeLaser, + NPCID.PrimeSaw, + NPCID.PrimeVice, + NPCID.Probe, + NPCID.SkeletronHand, + NPCID.TheHungry, + NPCID.TheHungryII, + NPCID.VileSpit, + NPCID.WallofFleshEye, + NPCID.WaterSphere, + }; + + blacklistNPCs = blacklistNPCsList.ToArray(); + + Array.Sort(blacklistNPCs); + } + + private bool SetDrawPos() + { + type.Clear(); + bossHeadIndex.Clear(); + drawPos.Clear(); + drawRotation.Clear(); + drawLOS.Clear(); + drawColor.Clear(); + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + + if (type.Count < 20 && //limit to 20 drawn at all times + npc.active && !npc.friendly && npc.damage > 0 && npc.lifeMax > 5 && + !npc.dontCountMe && !npc.hide && !npc.dontTakeDamage && + Array.BinarySearch(blacklistNPCs, npc.type) < 0 && + !AssUtils.IsWormBodyOrTail(npc)) + { + Vector2 between = npc.Center - Main.LocalPlayer.Center; + //screen "radius" is 960, "diameter" is 1920 + int diameter = 1300 * 3; //radar range, basically two screens wide + + if (between.Length() < diameter / 2) + { + + int ltype = npc.type; + Vector2 ldrawPos = Vector2.Zero; + + //when to draw the icon, has to be PendingResolutionWidth/Height because ScreenWidth/Height doesn't work in this case + + //rectangle at which the npc ISN'T rendered (so its sprite won't draw aswell as the NPC itself) + + //independent of resolution, but scales with zoom factor + + float zoomFactorX = 0.25f * AssUISystem.ZoomFactor.X; + float zoomFactorY = 0.25f * AssUISystem.ZoomFactor.Y; + //for some reason with small hitbox NPCs, it starts drawing closer to the player than it should when zoomed in too much + if (zoomFactorX > 0.175f) zoomFactorX = 0.175f; + if (zoomFactorY > 0.175f) zoomFactorY = 0.175f; + + int rectPosX = (int)(Main.screenPosition.X + (Main.PendingResolutionWidth * zoomFactorX)); + int rectPosY = (int)(Main.screenPosition.Y + (Main.PendingResolutionHeight * zoomFactorY)); + int rectWidth = (int)(Main.PendingResolutionWidth * (1 - 2f * zoomFactorX)); + int rectHeight = (int)(Main.PendingResolutionHeight * (1 - 2f * zoomFactorY)); + + //padding for npc height + Rectangle rectangle = new Rectangle(rectPosX - npc.width / 2, + rectPosY - npc.height / 2, + rectWidth + npc.width, + rectHeight + npc.height); + + if (!rectangle.Intersects(npc.getRect())) + { + if (between.X == 0f) between.X = 0.0001f; //protection against division by zero + if (between.Y == 0f) between.Y = 0.0001f; //protection against NaN + + if (Main.LocalPlayer.gravDir != 1f) + { + between.Y = -between.Y; + } + + float slope = between.Y / between.X; + + Vector2 pad = new Vector2 + ( + (Main.screenWidth + npc.width) / 2, + (Main.screenHeight + npc.height) / 2 + ); + + //first iteration + + if (between.Y > 0) //target below player + { + //use lower border which is positive + if (between.Y > pad.Y) + { + ldrawPos.Y = pad.Y; + } + else + { + ldrawPos.Y = between.Y; + } + } + else //target above player + { + //use upper border which is negative + if (between.Y < -pad.Y) + { + ldrawPos.Y = -pad.Y; + } + else + { + ldrawPos.Y = between.Y; + } + } + ldrawPos.X = ldrawPos.Y / slope; + + //second iteration + + if (ldrawPos.X > 0) //if x is outside the right edge + { + //use right border which is positive + if (ldrawPos.X > pad.X) + { + ldrawPos.X = pad.X; + } + } + else if (ldrawPos.X <= 0) //if x is outside the left edge + { + //use left border which is negative + if (ldrawPos.X <= -pad.X) + { + ldrawPos.X = -pad.X; + } + } + ldrawPos.Y = ldrawPos.X * slope; + + //revert offset + ldrawPos += new Vector2(pad.X, pad.Y); + + //since we were operating based on Center to Center, we need to put the drawPos back to position instead + ldrawPos -= new Vector2(npc.width / 2, npc.height / 2); + + //get boss head texture if it has one and use that instead of the NPC texture + int lbossHeadIndex = -1; + if (npc.GetBossHeadTextureIndex() >= 0 && npc.GetBossHeadTextureIndex() < TextureAssets.NpcHeadBoss.Length) + { + lbossHeadIndex = npc.GetBossHeadTextureIndex(); + } + + //get color if NPC has any + drawColor.Add(npc.color); + + type.Add(ltype); + bossHeadIndex.Add(lbossHeadIndex); + drawPos.Add(ldrawPos); + drawRotation.Add(between.ToRotation()); + drawLOS.Add(Collision.CanHitLine(Main.LocalPlayer.position, Main.LocalPlayer.width, Main.LocalPlayer.height, npc.position, npc.width, npc.height)); + } + } + } + } + return type.Count > 0; + } + + //Update + public override void Update(GameTime gameTime) + { + if (!visible) return; + base.Update(gameTime); + + //do stuff + SetDrawPos(); + } + + //Draw + protected override void DrawSelf(SpriteBatch spriteBatch) + { + if (!visible) return; + base.DrawSelf(spriteBatch); + + for (int i = 0; i < type.Count; i++) + { + Vector2 ldrawPos = drawPos[i]; //contains npc.Center basically, but for screenpos + Texture2D tex = TextureAssets.Npc[type[i]].Value; + + //scale image down to max 64x64, only one of them needs to be max + int tempWidth = tex.Width; + int tempHeight = tex.Height / Main.npcFrameCount[type[i]]; + float scaleFactor = (float)64 / ((tempWidth > tempHeight) ? tempWidth : tempHeight); + if (scaleFactor > 0.75f) //because when fully zoomed out, the texture isn't actually drawn in 1:1 scale onto the screen + { + scaleFactor = 0.75f; //only scale down, don't scale up + } + int finalWidth = (int)(tempWidth * scaleFactor); + int finalHeight = (int)(tempHeight * scaleFactor); + + //if it's a boss, draw the head texture instead, no scaling + if (bossHeadIndex[i] != -1) + { + tex = TextureAssets.NpcHeadBoss[bossHeadIndex[i]].Value; + tempWidth = tex.Width; + tempHeight = tex.Height; + finalWidth = tex.Width; + finalHeight = tex.Height; + } + int arrowPad = 10; + + //adjust pos if outside of screen, more padding for arrow + if (ldrawPos.X >= Main.screenWidth - finalWidth - arrowPad) ldrawPos.X = Main.screenWidth - finalWidth - arrowPad; + if (ldrawPos.X <= finalWidth + arrowPad) ldrawPos.X = finalWidth + arrowPad; + if (ldrawPos.Y >= Main.screenHeight - finalHeight - arrowPad) ldrawPos.Y = Main.screenHeight - finalHeight - arrowPad; + if (ldrawPos.Y <= finalHeight + arrowPad) ldrawPos.Y = finalHeight + arrowPad; + + ////adjust pos if outside of screen, more padding + //if (ldrawPos.X >= Main.screenWidth - finalWidth * 1.25f) ldrawPos.X = Main.screenWidth - finalWidth * 1.25f; + //if (ldrawPos.X <= finalWidth * 1.25f) ldrawPos.X = finalWidth * 1.25f; + //if (ldrawPos.Y >= Main.screenHeight - finalHeight * 1.25f) ldrawPos.Y = Main.screenHeight - finalHeight * 1.25f; + //if (ldrawPos.Y <= finalHeight * 1.25f) ldrawPos.Y = finalHeight * 1.25f; + + //create rect around center + Rectangle outputRect = new Rectangle((int)ldrawPos.X - (finalWidth / 2), (int)ldrawPos.Y - (finalHeight / 2), finalWidth, finalHeight); + + //set color overlay if NPC has one + Color color = Color.LightGray; + if (drawColor[i] != default(Color)) + { + color = new Color( + Math.Max(drawColor[i].R - 25, 50), + Math.Max(drawColor[i].G - 25, 50), + Math.Max(drawColor[i].B - 25, 50), + Math.Max((byte)(drawColor[i].A * 1.5f), (byte)75)); + } + color *= drawLOS[i] ? 0.75f : 0.5f; + Main.spriteBatch.Draw(tex, outputRect, new Rectangle(0, 0, tempWidth, tempHeight), color); + + //draw Arrow + Vector2 stupidOffset = drawRotation[i].ToRotationVector2() * 24f; + Vector2 drawPosArrow = ldrawPos + stupidOffset; + color = drawLOS[i] ? Color.Green * 0.75f : Color.Red * 0.75f; + color.A = 150; + Main.spriteBatch.Draw(arrowTexture.Value, drawPosArrow, null, color, drawRotation[i], arrowTexture.Frame().Size() / 2, 1f, SpriteEffects.None, 0f); + } + } + } } diff --git a/UI/HoverNPCUI.cs b/UI/HoverNPCUI.cs index cf230d9d..59052f6b 100644 --- a/UI/HoverNPCUI.cs +++ b/UI/HoverNPCUI.cs @@ -13,164 +13,164 @@ namespace AssortedCrazyThings.UI { - class HoverNPCUI : UIState - { - internal static bool visible = false; - internal static string drawString = ""; - internal static Color drawColor = Color.White; - - private string AlmostVanillaBehavior() - { - //works on dummies for some reason - Player player = Main.LocalPlayer; - string ret = ""; - Rectangle rectangle = new Rectangle((int)((float)Main.mouseX + Main.screenPosition.X), (int)((float)Main.mouseY + Main.screenPosition.Y), 1, 1); - if (player.gravDir == -1f) - { - rectangle.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY; - } - - float num = Main.mouseTextColor / 255f; - - for (int k = 0; k < Main.maxNPCs; k++) - { - //LoadNPC(Main.npc[k].type); //idk why - if (Main.npc[k].active) - { - Rectangle npcrect = new Rectangle((int)Main.npc[k].Bottom.X - Main.npc[k].frame.Width / 2, (int)Main.npc[k].Bottom.Y - Main.npc[k].frame.Height, Main.npc[k].frame.Width, Main.npc[k].frame.Height); - if (Main.npc[k].type >= NPCID.WyvernHead && Main.npc[k].type <= NPCID.WyvernTail) //Wyvern - { - npcrect = new Rectangle((int)((double)Main.npc[k].position.X + (double)Main.npc[k].width * 0.5 - 32.0), (int)((double)Main.npc[k].position.Y + (double)Main.npc[k].height * 0.5 - 32.0), 64, 64); - } - if (rectangle.Intersects(npcrect)) //mouse cursor inside hitbox - { - drawColor = new Color((byte)(255 * num), (byte)(255 * num), (byte)(255 * num), Main.mouseTextColor); - player.cursorItemIconEnabled = false; - ret = Main.npc[k].GivenOrTypeName; - int num2 = k; - if (Main.npc[k].realLife >= 0) - { - num2 = Main.npc[k].realLife; - } - if (Main.npc[num2].lifeMax > 1 && !Main.npc[num2].dontTakeDamage) - { - ret = ret + ": " + Main.npc[num2].life + "/" + Main.npc[num2].lifeMax; - } - break; - } - } - } - return ret; - } - - private string Custom() - { - Player player = Main.LocalPlayer; - string ret = ""; - Rectangle rectangle = new Rectangle((int)((float)Main.mouseX + Main.screenPosition.X), (int)((float)Main.mouseY + Main.screenPosition.Y), 1, 1); - if (player.gravDir == -1f) - { - rectangle.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY; - } - - float num = Main.mouseTextColor / 255f; - - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - if (npc.active) - { - Rectangle npcrect = new Rectangle((int)npc.Bottom.X - npc.frame.Width / 2, (int)npc.Bottom.Y - npc.frame.Height, npc.frame.Width, npc.frame.Height); - if (rectangle.Intersects(npcrect)) //mouse cursor inside hitbox - { - drawColor = new Color((byte)(35 * num), (byte)(200f * num), (byte)(254f * num), Main.mouseTextColor); - - if (ContentConfig.Instance.Bosses) - { - if (npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType()) - { - ret = "Catch it with a net"; - } - } - - if (ContentConfig.Instance.HostileNPCs) - { - if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) - { - drawColor = Color.White * num; - ret = "Catch it with a net"; - } - } - - break; - } - } - } - return ret; - } - - //Update - public override void Update(GameTime gameTime) - { - //if (!visible) return; - if (Main.hoverItemName != "") return; - base.Update(gameTime); - - drawString = ""; - - int lastMouseXbak = Main.lastMouseX; - int lastMouseYbak = Main.lastMouseY; - int mouseXbak = Main.mouseX; - int mouseYbak = Main.mouseY; - int lastscreenWidthbak = Main.screenWidth; - int lastscreenHeightbak = Main.screenHeight; - - PlayerInput.SetZoom_Unscaled(); - PlayerInput.SetZoom_MouseInWorld(); - - //do stuff - //drawString = AlmostVanillaBehavior(); - drawString = Custom(); - - Main.lastMouseX = lastMouseXbak; - Main.lastMouseY = lastMouseYbak; - Main.mouseX = mouseXbak; - Main.mouseY = mouseYbak; - Main.screenWidth = lastscreenWidthbak; - Main.screenHeight = lastscreenHeightbak; - } - - //Draw - protected override void DrawSelf(SpriteBatch spriteBatch) - { - //if (!visible) return; - if (Main.hoverItemName != "") return; - base.DrawSelf(spriteBatch); - - if (drawString != "") Main.LocalPlayer.cursorItemIconEnabled = false; - Vector2 mousePos = new Vector2(Main.mouseX, Main.mouseY); - mousePos.X += 10; - mousePos.Y += 10; - if (Main.ThickMouse) - { - mousePos.X += 6; - mousePos.Y += 6; - } - - DynamicSpriteFont font = FontAssets.MouseText.Value; - Vector2 vector = font.MeasureString(drawString); - - if (mousePos.X + vector.X + 4f > Main.screenWidth) - { - mousePos.X = (int)((float)Main.screenWidth - vector.X - 4f); - } - if (mousePos.Y + vector.Y + 4f > Main.screenHeight) - { - mousePos.Y = (int)(Main.screenHeight - vector.Y - 4f); - } - - ChatManager.DrawColorCodedStringWithShadow(spriteBatch, font, drawString, mousePos + new Vector2(2, 24), drawColor, 0, Vector2.Zero, Vector2.One); - } - } + class HoverNPCUI : UIState + { + internal static bool visible = false; + internal static string drawString = ""; + internal static Color drawColor = Color.White; + + private string AlmostVanillaBehavior() + { + //works on dummies for some reason + Player player = Main.LocalPlayer; + string ret = ""; + Rectangle rectangle = new Rectangle((int)((float)Main.mouseX + Main.screenPosition.X), (int)((float)Main.mouseY + Main.screenPosition.Y), 1, 1); + if (player.gravDir == -1f) + { + rectangle.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY; + } + + float num = Main.mouseTextColor / 255f; + + for (int k = 0; k < Main.maxNPCs; k++) + { + //LoadNPC(Main.npc[k].type); //idk why + if (Main.npc[k].active) + { + Rectangle npcrect = new Rectangle((int)Main.npc[k].Bottom.X - Main.npc[k].frame.Width / 2, (int)Main.npc[k].Bottom.Y - Main.npc[k].frame.Height, Main.npc[k].frame.Width, Main.npc[k].frame.Height); + if (Main.npc[k].type >= NPCID.WyvernHead && Main.npc[k].type <= NPCID.WyvernTail) //Wyvern + { + npcrect = new Rectangle((int)((double)Main.npc[k].position.X + (double)Main.npc[k].width * 0.5 - 32.0), (int)((double)Main.npc[k].position.Y + (double)Main.npc[k].height * 0.5 - 32.0), 64, 64); + } + if (rectangle.Intersects(npcrect)) //mouse cursor inside hitbox + { + drawColor = new Color((byte)(255 * num), (byte)(255 * num), (byte)(255 * num), Main.mouseTextColor); + player.cursorItemIconEnabled = false; + ret = Main.npc[k].GivenOrTypeName; + int num2 = k; + if (Main.npc[k].realLife >= 0) + { + num2 = Main.npc[k].realLife; + } + if (Main.npc[num2].lifeMax > 1 && !Main.npc[num2].dontTakeDamage) + { + ret = ret + ": " + Main.npc[num2].life + "/" + Main.npc[num2].lifeMax; + } + break; + } + } + } + return ret; + } + + private string Custom() + { + Player player = Main.LocalPlayer; + string ret = ""; + Rectangle rectangle = new Rectangle((int)((float)Main.mouseX + Main.screenPosition.X), (int)((float)Main.mouseY + Main.screenPosition.Y), 1, 1); + if (player.gravDir == -1f) + { + rectangle.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY; + } + + float num = Main.mouseTextColor / 255f; + + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + if (npc.active) + { + Rectangle npcrect = new Rectangle((int)npc.Bottom.X - npc.frame.Width / 2, (int)npc.Bottom.Y - npc.frame.Height, npc.frame.Width, npc.frame.Height); + if (rectangle.Intersects(npcrect)) //mouse cursor inside hitbox + { + drawColor = new Color((byte)(35 * num), (byte)(200f * num), (byte)(254f * num), Main.mouseTextColor); + + if (ContentConfig.Instance.Bosses) + { + if (npc.type == ModContent.NPCType() || + npc.type == ModContent.NPCType()) + { + ret = "Catch it with a net"; + } + } + + if (ContentConfig.Instance.HostileNPCs) + { + if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) + { + drawColor = Color.White * num; + ret = "Catch it with a net"; + } + } + + break; + } + } + } + return ret; + } + + //Update + public override void Update(GameTime gameTime) + { + //if (!visible) return; + if (Main.hoverItemName != "") return; + base.Update(gameTime); + + drawString = ""; + + int lastMouseXbak = Main.lastMouseX; + int lastMouseYbak = Main.lastMouseY; + int mouseXbak = Main.mouseX; + int mouseYbak = Main.mouseY; + int lastscreenWidthbak = Main.screenWidth; + int lastscreenHeightbak = Main.screenHeight; + + PlayerInput.SetZoom_Unscaled(); + PlayerInput.SetZoom_MouseInWorld(); + + //do stuff + //drawString = AlmostVanillaBehavior(); + drawString = Custom(); + + Main.lastMouseX = lastMouseXbak; + Main.lastMouseY = lastMouseYbak; + Main.mouseX = mouseXbak; + Main.mouseY = mouseYbak; + Main.screenWidth = lastscreenWidthbak; + Main.screenHeight = lastscreenHeightbak; + } + + //Draw + protected override void DrawSelf(SpriteBatch spriteBatch) + { + //if (!visible) return; + if (Main.hoverItemName != "") return; + base.DrawSelf(spriteBatch); + + if (drawString != "") Main.LocalPlayer.cursorItemIconEnabled = false; + Vector2 mousePos = new Vector2(Main.mouseX, Main.mouseY); + mousePos.X += 10; + mousePos.Y += 10; + if (Main.ThickMouse) + { + mousePos.X += 6; + mousePos.Y += 6; + } + + DynamicSpriteFont font = FontAssets.MouseText.Value; + Vector2 vector = font.MeasureString(drawString); + + if (mousePos.X + vector.X + 4f > Main.screenWidth) + { + mousePos.X = (int)((float)Main.screenWidth - vector.X - 4f); + } + if (mousePos.Y + vector.Y + 4f > Main.screenHeight) + { + mousePos.Y = (int)(Main.screenHeight - vector.Y - 4f); + } + + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, font, drawString, mousePos + new Vector2(2, 24), drawColor, 0, Vector2.Zero, Vector2.One); + } + } } diff --git a/UI/PetVanityUI.cs b/UI/PetVanityUI.cs index 1c1abb3a..56debcf5 100644 --- a/UI/PetVanityUI.cs +++ b/UI/PetVanityUI.cs @@ -11,199 +11,199 @@ namespace AssortedCrazyThings.UI { - //TODO redo that - class PetVanityUI : UIState - { - internal const int NONE = -1; - - internal const int IGNORE = -2; - - /// - /// Circle diameter - /// - internal const int mainDiameter = 36; - - /// - /// Circle radius - /// - internal const int mainRadius = mainDiameter / 2; - - /// - /// Is the UI visible? - /// - internal static bool visible = false; - - /// - /// Spawn position, i.e. mouse position at UI start - /// - internal static Vector2 spawnPosition = default(Vector2); - - /// - /// If pet currently has something of that type in that slot - /// - internal static bool hasEquipped = false; - - /// - /// Which thing is currently highlighted? - /// - internal static int returned = NONE; - - /// - /// Fade in animation when opening the UI - /// - internal static float fadeIn = 0; - - /// - /// Red cross for when to unequip - /// - internal static Asset redCrossTexture; - - /// - /// Holds data about what to draw - /// - internal static PetAccessory petAccessory; - - /// - /// Spawn position offset to top left corner of that to draw the icons - /// - private Vector2 TopLeftCorner - { - get - { - return spawnPosition - new Vector2(mainRadius, mainRadius); - } - } - - //Initialization - public override void OnInitialize() - { - redCrossTexture = AssUtils.Instance.Assets.Request("UI/UIRedCross"); - } - - //Update, unused - public override void Update(GameTime gameTime) - { - base.Update(gameTime); - } - - //Draw - protected override void DrawSelf(SpriteBatch spriteBatch) - { - base.DrawSelf(spriteBatch); - Main.LocalPlayer.mouseInterface = true; - - //48 - int outerRadius = 48; - if (petAccessory.AltTextures.Count > 5) outerRadius += 5 * (petAccessory.AltTextures.Count - 5); //increase by 5 after having more than 5 options, starts getting clumped at about 24 circles - if (fadeIn < outerRadius) outerRadius = (int)(fadeIn += (float)outerRadius / 10); - - double angleSteps = 2.0d / petAccessory.AltTextures.Count; - int done; - //done --> ID of currently drawn circle - for (done = 0; done < petAccessory.AltTextures.Count; done++) - { - double x = outerRadius * Math.Sin(angleSteps * done * Math.PI); - double y = outerRadius * -Math.Cos(angleSteps * done * Math.PI); - - - Rectangle bgRect = new Rectangle((int)(TopLeftCorner.X + x), (int)(TopLeftCorner.Y + y), mainDiameter, mainDiameter); - //Check if mouse is within the circle checked - bool isMouseWithin = CircleUI.CheckMouseWithinWheel(Main.MouseScreen, spawnPosition, mainRadius, petAccessory.AltTextures.Count, done); - - //Actually draw the bg circle - Color drawColor = Color.White; - if (hasEquipped && done == petAccessory.AltTextureIndex) - { - drawColor = Color.Gray; - } - Main.spriteBatch.Draw(TextureAssets.WireUi[isMouseWithin ? 1 : 0].Value, bgRect, drawColor); - - //Draw sprites over the icons - Texture2D tex = petAccessory.AltTextures[done].Value; - int width = tex.Width; - int height = tex.Height; - Rectangle projRect = new Rectangle((int)(spawnPosition.X + x) - (width / 2), (int)(spawnPosition.Y + y) - (height / 2), width, height); - - drawColor = Color.White; - if (hasEquipped && done == petAccessory.AltTextureIndex) drawColor = Color.Gray; - - Main.spriteBatch.Draw(tex, projRect, tex.Bounds, drawColor); - - if (isMouseWithin) - { - //set the "returned" new type - returned = done; - //In UpdatePetVanityUI(): else if (returned == IGNORE) {nothing happens} - if (hasEquipped && done == petAccessory.AltTextureIndex) returned = IGNORE; - } - } - - //Draw held item bg circle - Rectangle outputRect = new Rectangle((int)TopLeftCorner.X, (int)TopLeftCorner.Y, mainDiameter, mainDiameter); - - bool middle = CircleUI.CheckMouseWithinCircle(Main.MouseScreen, mainRadius, spawnPosition); - - Main.spriteBatch.Draw(TextureAssets.WireUi[middle ? 1 : 0].Value, outputRect, Color.White); - - //Draw held item inside circle - if (petAccessory.Type != -1) - { - Asset asset = TextureAssets.Item[petAccessory.Type]; - int finalWidth = asset.Width(); - int finalHeight = asset.Height(); - Rectangle outputWeaponRect = new Rectangle((int)spawnPosition.X - (finalWidth / 2), (int)spawnPosition.Y - (finalHeight / 2), finalWidth, finalHeight); - //outputWeaponRect.Inflate(4, 4); - Main.spriteBatch.Draw(asset.Value, outputWeaponRect, Color.White); - } - - if (middle) - { - //if hovering over the middle, reset color - returned = NONE; - if (hasEquipped) - { - //Draw the red cross - Texture2D redCrossTex = redCrossTexture.Value; - int finalWidth = redCrossTex.Width; - int finalHeight = redCrossTex.Height; - Rectangle outputCrossRect = new Rectangle((int)spawnPosition.X - (finalWidth / 2), (int)spawnPosition.Y - (finalHeight / 2), finalWidth, finalHeight); - Main.spriteBatch.Draw(redCrossTex, outputCrossRect, Color.White); - - //Draw the tooltip - Color fontColor = Color.White; - Vector2 mousePos = new Vector2(Main.mouseX, Main.mouseY); - ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, "Unequip", mousePos + new Vector2(16, 16), fontColor, 0, Vector2.Zero, Vector2.One); - } - } - - //extra loop so tooltips are always drawn after the circles - for (done = 0; done < petAccessory.AltTextures.Count; done++) - { - bool isMouseWithin = CircleUI.CheckMouseWithinWheel(Main.MouseScreen, spawnPosition, mainRadius, petAccessory.AltTextures.Count, done); - string tooltip = petAccessory.AltTextureSuffixes[done]; - - if (isMouseWithin) - { - //Draw the tooltip - Color fontColor = Color.White; - Vector2 mousePos = new Vector2(Main.mouseX, Main.mouseY); - ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, tooltip, mousePos + new Vector2(16, 16), fontColor, 0, Vector2.Zero, Vector2.One); - } - } - } - - /// - /// Called when the UI is about to appear - /// - public static void Start(PetAccessory pAccessory) - { - visible = true; - spawnPosition = Main.MouseScreen; - petAccessory = pAccessory; - PetPlayer pPlayer = Main.LocalPlayer.GetModPlayer(); - pPlayer.TryGetAccessoryInSlot((byte)petAccessory.Slot, out PetAccessory equipped); - hasEquipped = equipped != null && equipped.Type == petAccessory.Type; - fadeIn = 0; - } - } + //TODO redo that + class PetVanityUI : UIState + { + internal const int NONE = -1; + + internal const int IGNORE = -2; + + /// + /// Circle diameter + /// + internal const int mainDiameter = 36; + + /// + /// Circle radius + /// + internal const int mainRadius = mainDiameter / 2; + + /// + /// Is the UI visible? + /// + internal static bool visible = false; + + /// + /// Spawn position, i.e. mouse position at UI start + /// + internal static Vector2 spawnPosition = default(Vector2); + + /// + /// If pet currently has something of that type in that slot + /// + internal static bool hasEquipped = false; + + /// + /// Which thing is currently highlighted? + /// + internal static int returned = NONE; + + /// + /// Fade in animation when opening the UI + /// + internal static float fadeIn = 0; + + /// + /// Red cross for when to unequip + /// + internal static Asset redCrossTexture; + + /// + /// Holds data about what to draw + /// + internal static PetAccessory petAccessory; + + /// + /// Spawn position offset to top left corner of that to draw the icons + /// + private Vector2 TopLeftCorner + { + get + { + return spawnPosition - new Vector2(mainRadius, mainRadius); + } + } + + //Initialization + public override void OnInitialize() + { + redCrossTexture = AssUtils.Instance.Assets.Request("UI/UIRedCross"); + } + + //Update, unused + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + } + + //Draw + protected override void DrawSelf(SpriteBatch spriteBatch) + { + base.DrawSelf(spriteBatch); + Main.LocalPlayer.mouseInterface = true; + + //48 + int outerRadius = 48; + if (petAccessory.AltTextures.Count > 5) outerRadius += 5 * (petAccessory.AltTextures.Count - 5); //increase by 5 after having more than 5 options, starts getting clumped at about 24 circles + if (fadeIn < outerRadius) outerRadius = (int)(fadeIn += (float)outerRadius / 10); + + double angleSteps = 2.0d / petAccessory.AltTextures.Count; + int done; + //done --> ID of currently drawn circle + for (done = 0; done < petAccessory.AltTextures.Count; done++) + { + double x = outerRadius * Math.Sin(angleSteps * done * Math.PI); + double y = outerRadius * -Math.Cos(angleSteps * done * Math.PI); + + + Rectangle bgRect = new Rectangle((int)(TopLeftCorner.X + x), (int)(TopLeftCorner.Y + y), mainDiameter, mainDiameter); + //Check if mouse is within the circle checked + bool isMouseWithin = CircleUI.CheckMouseWithinWheel(Main.MouseScreen, spawnPosition, mainRadius, petAccessory.AltTextures.Count, done); + + //Actually draw the bg circle + Color drawColor = Color.White; + if (hasEquipped && done == petAccessory.AltTextureIndex) + { + drawColor = Color.Gray; + } + Main.spriteBatch.Draw(TextureAssets.WireUi[isMouseWithin ? 1 : 0].Value, bgRect, drawColor); + + //Draw sprites over the icons + Texture2D tex = petAccessory.AltTextures[done].Value; + int width = tex.Width; + int height = tex.Height; + Rectangle projRect = new Rectangle((int)(spawnPosition.X + x) - (width / 2), (int)(spawnPosition.Y + y) - (height / 2), width, height); + + drawColor = Color.White; + if (hasEquipped && done == petAccessory.AltTextureIndex) drawColor = Color.Gray; + + Main.spriteBatch.Draw(tex, projRect, tex.Bounds, drawColor); + + if (isMouseWithin) + { + //set the "returned" new type + returned = done; + //In UpdatePetVanityUI(): else if (returned == IGNORE) {nothing happens} + if (hasEquipped && done == petAccessory.AltTextureIndex) returned = IGNORE; + } + } + + //Draw held item bg circle + Rectangle outputRect = new Rectangle((int)TopLeftCorner.X, (int)TopLeftCorner.Y, mainDiameter, mainDiameter); + + bool middle = CircleUI.CheckMouseWithinCircle(Main.MouseScreen, mainRadius, spawnPosition); + + Main.spriteBatch.Draw(TextureAssets.WireUi[middle ? 1 : 0].Value, outputRect, Color.White); + + //Draw held item inside circle + if (petAccessory.Type != -1) + { + Asset asset = TextureAssets.Item[petAccessory.Type]; + int finalWidth = asset.Width(); + int finalHeight = asset.Height(); + Rectangle outputWeaponRect = new Rectangle((int)spawnPosition.X - (finalWidth / 2), (int)spawnPosition.Y - (finalHeight / 2), finalWidth, finalHeight); + //outputWeaponRect.Inflate(4, 4); + Main.spriteBatch.Draw(asset.Value, outputWeaponRect, Color.White); + } + + if (middle) + { + //if hovering over the middle, reset color + returned = NONE; + if (hasEquipped) + { + //Draw the red cross + Texture2D redCrossTex = redCrossTexture.Value; + int finalWidth = redCrossTex.Width; + int finalHeight = redCrossTex.Height; + Rectangle outputCrossRect = new Rectangle((int)spawnPosition.X - (finalWidth / 2), (int)spawnPosition.Y - (finalHeight / 2), finalWidth, finalHeight); + Main.spriteBatch.Draw(redCrossTex, outputCrossRect, Color.White); + + //Draw the tooltip + Color fontColor = Color.White; + Vector2 mousePos = new Vector2(Main.mouseX, Main.mouseY); + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, "Unequip", mousePos + new Vector2(16, 16), fontColor, 0, Vector2.Zero, Vector2.One); + } + } + + //extra loop so tooltips are always drawn after the circles + for (done = 0; done < petAccessory.AltTextures.Count; done++) + { + bool isMouseWithin = CircleUI.CheckMouseWithinWheel(Main.MouseScreen, spawnPosition, mainRadius, petAccessory.AltTextures.Count, done); + string tooltip = petAccessory.AltTextureSuffixes[done]; + + if (isMouseWithin) + { + //Draw the tooltip + Color fontColor = Color.White; + Vector2 mousePos = new Vector2(Main.mouseX, Main.mouseY); + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, tooltip, mousePos + new Vector2(16, 16), fontColor, 0, Vector2.Zero, Vector2.One); + } + } + } + + /// + /// Called when the UI is about to appear + /// + public static void Start(PetAccessory pAccessory) + { + visible = true; + spawnPosition = Main.MouseScreen; + petAccessory = pAccessory; + PetPlayer pPlayer = Main.LocalPlayer.GetModPlayer(); + pPlayer.TryGetAccessoryInSlot((byte)petAccessory.Slot, out PetAccessory equipped); + hasEquipped = equipped != null && equipped.Type == petAccessory.Type; + fadeIn = 0; + } + } }