Files
CalamityModPublic/Projectiles/Summon/MK2FlaskSummon.cs
T
2024-10-15 23:48:00 +07:00

67 lines
2.6 KiB
C#

using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class MK2FlaskSummon : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override string Texture => "CalamityMod/Items/Weapons/Summon/FuelCellBundle";
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionShot[Type] = true;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.friendly = true;
Projectile.width = 26;
Projectile.height = 26;
Projectile.minion = true;
Projectile.minionSlots = 0f;
Projectile.ignoreWater = true;
Projectile.tileCollide = true;
Projectile.timeLeft = 240;
Projectile.DamageType = DamageClass.Summon;
}
public override void AI()
{
Projectile.velocity.Y += 0.2f;
Projectile.rotation += 0.1f * (Projectile.velocity.X > 0).ToDirectionInt();
}
public override void OnKill(int timeLeft)
{
if (Main.myPlayer == Projectile.owner)
{
for (int i = 0; i < Main.rand.Next(18, 21); i++)
{
Dust.NewDustPerfect(Projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f),
(int)CalamityDusts.Plague,
Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f));
}
SoundEngine.PlaySound(SoundID.Item107, Projectile.Center);
int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.UnitY * 6f, ModContent.ProjectileType<PlaguebringerMK2>(), Projectile.damage, 4f, Projectile.owner);
if (Main.projectile.IndexInRange(p))
Main.projectile[p].originalDamage = Projectile.originalDamage;
int beeArrayIndex = 0;
foreach (Projectile pro in Main.ActiveProjectiles)
{
if (pro.owner == Projectile.owner && pro.type == ModContent.ProjectileType<PlaguebringerMK2>())
{
pro.ai[1] = beeArrayIndex;
beeArrayIndex++;
}
}
}
}
public override bool? CanDamage() => false;
}
}