Finish set bonuses, add more options to the Avali Trader

This commit is contained in:
2025-11-20 16:22:50 +00:00
parent 9162878883
commit b30fcc9563
44 changed files with 1744 additions and 81 deletions
@@ -0,0 +1,126 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using ForgottenWawiTech.Content.Players;
namespace ForgottenWawiTech.Content.Projectiles.Avali
{
public class AvaliHuntingDrone : ModProjectile
{
private const float OrbitSpeed = 0.045f;
private const float OrbitRadius = 96f;
private const int ShootCooldown = 28;
private const float TargetRange = 920f;
private const float ShotSpeed = 19.5f;
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = false;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 26;
Projectile.height = 26;
Projectile.friendly = false;
Projectile.minion = true;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Summon;
Projectile.netImportant = true;
Projectile.timeLeft = 2;
Projectile.minionSlots = 0f;
Projectile.damage = 0;
}
public override void AI()
{
Player owner = Main.player[Projectile.owner];
AvaliVanguardPlayer modPlayer = owner.GetModPlayer<AvaliVanguardPlayer>();
if (!owner.active || owner.dead || !modPlayer.HuntingDronesActive)
{
Projectile.Kill();
return;
}
Projectile.timeLeft = 2;
float index = Projectile.ai[0];
float total = Projectile.ai[1];
if (total <= 0f)
{
total = 3f;
}
float rotation = (Main.GameUpdateCount * OrbitSpeed) + index * MathHelper.TwoPi / total;
Vector2 offset = rotation.ToRotationVector2() * OrbitRadius;
Projectile.Center = owner.Center + offset;
Projectile.velocity = owner.velocity;
Projectile.rotation = (owner.Center - Projectile.Center).ToRotation() + MathHelper.PiOver2;
Lighting.AddLight(Projectile.Center, 0.35f, 0.6f, 1f);
if (Projectile.owner == Main.myPlayer)
{
Projectile.localAI[0]++;
if (Projectile.localAI[0] >= ShootCooldown)
{
Projectile.localAI[0] = 0f;
NPC target = AcquireTarget(owner, Projectile.Center, TargetRange);
if (target != null)
{
Vector2 velocity = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitY) * ShotSpeed;
int damage = AvaliVanguardPlayer.GetDroneBaseDamage(owner);
var source = Projectile.GetSource_FromAI();
Projectile.NewProjectile(
source,
Projectile.Center,
velocity,
ModContent.ProjectileType<AvaliHuntingDroneShot>(),
damage,
2f,
owner.whoAmI);
SoundEngine.PlaySound(SoundID.Item12 with { Volume = 0.6f }, Projectile.Center);
Projectile.netUpdate = true;
}
}
}
}
private static NPC AcquireTarget(Player owner, Vector2 center, float range)
{
if (owner.HasMinionAttackTargetNPC)
{
NPC target = Main.npc[owner.MinionAttackTargetNPC];
if (target.CanBeChasedBy())
{
return target;
}
}
NPC closest = null;
float squaredRange = range * range;
for (int i = 0; i < Main.maxNPCs; i++)
{
NPC npc = Main.npc[i];
if (!npc.active || npc.friendly || npc.dontTakeDamage || npc.life <= 0)
{
continue;
}
float distance = Vector2.DistanceSquared(npc.Center, center);
if (distance <= squaredRange && Collision.CanHitLine(center, 0, 0, npc.Center, 0, 0))
{
squaredRange = distance;
closest = npc;
}
}
return closest;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

@@ -0,0 +1,52 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace ForgottenWawiTech.Content.Projectiles.Avali
{
public class AvaliHuntingDroneShot : ModProjectile
{
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionShot[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 12;
Projectile.height = 12;
Projectile.friendly = true;
Projectile.timeLeft = 120;
Projectile.penetrate = 1;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Summon;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.extraUpdates = 1;
Projectile.alpha = 40;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation();
Lighting.AddLight(Projectile.Center, 0.4f, 0.7f, 1.2f);
if (Main.rand.NextBool(3))
{
Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Electric, 0f, 0f, 120, default, 1.1f);
dust.noGravity = true;
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (Main.myPlayer == Projectile.owner)
{
SoundEngine.PlaySound(SoundID.Item93 with { Volume = 0.4f }, Projectile.Center);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B