Flak Kraken Rework, awaiting Xyk.
This commit is contained in:
1 parent
c28441d8b4
commit
07c6d07be9
8 files changed
+584
-302
No files matched your search
+3
-3
@@ -850,7 +850,7 @@ namespace CalamityMod
|
||||
ProjectileType<ContagionBow>(),
|
||||
ProjectileType<DaemonsFlameBow>(),
|
||||
ProjectileType<DrataliornusBow>(),
|
||||
ProjectileType<FlakKrakenGun>(),
|
||||
ProjectileType<FlakKrakenHoldout>(),
|
||||
ProjectileType<ButcherGun>(),
|
||||
ProjectileType<StarfleetMK2Gun>(),
|
||||
ProjectileType<NorfleetCannon>(),
|
||||
@@ -875,7 +875,7 @@ namespace CalamityMod
|
||||
ProjectileType<RancorLaserbeam>(),
|
||||
ProjectileType<NebulousCataclysm_Held>(),
|
||||
|
||||
ProjectileType<FlakKrakenProj>(),
|
||||
ProjectileType<FlakKrakenProjectile>(),
|
||||
ProjectileType<InfernadoFriendly>(),
|
||||
ProjectileType<DragonRageStaff>(),
|
||||
ProjectileType<MurasamaSlash>(),
|
||||
@@ -2111,7 +2111,7 @@ namespace CalamityMod
|
||||
ProjectileType<EyeOfNightCell>(),
|
||||
ProjectileType<FantasyTalismanProj>(),
|
||||
ProjectileType<FantasyTalismanStealth>(),
|
||||
ProjectileType<FlakKrakenProj>(),
|
||||
ProjectileType<FlakKrakenProjectile>(),
|
||||
ProjectileType<GodsParanoiaProj>(),
|
||||
ProjectileType<InsidiousHarpoon>(),
|
||||
ProjectileType<JawsProjectile>(),
|
||||
|
||||
@@ -1,39 +1,76 @@
|
||||
using Terraria.DataStructures;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Items.Placeables;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Sounds;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
public class FlakKraken : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Weapons.Ranged";
|
||||
|
||||
#region Other Stats
|
||||
public static float TimeBetweenShots = 20f;
|
||||
public static float ProjectilesPerBurst = 2f;
|
||||
|
||||
public static float OwnerKnockbackStrength = 5f;
|
||||
|
||||
public static float ProjectileGravityStrength = 0.15f;
|
||||
public static float ProjectileShootSpeed = 20f;
|
||||
|
||||
public static float InitialShotDamageMultiplier = 0.5f;
|
||||
public static float InitialShotHitShrapnelDamageMultiplier = 0.75f;
|
||||
|
||||
public static int ShrapnelAmount = 12;
|
||||
public static float ShrapnelAngleOffset = MathHelper.PiOver4;
|
||||
|
||||
public static int ClusterShrapnelAmount = 20;
|
||||
public static float ClusterShrapnelAngleOffset = MathHelper.PiOver2 + MathHelper.ToRadians(10f);
|
||||
#endregion
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.damage = 88; // Here you're modifying the shrapnel's damage.
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.useTime = Item.useAnimation = 180;
|
||||
Item.shoot = ModContent.ProjectileType<FlakKrakenHoldout>();
|
||||
Item.shootSpeed = 15f;
|
||||
|
||||
Item.width = 152;
|
||||
Item.height = 58;
|
||||
Item.damage = 88;
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.useTime = 10;
|
||||
Item.useAnimation = 10;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.channel = true;
|
||||
Item.knockBack = 0f;
|
||||
Item.useAmmo = AmmoID.Rocket;
|
||||
Item.value = CalamityGlobalItem.Rarity7BuyPrice;
|
||||
Item.rare = ItemRarityID.Lime;
|
||||
Item.UseSound = CommonCalamitySounds.LaserCannonSound;
|
||||
Item.shoot = ModContent.ProjectileType<FlakKrakenGun>();
|
||||
Item.shootSpeed = 30f; //30
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.9f, PitchVariance = 0.1f };
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
|
||||
// Obviously we don't want multiple holdouts existing at the same time.
|
||||
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0;
|
||||
|
||||
// Spawning the holdout won't consume ammo.
|
||||
public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] != 0;
|
||||
|
||||
// Makes the rotation of the mouse around the player sync in multiplayer.
|
||||
public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true;
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType<FlakKrakenHoldout>(), 0, 0f, player.whoAmI);
|
||||
|
||||
// We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out.
|
||||
holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class MediumMistParticleAlphaBlend : Particle
|
||||
{
|
||||
public override string Texture => "CalamityMod/Particles/MediumSmoke";
|
||||
public override int FrameVariants => 3;
|
||||
|
||||
private float Opacity;
|
||||
private Color ColorFire;
|
||||
private Color ColorFade;
|
||||
private float Spin;
|
||||
|
||||
public MediumMistParticleAlphaBlend(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f)
|
||||
{
|
||||
Position = position;
|
||||
Velocity = velocity;
|
||||
ColorFire = colorFire;
|
||||
ColorFade = colorFade;
|
||||
Scale = scale;
|
||||
Opacity = opacity;
|
||||
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
|
||||
Spin = rotationSpeed;
|
||||
Variant = Main.rand.Next(3);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
|
||||
Velocity *= 0.85f;
|
||||
|
||||
if (Opacity > 90)
|
||||
{
|
||||
Lighting.AddLight(Position, Color.ToVector3() * 0.1f);
|
||||
Scale += 0.01f;
|
||||
Opacity -= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
Scale *= 0.975f;
|
||||
Opacity -= 2;
|
||||
}
|
||||
|
||||
if (Opacity < 0)
|
||||
Kill();
|
||||
|
||||
Color = Color.Lerp(ColorFire, ColorFade, MathHelper.Clamp((float)((255 - Opacity) - 100) / 80, 0f, 1f)) * (Opacity / 255f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
using System;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class FlakKrakenGun : ModProjectile
|
||||
{
|
||||
public override LocalizedText DisplayName => CalamityUtils.GetItemName<FlakKraken>();
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Ranged/FlakKraken";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 152;
|
||||
Projectile.height = 58;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.ignoreWater = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[Projectile.owner];
|
||||
float pi = 0f;
|
||||
Vector2 playerRotation = player.RotatedRelativePoint(player.MountedCenter, true);
|
||||
if (Projectile.spriteDirection == -1)
|
||||
{
|
||||
pi = 3.14159274f;
|
||||
}
|
||||
float hitRate = 30f;
|
||||
if (Projectile.ai[0] > 90f)
|
||||
{
|
||||
hitRate = 15f;
|
||||
}
|
||||
if (Projectile.ai[0] > 120f)
|
||||
{
|
||||
hitRate = 5f;
|
||||
}
|
||||
Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem());
|
||||
Projectile.ai[0] += 1f;
|
||||
Projectile.ai[1] += 1f;
|
||||
bool isUsing = false;
|
||||
if (Projectile.ai[0] % hitRate == 0f)
|
||||
{
|
||||
isUsing = true;
|
||||
}
|
||||
if (Projectile.ai[1] >= 1f)
|
||||
{
|
||||
Projectile.ai[1] = 0f;
|
||||
isUsing = true;
|
||||
if (Main.myPlayer == Projectile.owner)
|
||||
{
|
||||
float scaleFactor5 = player.ActiveItem().shootSpeed * Projectile.scale;
|
||||
Vector2 shootDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotation;
|
||||
if (player.gravDir == -1f)
|
||||
{
|
||||
shootDirection.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - playerRotation.Y;
|
||||
}
|
||||
Vector2 normalizeShoot = Vector2.Normalize(shootDirection);
|
||||
if (float.IsNaN(normalizeShoot.X) || float.IsNaN(normalizeShoot.Y))
|
||||
{
|
||||
normalizeShoot = -Vector2.UnitY;
|
||||
}
|
||||
normalizeShoot = Vector2.Normalize(Vector2.Lerp(normalizeShoot, Vector2.Normalize(Projectile.velocity), 0.92f)); //0.92
|
||||
normalizeShoot *= scaleFactor5;
|
||||
if (normalizeShoot.X != Projectile.velocity.X || normalizeShoot.Y != Projectile.velocity.Y)
|
||||
{
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
Projectile.velocity = normalizeShoot;
|
||||
}
|
||||
}
|
||||
if (Projectile.soundDelay <= 0)
|
||||
{
|
||||
Projectile.soundDelay = 10;
|
||||
Projectile.soundDelay *= 2;
|
||||
if (Projectile.ai[0] != 1f && Projectile.ai[0] <= 500f)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item15, Projectile.position);
|
||||
}
|
||||
}
|
||||
if (isUsing && Main.myPlayer == Projectile.owner)
|
||||
{
|
||||
bool canUseItem = player.channel && !player.noItems && !player.CCed;
|
||||
if (canUseItem)
|
||||
{
|
||||
if (Projectile.ai[0] == 1f)
|
||||
{
|
||||
Vector2 projPos = player.RotatedRelativePoint(player.MountedCenter, true);
|
||||
float projX = (float)Main.mouseX + Main.screenPosition.X - projPos.X;
|
||||
float projY = (float)Main.mouseY + Main.screenPosition.Y - projPos.Y;
|
||||
if (player.gravDir == -1f)
|
||||
{
|
||||
projY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projPos.Y;
|
||||
}
|
||||
if ((float.IsNaN(projX) && float.IsNaN(projY)) || (projX == 0f && projY == 0f))
|
||||
{
|
||||
projX = (float)player.direction;
|
||||
projY = 0f;
|
||||
}
|
||||
projPos += new Vector2(projX, projY);
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, 0f, 0f, ModContent.ProjectileType<FlakKrakenProj>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, (float)Projectile.whoAmI);
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.Kill();
|
||||
}
|
||||
}
|
||||
Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f;
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + pi;
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
Projectile.timeLeft = 2;
|
||||
player.ChangeDir(Projectile.direction);
|
||||
player.heldProj = Projectile.whoAmI;
|
||||
player.itemTime = 2;
|
||||
player.itemAnimation = 2;
|
||||
player.itemRotation = (float)Math.Atan2((double)(Projectile.velocity.Y * (float)Projectile.direction), (double)(Projectile.velocity.X * (float)Projectile.direction));
|
||||
}
|
||||
|
||||
public override bool? CanDamage() => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
using System;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
using static CalamityMod.Items.Weapons.Ranged.FlakKraken;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class FlakKrakenHoldout : ModProjectile
|
||||
{
|
||||
public override LocalizedText DisplayName => CalamityUtils.GetItemName<FlakKraken>();
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Ranged/FlakKraken";
|
||||
|
||||
public Player Owner { get; set; }
|
||||
public ref float ShootingTimer => ref Projectile.ai[0];
|
||||
public ref float TimerBetweenBursts => ref Projectile.ai[1];
|
||||
public ref float OffsetLengthScalar => ref Projectile.localAI[0];
|
||||
|
||||
// The type of dust used in the effects and the color of the particles that it'll use depending on the type of rocket used.
|
||||
// It'll carry over to the projectiles that it shoots.
|
||||
public static int DustEffectsID { get; set; }
|
||||
public static Color EffectsColor { get; set; }
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = Projectile.height = 152;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.netImportant = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout.
|
||||
bool cantUse = Owner == null || !Owner.active || Owner.dead || !Owner.channel || Main.myPlayer != Projectile.owner || Owner.CCed || Owner.noItems;
|
||||
if (cantUse)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
// The center of the player, taking into account if they have a mount or not.
|
||||
Vector2 mountedCenter = Owner.MountedCenter;
|
||||
|
||||
// The vector between the player and the mouse.
|
||||
Vector2 ownerToMouse = Owner.Calamity().mouseWorld - mountedCenter;
|
||||
|
||||
// Deals with the holdout's rotation and direction, the owner's arms, etc.
|
||||
ManageHoldout(mountedCenter, ownerToMouse);
|
||||
|
||||
// If the timer reaches Item.useTime, it'll shoot.
|
||||
// It'll shoot once immediately as the timer reaches.
|
||||
if (ShootingTimer >= Owner.itemTimeMax)
|
||||
{
|
||||
// Every X frames it'll shoot a projectile.
|
||||
if (ShootingTimer % TimeBetweenShots == 0f)
|
||||
{
|
||||
// We use the velocity of this projectie as its direction vector.
|
||||
Vector2 direction = Projectile.velocity.SafeNormalize(Vector2.Zero);
|
||||
|
||||
// The position of the tip of the gun.
|
||||
Vector2 nuzzlePosition = Projectile.Center + direction * Projectile.width / 2f;
|
||||
|
||||
// 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);
|
||||
|
||||
// Decides the color of the effects depending on the type of rocket used.
|
||||
switch (rocketTypeShot)
|
||||
{
|
||||
case ItemID.WetRocket:
|
||||
DustEffectsID = DustID.Water;
|
||||
EffectsColor = Color.Blue;
|
||||
break;
|
||||
case ItemID.LavaRocket:
|
||||
DustEffectsID = DustID.Torch;
|
||||
EffectsColor = Color.Red;
|
||||
break;
|
||||
case ItemID.HoneyRocket:
|
||||
DustEffectsID = DustID.Honey;
|
||||
EffectsColor = Color.Yellow;
|
||||
break;
|
||||
default:
|
||||
DustEffectsID = 109;
|
||||
EffectsColor = Color.Black;
|
||||
break;
|
||||
}
|
||||
|
||||
// Spawns the projectile.
|
||||
Projectile.NewProjectileDirect(
|
||||
Projectile.GetSource_FromThis(),
|
||||
nuzzlePosition,
|
||||
direction * itemShootSpeed,
|
||||
ProjectileType<FlakKrakenProjectile>(),
|
||||
itemDamage,
|
||||
itemKnockback,
|
||||
Projectile.owner,
|
||||
rocketTypeShot,
|
||||
ownerToMouse.Length());
|
||||
|
||||
// Applies the knockback to the player.
|
||||
Owner.velocity += ownerToMouse.SafeNormalize(Vector2.UnitY) * -OwnerKnockbackStrength;
|
||||
|
||||
// Inside here go all the things that dedicated servers shouldn't spend resources on.
|
||||
// Like visuals and sounds.
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
// By decreasing the offset length of the gun from the arms, we give an effect of recoil.
|
||||
OffsetLengthScalar = 10f;
|
||||
|
||||
Owner.Calamity().GeneralScreenShakePower = 5f;
|
||||
|
||||
Particle shootPulse = new DirectionalPulseRing(nuzzlePosition,
|
||||
Vector2.Zero,
|
||||
Color.Gray * 0.7f,
|
||||
new Vector2(0.5f, 1f),
|
||||
Projectile.rotation,
|
||||
0.1f,
|
||||
0.4f,
|
||||
20);
|
||||
GeneralParticleHandler.SpawnParticle(shootPulse);
|
||||
|
||||
int smokeAmount = Main.rand.Next(12, 16 + 1);
|
||||
for (int i = 0; i < smokeAmount; i++)
|
||||
{
|
||||
Particle smoke = new MediumMistParticleAlphaBlend(
|
||||
nuzzlePosition,
|
||||
direction.RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(2f, 30f),
|
||||
EffectsColor * 0.1f,
|
||||
Color.Transparent,
|
||||
Main.rand.NextFloat(0.5f, 1.2f),
|
||||
Main.rand.NextFloat(300f, 400f));
|
||||
GeneralParticleHandler.SpawnParticle(smoke);
|
||||
}
|
||||
|
||||
int dustAmount = Main.rand.Next(15, 20 + 1);
|
||||
for (int i = 0; i < dustAmount; i++)
|
||||
{
|
||||
Dust shootDust = Dust.NewDustPerfect(
|
||||
nuzzlePosition,
|
||||
DustEffectsID,
|
||||
direction.RotatedByRandom(MathHelper.PiOver4 * 0.5f) * Main.rand.NextFloat(2f, 12f),
|
||||
Scale: Main.rand.NextFloat(0.8f, 1f));
|
||||
shootDust.fadeIn = 100f;
|
||||
shootDust.noLight = false;
|
||||
shootDust.noLightEmittence = false;
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") { Volume = 0.6f }, nuzzlePosition);
|
||||
}
|
||||
|
||||
NetUpdate();
|
||||
}
|
||||
|
||||
// When it has shot all the projectiles in the burst, reset all the variables and back to shooting.
|
||||
if (ShootingTimer >= Owner.itemTimeMax + TimeBetweenShots * (ProjectilesPerBurst - 1))
|
||||
{
|
||||
ShootingTimer = 0f;
|
||||
TimerBetweenBursts = 0f;
|
||||
NetUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// When we change the distance of the gun from the arms for the recoil,
|
||||
// recover to the original position smoothly.
|
||||
if (OffsetLengthScalar != 30f)
|
||||
OffsetLengthScalar = MathHelper.Lerp(OffsetLengthScalar, 30f, 0.05f);
|
||||
|
||||
ShootingTimer++;
|
||||
}
|
||||
|
||||
#region AI Methods
|
||||
|
||||
public void ManageHoldout(Vector2 mountedCenter, Vector2 ownerToMouse)
|
||||
{
|
||||
Vector2 rotationVector = Projectile.rotation.ToRotationVector2();
|
||||
float velocityRotation = Projectile.velocity.ToRotation();
|
||||
float proximityLookingUpwards = Vector2.Dot(ownerToMouse.SafeNormalize(Vector2.Zero), -Vector2.UnitY);
|
||||
int direction = MathF.Sign(ownerToMouse.X);
|
||||
|
||||
Vector2 armPosition = Owner.RotatedRelativePoint(mountedCenter, true);
|
||||
Vector2 lengthOffset = rotationVector * OffsetLengthScalar;
|
||||
Vector2 armOffset = new Vector2(Utils.Remap(proximityLookingUpwards, -1f, 1f, 15f, -18f) * direction, -20f + Utils.Remap(MathF.Abs(proximityLookingUpwards), 0f, 1f, 0f, proximityLookingUpwards > 0f ? 20f : 10f));
|
||||
Projectile.Center = armPosition + lengthOffset + armOffset;
|
||||
Projectile.velocity = velocityRotation.AngleTowards(ownerToMouse.ToRotation(), 0.2f).ToRotationVector2();
|
||||
Projectile.rotation = velocityRotation;
|
||||
Projectile.timeLeft = 2;
|
||||
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
Owner.itemTime = Owner.itemAnimation = 2;
|
||||
Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation();
|
||||
|
||||
Projectile.spriteDirection = Projectile.direction = direction;
|
||||
Owner.ChangeDir(direction);
|
||||
|
||||
float armRotation = Projectile.rotation - MathHelper.PiOver2; // -Pi/2 because the arms rotation starts with arms pointing down.
|
||||
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.ThreeQuarters, armRotation);
|
||||
Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armRotation);
|
||||
}
|
||||
|
||||
public void NetUpdate()
|
||||
{
|
||||
Projectile.netUpdate = true;
|
||||
if (Projectile.netSpam >= 10)
|
||||
Projectile.netSpam = 9;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
Owner = Main.player[Projectile.owner];
|
||||
OffsetLengthScalar = 30f;
|
||||
}
|
||||
|
||||
// Because we use the velocity as a direction, we don't need it to change its position.
|
||||
public override bool ShouldUpdatePosition() => false;
|
||||
|
||||
public override bool? CanDamage() => false;
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = Request<Texture2D>(Texture).Value;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
Color drawColor = Projectile.GetAlpha(lightColor);
|
||||
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
|
||||
Vector2 rotationPoint = texture.Size() * 0.5f;
|
||||
SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class FlakKrakenProj : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
|
||||
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 54;
|
||||
Projectile.height = 54;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.scale = 0.002f;
|
||||
Projectile.timeLeft = 36000;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 10;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Projectile.type != ModContent.ProjectileType<FlakKrakenProj>() ||
|
||||
!Main.projectile[(int)Projectile.ai[1]].active ||
|
||||
Main.projectile[(int)Projectile.ai[1]].type != ModContent.ProjectileType<FlakKrakenGun>())
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
// This code uses player-specific fields (such as the mouse), and does not need to be run for anyone
|
||||
// other than its owner.
|
||||
if (Main.myPlayer != Projectile.owner)
|
||||
return;
|
||||
|
||||
// This needs to happen retroactively due to Deadshot Brooch and other potential items boosting updates
|
||||
Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates;
|
||||
|
||||
Projectile.rotation += 0.2f;
|
||||
if (Projectile.localAI[0] < 1f)
|
||||
{
|
||||
Projectile.localAI[0] += 0.002f;
|
||||
Projectile.scale += 0.002f;
|
||||
Projectile.width = Projectile.height = (int)(50f * Projectile.scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.width = Projectile.height = 50;
|
||||
}
|
||||
Player player = Main.player[Projectile.owner];
|
||||
Vector2 projPos = player.RotatedRelativePoint(player.MountedCenter, true);
|
||||
float projX = (float)Main.mouseX + Main.screenPosition.X - projPos.X;
|
||||
float projY = (float)Main.mouseY + Main.screenPosition.Y - projPos.Y;
|
||||
if (player.gravDir == -1f)
|
||||
{
|
||||
projY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projPos.Y;
|
||||
}
|
||||
if ((float.IsNaN(projX) && float.IsNaN(projY)) || (projX == 0f && projY == 0f))
|
||||
{
|
||||
projX = (float)player.direction;
|
||||
projY = 0f;
|
||||
}
|
||||
projPos += new Vector2(projX, projY);
|
||||
float speed = 30f;
|
||||
float speedScale = 3f;
|
||||
Vector2 vectorPos = Projectile.Center;
|
||||
if (Vector2.Distance(projPos, vectorPos) < 90f)
|
||||
{
|
||||
speed = 10f;
|
||||
speedScale = 1f;
|
||||
}
|
||||
if (Vector2.Distance(projPos, vectorPos) < 30f)
|
||||
{
|
||||
speed = 3f;
|
||||
speedScale = 0.3f;
|
||||
}
|
||||
if (Vector2.Distance(projPos, vectorPos) < 10f)
|
||||
{
|
||||
speed = 1f;
|
||||
speedScale = 0.1f;
|
||||
}
|
||||
float projectileX = projPos.X - vectorPos.X;
|
||||
float projectileY = projPos.Y - vectorPos.Y;
|
||||
float projectileAdjust = (float)Math.Sqrt((double)(projectileX * projectileX + projectileY * projectileY));
|
||||
projectileAdjust = speed / projectileAdjust;
|
||||
projectileX *= projectileAdjust;
|
||||
projectileY *= projectileAdjust;
|
||||
if (Projectile.velocity.X < projectileX)
|
||||
{
|
||||
Projectile.velocity.X = Projectile.velocity.X + speedScale;
|
||||
if (Projectile.velocity.X < 0f && projectileX > 0f)
|
||||
{
|
||||
Projectile.velocity.X = Projectile.velocity.X + speedScale;
|
||||
}
|
||||
}
|
||||
else if (Projectile.velocity.X > projectileX)
|
||||
{
|
||||
Projectile.velocity.X = Projectile.velocity.X - speedScale;
|
||||
if (Projectile.velocity.X > 0f && projectileX < 0f)
|
||||
{
|
||||
Projectile.velocity.X = Projectile.velocity.X - speedScale;
|
||||
}
|
||||
}
|
||||
if (Projectile.velocity.Y < projectileY)
|
||||
{
|
||||
Projectile.velocity.Y = Projectile.velocity.Y + speedScale;
|
||||
if (Projectile.velocity.Y < 0f && projectileY > 0f)
|
||||
{
|
||||
Projectile.velocity.Y = Projectile.velocity.Y + speedScale;
|
||||
}
|
||||
}
|
||||
else if (Projectile.velocity.Y > projectileY)
|
||||
{
|
||||
Projectile.velocity.Y = Projectile.velocity.Y - speedScale;
|
||||
if (Projectile.velocity.Y > 0f && projectileY < 0f)
|
||||
{
|
||||
Projectile.velocity.Y = Projectile.velocity.Y - speedScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<CrushDepth>(), 180);
|
||||
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<CrushDepth>(), 180);
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
modifiers.SourceDamage *= Projectile.localAI[0];
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(255, 200, 50, Projectile.alpha);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
using System.IO;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static CalamityMod.Items.Weapons.Ranged.FlakKraken;
|
||||
using static CalamityMod.Projectiles.Ranged.FlakKrakenHoldout;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class FlakKrakenProjectile : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override string Texture => "CalamityMod/Projectiles/Summon/CalamarisLamentProjectile";
|
||||
|
||||
public ref float RocketID => ref Projectile.ai[0];
|
||||
public ref float DistanceOwnerMouse => ref Projectile.ai[1];
|
||||
public bool IsShrapnel
|
||||
{
|
||||
get => Projectile.ai[2] == 1f;
|
||||
set => Projectile.ai[2] = value == true ? 1f : 0f;
|
||||
}
|
||||
public bool HasHitEnemyWithInitialShot;
|
||||
|
||||
public Player Owner { get; set; }
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.projFrames[Type] = 5;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 4;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.width = Projectile.height = 28;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
|
||||
Projectile.friendly = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
}
|
||||
|
||||
// Syncs other variables that can't fit into the Projectile.ai[] array.
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(HasHitEnemyWithInitialShot);
|
||||
}
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
HasHitEnemyWithInitialShot = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Enforces the gravity.
|
||||
if (Projectile.velocity.Y < 25f)
|
||||
Projectile.velocity.Y += ProjectileGravityStrength;
|
||||
|
||||
// Rotates towards its velocity.
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2;
|
||||
|
||||
Projectile.frameCounter++;
|
||||
if (Projectile.frameCounter >= 4)
|
||||
{
|
||||
Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type];
|
||||
Projectile.frameCounter = 0;
|
||||
}
|
||||
|
||||
// If it's the initial shot and the shot has gone past the distance of the player and the mouse when shooting,
|
||||
// split into shrapnel.
|
||||
if (!IsShrapnel && !Projectile.WithinRange(Owner.MountedCenter, DistanceOwnerMouse))
|
||||
Projectile.Kill();
|
||||
|
||||
// Below here go all the things that dedicated servers shouldn't spend resources on.
|
||||
// Like visuals and sounds.
|
||||
if (Main.dedServ)
|
||||
return;
|
||||
|
||||
// The projectile will fade away as its time alive is ending.
|
||||
Projectile.alpha = (int)Utils.Remap(Projectile.timeLeft, 30f, 0f, 0f, 255f);
|
||||
|
||||
Dust trailDust = Dust.NewDustDirect(Projectile.position,
|
||||
Projectile.width,
|
||||
Projectile.height,
|
||||
DustEffectsID,
|
||||
Scale: Main.rand.NextFloat(0.5f, 0.8f),
|
||||
Alpha: 127);
|
||||
trailDust.noGravity = true;
|
||||
trailDust.noLight = true;
|
||||
trailDust.alpha = (int)Utils.Remap(Projectile.timeLeft, 30f, 0f, 127f, 0f);
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
Owner = Main.player[Projectile.owner];
|
||||
Projectile.scale = 1.5f;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(BuffType<CrushDepth>(), 180);
|
||||
if (!IsShrapnel)
|
||||
HasHitEnemyWithInitialShot = true;
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo info)
|
||||
{
|
||||
target.AddBuff(BuffType<CrushDepth>(), 180);
|
||||
if (!IsShrapnel)
|
||||
HasHitEnemyWithInitialShot = true;
|
||||
}
|
||||
|
||||
// The initial shot deals less damage.
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage *= IsShrapnel ? 1f : InitialShotDamageMultiplier;
|
||||
public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) => modifiers.SourceDamage *= IsShrapnel ? 1f : InitialShotDamageMultiplier;
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID)
|
||||
{
|
||||
// Since we use our own spawning method for the cluster rockets, we don't need them to shoot anything,
|
||||
// we'll do it ourselves.
|
||||
clusterProjectileID = ProjectileID.None,
|
||||
destructiveClusterProjectileID = ProjectileID.None,
|
||||
};
|
||||
int blastRadius = Projectile.RocketBehavior(info);
|
||||
Projectile.ExpandHitboxBy((float)blastRadius);
|
||||
Projectile.Damage();
|
||||
|
||||
if (!IsShrapnel)
|
||||
{
|
||||
bool usedClusterRockets = RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII;
|
||||
int flakAmount = usedClusterRockets ? ClusterShrapnelAmount : ShrapnelAmount;
|
||||
for (int i = 0; i < flakAmount; i++)
|
||||
{
|
||||
Projectile shrapnel = Projectile.NewProjectileDirect(
|
||||
Projectile.GetSource_FromThis(),
|
||||
Projectile.Center,
|
||||
Projectile.velocity.SafeNormalize(-Vector2.UnitY).RotatedByRandom(usedClusterRockets ? ClusterShrapnelAngleOffset : ShrapnelAngleOffset) * ProjectileShootSpeed,
|
||||
ProjectileType<FlakKrakenProjectile>(),
|
||||
(int)(Projectile.damage * (HasHitEnemyWithInitialShot ? InitialShotHitShrapnelDamageMultiplier : 1f)),
|
||||
Projectile.knockBack,
|
||||
Projectile.owner,
|
||||
RocketID,
|
||||
ai2: 1f);
|
||||
|
||||
// Since the shrapnel and the initial shot are the same projectile,
|
||||
// and we want to apply the damage penalty for hitting with the initial shot,
|
||||
// all shrapnel will have this bool on and we'll apply the penalty here.
|
||||
if (HasHitEnemyWithInitialShot)
|
||||
shrapnel.ModProjectile<FlakKrakenProjectile>().HasHitEnemyWithInitialShot = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Inside here go all the things that dedicated servers shouldn't spend resources on.
|
||||
// Like visuals and sounds.
|
||||
if (Main.dedServ)
|
||||
return;
|
||||
|
||||
// These effects will only run if the initial shot is splitting,
|
||||
// or the shrapnel doesn't have the damage pentalty, so we don't have effect overload.
|
||||
if (!IsShrapnel || (IsShrapnel && !HasHitEnemyWithInitialShot))
|
||||
{
|
||||
int dustAmount = Main.rand.Next(20, 30 + 1);
|
||||
for (int i = 0; i < dustAmount; i++)
|
||||
{
|
||||
Dust boomDust = Dust.NewDustPerfect(Projectile.Center,
|
||||
DustEffectsID,
|
||||
Main.rand.NextVector2Circular(5f, 5f),
|
||||
newColor: EffectsColor,
|
||||
Scale: Main.rand.NextFloat(.8f, 1.2f));
|
||||
boomDust.noLight = true;
|
||||
boomDust.noLightEmittence = true;
|
||||
}
|
||||
|
||||
Particle boomRing = new DirectionalPulseRing(Projectile.Center,
|
||||
Vector2.Zero,
|
||||
Color.White * 0.3f,
|
||||
Vector2.One,
|
||||
0f,
|
||||
Projectile.width / 1560f,
|
||||
Projectile.width / 156f,
|
||||
20);
|
||||
GeneralParticleHandler.SpawnParticle(boomRing);
|
||||
|
||||
int blobAmount = Main.rand.Next(4, 6 + 1);
|
||||
for (int i = 0; i < blobAmount; i++)
|
||||
{
|
||||
Particle blob = new WaterGlobParticle(Projectile.Center,
|
||||
Main.rand.NextVector2Circular(5f, 5f),
|
||||
Main.rand.NextFloat(0.8f, 1.2f));
|
||||
blob.Color = EffectsColor;
|
||||
GeneralParticleHandler.SpawnParticle(blob);
|
||||
}
|
||||
|
||||
int mistAmount = Main.rand.Next(3, 5 + 1);
|
||||
for (int mistIndex = 0; mistIndex < mistAmount; mistIndex++)
|
||||
{
|
||||
float angle = MathHelper.TwoPi / mistAmount * mistIndex;
|
||||
Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f, 15f);
|
||||
Particle boomMist = new MediumMistParticleAlphaBlend(Projectile.Center,
|
||||
velocity,
|
||||
EffectsColor * Main.rand.NextFloat(0.1f, 0.3f),
|
||||
Color.Transparent,
|
||||
Main.rand.NextFloat(.6f, 1.4f),
|
||||
Main.rand.NextFloat(200f, 400f));
|
||||
GeneralParticleHandler.SpawnParticle(boomMist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = Request<Texture2D>(Texture).Value;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
|
||||
Color drawColor = Projectile.GetAlpha(lightColor);
|
||||
Vector2 origin = frame.Size() * 0.5f;
|
||||
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor);
|
||||
|
||||
Main.EntitySpriteDraw(texture, drawPosition, frame, drawColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user