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,115 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ForgottenWawiTech.Content.Projectiles.Protogen
{
public class ProtogenOperativeNanite : ModProjectile
{
private const float DetectionRange = 640f;
private const float HomingStrength = 0.14f;
private const float DesiredSpeed = 14f;
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionShot[Type] = true;
ProjectileID.Sets.MinionSacrificable[Type] = false;
}
public override void SetDefaults()
{
Projectile.width = 14;
Projectile.height = 14;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.timeLeft = 360;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Generic;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 20;
Projectile.extraUpdates = 1;
}
public override void AI()
{
Player owner = Main.player[Projectile.owner];
if (!owner.active || owner.dead)
{
Projectile.Kill();
return;
}
Projectile.rotation += 0.2f * Projectile.direction;
Lighting.AddLight(Projectile.Center, 0.25f, 0.55f, 0.75f);
NPC target = AcquireTarget(owner, Projectile.Center, DetectionRange);
if (target != null)
{
Vector2 desiredVelocity = (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * DesiredSpeed;
Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, HomingStrength);
}
else
{
Projectile.velocity *= 0.98f;
}
if (Main.rand.NextBool(4))
{
Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Electric, 0f, 0f, 100, default, 1.1f);
dust.noGravity = true;
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (Main.myPlayer != Projectile.owner)
{
return;
}
Player owner = Main.player[Projectile.owner];
int healAmount = (int)(damageDone * 0.5f);
if (healAmount <= 0)
{
return;
}
owner.statLife = Utils.Clamp(owner.statLife + healAmount, 0, owner.statLifeMax2);
owner.HealEffect(healAmount);
}
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,124 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using ForgottenWawiTech.Content.Players;
using ForgottenWawiTech.Content.GlobalProjectiles;
namespace ForgottenWawiTech.Content.Projectiles.Protogen
{
public class ProtogenSentinelCore : ModProjectile
{
private const float HoverRadius = 70f;
private const float HoverSpeed = 0.035f;
private const int FireCooldown = 32;
private const float TargetRange = 950f;
private const float BeamVelocity = 18f;
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = false;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 36;
Projectile.height = 36;
Projectile.friendly = false;
Projectile.minion = true;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.penetrate = -1;
Projectile.netImportant = true;
Projectile.timeLeft = 2;
Projectile.damage = 0;
Projectile.minionSlots = 0f;
}
public override void AI()
{
Player owner = Main.player[Projectile.owner];
ProtogenSentinelPlayer modPlayer = owner.GetModPlayer<ProtogenSentinelPlayer>();
if (!owner.active || owner.dead || !modPlayer.SentinelCoreActive)
{
Projectile.Kill();
return;
}
Projectile.timeLeft = 2;
float rotation = ((float)Main.GameUpdateCount * HoverSpeed) % MathHelper.TwoPi;
Vector2 desiredOffset = new Vector2(0f, -HoverRadius).RotatedBy(rotation);
Vector2 desiredPosition = owner.Center + desiredOffset;
Projectile.Center = Vector2.Lerp(Projectile.Center, desiredPosition, 0.2f);
Projectile.velocity = owner.velocity;
Lighting.AddLight(Projectile.Center, 0.2f, 0.6f, 0.9f);
if (Projectile.owner == Main.myPlayer)
{
Projectile.localAI[0]++;
if (Projectile.localAI[0] >= FireCooldown)
{
Projectile.localAI[0] = 0f;
NPC target = AcquireTarget(owner, Projectile.Center, TargetRange);
if (target != null)
{
FireBeam(owner, target);
}
}
}
}
private void FireBeam(Player owner, NPC target)
{
Vector2 velocity = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitY) * BeamVelocity;
int damage = ProtogenSentinelPlayer.GetCoreDamage(owner);
var source = Projectile.GetSource_FromThis();
Projectile beam = Projectile.NewProjectileDirect(
source,
Projectile.Center,
velocity,
ModContent.ProjectileType<ProtogenSentinelCoreBeam>(),
damage,
3f,
owner.whoAmI);
beam.GetGlobalProjectile<ProtogenSentinelGlobalProjectile>().DisableSentinelSplit = true;
SoundEngine.PlaySound(SoundID.Item33 with { Volume = 0.7f, Pitch = 0.15f }, Projectile.Center);
}
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,50 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using ForgottenWawiTech.Content.GlobalProjectiles;
namespace ForgottenWawiTech.Content.Projectiles.Protogen
{
public class ProtogenSentinelCoreBeam : ModProjectile
{
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionShot[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 18;
Projectile.height = 18;
Projectile.friendly = true;
Projectile.timeLeft = 120;
Projectile.penetrate = 2;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Summon;
Projectile.extraUpdates = 1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation();
Lighting.AddLight(Projectile.Center, 0.35f, 0.9f, 1.2f);
if (Main.rand.NextBool(3))
{
Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.BlueCrystalShard, 0f, 0f, 150, default, 1.1f);
dust.noGravity = true;
dust.velocity = Projectile.velocity * 0.2f;
}
}
public override void OnSpawn(IEntitySource source)
{
Projectile.GetGlobalProjectile<ProtogenSentinelGlobalProjectile>().DisableSentinelSplit = true;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

@@ -0,0 +1,87 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using ForgottenWawiTech.Content.GlobalProjectiles;
namespace ForgottenWawiTech.Content.Projectiles.Protogen
{
public class ProtogenSentinelFragment : ModProjectile
{
private const float HomingRange = 560f;
private const float HomingStrength = 0.18f;
private const float DesiredSpeed = 15f;
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionShot[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 14;
Projectile.height = 14;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.timeLeft = 240;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Generic;
Projectile.extraUpdates = 1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 15;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation();
Lighting.AddLight(Projectile.Center, 0.3f, 0.8f, 1.15f);
NPC target = AcquireTarget(Projectile.Center, HomingRange);
if (target != null)
{
Vector2 desiredVelocity = (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * DesiredSpeed;
Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, HomingStrength);
}
else
{
Projectile.velocity *= 0.99f;
}
if (Main.rand.NextBool(4))
{
Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Electric, 0f, 0f, 120, default, 1.05f);
dust.noGravity = true;
}
}
public override void OnSpawn(IEntitySource source)
{
Projectile.GetGlobalProjectile<ProtogenSentinelGlobalProjectile>().DisableSentinelSplit = true;
}
private static NPC AcquireTarget(Vector2 center, float range)
{
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