Files
CalamityModPublic/Projectiles/Summon/BabyPlaguebringer.cs
T
termigator1359 1b22071cf4 squash merge: Removed all unused textures
Removed nearly all unused textures in the entire mod, especially focusing on projectiles.
Apotheosis & the Death Valley Duster weapon line were ignored to prevent merge conflicts.
2020-11-15 14:25:46 -05:00

255 lines
9.2 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
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 BabyPlaguebringer : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/Pets/PlaguebringerBab";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Baby Plaguebringer");
Main.projFrames[projectile.type] = 4;
ProjectileID.Sets.MinionShot[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.width = 56;
projectile.height = 46;
projectile.netImportant = true;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 15;
projectile.extraUpdates = 0;
projectile.minionSlots = 0f;
projectile.timeLeft = 360;
projectile.penetrate = 3;
projectile.tileCollide = false;
projectile.timeLeft *= 5;
projectile.minion = true;
}
public override void AI()
{
Player player = Main.player[projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
if ((double)Math.Abs(projectile.velocity.X) > 0.2)
{
projectile.spriteDirection = -projectile.direction;
}
float num633 = 800f;
float num634 = 1200f;
float num635 = 3000f;
float num636 = 500f;
//lighting
float num = (float)Main.rand.Next(90, 111) * 0.01f;
num *= Main.essScale;
Lighting.AddLight(projectile.Center, 0f * num, 0.75f * num, 0f * num);
bool flag24 = false;
if (projectile.ai[0] == 2f)
{
projectile.ai[1] += 1f;
projectile.extraUpdates = 1;
projectile.frameCounter++;
if (projectile.frameCounter > 3)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame > 2)
{
projectile.frame = 0;
}
if (projectile.ai[1] > 30f)
{
projectile.ai[1] = 1f;
projectile.ai[0] = 0f;
projectile.extraUpdates = 0;
projectile.numUpdates = 0;
projectile.netUpdate = true;
}
else
{
flag24 = true;
}
}
if (flag24)
{
return;
}
Vector2 vector46 = projectile.position;
bool flag25 = false;
if (player.HasMinionAttackTargetNPC)
{
NPC npc = Main.npc[player.MinionAttackTargetNPC];
if (npc.CanBeChasedBy(projectile, false))
{
float num646 = Vector2.Distance(npc.Center, projectile.Center);
if (!flag25 && num646 < num633)
{
num633 = num646;
vector46 = npc.Center;
flag25 = true;
}
}
}
if (!flag25)
{
for (int num645 = 0; num645 < Main.maxNPCs; num645++)
{
NPC nPC2 = Main.npc[num645];
if (nPC2.CanBeChasedBy(projectile, false))
{
float num646 = Vector2.Distance(nPC2.Center, projectile.Center);
if (!flag25 && num646 < num633)
{
num633 = num646;
vector46 = nPC2.Center;
flag25 = true;
}
}
}
}
float num647 = num634;
if (flag25)
{
num647 = num635;
}
if (Vector2.Distance(player.Center, projectile.Center) > num647)
{
projectile.ai[0] = 1f;
projectile.netUpdate = true;
}
if (flag25 && projectile.ai[0] == 0f)
{
Vector2 vector47 = vector46 - projectile.Center;
float num648 = vector47.Length();
vector47.Normalize();
if (num648 > 200f)
{
float scaleFactor2 = 8f;
vector47 *= scaleFactor2;
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
}
else
{
float num649 = 4f;
vector47 *= -num649;
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
}
}
else
{
bool flag26 = false;
if (!flag26)
{
flag26 = projectile.ai[0] == 1f;
}
float num650 = 6f;
if (flag26)
{
num650 = 15f;
}
Vector2 center2 = projectile.Center;
Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f);
float num651 = vector48.Length();
if (num651 > 200f && num650 < 8f)
{
num650 = 8f;
}
if (num651 < num636 && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
{
projectile.ai[0] = 0f;
projectile.netUpdate = true;
}
if (num651 > 2000f)
{
projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2);
projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2);
projectile.netUpdate = true;
}
if (num651 > 70f)
{
vector48.Normalize();
vector48 *= num650;
projectile.velocity = (projectile.velocity * 40f + vector48) / 41f;
}
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
{
projectile.velocity.X = -0.15f;
projectile.velocity.Y = -0.05f;
}
}
projectile.frameCounter++;
if (projectile.frameCounter > 12)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame >= 4)
{
projectile.frame = 2;
}
if (projectile.ai[1] > 0f)
{
projectile.ai[1] += (float)Main.rand.Next(1, 4);
}
if (projectile.ai[1] > 40f)
{
projectile.ai[1] = 0f;
projectile.netUpdate = true;
}
if (projectile.ai[0] == 0f)
{
if (projectile.ai[1] == 0f && flag25 && num633 < 500f)
{
projectile.ai[1] += 1f;
if (Main.myPlayer == projectile.owner)
{
projectile.ai[0] = 2f;
Vector2 value20 = vector46 - projectile.Center;
value20.Normalize();
projectile.velocity = value20 * 8f;
projectile.netUpdate = true;
}
}
}
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.NPCHit4, projectile.position);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
Texture2D texture2D13 = Main.projectileTexture[projectile.type];
int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
int y6 = num214 * projectile.frame;
Main.spriteBatch.Draw(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, 0f);
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<Plague>(), 120);
}
public override void OnHitPvp(Player target, int damage, bool crit)
{
target.AddBuff(ModContent.BuffType<Plague>(), 120);
}
}
}