using System; using Decimation.Content.Buffs.Debuffs; using Decimation.Lib.Util; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Decimation.Content.Projectiles { public class MagmaBall : DecimationProjectile { private bool HitPlayer { get => projectile.ai[0] == 1f; set => projectile.ai[0] = value ? 1 : 0; } protected override void Init() { projectile.width = 22; projectile.height = 20; projectile.aiStyle = -1; projectile.hostile = true; projectile.penetrate = 1; } public override void AI() { Lighting.AddLight(projectile.Center, LightingUtils.Rgb255ToRgb1(255, 155, 48)); Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.LavaMoss); projectile.velocity.Y += 1 / 4f; } public override void OnHitPlayer(Player target, int damage, bool crit) { DustUtils.NewDustCircle(16, target.position, target.width, target.height, DustID.Fire, projectile.scale * 3f); target.AddBuff(ModContent.BuffType(), 300); HitPlayer = true; projectile.Kill(); } public override void Kill(int timeLeft) { if (HitPlayer) return; DustUtils.NewDustCircle(4, projectile.position, projectile.width, projectile.height, DustID.Fire, projectile.scale * 3f); Tile currentTile = Framing.GetTileSafely((int) Math.Floor(projectile.position.X / 16f), (int) Math.Ceiling(projectile.position.Y / 16f)); currentTile.liquid = 1; currentTile.lava(true); Main.PlaySound(SoundID.NPCDeath19, projectile.Center); } } }