diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index cea0943cdd..8eed5ff6f4 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -22,6 +22,15 @@ internal static readonly int DaedalusReflectCooldown = 5400; internal static readonly int EvolutionReflectCooldown = 7200; + // Internal vanilla item damage variables + internal static readonly float LeatherWhipTagDamageMultiplier = 1.08f; + internal static readonly float SnapthornTagDamageMultiplier = 1.04f; + internal static readonly float SpinalTapTagDamageMultiplier = 1.08f; + internal static readonly float FirecrackerExplosionDamageMultiplier = 2.25f; // Relative to the whip, not the summon. + internal static readonly float DurendalTagDamageMultiplier = 1.09f; + internal static readonly float MorningStarTagDamageMultiplier = 1.11f; + internal static readonly float KaleidoscopeTagDamageMultiplier = 1.12f; + // TODO -- Add all balance related constants here that don't belong in other files. // These constants were just the ones sitting in CalamityPlayer. // Review all constants and static readonlys in the entire mod to find things to add. diff --git a/CalamityMod.cs b/CalamityMod.cs index 8630a3dbee..a49ae6e3c7 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -86,8 +86,6 @@ namespace CalamityMod public static Asset rainOriginal; public static Asset manaOriginal; public static Asset carpetOriginal; - public static Texture2D AstralCactusTexture; - public static Texture2D AstralCactusGlowTexture; public static Texture2D AstralSky; // DR data structure @@ -211,8 +209,6 @@ namespace CalamityMod private void LoadClient() { - AstralCactusTexture = ModContent.Request("CalamityMod/ExtraTextures/Tiles/AstralCactus", AssetRequestMode.ImmediateLoad).Value; - AstralCactusGlowTexture = ModContent.Request("CalamityMod/ExtraTextures/Tiles/AstralCactusGlow", AssetRequestMode.ImmediateLoad).Value; AstralSky = ModContent.Request("CalamityMod/ExtraTextures/AstralSky", AssetRequestMode.ImmediateLoad).Value; Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.1f, 1.0f).UseOpacity(0.5f), EffectPriority.VeryHigh); @@ -304,8 +300,6 @@ namespace CalamityMod thorium = null; varia = null; - AstralCactusTexture = null; - AstralCactusGlowTexture = null; AstralSky = null; DRValues?.Clear(); diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index d7f7c27ef2..a10ad0827b 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -102,6 +102,7 @@ namespace CalamityMod.ILEditing IL.Terraria.Projectile.CanExplodeTile += MakeMeteoriteExplodable; IL.Terraria.Main.UpdateTime_StartNight += BloodMoonsRequire200MaxLife; IL.Terraria.WorldGen.AttemptFossilShattering += PreventFossilShattering; + IL.Terraria.Projectile.Damage += MakeTagDamageMultiplicative; // Fix vanilla bugs exposed by Calamity mechanics IL.Terraria.NPC.NPCLoot += FixSplittingWormBannerDrops; @@ -184,6 +185,7 @@ namespace CalamityMod.ILEditing IL.Terraria.Projectile.CanExplodeTile -= MakeMeteoriteExplodable; IL.Terraria.Main.UpdateTime_StartNight -= BloodMoonsRequire200MaxLife; IL.Terraria.WorldGen.AttemptFossilShattering -= PreventFossilShattering; + IL.Terraria.Projectile.Damage -= MakeTagDamageMultiplicative; // Fix vanilla bugs exposed by Calamity mechanics // On.Terraria.Main.InitLifeBytes -= BossRushLifeBytes; diff --git a/ILEditing/VanillaStupidityFixingILChanges.cs b/ILEditing/VanillaStupidityFixingILChanges.cs index 293254ee2c..b4cc23baa8 100644 --- a/ILEditing/VanillaStupidityFixingILChanges.cs +++ b/ILEditing/VanillaStupidityFixingILChanges.cs @@ -1,8 +1,11 @@ -using Mono.Cecil.Cil; +using CalamityMod.Balancing; +using Microsoft.Xna.Framework; +using Mono.Cecil.Cil; using MonoMod.Cil; using System; using Terraria; using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.ILEditing { @@ -220,6 +223,96 @@ namespace CalamityMod.ILEditing } #endregion + #region Make Tag Damage Multiplicative + private static void MakeTagDamageMultiplicative(ILContext il) + { + var cursor = new ILCursor(il); + int damageLocalIndex = 37; + + bool replaceWithMultipler(int flagLocalIndex, float damageFactor, bool usesExtraVariableToStoreDamage = false) + { + // Move after the bool load and branch-if-false instruction. + cursor.Goto(0); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdloc(flagLocalIndex))) + { + LogFailure("Making Tag Damage Multiplicative", $"Could not locate the flag local index of '{flagLocalIndex}'."); + return false; + } + cursor.Index += 2; + + // OPTIONAL case for if an extra variable to store damage is used: + // Load damage to add. + // Store damage to add as a variable. + + // Load damage -> + // Load damage addition -> + // Add the two -> + // Store damage. + cursor.RemoveRange(usesExtraVariableToStoreDamage ? 6 : 4); + + // Load damage -> + // Cast damage to float -> + // Load the damage factor -> + // Multiply the two -> + // Cast the result to int, removing the fractional part -> + // Store damage. + cursor.Emit(OpCodes.Ldloc, damageLocalIndex); + cursor.Emit(OpCodes.Conv_R4); + cursor.Emit(OpCodes.Ldc_R4, damageFactor); + cursor.Emit(OpCodes.Mul); + cursor.Emit(OpCodes.Conv_I4); + cursor.Emit(OpCodes.Stloc, damageLocalIndex); + return true; + } + + // Leather whip. + replaceWithMultipler(50, BalancingConstants.LeatherWhipTagDamageMultiplier); + + // Durendal. + replaceWithMultipler(51, BalancingConstants.DurendalTagDamageMultiplier); + + // Snapthorn. + replaceWithMultipler(54, BalancingConstants.SnapthornTagDamageMultiplier); + + // Spinal Tap. + replaceWithMultipler(55, BalancingConstants.SpinalTapTagDamageMultiplier); + + // Morning Star. + replaceWithMultipler(56, BalancingConstants.MorningStarTagDamageMultiplier); + + // Kaleidoscope. + replaceWithMultipler(57, BalancingConstants.KaleidoscopeTagDamageMultiplier, true); + + // SPECIAL CASE: Firecracker's damage is fucking absurd and everything needs to go. + cursor.Goto(0); + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(64))) + { + LogFailure("Making Tag Damage Multiplicative", $"Could not locate the flag local index of 52."); + return; + } + + // Change the damage of the explosions. + cursor.Emit(OpCodes.Ldarg_0); + cursor.EmitDelegate>(projectile => + { + int damage = (int)(Main.player[projectile.owner].ActiveItem().damage * BalancingConstants.FirecrackerExplosionDamageMultiplier); + damage = (int)Main.player[projectile.owner].GetDamage(DamageClass.Summon).ApplyTo(damage); + return damage; + }); + cursor.Emit(OpCodes.Stloc, 64); + + // Change the x in damage += x; to zero. + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchAdd())) + { + LogFailure("Making Tag Damage Multiplicative", $"Could not locate the damage additive value."); + return; + } + cursor.Index--; + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4_0); + } + #endregion Make Tag Damage Multiplicative + #region Fix Chlorophyte Crystal Attacking Where it Shouldn't #endregion Fix Chlorophyte Crystal Attacking Where it Shouldn't diff --git a/Items/Ammo/AstralSolution.cs b/Items/Ammo/AstralSolution.cs index f7a5264f95..12b13e3aeb 100644 --- a/Items/Ammo/AstralSolution.cs +++ b/Items/Ammo/AstralSolution.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Ammo return; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { return !(player.itemAnimation < player.ActiveItem().useAnimation - 3); } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 901cde3a65..b11c44444f 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1576,7 +1576,7 @@ namespace CalamityMod.Items #endregion #region Ammo - public override bool CanConsumeAmmo(Item item, Player player) => Main.rand.NextFloat() <= player.Calamity().rangedAmmoCost; + public override bool CanConsumeAmmo(Item weapon, Item ammo, Player player) => Main.rand.NextFloat() <= player.Calamity().rangedAmmoCost; public static bool HasEnoughAmmo(Player player, Item item, int ammoConsumed) { diff --git a/Items/Weapons/Magic/IceBarrage.cs b/Items/Weapons/Magic/IceBarrage.cs index 95dfb4663c..da07464d03 100644 --- a/Items/Weapons/Magic/IceBarrage.cs +++ b/Items/Weapons/Magic/IceBarrage.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => CalamityGlobalItem.HasEnoughAmmo(player, Item, 2); - public override bool CanConsumeAmmo(Player player) => false; + public override bool CanConsumeAmmo(Item ammo, Player player) => false; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Ranged/Animosity.cs b/Items/Weapons/Ranged/Animosity.cs index aaf08f6426..1bd98d26b0 100644 --- a/Items/Weapons/Ranged/Animosity.cs +++ b/Items/Weapons/Ranged/Animosity.cs @@ -87,7 +87,7 @@ Right click to fire a burst of bullets"); } } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50) return false; diff --git a/Items/Weapons/Ranged/Auralis.cs b/Items/Weapons/Ranged/Auralis.cs index e9dfbcb021..a55c3ca8ff 100644 --- a/Items/Weapons/Ranged/Auralis.cs +++ b/Items/Weapons/Ranged/Auralis.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override bool CanConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 50; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/AuroraBlazer.cs b/Items/Weapons/Ranged/AuroraBlazer.cs index 683bcb9b7c..c99834dff2 100644 --- a/Items/Weapons/Ranged/AuroraBlazer.cs +++ b/Items/Weapons/Ranged/AuroraBlazer.cs @@ -55,6 +55,6 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override bool CanConsumeAmmo(Player player) => Main.rand.Next(100) >= 60; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 60; } } diff --git a/Items/Weapons/Ranged/BulletFilledShotgun.cs b/Items/Weapons/Ranged/BulletFilledShotgun.cs index 2e8cd62728..1de66a3cc4 100644 --- a/Items/Weapons/Ranged/BulletFilledShotgun.cs +++ b/Items/Weapons/Ranged/BulletFilledShotgun.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) => CalamityGlobalItem.HasEnoughAmmo(player, Item, 5); // Disable vanilla ammo consumption - public override bool CanConsumeAmmo(Player player) => false; + public override bool CanConsumeAmmo(Item ammo, Player player) => false; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Ranged/ChickenCannon.cs b/Items/Weapons/Ranged/ChickenCannon.cs index 13dbdade32..000aa02e36 100644 --- a/Items/Weapons/Ranged/ChickenCannon.cs +++ b/Items/Weapons/Ranged/ChickenCannon.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool AltFunctionUse(Player player) => true; // Right click doesn't use ammo because it's a detonation signal. - public override bool CanConsumeAmmo(Player player) => player.altFunctionUse != 2; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.altFunctionUse != 2; public override bool CanUseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 || player.altFunctionUse == 2; diff --git a/Items/Weapons/Ranged/CleansingBlaze.cs b/Items/Weapons/Ranged/CleansingBlaze.cs index dd9bdd64d2..2c7c2664e4 100644 --- a/Items/Weapons/Ranged/CleansingBlaze.cs +++ b/Items/Weapons/Ranged/CleansingBlaze.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-5, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 90) return false; diff --git a/Items/Weapons/Ranged/ClockGatlignum.cs b/Items/Weapons/Ranged/ClockGatlignum.cs index 1764bba9c4..6bd446563e 100644 --- a/Items/Weapons/Ranged/ClockGatlignum.cs +++ b/Items/Weapons/Ranged/ClockGatlignum.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 33) return false; diff --git a/Items/Weapons/Ranged/DragonsBreath.cs b/Items/Weapons/Ranged/DragonsBreath.cs index 0ed55a7480..f4e4b5e075 100644 --- a/Items/Weapons/Ranged/DragonsBreath.cs +++ b/Items/Weapons/Ranged/DragonsBreath.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.Calamity().customRarity = CalamityRarity.Violet; Item.value = CalamityGlobalItem.Rarity15BuyPrice; } - public override bool CanConsumeAmmo(Player player) => Main.rand.NextFloat() > 0.66f; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.66f; public override Vector2? HoldoutOffset() => new Vector2(-5, 5); diff --git a/Items/Weapons/Ranged/ElementalEruption.cs b/Items/Weapons/Ranged/ElementalEruption.cs index 24384418ac..5f91cbb3cb 100644 --- a/Items/Weapons/Ranged/ElementalEruption.cs +++ b/Items/Weapons/Ranged/ElementalEruption.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) => Main.rand.NextFloat() > 0.9f; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.9f; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/FetidEmesis.cs b/Items/Weapons/Ranged/FetidEmesis.cs index c7e82dd7a7..b7331d479b 100644 --- a/Items/Weapons/Ranged/FetidEmesis.cs +++ b/Items/Weapons/Ranged/FetidEmesis.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.Calamity().canFirePointBlankShots = true; } - public override bool CanConsumeAmmo(Player player) => Main.rand.Next(100) > 40; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) > 40; public override Vector2? HoldoutOffset() => new Vector2(-5, 0); diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index f1009f1cf0..1686e4b92f 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override bool CanConsumeAmmo(Player player) => Main.rand.Next(100) >= 70; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 70; public override bool AltFunctionUse(Player player) => true; diff --git a/Items/Weapons/Ranged/FlurrystormCannon.cs b/Items/Weapons/Ranged/FlurrystormCannon.cs index 25b3dcdccf..246b7a1dc9 100644 --- a/Items/Weapons/Ranged/FlurrystormCannon.cs +++ b/Items/Weapons/Ranged/FlurrystormCannon.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50) return false; diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index da70bb5db2..70fa6f71af 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-15, 0); - public override bool CanConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 50; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/HeavenlyGale.cs b/Items/Weapons/Ranged/HeavenlyGale.cs index 83cc7835da..3a69e39bfc 100644 --- a/Items/Weapons/Ranged/HeavenlyGale.cs +++ b/Items/Weapons/Ranged/HeavenlyGale.cs @@ -98,7 +98,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 66) return false; diff --git a/Items/Weapons/Ranged/Interfacer.cs b/Items/Weapons/Ranged/Interfacer.cs index c537a24a79..4eecdada85 100644 --- a/Items/Weapons/Ranged/Interfacer.cs +++ b/Items/Weapons/Ranged/Interfacer.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-10, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50) return false; diff --git a/Items/Weapons/Ranged/Karasawa.cs b/Items/Weapons/Ranged/Karasawa.cs index 516dabc145..9f90a5e905 100644 --- a/Items/Weapons/Ranged/Karasawa.cs +++ b/Items/Weapons/Ranged/Karasawa.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Items.Weapons.Ranged } // Disable vanilla ammo consumption - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { return false; } diff --git a/Items/Weapons/Ranged/MagnomalyCannon.cs b/Items/Weapons/Ranged/MagnomalyCannon.cs index 539b062f49..2d2368b9e5 100644 --- a/Items/Weapons/Ranged/MagnomalyCannon.cs +++ b/Items/Weapons/Ranged/MagnomalyCannon.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 66) return false; diff --git a/Items/Weapons/Ranged/Megafleet.cs b/Items/Weapons/Ranged/Megafleet.cs index 75f7fbbb0a..4c056da550 100644 --- a/Items/Weapons/Ranged/Megafleet.cs +++ b/Items/Weapons/Ranged/Megafleet.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50 || shotType % 2 == 0) return false; diff --git a/Items/Weapons/Ranged/Megalodon.cs b/Items/Weapons/Ranged/Megalodon.cs index 0045f9d849..ade067808b 100644 --- a/Items/Weapons/Ranged/Megalodon.cs +++ b/Items/Weapons/Ranged/Megalodon.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (shotType == 2) return false; diff --git a/Items/Weapons/Ranged/Meowthrower.cs b/Items/Weapons/Ranged/Meowthrower.cs index 79388a7909..0713c79eaf 100644 --- a/Items/Weapons/Ranged/Meowthrower.cs +++ b/Items/Weapons/Ranged/Meowthrower.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-10, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50) return false; diff --git a/Items/Weapons/Ranged/Minigun.cs b/Items/Weapons/Ranged/Minigun.cs index 2cdcf14946..8d1521c20a 100644 --- a/Items/Weapons/Ranged/Minigun.cs +++ b/Items/Weapons/Ranged/Minigun.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) => Main.rand.NextFloat() > 0.8f; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.8f; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/OnyxChainBlaster.cs b/Items/Weapons/Ranged/OnyxChainBlaster.cs index 7e8db74b59..cb1c8cfde4 100644 --- a/Items/Weapons/Ranged/OnyxChainBlaster.cs +++ b/Items/Weapons/Ranged/OnyxChainBlaster.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50) return false; diff --git a/Items/Weapons/Ranged/Onyxia.cs b/Items/Weapons/Ranged/Onyxia.cs index 8ad5ed9ffe..5e4e915db4 100644 --- a/Items/Weapons/Ranged/Onyxia.cs +++ b/Items/Weapons/Ranged/Onyxia.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < NotConsumeAmmo) return false; diff --git a/Items/Weapons/Ranged/OverloadedBlaster.cs b/Items/Weapons/Ranged/OverloadedBlaster.cs index 1ffccbbaa4..d1c36b75ce 100644 --- a/Items/Weapons/Ranged/OverloadedBlaster.cs +++ b/Items/Weapons/Ranged/OverloadedBlaster.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-4, -5); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 33) return false; diff --git a/Items/Weapons/Ranged/P90.cs b/Items/Weapons/Ranged/P90.cs index 4b2b600d3f..5a30b98d53 100644 --- a/Items/Weapons/Ranged/P90.cs +++ b/Items/Weapons/Ranged/P90.cs @@ -51,6 +51,6 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) => Main.rand.NextFloat() < 0.5f; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() < 0.5f; } } diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index fc4db51a81..365a652940 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -104,7 +104,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) => Main.rand.NextFloat() > AmmoNotConsumeChance; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > AmmoNotConsumeChance; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/PrideHuntersPlanarRipper.cs b/Items/Weapons/Ranged/PrideHuntersPlanarRipper.cs index e671562d72..fd62c2f6e2 100644 --- a/Items/Weapons/Ranged/PrideHuntersPlanarRipper.cs +++ b/Items/Weapons/Ranged/PrideHuntersPlanarRipper.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-12, -6); - public override bool CanConsumeAmmo(Player player) => Main.rand.Next(0, 100) >= 33; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(0, 100) >= 33; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Ranged/SDFMG.cs b/Items/Weapons/Ranged/SDFMG.cs index 1eff9efa3c..15c1591182 100644 --- a/Items/Weapons/Ranged/SDFMG.cs +++ b/Items/Weapons/Ranged/SDFMG.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50) return false; diff --git a/Items/Weapons/Ranged/SandstormGun.cs b/Items/Weapons/Ranged/SandstormGun.cs index 0de0ed9d16..f634a97383 100644 --- a/Items/Weapons/Ranged/SandstormGun.cs +++ b/Items/Weapons/Ranged/SandstormGun.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-10, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50) return false; diff --git a/Items/Weapons/Ranged/ScorchedEarth.cs b/Items/Weapons/Ranged/ScorchedEarth.cs index 0b4f372c71..3e42ca1072 100644 --- a/Items/Weapons/Ranged/ScorchedEarth.cs +++ b/Items/Weapons/Ranged/ScorchedEarth.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Ranged } // Consume two ammo per fire - public override bool CanConsumeAmmo(Player player) => counter % 2 == 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => counter % 2 == 0; public override Vector2? HoldoutOffset() => new Vector2(-30, 0); diff --git a/Items/Weapons/Ranged/Seadragon.cs b/Items/Weapons/Ranged/Seadragon.cs index d4c005232c..92e0d019dc 100644 --- a/Items/Weapons/Ranged/Seadragon.cs +++ b/Items/Weapons/Ranged/Seadragon.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (shotType % 2 == 0) return false; diff --git a/Items/Weapons/Ranged/Shadethrower.cs b/Items/Weapons/Ranged/Shadethrower.cs index 5d9e4e602e..ee7b5f2c55 100644 --- a/Items/Weapons/Ranged/Shadethrower.cs +++ b/Items/Weapons/Ranged/Shadethrower.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-5, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 66) return false; diff --git a/Items/Weapons/Ranged/SomaPrime.cs b/Items/Weapons/Ranged/SomaPrime.cs index 5c2c10273d..51b4cb5852 100644 --- a/Items/Weapons/Ranged/SomaPrime.cs +++ b/Items/Weapons/Ranged/SomaPrime.cs @@ -71,7 +71,7 @@ Replaces standard bullets with High Velocity Bullets return false; } - public override bool CanConsumeAmmo(Player player) => Main.rand.NextFloat() > 0.8f; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.8f; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index fc039b7c3e..396faab615 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-4, 0); - public override bool CanConsumeAmmo(Player player) => Main.rand.Next(100) >= 70; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 70; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/SpectralstormCannon.cs b/Items/Weapons/Ranged/SpectralstormCannon.cs index 6a35b68f56..0a5fe65950 100644 --- a/Items/Weapons/Ranged/SpectralstormCannon.cs +++ b/Items/Weapons/Ranged/SpectralstormCannon.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 70) return false; diff --git a/Items/Weapons/Ranged/StarSputter.cs b/Items/Weapons/Ranged/StarSputter.cs index 1100efc8bf..09bc5c7e90 100644 --- a/Items/Weapons/Ranged/StarSputter.cs +++ b/Items/Weapons/Ranged/StarSputter.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-5, 0); } - public override bool CanConsumeAmmo(Player player) //consume ammo only once per round + public override bool CanConsumeAmmo(Item ammo, Player player) //consume ammo only once per round { if (counter == 1 || counter == 2 || counter == 4 || counter == 5 || counter == 7 || counter == 8 || counter == 10 || counter == 11) return false; diff --git a/Items/Weapons/Ranged/StormDragoon.cs b/Items/Weapons/Ranged/StormDragoon.cs index 2746d5fdf9..bc5037ab40 100644 --- a/Items/Weapons/Ranged/StormDragoon.cs +++ b/Items/Weapons/Ranged/StormDragoon.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 90) return false; diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index 7cded681a5..d6a632438d 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-5, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 70) return false; diff --git a/Items/Weapons/Ranged/TerraFlameburster.cs b/Items/Weapons/Ranged/TerraFlameburster.cs index bc54739976..175d323abb 100644 --- a/Items/Weapons/Ranged/TerraFlameburster.cs +++ b/Items/Weapons/Ranged/TerraFlameburster.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-10, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 80) return false; diff --git a/Items/Weapons/Ranged/TheEmpyrean.cs b/Items/Weapons/Ranged/TheEmpyrean.cs index 540fbad471..329878ae8b 100644 --- a/Items/Weapons/Ranged/TheEmpyrean.cs +++ b/Items/Weapons/Ranged/TheEmpyrean.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-10, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 70) return false; diff --git a/Items/Weapons/Ranged/TrueConferenceCall.cs b/Items/Weapons/Ranged/TrueConferenceCall.cs index 205c9bcd14..d126b5af31 100644 --- a/Items/Weapons/Ranged/TrueConferenceCall.cs +++ b/Items/Weapons/Ranged/TrueConferenceCall.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-10, 0); } - public override bool CanConsumeAmmo(Player player) + public override bool CanConsumeAmmo(Item ammo, Player player) { if (Main.rand.Next(0, 100) < 50) return false; diff --git a/Items/Weapons/Ranged/Ultima.cs b/Items/Weapons/Ranged/Ultima.cs index bb84026e9e..eb08bf3a0a 100644 --- a/Items/Weapons/Ranged/Ultima.cs +++ b/Items/Weapons/Ranged/Ultima.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) => Main.rand.Next(0, 100) >= 90; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(0, 100) >= 90; public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/UniversalGenesis.cs b/Items/Weapons/Ranged/UniversalGenesis.cs index cd0f8a1e35..6a0c7cae26 100644 --- a/Items/Weapons/Ranged/UniversalGenesis.cs +++ b/Items/Weapons/Ranged/UniversalGenesis.cs @@ -98,7 +98,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Player player) => Main.rand.NextBool(); + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool(); public override void AddRecipes() { diff --git a/Projectiles/Magic/AetherfluxCannonHoldout.cs b/Projectiles/Magic/AetherfluxCannonHoldout.cs index e17b54ddc2..67f8c32038 100644 --- a/Projectiles/Magic/AetherfluxCannonHoldout.cs +++ b/Projectiles/Magic/AetherfluxCannonHoldout.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Magic private const int FramesPerFireRateIncrease = 36; private Player Owner => Main.player[Projectile.owner]; - private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; + private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem()) && !Owner.noItems && !Owner.CCed; private ref float DeployedFrames => ref Projectile.ai[0]; private ref float AnimationRate => ref Projectile.ai[1]; diff --git a/Projectiles/Magic/NanoPurgeHoldout.cs b/Projectiles/Magic/NanoPurgeHoldout.cs index 0bedfcc9b6..9db4701edf 100644 --- a/Projectiles/Magic/NanoPurgeHoldout.cs +++ b/Projectiles/Magic/NanoPurgeHoldout.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Magic private static int[] LaserOffsetByAnimationFrame = { 4, 3, 0, 3 }; private Player Owner => Main.player[Projectile.owner]; - private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; + private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem()) && !Owner.noItems && !Owner.CCed; private ref float DeployedFrames => ref Projectile.ai[0]; private ref float ChargeTowardsNextShot => ref Projectile.ai[1]; diff --git a/Projectiles/Ranged/BeeRPG.cs b/Projectiles/Ranged/BeeRPG.cs index 4edff39756..f0a7307194 100644 --- a/Projectiles/Ranged/BeeRPG.cs +++ b/Projectiles/Ranged/BeeRPG.cs @@ -187,10 +187,9 @@ namespace CalamityMod.Projectiles.Ranged Player player = Main.player[Projectile.owner]; int projID = ProjectileID.RocketI; float shootSpeed = 0f; - bool canShoot = true; int damage = 0; float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, out _, true); + player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); int blastRadius = 0; if (projID == ProjectileID.RocketII) blastRadius = 3; diff --git a/Projectiles/Ranged/BigNuke.cs b/Projectiles/Ranged/BigNuke.cs index 26792c1939..869daf21e2 100644 --- a/Projectiles/Ranged/BigNuke.cs +++ b/Projectiles/Ranged/BigNuke.cs @@ -166,7 +166,7 @@ namespace CalamityMod.Projectiles.Ranged bool canShoot = true; int damage = 0; float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, out _, true); + player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); CalamityGlobalProjectile.ExpandHitboxBy(Projectile, 16); diff --git a/Projectiles/Ranged/ButcherGun.cs b/Projectiles/Ranged/ButcherGun.cs index b80c2e02d6..b89c8f3663 100644 --- a/Projectiles/Ranged/ButcherGun.cs +++ b/Projectiles/Ranged/ButcherGun.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ai[1] = (float)(shootDelayBase - incrementMult * incrementAmt); willShoot = true; } - bool canShoot = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; + bool canShoot = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Ranged float kback = player.ActiveItem().knockBack; if (canShoot) { - player.PickAmmo(player.ActiveItem(), ref projType, ref speedMult, ref canShoot, ref damage, ref kback, out _); + player.PickAmmo(player.ActiveItem(), out projType, out speedMult, out damage, out kback, out _); kback = player.GetWeaponKnockback(player.ActiveItem(), kback); float speed = player.ActiveItem().shootSpeed * Projectile.scale; Vector2 targetPos = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - source; diff --git a/Projectiles/Ranged/ChickenCannonHeld.cs b/Projectiles/Ranged/ChickenCannonHeld.cs index 7272da595c..c361604897 100644 --- a/Projectiles/Ranged/ChickenCannonHeld.cs +++ b/Projectiles/Ranged/ChickenCannonHeld.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Ranged FramesTillNextShot = FireRate; shouldShoot = true; } - bool canShoot = player.channel && (player.HasAmmo(player.ActiveItem(), true) || FreeShotLoaded > 0) && !player.noItems && !player.CCed; + bool canShoot = player.channel && (player.HasAmmo(player.ActiveItem()) || FreeShotLoaded > 0) && !player.noItems && !player.CCed; if (Projectile.soundDelay <= 0 && canShoot) { Projectile.soundDelay = (int)FireRate; @@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.Ranged if (FreeShotLoaded > 0) FreeShotLoaded--; else - player.PickAmmo(player.ActiveItem(), ref projType, ref speedMult2, ref canShoot, ref dmg, ref kBack, out _); + player.PickAmmo(player.ActiveItem(), out projType, out speedMult2, out dmg, out kBack, out _); projType = ModContent.ProjectileType(); kBack = player.GetWeaponKnockback(player.ActiveItem(), kBack); diff --git a/Projectiles/Ranged/ClockworkBowHoldout.cs b/Projectiles/Ranged/ClockworkBowHoldout.cs index 8ccff01414..58188c93e1 100644 --- a/Projectiles/Ranged/ClockworkBowHoldout.cs +++ b/Projectiles/Ranged/ClockworkBowHoldout.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Ranged private Player Owner => Main.player[Projectile.owner]; - private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; + private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem()) && !Owner.noItems && !Owner.CCed; private ref float CurrentChargingFrames => ref Projectile.ai[0]; private ref float LoadedBolts => ref Projectile.ai[1]; private ref float FramesToLoadBolt => ref Projectile.localAI[0]; @@ -150,7 +150,7 @@ namespace CalamityMod.Projectiles.Ranged bool uselessFuckYou = OwnerCanShoot; //Not a very nice thing to say :/ int projectileType = 0; - Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref BoltDamage, ref knockback, out _, false); + Owner.PickAmmo(heldItem, out projectileType, out shootSpeed, out BoltDamage, out knockback, out _); projectileType = ModContent.ProjectileType(); knockback = Owner.GetWeaponKnockback(heldItem, knockback); diff --git a/Projectiles/Ranged/CondemnationHoldout.cs b/Projectiles/Ranged/CondemnationHoldout.cs index ff4d3829e8..43ccf6b10d 100644 --- a/Projectiles/Ranged/CondemnationHoldout.cs +++ b/Projectiles/Ranged/CondemnationHoldout.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.Ranged public class CondemnationHoldout : ModProjectile { private Player Owner => Main.player[Projectile.owner]; - private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; + private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem()) && !Owner.noItems && !Owner.CCed; private ref float CurrentChargingFrames => ref Projectile.ai[0]; private ref float ArrowsLoaded => ref Projectile.ai[1]; private ref float FramesToLoadNextArrow => ref Projectile.localAI[0]; @@ -126,13 +126,9 @@ namespace CalamityMod.Projectiles.Ranged Item heldItem = Owner.ActiveItem(); // calculate damage at the instant this arrow is fired - int arrowDamage = (int)(heldItem.damage * Owner.RangedDamage()); - float shootSpeed = heldItem.shootSpeed * 1.5f; // Loaded arrows move faster than normal. - float knockback = heldItem.knockBack; + Owner.PickAmmo(heldItem, out int projectileType, out float shootSpeed, out int arrowDamage, out float knockback, out _); + shootSpeed *= 1.5f; - bool uselessFuckYou = OwnerCanShoot; - int projectileType = 0; - Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref arrowDamage, ref knockback, out _); projectileType = ModContent.ProjectileType(); knockback = Owner.GetWeaponKnockback(heldItem, knockback); diff --git a/Projectiles/Ranged/DaemonsFlameBow.cs b/Projectiles/Ranged/DaemonsFlameBow.cs index 2959c05065..ee544bb60d 100644 --- a/Projectiles/Ranged/DaemonsFlameBow.cs +++ b/Projectiles/Ranged/DaemonsFlameBow.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Ranged flag15 = true; int arg_1EF4_0 = (int)Projectile.ai[0] / (num40 - num41 * num39); } - bool flag16 = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; + bool flag16 = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Ranged float weaponKnockback2 = player.ActiveItem().knockBack; if (flag16) { - player.PickAmmo(player.ActiveItem(), ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, out _); + player.PickAmmo(player.ActiveItem(), out num42, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale; Vector2 vector19 = vector; diff --git a/Projectiles/Ranged/DrataliornusBow.cs b/Projectiles/Ranged/DrataliornusBow.cs index 3b4d169c14..18b4acec5a 100644 --- a/Projectiles/Ranged/DrataliornusBow.cs +++ b/Projectiles/Ranged/DrataliornusBow.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Ranged timeToFire = true; } - bool canFire = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; + bool canFire = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.soundDelay <= 0 && canFire) { @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Ranged int damage = player.GetWeaponDamage(player.ActiveItem()); float knockBack = player.ActiveItem().knockBack; - player.PickAmmo(player.ActiveItem(), ref type, ref scaleFactor, ref canFire, ref damage, ref knockBack, out _); + player.PickAmmo(player.ActiveItem(), out type, out scaleFactor, out damage, out knockBack, out _); type = ModContent.ProjectileType(); knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); diff --git a/Projectiles/Ranged/FlurrystormCannonShooting.cs b/Projectiles/Ranged/FlurrystormCannonShooting.cs index d794d384a4..cc0752ce84 100644 --- a/Projectiles/Ranged/FlurrystormCannonShooting.cs +++ b/Projectiles/Ranged/FlurrystormCannonShooting.cs @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ai[1] = (float)(initialRate - fireRateMult * fireRate); shouldShoot = true; } - bool canShoot = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; + bool canShoot = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Ranged float kBack = player.ActiveItem().knockBack; if (canShoot) { - player.PickAmmo(player.ActiveItem(), ref projType, ref speedMult2, ref canShoot, ref dmg, ref kBack, out _); + player.PickAmmo(player.ActiveItem(), out projType, out speedMult2, out dmg, out kBack, out _); kBack = player.GetWeaponKnockback(player.ActiveItem(), kBack); float shootSpeed = player.ActiveItem().shootSpeed * Projectile.scale; Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); diff --git a/Projectiles/Ranged/GoliathRocket.cs b/Projectiles/Ranged/GoliathRocket.cs index 9ab7c1f509..9371d35068 100644 --- a/Projectiles/Ranged/GoliathRocket.cs +++ b/Projectiles/Ranged/GoliathRocket.cs @@ -187,10 +187,9 @@ namespace CalamityMod.Projectiles.Ranged Player player = Main.player[Projectile.owner]; int projID = ProjectileID.RocketI; float shootSpeed = 0f; - bool canShoot = true; int damage = 0; float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, out _, true); + player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); int blastRadius = 0; if (projID == ProjectileID.RocketII) blastRadius = 6; diff --git a/Projectiles/Ranged/HiveBomb.cs b/Projectiles/Ranged/HiveBomb.cs index b742dac009..929ebdfaf2 100644 --- a/Projectiles/Ranged/HiveBomb.cs +++ b/Projectiles/Ranged/HiveBomb.cs @@ -187,10 +187,9 @@ namespace CalamityMod.Projectiles.Ranged Player player = Main.player[Projectile.owner]; int projID = ProjectileID.RocketI; float shootSpeed = 0f; - bool canShoot = true; int damage = 0; float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, out _, true); + player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); int blastRadius = 0; if (projID == ProjectileID.RocketII) blastRadius = 4; diff --git a/Projectiles/Ranged/HiveMissile.cs b/Projectiles/Ranged/HiveMissile.cs index 52d80fc96c..5e94f52df3 100644 --- a/Projectiles/Ranged/HiveMissile.cs +++ b/Projectiles/Ranged/HiveMissile.cs @@ -187,10 +187,9 @@ namespace CalamityMod.Projectiles.Ranged Player player = Main.player[Projectile.owner]; int projID = ProjectileID.RocketI; float shootSpeed = 0f; - bool canShoot = true; int damage = 0; float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, out _, true); + player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); int blastRadius = 0; if (projID == ProjectileID.RocketII) blastRadius = 5; diff --git a/Projectiles/Ranged/MaelstromHoldout.cs b/Projectiles/Ranged/MaelstromHoldout.cs index 612e9f6802..8d000d7e8b 100644 --- a/Projectiles/Ranged/MaelstromHoldout.cs +++ b/Projectiles/Ranged/MaelstromHoldout.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.Ranged public class MaelstromHoldout : ModProjectile { private Player Owner => Main.player[Projectile.owner]; - private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; + private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem()) && !Owner.noItems && !Owner.CCed; private ref float CurrentChargingFrames => ref Projectile.ai[0]; private ref float ArrowsLoaded => ref Projectile.ai[1]; private ref float FramesToLoadNextArrow => ref Projectile.localAI[0]; @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Ranged bool uselessFuckYou = OwnerCanShoot; int projectileType = 0; - Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref arrowDamage, ref knockback, out _); + Owner.PickAmmo(heldItem, out projectileType, out shootSpeed, out arrowDamage, out knockback, out _); projectileType = ModContent.ProjectileType(); knockback = Owner.GetWeaponKnockback(heldItem, knockback); diff --git a/Projectiles/Ranged/MiniRocket.cs b/Projectiles/Ranged/MiniRocket.cs index 39d9433f61..5829d133e9 100644 --- a/Projectiles/Ranged/MiniRocket.cs +++ b/Projectiles/Ranged/MiniRocket.cs @@ -156,10 +156,9 @@ namespace CalamityMod.Projectiles.Ranged Player player = Main.player[Projectile.owner]; int projID = ProjectileID.RocketI; float shootSpeed = 0f; - bool canShoot = true; int damage = 0; float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, out _, true); + player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); int blastRadius = 0; if (projID == ProjectileID.RocketII) blastRadius = 3; diff --git a/Projectiles/Ranged/NorfleetCannon.cs b/Projectiles/Ranged/NorfleetCannon.cs index e93662916b..f9b878ac87 100644 --- a/Projectiles/Ranged/NorfleetCannon.cs +++ b/Projectiles/Ranged/NorfleetCannon.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ai[1] = baseUseTime - modifier * Projectile.localAI[0]; timeToFire = true; } - bool canFire = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; + bool canFire = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.soundDelay <= 0 && canFire) { Projectile.soundDelay = baseUseTime - modifier * (int)Projectile.localAI[0]; @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Ranged float knockBack = player.ActiveItem().knockBack; for (int i = 0; i < 5; i++) { - player.PickAmmo(player.ActiveItem(), ref type, ref shootSpeed, ref canFire, ref damage, ref knockBack, out _); + player.PickAmmo(player.ActiveItem(), out type, out shootSpeed, out damage, out knockBack, out _); knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); Vector2 playerPosition = player.RotatedRelativePoint(player.MountedCenter, true); Projectile.velocity = Main.screenPosition - playerPosition; diff --git a/Projectiles/Ranged/Nuke.cs b/Projectiles/Ranged/Nuke.cs index 055b6e14b4..7e2cef1dc4 100644 --- a/Projectiles/Ranged/Nuke.cs +++ b/Projectiles/Ranged/Nuke.cs @@ -161,10 +161,9 @@ namespace CalamityMod.Projectiles.Ranged Player player = Main.player[Projectile.owner]; int projID = ProjectileID.RocketI; float shootSpeed = 0f; - bool canShoot = true; int damage = 0; float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, out _, true); + player.PickAmmo(FalseLauncher, out projID, out shootSpeed, out damage, out kb, out _, true); int blastRadius = 0; if (projID == ProjectileID.RocketII) blastRadius = 6; diff --git a/Projectiles/Ranged/PhangasmBow.cs b/Projectiles/Ranged/PhangasmBow.cs index 4361b55e30..ec156911ef 100644 --- a/Projectiles/Ranged/PhangasmBow.cs +++ b/Projectiles/Ranged/PhangasmBow.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Ranged flag15 = true; int arg_1EF4_0 = (int)Projectile.ai[0] / (num40 - num41 * num39); } - bool flag16 = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; + bool flag16 = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Ranged float weaponKnockback2 = player.ActiveItem().knockBack; if (flag16) { - player.PickAmmo(player.ActiveItem(), ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, out _); + player.PickAmmo(player.ActiveItem(), out num42, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale; Vector2 vector19 = vector; diff --git a/Projectiles/Ranged/StarfleetMK2Gun.cs b/Projectiles/Ranged/StarfleetMK2Gun.cs index 2c347f3ce5..5ff46a8284 100644 --- a/Projectiles/Ranged/StarfleetMK2Gun.cs +++ b/Projectiles/Ranged/StarfleetMK2Gun.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ai[1] = baseUseTime - modifier * Projectile.localAI[0]; timeToFire = true; } - bool canFire = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; + bool canFire = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (Projectile.soundDelay <= 0 && canFire) { Projectile.soundDelay = baseUseTime - modifier * (int)Projectile.localAI[0]; @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Ranged float shootSpeed = 16f; int damage = player.GetWeaponDamage(player.ActiveItem()); float knockBack = player.ActiveItem().knockBack; - player.PickAmmo(player.ActiveItem(), ref type, ref shootSpeed, ref canFire, ref damage, ref knockBack, out _); + player.PickAmmo(player.ActiveItem(), out type, out shootSpeed, out damage, out knockBack, out _); for (int i = 0; i < 5; i++) { knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); diff --git a/Projectiles/Ranged/SurgeDriverHoldout.cs b/Projectiles/Ranged/SurgeDriverHoldout.cs index ff2854bf82..d941d7bd1c 100644 --- a/Projectiles/Ranged/SurgeDriverHoldout.cs +++ b/Projectiles/Ranged/SurgeDriverHoldout.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Projectiles.Ranged public class SurgeDriverHoldout : ModProjectile { public Player Owner => Main.player[Projectile.owner]; - public bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; + public bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem()) && !Owner.noItems && !Owner.CCed; public ref float ShootCountdown => ref Projectile.ai[0]; public override void SetStaticDefaults() => DisplayName.SetDefault("Surge Driver"); @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Ranged float knockback = heldItem.knockBack; bool uselessFuckYou = OwnerCanShoot; - Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref damage, ref knockback, out _); + Owner.PickAmmo(heldItem, out projectileType, out shootSpeed, out damage, out knockback, out _); projectileType = ModContent.ProjectileType(); knockback = Owner.GetWeaponKnockback(heldItem, knockback); diff --git a/Projectiles/Ranged/UltimaBowProjectile.cs b/Projectiles/Ranged/UltimaBowProjectile.cs index baa2adb5e4..c5a00633dd 100644 --- a/Projectiles/Ranged/UltimaBowProjectile.cs +++ b/Projectiles/Ranged/UltimaBowProjectile.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Ranged public void AttemptToFireProjectiles(Player player) { - bool canFire = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; + bool canFire = player.channel && player.HasAmmo(player.ActiveItem()) && !player.noItems && !player.CCed; if (!canFire) { Projectile.Kill(); @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged int damage = player.GetWeaponDamage(player.ActiveItem()); float knockBack = player.ActiveItem().knockBack; - player.PickAmmo(player.ActiveItem(), ref type, ref shotSpeed, ref canFire, ref damage, ref knockBack, out _); // Pick ammo and consume it (this incorporates the bow's chance to not consume ammo). + player.PickAmmo(player.ActiveItem(), out type, out shotSpeed, out damage, out knockBack, out _); // Pick ammo and consume it (this incorporates the bow's chance to not consume ammo). SoundEngine.PlaySound(player.ActiveItem().UseSound, Projectile.Center); diff --git a/Projectiles/Summon/TacticalPlagueJet.cs b/Projectiles/Summon/TacticalPlagueJet.cs index bb9b6ab694..d3770d8391 100644 --- a/Projectiles/Summon/TacticalPlagueJet.cs +++ b/Projectiles/Summon/TacticalPlagueJet.cs @@ -43,6 +43,9 @@ namespace CalamityMod.Projectiles.Summon int p90ID = ModContent.ItemType(); FalseGun = new Item(); FalseGun.SetDefaults(p90ID, true); + FalseGun.consumeAmmoOnFirstShotOnly = false; + FalseGun.consumeAmmoOnLastShotOnly = false; + // FalseGun.ranged = false /* tModPorter - this is redundant, for more info see https://github.com/tModLoader/tModLoader/wiki/Update-Migration-Guide#damage-classes */ ; FalseGun.DamageType = DamageClass.Summon; } @@ -95,7 +98,7 @@ namespace CalamityMod.Projectiles.Summon NPC potentialTarget = Projectile.Center.MinionHoming(1560f, player); // If the jet has no target or is out of ammo, passively fly around the player. - if (potentialTarget is null || !player.HasAmmo(FalseGun, false)) + if (potentialTarget is null || !player.HasAmmo(FalseGun)) { float distanceToOwner = (player.Center - Projectile.Center).Length(); float acceleration = 0.1f; @@ -164,7 +167,7 @@ namespace CalamityMod.Projectiles.Summon int projIndex; // Vanilla function tricked into using a fake gun item with the appropriate base damage as the "firing item". - player.PickAmmo(FalseGun, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, out _, dontConsumeAmmo); + player.PickAmmo(FalseGun, out projID, out shootSpeed, out damage, out kb, out _); // One in every 20 shots is a rocket which deals 1.5x total damage and extreme knockback. if (shootRocket) diff --git a/Tiles/Abyss/AcidWoodTree.cs b/Tiles/Abyss/AcidWoodTree.cs index 29cb6872fa..f3065aa700 100644 --- a/Tiles/Abyss/AcidWoodTree.cs +++ b/Tiles/Abyss/AcidWoodTree.cs @@ -1,14 +1,45 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria.ModLoader; +using Terraria.GameContent; + namespace CalamityMod.Tiles.Abyss { public class AcidWoodTree : ModPalmTree { - public override Texture2D GetTopTextures() => ModContent.Request("CalamityMod/Tiles/Abyss/AcidWoodTreeTops").Value; - public override Texture2D GetTexture() => ModContent.Request("CalamityMod/Tiles/Abyss/AcidWoodTree").Value; + public override void SetStaticDefaults() + { + // Grows on sulphurous sand + GrowsOnTileId = new int[2] { ModContent.TileType() , ModContent.TileType()}; + } + + //Copypasted from vanilla, just as ExampleMod did, due to the lack of proper explanation + public override TreePaintingSettings TreeShaderSettings => new TreePaintingSettings + { + UseSpecialGroups = true, + SpecialGroupMinimalHueValue = 11f / 72f, + SpecialGroupMaximumHueValue = 0.25f, + SpecialGroupMinimumSaturationValue = 0.88f, + SpecialGroupMaximumSaturationValue = 1f + }; + + public override Asset GetTopTextures() => ModContent.Request("CalamityMod/Tiles/Abyss/AcidWoodTreeTops"); + public override Asset GetTexture() => ModContent.Request("CalamityMod/Tiles/Abyss/AcidWoodTree"); + + //I don't know what this means. Why do palm trees have branches?? Since when. Also acidwood trees arent meant to have oasis alts + public override Asset GetOasisTopTextures() => ModContent.Request("CalamityMod/Tiles/Abyss/AcidWoodTreeTops"); + public override Asset GetBranchTextures() => null; + public override Asset GetOasisBranchTextures() => ModContent.Request("CalamityMod/Tiles/Abyss/AcidWoodTree"); + public override int DropWood() => ModContent.ItemType(); public override int CreateDust() => (int)CalamityDusts.SulfurousSeaAcid; + + public override int SaplingGrowthType(ref int style) + { + style = 0; + return ModContent.TileType(); + } } } diff --git a/Tiles/Abyss/SulphurousCactus.cs b/Tiles/Abyss/SulphurousCactus.cs index cc6bbc692c..37ae76e5c4 100644 --- a/Tiles/Abyss/SulphurousCactus.cs +++ b/Tiles/Abyss/SulphurousCactus.cs @@ -1,10 +1,20 @@ using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; +using ReLogic.Content; namespace CalamityMod.Tiles.Abyss { public class SulphurousCactus : ModCactus { - public override Texture2D GetTexture() => ModContent.Request("CalamityMod/Tiles/Abyss/SulphurousCactus").Value; + public override void SetStaticDefaults() + { + // Grows on sulphurous sand + GrowsOnTileId = new int[2] { ModContent.TileType(), ModContent.TileType() }; + } + + public override Asset GetTexture() => ModContent.Request("CalamityMod/Tiles/Abyss/SulphurousCactus"); + + //What is a FruitTexture + public override Asset GetFruitTexture() => null; } } diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index aa9b1371d7..3144899e0e 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -24,8 +24,6 @@ namespace CalamityMod.Tiles.Abyss AddMapEntry(new Color(150, 100, 50)); MineResist = 1f; SoundType = SoundID.Dig; - SetModPalmTree(new AcidWoodTree()); - SetModCactus(new SulphurousCactus()); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -255,10 +253,5 @@ namespace CalamityMod.Tiles.Abyss TileFraming.CustomMergeFrame(i, j, Type, ModContent.TileType(), false, false, false, false, resetFrame); return false; } - public override int SaplingGrowthType(ref int style) - { - style = 0; - return ModContent.TileType(); - } } } diff --git a/Tiles/Abyss/SulphurousSandNoWater.cs b/Tiles/Abyss/SulphurousSandNoWater.cs index 76da6a8088..c790f746b4 100644 --- a/Tiles/Abyss/SulphurousSandNoWater.cs +++ b/Tiles/Abyss/SulphurousSandNoWater.cs @@ -20,7 +20,6 @@ namespace CalamityMod.Tiles.Abyss AddMapEntry(new Color(150, 100, 50)); MineResist = 1f; SoundType = SoundID.Dig; - SetModPalmTree(new AcidWoodTree()); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -33,10 +32,5 @@ namespace CalamityMod.Tiles.Abyss TileFraming.CustomMergeFrame(i, j, Type, ModContent.TileType(), false, false, false, false, resetFrame); return false; } - public override int SaplingGrowthType(ref int style) - { - style = 0; - return ModContent.TileType(); - } } } diff --git a/Tiles/Astral/AstralGrass.cs b/Tiles/Astral/AstralGrass.cs index 505956d462..3cf854d50a 100644 --- a/Tiles/Astral/AstralGrass.cs +++ b/Tiles/Astral/AstralGrass.cs @@ -31,8 +31,6 @@ namespace CalamityMod.Tiles.Astral //Grass framing (<3 terraria devs) TileID.Sets.NeedsGrassFraming[Type] = true; TileID.Sets.NeedsGrassFramingDirt[Type] = ModContent.TileType(); - - SetModTree(new AstralTree()); } public override void NumDust(int i, int j, bool fail, ref int Type) @@ -47,11 +45,5 @@ namespace CalamityMod.Tiles.Astral Main.tile[i, j].TileType = (ushort)ModContent.TileType(); } } - - public override int SaplingGrowthType(ref int style) - { - style = 0; - return ModContent.TileType(); - } } } diff --git a/Tiles/Astral/AstralTree.cs b/Tiles/Astral/AstralTree.cs index 7c93952607..d0658269e4 100644 --- a/Tiles/Astral/AstralTree.cs +++ b/Tiles/Astral/AstralTree.cs @@ -1,20 +1,48 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; + namespace CalamityMod.Tiles.Astral { public class AstralTree : ModTree { - public override Texture2D GetTopTextures(int i, int j, ref int frame, ref int frameWidth, ref int frameHeight, ref int xOffsetLeft, ref int yOffset) + public override void SetStaticDefaults() { - frame = (i + j * j) % 3; - return ModContent.Request("CalamityMod/Tiles/Astral/AstralTree_Tops").Value; + // Grows on astral grass + GrowsOnTileId = new int[1] { ModContent.TileType() }; } - public override Texture2D GetBranchTextures(int i, int j, int trunkOffset, ref int frame) => ModContent.Request("CalamityMod/Tiles/Astral/AstralTree_Branches").Value; - public override Texture2D GetTexture() => ModContent.Request("CalamityMod/Tiles/Astral/AstralTree").Value; + //Copypasted from vanilla, just as ExampleMod did, due to the lack of proper explanation + public override TreePaintingSettings TreeShaderSettings => new TreePaintingSettings + { + UseSpecialGroups = true, + SpecialGroupMinimalHueValue = 11f / 72f, + SpecialGroupMaximumHueValue = 0.25f, + SpecialGroupMinimumSaturationValue = 0.88f, + SpecialGroupMaximumSaturationValue = 1f + }; + + public override Asset GetTopTextures() => ModContent.Request("CalamityMod/Tiles/Astral/AstralTree_Tops"); + + public override void SetTreeFoliageSettings(Tile tile, int xoffset, ref int treeFrame, ref int floorY, ref int topTextureFrameWidth, ref int topTextureFrameHeight) + { + //What does this code do? + //treeFrame = (i + j * j) % 3; + } + + public override Asset GetBranchTextures() => ModContent.Request("CalamityMod/Tiles/Astral/AstralTree_Branches"); + public override Asset GetTexture() => ModContent.Request("CalamityMod/Tiles/Astral/AstralTree"); public override int DropWood() => ModContent.ItemType(); public override int CreateDust() => ModContent.DustType(); public override int GrowthFXGore() => -1; + + public override int SaplingGrowthType(ref int style) + { + style = 0; + return ModContent.TileType(); + } } } diff --git a/Tiles/AstralDesert/AstralCactus.cs b/Tiles/AstralDesert/AstralCactus.cs new file mode 100644 index 0000000000..f9c2e5064b --- /dev/null +++ b/Tiles/AstralDesert/AstralCactus.cs @@ -0,0 +1,28 @@ +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Tiles.Astral; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using ReLogic.Content; + +namespace CalamityMod.Tiles.AstralDesert +{ + public class AstralCactus : ModCactus + { + public override void SetStaticDefaults() + { + // Grows on astral sand + GrowsOnTileId = new int[1] { ModContent.TileType() }; + } + + //Idk what to make with the glowmask + public override Asset GetTexture() => ModContent.Request("CalamityMod/Tiles/AstralDesert/AstralCactus"); + + //What is a FruitTexture + public override Asset GetFruitTexture() => null; + + } +} diff --git a/ExtraTextures/Tiles/AstralCactus.png b/Tiles/AstralDesert/AstralCactus.png similarity index 100% rename from ExtraTextures/Tiles/AstralCactus.png rename to Tiles/AstralDesert/AstralCactus.png diff --git a/ExtraTextures/Tiles/AstralCactusGlow.png b/Tiles/AstralDesert/AstralCactusGlow.png similarity index 100% rename from ExtraTextures/Tiles/AstralCactusGlow.png rename to Tiles/AstralDesert/AstralCactusGlow.png diff --git a/Tiles/AstralDesert/AstralPalmSapling.cs b/Tiles/AstralDesert/AstralPalmSapling.cs index 5415fe8841..251e334dc8 100644 --- a/Tiles/AstralDesert/AstralPalmSapling.cs +++ b/Tiles/AstralDesert/AstralPalmSapling.cs @@ -20,6 +20,8 @@ namespace CalamityMod.Tiles.AstralDesert Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; Main.tileLavaDeath[Type] = true; + TileID.Sets.CommonSapling[Type] = true; + TileID.Sets.TreeSapling[Type] = true; TileObjectData.newTile.Width = 1; TileObjectData.newTile.Height = 2; TileObjectData.newTile.Origin = new Point16(0, 1); @@ -49,10 +51,12 @@ namespace CalamityMod.Tiles.AstralDesert public override void RandomUpdate(int i, int j) { - if (WorldGen.genRand.Next(20) == 0) + if (WorldGen.genRand.Next(20) == 0 || true) { bool isPlayerNear = WorldGen.PlayerLOS(i, j); - bool success = WorldGen.GrowTree(i, j); + + bool success = WorldGen.GrowPalmTree(i, j); + if (success && isPlayerNear) { WorldGen.TreeGrowFXCheck(i, j); diff --git a/Tiles/AstralDesert/AstralPalmTree.cs b/Tiles/AstralDesert/AstralPalmTree.cs index 12681ef988..a9ae6122e6 100644 --- a/Tiles/AstralDesert/AstralPalmTree.cs +++ b/Tiles/AstralDesert/AstralPalmTree.cs @@ -1,33 +1,50 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; +using ReLogic.Content; +using Terraria.GameContent; + namespace CalamityMod.Tiles.AstralDesert { public class AstralPalmTree : ModPalmTree { - public override Texture2D GetTexture() + public override void SetStaticDefaults() { - return ModContent.Request("CalamityMod/Tiles/AstralDesert/AstralPalmTree").Value; + // Grows on astral sand + GrowsOnTileId = new int[1] { ModContent.TileType() }; } - public override Texture2D GetTopTextures() + //Copypasted from vanilla, just as ExampleMod did, due to the lack of proper explanation + public override TreePaintingSettings TreeShaderSettings => new TreePaintingSettings { - return ModContent.Request("CalamityMod/Tiles/AstralDesert/AstralPalmTree_Tops").Value; - } + UseSpecialGroups = true, + SpecialGroupMinimalHueValue = 11f / 72f, + SpecialGroupMaximumHueValue = 0.25f, + SpecialGroupMinimumSaturationValue = 0.88f, + SpecialGroupMaximumSaturationValue = 1f + }; - public override int DropWood() - { - return ModContent.ItemType(); - } + public override Asset GetTexture() => ModContent.Request("CalamityMod/Tiles/AstralDesert/AstralPalmTree"); - public override int CreateDust() - { - return ModContent.DustType(); - } + public override Asset GetTopTextures() => ModContent.Request("CalamityMod/Tiles/AstralDesert/AstralPalmTree_Tops"); - public override int GrowthFXGore() + + //I don't know what this means. Why do palm trees have branches?? Since when. Will ask spriters for an oasis alt later + public override Asset GetOasisTopTextures() => ModContent.Request("CalamityMod/Tiles/AstralDesert/AstralPalmTree_Tops"); + public override Asset GetBranchTextures() => null; + public override Asset GetOasisBranchTextures() => ModContent.Request("CalamityMod/Tiles/AstralDesert/AstralPalmTree"); + + + public override int DropWood() => ModContent.ItemType(); + + public override int CreateDust() => ModContent.DustType(); + + public override int GrowthFXGore() => -1; + + public override int SaplingGrowthType(ref int style) { - return -1; + style = 0; + return ModContent.TileType(); } } } diff --git a/Tiles/AstralDesert/AstralSand.cs b/Tiles/AstralDesert/AstralSand.cs index 24b0bb63b3..bd2bcfae17 100644 --- a/Tiles/AstralDesert/AstralSand.cs +++ b/Tiles/AstralDesert/AstralSand.cs @@ -32,10 +32,6 @@ namespace CalamityMod.Tiles.AstralDesert TileID.Sets.Conversion.Sand[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; TileID.Sets.Falling[Type] = true; - - SetModCactus(new AstralCactus()); - - SetModPalmTree(new AstralPalmTree()); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -70,19 +66,5 @@ namespace CalamityMod.Tiles.AstralDesert { DustType = 108; } - - public override int SaplingGrowthType(ref int style) - { - style = 0; - return ModContent.TileType(); - } - } - - public class AstralCactus : ModCactus - { - public override Texture2D GetTexture() - { - return CalamityMod.AstralCactusTexture; - } } } diff --git a/Tiles/AstralSnow/AstralSnow.cs b/Tiles/AstralSnow/AstralSnow.cs index 94f23e8a32..307c8f2799 100644 --- a/Tiles/AstralSnow/AstralSnow.cs +++ b/Tiles/AstralSnow/AstralSnow.cs @@ -30,8 +30,6 @@ namespace CalamityMod.Tiles.AstralSnow TileID.Sets.Snow[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; - - SetModTree(new AstralSnowTree()); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -45,11 +43,5 @@ namespace CalamityMod.Tiles.AstralSnow TileFraming.CustomMergeFrame(i, j, Type, ModContent.TileType()); return false; } - - public override int SaplingGrowthType(ref int style) - { - style = 0; - return ModContent.TileType(); - } } } diff --git a/Tiles/AstralSnow/AstralSnowTree.cs b/Tiles/AstralSnow/AstralSnowTree.cs index bfd930a28e..bf60c5f222 100644 --- a/Tiles/AstralSnow/AstralSnowTree.cs +++ b/Tiles/AstralSnow/AstralSnowTree.cs @@ -1,25 +1,40 @@ using Terraria.ModLoader; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; -namespace CalamityMod.Tiles +namespace CalamityMod.Tiles.AstralSnow { public class AstralSnowTree : ModTree { - public override Texture2D GetTopTextures(int i, int j, ref int frame, ref int frameWidth, ref int frameHeight, ref int xOffsetLeft, ref int yOffset) + public override void SetStaticDefaults() { - frame = (i + j * j) % 6; - return ModContent.Request("CalamityMod/Tiles/AstralSnow/AstralSnowTree_Tops").Value; + // Grows on astral snow + GrowsOnTileId = new int[1] { ModContent.TileType() }; } - public override Texture2D GetBranchTextures(int i, int j, int trunkOffset, ref int frame) + //Copypasted from vanilla, just as ExampleMod did, due to the lack of proper explanation + public override TreePaintingSettings TreeShaderSettings => new TreePaintingSettings { - return ModContent.Request("CalamityMod/Tiles/AstralSnow/AstralSnowTree_Branches").Value; + UseSpecialGroups = true, + SpecialGroupMinimalHueValue = 11f / 72f, + SpecialGroupMaximumHueValue = 0.25f, + SpecialGroupMinimumSaturationValue = 0.88f, + SpecialGroupMaximumSaturationValue = 1f + }; + + public override Asset GetTopTextures() => ModContent.Request("CalamityMod/Tiles/AstralSnow/AstralSnowTree_Tops"); + + public override void SetTreeFoliageSettings(Tile tile, int xoffset, ref int treeFrame, ref int floorY, ref int topTextureFrameWidth, ref int topTextureFrameHeight) + { + //What does this code do? + //treeFrame = (i + j * j) % 6; } - public override Texture2D GetTexture() - { - return ModContent.Request("CalamityMod/Tiles/AstralSnow/AstralSnowTree").Value; - } + public override Asset GetBranchTextures() => ModContent.Request("CalamityMod/Tiles/AstralSnow/AstralSnowTree_Branches"); + + public override Asset GetTexture() => ModContent.Request("CalamityMod/Tiles/AstralSnow/AstralSnowTree"); public override int DropWood() { @@ -35,5 +50,11 @@ namespace CalamityMod.Tiles { return -1; } + + public override int SaplingGrowthType(ref int style) + { + style = 0; + return ModContent.TileType(); + } } } diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 85e440eaec..52b5907f1a 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -129,7 +129,7 @@ namespace CalamityMod.Tiles // If it is actually astral cactus, then draw its glowmask. if (astralCactus) { - spriteBatch.Draw(CalamityMod.AstralCactusGlowTexture, new Vector2((float)(i * 16 - (int)Main.screenPosition.X), (float)(j * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle((int)frameX, (int)frameY, 16, 18), Color.White * 0.75f, 0f, default, 1f, SpriteEffects.None, 0f); + spriteBatch.Draw(ModContent.Request("CalamityMod/Tiles/AstralDesert/AstralCactusGlow").Value, new Vector2((float)(i * 16 - (int)Main.screenPosition.X), (float)(j * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle((int)frameX, (int)frameY, 16, 18), Color.White * 0.75f, 0f, default, 1f, SpriteEffects.None, 0f); } }