40 hours of elephant gun
This commit is contained in:
1 parent
7edee161b4
commit
267b03b9a2
18 files changed
+905
-195
No files matched your search
@@ -140,6 +140,12 @@ namespace CalamityMod.CalPlayer
|
||||
/// </summary>
|
||||
public bool heldGaelsLastFrame = false;
|
||||
/// <summary>
|
||||
/// Tracks whether or not the player is currently holding Elephant Killer.<br/>
|
||||
/// Used to reset stealth when swapping to this item.
|
||||
/// </summary>
|
||||
public bool heldElephantKillerLastFrame = false;
|
||||
public float elephantKillerJoke = 0;
|
||||
/// <summary>
|
||||
/// Tracks whether or not the player currently has Draedon's Heart equipped.<br/>
|
||||
/// Used to reset Adrenaline when (un)equipped to prevent exploits.
|
||||
/// </summary>
|
||||
@@ -3069,6 +3075,7 @@ namespace CalamityMod.CalPlayer
|
||||
if (Player.HeldItem.IsAir || Player.HeldItem.fishingPole == 0)
|
||||
consecutiveCaughtFish = 0;
|
||||
heldGaelsLastFrame = false;
|
||||
heldElephantKillerLastFrame = false;
|
||||
partialLifeRegenCounter = 0f;
|
||||
gaelSwipes = 0;
|
||||
whitewaterHeal = 0;
|
||||
@@ -6040,6 +6047,10 @@ namespace CalamityMod.CalPlayer
|
||||
if (it.type == ItemType<DoomsdayDevice>())
|
||||
playerUsingWeapon = false;
|
||||
|
||||
// Elephant Killer consumes stealth in a special wa- hey maybe this is a sign this class needs some work huh
|
||||
if (it.type == ItemType<ElephantKiller>())
|
||||
playerUsingWeapon = false;
|
||||
|
||||
// Animation check depends on whether the item is "clockwork", like Clockwork Assault Rifle.
|
||||
// "Clockwork" weapons can chain-fire multiple stealth strikes (really only 2 max) until you run out of stealth.
|
||||
bool animationCheck = it.useAnimation == it.useTime
|
||||
@@ -6106,7 +6117,7 @@ namespace CalamityMod.CalPlayer
|
||||
Player.ownedProjectileCounts[ProjectileType<FinalDawnThrow2>()];
|
||||
|
||||
// If you are actively using an item, you cannot gain stealth.
|
||||
if (Player.itemAnimation > 0 || finalDawnProjCount > 0)
|
||||
if (Player.itemAnimation > 0 || finalDawnProjCount > 0 || (Player.ownedProjectileCounts[ProjectileType<ElephantKillerThrown>()] > 0 || Player.HeldItem.type == ModContent.ItemType<ElephantKiller>()))
|
||||
return 0f;
|
||||
|
||||
if (shadow)
|
||||
|
||||
@@ -45,6 +45,7 @@ using CalamityMod.Items.VanillaArmorChanges;
|
||||
using CalamityMod.Items.Weapons.Magic;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.Items.Weapons.Summon;
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.NPCs.AcidRain;
|
||||
@@ -239,6 +240,15 @@ namespace CalamityMod.CalPlayer
|
||||
rage = 0f;
|
||||
}
|
||||
|
||||
bool holdingElephantKiller = Player.HeldItem.type == ModContent.ItemType<ElephantKiller>();
|
||||
if (holdingElephantKiller && !heldElephantKillerLastFrame)
|
||||
{
|
||||
Player.Calamity().rogueStealth = 0;
|
||||
heldElephantKillerLastFrame = true;
|
||||
}
|
||||
else if (!holdingElephantKiller)
|
||||
heldElephantKillerLastFrame = false;
|
||||
|
||||
if (furyFuel < FuryFuelMax && furyRefuelTimer >= 0)
|
||||
{
|
||||
furyFuel += (int)furyRefuelTimer;
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Rogue
|
||||
{
|
||||
public class ElephantGun : RogueWeapon
|
||||
{
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 46;
|
||||
Item.height = 58;
|
||||
Item.damage = 84;
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.useAnimation = Item.useTime = 46;
|
||||
Item.useStyle = ItemUseStyleID.Swing;
|
||||
Item.knockBack = 1f;
|
||||
Item.UseSound = SoundID.Item1;
|
||||
Item.autoReuse = true;
|
||||
Item.maxStack = 1;
|
||||
Item.value = CalamityGlobalItem.RarityLightRedBuyPrice;
|
||||
Item.rare = ItemRarityID.LightRed;
|
||||
Item.shoot = ModContent.ProjectileType<ElephantGunThrown>();
|
||||
Item.shootSpeed = 3f;
|
||||
Item.DamageType = RogueDamageClass.Instance;
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
if (player.Calamity().StealthStrikeAvailable())
|
||||
{
|
||||
int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f);
|
||||
if (p.WithinBounds(Main.maxProjectiles))
|
||||
Main.projectile[p].Calamity().stealthStrike = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
CreateRecipe().
|
||||
AddIngredient<FishboneBoomerang>().
|
||||
AddIngredient(ItemID.DarkShard).
|
||||
AddIngredient(ItemID.LightShard).
|
||||
AddIngredient(ItemID.SoulofLight, 7).
|
||||
AddIngredient(ItemID.SoulofNight, 7).
|
||||
AddTile(TileID.Anvils).
|
||||
Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Rogue
|
||||
{
|
||||
public class ElephantKiller : RogueWeapon
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true;
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 46;
|
||||
Item.height = 58;
|
||||
Item.damage = 67;
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.useAnimation = Item.useTime = 38;
|
||||
Item.useStyle = ItemUseStyleID.Swing;
|
||||
Item.knockBack = 3f;
|
||||
Item.autoReuse = true;
|
||||
Item.value = CalamityGlobalItem.RarityLightRedBuyPrice;
|
||||
Item.rare = ItemRarityID.LightRed;
|
||||
Item.shoot = ModContent.ProjectileType<ElephantKillerThrown>();
|
||||
Item.shootSpeed = 15f;
|
||||
Item.DamageType = RogueDamageClass.Instance;
|
||||
}
|
||||
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
|
||||
public override bool AltFunctionUse(Player player) => true;
|
||||
public override void HoldItem(Player player)
|
||||
{
|
||||
if (Main.myPlayer == player.whoAmI)
|
||||
player.Calamity().rightClickListener = true;
|
||||
player.Calamity().mouseWorldListener = true;
|
||||
}
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
bool shoot = player.Calamity().mouseRight;
|
||||
Projectile gun = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI, 0, shoot ? 1f : 0);
|
||||
gun.scale = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 450 B |
@@ -364,14 +364,14 @@ EclipsesFall: {
|
||||
'''
|
||||
}
|
||||
|
||||
ElephantGun: {
|
||||
ElephantKiller: {
|
||||
DisplayName: Elephant Killer
|
||||
Tooltip:
|
||||
'''
|
||||
'''
|
||||
[c/1FFBFF:'My own personal weapon, used to stamp out elephant uprisings.]
|
||||
[c/1FFBFF:Their souls are forever trapped within this weapon, ready to once again enact revenge.]
|
||||
[c/1FFBFF:Their souls are forever trapped within this weapon, ready to once again enact revenge.]
|
||||
[c/1FFBFF:I have backed up the schematics in the event of the original's destruction.']
|
||||
'''
|
||||
'''
|
||||
}
|
||||
|
||||
EnchantedAxe: {
|
||||
|
||||
@@ -91,6 +91,7 @@ EclipsesStealth.DisplayName: Eclipse's Fall
|
||||
EclipseStealthBoom.DisplayName: Eclipse Blast
|
||||
EGloveSpark.DisplayName: Electrician's Spark
|
||||
EnchantedAxe2.DisplayName: Enchanted Axe
|
||||
ElephantKillerThrown.DisplayName: Elephant Killer
|
||||
EnchantedAxeProj.DisplayName: Enchanted Axe
|
||||
EpidemicShredderProjectile.DisplayName: Epidemic Shredder
|
||||
EquanimityDarkShard.DisplayName: Dark Shard
|
||||
@@ -333,4 +334,4 @@ WrathwingFireball.DisplayName: Wrathwing Fireball
|
||||
WrathwingSpear.DisplayName: Wrathwing
|
||||
WulfrumKnifeProj.DisplayName: Wulfrum Knife
|
||||
NanoblackLightspeedCarveSlashVisual.DisplayName: Nanoblack Light-speed Carve Visuals
|
||||
ElephantGunThrown.DisplayName: Elephant Gun Thrown
|
||||
ElephantKillerElephant.DisplayName: Elephant Killer Elephant
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
@@ -1,132 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class ElephantGunThrown : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Rogue/ElephantGun";
|
||||
|
||||
public static int ChargeupTime = 10;
|
||||
public static int Lifetime = 500;
|
||||
public float OverallProgress => 1 - Projectile.timeLeft / (float)Lifetime;
|
||||
public float ThrowProgress => 1 - Projectile.timeLeft / (float)(Lifetime);
|
||||
public float ChargeProgress => 1 - (Projectile.timeLeft - Lifetime) / (float)(ChargeupTime);
|
||||
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public ref float Returning => ref Projectile.ai[0];
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 46;
|
||||
Projectile.height = 46;
|
||||
Projectile.friendly = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = Lifetime + ChargeupTime;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 10;
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
}
|
||||
|
||||
public override bool ShouldUpdatePosition()
|
||||
{
|
||||
return ChargeProgress >= 1;
|
||||
}
|
||||
|
||||
public override bool? CanDamage()
|
||||
{
|
||||
//We don't want the anticipation to deal damage.
|
||||
if (ChargeProgress < 1)
|
||||
return false;
|
||||
|
||||
if (Returning == 1f)
|
||||
return false;
|
||||
|
||||
return base.CanDamage();
|
||||
}
|
||||
|
||||
//Swing animation keys
|
||||
public CurveSegment pullback = new CurveSegment(EasingType.PolyOut, 0f, 0f, MathHelper.PiOver4 * -1.2f, 2);
|
||||
public CurveSegment throwout = new CurveSegment(EasingType.PolyOut, 0.7f, MathHelper.PiOver4 * -1.2f, MathHelper.PiOver4 * 1.2f + MathHelper.PiOver2, 3);
|
||||
internal float ArmAnticipationMovement() => PiecewiseAnimation(ChargeProgress, new CurveSegment[] { pullback, throwout });
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
//Anticipation animation. Make the player look like theyre holding the boomerang
|
||||
if (ChargeProgress < 1)
|
||||
{
|
||||
float armRotation = ArmAnticipationMovement() * Owner.direction;
|
||||
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
|
||||
Projectile.Center = Owner.MountedCenter + Vector2.UnitY.RotatedBy(armRotation * Owner.gravDir) * -40f * Owner.gravDir;
|
||||
Projectile.rotation = (-MathHelper.PiOver2 + armRotation) * Owner.gravDir;
|
||||
|
||||
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, MathHelper.Pi + armRotation);
|
||||
|
||||
Projectile.tileCollide = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Projectile.rotation += 0.4f * Projectile.direction;
|
||||
|
||||
//Play the throw sound when the throw ACTUALLY BEGINS.
|
||||
//Additionally, make the projectile collide and set its speed and velocity
|
||||
if (Projectile.timeLeft == Lifetime)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.DD2_GoblinBomberThrow, Projectile.Center);
|
||||
Projectile.Center = Owner.MountedCenter + Projectile.velocity * 12f;
|
||||
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 17.5f;
|
||||
}
|
||||
|
||||
//Boomerang spinny sounds
|
||||
if (Projectile.soundDelay <= 0)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item7, Projectile.Center);
|
||||
Projectile.soundDelay = 8;
|
||||
}
|
||||
|
||||
if (Projectile.velocity.Length() < 2f)
|
||||
{
|
||||
Returning = 1f;
|
||||
Projectile.numHits = 0;
|
||||
}
|
||||
|
||||
if (Returning == 0f && Projectile.velocity.Length() > 2f && Projectile.timeLeft < (455 + ChargeupTime))
|
||||
{
|
||||
Projectile.velocity *= 0.88f;
|
||||
}
|
||||
|
||||
if (Returning == 1f && Projectile.velocity.Length() < 20f)
|
||||
{
|
||||
Projectile.velocity *= 1.1f;
|
||||
}
|
||||
|
||||
if (Returning == 1f)
|
||||
{
|
||||
//Aim back at the player
|
||||
Projectile.velocity = Projectile.velocity.Length() * (Owner.MountedCenter - Projectile.Center).SafeNormalize(Vector2.One);
|
||||
|
||||
if ((Projectile.Center - Owner.MountedCenter).Length() < 24f)
|
||||
{
|
||||
Projectile.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
Projectile.velocity *= 0.3f;
|
||||
Returning = 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Systems.Graphic.PixelationSystem;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using ReLogic.Utilities;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static CalamityMod.Projectiles.Rogue.ElephantKillerThrown;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class ElephantKillerElephant : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public SlotId soundSlot;
|
||||
public float rumble = 0;
|
||||
public float displace = 0;
|
||||
public ref float holeSize => ref Projectile.localAI[1];
|
||||
public ref float time => ref Projectile.ai[0];
|
||||
public static Asset<Texture2D> ElephantTexture { get; private set; }
|
||||
public override void Load()
|
||||
{
|
||||
if (Main.dedServ)
|
||||
return;
|
||||
|
||||
ElephantTexture = Terraria.GameContent.TextureAssets.Projectile[Type];
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.scale = 2f;
|
||||
Projectile.width = 135;
|
||||
Projectile.height = 90;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = 2300;
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 20;
|
||||
Projectile.extraUpdates = 3;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (time == 0)
|
||||
{
|
||||
Projectile.spriteDirection = Math.Sign(Projectile.velocity.X);
|
||||
Projectile.rotation = Projectile.velocity.ToRotation();
|
||||
}
|
||||
float sine = MathF.Sin((time * 0.05f) / MathHelper.Pi);
|
||||
if (time < 70)
|
||||
{
|
||||
Projectile.velocity *= 0.93f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.velocity = Vector2.Zero;
|
||||
Projectile.Center += Vector2.UnitY * sine * 0.1f;
|
||||
}
|
||||
Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.spriteDirection == -1 ? MathHelper.Pi : 0, 0.04f);
|
||||
|
||||
if (time == 90)
|
||||
{
|
||||
SoundStyle fire = new("CalamityMod/Sounds/Item/ElephantKillerElephant");
|
||||
soundSlot = SoundEngine.PlaySound(fire with { Volume = 1f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) - 0.2f, MaxInstances = -1 }, Projectile.Center);
|
||||
rumble = 30;
|
||||
}
|
||||
|
||||
if (SoundEngine.TryGetActiveSound(soundSlot, out var sound) && sound.IsPlaying)
|
||||
sound.Position = Projectile.Center;
|
||||
|
||||
Projectile.Opacity = 1 - MathF.Pow(Utils.GetLerpValue(230, 0, Projectile.timeLeft, true), 6);
|
||||
rumble = MathHelper.Lerp(rumble, 0, 0.04f);
|
||||
time += Utils.Remap(Projectile.Opacity, 1, 0, 1, 10);
|
||||
holeSize = MathHelper.Lerp(holeSize, 0, 0.04f);
|
||||
}
|
||||
public override bool? CanDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
|
||||
Vector2 generalDrawPos = Projectile.Center + Main.rand.NextVector2Circular(rumble, rumble) + Vector2.UnitY * 25;
|
||||
|
||||
SpriteEffects spriteFx = SpriteEffects.FlipHorizontally;
|
||||
if (Projectile.spriteDirection == -1)
|
||||
spriteFx |= SpriteEffects.FlipVertically;
|
||||
|
||||
float deathFade = 1 - Projectile.Opacity;
|
||||
float lerp = MathF.Pow(Utils.GetLerpValue(0, 35, time, true), 3);
|
||||
float scale = (0.5f + 0.5f * lerp);
|
||||
|
||||
//PixelationManager.AddPixelatedDrawer((_) =>
|
||||
//{
|
||||
float lerpFade = (1 - MathF.Pow(Utils.GetLerpValue(1f, 0, deathFade, true), 5));
|
||||
int frameDivis = 2;
|
||||
int framesY = tex.Height / frameDivis;
|
||||
int framesX = tex.Width / frameDivis;
|
||||
float directionRot = Projectile.rotation;
|
||||
for (int i = 1; i <= framesY; i++)
|
||||
{
|
||||
float sine = MathF.Sin((time * 0.15f + i * frameDivis) / MathHelper.Pi);
|
||||
float frameLerp = Utils.GetLerpValue(framesY, 1, i, true);
|
||||
float frameFade = Math.Max(MathF.Pow(frameLerp, 4), deathFade);
|
||||
float colorFade = MathF.Pow(1 - frameLerp, 1.5f);
|
||||
for (int x = 1; x <= framesX; x++)
|
||||
{
|
||||
Rectangle frame = tex.Frame(framesX, framesY, framesX - x, framesY - i);
|
||||
|
||||
Vector2 xPos = Vector2.UnitX.RotatedBy(Projectile.spriteDirection == -1 ? directionRot + MathHelper.Pi : directionRot) * frame.Width * x * 2 * Projectile.spriteDirection;
|
||||
|
||||
Vector2 frameMovement = generalDrawPos + (xPos + -Vector2.UnitY.RotatedBy(directionRot) * framesY * (Projectile.spriteDirection == 1 ? -2 * frameDivis : 0f) + -Vector2.UnitY.RotatedBy(directionRot) * frame.Height * 2 * i * Projectile.spriteDirection) * scale
|
||||
+ Vector2.UnitX.RotatedBy(directionRot) * (25 + (295 * Utils.GetLerpValue(tex.Height / 2, 0, Math.Abs(tex.Height / 2 - i), true) * lerpFade)) * sine * frameFade;
|
||||
|
||||
Vector2 holePlace = new Vector2(Projectile.ai[1], Projectile.ai[2]) + (Projectile.spriteDirection * tex.Size());
|
||||
Vector2 pixelPlace = frameMovement;
|
||||
Vector2 holeAdjust = pixelPlace.DirectionFrom(holePlace) * MathHelper.Lerp(0, 25, MathF.Pow(Utils.GetLerpValue(80, 0, pixelPlace.Distance(holePlace), true), 2f)) * holeSize;
|
||||
|
||||
Main.EntitySpriteDraw(tex, frameMovement + holeAdjust - Main.screenPosition, frame, Color.CornflowerBlue with { A = 0 } * (colorFade) * Projectile.Opacity, Projectile.rotation, tex.Size() / 2, Projectile.scale * scale, spriteFx, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//}, Enums.GeneralDrawLayer.BeforeNPCs, default);
|
||||
return false;
|
||||
}
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
float damageMult = MathHelper.Clamp(Utils.GetLerpValue(8, 1, Projectile.numHits), 0.4f, 1);
|
||||
modifiers.SourceDamage *= damageMult;
|
||||
}
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
{
|
||||
return base.Colliding(projHitbox, targetHitbox);
|
||||
}
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
if (SoundEngine.TryGetActiveSound(soundSlot, out var sound) && sound.IsPlaying)
|
||||
sound?.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
@@ -0,0 +1,679 @@
|
||||
using System;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.NPCs.TownNPCs;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
using CalamityMod.Systems.Graphic.PixelationSystem;
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class ElephantKillerThrown : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public ref float time => ref Projectile.ai[0];
|
||||
public ref float rightClicking => ref Projectile.ai[1];
|
||||
public int initialDirection = 0;
|
||||
public float throwSpeed = 0;
|
||||
public float holdoutOffset = 0;
|
||||
public bool tryShooting = true; // Used in the holding mode, is used in inverse for stealth strikes
|
||||
public bool soundToss = true;
|
||||
public bool resetIframes = true;
|
||||
|
||||
public bool spinFxOn = false;
|
||||
public float spinFx = 0;
|
||||
public bool firedThisFrame = false;
|
||||
public bool hasFiredBulletEver = false;
|
||||
public int firingEffectDisableTimer = 0;
|
||||
public int disableTimerMax = 4;
|
||||
public bool resetAll = false;
|
||||
public Vector2 aimedTargetPos;
|
||||
|
||||
public float recoilRotation = 0;
|
||||
public int recoilLifetime = 0;
|
||||
public int recoilLifetimeMax = 30;
|
||||
public bool shouldDie = false;
|
||||
public float shineProgress = 0;
|
||||
public float shineOpacity = 0;
|
||||
public bool shineSound = true;
|
||||
public float rumble = 0;
|
||||
public int hitStop = 0;
|
||||
public int tileHits = 0;
|
||||
|
||||
public float stealthShotDamageMult = 1.5f;
|
||||
public float elephantBoostedShotDamageMult = 3.5f;
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 30;
|
||||
Projectile.height = 30;
|
||||
Projectile.friendly = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = 120;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
Projectile.ContinuouslyUpdateDamageStats = true;
|
||||
}
|
||||
public enum gunState
|
||||
{
|
||||
NotThrown,
|
||||
Thrown,
|
||||
Returning,
|
||||
Shooting,
|
||||
Rebounding,
|
||||
Stealth
|
||||
}
|
||||
public gunState mode;
|
||||
public override bool ShouldUpdatePosition()
|
||||
{
|
||||
return !(mode == gunState.NotThrown || mode == gunState.Stealth || firedThisFrame || hitStop > 0);
|
||||
}
|
||||
public override bool? CanDamage()
|
||||
{
|
||||
//We don't want the anticipation to deal damage.
|
||||
if (mode == gunState.NotThrown || mode == gunState.Stealth || firedThisFrame || hitStop > 0)
|
||||
return false;
|
||||
|
||||
return null;
|
||||
}
|
||||
public void Thrown(Vector2 toMouse, int returnTime, int animationTimeMax)
|
||||
{
|
||||
if (mode == gunState.Thrown || mode == gunState.Returning)
|
||||
{
|
||||
if (time < animationTimeMax * 1.65f)
|
||||
{
|
||||
Owner.ChangeDir(MathF.Sign(toMouse.X));
|
||||
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, MathHelper.Pi * 1.5f + toMouse.ToRotation());
|
||||
}
|
||||
if (!firedThisFrame)
|
||||
Projectile.rotation += 0.55f * initialDirection;
|
||||
|
||||
if (time > returnTime && mode != gunState.Returning)
|
||||
{
|
||||
mode = gunState.Returning;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == gunState.Returning)
|
||||
{
|
||||
if (time < returnTime)
|
||||
time = returnTime;
|
||||
if (time > returnTime * 1.2f && resetIframes)
|
||||
{
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
Projectile.localNPCImmunity[i] = 0;
|
||||
resetIframes = false;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
// Aim back at the player
|
||||
Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.Center.DirectionTo(Owner.Center) * throwSpeed, 0.03f * (1 + 2 * Utils.GetLerpValue(returnTime, returnTime * 2, time)));
|
||||
|
||||
if (Projectile.numHits > 0 && time > returnTime && !hasFiredBulletEver)
|
||||
Projectile.velocity *= 0.93f;
|
||||
|
||||
if (Projectile.numHits > 0 && time > returnTime * 1.4f && (!hasFiredBulletEver || (hasFiredBulletEver && firedThisFrame)))
|
||||
{
|
||||
NPC attemptTarget = !hasFiredBulletEver ? Projectile.Center.ClosestNPCAt(1000, true) : null;
|
||||
if (aimedTargetPos == Vector2.Zero && attemptTarget != null)
|
||||
aimedTargetPos = attemptTarget.Center;
|
||||
|
||||
Vector2 shootVel = aimedTargetPos == Vector2.Zero ? Projectile.rotation.ToRotationVector2() : Projectile.Center.DirectionTo(aimedTargetPos);
|
||||
if (aimedTargetPos != Vector2.Zero)
|
||||
{
|
||||
if (!hasFiredBulletEver)
|
||||
{
|
||||
Projectile.extraUpdates = 0;
|
||||
spinFxOn = false;
|
||||
disableTimerMax = (int)(disableTimerMax * 1.5f);
|
||||
FireShot(shootVel);
|
||||
}
|
||||
spinFx = 0;
|
||||
Projectile.rotation = shootVel.ToRotation();
|
||||
Projectile.Center += -shootVel * holdoutOffset * 2.3f;
|
||||
Projectile.velocity = -shootVel * 20;
|
||||
time--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Projectile.extraUpdates == 0)
|
||||
{
|
||||
spinFxOn = true;
|
||||
Projectile.extraUpdates = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Projectile.Center - Owner.MountedCenter).Length() < 24f && time > returnTime * 1.5f)
|
||||
{
|
||||
Projectile.Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Held(Vector2 toMouse, int returnTime, int animationTimeMax)
|
||||
{
|
||||
if (mode == gunState.NotThrown || mode == gunState.Stealth) // The throw animation
|
||||
{
|
||||
float throwAnimLerp = Utils.GetLerpValue(0, animationTimeMax, time);
|
||||
float dudFireEndPoint = 0.4f; float throwStartPoint = 0.5f; float throwCutPoint = 0.75f; float maxRotation = -MathHelper.PiOver2; float startRotation = MathHelper.PiOver2;
|
||||
|
||||
Owner.ChangeDir(MathF.Sign(toMouse.X));
|
||||
initialDirection = MathF.Sign(toMouse.X);
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
if (recoilLifetime < recoilLifetimeMax - 7)
|
||||
Owner.itemTime = Owner.itemAnimation = 5;
|
||||
if (mode == gunState.Stealth && !tryShooting)
|
||||
rumble = MathHelper.Lerp(rumble, 11, 0.08f);
|
||||
if ((throwAnimLerp >= dudFireEndPoint / 2 && ((mode != gunState.Stealth && tryShooting) || (mode == gunState.Stealth && !tryShooting))))
|
||||
{
|
||||
float stealthAmount = Owner.Calamity().rogueStealthMax * 0.1f;
|
||||
bool fires = mode == gunState.Stealth || (Owner.Calamity().rogueStealthMax > 0 && rightClicking == 1 && Owner.Calamity().rogueStealth >= stealthAmount);
|
||||
if (fires)
|
||||
{
|
||||
if (mode == gunState.Stealth)
|
||||
{
|
||||
Owner.Calamity().ConsumeStealthByAttacking();
|
||||
recoilLifetime++;
|
||||
}
|
||||
else
|
||||
Owner.Calamity().rogueStealth -= stealthAmount;
|
||||
CheckStealth();
|
||||
FireShot(toMouse, true, stealthShotDamageMult, mode == gunState.Stealth);
|
||||
}
|
||||
else
|
||||
{
|
||||
holdoutOffset = 8;
|
||||
SoundStyle click = new("CalamityMod/Sounds/Item/DudFire");
|
||||
SoundEngine.PlaySound(click with { Volume = 0.6f, Pitch = -0.2f }, Projectile.Center);
|
||||
}
|
||||
tryShooting = mode == gunState.Stealth;
|
||||
}
|
||||
if (throwAnimLerp >= dudFireEndPoint)
|
||||
{
|
||||
if (recoilLifetime < recoilLifetimeMax && mode == gunState.Stealth && recoilLifetime > 0)
|
||||
time--;
|
||||
else if (hasFiredBulletEver)
|
||||
{
|
||||
if (mode == gunState.Stealth)
|
||||
{ Projectile.Kill(); return; }
|
||||
if (Owner.Calamity().mouseRight)
|
||||
{ Reset(); return; }
|
||||
else
|
||||
shouldDie = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (throwAnimLerp >= throwStartPoint && soundToss)
|
||||
{
|
||||
SoundStyle toss = new("CalamityMod/Sounds/Item/LightThrow");
|
||||
SoundEngine.PlaySound(toss with { Volume = 0.6f, Pitch = -0.1f }, Projectile.Center);
|
||||
spinFx = 0.5f;
|
||||
spinFxOn = true;
|
||||
soundToss = false;
|
||||
}
|
||||
if (throwAnimLerp >= throwCutPoint)
|
||||
spinFxOn = false;
|
||||
|
||||
float prepThrowLerp = Utils.Remap(throwAnimLerp, dudFireEndPoint, throwStartPoint, 0, 1);
|
||||
float aim = MathHelper.PiOver2 + MathHelper.PiOver4 * (prepThrowLerp < 0.5f ? (1 - MathF.Pow(Utils.GetLerpValue(0.5f, 0, prepThrowLerp, true), 1f)) : (1 - MathF.Pow(Utils.GetLerpValue(0.5f, 1, prepThrowLerp, true), 2.5f)));
|
||||
float pullbackLerp = CalamityUtils.EaseInOutExp(Utils.Remap(throwAnimLerp, throwStartPoint, throwCutPoint, 0, 1), 2, 4); float pullback = MathHelper.Lerp(startRotation, maxRotation, pullbackLerp);
|
||||
float throwForward = MathHelper.Lerp(startRotation, maxRotation, 1 - MathF.Pow(Utils.Remap(throwAnimLerp, throwCutPoint, 1, 0, 1), mode == gunState.Stealth ? 5 : 8.5f));
|
||||
|
||||
float baseRotation = (recoilLifetime > 0 ? MathHelper.PiOver2 : (throwAnimLerp > throwStartPoint ? throwAnimLerp > throwCutPoint ? throwForward : pullback : aim)) + recoilRotation;
|
||||
float finalRotation = toMouse.ToRotation() + baseRotation * Owner.direction + (Owner.direction == -1 ? MathHelper.Pi : 0);
|
||||
float armRotation = finalRotation;
|
||||
|
||||
float jumpLerp = Utils.Remap(throwAnimLerp, throwStartPoint, throwCutPoint, 0, 1);
|
||||
float jumpMult = (jumpLerp < 0.5f ? (1 - MathF.Pow(Utils.GetLerpValue(0.5f, 0, jumpLerp, true), 6)) : (1 - MathF.Pow(Utils.GetLerpValue(0.5f, 1, jumpLerp, true), 6)));
|
||||
if (jumpMult == 0)
|
||||
spinFx = 0;
|
||||
Vector2 jump = Vector2.UnitY * -90 * (jumpMult);
|
||||
Projectile.Center = jump + Owner.MountedCenter + (Vector2.UnitY.RotatedBy(armRotation * Owner.gravDir) * (-31f + holdoutOffset) * Owner.gravDir + Vector2.UnitY.RotatedBy(armRotation + MathHelper.PiOver2 * initialDirection) * 3.5f) * Projectile.scale;
|
||||
|
||||
float rotMult = 1.25f;
|
||||
if (throwAnimLerp <= throwCutPoint && throwAnimLerp >= throwStartPoint)
|
||||
Projectile.rotation -= 0.85f * initialDirection * (jumpMult);
|
||||
else
|
||||
Projectile.rotation = (toMouse.ToRotation() + -MathHelper.PiOver2 + ((baseRotation - MathHelper.PiOver2) * rotMult + MathHelper.PiOver2) * Owner.direction + (Owner.direction == -1 ? MathHelper.Pi : 0)) * Owner.gravDir;
|
||||
|
||||
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, MathHelper.Pi + armRotation);
|
||||
|
||||
if (mode == gunState.Stealth)
|
||||
{
|
||||
float shineLerp = Utils.Remap(throwAnimLerp, 0, dudFireEndPoint, 0, 1);
|
||||
shineProgress = CalamityUtils.EaseInOutExp(shineLerp, 6, 6);
|
||||
shineOpacity = soundToss ? (1 - MathF.Pow(shineLerp, 3)) : 0;
|
||||
if (shineProgress > 0 && shineSound)
|
||||
{
|
||||
SoundStyle shine = new("CalamityMod/Sounds/Item/ElephantKillerShine");
|
||||
SoundEngine.PlaySound(shine with { Volume = 0.6f, Pitch = 0f }, Projectile.Center);
|
||||
shineSound = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (throwAnimLerp > 1)
|
||||
{
|
||||
if (mode == gunState.Stealth)
|
||||
{
|
||||
time = 0;
|
||||
tryShooting = false;
|
||||
return;
|
||||
}
|
||||
mode = gunState.Thrown;
|
||||
Projectile.Center = Owner.MountedCenter;
|
||||
Projectile.extraUpdates = 1;
|
||||
spinFxOn = true;
|
||||
Projectile.tileCollide = true;
|
||||
Projectile.velocity = toMouse * throwSpeed;
|
||||
SoundStyle toss = new("CalamityMod/Sounds/Item/LightThrow");
|
||||
SoundEngine.PlaySound(toss with { Volume = 0.8f, Pitch = -0.3f }, Projectile.Center);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
resetAll = true;
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
Projectile.localNPCImmunity[i] = 0;
|
||||
|
||||
mode = gunState.NotThrown;
|
||||
Projectile.extraUpdates = 0;
|
||||
Projectile.numHits = 0;
|
||||
firedThisFrame = false;
|
||||
hasFiredBulletEver = false;
|
||||
firingEffectDisableTimer = 0;
|
||||
throwSpeed = 0;
|
||||
holdoutOffset = 0;
|
||||
tryShooting = true;
|
||||
soundToss = true;
|
||||
resetIframes = true;
|
||||
Owner.itemTime = Owner.itemAnimation = 0;
|
||||
time = 0;
|
||||
}
|
||||
public override void AI()
|
||||
{
|
||||
if (hitStop > 0)
|
||||
{
|
||||
Projectile.timeLeft++; hitStop--;
|
||||
if (hitStop == 0) { Projectile.extraUpdates = 2; }
|
||||
Projectile.rotation += 0.75f * initialDirection;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (Owner.Calamity().mouseRight || rightClicking == 1)
|
||||
rightClicking = 1;
|
||||
else
|
||||
rightClicking = 0;
|
||||
if (time == 0) // On spawn
|
||||
{
|
||||
resetAll = false;
|
||||
bool canStealth = Owner.Calamity().StealthStrikeAvailable();
|
||||
if (canStealth)
|
||||
Projectile.Calamity().stealthStrike = true;
|
||||
mode = (canStealth && rightClicking == 0) ? gunState.Stealth : gunState.NotThrown;
|
||||
throwSpeed = Owner.HeldItem.shootSpeed;
|
||||
}
|
||||
if (firedThisFrame && firingEffectDisableTimer < disableTimerMax)
|
||||
{
|
||||
firingEffectDisableTimer++;
|
||||
spinFx = 0;
|
||||
Lighting.AddLight(Projectile.Center, Color.Khaki.ToVector3() * 0.9f);
|
||||
}
|
||||
if (firingEffectDisableTimer >= disableTimerMax)
|
||||
{
|
||||
firedThisFrame = false;
|
||||
if (mode == gunState.Stealth)
|
||||
recoilRotation = 0.001f;
|
||||
else
|
||||
recoilRotation = -MathHelper.PiOver4 / 2;
|
||||
firingEffectDisableTimer = 0;
|
||||
}
|
||||
|
||||
Vector2 toMouse = Owner.Center.DirectionTo(Owner.Calamity().mouseWorld);
|
||||
int animationTimeMax = Owner.HeldItem.useAnimation * 2;
|
||||
int returnTime = 30 + animationTimeMax;
|
||||
|
||||
Held(toMouse, returnTime, animationTimeMax);
|
||||
|
||||
Thrown(toMouse, returnTime, animationTimeMax);
|
||||
|
||||
if (resetAll)
|
||||
return;
|
||||
|
||||
if (Projectile.soundDelay <= 0 && spinFx > 0.3f) // Spin sounds
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item7 with { MaxInstances = -1 }, Projectile.Center);
|
||||
Projectile.soundDelay = 5 * Projectile.MaxUpdates;
|
||||
}
|
||||
|
||||
holdoutOffset = MathHelper.Lerp(holdoutOffset, 0, 0.185f);
|
||||
if (recoilRotation != 0)
|
||||
recoilRotation = MathHelper.Lerp(recoilRotation, mode == gunState.Stealth ? (-MathHelper.PiOver4 * (1.3f + 0.03f * recoilLifetime)) : 0, 0.245f);
|
||||
if (!firedThisFrame)
|
||||
spinFx = MathHelper.Lerp(spinFx, spinFxOn ? 1 : 0, 0.28f);
|
||||
Projectile.scale = MathHelper.Lerp(Projectile.scale, shouldDie ? 0 : 1, 0.28f);
|
||||
if (recoilLifetime > 0)
|
||||
rumble = MathHelper.Lerp(rumble, 0, 0.06f);
|
||||
if (shouldDie)
|
||||
{
|
||||
if (Projectile.scale <= 0.05f)
|
||||
{ Projectile.Kill(); return; }
|
||||
time--;
|
||||
}
|
||||
if (tileHits >= 3)
|
||||
Projectile.tileCollide = false;
|
||||
|
||||
Projectile.timeLeft++;
|
||||
if (recoilLifetime > 0)
|
||||
recoilLifetime++;
|
||||
time++;
|
||||
}
|
||||
public void FireShot(Vector2 velocity, bool recoil = false, float damageMult = 1, bool elephant = false)
|
||||
{
|
||||
holdoutOffset = 15;
|
||||
Owner.SetScreenshake(3.5f + damageMult);
|
||||
firedThisFrame = true;
|
||||
hasFiredBulletEver = true;
|
||||
SoundStyle fire = new("CalamityMod/Sounds/Item/ElephantKillerShot");
|
||||
SoundEngine.PlaySound(fire with { Volume = 0.9f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) - (elephant ? 0.6f : 0), MaxInstances = 3 }, Projectile.Center);
|
||||
if (elephant)
|
||||
{
|
||||
SoundStyle fire3 = new("CalamityMod/Sounds/Item/ElephantKillerShot");
|
||||
SoundEngine.PlaySound(fire3 with { Volume = 0.9f, Pitch = 0.4f, MaxInstances = 3 }, Projectile.Center);
|
||||
}
|
||||
if (recoil)
|
||||
Owner.velocity -= velocity * 2.25f * damageMult * (elephant ? 1.5f : 1);
|
||||
|
||||
if (elephant)
|
||||
{
|
||||
for (int x = 0; x < Main.maxProjectiles; x++)
|
||||
{
|
||||
Projectile projectile = Main.projectile[x];
|
||||
if (projectile.owner == Projectile.owner && projectile.active && projectile.type == ModContent.ProjectileType<ElephantKillerElephant>())
|
||||
{
|
||||
projectile.timeLeft = 90;
|
||||
}
|
||||
}
|
||||
Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), Projectile.Center, velocity * Owner.HeldItem.shootSpeed * 2, ModContent.ProjectileType<ElephantKillerElephant>(), 0, 0, Owner.whoAmI);
|
||||
}
|
||||
else
|
||||
{
|
||||
float elephantDistance = 0;
|
||||
bool elephantBoosted = false;
|
||||
if (recoil) // Check if you shot an elephant
|
||||
{
|
||||
for (int x = 0; x < Main.maxProjectiles; x++)
|
||||
{
|
||||
Projectile projectile = Main.projectile[x];
|
||||
if (projectile.owner == Projectile.owner && projectile.active && projectile.type == ModContent.ProjectileType<ElephantKillerElephant>())
|
||||
{
|
||||
float _ = float.NaN;
|
||||
bool elephantCollide = Collision.CheckAABBvLineCollision(projectile.Hitbox.TopLeft(), projectile.Hitbox.Size(), Projectile.Center, Projectile.Center + velocity * 2500, 10 * Projectile.scale, ref _);
|
||||
if (Projectile.Hitbox.Intersects(projectile.Hitbox))
|
||||
{
|
||||
elephantCollide = true;
|
||||
_ = Projectile.width;
|
||||
}
|
||||
if (elephantCollide)
|
||||
{
|
||||
elephantDistance = _;
|
||||
Vector2 hitPoint = Projectile.Center + velocity * _;
|
||||
makeHitEffects(velocity, 2, hitPoint, projectile.whoAmI, false);
|
||||
elephantBoosted = true;
|
||||
Vector2 adjustedHitPoint = hitPoint + velocity * 15;
|
||||
projectile.ai[1] = adjustedHitPoint.X;
|
||||
projectile.ai[2] = adjustedHitPoint.Y;
|
||||
projectile.localAI[0] = velocity.ToRotation();
|
||||
projectile.localAI[1] = 2.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int index = 0; index < Main.npc.Length; index++)
|
||||
{
|
||||
NPC target = Main.npc[index];
|
||||
if (!target.dontTakeDamage && target.active && target.life > 0)
|
||||
{
|
||||
float _ = float.NaN;
|
||||
bool collides = Collision.CheckAABBvLineCollision(target.Hitbox.TopLeft(), target.Hitbox.Size(), Projectile.Center, Projectile.Center + velocity * 2500, 10 * Projectile.scale, ref _);
|
||||
if (Projectile.Hitbox.Intersects(target.Hitbox))
|
||||
{
|
||||
collides = true;
|
||||
_ = Projectile.width;
|
||||
}
|
||||
Vector2 hitPoint = Projectile.Center + velocity * _;
|
||||
if (collides)
|
||||
{
|
||||
bool isAfterElephantHit = (elephantBoosted && _ >= elephantDistance);
|
||||
int damage = (int)(Projectile.damage * (isAfterElephantHit ? elephantBoostedShotDamageMult : damageMult));
|
||||
Projectile bullet = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), hitPoint, Vector2.Zero, ModContent.ProjectileType<DirectStrike>(), damage, 0, Owner.whoAmI, target.whoAmI);
|
||||
bullet.DamageType = RogueDamageClass.Instance;
|
||||
//bullet.Calamity().stealthStrike = isAfterElephantHit; // Turn bullets shot through the Elephant into stealth strikes
|
||||
|
||||
makeHitEffects(velocity, damageMult, hitPoint, elephantBoosted: isAfterElephantHit);
|
||||
|
||||
if (damageMult > 0.25f) // Loose 15% damage every hit, min of 25% original damage
|
||||
damageMult -= 0.15f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void makeHitEffects(Vector2 velocity, float damageMult, Vector2 hitPoint, int shotElephantID = -50, bool elephantBoosted = false)
|
||||
{
|
||||
bool shotElephant = shotElephantID != -50;
|
||||
bool blue = (shotElephant || !ChildSafety.Disabled);
|
||||
Color flashColor = (elephantBoosted || shotElephant) ? Color.CornflowerBlue : Color.Khaki;
|
||||
if (elephantBoosted)
|
||||
{
|
||||
velocity *= 1.3f;
|
||||
Owner.SetScreenshake(6f);
|
||||
float falloff = Math.Min(MathF.Pow(damageMult, 3), 1);
|
||||
SoundStyle bigHit = new("CalamityMod/Sounds/NPCHit/ThanatosHitClosed3");
|
||||
SoundEngine.PlaySound(bigHit with { Volume = 0.8f * falloff, Pitch = Main.rand.NextFloat(1.2f, 1.3f) * falloff, MaxInstances = -1 }, hitPoint);
|
||||
SoundStyle bigHit2 = new("CalamityMod/Sounds/NPCHit/ExoHit4");
|
||||
SoundEngine.PlaySound(bigHit2 with { Volume = 0.8f * falloff, Pitch = Main.rand.NextFloat(0.6f, 0.75f) * falloff, MaxInstances = -1 }, hitPoint);
|
||||
}
|
||||
for (int y = 0; y < ((shotElephant || elephantBoosted) ? 2 : 1); y++)
|
||||
{
|
||||
if (y == 1)
|
||||
{
|
||||
velocity *= -1;
|
||||
if (!elephantBoosted)
|
||||
{
|
||||
float lastCollisionDistance = float.NaN;
|
||||
Projectile elephant = Main.projectile[shotElephantID];
|
||||
Vector2 lineStartPoint = hitPoint - velocity * 600;
|
||||
bool collides = Collision.CheckAABBvLineCollision(elephant.Hitbox.TopLeft(), elephant.Hitbox.Size(), lineStartPoint, hitPoint, 10 * Projectile.scale, ref lastCollisionDistance);
|
||||
|
||||
hitPoint = lineStartPoint + velocity * lastCollisionDistance;
|
||||
}
|
||||
}
|
||||
Vector2 displayHitPoint = hitPoint + velocity * 25;
|
||||
|
||||
Particle bloom = new CustomSpark(displayHitPoint - velocity * 8, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(7, 8 + 1), Main.rand.NextFloat(0.3f, 0.35f) * 1.5f * damageMult, flashColor, new Vector2(1f, 1f), true, true, glowOpacity: 0.7f, colorFadeSpeed: 10);
|
||||
GeneralParticleHandler.SpawnParticle(bloom, true);
|
||||
if (elephantBoosted && y == 0)
|
||||
{
|
||||
Vector2 spawnPoint = displayHitPoint - velocity * 16;
|
||||
float spins = Main.rand.NextFloat(0.02f, 0.06f) * (Main.rand.NextBool() ? 1 : -1);
|
||||
for (int i = 0; i <= 1; i++) // twice
|
||||
{
|
||||
Particle bloom2 = new CustomSpark(spawnPoint, Vector2.Zero, "CalamityMod/Particles/HalfStar", false, 10, 4f * damageMult, flashColor, new Vector2(1.5f, 0.4f), true, true, glowOpacity: 0.7f, colorFadeSpeed: 10, shrinkSpeed: 1.5f, extraRotation: MathHelper.PiOver2 * i, spin: spins);
|
||||
GeneralParticleHandler.SpawnParticle(bloom2, true);
|
||||
}
|
||||
float scale = 0.01f;
|
||||
Particle pulse = new CustomPulse(spawnPoint, Vector2.Zero, flashColor, "CalamityMod/Particles/HigResThinCircle", Vector2.One, 0, damageMult * scale, 4f * damageMult * scale, 35);
|
||||
GeneralParticleHandler.SpawnParticle(pulse, true);
|
||||
Particle pulse2 = new CustomPulse(spawnPoint, Vector2.Zero, flashColor, "CalamityMod/Particles/HigResThinCircle", Vector2.One, 0, damageMult * scale, 6f * damageMult * scale, 22);
|
||||
GeneralParticleHandler.SpawnParticle(pulse2, true);
|
||||
|
||||
}
|
||||
|
||||
if ((!shotElephant && y == 0) || (y == 1 && !elephantBoosted))
|
||||
{
|
||||
for (int i = 0; i < (int)(12 * damageMult); i++)
|
||||
{
|
||||
Vector2 bloodVel = !shotElephant ? velocity : -velocity;
|
||||
Color clr = blue ? (Main.rand.NextBool(3) ? Color.DodgerBlue : Color.CornflowerBlue) : (Main.rand.NextBool(3) ? Color.DarkRed : Color.Maroon);
|
||||
|
||||
int dustType = blue ? ModContent.DustType<SquashDustPixelated>() : DustID.Blood;
|
||||
bool spread = Main.rand.NextBool();
|
||||
Vector2 dustVel = bloodVel.RotatedBy(spread ? ((Main.rand.NextBool() ? -1 : 1) * Main.rand.NextFloat(0.2f, 0.6f)) : 0) * Main.rand.NextFloat(8.5f, 18.5f) * damageMult * (spread ? 0.6f : 1);
|
||||
Dust dust = Dust.NewDustPerfect(displayHitPoint + (spread? Vector2.Zero : Main.rand.NextVector2Circular(6, 6)) * damageMult, dustType, dustVel, Main.rand.Next(10, 120), default, Main.rand.NextFloat(0.9f, 1.4f) * damageMult);
|
||||
dust.noGravity = true;
|
||||
if (blue)
|
||||
{
|
||||
dust.alpha = 200;
|
||||
dust.scale *= 0.75f;
|
||||
dust.fadeIn = 2.5f;
|
||||
dust.color = clr;
|
||||
dust.noLight = true;
|
||||
dust.noLightEmittence = true;
|
||||
}
|
||||
float speedMult = Main.rand.NextFloat(0, 1f);
|
||||
Particle spark = new CustomSpark(displayHitPoint, bloodVel.RotateRandom((1 - speedMult) * 0.12f) * 10 * (speedMult + 0.25f) * damageMult, "CalamityMod/Particles/" + (Main.rand.NextBool() ? "FadeLine" : "GlowOrbParticle"), false, Main.rand.Next(7, 11 + 1), Main.rand.NextFloat(0.2f, 0.4f) * 2f * damageMult, clr, new Vector2(1.5f, 1f), blue ? true : false, shrinkSpeed: 0.6f, colorFadeSpeed: 10);
|
||||
GeneralParticleHandler.SpawnParticle(spark, true);
|
||||
}
|
||||
}
|
||||
|
||||
int effects = 4;
|
||||
for (int i = -effects; i <= effects; i++)
|
||||
{
|
||||
if (i == 0) i++;
|
||||
bool glow = MathF.Abs(i) == 2;
|
||||
Color clr = Main.rand.NextBool(3, 4) ? new Color(114, 112, 116) : new Color(216, 216, 216);
|
||||
Vector2 vel = -velocity.RotatedBy(MathHelper.PiOver2 * (elephantBoosted ? 0.1f : 0.4f) * (y == 1 ? 0.25f : 1) * Math.Sign(i)).RotatedByRandom(glow ? 0 : 0.35f) * Main.rand.NextFloat(5, 14);
|
||||
Particle spark = new CustomSpark(displayHitPoint + vel * (glow ? 5f : 3f) * damageMult, vel * (y == 1 ? 1.5f : 1), "CalamityMod/Particles/" + (!glow ? "FadeLine" : "ForwardSmear"), false, (int)(Main.rand.Next(29, 35 + 1) * (glow ? 0.3f : 1)), Main.rand.NextFloat(0.2f, 0.3f) * (glow ? 0.3f : 2f) * damageMult, glow ? flashColor : clr, new Vector2(glow ? 1.5f : 0.8f, 1f), glow, shrinkSpeed: glow ? 0.7f : 0.35f, colorFadeSpeed: 10);
|
||||
GeneralParticleHandler.SpawnParticle(spark, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void CheckStealth()
|
||||
{
|
||||
if (Owner.Calamity().rogueStealth > Owner.Calamity().rogueStealthMax)
|
||||
Owner.Calamity().rogueStealth = Owner.Calamity().rogueStealthMax;
|
||||
if (Owner.Calamity().rogueStealth < 0)
|
||||
Owner.Calamity().rogueStealth = 0;
|
||||
}
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
if (Projectile.numHits == 0)
|
||||
{
|
||||
throwCollideEffects();
|
||||
Projectile.extraUpdates = 0;
|
||||
Owner.Calamity().rogueStealth += Owner.Calamity().rogueStealthMax * 0.25f; // Give 25% of max on hit
|
||||
CheckStealth();
|
||||
mode = gunState.Returning;
|
||||
Projectile.velocity = new Vector2(-Math.Sign(Projectile.Center.DirectionTo(target.Center).X) * Projectile.velocity.Length() / 2, -18 * Math.Sign(Projectile.Center.DirectionTo(target.Center).Y));
|
||||
}
|
||||
}
|
||||
public void throwCollideEffects()
|
||||
{
|
||||
Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, new Color(114, 112, 116), "CalamityMod/Particles/HigResThinCircle", Vector2.One, 0, 0.03f, 0.05f, 10, false);
|
||||
GeneralParticleHandler.SpawnParticle(pulse, true);
|
||||
SoundStyle bigHit2 = new("CalamityMod/Sounds/NPCHit/ExoHit3");
|
||||
SoundEngine.PlaySound(bigHit2 with { Volume = 0.4f, Pitch = Main.rand.NextFloat(0.3f, 0.5f) + tileHits * 0.1f, MaxInstances = -1 }, Projectile.Center);
|
||||
hitStop = Math.Max(5 - tileHits * 2, 0);
|
||||
}
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
throwCollideEffects();
|
||||
if (Projectile.numHits == 0)
|
||||
Projectile.numHits += 1;
|
||||
tileHits++;
|
||||
if (Projectile.velocity.X != oldVelocity.X)
|
||||
{
|
||||
Projectile.velocity.X = -oldVelocity.X;
|
||||
}
|
||||
if (Projectile.velocity.Y != oldVelocity.Y)
|
||||
{
|
||||
Projectile.velocity.Y = -oldVelocity.Y;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
float damageMult = MathHelper.Clamp(Utils.GetLerpValue(8, 1, Projectile.numHits), 0.4f, 1);
|
||||
modifiers.SourceDamage *= damageMult;
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Asset<Texture2D> tex = ModContent.Request<Texture2D>( firedThisFrame ? "CalamityMod/Projectiles/Rogue/ElephantKillerFlash" : "CalamityMod/Items/Weapons/Rogue/ElephantKiller");
|
||||
Asset<Texture2D> p = ModContent.Request<Texture2D>("CalamityMod/Particles/CircularSmearLarge");
|
||||
Asset<Texture2D> flash = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle");
|
||||
Asset<Texture2D> flashTip = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomLineFade");
|
||||
Asset<Texture2D> shineTip = ModContent.Request<Texture2D>("CalamityMod/Particles/FullStar");
|
||||
|
||||
Vector2 generalDrawPos = Projectile.Center - Main.screenPosition + Main.rand.NextVector2Circular(rumble, rumble);
|
||||
PixelationManager.AddPixelatedDrawer((_) =>
|
||||
{
|
||||
if (spinFx > 0.001f)
|
||||
{
|
||||
float scale = 0.19f;
|
||||
Color dark = Lighting.GetColor(Projectile.Center.ToTileCoordinates()).MultiplyRGB(new Color(24, 20, 37));
|
||||
Color light = Lighting.GetColor(Projectile.Center.ToTileCoordinates()).MultiplyRGB(new Color(114, 112, 116));
|
||||
Color shine = Lighting.GetColor(Projectile.Center.ToTileCoordinates()).MultiplyRGB(new Color(216, 216, 216));
|
||||
Main.EntitySpriteDraw(p.Value, generalDrawPos, null, light * spinFx, Projectile.rotation * Main.rand.NextFloat(3.9f, 4.2f), p.Size() * 0.5f, Projectile.scale * 0.55f * scale * Main.rand.NextFloat(0.95f, 1.05f), SpriteEffects.None);
|
||||
Main.EntitySpriteDraw(p.Value, generalDrawPos, null, shine * spinFx, Projectile.rotation * Main.rand.NextFloat(1.2f, 1.3f), p.Size() * 0.5f, Projectile.scale * 0.45f * scale, SpriteEffects.None);
|
||||
Main.EntitySpriteDraw(p.Value, generalDrawPos, null, dark * spinFx, Projectile.rotation * Main.rand.NextFloat(0.7f, 0.8f), p.Size() * 0.5f, Projectile.scale * 0.4f * scale * Main.rand.NextFloat(0.95f, 1.05f), SpriteEffects.None);
|
||||
}
|
||||
}, Enums.GeneralDrawLayer.BeforeProjectiles, BlendState.NonPremultiplied);
|
||||
|
||||
Main.EntitySpriteDraw(tex.Value, generalDrawPos + Main.rand.NextVector2Circular(hitStop * 2, hitStop * 2), null, lightColor, Projectile.rotation, tex.Size() / 2f, Projectile.scale, initialDirection == -1 ? SpriteEffects.FlipVertically : SpriteEffects.None, 0);
|
||||
|
||||
if (firedThisFrame)
|
||||
{
|
||||
PixelationManager.AddPixelatedDrawer((_) =>
|
||||
{
|
||||
float scale = (0.35f + firingEffectDisableTimer * 0.22f) * (mode == gunState.Stealth ? 2 : 1);
|
||||
float flashFade = !firedThisFrame ? 0 : MathF.Pow(Utils.GetLerpValue(disableTimerMax, 0, firingEffectDisableTimer, true), 3);
|
||||
float flashMult = Utils.GetLerpValue(0, disableTimerMax, firingEffectDisableTimer, true) * 5;
|
||||
|
||||
Vector2 vel = Projectile.rotation.ToRotationVector2();
|
||||
Vector2 gunTipPostion = generalDrawPos + vel * (30 + flashMult * 4.5f) - vel.RotatedBy(MathHelper.PiOver2 * initialDirection) * 5;
|
||||
for (int i = 0; i < 2; i++)
|
||||
Main.EntitySpriteDraw(flash.Value, gunTipPostion, null, Color.Khaki with { A = 0 } * 0.8f * Utils.GetLerpValue(disableTimerMax, 0, firingEffectDisableTimer, true), Projectile.rotation, flash.Size() * 0.5f, Projectile.scale * scale * (i == 0 ? 1 : 0.75f), SpriteEffects.None);
|
||||
for (int i = -1; i <= 1; i++) // 3
|
||||
{
|
||||
Vector2 squash = new Vector2(0.9f * flashFade, 0.9f + 0.9f * (1 - flashFade) - Math.Abs(i) * 0.45f) * 0.15f;
|
||||
Main.EntitySpriteDraw(flashTip.Value, gunTipPostion, null, Color.Khaki with { A = 0 } * (0.6f - 0.15f * flashMult), Projectile.rotation + MathHelper.PiOver2 + MathHelper.PiOver4 * i * flashFade, new Vector2(flashTip.Width() / 2, flashTip.Height()), squash * Projectile.scale * scale, SpriteEffects.None);
|
||||
}
|
||||
}, Enums.GeneralDrawLayer.AfterProjectiles, default);
|
||||
}
|
||||
if (mode == gunState.Stealth)
|
||||
{
|
||||
PixelationManager.AddPixelatedDrawer((_) =>
|
||||
{
|
||||
float scale = 0.5f + 1.3f * shineProgress;
|
||||
|
||||
Vector2 vel = Projectile.rotation.ToRotationVector2();
|
||||
Vector2 gunTipPostion = generalDrawPos + vel * (MathHelper.Lerp(-15, 30, shineProgress)) - vel.RotatedBy(MathHelper.PiOver2 * initialDirection) * 9;
|
||||
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
Vector2 squash = new Vector2(1f - 0.7f * i * shineProgress, 1 + 0.7f * i * shineProgress) * scale;
|
||||
Main.EntitySpriteDraw(shineTip.Value, gunTipPostion, null, (i == 0 ? Color.White : new Color(216, 216, 216)) with { A = 0 } * 0.8f * shineOpacity, Projectile.rotation + MathHelper.Pi * shineProgress, shineTip.Size() * 0.5f, squash * Projectile.scale * (i == 0 ? 0.5f : 1f), SpriteEffects.None);
|
||||
}
|
||||
}, Enums.GeneralDrawLayer.AfterEverything, default);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
Mods.CalamityMod.Projectiles.V8000SoulVisual.DisplayName: V8000 Soul Visual
|
||||
Reference in new issue
Block a user