Files
CalamityModPublic/Projectiles/Rogue/ShroomerangProj.cs
T

69 lines
2.6 KiB
C#

using CalamityMod.Buffs.StatBuffs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class ShroomerangProj : ModProjectile
{
public int stealthCounter = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Shroomerang");
}
public override void SetDefaults()
{
projectile.width = 30;
projectile.height = 30;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.aiStyle = 3;
projectile.timeLeft = 300;
aiType = 52;
projectile.Calamity().rogue = true;
}
public override void AI()
{
Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0.5f / 255f);
if (Main.rand.NextBool(5))
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 56, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);
}
if (projectile.Calamity().stealthStrike == true)
{
stealthCounter++;
if (stealthCounter == 15 && projectile.owner == Main.myPlayer)
{
Vector2 vector62 = Main.player[projectile.owner].Center - projectile.Center;
stealthCounter = 0;
Vector2 vector63 = vector62 * -1f;
vector63.Normalize();
vector63 *= (float)Main.rand.Next(45, 65) * 0.1f;
vector63 = vector63.RotatedBy((Main.rand.NextDouble() - 0.5) * 1.5707963705062866, default);
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector63.X, vector63.Y, ModContent.ProjectileType<ShroomerangSpore>(), (int)((double)projectile.damage * 0.1), projectile.knockBack * 0.2f, projectile.owner, -10f, 0f);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D tex = Main.projectileTexture[projectile.type];
spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
Player player = Main.player[projectile.owner];
if (projectile.Calamity().stealthStrike == true)
player.AddBuff(ModContent.BuffType<Mushy>(), 720);
}
}
}