MP-fixed Anahita's Arpeggio.

This commit is contained in:
Memes committed 2024-11-23 17:39:49 +01:00
1 parent 41ea7cb9d8
commit eefe854500
2 files changed
+18 -9

No files matched your search

+5 -8
View File
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Projectiles.Magic;
using Microsoft.Xna.Framework;
using System.Linq;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
@@ -15,7 +15,6 @@ namespace CalamityMod.Items.Weapons.Magic
{
public new string LocalizationCategory => "Items.Weapons.Magic";
public float RotationOffset;
public static int MusicNoteAmt = 0;
public static readonly SoundStyle CapSound = new("CalamityMod/Sounds/Item/HarpLV6");
public static readonly SoundStyle EndSound = new("CalamityMod/Sounds/Item/HarpEnd");
@@ -48,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Magic
{
// Max music note check is in Shoot instead of CanUseItem so that the weapon can still be visually played while at the cap
int musicNoteCap = Main.zenithWorld ? 7 : 6;
if (MusicNoteAmt >= musicNoteCap)
if (player.ownedProjectileCounts[type] >= musicNoteCap)
{
Main.musicPitch = -0.5f;
SoundEngine.PlaySound(CapSound with { Volume = 0.8f }, player.Center);
@@ -56,12 +55,10 @@ namespace CalamityMod.Items.Weapons.Magic
}
else
{
if (MusicNoteAmt <= 0)
if (player.ownedProjectileCounts[type] <= 0)
RotationOffset = Main.rand.NextFloat(0f, MathHelper.TwoPi);
int note = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 0f, RotationOffset);
Main.projectile[note].localAI[1] = MusicNoteAmt;
MusicNoteAmt++;
Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 0f, RotationOffset);
return false;
}
}
@@ -77,7 +74,7 @@ namespace CalamityMod.Items.Weapons.Magic
// Consume much less mana while the maximum number of notes are present
public override void ModifyManaCost(Player player, ref float reduce, ref float mult)
{
if (MusicNoteAmt >= 6)
if (player.ownedProjectileCounts[Item.shoot] >= 6)
mult *= 0.25f;
}
+13 -1
View File
@@ -2,6 +2,7 @@
using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using System;
using System.IO;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
@@ -19,6 +20,7 @@ namespace CalamityMod.Projectiles.Magic
public int LingeringTime = 300;
public int FadeOutTime = 20;
public bool HasSetFadeOutVelocity = false;
private bool _hasSpawned;
public Player Owner => Main.player[Projectile.owner];
@@ -43,6 +45,12 @@ namespace CalamityMod.Projectiles.Magic
public override void AI()
{
if (!_hasSpawned)
{
NoteSequence = Owner.ownedProjectileCounts[Type] - 1;
_hasSpawned = true;
}
Timer++;
// Slight size oscillation
@@ -67,6 +75,7 @@ namespace CalamityMod.Projectiles.Magic
else
Lighting.AddLight(Projectile.Center, 0f, 0f, 1.25f);
Main.NewText(NoteSequence);
if (AIState == 0f) // Orbiting the player
{
@@ -81,7 +90,6 @@ namespace CalamityMod.Projectiles.Magic
// If the player stops using the weapon, switch to fade away mode
if (Owner.releaseUseItem)
{
AnahitasArpeggio.MusicNoteAmt = 0;
Owner.Calamity().arpeggioCooldown = 40;
AIState = 1f;
}
@@ -197,5 +205,9 @@ namespace CalamityMod.Projectiles.Magic
if (!SoundEngine.TryGetActiveSound(SingularSoundInstanceSystem.SoundSlot, out var activeSound))
SingularSoundInstanceSystem.PlaySingleInstance(AnahitasArpeggio.HitSound, 60, 60, Owner);
}
public override void SendExtraAI(BinaryWriter writer) => writer.Write(Projectile.localAI[1]);
public override void ReceiveExtraAI(BinaryReader reader) => Projectile.localAI[1] = reader.ReadSingle();
}
}