62 lines
2.6 KiB
C#
62 lines
2.6 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class CrystallineProj : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Rogue";
|
|
public override string Texture => "CalamityMod/Items/Weapons/Rogue/Crystalline";
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = Projectile.height = 20;
|
|
Projectile.friendly = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.aiStyle = ProjAIStyleID.StickProjectile;
|
|
Projectile.timeLeft = 120;
|
|
AIType = ProjectileID.BoneJavelin;
|
|
Projectile.DamageType = RogueDamageClass.Instance;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f);
|
|
Projectile.ai[1] += 1f;
|
|
if (Projectile.ai[1] == 30f)
|
|
{
|
|
int numProj = 2;
|
|
float rotation = MathHelper.ToRadians(50);
|
|
if (Projectile.owner == Main.myPlayer)
|
|
{
|
|
for (int i = 0; i < numProj + 1; i++)
|
|
{
|
|
float AI1 = Projectile.Calamity().stealthStrike ? 1f : 0f;
|
|
Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1)));
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType<Crystalline2>(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, 0f, AI1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
|
|
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
|
|
return false;
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item27, Projectile.position);
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Rain, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
}
|
|
}
|
|
}
|