87 lines
3.5 KiB
C#
87 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles
|
|
{
|
|
public class SpatialLanceProjectile : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Lance");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 40; //The width of the .png file in pixels divided by 2.
|
|
projectile.aiStyle = 19;
|
|
projectile.melee = true; //Dictates whether this is a melee-class weapon.
|
|
projectile.timeLeft = 90;
|
|
projectile.height = 40; //The height of the .png file in pixels divided by 2.
|
|
projectile.friendly = true;
|
|
projectile.hostile = false;
|
|
projectile.tileCollide = false;
|
|
projectile.ignoreWater = true;
|
|
projectile.penetrate = -1;
|
|
projectile.ownerHitCheck = true;
|
|
projectile.hide = true;
|
|
projectile.usesLocalNPCImmunity = true;
|
|
projectile.localNPCHitCooldown = 3;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Main.player[projectile.owner].direction = projectile.direction;
|
|
Main.player[projectile.owner].heldProj = projectile.whoAmI;
|
|
Main.player[projectile.owner].itemTime = Main.player[projectile.owner].itemAnimation;
|
|
projectile.position.X = Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2) - (float)(projectile.width / 2);
|
|
projectile.position.Y = Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2) - (float)(projectile.height / 2);
|
|
projectile.position += projectile.velocity * projectile.ai[0];
|
|
if (Main.rand.Next(5) == 0)
|
|
{
|
|
int num = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f);
|
|
Main.dust[num].noGravity = true;
|
|
}
|
|
if(projectile.ai[0] == 0f)
|
|
{
|
|
projectile.ai[0] = 3f;
|
|
projectile.netUpdate = true;
|
|
}
|
|
if(Main.player[projectile.owner].itemAnimation < Main.player[projectile.owner].itemAnimationMax / 3)
|
|
{
|
|
projectile.ai[0] -= 2.4f;
|
|
if (projectile.localAI[0] == 0f && Main.myPlayer == projectile.owner)
|
|
{
|
|
projectile.localAI[0] = 1f;
|
|
Projectile.NewProjectile(projectile.Center.X + projectile.velocity.X * projectile.ai[0], projectile.Center.Y + projectile.velocity.Y * projectile.ai[0], projectile.velocity.X * 1.4f, projectile.velocity.Y * 1.4f, mod.ProjectileType("SpatialSpear"), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
projectile.ai[0] += 0.95f;
|
|
}
|
|
|
|
if(Main.player[projectile.owner].itemAnimation == 0)
|
|
{
|
|
projectile.Kill();
|
|
}
|
|
|
|
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 2.355f;
|
|
if(projectile.spriteDirection == -1)
|
|
{
|
|
projectile.rotation -= 1.57f;
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
target.AddBuff(mod.BuffType("BrimstoneFlames"), 300);
|
|
target.AddBuff(mod.BuffType("GlacialState"), 300);
|
|
target.AddBuff(mod.BuffType("Plague"), 300);
|
|
target.AddBuff(mod.BuffType("HolyLight"), 300);
|
|
}
|
|
}
|
|
} |