Finish set bonuses, add more options to the Avali Trader
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using ForgottenWawiTech.Content.Projectiles.Protogen;
|
||||
using ForgottenWawiTech.Content.GlobalProjectiles;
|
||||
|
||||
namespace ForgottenWawiTech.Content.Players
|
||||
{
|
||||
public class ProtogenSentinelPlayer : ModPlayer
|
||||
{
|
||||
private const int CoreProjectileCount = 1;
|
||||
private const int CoreBaseDamage = 320;
|
||||
private const float CoreSpawnOffset = -68f;
|
||||
private const float FragmentSplitChance = 0.20f;
|
||||
|
||||
public bool SentinelCoreActive { get; private set; }
|
||||
public bool SentinelProjectileSplitActive { get; private set; }
|
||||
|
||||
public override void ResetEffects()
|
||||
{
|
||||
SentinelCoreActive = false;
|
||||
SentinelProjectileSplitActive = false;
|
||||
}
|
||||
|
||||
public void EnableSentinelCore()
|
||||
{
|
||||
SentinelCoreActive = true;
|
||||
SentinelProjectileSplitActive = true;
|
||||
}
|
||||
|
||||
public override void PostUpdate()
|
||||
{
|
||||
if (!SentinelCoreActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Player.whoAmI != Main.myPlayer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int coreType = ModContent.ProjectileType<ProtogenSentinelCore>();
|
||||
if (Player.ownedProjectileCounts[coreType] >= CoreProjectileCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var source = Player.GetSource_Misc("ProtogenSentinelSet");
|
||||
Vector2 spawnPos = Player.Center + new Vector2(0f, CoreSpawnOffset);
|
||||
Projectile.NewProjectile(
|
||||
source,
|
||||
spawnPos,
|
||||
Vector2.Zero,
|
||||
coreType,
|
||||
0,
|
||||
0f,
|
||||
Player.whoAmI);
|
||||
}
|
||||
|
||||
public static int GetCoreDamage(Player player)
|
||||
{
|
||||
return (int)player.GetTotalDamage(DamageClass.Summon).ApplyTo(CoreBaseDamage);
|
||||
}
|
||||
|
||||
public override void OnHitNPCWithProj(Projectile proj, NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
if (!SentinelProjectileSplitActive || Player.whoAmI != Main.myPlayer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!proj.friendly || proj.owner != Player.whoAmI)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (proj.GetGlobalProjectile<ProtogenSentinelGlobalProjectile>().DisableSentinelSplit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (proj.type == ModContent.ProjectileType<ProtogenSentinelCoreBeam>() || proj.type == ModContent.ProjectileType<ProtogenSentinelFragment>())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (damageDone <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Main.rand.NextFloat() > FragmentSplitChance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnFragments(proj, damageDone);
|
||||
}
|
||||
|
||||
private void SpawnFragments(Projectile sourceProj, int damageDone)
|
||||
{
|
||||
int fragmentType = ModContent.ProjectileType<ProtogenSentinelFragment>();
|
||||
int fragmentCount = 2;
|
||||
int fragmentDamage = Math.Max(1, damageDone / 2);
|
||||
var source = Player.GetSource_Misc("ProtogenSentinelSplit");
|
||||
|
||||
for (int i = 0; i < fragmentCount; i++)
|
||||
{
|
||||
float rotation = MathHelper.ToRadians(Main.rand.NextFloat(-18f, 18f));
|
||||
Vector2 launch = sourceProj.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(rotation) * 14f;
|
||||
Projectile fragment = Projectile.NewProjectileDirect(
|
||||
source,
|
||||
sourceProj.Center,
|
||||
launch,
|
||||
fragmentType,
|
||||
fragmentDamage,
|
||||
2f,
|
||||
Player.whoAmI);
|
||||
fragment.GetGlobalProjectile<ProtogenSentinelGlobalProjectile>().DisableSentinelSplit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user