Start of magic fish
This commit is contained in:
1 parent
8ba2beed85
commit
60173cedcf
3 files changed
+245
-219
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using CalamityMod.Projectiles.Magic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -9,32 +10,34 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches
|
||||
public class SparklingEmpress : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Fishing";
|
||||
public static int BaseDamage = 10;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Item.staff[Type] = true; //so it doesn't look weird af when holding it
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 44;
|
||||
Item.height = 44;
|
||||
Item.damage = BaseDamage;
|
||||
Item.damage = 11;
|
||||
Item.DamageType = DamageClass.Magic;
|
||||
Item.mana = 5;
|
||||
Item.useAnimation = Item.useTime = 20;
|
||||
Item.mana = 3;
|
||||
Item.useAnimation = Item.useTime = 10;
|
||||
Item.knockBack = 0.25f;
|
||||
Item.shoot = ModContent.ProjectileType<SparklingLaser>();
|
||||
Item.shootSpeed = 14f;
|
||||
Item.shoot = ModContent.ProjectileType<SparklingEmpressHoldout>();
|
||||
Item.shootSpeed = 5f;
|
||||
|
||||
Item.UseSound = SoundID.Item13;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.channel = true; //Channel so that you can hold the weapon [Important]
|
||||
Item.channel = true;
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.autoReuse = true;
|
||||
|
||||
Item.rare = ItemRarityID.Green;
|
||||
Item.value = CalamityGlobalItem.RarityGreenBuyPrice;
|
||||
}
|
||||
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0;
|
||||
public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = 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, Item.shoot, damage, knockback, player.whoAmI);
|
||||
holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using CalamityMod.Items.Fishing.SunkenSeaCatches;
|
||||
using CalamityMod.Items.Weapons.Magic;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class SparklingEmpressHoldout : BaseGunHoldoutProjectile
|
||||
{
|
||||
public override int AssociatedItemID => ModContent.ItemType<SparklingEmpress>();
|
||||
public override Vector2 GunTipPosition => base.GunTipPosition - Vector2.UnitX.RotatedBy(Projectile.rotation) * -3;
|
||||
public override float MaxOffsetLengthFromArm => 40f;
|
||||
public override float OffsetXUpwards => 0f;
|
||||
public override float BaseOffsetY => 0f;
|
||||
public override float OffsetYDownwards => 0f;
|
||||
public override float RecoilResolveSpeed => 0.5f;
|
||||
public override float WeaponTurnSpeed => 0.05f;
|
||||
|
||||
public ref float shootingTimer => ref Projectile.ai[0];
|
||||
public ref float completion => ref Projectile.ai[1];
|
||||
public Color EffectsColor = Color.Cyan;
|
||||
public bool hasLetGo = false;
|
||||
public int time = 0;
|
||||
public int postFireTimer = 0;
|
||||
public bool deservesKiss = false;
|
||||
public Vector2 storedPos;
|
||||
public int cooldownTime => 20 * (deservesKiss ? 2 : 1);
|
||||
|
||||
public override void KillHoldoutLogic()
|
||||
{
|
||||
if (HeldItem.type != Owner.ActiveItem().type)
|
||||
Projectile.Kill();
|
||||
if (Owner.CantUseHoldout() && !hasLetGo)
|
||||
postFireTimer = cooldownTime;
|
||||
}
|
||||
|
||||
public override void HoldoutAI()
|
||||
{
|
||||
if (!hasLetGo)
|
||||
{
|
||||
if (shootingTimer >= (deservesKiss ? 5 : 3))
|
||||
{
|
||||
if (Owner.CheckMana(HeldItem, -1, true, false))
|
||||
{
|
||||
Shoot();
|
||||
shootingTimer = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.MaxMana with { Pitch = -0.5f }, Projectile.Center);
|
||||
postFireTimer = cooldownTime;
|
||||
}
|
||||
}
|
||||
|
||||
shootingTimer++;
|
||||
|
||||
if (time >= 120)
|
||||
deservesKiss = true;
|
||||
if (time == 120)
|
||||
{
|
||||
SoundStyle f = new("CalamityMod/Sounds/Item/MeldShoot");
|
||||
SoundEngine.PlaySound(f with { Volume = 0.5f, Pitch = 0.95f }, Projectile.Center);
|
||||
for (int k = 0; k < 14; k++)
|
||||
{
|
||||
Vector2 shootVel = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(5.1f, 8.8f);
|
||||
|
||||
Dust dust2 = Dust.NewDustPerfect(GunTipPosition, Main.rand.NextBool(4) ? 267 : 66, shootVel);
|
||||
dust2.scale = Main.rand.NextFloat(1.15f, 1.45f);
|
||||
dust2.noGravity = true;
|
||||
dust2.color = Main.rand.NextBool() ? Color.Lerp(EffectsColor, Color.White, 0.5f) : EffectsColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
time++;
|
||||
|
||||
if (postFireTimer > 0)
|
||||
PostFireEffect();
|
||||
}
|
||||
public void PostFireEffect()
|
||||
{
|
||||
if (!hasLetGo)
|
||||
{
|
||||
storedPos = Projectile.Center;
|
||||
}
|
||||
hasLetGo = true;
|
||||
|
||||
if (deservesKiss && postFireTimer % 8 == 0)
|
||||
{
|
||||
int manaGained = 24;
|
||||
Owner.statMana += manaGained;
|
||||
if (Main.myPlayer == Owner.whoAmI)
|
||||
Owner.ManaEffect(manaGained);
|
||||
|
||||
if (Owner.statMana > Owner.statManaMax2)
|
||||
Owner.statMana = Owner.statManaMax2;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Particle spark = new CustomSpark(GunTipPosition, (-Vector2.UnitY * Main.rand.NextFloat(3f, 5f)).RotatedByRandom(0.6f), "CalamityMod/Particles/HeartParticle", false, 45, Main.rand.NextFloat(0.9f, 1.2f), Color.Lerp(Color.Aqua, Color.DodgerBlue, i * 0.5f), Vector2.One, true, true, 0, false, false);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
OffsetLengthFromArm -= 9f;
|
||||
|
||||
SoundStyle s = new("CalamityMod/Sounds/Custom/PistolShrimpBubbleBurst");
|
||||
SoundEngine.PlaySound(s with { Volume = 0.35f, Pitch = -postFireTimer * 0.01f, MaxInstances = -1 }, Projectile.Center);
|
||||
}
|
||||
if (deservesKiss && (postFireTimer + 2) % 8 == 0)
|
||||
{
|
||||
Owner.HealPlayer(4);
|
||||
}
|
||||
if (postFireTimer == 1)
|
||||
Projectile.Kill();
|
||||
postFireTimer--;
|
||||
}
|
||||
public void Shoot()
|
||||
{
|
||||
Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero);
|
||||
Vector2 firingVelocity = (shootDirection * 4);
|
||||
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition + firingVelocity * 5, firingVelocity, ModContent.ProjectileType<SparklingLaser>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 0);
|
||||
|
||||
// Inside here go all the things that dedicated servers shouldn't spend resources on.
|
||||
// Like visuals and sounds.
|
||||
if (Main.dedServ)
|
||||
return;
|
||||
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
Vector2 shootVel = (shootDirection * 15).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 1.8f);
|
||||
|
||||
Dust dust2 = Dust.NewDustPerfect(GunTipPosition, Main.rand.NextBool(4) ? 267 : 66, shootVel);
|
||||
dust2.scale = Main.rand.NextFloat(1.15f, 1.45f);
|
||||
dust2.noGravity = true;
|
||||
dust2.color = Main.rand.NextBool() ? Color.Lerp(EffectsColor, Color.White, 0.5f) : EffectsColor;
|
||||
}
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (time < 2)
|
||||
return false;
|
||||
Vector2 toHead = Utils.DirectionTo(storedPos, Owner.Center - Vector2.UnitY * 4);
|
||||
|
||||
Texture2D texture = TextureAssets.Projectile[Type].Value;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
|
||||
Vector2 rotationPoint = texture.Size() * 0.5f;
|
||||
SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
Texture2D shineTex = ModContent.Request<Texture2D>("CalamityMod/Particles/FullStar").Value;
|
||||
|
||||
Main.EntitySpriteDraw(texture, drawPosition + (hasLetGo ? Vector2.Zero : Main.rand.NextVector2Circular(2, 2)), null, Projectile.GetAlpha(lightColor), drawRotation + (MathHelper.ToRadians(45f * (Projectile.spriteDirection))), rotationPoint, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
if (deservesKiss && !hasLetGo)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
Main.EntitySpriteDraw(shineTex, GunTipPosition - Main.screenPosition, null, Color.DodgerBlue with { A = 0 }, Projectile.rotation + MathHelper.ToRadians(45 * (i == 0 ? -1 : 1)), shineTex.Size() * 0.5f, new Vector2(0.9f, 2.5f) * Main.rand.NextFloat(0.7f, 1.1f), SpriteEffects.None, 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -6,233 +8,86 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Enums;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class SparklingLaser : BaseLaserbeamProjectile, ILocalizedModType
|
||||
public class SparklingLaser : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Magic";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public bool playedSound = false;
|
||||
public const int ChargeupTime = 50;
|
||||
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public override Color LightCastColor => new Color(204, 204, 255); //#CCCCFF
|
||||
public override float Lifetime => 18000f;
|
||||
public override float MaxScale => 1f;
|
||||
public override float MaxLaserLength => 1600f; //100 tiles
|
||||
public override Texture2D LaserBeginTexture => ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Lasers/SparklingLaserBegin", AssetRequestMode.ImmediateLoad).Value;
|
||||
public override Texture2D LaserMiddleTexture => ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Lasers/SparklingLaserMid", AssetRequestMode.ImmediateLoad).Value;
|
||||
public override Texture2D LaserEndTexture => ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Lasers/SparklingLaserEnd", AssetRequestMode.ImmediateLoad).Value;
|
||||
private const float AimResponsiveness = 0.8f; // Last Prism is 0.92f. Lower makes the laser turn faster.
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.projFrames[Type] = 5;
|
||||
}
|
||||
|
||||
public ref float time => ref Projectile.ai[0];
|
||||
public bool isSplit => Projectile.ai[1] == 5;
|
||||
public ref NPC targeted => ref Main.npc[(int)Projectile.ai[2]];
|
||||
public Color mainColor = Color.Cyan;
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 10;
|
||||
Projectile.height = 10;
|
||||
Projectile.width = 25;
|
||||
Projectile.height = 25;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Magic;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.hide = true;
|
||||
Projectile.timeLeft = 18000;
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.idStaticNPCHitCooldown = 20;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.tileCollide = true;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.ArmorPenetration = 20;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.extraUpdates = 3;
|
||||
}
|
||||
|
||||
public override void DetermineScale()
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.scale = Time < ChargeupTime ? 0f : MaxScale;
|
||||
Player Owner = Main.player[Projectile.owner];
|
||||
float targetDist = Vector2.Distance(Owner.Center, Projectile.Center);
|
||||
if (time == 0)
|
||||
{
|
||||
mainColor = Main.rand.NextBool() ? Color.Cyan : Color.DodgerBlue;
|
||||
}
|
||||
if (targetDist < 1400)
|
||||
{
|
||||
float beamSize = (isSplit ? 0.4f : 1f);
|
||||
Particle beamBody = new CustomSpark(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 65, Projectile.velocity * 0.05f, "CalamityMod/Particles/Crack", false, (int)(7 * (isSplit ? 2 : 1)), 0.15f * beamSize, mainColor * 0.7f, new Vector2(0.7f, 1.4f), true, true, extraRotation: MathHelper.ToRadians(180), shrinkSpeed: (isSplit ? 0.4f : 1.1f), glowCenterScale: 0.7f, glowOpacity: 0.4f);
|
||||
GeneralParticleHandler.SpawnParticle(beamBody);
|
||||
}
|
||||
if (isSplit)
|
||||
{
|
||||
Projectile.velocity *= 0.98f;
|
||||
}
|
||||
else if (Projectile.velocity.Length() < 9)
|
||||
{
|
||||
Projectile.velocity *= 1.01f;
|
||||
Projectile.velocity = Projectile.velocity.RotatedByRandom(0.035f);
|
||||
}
|
||||
time++;
|
||||
}
|
||||
|
||||
public override float DetermineLaserLength()
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
return DetermineLaserLength_CollideWithTiles(5);
|
||||
}
|
||||
|
||||
public override bool PreAI()
|
||||
{
|
||||
// Multiplayer support here, only run this code if the client running it is the owner of the projectile
|
||||
if (Projectile.owner == Main.myPlayer)
|
||||
if (!isSplit)
|
||||
{
|
||||
Vector2 rrp = Owner.RotatedRelativePoint(Owner.MountedCenter, true);
|
||||
UpdateAim(rrp);
|
||||
Projectile.direction = Main.MouseWorld.X > Owner.Center.X ? 1 : -1;
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
int dir = Projectile.direction;
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
Projectile.Center = Owner.Center + Projectile.velocity * 56f; //Distance offset
|
||||
Projectile.timeLeft = 18000; //Infinite lifespan
|
||||
Owner.ChangeDir(dir);
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
Owner.itemTime = 2;
|
||||
Owner.itemAnimation = 2;
|
||||
Owner.itemRotation = ((Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * -Owner.direction).ToRotation();
|
||||
|
||||
if (!Owner.channel)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return false;
|
||||
}
|
||||
// Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore
|
||||
if (Owner.miscCounter % 10 == 0 && !Owner.CheckMana(Owner.ActiveItem(), -1, true))
|
||||
{
|
||||
Projectile.Kill();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Time < ChargeupTime)
|
||||
{
|
||||
// Crate charge-up dust.
|
||||
int dustCount = (int)(Time / 20f);
|
||||
Vector2 spawnPos = Projectile.Center;
|
||||
for (int k = 0; k < dustCount + 1; k++)
|
||||
Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 7;
|
||||
Projectile splitProj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (shootDirection).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.8f, 1.2f), ModContent.ProjectileType<SparklingLaser>(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0, 5, target.whoAmI);
|
||||
splitProj.timeLeft = 120;
|
||||
splitProj.penetrate = -1;
|
||||
splitProj.extraUpdates = 2;
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
Dust dust = Dust.NewDustDirect(spawnPos, 1, 1, DustID.Electric, Projectile.velocity.X / 2f, Projectile.velocity.Y / 2f);
|
||||
dust.position += Main.rand.NextVector2Square(-10f, 10f);
|
||||
dust.velocity = Main.rand.NextVector2Unit() * (10f - dustCount * 2f) / 10f;
|
||||
dust.scale = Main.rand.NextFloat(0.5f, 1f);
|
||||
dust.noGravity = true;
|
||||
}
|
||||
Time++;
|
||||
return false;
|
||||
}
|
||||
Vector2 shootVel = (shootDirection).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 1.8f);
|
||||
|
||||
// Play a cool sound when fully charged.
|
||||
if (!playedSound)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item68, Projectile.Center);
|
||||
playedSound = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PostAI()
|
||||
{
|
||||
// Determine frames.
|
||||
Projectile.frameCounter++;
|
||||
if (Projectile.frameCounter % 5f == 4f)
|
||||
Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type];
|
||||
}
|
||||
|
||||
// Gently adjusts the aim vector of the laser to point towards the mouse.
|
||||
private void UpdateAim(Vector2 source)
|
||||
{
|
||||
// 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction
|
||||
Vector2 aimVector = Vector2.Normalize(Main.MouseWorld - source);
|
||||
if (aimVector.HasNaNs())
|
||||
aimVector = -Vector2.UnitY;
|
||||
aimVector = Vector2.Normalize(Vector2.Lerp(aimVector, Vector2.Normalize(Projectile.velocity), AimResponsiveness));
|
||||
|
||||
if (aimVector != Projectile.velocity)
|
||||
Projectile.netUpdate = true;
|
||||
Projectile.velocity = aimVector;
|
||||
}
|
||||
|
||||
public override bool ShouldUpdatePosition() => false;
|
||||
|
||||
public override bool? CanDamage() => Time >= ChargeupTime;
|
||||
|
||||
// Update CutTiles so the laser will cut tiles (like grass).
|
||||
public override void CutTiles()
|
||||
{
|
||||
DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile;
|
||||
Vector2 unit = Projectile.velocity;
|
||||
Utils.PlotTileLine(Projectile.Center, Projectile.Center + unit * LaserLength, Projectile.width + 16, DelegateMethods.CutTiles);
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
if (target.life <= 0 && target.lifeMax > 5 && Projectile.owner == Main.myPlayer)
|
||||
{
|
||||
int shardDamage = Projectile.damage / 5;
|
||||
int shardAmt = Main.rand.Next(2, 4);
|
||||
for (int s = 0; s < shardAmt; s++)
|
||||
{
|
||||
Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f);
|
||||
int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, velocity, ModContent.ProjectileType<AquashardSplit>(), shardDamage, 0f, Projectile.owner);
|
||||
if (shard.WithinBounds(Main.maxProjectiles))
|
||||
Main.projectile[shard].DamageType = DamageClass.Magic;
|
||||
Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 267 : 66, shootVel);
|
||||
dust2.scale = Main.rand.NextFloat(0.9f, 1.15f);
|
||||
dust2.noGravity = true;
|
||||
dust2.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Cyan;
|
||||
}
|
||||
}
|
||||
target.AddBuff(ModContent.BuffType<RiptideDebuff>(), (isSplit ? 60 : 120));
|
||||
|
||||
float minMult = 0.25f;
|
||||
int hitsToMinMult = 7;
|
||||
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true);
|
||||
modifiers.SourceDamage *= damageMult;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
// This should never happen, but just in case-
|
||||
if (Projectile.velocity == Vector2.Zero || Time < ChargeupTime)
|
||||
return false;
|
||||
|
||||
Color beamColor = LaserOverlayColor;
|
||||
Rectangle startFrameArea = LaserBeginTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
|
||||
Rectangle middleFrameArea = LaserMiddleTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
|
||||
Rectangle endFrameArea = LaserEndTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
|
||||
|
||||
// Start texture drawing.
|
||||
// This is a lot more scuffed than other lasers... for some reason I'll try not to think about right now.
|
||||
Vector2 laserBeginCenter = Projectile.Center - Main.screenPosition + Projectile.velocity * Projectile.scale * 50f;
|
||||
Main.EntitySpriteDraw(LaserBeginTexture,
|
||||
laserBeginCenter,
|
||||
startFrameArea,
|
||||
beamColor,
|
||||
Projectile.rotation,
|
||||
LaserBeginTexture.Size() / 2f,
|
||||
Projectile.scale,
|
||||
SpriteEffects.None,
|
||||
0);
|
||||
|
||||
// Prepare things for body drawing.
|
||||
float laserBodyLength = LaserLength;
|
||||
laserBodyLength -= (startFrameArea.Height / 2 + endFrameArea.Height) * Projectile.scale;
|
||||
Vector2 centerOnLaser = Projectile.Center - Main.screenPosition;
|
||||
centerOnLaser += Projectile.velocity * Projectile.scale * 10.5f;
|
||||
|
||||
// Body drawing.
|
||||
if (laserBodyLength > 0f)
|
||||
{
|
||||
float laserOffset = middleFrameArea.Height * Projectile.scale;
|
||||
float incrementalBodyLength = 0f;
|
||||
while (incrementalBodyLength + 1f < laserBodyLength)
|
||||
{
|
||||
centerOnLaser += Projectile.velocity * laserOffset;
|
||||
incrementalBodyLength += laserOffset;
|
||||
Main.EntitySpriteDraw(LaserMiddleTexture,
|
||||
centerOnLaser,
|
||||
middleFrameArea,
|
||||
beamColor,
|
||||
Projectile.rotation,
|
||||
LaserMiddleTexture.Width * 0.5f * Vector2.UnitX,
|
||||
Projectile.scale,
|
||||
SpriteEffects.None,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
// End texture drawing.
|
||||
if (Math.Abs(LaserLength - DetermineLaserLength()) < 30f)
|
||||
{
|
||||
Main.EntitySpriteDraw(LaserEndTexture,
|
||||
centerOnLaser,
|
||||
endFrameArea,
|
||||
beamColor,
|
||||
Projectile.rotation,
|
||||
LaserEndTexture.Frame(1, 1, 0, 0).Top(),
|
||||
Projectile.scale,
|
||||
SpriteEffects.None,
|
||||
0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool? CanHitNPC(NPC target) => (target == targeted && isSplit) ? false : null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user