Merge of Warlok's Moon Fist
This commit is contained in:
9 files changed
+416
No files matched your search
@@ -0,0 +1,34 @@
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Projectiles.DraedonsArsenal;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Buffs.Summon
|
||||
{
|
||||
public class MoonFistBuff : ModBuff
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Moon Fist");
|
||||
Description.SetDefault("Catch these hands");
|
||||
Main.buffNoTimeDisplay[Type] = true;
|
||||
Main.buffNoSave[Type] = true;
|
||||
}
|
||||
|
||||
public override void Update(Player player, ref int buffIndex)
|
||||
{
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (player.ownedProjectileCounts[ModContent.ProjectileType<MoonFist>()] > 0)
|
||||
modPlayer.MoonFist = true;
|
||||
|
||||
if (!modPlayer.MoonFist)
|
||||
{
|
||||
player.DelBuff(buffIndex);
|
||||
buffIndex--;
|
||||
}
|
||||
else
|
||||
player.buffTime[buffIndex] = 18000;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 383 B |
@@ -965,6 +965,7 @@ namespace CalamityMod.CalPlayer
|
||||
public bool eyeOfNight = false;
|
||||
public bool soulSeeker = false;
|
||||
public bool perditionBeacon = false;
|
||||
public bool MoonFist = false;
|
||||
public bool AresCannons = false;
|
||||
|
||||
public List<DeadMinionProperties> PendingProjectilesToRespawn = new List<DeadMinionProperties>();
|
||||
@@ -2000,6 +2001,7 @@ namespace CalamityMod.CalPlayer
|
||||
eyeOfNight = false;
|
||||
soulSeeker = false;
|
||||
perditionBeacon = false;
|
||||
MoonFist = false;
|
||||
AresCannons = false;
|
||||
|
||||
disableVoodooSpawns = false;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
using Terraria.DataStructures;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Summon
|
||||
{
|
||||
public class WarloksMoonFist : ModItem
|
||||
{
|
||||
public const int SlotCount = 4;
|
||||
|
||||
public const int PunchCooldownTime = 36;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Warloks's Moon Fist");
|
||||
Tooltip.SetDefault("Summons a celestial fist to punch enemies for you\n" +
|
||||
$"Takes up {SlotCount} minion slots");
|
||||
SacrificeTotal = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.damage = 330;
|
||||
Item.mana = 10;
|
||||
Item.width = 50;
|
||||
Item.height = 50;
|
||||
Item.useTime = Item.useAnimation = 25;
|
||||
Item.useStyle = ItemUseStyleID.Swing;
|
||||
Item.noMelee = true;
|
||||
Item.knockBack = 2f;
|
||||
Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice;
|
||||
Item.rare = ItemRarityID.Purple;
|
||||
Item.Calamity().customRarity = CalamityRarity.PureGreen;
|
||||
Item.UseSound = SoundID.Item104;
|
||||
Item.autoReuse = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.shoot = ModContent.ProjectileType<MoonFist>();
|
||||
Item.shootSpeed = 10f;
|
||||
Item.DamageType = DamageClass.Summon;
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
if (player.altFunctionUse != 2)
|
||||
{
|
||||
int existingFists = player.ownedProjectileCounts[type];
|
||||
int p = Projectile.NewProjectile(source, Main.MouseWorld, Vector2.Zero, type, damage, knockback, player.whoAmI);
|
||||
if (Main.projectile.IndexInRange(p))
|
||||
{
|
||||
Main.projectile[p].originalDamage = Item.damage;
|
||||
Main.projectile[p].ai[0] = existingFists;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,251 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.Audio;
|
||||
using CalamityMod.Items.Weapons.Summon;
|
||||
using CalamityMod.Buffs.Summon;
|
||||
using System.IO;
|
||||
using Terraria.GameContent.Drawing;
|
||||
using CalamityMod.Dusts;
|
||||
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MoonFist : ModProjectile
|
||||
{
|
||||
public int DelayUntilNextPunch;
|
||||
|
||||
public int FistIndex => (int)Projectile.ai[0];
|
||||
|
||||
public ref float AttackTimer => ref Projectile.ai[1];
|
||||
|
||||
public ref float FrameTimer => ref Projectile.localAI[0];
|
||||
|
||||
public float FistInterpolant
|
||||
{
|
||||
get
|
||||
{
|
||||
float projectileCounts = Owner.ownedProjectileCounts[Type];
|
||||
|
||||
// Use a midway interpolant if the projectile count is one. This makes the fist use middle positions instead of
|
||||
// sitting awkwardly to the left.
|
||||
if (projectileCounts <= 1f)
|
||||
return 0.5f;
|
||||
|
||||
return FistIndex / (projectileCounts - 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Cosmic Fist");
|
||||
Main.projFrames[Type] = 18;
|
||||
ProjectileID.Sets.MinionSacrificable[Projectile.type] = true;
|
||||
ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 48;
|
||||
Projectile.height = 48;
|
||||
Projectile.minion = true;
|
||||
Projectile.friendly = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.netImportant = true;
|
||||
Projectile.alpha = 255;
|
||||
Projectile.minionSlots = WarloksMoonFist.SlotCount;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.MaxUpdates = 2;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 10;
|
||||
Projectile.netImportant = true;
|
||||
Projectile.timeLeft = 90000;
|
||||
Projectile.DamageType = DamageClass.Summon;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer) => writer.Write(DelayUntilNextPunch);
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader) => DelayUntilNextPunch = reader.ReadInt32();
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
ApplyMinionBuffs();
|
||||
|
||||
NPC potentialTarget = Owner.Center.ClosestNPCAt(1650f);
|
||||
if (potentialTarget is null)
|
||||
HoverNearOwner();
|
||||
else
|
||||
AttackTarget(potentialTarget);
|
||||
|
||||
FrameTimer++;
|
||||
Projectile.frameCounter++;
|
||||
if (DelayUntilNextPunch > 0)
|
||||
DelayUntilNextPunch--;
|
||||
|
||||
// Fade in.
|
||||
Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.1f, 0f, 1f);
|
||||
}
|
||||
|
||||
public void ApplyMinionBuffs()
|
||||
{
|
||||
// Maintain or remove the Mechworm buff from the owner.
|
||||
Owner.AddBuff(ModContent.BuffType<MoonFistBuff>(), 3600);
|
||||
if (Owner.dead)
|
||||
Owner.Calamity().MoonFist = false;
|
||||
if (Owner.Calamity().MoonFist)
|
||||
Projectile.timeLeft = 2;
|
||||
}
|
||||
|
||||
public void HoverNearOwner()
|
||||
{
|
||||
float hoverOffsetAngle = MathHelper.Lerp(-MathHelper.PiOver2, MathHelper.PiOver2, FistInterpolant);
|
||||
Vector2 hoverDestination = Owner.Center - Vector2.UnitY.RotatedBy(hoverOffsetAngle) * (Owner.height + 70f);
|
||||
Projectile.velocity *= 0.7f;
|
||||
Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.13333f);
|
||||
|
||||
// Use idle frames.
|
||||
float frameInterpolant = (FrameTimer / 50f + FistInterpolant) % 1f;
|
||||
Projectile.frame = (int)Math.Round(MathHelper.Lerp(0f, 5f, frameInterpolant));
|
||||
|
||||
// Determine direction and rotation.
|
||||
Projectile.rotation = Projectile.rotation.AngleTowards(0f, 0.333f);
|
||||
Projectile.spriteDirection = Owner.direction;
|
||||
|
||||
// Reset the attack timer.
|
||||
AttackTimer = 0f;
|
||||
}
|
||||
|
||||
public void AttackTarget(NPC target)
|
||||
{
|
||||
int reelBackTime = 32;
|
||||
int homeDelay = 27;
|
||||
int attackTime = 150;
|
||||
int attackCycleInterval = reelBackTime + attackTime;
|
||||
|
||||
// Teleport to the enemy if it's far away.
|
||||
if (!Projectile.WithinRange(target.Center, 1200f))
|
||||
{
|
||||
Vector2 teleportDestination = target.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(250f, 300f);
|
||||
DoTeleport(teleportDestination);
|
||||
}
|
||||
|
||||
Projectile.rotation = Projectile.AngleTo(target.Center);
|
||||
Projectile.spriteDirection = (target.Center.X < Projectile.Center.X).ToDirectionInt();
|
||||
if (Projectile.spriteDirection == -1)
|
||||
Projectile.rotation += MathHelper.Pi;
|
||||
|
||||
// Clench the fist and hover near the target.
|
||||
if (AttackTimer <= reelBackTime)
|
||||
{
|
||||
Projectile.frame = (int)Math.Round(MathHelper.Lerp(6f, 11f, AttackTimer / reelBackTime));
|
||||
|
||||
// Reel back and look at the target.
|
||||
float hoverOffset = MathHelper.Lerp(200f, 480f, AttackTimer / reelBackTime);
|
||||
hoverOffset += MathHelper.Lerp(-10f, 75f, Projectile.identity % 9f / 1f);
|
||||
float spin = MathHelper.Lerp(-0.27f, 0.27f, Projectile.identity / 7f % 1f);
|
||||
Vector2 hoverDestination = target.Center - target.SafeDirectionTo(target.Center, Vector2.UnitY).RotatedBy(spin) * hoverOffset;
|
||||
Vector2 idealVelocity = Projectile.SafeDirectionTo(hoverDestination) * MathHelper.Min(25f, Projectile.Distance(hoverDestination));
|
||||
|
||||
Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.02f);
|
||||
Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.03f).MoveTowards(idealVelocity, 0.5f);
|
||||
|
||||
// Fly towards the target at an incredibly fast speed.
|
||||
if (AttackTimer == reelBackTime)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.DD2_WyvernDiveDown, Projectile.Center);
|
||||
Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, target, 40f);
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
else if (DelayUntilNextPunch <= 0)
|
||||
{
|
||||
// Home towards the target briefly after the initial charge.
|
||||
if (AttackTimer >= reelBackTime + homeDelay)
|
||||
Projectile.velocity = Projectile.SuperhomeTowardsTarget(target, 34f, 24f);
|
||||
}
|
||||
|
||||
// Increment the attack timer.
|
||||
AttackTimer = (AttackTimer + 1f) % attackCycleInterval;
|
||||
}
|
||||
|
||||
public void DoTeleport(Vector2 end)
|
||||
{
|
||||
Vector2 start = Projectile.Center;
|
||||
for (int i = 0; i < 75; i++)
|
||||
{
|
||||
Vector2 dustDrawPosition = Vector2.Lerp(start, end, i / 74f);
|
||||
|
||||
Dust magic = Dust.NewDustPerfect(dustDrawPosition, 267);
|
||||
magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(0.2f, 0.235f);
|
||||
magic.color = Color.LightCyan;
|
||||
magic.color.A = 0;
|
||||
magic.scale = 0.8f;
|
||||
magic.fadeIn = 1.4f;
|
||||
magic.noGravity = true;
|
||||
}
|
||||
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
int magic = Projectile.NewProjectile(Projectile.GetSource_FromAI(), start, Vector2.Zero, ModContent.ProjectileType<MoonFistTeleportVisual>(), 0, 0f);
|
||||
Main.projectile[magic].timeLeft -= i * 2;
|
||||
magic = Projectile.NewProjectile(Projectile.GetSource_FromAI(), end, Vector2.Zero, ModContent.ProjectileType<MoonFistTeleportVisual>(), 0, 0f);
|
||||
Main.projectile[magic].timeLeft -= i * 2;
|
||||
}
|
||||
Projectile.Center = end;
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
// Rebound on collision.
|
||||
if (DelayUntilNextPunch > 0 || AttackTimer <= 0f)
|
||||
return;
|
||||
|
||||
// Create some cool particles to go with the hit.
|
||||
Vector2 impactPoint = Vector2.Lerp(Projectile.Center, target.Hitbox.ClosestPointInRect(Projectile.Center), 0.5f);
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
ParticleOrchestrator.RequestParticleSpawn(false, ParticleOrchestraType.StardustPunch, new()
|
||||
{
|
||||
PositionInWorld = impactPoint + Vector2.UnitY * Main.rand.NextFloatDirection() * 10f,
|
||||
MovementVector = Main.rand.NextVector2Unit() * Main.rand.NextFloat(3f, 9.6f)
|
||||
});
|
||||
}
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
int dustID = Main.rand.NextBool() ? (int)CalamityDusts.BlueCosmilite : (int)CalamityDusts.PurpleCosmilite;
|
||||
|
||||
Dust cosmicDust = Dust.NewDustPerfect(impactPoint + Main.rand.NextVector2Circular(10f, 10f), dustID);
|
||||
cosmicDust.velocity = Projectile.velocity.RotatedByRandom(0.6f) * 0.2f;
|
||||
cosmicDust.scale = Main.rand.NextFloat(1f, 1.4f);
|
||||
cosmicDust.noGravity = true;
|
||||
if (Main.rand.NextBool(5))
|
||||
cosmicDust.scale += 0.45f;
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Item74 with { Pitch = -0.36f }, Projectile.Center);
|
||||
DelayUntilNextPunch = WarloksMoonFist.PunchCooldownTime - 10;
|
||||
Projectile.velocity = Projectile.SafeDirectionTo(target.Center, -Vector2.UnitY).RotatedBy(0.16f) * Projectile.velocity.Length() * -0.45f;
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
|
||||
Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
|
||||
Vector2 origin = frame.Size() * 0.5f;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,69 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MoonFistTeleportVisual : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults() => DisplayName.SetDefault("Light");
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = Projectile.height = 2;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.hide = true;
|
||||
Projectile.timeLeft = 45;
|
||||
Projectile.MaxUpdates = 2;
|
||||
Projectile.penetrate = -1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.Opacity = Utils.GetLerpValue(0f, 12f, Projectile.timeLeft);
|
||||
Projectile.scale = Utils.GetLerpValue(45f, 5f, Projectile.timeLeft);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D telegraphTexture = TextureAssets.Projectile[Projectile.type].Value;
|
||||
Color telegraphColor = Color.White * Projectile.Opacity * 0.2f;
|
||||
telegraphColor.A = 0;
|
||||
|
||||
for (int i = 0; i < 35; i++)
|
||||
{
|
||||
Vector2 drawPosition = Projectile.Center + (MathHelper.TwoPi * i / 5f + Main.GlobalTimeWrappedHourly * 3f).ToRotationVector2() * 2f;
|
||||
drawPosition -= Main.screenPosition;
|
||||
|
||||
Vector2 scale = new Vector2(0.58f, 1f) * Projectile.scale;
|
||||
scale *= MathHelper.Lerp(0.015f, 1f, i / 35f);
|
||||
|
||||
Main.spriteBatch.Draw(telegraphTexture, drawPosition, null, telegraphColor, 0f, telegraphTexture.Size() * 0.5f, scale, 0, 0f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
Dust magic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(30f, 30f), 267);
|
||||
magic.color = Color.SkyBlue;
|
||||
magic.scale = 1.1f;
|
||||
magic.fadeIn = 0.6f;
|
||||
magic.velocity = Main.rand.NextVector2Circular(2f, 2f);
|
||||
magic.velocity = Vector2.Lerp(magic.velocity, -Vector2.UnitY * magic.velocity.Length(), Main.rand.NextFloat(0.65f, 1f));
|
||||
magic.noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawBehind(int index, List<int> behindNPCsAndTiles, List<int> behindNPCs, List<int> behindProjectiles, List<int> overPlayers, List<int> overWiresUI)
|
||||
{
|
||||
behindNPCsAndTiles.Add(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
Reference in new issue
Block a user