Files
CalamityModPublic/NPCs/PlagueEnemies/PlagueChargerLarge.cs
T
Mortis3 4a856851d1 Localization stuffs
localized (hopefully) every npc in calamity that needs it
2023-07-20 10:11:57 -04:00

160 lines
7.2 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Banners;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
using Terraria.Audio;
using Terraria.GameContent.ItemDropRules;
using CalamityMod.Sounds;
namespace CalamityMod.NPCs.PlagueEnemies
{
public class PlagueChargerLarge : ModNPC
{
public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.PlagueCharger.DisplayName");
public override void SetStaticDefaults()
{
Main.npcFrameCount[NPC.type] = 4;
NPCID.Sets.TrailingMode[NPC.type] = 1;
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0);
}
public override void SetDefaults()
{
NPC.damage = 45;
NPC.width = 36;
NPC.height = 30;
NPC.defense = 25;
NPC.scale *= 0.75f;
NPC.lifeMax = 300;
NPC.aiStyle = NPCAIStyleID.Flying;
AIType = NPCID.Bee;
NPC.knockBackResist = 0f;
AnimationType = NPCID.Bee;
NPC.value = Item.buyPrice(0, 0, 10, 0);
NPC.HitSound = SoundID.NPCHit4;
NPC.noGravity = true;
NPC.noTileCollide = false;
Banner = ModContent.NPCType<PlagueCharger>();
BannerItem = ModContent.ItemType<PlagueChargerBanner>();
NPC.Calamity().VulnerableToSickness = false;
NPC.Calamity().VulnerableToElectricity = true;
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle,
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.UndergroundJungle,
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.PlagueCharger")
});
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value;
Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2));
Color color36 = Color.White;
float amount9 = 0.5f;
int num153 = 5;
if (CalamityConfig.Instance.Afterimages)
{
for (int num155 = 1; num155 < num153; num155 += 2)
{
Color color38 = drawColor;
color38 = Color.Lerp(color38, color36, amount9);
color38 = NPC.GetAlpha(color38);
color38 *= (float)(num153 - num155) / 15f;
Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos;
vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f;
vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f);
}
}
Vector2 vector43 = NPC.Center - screenPos;
vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f;
vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f);
texture2D15 = ModContent.Request<Texture2D>("CalamityMod/NPCs/PlagueEnemies/PlagueChargerGlow").Value;
Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f);
if (CalamityConfig.Instance.Afterimages)
{
for (int num163 = 1; num163 < num153; num163++)
{
Color color41 = color37;
color41 = Color.Lerp(color41, color36, amount9);
color41 *= (float)(num153 - num163) / 15f;
Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos;
vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f;
vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f);
}
}
spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f);
return false;
}
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
npcLoot.Add(ModContent.ItemType<PlagueCellCanister>(), 1, 2, 3);
npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Stinger, 4, 2));
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (spawnInfo.PlayerSafe || !NPC.downedGolemBoss || spawnInfo.Player.Calamity().ZoneSunkenSea)
{
return 0f;
}
return SpawnCondition.HardmodeJungle.Chance * 0.12f;
}
public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
{
if (hurtInfo.Damage > 0)
target.AddBuff(ModContent.BuffType<Plague>(), 180, true);
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Plague, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
SoundEngine.PlaySound(CommonCalamitySounds.PlagueBoomSound, NPC.Center);
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Plague, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.Server)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("PlagueCharger").Type, 0.75f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("PlagueCharger2").Type, 0.75f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("PlagueCharger3").Type, 0.75f);
}
}
}
}
}