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) { int dustAmount = 16; for (int i = 0; i < dustAmount; i++) { Dust.NewDust(target.position, target.width, target.height, DustID.Fire, 0, 0, 0, default, projectile.scale * 3f); } target.AddBuff(ModContent.BuffType(), 300); HitPlayer = true; projectile.Kill(); } public override void Kill(int timeLeft) { if (HitPlayer) return; int dustAmount = 4; for (int i = 0; i < dustAmount; i++) { Vector2 velocity = Vector2.One.RotatedBy(Math.PI * (2f / dustAmount)); Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, velocity.X, velocity.Y, 0, default, 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); } } }