Fixed Grand Dad in MP.
This commit is contained in:
1 parent
08954d6022
commit
fcaf0620cc
1 file changed
+129
-87
@@ -1,18 +1,17 @@
|
||||
using System;
|
||||
using CalamityMod.CalPlayer;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.NPCs.PrimordialWyrm;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -39,6 +38,12 @@ namespace CalamityMod.Projectiles.Melee
|
||||
public int swingCount;
|
||||
public bool finalFlip = false;
|
||||
public bool swingSound = true;
|
||||
|
||||
private NPC target => Main.npc[(int)Projectile.ai[0]];
|
||||
private bool hasSpawned;
|
||||
private bool hasHit;
|
||||
private int damageDone;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
base.SetDefaults();
|
||||
@@ -46,26 +51,110 @@ namespace CalamityMod.Projectiles.Melee
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.DamageType = TrueMeleeDamageClass.Instance;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
Projectile.knockBack = 0;
|
||||
Projectile.scale = 1;
|
||||
Projectile.ai[1] = -1;
|
||||
base.OnSpawn(source);
|
||||
|
||||
// 14NOV2024: Ozzatron: clamped mouse position unnecessary, as Grand Dad has no projectiles
|
||||
mousePos = Owner.Calamity().mouseWorld;
|
||||
aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65;
|
||||
useAnim = Owner.itemAnimationMax;
|
||||
|
||||
if (mousePos.X < Owner.Center.X) Owner.direction = -1;
|
||||
else Owner.direction = 1;
|
||||
|
||||
FlipAsSword = Owner.direction == -1 ? true : false;
|
||||
}
|
||||
|
||||
public override void UseStyle()
|
||||
{
|
||||
/*
|
||||
* OnSpawn() method implemented inside AI().
|
||||
* This is done for MP syncing.
|
||||
*/
|
||||
if (!hasSpawned)
|
||||
{
|
||||
Projectile.timeLeft = Owner.HeldItem.useAnimation + 1;
|
||||
Projectile.knockBack = 0;
|
||||
Projectile.scale = 1;
|
||||
Projectile.ai[1] = -1;
|
||||
|
||||
// 14NOV2024: Ozzatron: clamped mouse position unnecessary, as Grand Dad has no projectiles
|
||||
mousePos = Owner.Calamity().mouseWorld;
|
||||
aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65;
|
||||
useAnim = Owner.itemAnimationMax;
|
||||
|
||||
if (mousePos.X < Owner.Center.X) Owner.direction = -1;
|
||||
else Owner.direction = 1;
|
||||
|
||||
FlipAsSword = Owner.direction == -1;
|
||||
hasSpawned = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* OnHitNPC() method implemented inside AI().
|
||||
* This is done for MP syncing.
|
||||
*/
|
||||
if (hasHit)
|
||||
{
|
||||
if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0)
|
||||
Projectile.numHits -= 1;
|
||||
|
||||
SoundStyle fire = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1");
|
||||
SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = -0.1f }, Projectile.Center);
|
||||
SoundStyle fire2 = new("CalamityMod/Sounds/Item/FinalDawnSlash");
|
||||
SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center);
|
||||
if (Main.zenithWorld && Projectile.numHits == 0 && target.type != ModContent.NPCType<PrimordialWyrmHead>() && Main.rand.NextBool(5))
|
||||
{
|
||||
SoundStyle fire3 = new("CalamityMod/Sounds/Item/GFBScreams/Scream", 8);
|
||||
SoundEngine.PlaySound(fire3 with { Volume = 0.8f }, Projectile.Center);
|
||||
}
|
||||
if (Projectile.numHits == 0)
|
||||
{
|
||||
Owner.Calamity().GeneralScreenShakePower = 6.5f;
|
||||
}
|
||||
|
||||
int heal = (int)MathHelper.Clamp(20 - Projectile.numHits * 12, 1, 20);
|
||||
if (Projectile.numHits < 10)
|
||||
{
|
||||
Owner.HealPlayer(heal);
|
||||
}
|
||||
|
||||
if (target.CanBeMoved(true) || Main.zenithWorld || target.type == ModContent.NPCType<PrimordialWyrmHead>() || (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs))
|
||||
{
|
||||
if (target.type == ModContent.NPCType<PrimordialWyrmHead>())
|
||||
{
|
||||
CombatText.NewText(target.Hitbox, Color.Aqua, CalamityUtils.GetTextValue("Misc.HecBoop"));
|
||||
SoundStyle boop = new("CalamityMod/Sounds/Item/SnootBooped");
|
||||
SoundEngine.PlaySound(boop with { Pitch = Main.rand.NextFloat(-0.15f, 0.15f) }, Projectile.Center);
|
||||
}
|
||||
|
||||
bool rightClicked = Owner.Calamity().mouseRight;
|
||||
|
||||
// Make all hit enemies able to hit tiles, so you can dunk them
|
||||
target.noTileCollide = false;
|
||||
|
||||
// Launch the suckers
|
||||
Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld);
|
||||
float launchPower = (Main.zenithWorld ? 50 : 30) * (rightClicked ? 2 : 1);
|
||||
target.MoveNPC(launchVel, launchPower * 0.5f, true);
|
||||
|
||||
// Remove knockback resist, just like it used to
|
||||
target.knockBackResist = 1;
|
||||
|
||||
// Apply tile collison damage (is bonus on GFB and even further is both final bosses are gone)
|
||||
target.FlungNPC().ApplyCollisionDamage(target, Owner, Projectile.damage * (Main.zenithWorld ? (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs ? 1000 : 77) : 3) * (rightClicked ? 3 : 1), launchVel * launchPower, 5f, true);
|
||||
}
|
||||
|
||||
if (Projectile.numHits < 3)
|
||||
{
|
||||
Particle spark = new VoidSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * (-45 + Projectile.numHits * 5), false, (int)(16 - Projectile.numHits * 3), 0.6f - Projectile.numHits * 0.15f, Color.DodgerBlue, 0.45f);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++)
|
||||
{
|
||||
Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 55, Main.rand.NextFloat(0.4f, 1.5f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue);
|
||||
GeneralParticleHandler.SpawnParticle(spark2);
|
||||
Dust dust = Dust.NewDustPerfect(target.Center, ModContent.DustType<VoidDust>(), ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(1.55f, 2.2f));
|
||||
dust.noGravity = true;
|
||||
dust.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Blue;
|
||||
}
|
||||
|
||||
hasHit = false;
|
||||
}
|
||||
|
||||
AnimationProgress = Animation % useAnim;
|
||||
DrawUnconditionally = false;
|
||||
|
||||
@@ -93,7 +182,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
CanHit = false;
|
||||
if (mousePos.X < Owner.Center.X) Owner.direction = -1;
|
||||
else Owner.direction = 1;
|
||||
FlipAsSword = Owner.direction == -1 ? true : false;
|
||||
FlipAsSword = Owner.direction == -1;
|
||||
|
||||
doSwing = true;
|
||||
swingCount++;
|
||||
@@ -112,8 +201,8 @@ namespace CalamityMod.Projectiles.Melee
|
||||
if ((Owner.Center - aimVel).X < Owner.Center.X) Owner.direction = -1;
|
||||
else Owner.direction = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Projectile.rotation = Projectile.rotation.AngleLerp(Owner.AngleTo(mousePos) + MathHelper.ToRadians(45f), 0.1f);
|
||||
|
||||
if (AnimationProgress < (useAnim / 1.5f))
|
||||
@@ -132,7 +221,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
if (!finalFlip)
|
||||
{
|
||||
FlipAsSword = Owner.direction < 0 ? true : false;
|
||||
FlipAsSword = Owner.direction < 0;
|
||||
}
|
||||
|
||||
float time = (AnimationProgress) - (useAnim / 3);
|
||||
@@ -144,7 +233,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
SoundEngine.PlaySound(fire with { Volume = 0.8f, Pitch = Main.rand.NextFloat(0.2f, 0.32f) }, Projectile.Center);
|
||||
swingSound = false;
|
||||
}
|
||||
if ( time > (int)(timeMax * 0.4f) && time < (int)(timeMax * 0.7f))
|
||||
if (time > (int)(timeMax * 0.4f) && time < (int)(timeMax * 0.7f))
|
||||
{
|
||||
CanHit = true;
|
||||
|
||||
@@ -195,79 +284,22 @@ namespace CalamityMod.Projectiles.Melee
|
||||
dust2.noGravity = true;
|
||||
dust2.color = Main.rand.NextBool(3) ? Color.Goldenrod : Color.Gold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArmRotationOffset = MathHelper.ToRadians(-140f);
|
||||
ArmRotationOffsetBack = MathHelper.ToRadians(-140f);
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0)
|
||||
Projectile.numHits -= 1;
|
||||
|
||||
SoundStyle fire = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1");
|
||||
SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = -0.1f }, Projectile.Center);
|
||||
SoundStyle fire2 = new("CalamityMod/Sounds/Item/FinalDawnSlash");
|
||||
SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center);
|
||||
if (Main.zenithWorld && Projectile.numHits == 0 && target.type != ModContent.NPCType<PrimordialWyrmHead>() && Main.rand.NextBool(5))
|
||||
{
|
||||
SoundStyle fire3 = new("CalamityMod/Sounds/Item/GFBScreams/Scream", 8);
|
||||
SoundEngine.PlaySound(fire3 with { Volume = 0.8f }, Projectile.Center);
|
||||
}
|
||||
if (Projectile.numHits == 0)
|
||||
{
|
||||
Owner.Calamity().GeneralScreenShakePower = 6.5f;
|
||||
}
|
||||
|
||||
int heal = (int)(MathHelper.Clamp(20 - Projectile.numHits * 12, 1, 20));
|
||||
if (Projectile.numHits < 10)
|
||||
{
|
||||
Owner.HealPlayer(heal);
|
||||
}
|
||||
|
||||
if (target.CanBeMoved(true) || Main.zenithWorld || target.type == ModContent.NPCType<PrimordialWyrmHead>() || (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs))
|
||||
{
|
||||
if (target.type == ModContent.NPCType<PrimordialWyrmHead>())
|
||||
{
|
||||
CombatText.NewText(target.Hitbox, Color.Aqua, CalamityUtils.GetTextValue("Misc.HecBoop"));
|
||||
SoundStyle boop = new("CalamityMod/Sounds/Item/SnootBooped");
|
||||
SoundEngine.PlaySound(boop with {Pitch = Main.rand.NextFloat(-0.15f, 0.15f) }, Projectile.Center);
|
||||
}
|
||||
|
||||
bool rightClicked = Owner.Calamity().mouseRight;
|
||||
|
||||
// Make all hit enemies able to hit tiles, so you can dunk them
|
||||
target.noTileCollide = false;
|
||||
|
||||
// Launch the suckers
|
||||
Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld);
|
||||
float launchPower = (Main.zenithWorld ? 50 : 30) * (rightClicked ? 2 : 1);
|
||||
target.MoveNPC(launchVel, launchPower * 0.5f, true);
|
||||
|
||||
// Remove knockback resist, just like it used to
|
||||
target.knockBackResist = 1;
|
||||
|
||||
// Apply tile collison damage (is bonus on GFB and even further is both final bosses are gone)
|
||||
target.FlungNPC().ApplyCollisionDamage(target, Owner, Projectile.damage * (Main.zenithWorld ? (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs ? 1000 : 77) : 3) * (rightClicked ? 3 : 1), launchVel * launchPower, 5f, true);
|
||||
}
|
||||
|
||||
if (Projectile.numHits < 3)
|
||||
{
|
||||
Particle spark = new VoidSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * (-45 + Projectile.numHits * 5), false, (int)(16 - Projectile.numHits * 3), 0.6f - Projectile.numHits * 0.15f, Color.DodgerBlue, 0.45f);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++)
|
||||
{
|
||||
Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 55, Main.rand.NextFloat(0.4f, 1.5f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue);
|
||||
GeneralParticleHandler.SpawnParticle(spark2);
|
||||
Dust dust = Dust.NewDustPerfect(target.Center, ModContent.DustType<VoidDust>(), ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(1.55f, 2.2f));
|
||||
dust.noGravity = true;
|
||||
dust.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Blue;
|
||||
}
|
||||
Projectile.ai[0] = target.whoAmI;
|
||||
this.damageDone = damageDone;
|
||||
hasHit = true;
|
||||
Projectile.ForceNetUpdate();
|
||||
}
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
if (Owner.Calamity().mouseRight)
|
||||
@@ -280,6 +312,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
modifiers.SourceDamage *= damageMult;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
// Only draw the projectile if the projectile's owner is currently using the item this projectile is attached to.
|
||||
@@ -308,8 +341,17 @@ namespace CalamityMod.Projectiles.Melee
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override void ResetStyle()
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(hasHit);
|
||||
writer.Write(damageDone);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
hasHit = reader.ReadBoolean();
|
||||
damageDone = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user