109 lines
4.2 KiB
C#
109 lines
4.2 KiB
C#
using CalamityMod.CalPlayer;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Summon
|
|
{
|
|
public class Valkyrie : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Summon";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Main.projFrames[Projectile.type] = 4;
|
|
ProjectileID.Sets.MinionSacrificable[Projectile.type] = true;
|
|
ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 90;
|
|
Projectile.height = 90;
|
|
Projectile.netImportant = true;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 20;
|
|
Projectile.minionSlots = 0f;
|
|
Projectile.timeLeft = 18000;
|
|
Projectile.penetrate = -1;
|
|
Projectile.tileCollide = false;
|
|
Projectile.timeLeft *= 5;
|
|
Projectile.minion = true;
|
|
Projectile.DamageType = DamageClass.Summon;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Player player = Main.player[Projectile.owner];
|
|
CalamityPlayer modPlayer = player.Calamity();
|
|
if (!modPlayer.valkyrie)
|
|
{
|
|
Projectile.active = false;
|
|
return;
|
|
}
|
|
bool correctMinion = Projectile.type == ModContent.ProjectileType<Valkyrie>();
|
|
if (correctMinion)
|
|
{
|
|
if (player.dead)
|
|
{
|
|
modPlayer.aValkyrie = false;
|
|
}
|
|
if (modPlayer.aValkyrie)
|
|
{
|
|
Projectile.timeLeft = 2;
|
|
}
|
|
}
|
|
if (Projectile.localAI[0] == 0f)
|
|
{
|
|
int num501 = 30;
|
|
for (int num502 = 0; num502 < num501; num502++)
|
|
{
|
|
int num503 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 59, 0f, 0f, 0, default, 1f);
|
|
Main.dust[num503].velocity *= 2f;
|
|
Main.dust[num503].scale *= 1.15f;
|
|
}
|
|
Projectile.localAI[0] += 1f;
|
|
}
|
|
|
|
//Adjust sprite direction so it faces correctly
|
|
if (Math.Abs(Projectile.velocity.X) > 0.2f)
|
|
{
|
|
Projectile.spriteDirection = -Projectile.direction;
|
|
}
|
|
|
|
Projectile.ChargingMinionAI(700f, 800f, 1200f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, false, true);
|
|
|
|
//Give off some light
|
|
float lightScalar = (float)Main.rand.Next(90, 111) * 0.01f;
|
|
lightScalar *= Main.essScale;
|
|
Lighting.AddLight(Projectile.Center, 0f * lightScalar, 0.2f * lightScalar, 0.45f * lightScalar);
|
|
|
|
//Frames
|
|
Projectile.frameCounter++;
|
|
if (Projectile.frameCounter > 7)
|
|
{
|
|
Projectile.frame++;
|
|
Projectile.frameCounter = 0;
|
|
}
|
|
if (Projectile.frame > 3)
|
|
{
|
|
Projectile.frame = 0;
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
|
Texture2D texture2D13 = ModContent.Request<Texture2D>(Texture).Value;
|
|
int num214 = ModContent.Request<Texture2D>(Texture).Value.Height / Main.projFrames[Projectile.type];
|
|
int y6 = num214 * Projectile.frame;
|
|
Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, spriteEffects, 0);
|
|
return false;
|
|
}
|
|
}
|
|
}
|