Fixed Fetid Emesis firing multiple projectiles in mp

Removed our Player.ActiveItem() function because it is strictly worse and buggier than Player.HeldItem
This commit is contained in:
CongratsIsTrash committed 2025-11-15 00:01:36 -05:00
1 parent 60c1d04b4e
commit 88e9dffcaa
130 files changed
+321 -317

No files matched your search

+1 -1
View File
@@ -50,7 +50,7 @@ namespace CalamityMod.Balancing
p.type == ProjectileType<ArkoftheCosmosSwungBlade>() && (p.ai[0] == 2 || p.ai[0] == 3);
bool HiveBeeFilter(Projectile p) =>
p.type == ProjectileType<BasicPlagueBee>() && Main.player[p.owner].ActiveItem().type == ItemType<TheHive>();
p.type == ProjectileType<BasicPlagueBee>() && Main.player[p.owner].HeldItem.type == ItemType<TheHive>();
NPCSpecificBalancingChanges = new List<NPCBalancingChange>();
+1 -1
View File
@@ -32,7 +32,7 @@ namespace CalamityMod.Buffs.DamageOverTime
}
}
Item heldItem = Main.player[owner].ActiveItem();
Item heldItem = Main.player[owner].HeldItem;
int totalDamage = (int)Main.player[owner].GetTotalDamage<SummonDamageClass>().ApplyTo(debuffData.EnemyLostRegen);
if (CalamityUtils.ShouldTriggerSummonPenalty(Main.player[owner], heldItem))
+10 -10
View File
@@ -275,8 +275,8 @@ namespace CalamityMod.CalPlayer
public int arsenalCooldown = 0;
public int killModeCooldown = 0;
public bool demonSwordKillMode = false;
public bool exaltedKillMode => (demonSwordKillMode && Player.ActiveItem().type == ItemType<ExaltedOathblade>());
public bool devilsDevastationKillMode => (demonSwordKillMode && Player.ActiveItem().type == ItemType<DevilsDevastation>());
public bool exaltedKillMode => (demonSwordKillMode && Player.HeldItem.type == ItemType<ExaltedOathblade>());
public bool devilsDevastationKillMode => (demonSwordKillMode && Player.HeldItem.type == ItemType<DevilsDevastation>());
/// <summary>
/// Tracks Dragoon Drizzlefish's "gel feed" mechanic in Get fixed boi.<br/>
/// Consuming Gel adds 1 to this counter, up to a maximum of 6, and using the weapon has a random chance to decrement the counter.<br/>
@@ -2783,7 +2783,7 @@ namespace CalamityMod.CalPlayer
disablePerfCystSpawns = false;
disableVoodooSpawns = false;
EnchantHeldItemEffects(Player, Player.Calamity(), Player.ActiveItem());
EnchantHeldItemEffects(Player, Player.Calamity(), Player.HeldItem);
}
#endregion
@@ -3634,7 +3634,7 @@ namespace CalamityMod.CalPlayer
if (Player.Calamity().SpeedBlasterDashStarted || (Player.dashDelay != 0 && (Player.Calamity().LastUsedDashID == SuperradiantSawDash.ID || Player.Calamity().LastUsedDashID == SpeedBlasterDash.ID)))
{
Player.Calamity().DeferredDashID = Player.ActiveItem().type == ItemType<SuperradiantSlaughterer>() ? SuperradiantSawDash.ID : SpeedBlasterDash.ID;
Player.Calamity().DeferredDashID = Player.HeldItem.type == ItemType<SuperradiantSlaughterer>() ? SuperradiantSawDash.ID : SpeedBlasterDash.ID;
Player.dash = 0;
}
@@ -3642,7 +3642,7 @@ namespace CalamityMod.CalPlayer
if (CalamityKeybinds.RageHotKey.JustPressed)
{
// Gael's Greatsword replaces Rage Mode with an uber skull attack
if (!(Player.HasCooldown(Cooldowns.GaelsRage.ID)) && Player.ActiveItem().type == ItemType<GaelsGreatsword>() && rage > 0f)
if (!(Player.HasCooldown(Cooldowns.GaelsRage.ID)) && Player.HeldItem.type == ItemType<GaelsGreatsword>() && rage > 0f)
{
SoundEngine.PlaySound(SilvaArmor.DispelSound, Player.Center);
@@ -3661,7 +3661,7 @@ namespace CalamityMod.CalPlayer
}
// https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list
var source = Player.GetSource_ItemUse(Player.ActiveItem(), GaelsGreatsword.SkullsplosionEntitySourceContext);
var source = Player.GetSource_ItemUse(Player.HeldItem, GaelsGreatsword.SkullsplosionEntitySourceContext);
float rageRatio = rage / rageMax;
float baseDamage = rageRatio * GaelsGreatsword.SkullsplosionDamageMultiplier * GaelsGreatsword.BaseDamage;
int damage = (int)Player.GetTotalDamage<MeleeDamageClass>().ApplyTo(baseDamage);
@@ -5212,7 +5212,7 @@ namespace CalamityMod.CalPlayer
#region Anomaly's Nanogun Kill Sound
public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
{
if (Player.whoAmI == Main.myPlayer && Player.ActiveItem().type == ItemType<TheAnomalysNanogun>())
if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ItemType<TheAnomalysNanogun>())
{
if (Main.rand.NextBool(20))
SoundEngine.PlaySound(IjiDeathSound, Player.Center);
@@ -5384,7 +5384,7 @@ namespace CalamityMod.CalPlayer
// This doesn't trigger stealth strike effects (ConsumeStealthStrike instead of StealthStrike)
// so non-rogue weapons can't call lasers down from the sky and such.
// Using any item which deals no damage or is a tool doesn't consume stealth.
Item it = Player.ActiveItem();
Item it = Player.HeldItem;
bool hasDamage = it.damage > 0;
bool hasHitboxes = !it.noMelee || it.shoot > ProjectileID.None;
bool isPickaxe = it.pick > 0;
@@ -5432,7 +5432,7 @@ namespace CalamityMod.CalPlayer
return;
// Hovering over an item will adjust the stealth bonus dynamically so that you see the correct damage for an item you put your cursor on.
Item it = !Main.HoverItem.IsAir ? Main.HoverItem : Player.ActiveItem();
Item it = !Main.HoverItem.IsAir ? Main.HoverItem : Player.HeldItem;
// The potential damage bonus from stealth is a complex equation based on the item's use time,
// the player's averaged-together stealth generation stats, and max stealth.
@@ -5579,7 +5579,7 @@ namespace CalamityMod.CalPlayer
internal void rollBabSpears(int randAmt, bool chaseable)
{
var source = Player.GetSource_ItemUse(Player.ActiveItem());
var source = Player.GetSource_ItemUse(Player.HeldItem);
if (Player.whoAmI == Main.myPlayer && !endoCooper && randAmt > 0 && Main.rand.NextBool(randAmt) && chaseable)
{
int spearsFired = 0;
+1 -1
View File
@@ -635,7 +635,7 @@ namespace CalamityMod.CalPlayer
return;
Player drawPlayer = drawInfo.drawPlayer;
Item item = drawPlayer.ActiveItem();
Item item = drawPlayer.HeldItem;
if (!drawPlayer.frozen &&
(item.IsAir || item.type > ItemID.None) &&
+3 -3
View File
@@ -733,7 +733,7 @@ namespace CalamityMod.CalPlayer
bool isSummon = proj.CountsAsClass<SummonDamageClass>();
if (isSummon)
{
Item heldItem = Player.ActiveItem();
Item heldItem = Player.HeldItem;
if (CalamityUtils.ShouldTriggerSummonPenalty(Player, heldItem) && !CalamityProjectileSets.MinionWhichIgnoresSummonerNerf[proj.type])
modifiers.FinalDamage *= BalancingConstants.SummonerCrossClassNerf;
@@ -841,7 +841,7 @@ namespace CalamityMod.CalPlayer
if (bloodflareMelee && bloodflareFrenzy && !Player.HasCooldown(BloodflareFrenzy.ID))
modifiers.FinalDamage *= (1f - BloodflareHeadMelee.FrenzyContactDamageReduction);
if (Player.ownedProjectileCounts[ModContent.ProjectileType<EnergyShell>()] > 0 && Player.ActiveItem().type == ModContent.ItemType<LionHeart>())
if (Player.ownedProjectileCounts[ModContent.ProjectileType<EnergyShell>()] > 0 && Player.HeldItem.type == ModContent.ItemType<LionHeart>())
modifiers.FinalDamage *= 0.5f;
bool lifeAndShieldCondition = Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability);
@@ -1053,7 +1053,7 @@ namespace CalamityMod.CalPlayer
modifiers.FinalDamage *= 0.75f;
}
if (Player.ownedProjectileCounts[ModContent.ProjectileType<EnergyShell>()] > 0 && Player.ActiveItem().type == ModContent.ItemType<LionHeart>())
if (Player.ownedProjectileCounts[ModContent.ProjectileType<EnergyShell>()] > 0 && Player.HeldItem.type == ModContent.ItemType<LionHeart>())
modifiers.FinalDamage *= 0.5f;
bool lifeAndShieldCondition = Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability);
+10 -10
View File
@@ -188,7 +188,7 @@ namespace CalamityMod.CalPlayer
}
}
if (Player.ActiveItem().type != ModContent.ItemType<SaharaSlicers>())
if (Player.HeldItem.type != ModContent.ItemType<SaharaSlicers>())
saharaSlicersBolts = 0;
if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType<Starfleet>() && (Player.ownedProjectileCounts[ModContent.ProjectileType<StarfleetHoldout>()] == 0) && !Player.dead)
@@ -203,7 +203,7 @@ namespace CalamityMod.CalPlayer
}
// De-equipping Gael's Greatsword deletes all rage.
if (Player.ActiveItem().type == ModContent.ItemType<GaelsGreatsword>())
if (Player.HeldItem.type == ModContent.ItemType<GaelsGreatsword>())
heldGaelsLastFrame = true;
else if (heldGaelsLastFrame)
{
@@ -1160,7 +1160,7 @@ namespace CalamityMod.CalPlayer
DoGCartSegments = new DoGCartSegment[DoGCartSegments.Length];
// Dust on hand when holding the phosphorescent gauntlet.
if (Player.ActiveItem().type == ModContent.ItemType<PhosphorescentGauntlet>())
if (Player.HeldItem.type == ModContent.ItemType<PhosphorescentGauntlet>())
PhosphorescentGauntletPunches.GenerateDustOnOwnerHand(Player);
if (stealthUIAlpha > 0f && (rogueStealth <= 0f || rogueStealthMax <= 0f))
@@ -2807,7 +2807,7 @@ namespace CalamityMod.CalPlayer
}
// Vortex Armor nerf
if (Player.vortexStealthActive && Player.ActiveItem().type != ItemID.PsychoKnife)
if (Player.vortexStealthActive && Player.HeldItem.type != ItemID.PsychoKnife)
{
Player.GetDamage<RangedDamageClass>() -= (1f - Player.stealth) * 0.4f; // Change 80 to 40
Player.GetCritChance<RangedDamageClass>() -= (int)((1f - Player.stealth) * 5f); // Change 20 to 15
@@ -2982,7 +2982,7 @@ namespace CalamityMod.CalPlayer
}
bool hasKillMode = cooldowns.TryGetValue(KillMode.ID, out CooldownInstance killModeCD);
if (hasKillMode && killModeCD.timeLeft > KillMode.cooldownMax && !(Player.ActiveItem().type == ModContent.ItemType<ForbiddenOathblade>() || Player.ActiveItem().type == ModContent.ItemType<ExaltedOathblade>() || Player.ActiveItem().type == ModContent.ItemType<DevilsDevastation>()))
if (hasKillMode && killModeCD.timeLeft > KillMode.cooldownMax && !(Player.HeldItem.type == ModContent.ItemType<ForbiddenOathblade>() || Player.HeldItem.type == ModContent.ItemType<ExaltedOathblade>() || Player.HeldItem.type == ModContent.ItemType<DevilsDevastation>()))
{
killModeCD.timeLeft = KillMode.cooldownMax - 1;
Player.Calamity().killModeCooldown = KillMode.cooldownMax - 1;
@@ -3342,7 +3342,7 @@ namespace CalamityMod.CalPlayer
else
aquaticBoost = AquaticBoostMax;
if (Player.ActiveItem().type == ModContent.ItemType<Auralis>() && Player.StandingStill(0.1f))
if (Player.HeldItem.type == ModContent.ItemType<Auralis>() && Player.StandingStill(0.1f))
{
if (auralisStealthCounter < 300f)
auralisStealthCounter++;
@@ -3696,22 +3696,22 @@ namespace CalamityMod.CalPlayer
}
}
if (CalamityItemSets.FishingPoleThatNeverBreaks[Player.ActiveItem().type])
if (CalamityItemSets.FishingPoleThatNeverBreaks[Player.HeldItem.type])
Player.accFishingLine = true;
if (planarSpeedBoost != 0)
{
if (Player.ActiveItem().type != ModContent.ItemType<PridefulHuntersPlanarRipper>())
if (Player.HeldItem.type != ModContent.ItemType<PridefulHuntersPlanarRipper>())
planarSpeedBoost = 0;
}
if (evilSmasherBoost > 0)
{
if (Player.ActiveItem().type != ModContent.ItemType<EvilSmasher>())
if (Player.HeldItem.type != ModContent.ItemType<EvilSmasher>())
evilSmasherBoost = 0;
}
if (searedPanCounter > 0)
{
if (Player.ActiveItem().type != ModContent.ItemType<SearedPan>())
if (Player.HeldItem.type != ModContent.ItemType<SearedPan>())
{
searedPanCounter = 0;
searedPanTimer = 0;
+3 -3
View File
@@ -754,7 +754,7 @@ namespace CalamityMod.CalPlayer
private void MeleeOnHit(Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck, bool targetIsDummy)
{
var source = proj.GetSource_FromThis();
Item heldItem = Player.ActiveItem();
Item heldItem = Player.HeldItem;
if (proj.IsTrueMelee())
{
@@ -1330,7 +1330,7 @@ namespace CalamityMod.CalPlayer
if (bloodflareThrowing && proj.CountsAsClass<ThrowingDamageClass>() && crit)
Projectile.NewProjectile(proj.GetSource_OnHit(target), proj.Center, proj.velocity.SafeNormalize(Vector2.Zero) * Math.Min(((proj.velocity.Length() * proj.MaxUpdates) / 4f), 4f) * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType<BloodstoneHealOrb>(), 4, 0f, proj.owner);
if (proj.CountsAsClass<MagicDamageClass>() && Player.ActiveItem().CountsAsClass<MagicDamageClass>())
if (proj.CountsAsClass<MagicDamageClass>() && Player.HeldItem.CountsAsClass<MagicDamageClass>())
{
if (manaOverloader)
{
@@ -1405,7 +1405,7 @@ namespace CalamityMod.CalPlayer
Vector2 velocity = Main.npc[targetIdx].DirectionFrom(spawnPos);
velocity *= speed;
var source = player.GetSource_ItemUse(player.ActiveItem());
var source = player.GetSource_ItemUse(player.HeldItem);
int projectile = Projectile.NewProjectile(source, spawnPos, velocity, type, damage, knockback, player.whoAmI, targetIdx, 0f);
Main.projectile[projectile].extraUpdates += extraUpdateAmt;
}
+11 -11
View File
@@ -67,17 +67,17 @@ namespace CalamityMod.DataStructures
// Calculate the gem that should be lost.
// The accessory check is to catch the edge-case of the Shield of Cthulhu
// having melee damage for some godforsaken reason.
if (!Owner.ActiveItem().IsAir && !Owner.ActiveItem().accessory)
if (!Owner.HeldItem.IsAir && !Owner.HeldItem.accessory)
{
if (Owner.ActiveItem().CountsAsClass<MeleeDamageClass>())
if (Owner.HeldItem.CountsAsClass<MeleeDamageClass>())
GemThatShouldBeLost = GemTechArmorGemType.Melee;
if (Owner.ActiveItem().CountsAsClass<RangedDamageClass>())
if (Owner.HeldItem.CountsAsClass<RangedDamageClass>())
GemThatShouldBeLost = GemTechArmorGemType.Ranged;
if (Owner.ActiveItem().CountsAsClass<MagicDamageClass>())
if (Owner.HeldItem.CountsAsClass<MagicDamageClass>())
GemThatShouldBeLost = GemTechArmorGemType.Magic;
if (Owner.ActiveItem().CountsAsClass<SummonDamageClass>())
if (Owner.HeldItem.CountsAsClass<SummonDamageClass>())
GemThatShouldBeLost = GemTechArmorGemType.Summoner;
if (Owner.ActiveItem().CountsAsClass<ThrowingDamageClass>())
if (Owner.HeldItem.CountsAsClass<ThrowingDamageClass>())
GemThatShouldBeLost = GemTechArmorGemType.Rogue;
}
@@ -128,7 +128,7 @@ namespace CalamityMod.DataStructures
MeleeCrystalCountdown--;
// Make the crystal fire countdown go down faster if holding a true melee item.
if (Owner.ActiveItem().IsTrueMelee())
if (Owner.HeldItem.IsTrueMelee())
MeleeCrystalCountdown--;
// Ensure the crystal cooldown does not go below 0 due to the second decrement.
@@ -153,7 +153,7 @@ namespace CalamityMod.DataStructures
for (int i = 0; i < 14; i++)
{
Vector2 shootVelocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(0.5f, 3.25f);
Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.ActiveItem()), target.Center, shootVelocity, ModContent.ProjectileType<GemTechYellowShard>(), damage, 0f, OwnerIndex);
Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.HeldItem), target.Center, shootVelocity, ModContent.ProjectileType<GemTechYellowShard>(), damage, 0f, OwnerIndex);
}
MeleeCrystalCountdown = GemTechHeadgear.MeleeShardDelay;
@@ -173,7 +173,7 @@ namespace CalamityMod.DataStructures
shootVelocity = shootVelocity.SafeNormalize(Vector2.UnitY) * 6f;
spawnPosition -= shootVelocity.SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(15f, 50f);
Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.ActiveItem()), spawnPosition, shootVelocity, ModContent.ProjectileType<GemTechGreenFlechette>(), damage, 0f, OwnerIndex);
Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.HeldItem), spawnPosition, shootVelocity, ModContent.ProjectileType<GemTechGreenFlechette>(), damage, 0f, OwnerIndex);
}
public void OnItemUseEffects(Item item)
@@ -277,7 +277,7 @@ namespace CalamityMod.DataStructures
gemDamage = CalamityUtils.DamageSoftCap(gemDamage, GemTechHeadgear.GemDamageSoftcapThreshold);
if (Main.myPlayer == OwnerIndex)
Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.ActiveItem()), gemPosition, Vector2.Zero, ModContent.ProjectileType<GemTechArmorGem>(), gemDamage, 0f, OwnerIndex, 0f, (int)GemThatShouldBeLost);
Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.HeldItem), gemPosition, Vector2.Zero, ModContent.ProjectileType<GemTechArmorGem>(), gemDamage, 0f, OwnerIndex, 0f, (int)GemThatShouldBeLost);
}
}
@@ -349,7 +349,7 @@ namespace CalamityMod.DataStructures
Owner.lifeRegen += GemTechHeadgear.AllGemsWeaponUseLifeRegenBoost;
}
if (!Owner.ActiveItem().IsAir && !Owner.ActiveItem().CountsAsClass<MagicDamageClass>())
if (!Owner.HeldItem.IsAir && !Owner.HeldItem.CountsAsClass<MagicDamageClass>())
Owner.manaRegen += GemTechHeadgear.NonMagicItemManaRegenBoost;
}
+1 -1
View File
@@ -591,7 +591,7 @@ namespace CalamityMod.ILEditing
// This only applies to minions spawned by weapon uses, preventing other minions such as Luxor's Gift from exploding
if (projectile.minion && spawnSource is EntitySource_ItemUse useSource && useSource.Item is Item weapon && weapon.useAnimation > 0)
{
CalamityPlayer.EnchantHeldItemEffects(player, player.Calamity(), player.ActiveItem());
CalamityPlayer.EnchantHeldItemEffects(player, player.Calamity(), player.HeldItem);
if (player.Calamity().explosiveMinionsEnchant)
calProj.ExplosiveEnchantCountdown = CalamityGlobalProjectile.ExplosiveEnchantTime;
}
+1 -1
View File
@@ -36,7 +36,7 @@ namespace CalamityMod.Items.Accessories
Item heldItem = null;
if (player.selectedItem >= 0 && player.selectedItem < Main.InventorySlotsTotal)
heldItem = player.ActiveItem();
heldItem = player.HeldItem;
static string OnePlace(float f) => f.ToString("n1");
static string TwoPlaces(float f) => f.ToString("n2");
+6 -6
View File
@@ -67,13 +67,13 @@ namespace CalamityMod.Items.Accessories
}
}
}
if (player.ActiveItem() != null && !player.ActiveItem().IsAir && player.ActiveItem().stack > 0)
if (player.HeldItem != null && !player.HeldItem.IsAir && player.HeldItem.stack > 0)
{
bool summon = player.ActiveItem().CountsAsClass<SummonDamageClass>();
bool rogue = player.ActiveItem().CountsAsClass<ThrowingDamageClass>();
bool melee = player.ActiveItem().CountsAsClass<MeleeDamageClass>();
bool ranged = player.ActiveItem().CountsAsClass<RangedDamageClass>();
bool magic = player.ActiveItem().CountsAsClass<MagicDamageClass>();
bool summon = player.HeldItem.CountsAsClass<SummonDamageClass>();
bool rogue = player.HeldItem.CountsAsClass<ThrowingDamageClass>();
bool melee = player.HeldItem.CountsAsClass<MeleeDamageClass>();
bool ranged = player.HeldItem.CountsAsClass<RangedDamageClass>();
bool magic = player.HeldItem.CountsAsClass<MagicDamageClass>();
if (summon)
{
player.GetKnockback<SummonDamageClass>() += 0.1f;
+4 -4
View File
@@ -613,7 +613,7 @@ namespace CalamityMod.Items
// Prevent Mana Stars from being picked up while wielding Ion Blaster or Apoctosis Array
if (item.type == ItemID.Star || item.type == ItemID.SoulCake || item.type == ItemID.SugarPlum)
{
if (player.ActiveItem().type == ItemType<IonBlaster>() || player.ActiveItem().type == ItemType<ApoctosisArray>())
if (player.HeldItem.type == ItemType<IonBlaster>() || player.HeldItem.type == ItemType<ApoctosisArray>())
return false;
}
return base.CanPickup(item, player);
@@ -724,7 +724,7 @@ namespace CalamityMod.Items
{
return false;
}
if (player.ActiveItem().type == ItemType<VoidConcentrationStaff>() && player.ownedProjectileCounts[ProjectileType<VoidConcentrationBlackhole>()] == 0)
if (player.HeldItem.type == ItemType<VoidConcentrationStaff>() && player.ownedProjectileCounts[ProjectileType<VoidConcentrationBlackhole>()] == 0)
{
foreach (Projectile p in Main.ActiveProjectiles)
{
@@ -739,7 +739,7 @@ namespace CalamityMod.Items
}
return false;
}
if (player.ActiveItem().type == ItemType<GlacialEmbrace>())
if (player.HeldItem.type == ItemType<GlacialEmbrace>())
{
bool canContinue = true;
int count = 0;
@@ -769,7 +769,7 @@ namespace CalamityMod.Items
float angleVariance = MathHelper.TwoPi / pointyThingyAmount;
float angle = 0f;
var source = player.GetSource_ItemUse(player.ActiveItem());
var source = player.GetSource_ItemUse(player.HeldItem);
for (int i = 0; i < pointyThingyAmount; i++)
{
if (Main.projectile.Length == Main.maxProjectiles)
@@ -54,7 +54,7 @@ namespace CalamityMod.Items.VanillaArmorChanges
int flareDamage = CalamityUtils.DamageSoftCap(originalDamage * 0.3, FlareDamageSoftcap);
Vector2 flareSpawnPosition = victim.Center + Main.rand.NextVector2Circular(10f, 10f);
Projectile.NewProjectile(owner.GetSource_ItemUse(owner.ActiveItem()), flareSpawnPosition, Vector2.Zero, ModContent.ProjectileType<MythrilFlare>(), flareDamage, 0f, owner.whoAmI);
Projectile.NewProjectile(owner.GetSource_ItemUse(owner.HeldItem), flareSpawnPosition, Vector2.Zero, ModContent.ProjectileType<MythrilFlare>(), flareDamage, 0f, owner.whoAmI);
}
}
}
+1 -1
View File
@@ -46,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Magic
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
Item v = player.ActiveItem();
Item v = player.HeldItem;
int chargeTime = 2 * v.useAnimation;
Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, chargeTime);
return false;
+2 -2
View File
@@ -91,7 +91,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void UpdateEquips()
{
if (Player.ActiveItem().type == ModContent.ItemType<StygianShield>())
if (Player.HeldItem.type == ModContent.ItemType<StygianShield>())
{
Player.hasRaisableShield = true;
Player.statDefense += StygianShield.HeldDefense;
@@ -111,7 +111,7 @@ namespace CalamityMod.Items.Weapons.Melee
// Overrides every other shield in accessories
public override void UpdateVisibleVanityAccessories()
{
if (Player.ActiveItem().type == ModContent.ItemType<StygianShield>())
if (Player.HeldItem.type == ModContent.ItemType<StygianShield>())
{
Player.shield = EquipLoader.GetEquipSlot(Mod, "StygianShield", EquipType.Shield);
Player.cShield = 0;
+2 -2
View File
@@ -93,7 +93,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void Update(ref float gravity, ref float maxFallSpeed) => ScrewStored = false;
public override void UpdateInventory(Player player)
{
if (player.ActiveItem() != Item)
if (player.HeldItem != Item)
ScrewStored = false;
}
@@ -165,7 +165,7 @@ namespace CalamityMod.Items.Weapons.Melee
Player myPlayer = Main.LocalPlayer;
if (myPlayer.ActiveItem() != Item || !myPlayer.active || myPlayer.dead)
if (myPlayer.HeldItem != Item || !myPlayer.active || myPlayer.dead)
return;
spriteBatch.End();
+2 -2
View File
@@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Ranged
public override void UpdateInventory(Player player)
{
//Spawn heads while holding
if (player.ActiveItem() == Item && player.ownedProjectileCounts[HeadID] < MaximumHeadCount)
if (player.HeldItem == Item && player.ownedProjectileCounts[HeadID] < MaximumHeadCount)
{
HeadSpawnTimer++;
if (HeadSpawnTimer >= TimeToSpawnHead * 60)
@@ -65,7 +65,7 @@ namespace CalamityMod.Items.Weapons.Ranged
head.OriginalCritChance = Item.crit;
}
}
else if (player.ActiveItem().type != Item.type || player.dead || !player.active)
else if (player.HeldItem.type != Item.type || player.dead || !player.active)
{
foreach (Projectile p in Main.ActiveProjectiles)
{
+1 -1
View File
@@ -70,7 +70,7 @@ namespace CalamityMod.Items.Weapons.Ranged
if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().despoilerNerf)
{
Projectile holdout2 = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.ActiveItem().damage, 0f, player.whoAmI, 0, 0, 10 + (shotType ? 5 : 0));
Projectile holdout2 = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.HeldItem.damage, 0f, player.whoAmI, 0, 0, 10 + (shotType ? 5 : 0));
holdout2.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero);
SoundStyle fire = new("CalamityMod/Sounds/Item/DudFire");
SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.5f + (shotType ? 0.5f : 0) }, player.Center);
+1 -1
View File
@@ -5283,7 +5283,7 @@ namespace CalamityMod.NPCs
{
// 08OCT2024: Ozzatron: this can be abused by firing a ton of shots then hotswapping to AMR while they are in flight
// we will need IEntitySource item use time provenance to fix this, and even that is unreliable with holdouts
modPlayer.spiritOriginCritBoost += player.ActiveItem().useTime;
modPlayer.spiritOriginCritBoost += player.HeldItem.useTime;
if (bullseye.ai[2] == 0f)
{
@@ -172,7 +172,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles
{
// Multiplayer null-checking.
Owner ??= Main.player[Projectile.owner];
HeldItem ??= Owner.ActiveItem();
HeldItem ??= Owner.HeldItem;
KillHoldoutLogic();
ManageHoldout();
@@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles
{
foreach (int itemID in ItemProjectileRelationship.Keys)
{
Item heldItem = player.ActiveItem();
Item heldItem = player.HeldItem;
if (heldItem.type != itemID)
continue;
@@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles
public sealed override void AI()
{
CheckForEveryHoldout(Owner);
if (Owner.ActiveItem().type != AssociatedItemID || Owner.CCed || !Owner.active || Owner.dead || Owner.Calamity().profanedCrystalBuffs)
if (Owner.HeldItem.type != AssociatedItemID || Owner.CCed || !Owner.active || Owner.dead || Owner.Calamity().profanedCrystalBuffs)
{
Projectile.Kill();
return;
+1 -1
View File
@@ -3667,7 +3667,7 @@ namespace CalamityMod.Projectiles
{
if (projectile.timeLeft > 570) //all of these have a time left of 600 or 660
{
if (player.ActiveItem().type == ItemID.BeesKnees)
if (player.HeldItem.type == ItemID.BeesKnees)
projectile.DamageType = DamageClass.Ranged;
}
}
@@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
public override void KillHoldoutLogic()
{
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)
Projectile.Kill();
}
public override void OnSpawn(IEntitySource source)
@@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
public override void HoldoutAI()
{
CalamityGlobalItem modItem = Owner.ActiveItem().Calamity();
CalamityGlobalItem modItem = Owner.HeldItem.Calamity();
Vector2 mountedCenter = Owner.MountedCenter;
Vector2 ownerToMouse = Owner.Calamity().mouseWorld - mountedCenter;
if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying)
@@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
if (Main.myPlayer == Owner.whoAmI)
{
// Get the projectile owner's held item. If it's not a modded item, stop now to prevent weird errors.
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
if (heldItem.type < ItemID.Count)
{
Projectile.Kill();
@@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
return;
}
if (HeldItem.type != Owner.ActiveItem().type)
if (HeldItem.type != Owner.HeldItem.type)
{
StopSounds();
Projectile.Kill();
@@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
return;
}
if (HeldItem.type != Owner.ActiveItem().type)
if (HeldItem.type != Owner.HeldItem.type)
{
StopSounds();
Projectile.Kill();
@@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
{
get
{
CalamityGlobalItem swordItem = Main.player[Projectile.owner].ActiveItem().Calamity();
CalamityGlobalItem swordItem = Main.player[Projectile.owner].HeldItem.Calamity();
return swordItem.ChargeRatio < Phaseslayer.SizeChargeThreshold;
}
}
@@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
public override void AI()
{
Player player = Main.player[Projectile.owner];
CalamityGlobalItem modItem = player.ActiveItem().Calamity();
CalamityGlobalItem modItem = player.HeldItem.Calamity();
// Angles are wrapped to be 0 to 2pi instead of -pi to pi for convenience with absolute values.
float rotationAdjusted = MathHelper.WrapAngle(Projectile.rotation) + MathHelper.Pi;
@@ -130,7 +130,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
if (Main.myPlayer == player.whoAmI)
{
// In addition to typical channel cancellation criteria, the sword fizzles out if it runs out of charge.
Item playerItem = player.ActiveItem();
Item playerItem = player.HeldItem;
bool hasCharge = modItem.Charge > 0f;
if (!player.CantUseHoldout() && playerItem.type == ModContent.ItemType<Phaseslayer>() && hasCharge)
{
@@ -205,7 +205,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
float speedDamageScalar = MathF.Log(AngularDamageFactor / StandardSwingSpeed + 3f, 3f);
// Get the underlying sword item's current damage. This takes into account the player's stats and the sword's current charge.
int damageWithChargeAndStats = player.GetWeaponDamage(player.ActiveItem());
int damageWithChargeAndStats = player.GetWeaponDamage(player.HeldItem);
float sizeDamageScalar = IsSmall ? Phaseslayer.SmallDamageMultiplier : 1f;
Projectile.damage = (int)(damageWithChargeAndStats * speedDamageScalar * sizeDamageScalar);
}
+2 -2
View File
@@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic
{
base.KillHoldoutLogic();
bool actuallyShoot = DeployedFrames >= (HeldItem?.useAnimation ?? AetherfluxCannon.UseTime);
bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem());
bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.HeldItem);
if (!manaOK)
Projectile.Kill();
}
@@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Magic
{
LastShootAttemptTime = DeployedFrames;
bool actuallyShoot = DeployedFrames >= itemUseTime;
bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem(), -1, true, false);
bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.HeldItem, -1, true, false);
if (manaOK)
{
if (actuallyShoot)
+1 -1
View File
@@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Magic
// Makes the music notes appear to orbit around the player
float baseRotationSpeed = Main.zenithWorld ? 0.857142f : 1f;
float rotationSpeed = baseRotationSpeed * (60f / Owner.ActiveItem().useTime);
float rotationSpeed = baseRotationSpeed * (60f / Owner.HeldItem.useTime);
Projectile.Center = Owner.Center + new Vector2(80, 0).RotatedBy(MathHelper.ToRadians(Timer * rotationSpeed));
// If the player stops using the weapon or does not have enough mana, switch to fade away mode
+1 -1
View File
@@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Magic
return;
}
if (HeldItem.type != Owner.ActiveItem().type)
if (HeldItem.type != Owner.HeldItem.type)
{
if (manaPower > 0)
shootingTimer = -75;
+1 -1
View File
@@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Magic
int attackType = ModContent.ProjectileType<ArtAttackStar>();
if (Owner.ownedProjectileCounts[attackType] == 0)
{
if (Projectile.ai[0] >= 0f && Owner.CheckMana(Owner.ActiveItem(), -1, true, false))
if (Projectile.ai[0] >= 0f && Owner.CheckMana(Owner.HeldItem, -1, true, false))
{
SoundEngine.PlaySound(ArtAttack.UseSound, Owner.Center);
Vector2 initialStarVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15f;
+3 -3
View File
@@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic
float rotoffset = MathHelper.PiOver4;
Vector2 playerpos = player.RotatedRelativePoint(player.MountedCenter, true);
bool shouldBeHeld = !player.CantUseHoldout();
Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem());
Projectile.damage = player.HeldItem is null ? 0 : player.GetWeaponDamage(player.HeldItem);
if (Projectile.ai[0] > 0f)
{
Projectile.ai[0] -= 1f;
@@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Magic
{
if (shouldBeHeld)
{
float holdscale = player.ActiveItem().shootSpeed * Projectile.scale;
float holdscale = player.HeldItem.shootSpeed * Projectile.scale;
Vector2 playerpos2 = playerpos;
Vector2 going = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - Projectile.Center;
if (player.gravDir == -1f)
@@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Magic
if (Projectile.ai[0] <= 0)
{
bool manaCostPaid = player.CheckMana(player.ActiveItem(), -1, true, false);
bool manaCostPaid = player.CheckMana(player.HeldItem, -1, true, false);
if (manaCostPaid)
{
SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, Projectile.Center);
@@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Magic
if (Projectile.ai[2] >= 32)
{
bool manaCostPaid = Owner.CheckMana(Owner.ActiveItem(), -1, true, false);
bool manaCostPaid = Owner.CheckMana(Owner.HeldItem, -1, true, false);
if (!manaCostPaid)
{
Projectile.Kill();
@@ -78,8 +78,8 @@ namespace CalamityMod.Projectiles.Magic
{
float scaleFactor6 = 1f;
if (Owner.ActiveItem().shoot == Projectile.type)
scaleFactor6 = Owner.ActiveItem().shootSpeed * Projectile.scale;
if (Owner.HeldItem.shoot == Projectile.type)
scaleFactor6 = Owner.HeldItem.shootSpeed * Projectile.scale;
// 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction
Vector2 slashDirection = Main.MouseWorld - Owner.RotatedRelativePoint(Owner.MountedCenter, true);
+3 -3
View File
@@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic
if (Projectile.ai[0] > 480f)
hitCooldown = 5f;
Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem());
Projectile.damage = player.HeldItem is null ? 0 : player.GetWeaponDamage(player.HeldItem);
Projectile.ai[0] += 1f;
Projectile.ai[1] += 1f;
@@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Magic
if (Main.myPlayer == Projectile.owner)
{
float scaleFactor5 = player.ActiveItem().shootSpeed * Projectile.scale;
float scaleFactor5 = player.HeldItem.shootSpeed * Projectile.scale;
Vector2 projRotation = playerRotation;
Vector2 gravityAdjustedRotation = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - projRotation;
if (player.gravDir == -1f)
@@ -127,7 +127,7 @@ namespace CalamityMod.Projectiles.Magic
if (shouldHitChargedUp && Main.myPlayer == Projectile.owner)
{
bool hasMana = !shouldHitNotCharged || player.CheckMana(player.ActiveItem(), -1, true, false);
bool hasMana = !shouldHitNotCharged || player.CheckMana(player.HeldItem, -1, true, false);
if (!player.CantUseHoldout() && hasMana)
{
if (Projectile.ai[0] == 1f)
+1 -1
View File
@@ -119,7 +119,7 @@ namespace CalamityMod.Projectiles.Magic
if (potentialTarget != null && Time % SubsumingVortex.VortexReleaseRate == SubsumingVortex.VortexReleaseRate - 1 && Time < SubsumingVortex.LargeVortexChargeupTime && !HasBeenReleased)
{
// CheckMana returns true if the mana cost can be paid..
bool allowContinuedUse = Owner.CheckMana(Owner.ActiveItem(), -1, true, false);
bool allowContinuedUse = Owner.CheckMana(Owner.HeldItem, -1, true, false);
bool vortexStillInUse = Owner.Calamity().mouseRight && allowContinuedUse && !Owner.noItems && !Owner.CCed;
if (vortexStillInUse)
{
+1 -1
View File
@@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Magic
public override void KillHoldoutLogic()
{
if (HeldItem.type != Owner.ActiveItem().type || Owner.CantUseHoldout())
if (HeldItem.type != Owner.HeldItem.type || Owner.CantUseHoldout())
Projectile.Kill();
}
+4 -4
View File
@@ -154,12 +154,12 @@ namespace CalamityMod.Projectiles.Magic
if (isActive && Main.myPlayer == Projectile.owner)
{
float coreVelocity = 11.5f;
int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem());
float weaponKnockback2 = player.ActiveItem().knockBack;
int weaponDamage2 = player.GetWeaponDamage(player.HeldItem);
float weaponKnockback2 = player.HeldItem.knockBack;
if (canUseItem)
{
weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2);
float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale;
weaponKnockback2 = player.GetWeaponKnockback(player.HeldItem, weaponKnockback2);
float scaleFactor12 = player.HeldItem.shootSpeed * Projectile.scale;
Vector2 playerRotateCopy = playerRotate;
Vector2 projSpawnDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotateCopy;
if (player.gravDir == -1f)
+3 -3
View File
@@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Magic
float rotoffset = MathHelper.PiOver2;
Vector2 playerpos = player.RotatedRelativePoint(player.MountedCenter, true);
bool shouldBeHeld = !player.CantUseHoldout();
Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem());
Projectile.damage = player.HeldItem is null ? 0 : player.GetWeaponDamage(player.HeldItem);
if (Projectile.ai[0] > 0f)
{
Projectile.ai[0]--;
@@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Magic
{
if (shouldBeHeld)
{
float holdscale = player.ActiveItem().shootSpeed * Projectile.scale;
float holdscale = player.HeldItem.shootSpeed * Projectile.scale;
Vector2 playerpos2 = playerpos;
Vector2 going = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerpos2;
if (player.gravDir == -1f)
@@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Magic
if (Projectile.ai[0] <= 0)
{
bool manaCostPaid = player.CheckMana(player.ActiveItem(), -1, true, false);
bool manaCostPaid = player.CheckMana(player.HeldItem, -1, true, false);
if (manaCostPaid)
{
SoundEngine.PlaySound(SoundID.Item111, Projectile.Center);
+1 -1
View File
@@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Magic
public override void KillHoldoutLogic()
{
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)
Projectile.Kill();
}
+1 -1
View File
@@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Magic
// If the owner has sufficient mana, consume it.
// Otherwise, delete the book and don't bother summoning anything.
if (!Owner.CheckMana(Owner.ActiveItem().mana, true, false))
if (!Owner.CheckMana(Owner.HeldItem.mana, true, false))
{
Projectile.Kill();
return;
+2 -2
View File
@@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Magic
if (TriggeredBurnOut)
Owner.Calamity().burningSeaBurnOut = BurningSea.BurnOutReuseDelay;
bool canUseMana = Owner.CheckMana(Owner.ActiveItem());
bool canUseMana = Owner.CheckMana(Owner.HeldItem);
// Use different behavior depending on if the player is channeling or not.
if (Owner.CantUseHoldout() || !canUseMana || Projectile.timeLeft <= (int)BurningSea.FizzleOutTime)
{
@@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Magic
// Consume mana periodically.
if (Timer % 15 == 0f)
Owner.CheckMana(Owner.ActiveItem(), -1, true);
Owner.CheckMana(Owner.HeldItem, -1, true);
// Spawn little spark effects around the fireball when fully charged.
if (Timer > BurningSea.ChargeTime && Timer < BurningSea.BurnOutTime)
+1 -1
View File
@@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Magic
return;
}
if (HeldItem.type != Owner.ActiveItem().type)
if (HeldItem.type != Owner.HeldItem.type)
{
if (manaPower > 0)
shootingTimer = -75;
+1 -1
View File
@@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Magic
Projectile.active = false;
return;
}
if (!player.ActiveItem().CountsAsClass<MagicDamageClass>() || player.ActiveItem().shoot != ModContent.ProjectileType<MelterNote1>())
if (!player.HeldItem.CountsAsClass<MagicDamageClass>() || player.HeldItem.shoot != ModContent.ProjectileType<MelterNote1>())
{
Projectile.active = false;
return;
+2 -2
View File
@@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Magic
{
base.KillHoldoutLogic();
bool actuallyShoot = DeployedFrames >= (HeldItem?.useAnimation ?? NanoPurge.UseTime);
bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem());
bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.HeldItem);
if (!manaOK)
Projectile.Kill();
}
@@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Magic
// Update the animation.
Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type];
bool manaCostPaid = Owner.CheckMana(Owner.ActiveItem(), -1, true, false);
bool manaCostPaid = Owner.CheckMana(Owner.HeldItem, -1, true, false);
if (manaCostPaid)
{
postShotFade = 1;
+1 -1
View File
@@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Magic
// If the index is not default, smart bounce in the direction of that enemy.
if (index != -1)
{
Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], owner.ActiveItem().shootSpeed, 3);
Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], owner.HeldItem.shootSpeed, 3);
}
else // Otherwise, use standard bouncing behavior.
{
+4 -4
View File
@@ -88,12 +88,12 @@ namespace CalamityMod.Projectiles.Magic
int projectileType = ModContent.ProjectileType<NebulaCloudCore>();
float coreVelocity = 8f;
int weaponDamage = Owner.GetWeaponDamage(Owner.ActiveItem());
float weaponKnockback = Owner.ActiveItem().knockBack;
int weaponDamage = Owner.GetWeaponDamage(Owner.HeldItem);
float weaponKnockback = Owner.HeldItem.knockBack;
if (weaponInUse)
{
weaponKnockback = Owner.GetWeaponKnockback(Owner.ActiveItem(), weaponKnockback);
float scaleFactor = Owner.ActiveItem().shootSpeed * Projectile.scale;
weaponKnockback = Owner.GetWeaponKnockback(Owner.HeldItem, weaponKnockback);
float scaleFactor = Owner.HeldItem.shootSpeed * Projectile.scale;
Vector2 projectileSpawnPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true);
Vector2 projectileDestination = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - projectileSpawnPosition;
+2 -2
View File
@@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Magic
if (Owner.Calamity().mouseRight && PostFireCooldown <= 0)
{
if (Owner.CheckMana(Owner.ActiveItem(), (int)(HeldItem.mana * Owner.manaCost) * 13, true))
if (Owner.CheckMana(Owner.HeldItem, (int)(HeldItem.mana * Owner.manaCost) * 13, true))
{
PostFireCooldown = 100;
Shoot(true);
@@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Magic
}
else if (ShootingTimer >= FireRate)
{
if (Owner.CheckMana(Owner.ActiveItem(), -1, true) && PostFireCooldown <= 0)
if (Owner.CheckMana(Owner.HeldItem, -1, true) && PostFireCooldown <= 0)
{
MaxFireRateShots++;
+3 -3
View File
@@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Magic
MovingUp = Projectile.ai[2] == 1;
firingDelay--;
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
// Update damage based on curent magic damage stat (so Mana Sickness affects it)
Projectile.damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem);
@@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Magic
if (launchDelay < 50)
launchDelay++;
if (launchDelay >= 50 && (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 2, true, false)))
if (launchDelay >= 50 && (Owner.CheckMana(Owner.HeldItem, (int)(heldItem.mana * Owner.manaCost) * 2, true, false)))
{
Shoot(true);
PostFireCooldown = 50;
@@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.Magic
}
else if (ShootingTimer >= FiringTime)
{
if (Owner.CheckMana(Owner.ActiveItem(), -1, false, false))
if (Owner.CheckMana(Owner.HeldItem, -1, false, false))
{
Shoot(false);
ShootingTimer = 0;
+2 -2
View File
@@ -36,13 +36,13 @@ namespace CalamityMod.Projectiles.Magic
public Color color2 = Color.Orange;
public override void KillHoldoutLogic()
{
if (!isOnCooldown && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type))
if (!isOnCooldown && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type))
Projectile.Kill();
}
public override void HoldoutAI()
{
if (!isOnCooldown && (Owner.CantUseHoldout() || HeldItem.type != Owner.ActiveItem().type))
if (!isOnCooldown && (Owner.CantUseHoldout() || HeldItem.type != Owner.HeldItem.type))
cooldownTimer = (int)(Utils.Remap(revFrames, 0, 350, 40, 120, true));
if (isOnCooldown)
{
@@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic
public override void AI()
{
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
Projectile.damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem);
UpdatePlayerVisuals(Owner.Center);
+1 -1
View File
@@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Magic
Projectile.Center = Owner.Center + Vector2.UnitX * Owner.direction * 8f;
// CheckMana returns true if the mana cost can be paid. If mana isn't consumed this frame, the CheckMana short-circuits out of being evaluated.
bool allowContinuedUse = Time % ManaConsumeRate != ManaConsumeRate - 1f || Owner.CheckMana(Owner.ActiveItem(), -1, true, false);
bool allowContinuedUse = Time % ManaConsumeRate != ManaConsumeRate - 1f || Owner.CheckMana(Owner.HeldItem, -1, true, false);
bool bookStillInUse = Owner.channel && allowContinuedUse && !Owner.noItems && !Owner.CCed;
// If the owner is no longer able to hold the book, kill it.
+1 -1
View File
@@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic
public override void KillHoldoutLogic()
{
if (HeldItem.type != Owner.ActiveItem().type || Owner.dead)
if (HeldItem.type != Owner.HeldItem.type || Owner.dead)
Projectile.Kill();
if (Owner.CantUseHoldout() && !hasLetGo)
postFireTimer = cooldownTime;
+1 -1
View File
@@ -167,7 +167,7 @@ namespace CalamityMod.Projectiles.Magic
/// </summary>
private void FireAwesomeMagicRays()
{
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
if (heldItem is null)
return;
+1 -1
View File
@@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Magic
return false;
}
// Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore
if (Owner.miscCounter % 10 == 0 && !Owner.CheckMana(Owner.ActiveItem(), -1, true))
if (Owner.miscCounter % 10 == 0 && !Owner.CheckMana(Owner.HeldItem, -1, true))
{
Projectile.Kill();
return false;
+1 -1
View File
@@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Magic
// Calculate how quickly the staff should charge. Charge increases by some number close to 1 every frame.
// Speed increasing reforges make this number greater than 1. Slowing reforges make it smaller than 1.
if (Projectile.localAI[0] == 0f)
Projectile.localAI[0] = (ValkyrieRay.ChargeFrames + ValkyrieRay.CooldownFrames) / player.ActiveItem().useTime;
Projectile.localAI[0] = (ValkyrieRay.ChargeFrames + ValkyrieRay.CooldownFrames) / player.HeldItem.useTime;
// Increment the timer for the staff. If the timer has passed the total time, destroy it.
Projectile.ai[0] += Projectile.localAI[0];
+1 -1
View File
@@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Magic
if (Main.myPlayer != Projectile.owner)
return;
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
Vector2 shootVelocity = Projectile.velocity * heldItem.shootSpeed;
int damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shootVelocity, ModContent.ProjectileType<VehemenceBolt>(), damage, heldItem.knockBack, Projectile.owner);
+1 -1
View File
@@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Magic
public override void KillHoldoutLogic()
{
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)
Projectile.Kill();
}
+4 -4
View File
@@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Magic
public override void KillHoldoutLogic()
{
// Override typical CantUseHoldout such that the weapon typically runs through the use animation while not channeled
if (HeldItem.type != Owner.ActiveItem().type || Owner.dead || !Owner.active)
if (HeldItem.type != Owner.HeldItem.type || Owner.dead || !Owner.active)
{
Projectile.Kill();
Projectile.netUpdate = true;
@@ -73,9 +73,9 @@ namespace CalamityMod.Projectiles.Magic
Projectile.frameCounter++;
// Subtract a flat 42 from the use time because the firing animation consists of 14 frames at 20 FPS
if (Projectile.frameCounter >= MathHelper.Clamp(Owner.ActiveItem().useAnimation - 42, 0f, Owner.ActiveItem().useAnimation))
if (Projectile.frameCounter >= MathHelper.Clamp(Owner.HeldItem.useAnimation - 42, 0f, Owner.HeldItem.useAnimation))
{
if (Owner.CantUseHoldout() || !Owner.CheckMana(Owner.ActiveItem()))
if (Owner.CantUseHoldout() || !Owner.CheckMana(Owner.HeldItem))
Projectile.Kill();
Projectile.frame = 0;
@@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Magic
}
Projectile.frameCounter++;
if (Owner.CheckMana(Owner.ActiveItem(), -1, true))
if (Owner.CheckMana(Owner.HeldItem, -1, true))
{
FlashTimer = 4f;
FireSoundSlot = SoundEngine.PlaySound(FireSound, GunTipPosition);
+3 -3
View File
@@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Magic
}
firingDelay--;
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
// Update damage based on curent magic damage stat (so Mana Sickness affects it)
Projectile.damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem);
@@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Magic
// If the player's pressing RMB, it'll shoot the grenade.
if (Owner.Calamity().mouseRight)
{
if ((Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 5, true, false)))
if ((Owner.CheckMana(Owner.HeldItem, (int)(heldItem.mana * Owner.manaCost) * 5, true, false)))
{
Shoot(true);
PostFireCooldown = 35 + 55 * Utils.GetLerpValue(10, 40, FiringTime, true);
@@ -100,7 +100,7 @@ namespace CalamityMod.Projectiles.Magic
}
else if (ShootingTimer >= FiringTime)
{
if (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost), true, false))
if (Owner.CheckMana(Owner.HeldItem, (int)(heldItem.mana * Owner.manaCost), true, false))
{
Shoot(false);
ShootingTimer = 0;
+3 -3
View File
@@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Magic
Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true);
// Update damage based on curent magic damage stat (so Mana Sickness affects it)
Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem());
Projectile.damage = player.HeldItem is null ? 0 : player.GetWeaponDamage(player.HeldItem);
FrameCounter += 1f;
float chargeRatio = MathHelper.Clamp(FrameCounter / MaxCharge, 0f, 1f);
@@ -79,11 +79,11 @@ namespace CalamityMod.Projectiles.Magic
if (Projectile.owner == Main.myPlayer)
{
// Scale seemingly never changes, so this just scales with shoot speed (Yharim's Crystal is 30 by default)
float speedTimesScale = player.ActiveItem().shootSpeed * Projectile.scale;
float speedTimesScale = player.HeldItem.shootSpeed * Projectile.scale;
UpdateAim(rrp, speedTimesScale);
// CheckMana returns true if the mana cost can be paid. If mana isn't consumed this frame, the CheckMana short-circuits out of being evaluated.
bool allowContinuedUse = !ShouldConsumeMana() || player.CheckMana(player.ActiveItem(), -1, true, false);
bool allowContinuedUse = !ShouldConsumeMana() || player.CheckMana(player.HeldItem, -1, true, false);
bool crystalStillInUse = !player.CantUseHoldout() && allowContinuedUse;
// The beams are only projected once (on frame 1).
+2 -2
View File
@@ -90,8 +90,8 @@ namespace CalamityMod.Projectiles.Melee
else
{
float velocityScale = 1f;
if (Owner.ActiveItem().shoot == Projectile.type)
velocityScale = Owner.ActiveItem().shootSpeed * Projectile.scale;
if (Owner.HeldItem.shoot == Projectile.type)
velocityScale = Owner.HeldItem.shootSpeed * Projectile.scale;
// 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction
Vector2 slashDirection = Main.MouseWorld - Owner.RotatedRelativePoint(Owner.MountedCenter, true);
+3 -3
View File
@@ -344,7 +344,7 @@ namespace CalamityMod.Projectiles.Melee
float rotationAngle = MathHelper.PiOver4 * 0.3f * ((Timer - beamShootStart) / beamShootPeriod);
int boltDamage = (int)(Projectile.damage * Exoblade.NotTrueMeleeDamagePenalty);
Vector2 boltVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4 * 0.3);
boltVelocity *= Owner.ActiveItem().shootSpeed;
boltVelocity *= Owner.HeldItem.shootSpeed;
Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + boltVelocity * 5f, boltVelocity, ModContent.ProjectileType<Exobeam>(), boltDamage, Projectile.knockBack / 3f, Projectile.owner);
}
@@ -589,8 +589,8 @@ namespace CalamityMod.Projectiles.Melee
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, hit, damageDone);
NPCLoader.OnHitByItem(target, Owner, Owner.ActiveItem(), hit, damageDone);
ItemLoader.OnHitNPC(Owner.HeldItem, Owner, target, hit, damageDone);
NPCLoader.OnHitByItem(target, Owner, Owner.HeldItem, hit, damageDone);
PlayerLoader.OnHitNPC(Owner, target, hit, damageDone);
if (State == SwingState.BonkDash)
+2 -2
View File
@@ -156,9 +156,9 @@ namespace CalamityMod.Projectiles.Melee
public void HandleChannelMovement(Player player, Vector2 playerRotatedPoint)
{
float speed = 1f;
if (player.ActiveItem().shoot == Projectile.type)
if (player.HeldItem.shoot == Projectile.type)
{
speed = player.ActiveItem().shootSpeed * Projectile.scale;
speed = player.HeldItem.shootSpeed * Projectile.scale;
}
// 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction
Vector2 newVelocity = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * player.direction) * speed;
+2 -2
View File
@@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Melee
{
// Recalculate damage every frame for balance reasons, as this is a long-lasting holdout.
// This is important because you could start using it while benefitting from Auric Tesla standstill bonus, for example.
Projectile.damage = Owner.ActiveItem() is null ? 0 : Owner.GetWeaponDamage(Owner.ActiveItem());
Projectile.damage = Owner.HeldItem is null ? 0 : Owner.GetWeaponDamage(Owner.HeldItem);
DetermineDamage();
PlayChainsawSounds();
@@ -217,7 +217,7 @@ namespace CalamityMod.Projectiles.Melee
// Incorporate item shoot speed into the range of the crystals.
// This means that projectile speed boosts will improve the range of the chainsaw.
shootReach *= Owner.ActiveItem().shootSpeed;
shootReach *= Owner.HeldItem.shootSpeed;
// 15NOV2024: Ozzatron: clamped mouse position unnecessary, the result is separately capped
float distanceFromMouse = Owner.Distance(Main.MouseWorld);
+1 -1
View File
@@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Melee
{
// Recalculate damage every frame for balance reasons, as this is a long-lasting holdout.
// This is important because you could start using it while benefitting from Auric Tesla standstill bonus, for example.
Projectile.damage = Owner.ActiveItem() is null ? 0 : Owner.GetWeaponDamage(Owner.ActiveItem());
Projectile.damage = Owner.HeldItem is null ? 0 : Owner.GetWeaponDamage(Owner.HeldItem);
PlayChainsawSounds();
@@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords
var source = player.GetSource_FromThis();
if (player.Calamity().galileoCooldown <= 0)
{
int damage = player.GetWeaponDamage(player.ActiveItem()) * 2;
int damage = player.GetWeaponDamage(player.HeldItem) * 2;
CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType<GalileosPlanet>(), damage, 15f, player.whoAmI);
player.Calamity().galileoCooldown = 15;
}
+1 -1
View File
@@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Melee
}
public override void AI()
{
if (Owner is null || Owner.dead || Owner.ActiveItem().type != ModContent.ItemType<StygianShield>())
if (Owner is null || Owner.dead || Owner.HeldItem.type != ModContent.ItemType<StygianShield>())
Projectile.Kill();
Owner.heldProj = Projectile.whoAmI;
+5 -5
View File
@@ -129,15 +129,15 @@ namespace CalamityMod.Projectiles.Melee
public override void AI()
{
CalamityPlayer.EnchantHeldItemEffects(Owner, Owner.Calamity(), Owner.ActiveItem());
if (!Owner.Calamity().bladeArmEnchant || Owner.ActiveItem().type != SwordItemID || Owner.CCed || !Owner.active || Owner.dead)
CalamityPlayer.EnchantHeldItemEffects(Owner, Owner.Calamity(), Owner.HeldItem);
if (!Owner.Calamity().bladeArmEnchant || Owner.HeldItem.type != SwordItemID || Owner.CCed || !Owner.active || Owner.dead)
{
Projectile.Kill();
return;
}
if (Owner.itemAnimationMax == 0)
Owner.itemAnimationMax = (int)(Owner.ActiveItem().useAnimation * Owner.GetAttackSpeed<MeleeDamageClass>());
Owner.itemAnimationMax = (int)(Owner.HeldItem.useAnimation * Owner.GetAttackSpeed<MeleeDamageClass>());
float swingOffsetAngle = MathHelper.SmoothStep(-1.87f, 3.79f, AttackCompletionRatio);
@@ -289,8 +289,8 @@ namespace CalamityMod.Projectiles.Melee
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, hit, damageDone);
NPCLoader.OnHitByItem(target, Owner, Owner.ActiveItem(), hit, damageDone);
ItemLoader.OnHitNPC(Owner.HeldItem, Owner, target, hit, damageDone);
NPCLoader.OnHitByItem(target, Owner, Owner.HeldItem, hit, damageDone);
PlayerLoader.OnHitNPC(Owner, target, hit, damageDone);
}
}
+2 -2
View File
@@ -161,7 +161,7 @@ namespace CalamityMod.Projectiles.Melee
if (Main.myPlayer == Projectile.owner && Time == (int)(Terratomere.SwingTime * (SwingCompletionRatio + 0.34f)))
{
// 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction
Vector2 bigSlashVelocity = Projectile.SafeDirectionTo(Main.MouseWorld) * Owner.ActiveItem().shootSpeed / 2f;
Vector2 bigSlashVelocity = Projectile.SafeDirectionTo(Main.MouseWorld) * Owner.HeldItem.shootSpeed / 2f;
if (bigSlashVelocity.AngleBetween(InitialRotation.ToRotationVector2()) > 1.456f)
bigSlashVelocity = InitialRotation.ToRotationVector2() * bigSlashVelocity.Length();
@@ -177,7 +177,7 @@ namespace CalamityMod.Projectiles.Melee
// Close range slash effect
if (Main.myPlayer == Projectile.owner && Time == (int)(Terratomere.SwingTime * RecoveryCompletionRatio) + 5f)
{
Vector2 bigSlashVelocity = InitialRotation.ToRotationVector2() * Owner.ActiveItem().shootSpeed / 6f;
Vector2 bigSlashVelocity = InitialRotation.ToRotationVector2() * Owner.HeldItem.shootSpeed / 6f;
Vector2 bigSlashSpawnPosition = Projectile.Center + bigSlashVelocity.SafeNormalize(Vector2.UnitY) * 64f;
int slash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), bigSlashSpawnPosition, bigSlashVelocity, ModContent.ProjectileType<TerratomereMeleeSlash>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
+1 -1
View File
@@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Melee
{
if (EndLag == 0) //Initialization
{
EndLag = (float)Math.Max(Owner.ActiveItem().useTime - MaxTime, 1);
EndLag = (float)Math.Max(Owner.HeldItem.useTime - MaxTime, 1);
// 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction
TrueDirection = (Owner.Calamity().mouseWorld - Owner.MountedCenter).SafeNormalize(Vector2.Zero).ToRotation(); //Store this for the screw hit
Projectile.velocity = (Owner.Calamity().mouseWorld - Owner.MountedCenter).SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.PiOver4 * 0.15f);
+1 -1
View File
@@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Pets
{
if (new Rectangle((int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height).Intersects(new Rectangle((int)item.position.X, (int)item.position.Y, item.width, item.height)))
{
if (Projectile.owner == Main.myPlayer && (player.ActiveItem().type != ItemID.None || player.itemAnimation <= 0))
if (Projectile.owner == Main.myPlayer && (player.HeldItem.type != ItemID.None || player.itemAnimation <= 0))
{
// TODO -- fix this maybe? (what is it?)
if (!ItemLoader.OnPickup(item, player))
+1 -1
View File
@@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void KillHoldoutLogic()
{
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)
Projectile.Kill();
}
+1 -1
View File
@@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Ranged
// If the index is not default, smart bounce in the direction of that enemy.
if (index != -1)
{
Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], owner.ActiveItem().shootSpeed, 3);
Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], owner.HeldItem.shootSpeed, 3);
}
return false;
}
+3 -3
View File
@@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void KillHoldoutLogic()
{
if (HeldItem.type != Owner.ActiveItem().type)
if (HeldItem.type != Owner.HeldItem.type)
{
Projectile.Kill();
Projectile.netUpdate = true;
@@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Ranged
Idle?.Stop();
Projectile.ai[1] = 1f;
Projectile.timeLeft = Owner.ActiveItem().useAnimation;
Projectile.timeLeft = Owner.HeldItem.useAnimation;
SoundStyle ShootSound = new("CalamityMod/Sounds/Item/SawShot", 2) { PitchVariance = 0.1f, Volume = 0.4f + SawPower * 0.5f };
SoundEngine.PlaySound(ShootSound, GunTipPosition);
@@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Ranged
float sawDamageMult = MathHelper.Lerp(1f, 5f, SawPower) / 1.5f; // The damage must be divided by 1.5 to offset the holdout having 1.5x base damage.
int sawPierce = (int)MathHelper.Lerp(2f, 6f, SawPower);
Projectile buzzsaw = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * Owner.ActiveItem().shootSpeed, ModContent.ProjectileType<BuzzkillSaw>(), (int)(Projectile.damage * sawDamageMult), (int)(Projectile.knockBack * (sawDamageMult / 2)), Main.myPlayer, sawLevel);
Projectile buzzsaw = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * Owner.HeldItem.shootSpeed, ModContent.ProjectileType<BuzzkillSaw>(), (int)(Projectile.damage * sawDamageMult), (int)(Projectile.knockBack * (sawDamageMult / 2)), Main.myPlayer, sawLevel);
buzzsaw.penetrate = sawPierce;
buzzsaw.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi);
}
+6 -6
View File
@@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Ranged
FramesTillNextShot = FireRate;
shouldShoot = true;
}
bool canShoot = !player.CantUseHoldout() && (player.HasAmmo(player.ActiveItem()) || FreeShotLoaded > 0);
bool canShoot = !player.CantUseHoldout() && (player.HasAmmo(player.HeldItem) || FreeShotLoaded > 0);
if (Projectile.soundDelay <= 0 && canShoot)
{
Projectile.soundDelay = (int)FireRate;
@@ -66,8 +66,8 @@ namespace CalamityMod.Projectiles.Ranged
{
int projType = ModContent.ProjectileType<ChickenRocket>(); // PickAmmo screws up with Rockets as per usual so this variable is reset right afterward
float speedMult2 = 14.5f;
int dmg = player.GetWeaponDamage(player.ActiveItem());
float kBack = player.ActiveItem().knockBack;
int dmg = player.GetWeaponDamage(player.HeldItem);
float kBack = player.HeldItem.knockBack;
if (canShoot)
{
Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true);
@@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged
direction.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - source.Y;
}
Vector2 speedMult = Vector2.Normalize(direction);
float shootSpeed = player.ActiveItem().shootSpeed * Projectile.scale;
float shootSpeed = player.HeldItem.shootSpeed * Projectile.scale;
if (float.IsNaN(speedMult.X) || float.IsNaN(speedMult.Y))
{
speedMult = -Vector2.UnitY;
@@ -94,10 +94,10 @@ namespace CalamityMod.Projectiles.Ranged
if (FreeShotLoaded > 0)
FreeShotLoaded--;
else
player.PickAmmo(player.ActiveItem(), out projType, out speedMult2, out dmg, out kBack, out _);
player.PickAmmo(player.HeldItem, out projType, out speedMult2, out dmg, out kBack, out _);
projType = ModContent.ProjectileType<ChickenRocket>();
kBack = player.GetWeaponKnockback(player.ActiveItem(), kBack);
kBack = player.GetWeaponKnockback(player.HeldItem, kBack);
Vector2 velocity = Vector2.Normalize(Projectile.velocity) * speedMult2;
if (float.IsNaN(velocity.X) || float.IsNaN(velocity.Y))
@@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Ranged
if (ShotCooldown == 0)
{
SoundEngine.PlaySound(SoundID.Item34, Projectile.Center);
Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _);
Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _);
for (int i = 0; i < 2; i++)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 10).RotatedByRandom(0.12f), ModContent.ProjectileType<ChromaticFire>(), damage, knockback, Projectile.owner);
+6 -6
View File
@@ -62,10 +62,10 @@ namespace CalamityMod.Projectiles.Ranged
// Frame 1 effects: Initialize the shoot speed
if (FramesToLoadBolt == 0f)
{
FramesToLoadBolt = Owner.ActiveItem().useAnimation;
FramesToLoadBolt = Owner.HeldItem.useAnimation;
}
if (Owner.HasAmmo(Owner.ActiveItem()))
if (Owner.HasAmmo(Owner.HeldItem))
{
++CurrentChargingFrames;
@@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Ranged
if (CurrentChargingFrames >= FramesToLoadBolt && LoadedBolts < ClockworkBow.MaxBolts)
{
// Save the stats here for later
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
Owner.PickAmmo(heldItem, out _, out float shootSpeed, out int damage, out float knockback, out _);
Projectile.damage = damage;
Projectile.knockBack = knockback;
@@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Ranged
SoundEngine.PlaySound(SoundID.Item38);//play the sound
}
FramesToLoadBolt = Owner.ActiveItem().useAnimation; //reset the reload time
FramesToLoadBolt = Owner.HeldItem.useAnimation; //reset the reload time
LoadedBolts = 0; //Unload the bow
}
@@ -216,7 +216,7 @@ namespace CalamityMod.Projectiles.Ranged
Shift = 1 - (CurrentChargingFrames / FramesToLoadBolt);
// You need to have arrows left for the tint to not remain in stasis
if ((i == LoadedBolts - 1 || LoadedBolts == ClockworkBow.MaxBolts) && Owner.HasAmmo(Owner.ActiveItem())) //If the arrow we are looking at is the one that just got loaded, OR all arrows got loaded, we apply some flashiness
if ((i == LoadedBolts - 1 || LoadedBolts == ClockworkBow.MaxBolts) && Owner.HasAmmo(Owner.HeldItem)) //If the arrow we are looking at is the one that just got loaded, OR all arrows got loaded, we apply some flashiness
{
Main.spriteBatch.EnterShaderRegion();
GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f - MathHelper.Clamp((CurrentChargingFrames * 2 / FramesToLoadBolt), 0f, 1f));
@@ -233,7 +233,7 @@ namespace CalamityMod.Projectiles.Ranged
Main.EntitySpriteDraw(BoltTexture, drawPosition, null, Transparency, Projectile.rotation + BoltAngle + MathHelper.PiOver2 + FlipFactor, BoltTexture.Size(), 1f, 0, 0);
if ((i == LoadedBolts - 1 || LoadedBolts == ClockworkBow.MaxBolts) && Owner.HasAmmo(Owner.ActiveItem())) //Don't forget to exit the shader region
if ((i == LoadedBolts - 1 || LoadedBolts == ClockworkBow.MaxBolts) && Owner.HasAmmo(Owner.HeldItem)) //Don't forget to exit the shader region
Main.spriteBatch.ExitShaderRegion();
}
return true;
+1 -1
View File
@@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged
// If no arrows are loaded, spawn a bit of dust to indicate it's not ready yet.
// Spawn the same dust if the max number of arrows have been loaded or the player ran out of ammos to load.
if (ArrowsLoaded <= 0f || ArrowsLoaded >= Condemnation.MaxLoadedArrows || !Owner.HasAmmo(Owner.ActiveItem()))
if (ArrowsLoaded <= 0f || ArrowsLoaded >= Condemnation.MaxLoadedArrows || !Owner.HasAmmo(Owner.HeldItem))
SpawnCannotLoadArrowsDust(GunTipPosition);
if (Owner.HasAmmo(HeldItem))
+1 -1
View File
@@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Ranged
{
if (!player.CantUseHoldout())
{
float speed = player.ActiveItem().shootSpeed * Projectile.scale;
float speed = player.HeldItem.shootSpeed * Projectile.scale;
Vector2 spawnPos = vector;
Vector2 direction = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - spawnPos;
if (player.gravDir == -1f)
+6 -6
View File
@@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged
fullSpeed = true;
int arg_1EF4_0 = (int)Projectile.ai[0] / (delayCompare - fireSpeedCompare * fireSpeed);
}
bool canUseItem = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem());
bool canUseItem = !player.CantUseHoldout() && player.HasAmmo(player.HeldItem);
if (Projectile.localAI[0] > 0f)
{
Projectile.localAI[0] -= 1f;
@@ -95,13 +95,13 @@ namespace CalamityMod.Projectiles.Ranged
{
int ammoType = ProjectileID.WoodenArrowFriendly;
float scaleFactor11 = 14f;
int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem());
float weaponKnockback2 = player.ActiveItem().knockBack;
int weaponDamage2 = player.GetWeaponDamage(player.HeldItem);
float weaponKnockback2 = player.HeldItem.knockBack;
if (canUseItem)
{
player.PickAmmo(player.ActiveItem(), out ammoType, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _);
weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2);
float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale;
player.PickAmmo(player.HeldItem, out ammoType, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _);
weaponKnockback2 = player.GetWeaponKnockback(player.HeldItem, weaponKnockback2);
float scaleFactor12 = player.HeldItem.shootSpeed * Projectile.scale;
Vector2 shootDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotate;
if (player.gravDir == -1f)
{
+1 -1
View File
@@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Ranged
// If the time reaches Item.useTime, it'll shoot the projectile, fire and reset the timer.
if (fireTimer >= Owner.itemTimeMax && Main.myPlayer == Projectile.owner)
{
Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _);
Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _);
for (int i = 0; i < 3; i++)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.15f * i * 0.5f) * shootSpeed * (i == 0 ? 0.5f : i == 1 ? 0.7f : 1) * Main.rand.NextFloat(0.8f, 1f), ModContent.ProjectileType<DragonsBreathFlames>(), damage, knockback, Projectile.owner);
+5 -5
View File
@@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged
timeToFire = true;
}
bool canFire = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem());
bool canFire = !player.CantUseHoldout() && player.HasAmmo(player.HeldItem);
if (Projectile.soundDelay <= 0 && canFire)
{
@@ -92,13 +92,13 @@ namespace CalamityMod.Projectiles.Ranged
{
int type = ProjectileID.WoodenArrowFriendly; //Gets changed below anyways
float scaleFactor = 18f;
int damage = player.GetWeaponDamage(player.ActiveItem());
float knockBack = player.ActiveItem().knockBack;
int damage = player.GetWeaponDamage(player.HeldItem);
float knockBack = player.HeldItem.knockBack;
player.PickAmmo(player.ActiveItem(), out type, out scaleFactor, out damage, out knockBack, out _);
player.PickAmmo(player.HeldItem, out type, out scaleFactor, out damage, out knockBack, out _);
type = ModContent.ProjectileType<DrataliornusFlame>();
knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack);
knockBack = player.GetWeaponKnockback(player.HeldItem, knockBack);
Vector2 playerPosition = player.RotatedRelativePoint(player.MountedCenter, true);
Projectile.velocity = Main.screenPosition - playerPosition;
+24 -19
View File
@@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
@@ -31,13 +32,13 @@ namespace CalamityMod.Projectiles.Ranged
public override void KillHoldoutLogic()
{
if (!isTired && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type))
if (!isTired && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type))
Projectile.Kill();
}
public override void HoldoutAI()
{
if (!isTired && (Owner.CantUseHoldout() || HeldItem.type != Owner.ActiveItem().type))
if (!isTired && (Owner.CantUseHoldout() || HeldItem.type != Owner.HeldItem.type))
cooldownTimer = (int)(Utils.Remap(revFrames, 0, 350, 40, 180, true));
if (isTired)
{
@@ -48,23 +49,24 @@ namespace CalamityMod.Projectiles.Ranged
revSpeed = Utils.Remap(revFrames, 0, maxFrames - 120, 1, 20, true);
if (shootingTimer >= initialFireTime && revFrames < maxFrames && secondShot)
{
Owner.PickAmmo(Owner.ActiveItem(), out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _);
Owner.PickAmmo(Owner.HeldItem, out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _);
SoundStyle fire = new("CalamityMod/Sounds/Item/GunShotSmallAlt");
SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.1f + revSpeed * 0.01f }, Projectile.Center);
Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 19;
float spread = 0.045f * Utils.GetLerpValue(0, maxFrames, revFrames, true);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity).RotatedByRandom(spread), bulletAMMO, Projectile.damage / 2, Projectile.knockBack, Projectile.owner);
if (Main.myPlayer == Projectile.owner)
{
float spread = 0.045f * Utils.GetLerpValue(0, maxFrames, revFrames, true);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity).RotatedByRandom(spread), bulletAMMO, Projectile.damage / 2, Projectile.knockBack, Projectile.owner);
}
for (int i = 0; i <= 3; i++)
{
Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 5, Main.rand.NextBool(5) ? 28 : 215, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f));
dust.noGravity = true;
}
//GenericSparkle sparker = new GenericSparkle(GunTipPosition, Vector2.Zero, Color.DarkGoldenrod, Color.Gold, Main.rand.NextFloat(1.1f, 1.8f), 2, Main.rand.NextFloat(-0.01f, 0.01f), 2.68f);
//GeneralParticleHandler.SpawnParticle(sparker);
OffsetLengthFromArm -= 5f;
secondShot = false;
@@ -72,10 +74,13 @@ namespace CalamityMod.Projectiles.Ranged
}
if (shootingTimer >= 60 && revFrames < maxFrames)
{
Owner.PickAmmo(Owner.ActiveItem(), out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _);
Owner.PickAmmo(Owner.HeldItem, out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _);
Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 19;
float spread = 0.045f * Utils.GetLerpValue(0, maxFrames, revFrames, true);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity).RotatedByRandom(spread).RotatedByRandom(0.04f), bulletAMMO, Projectile.damage / 2, Projectile.knockBack, Projectile.owner);
if (Main.myPlayer == Projectile.owner)
{
float spread = 0.045f * Utils.GetLerpValue(0, maxFrames, revFrames, true);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity).RotatedByRandom(spread).RotatedByRandom(0.04f), bulletAMMO, Projectile.damage / 2, Projectile.knockBack, Projectile.owner);
}
shootingTimer = 0;
secondShot = true;
}
@@ -105,20 +110,20 @@ namespace CalamityMod.Projectiles.Ranged
Particle pulse = new CustomPulse(GunTipPosition, Projectile.velocity * 9f, Color.Chartreuse * 0.7f, "CalamityMod/Particles/FlameExplosion", new Vector2(0.4f, 1f), Projectile.velocity.ToRotation(), 0.25f, 0, 34);
GeneralParticleHandler.SpawnParticle(pulse);
float velBonus = 1.1f;
for (int i = 0; i <= 5; i++)
if (Main.myPlayer == Projectile.owner)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(-0.03f * i * velBonus) * (1 - i * 0.08f) * velBonus, ModContent.ProjectileType<EmesisGore>(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, -i, 0, velBonus);
float velBonus = 1.1f;
for (int i = 0; i <= 5; i++)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(-0.03f * i * velBonus) * (1 - i * 0.08f) * velBonus, ModContent.ProjectileType<EmesisGore>(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, -i, 0, velBonus);
for (int j = 0; j <= 5; j++)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(0.03f * j * velBonus) * (1 - j * 0.08f) * velBonus, ModContent.ProjectileType<EmesisGore>(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, j, 0, velBonus);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * velBonus, ModContent.ProjectileType<EmesisGore>(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, 20, 0, velBonus);
}
for (int j = 0; j <= 5; j++)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(0.03f * j * velBonus) * (1 - j * 0.08f) * velBonus, ModContent.ProjectileType<EmesisGore>(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, j, 0, velBonus);
}
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * velBonus, ModContent.ProjectileType<EmesisGore>(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, 20, 0, velBonus);
for (int i = 0; i <= 18; i++)
{
Dust dust = Dust.NewDustPerfect(GunTipPosition, 66, shootVelocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f));
Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.RainbowTorch, shootVelocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f));
dust.noGravity = true;
dust.color = Color.Chartreuse;
}
+4 -4
View File
@@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Ranged
public static readonly SoundStyle OverheatSound = new("CalamityMod/Sounds/Item/HeliumFlashSteamRelease");
public SlotId WarningSlot;
public ref float Timer => ref Projectile.ai[0];
private int BuiltHeat => (Owner.ActiveItem().ModItem as FirestormCannon).BuiltUpHeat;
private int BuiltHeat => (Owner.HeldItem.ModItem as FirestormCannon).BuiltUpHeat;
private bool displayOverheat = false;
private const int WarningTime = FirestormCannon.OverheatLevel - 100;
@@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Ranged
// Not holding the item
// Right-clicking (Can kill it early) (Does not work if in overheat state)
// Completely cooling while not firing
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type ||
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type ||
(Owner.Calamity().mouseRight && !displayOverheat) || (BuiltHeat == 0 && !Main.mouseLeft))
{
if (SoundEngine.TryGetActiveSound(WarningSlot, out var warn))
@@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged
// Once holding the fire button down long enough, start actually firing
if (Timer >= 30)
{
// For some reason using ActiveItem() here breaks its functionality while being held on the cursor
// For some reason using HeldItem here breaks its functionality while being held on the cursor
(Owner.HeldItem.ModItem as FirestormCannon).BuiltUpHeat++;
// Overheat yourself if you fire too long
@@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Ranged
if (Main.myPlayer == Projectile.owner)
{
Owner.PickAmmo(HeldItem, out int flareType, out _, out _, out _, out _, Main.rand.Next(100) >= 70);
Vector2 velocity = Projectile.velocity.RotatedByRandom(MathHelper.Pi * 0.04f * (1f + firingLerp * 0.5f)) * Owner.ActiveItem().shootSpeed;
Vector2 velocity = Projectile.velocity.RotatedByRandom(MathHelper.Pi * 0.04f * (1f + firingLerp * 0.5f)) * Owner.HeldItem.shootSpeed;
Projectile flare = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, velocity, flareType, Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f, 1f);
flare.penetrate = 3;
flare.MaxUpdates = 2;
+1 -1
View File
@@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Ranged
// Every time we shoot we use ammo.
// With this method we also use the item's stats, like the shoot speed, or the type of ammo it was used.
Owner.PickAmmo(Owner.ActiveItem(), out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot);
Owner.PickAmmo(Owner.HeldItem, out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot);
// Decides the color of the effects depending on the type of rocket used.
switch (rocketTypeShot)
+1 -1
View File
@@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Ranged
// Every time we shoot we use ammo.
// With this method we also use the item's stats, like the shoot speed, or the type of ammo it was used.
Owner.PickAmmo(Owner.ActiveItem(), out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot);
Owner.PickAmmo(Owner.HeldItem, out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot);
// Decides the color of the effects depending on the type of rocket used.
switch (rocketTypeShot)
@@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged
Projectile.ai[1] = (float)(initialRate - fireRateMult * fireRate);
shouldShoot = true;
}
bool canShoot = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem());
bool canShoot = !player.CantUseHoldout() && player.HasAmmo(player.HeldItem);
if (Projectile.localAI[0] > 0f)
{
Projectile.localAI[0] -= 1f;
@@ -95,13 +95,13 @@ namespace CalamityMod.Projectiles.Ranged
{
int projType = ProjectileID.SnowBallFriendly;
float speedMult2 = 14f;
int dmg = player.GetWeaponDamage(player.ActiveItem());
float kBack = player.ActiveItem().knockBack;
int dmg = player.GetWeaponDamage(player.HeldItem);
float kBack = player.HeldItem.knockBack;
if (canShoot)
{
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;
player.PickAmmo(player.HeldItem, out projType, out speedMult2, out dmg, out kBack, out _);
kBack = player.GetWeaponKnockback(player.HeldItem, kBack);
float shootSpeed = player.HeldItem.shootSpeed * Projectile.scale;
Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true);
Vector2 direction = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - source;
if (player.gravDir == -1f)
+1 -1
View File
@@ -138,7 +138,7 @@ namespace CalamityMod.Projectiles.Ranged
// Projectile shooting.
if (shootThisFrame && Main.myPlayer == Projectile.owner)
{
Item freedomStar = player.ActiveItem();
Item freedomStar = player.HeldItem;
// This grabs the weapon's current damage, taking current charge level into account.
int currentDamage = player.GetWeaponDamage(freedomStar);
+7 -7
View File
@@ -15,13 +15,13 @@ namespace CalamityMod.Projectiles.Ranged
public class HeavenlyGaleProj : BaseIdleHoldoutProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public bool OwnerCanShoot => Owner.HasAmmo(Owner.ActiveItem()) && !Owner.noItems && !Owner.CCed;
public bool OwnerCanShoot => Owner.HasAmmo(Owner.HeldItem) && !Owner.noItems && !Owner.CCed;
public float StringReelbackInterpolant
{
get
{
int duration = Owner.ActiveItem().useAnimation;
int duration = Owner.HeldItem.useAnimation;
float time = duration - ShootDelay;
float firstHalf = Utils.GetLerpValue(8f, 0f, time, true);
float secondHalf = Utils.GetLerpValue(8f, duration * 0.6f, time, true);
@@ -65,12 +65,12 @@ namespace CalamityMod.Projectiles.Ranged
if (Main.myPlayer == Projectile.owner && OwnerCanShoot && activatingShoot)
{
SoundEngine.PlaySound(HeavenlyGale.FireSound, Projectile.Center);
ShootDelay = Owner.ActiveItem().useAnimation;
ShootDelay = Owner.HeldItem.useAnimation;
Projectile.netUpdate = true;
}
// Update damage based on current ranged damage stat, since this projectile exists regardless of if it's being fired.
Projectile.damage = Owner.ActiveItem() is null ? 0 : Owner.GetWeaponDamage(Owner.ActiveItem());
Projectile.damage = Owner.HeldItem is null ? 0 : Owner.GetWeaponDamage(Owner.HeldItem);
UpdateProjectileHeldVariables(armPosition);
ManipulatePlayerVariables();
@@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Ranged
// Fire arrows.
if (ShootDelay > 0f && Projectile.FinalExtraUpdate())
{
float shootCompletionRatio = 1f - ShootDelay / (Owner.ActiveItem().useAnimation - 1f);
float shootCompletionRatio = 1f - ShootDelay / (Owner.HeldItem.useAnimation - 1f);
float bowAngularOffset = (float)Math.Sin(MathHelper.TwoPi * shootCompletionRatio) * 0.4f;
float damageFactor = Utils.Remap(ChargeTimer, 0f, HeavenlyGale.MaxChargeTime, 1f, HeavenlyGale.MaxChargeDamageBoost);
@@ -96,9 +96,9 @@ namespace CalamityMod.Projectiles.Ranged
// Update the tip position for one frame.
tipPosition = armPosition + arrowDirection * Projectile.width * 0.45f;
if (Main.myPlayer == Projectile.owner && Owner.HasAmmo(Owner.ActiveItem()))
if (Main.myPlayer == Projectile.owner && Owner.HasAmmo(Owner.HeldItem))
{
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
Owner.PickAmmo(heldItem, out int projectileType, out float shootSpeed, out int damage, out float knockback, out _);
damage = (int)(damage * damageFactor);
projectileType = ModContent.ProjectileType<ExoCrystalArrow>();
+2 -2
View File
@@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void AI()
{
if (Owner.dead || !Owner.active || Owner.ActiveItem().type != ModContent.ItemType<Hydra>())
if (Owner.dead || !Owner.active || Owner.HeldItem.type != ModContent.ItemType<Hydra>())
Projectile.Kill();
else
Projectile.timeLeft = 2; //Infinite lifespan
@@ -137,7 +137,7 @@ namespace CalamityMod.Projectiles.Ranged
public void PerformAttacks(Vector2 aimDestination)
{
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
Vector2 shootDirection = Projectile.SafeDirectionTo(aimDestination);
+1 -1
View File
@@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Ranged
Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15;
int bulletAMMO = ProjectileID.Bullet;
Owner.PickAmmo(Owner.ActiveItem(), out bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out int _);
Owner.PickAmmo(Owner.HeldItem, out bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out int _);
// Fire Auric Bullets if the owner stops channeling or otherwise cannot use the weapon.
if (Owner.CantUseHoldout() || discharging)
+2 -2
View File
@@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void KillHoldoutLogic()
{
// Only allow the projectile to kill if we're not reloading
if (CurrentState == 0 && HeldItem.type != Owner.ActiveItem().type)
if (CurrentState == 0 && HeldItem.type != Owner.HeldItem.type)
{
Projectile.Kill();
Projectile.netUpdate = true;
@@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Ranged
if (Projectile.frame == 5)
{
Projectile.frameCounter++;
if (Projectile.frameCounter >= MathHelper.Clamp(Owner.ActiveItem().useAnimation - 18, 0f, Owner.ActiveItem().useAnimation))
if (Projectile.frameCounter >= MathHelper.Clamp(Owner.HeldItem.useAnimation - 18, 0f, Owner.HeldItem.useAnimation))
{
if (Owner.CantUseHoldout())
{
+3 -3
View File
@@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Ranged
Vector2 shootPosition = armPosition + Projectile.velocity * Projectile.width * 0.5f;
// Destroy the holdout projectile if the owner is no longer eligible to hold it.
if (Owner.CantUseHoldout() || !Owner.HasAmmo(Owner.ActiveItem()))
if (Owner.CantUseHoldout() || !Owner.HasAmmo(Owner.HeldItem))
{
Projectile.Kill();
return;
@@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Ranged
if (FramesToLoadNextArrow == 0f)
{
SoundEngine.PlaySound(SoundID.Item20, Projectile.Center);
FramesToLoadNextArrow = Owner.ActiveItem().useAnimation;
FramesToLoadNextArrow = Owner.HeldItem.useAnimation;
}
// Actually make progress towards loading more arrows.
@@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Ranged
if (Main.myPlayer != Projectile.owner)
return;
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
// Calculate damage at the instant the arrow is fired
int arrowDamage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem);
+1 -1
View File
@@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void KillHoldoutLogic()
{
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)
Projectile.Kill();
}
+1 -1
View File
@@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Ranged
// If the time reaches Item.useTime, it'll shoot the projectile, consume ammo and reset the timer.
if (Time >= Owner.itemTimeMax && Main.myPlayer == Projectile.owner)
{
Owner.PickAmmo(Owner.ActiveItem(), out _, out float speed, out int damage, out float knockback, out int usedItemAmmoId);
Owner.PickAmmo(Owner.HeldItem, out _, out float speed, out int damage, out float knockback, out int usedItemAmmoId);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX) * speed * 1.5f, ModContent.ProjectileType<MineralMortarProjectile>(), damage, knockback, Projectile.owner, usedItemAmmoId);
+1 -1
View File
@@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void AI()
{
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
if (Owner.dead || Owner is null)
Projectile.Kill();
@@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged
}
public override void KillHoldoutLogic()
{
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)
Projectile.Kill();
}
+1 -1
View File
@@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void KillHoldoutLogic()
{
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)
Projectile.Kill();
}
+5 -5
View File
@@ -117,7 +117,7 @@ namespace CalamityMod.Projectiles.Ranged
return;
// Immediately killed if ammo is out
if (!Owner.HasAmmo(Owner.ActiveItem()))
if (!Owner.HasAmmo(Owner.HeldItem))
{
Projectile.Kill();
return;
@@ -150,7 +150,7 @@ namespace CalamityMod.Projectiles.Ranged
Sound3.Pitch = 0 - (PhotoTimer * 0.002f);
// Consume ammo and retrieve projectile stats; has a chance to not consume ammo
Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.Next(100) < AmmoSavedPercent);
Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.Next(100) < AmmoSavedPercent);
var source = Projectile.GetSource_FromThis();
Vector2 position = armPosition + Projectile.velocity * 55f - verticalOffset * 10f;
@@ -193,7 +193,7 @@ namespace CalamityMod.Projectiles.Ranged
Projectile.NewProjectile(source, position, velocity.RotatedByRandom(0.005f), ProjectileType<ExoFire>(), (int)(damage * (1 - PhotoTimer / 59.9f)), knockback, Projectile.owner, Main.rand.NextFloat(0f, 3f));
// Shoots light bombs every once in a while, rate of which equals to the item's use time
if (ShootTimer >= Owner.ActiveItem().useTime * 10 && PhotoTimer == 0)
if (ShootTimer >= Owner.HeldItem.useTime * 10 && PhotoTimer == 0)
{
ShootTimer = 0f;
@@ -212,11 +212,11 @@ namespace CalamityMod.Projectiles.Ranged
public void RightClickAttack(Vector2 armPosition, Vector2 verticalOffset)
{
// Multiplied by the ratio of attack speed gained from modifiers
ShootTimer = (RightClickCooldown * Owner.ActiveItem().useTime / (float)LightBombCooldown) - 1f;
ShootTimer = (RightClickCooldown * Owner.HeldItem.useTime / (float)LightBombCooldown) - 1f;
ForcedLifespan = ShootTimer;
// Consume ammo and retrieve projectile stats
Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _);
Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _);
var source = Projectile.GetSource_FromThis();
Vector2 position = armPosition + Projectile.velocity * 55f - verticalOffset * 10f;
+3 -3
View File
@@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Ranged
// Frame 1 effects: Initialize the shoot speed
if (FramesToLoadNextPumpkin == 0f)
{
FramesToLoadNextPumpkin = Owner.ActiveItem().useAnimation;
FramesToLoadNextPumpkin = Owner.HeldItem.useAnimation;
}
// Actually make progress towards loading more arrows. Also, make smoke come out eventually perhaps
++CurrentChargingFrames;
@@ -149,7 +149,7 @@ namespace CalamityMod.Projectiles.Ranged
}
SoundEngine.PlaySound(SoundID.Item96);//play the sound
SmokeBurst(tipPosition);
FramesToLoadNextPumpkin = Owner.ActiveItem().useAnimation; //reset the reload time
FramesToLoadNextPumpkin = Owner.HeldItem.useAnimation; //reset the reload time
PumpkinsCharge = 0; //Unload the barrel
if (!IsOverfilled)
Overfilled = 1f; //Make the shoot anim play
@@ -161,7 +161,7 @@ namespace CalamityMod.Projectiles.Ranged
if (Main.myPlayer != Projectile.owner)
return;
Item heldItem = Owner.ActiveItem();
Item heldItem = Owner.HeldItem;
int projectileType = ModContent.ProjectileType<PumplerGrenade>();
int PumpkinDamage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem);
float shootSpeed = heldItem.shootSpeed * 1.5f;
Loaded 100 of 130 files, more files were not shown because too many files have changed in this diff. Show more