Artifact of Resilience
No files matched your search
@@ -0,0 +1,19 @@
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Buffs.Cooldowns
|
||||
{
|
||||
public class ResilienceCooldown : ModBuff
|
||||
{
|
||||
public override void SetDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Resilience Cooldown");
|
||||
Description.SetDefault("You cannot re-summon a relic of resilience");
|
||||
Main.debuff[Type] = true;
|
||||
Main.pvpBuff[Type] = true;
|
||||
Main.buffNoSave[Type] = true;
|
||||
longerExpertDebuff = false;
|
||||
canBeCleared = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 517 B |
@@ -0,0 +1,95 @@
|
||||
using CalamityMod.Buffs.Cooldowns;
|
||||
using CalamityMod.Projectiles.Damageable;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Typeless
|
||||
{
|
||||
public class RelicOfResilience : ModItem
|
||||
{
|
||||
public const int CooldownSeconds = 5;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Relic of Resilience");
|
||||
Tooltip.SetDefault("Summons a bulwark at the mouse position\n" +
|
||||
"The bulwark takes damage from enemies and all projectiles.\n" +
|
||||
"On death, the bulwark explodes into a burst of shards\n" +
|
||||
"After a bit of time, the shards come together to reform the original bulwark.\n" +
|
||||
$"This reformation can only happen {ArtifactOfResilienceBulwark.MaxReformations} times.\n" +
|
||||
"You gain a small cooldown when summoning a new bulwark.\n" +
|
||||
"If a bulwark or shard already exists, using this item will relocate them");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.width = 40;
|
||||
item.height = 34;
|
||||
item.rare = 10;
|
||||
item.Calamity().customRarity = CalamityRarity.Turquoise;
|
||||
item.useAnimation = item.useTime = 28;
|
||||
item.useStyle = ItemUseStyleID.HoldingUp;
|
||||
item.UseSound = SoundID.Item45;
|
||||
item.autoReuse = true;
|
||||
item.noMelee = true;
|
||||
item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice;
|
||||
item.shoot = ModContent.ProjectileType<ArtifactOfResilienceBulwark>();
|
||||
item.shootSpeed = 0f;
|
||||
}
|
||||
public override bool CanUseItem(Player player) => !player.HasBuff(ModContent.BuffType<ResilienceCooldown>());
|
||||
public override bool UseItem(Player player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
||||
{
|
||||
player.AddBuff(ModContent.BuffType<ResilienceCooldown>(), CooldownSeconds * 60);
|
||||
if (player.ownedProjectileCounts[item.shoot] > 0 ||
|
||||
player.ownedProjectileCounts[ModContent.ProjectileType<ArtifactOfResilienceShard1>()] > 0)
|
||||
{
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
if (Main.projectile[i].type == item.shoot)
|
||||
{
|
||||
Main.projectile[i].Center = Main.MouseWorld;
|
||||
Main.projectile[i].netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard1)
|
||||
{
|
||||
((ArtifactOfResilienceShard1)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld;
|
||||
}
|
||||
if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard2)
|
||||
{
|
||||
((ArtifactOfResilienceShard2)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld;
|
||||
}
|
||||
if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard3)
|
||||
{
|
||||
((ArtifactOfResilienceShard3)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld;
|
||||
}
|
||||
if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard4)
|
||||
{
|
||||
((ArtifactOfResilienceShard4)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld;
|
||||
}
|
||||
if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard5)
|
||||
{
|
||||
((ArtifactOfResilienceShard5)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld;
|
||||
}
|
||||
if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard6)
|
||||
{
|
||||
((ArtifactOfResilienceShard6)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 787 B |
@@ -1,6 +1,7 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Items.Weapons.Typeless;
|
||||
using CalamityMod.Projectiles.Boss;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -285,6 +286,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void NPCLoot()
|
||||
{
|
||||
DropHelper.DropItemChance(npc, ModContent.ItemType<RelicOfResilience>(), 4);
|
||||
}
|
||||
|
||||
public override void BossLoot(ref string name, ref int potionType)
|
||||
{
|
||||
name = "A Profaned Guardian";
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using CalamityMod.Dusts;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
namespace CalamityMod.Projectiles.Damageable
|
||||
{
|
||||
public class ArtifactOfResilienceBulwark : DamageableProjectile
|
||||
{
|
||||
public int Reformations = 0;
|
||||
public const int MaxReformations = 3;
|
||||
public override int LifeMax => 30000;
|
||||
public override int MaxDamageImmunityFrames => 5;
|
||||
public override DamageSourceType DamageSources => DamageSourceType.FriendlyProjectiles | DamageSourceType.HostileProjectiles | DamageSourceType.HostileNPCs;
|
||||
public override LegacySoundStyle HitSound => SoundID.NPCHit3;
|
||||
public override LegacySoundStyle DeathSound => SoundID.NPCDeath14;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Artifact of Resilience");
|
||||
}
|
||||
|
||||
public override void SafeSetDefaults()
|
||||
{
|
||||
projectile.width = projectile.height = 76;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = 20;
|
||||
}
|
||||
|
||||
public override void SafeAI()
|
||||
{
|
||||
projectile.rotation += MathHelper.ToRadians(8f);
|
||||
Vector2 spawnPosition = projectile.Center + Utils.NextVector2Circular(Main.rand, projectile.width, projectile.height) / 2f;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(spawnPosition, (int)CalamityDusts.ProfanedFire);
|
||||
dust.velocity = projectile.DirectionFrom(spawnPosition);
|
||||
dust.scale = Main.rand.NextFloat(1.1f, 1.5f);
|
||||
dust.noGravity = true;
|
||||
}
|
||||
}
|
||||
public override void HitEffectProjectile(int damage, Projectile target)
|
||||
{
|
||||
target.Kill();
|
||||
}
|
||||
public override void DamageKillEffect()
|
||||
{
|
||||
Utils.PoofOfSmoke(projectile.Center);
|
||||
}
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 1; i <= 6; i++)
|
||||
{
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
float angle = MathHelper.TwoPi / 6f * (i - 1);
|
||||
Projectile shard = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, mod.ProjectileType("ArtifactOfResilienceShard" + i.ToString()), projectile.damage, projectile.knockBack, projectile.owner);
|
||||
shard.ai[0] = angle;
|
||||
shard.frameCounter = projectile.frameCounter + 1; // FrameCounter is a stored value for the amount of times the bulwark has reformed.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,350 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Damageable
|
||||
{
|
||||
[Flags]
|
||||
public enum DamageSourceType
|
||||
{
|
||||
HostileProjectiles = 1 << 1,
|
||||
FriendlyProjectiles = 1 << 2, // Does NOT include itself.
|
||||
HostileNPCs = 1 << 3
|
||||
}
|
||||
public abstract class DamageableProjectile : ModProjectile
|
||||
{
|
||||
#region General Fields
|
||||
/// <summary>
|
||||
/// Current life of the projectile.
|
||||
/// </summary>
|
||||
public int Life;
|
||||
/// <summary>
|
||||
/// Total damage immunity frames. This projectile cannot be hit if this is greater than 0. Descends to 0 every frame.
|
||||
/// </summary>
|
||||
public int DamageImmunityFrames;
|
||||
#endregion
|
||||
|
||||
#region Overridable Fields/Properties
|
||||
|
||||
/// <summary>
|
||||
/// Total life of the projectile.
|
||||
/// </summary>
|
||||
public abstract int LifeMax
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sound the projectile makes on hit.
|
||||
/// </summary>
|
||||
public abstract LegacySoundStyle HitSound
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sound the projectile makes on death.
|
||||
/// </summary>
|
||||
public abstract LegacySoundStyle DeathSound
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The various possibile damage sources for the projectile.
|
||||
/// </summary>
|
||||
public abstract DamageSourceType DamageSources
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A boolean which determines if the HP bar should be drawn at all.
|
||||
/// </summary>
|
||||
public virtual bool DrawHPBar
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = true;
|
||||
|
||||
/// <summary>
|
||||
/// A boolean which determines if the HP bar should be drawn if <see cref="Life"/> is equal to <see cref="LifeMax"/>
|
||||
/// </summary>
|
||||
public virtual bool DrawHPBarAtFullHealth
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
|
||||
/// <summary>
|
||||
/// How many damage immunity frames this projectile should recieve on hit.
|
||||
/// </summary>
|
||||
public virtual int MaxDamageImmunityFrames
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = 10;
|
||||
|
||||
/// <summary>
|
||||
/// List of all enemies this projectile should ignore when checking if it's colliding with an enemy (assuming this is possible).
|
||||
/// </summary>
|
||||
public virtual List<int> NPCsToIgnore
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new List<int>();
|
||||
|
||||
/// <summary>
|
||||
/// List of all projectiles this projectile should ignore when checking if it's colliding with a projectile (assuming this is possible).
|
||||
/// </summary>
|
||||
public virtual List<int> ProjectilesToIgnore
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new List<int>();
|
||||
#endregion
|
||||
|
||||
#region Virtual Methods + Sealed Counterparts
|
||||
|
||||
/// <summary>
|
||||
/// Copy of <see cref="ModProjectile.SetDefaults"/> with integrations for this custom type.
|
||||
/// </summary>
|
||||
public virtual void SafeSetDefaults()
|
||||
{
|
||||
}
|
||||
public sealed override void SetDefaults()
|
||||
{
|
||||
SafeSetDefaults();
|
||||
Life = LifeMax;
|
||||
}
|
||||
public sealed override void PostDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
DrawHealthBar();
|
||||
MouseOverText();
|
||||
SafePostDraw(spriteBatch, lightColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy of <see cref="ModProjectile.PostDraw(SpriteBatch, Color)"/> with integrations for this custom type.
|
||||
/// </summary>
|
||||
public virtual void SafePostDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
}
|
||||
public sealed override void AI()
|
||||
{
|
||||
SafeAI();
|
||||
if (DamageImmunityFrames > 0)
|
||||
{
|
||||
DamageImmunityFrames--;
|
||||
return;
|
||||
}
|
||||
bool wasHit = NPCCollisionCheck();
|
||||
if (!wasHit)
|
||||
{
|
||||
wasHit = ProjectileCollisionCheck();
|
||||
}
|
||||
if (wasHit && Life > 0)
|
||||
{
|
||||
if (HitSound != null)
|
||||
{
|
||||
Main.PlaySound(HitSound, projectile.Center);
|
||||
}
|
||||
}
|
||||
else if (Life <= 0)
|
||||
{
|
||||
if (DeathSound != null)
|
||||
{
|
||||
Main.PlaySound(DeathSound, projectile.Center);
|
||||
}
|
||||
DamageKillEffect();
|
||||
projectile.Kill();
|
||||
}
|
||||
}
|
||||
public virtual bool NPCCollisionCheck()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
for (int i = 0; i < Main.npc.Length; i++)
|
||||
{
|
||||
if (Main.npc[i].active && !Main.npc[i].friendly && Main.npc[i].damage > 0 && DamageSources.HasFlag(DamageSourceType.HostileNPCs))
|
||||
{
|
||||
if (Main.npc[i].Hitbox.Intersects(projectile.Hitbox) && !NPCsToIgnore.Contains(Main.npc[i].type))
|
||||
{
|
||||
int damage = Main.DamageVar(Main.npc[i].damage);
|
||||
int bannerBuffId = Item.NPCtoBanner(Main.npc[i].BannerID());
|
||||
if (bannerBuffId > 0 && player.NPCBannerBuff[bannerBuffId])
|
||||
{
|
||||
if (Main.expertMode)
|
||||
{
|
||||
damage = (int)(damage * ItemID.Sets.BannerStrength[Item.BannerToItem(bannerBuffId)].ExpertDamageReceived);
|
||||
}
|
||||
else
|
||||
{
|
||||
damage = (int)(damage * ItemID.Sets.BannerStrength[Item.BannerToItem(bannerBuffId)].NormalDamageReceived);
|
||||
}
|
||||
}
|
||||
CombatText.NewText(new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height), CombatText.DamagedFriendly, damage);
|
||||
Life -= damage;
|
||||
HitEffectNPC(damage, Main.npc[i]);
|
||||
DamageImmunityFrames = MaxDamageImmunityFrames;
|
||||
NetUpdate(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public virtual bool ProjectileCollisionCheck()
|
||||
{
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
bool canBeHit = (Main.projectile[i].friendly && DamageSources.HasFlag(DamageSourceType.FriendlyProjectiles) ||
|
||||
Main.projectile[i].hostile && DamageSources.HasFlag(DamageSourceType.HostileProjectiles)) &&
|
||||
i != projectile.whoAmI;
|
||||
if (Main.projectile[i].active && canBeHit && Main.projectile[i].damage > 0)
|
||||
{
|
||||
if (Main.projectile[i].Colliding(Main.projectile[i].Hitbox, projectile.Hitbox))
|
||||
{
|
||||
int damage = Main.DamageVar(Main.projectile[i].damage) * 2;
|
||||
damage = Main.expertMode ? (int)(damage * Main.expertDamage) : damage;
|
||||
CombatText.NewText(new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height), CombatText.DamagedFriendly, damage);
|
||||
Life -= damage;
|
||||
HitEffectProjectile(damage, Main.projectile[i]);
|
||||
DamageImmunityFrames = MaxDamageImmunityFrames;
|
||||
if (projectile.usesIDStaticNPCImmunity)
|
||||
DamageImmunityFrames = projectile.idStaticNPCHitCooldown;
|
||||
if (projectile.usesLocalNPCImmunity)
|
||||
DamageImmunityFrames = projectile.localNPCHitCooldown;
|
||||
NetUpdate(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public virtual void DamageKillEffect()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Copy of <see cref="ModProjectile.AI"/> with integrations for this custom type.
|
||||
/// </summary>
|
||||
public virtual void SafeAI()
|
||||
{
|
||||
}
|
||||
public sealed override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
SafeSendExtraAI(writer);
|
||||
writer.Write(Life);
|
||||
writer.Write(DamageImmunityFrames);
|
||||
}
|
||||
public sealed override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
SafeReceiveExtraAI(reader);
|
||||
Life = reader.ReadInt32();
|
||||
DamageImmunityFrames = reader.ReadInt32();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy of <see cref="ModProjectile.SendExtraAI(BinaryWriter)"/> with integrations for this custom type.
|
||||
/// <param name="writer"/>The writer used to hold data which will be sent to the server.</param>
|
||||
/// </summary>
|
||||
public virtual void SafeSendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy of <see cref="ModProjectile.ReceiveExtraAI(BinaryReader)"/> with integrations for this custom type.
|
||||
/// <param name="reader"/>The reader used to obtain data which will be sent to the server.</param>
|
||||
/// </summary>
|
||||
public virtual void SafeReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Syncs data from this npc to the server, and then to all clients.
|
||||
/// </summary>
|
||||
/// <param name="force">Whether net spam should be ignored and a net update should be forced.</param>
|
||||
/// <param name="forceCondition">The condition required for a forceful sync. Defaults to: <code>Main.netMode != NetmodeID.MultiplayerClient</code></param>
|
||||
public virtual void NetUpdate(bool force = false, Func<bool> forceCondition = null)
|
||||
{
|
||||
if (forceCondition == null)
|
||||
forceCondition = () => Main.netMode != NetmodeID.MultiplayerClient;
|
||||
if (force)
|
||||
{
|
||||
if (forceCondition())
|
||||
{
|
||||
NetMessage.SendData(MessageID.SyncProjectile, number: projectile.whoAmI);
|
||||
}
|
||||
}
|
||||
else
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Does things when the projectile is hit.
|
||||
/// </summary>
|
||||
/// <param name="damage">The damage taken by the projectile.</param>
|
||||
/// <param name="target">The projectile which hit the target.</param>
|
||||
public virtual void HitEffectProjectile(int damage, Projectile target)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Does things when the projectile is hit.
|
||||
/// </summary>
|
||||
/// <param name="damage">The damage taken by the projectile.</param>
|
||||
/// <param name="target">The npc which hit the target.</param>
|
||||
public virtual void HitEffectNPC(int damage, NPC target)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Misc Functions
|
||||
/// <summary>
|
||||
/// Creates text, much akin to NPCs, when a mouse is over the projectile's hitbox.
|
||||
/// </summary>
|
||||
public void MouseOverText()
|
||||
{
|
||||
if (!Main.mouseText)
|
||||
{
|
||||
Rectangle mouseRectangle = new Rectangle((int)(Main.mouseX + Main.screenPosition.X), (int)(Main.mouseY + Main.screenPosition.Y), 1, 1);
|
||||
if (Main.player[Main.myPlayer].gravDir == -1f)
|
||||
{
|
||||
mouseRectangle.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY;
|
||||
}
|
||||
if (projectile.Hitbox.Intersects(mouseRectangle))
|
||||
{
|
||||
if (LifeMax > 1)
|
||||
{
|
||||
string lifeDataText = string.Concat(new object[]
|
||||
{
|
||||
projectile.Name,
|
||||
": ",
|
||||
Life,
|
||||
"/",
|
||||
LifeMax
|
||||
});
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, null, null, Main.UIScaleMatrix);
|
||||
Main.instance.MouseTextHackZoom(lifeDataText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Draws a health bar below the projectile.
|
||||
/// </summary>
|
||||
public void DrawHealthBar()
|
||||
{
|
||||
if (Life == LifeMax && !DrawHPBarAtFullHealth)
|
||||
return;
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, null, null, Main.UIScaleMatrix);
|
||||
Main.instance.DrawHealthBar(projectile.Bottom.X, projectile.Bottom.Y, Life, LifeMax, 1f, 1f);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 629 B |
|
After Width: | Height: | Size: 621 B |
|
After Width: | Height: | Size: 558 B |
|
After Width: | Height: | Size: 648 B |
|
After Width: | Height: | Size: 538 B |
|
After Width: | Height: | Size: 386 B |
@@ -0,0 +1,237 @@
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Projectiles.Damageable;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Typeless
|
||||
{
|
||||
public class ArtifactOfResilienceShard1 : ModProjectile
|
||||
{
|
||||
public int Timer = 0;
|
||||
public Vector2 StartingPosition;
|
||||
public const int MaxTimeLeft = 360;
|
||||
public const int FallTime = 240;
|
||||
public const float OutwardMovementTime = 85f;
|
||||
public const float InwardReturnMovementTime = 100f;
|
||||
public const float MaxRadius = 240f;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Artifact Shard");
|
||||
Main.projFrames[projectile.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = MaxTimeLeft;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 20;
|
||||
}
|
||||
public static void ArtifactOfResilienceShardAI(Projectile projectile, ref Vector2 StartingPosition, ref int Timer)
|
||||
{
|
||||
// Spinning
|
||||
if (projectile.localAI[1] == 0f)
|
||||
{
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
StartingPosition = projectile.Center;
|
||||
projectile.localAI[0] = 1f;
|
||||
}
|
||||
Timer++;
|
||||
if (Timer < OutwardMovementTime)
|
||||
{
|
||||
projectile.ai[1] = MathHelper.Lerp(0f, MaxRadius, Timer / OutwardMovementTime);
|
||||
}
|
||||
if (Timer > MaxTimeLeft - InwardReturnMovementTime)
|
||||
{
|
||||
projectile.ai[1] = MathHelper.Lerp(0f, MaxRadius, (Timer - MaxTimeLeft) / -InwardReturnMovementTime);
|
||||
}
|
||||
projectile.ai[0] += MathHelper.Pi / (projectile.ai[1] / MathHelper.Pi + 1);
|
||||
projectile.Center = StartingPosition + projectile.ai[0].ToRotationVector2() * projectile.ai[1];
|
||||
projectile.rotation = projectile.ai[0];
|
||||
if (projectile.timeLeft == 1)
|
||||
{
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.ProfanedFire);
|
||||
dust.velocity = Utils.NextVector2Circular(Main.rand, 36f, 36f);
|
||||
dust.scale = Main.rand.NextFloat(1.9f, 2.45f);
|
||||
dust.noGravity = true;
|
||||
}
|
||||
projectile.timeLeft = FallTime;
|
||||
projectile.tileCollide = true;
|
||||
projectile.velocity = Utils.NextVector2Circular(Main.rand, 18f, 9f);
|
||||
projectile.localAI[1] = 1;
|
||||
}
|
||||
}
|
||||
// Falling
|
||||
else
|
||||
{
|
||||
if (projectile.frameCounter <= ArtifactOfResilienceBulwark.MaxReformations)
|
||||
{
|
||||
// Reform
|
||||
if (projectile.modProjectile is ArtifactOfResilienceShard1 && Main.myPlayer == projectile.owner)
|
||||
{
|
||||
Projectile reformedBulwark = Projectile.NewProjectileDirect(projectile.Center,
|
||||
Vector2.Zero,
|
||||
ModContent.ProjectileType<ArtifactOfResilienceBulwark>(),
|
||||
projectile.damage,
|
||||
projectile.knockBack,
|
||||
projectile.owner);
|
||||
reformedBulwark.frameCounter = projectile.frameCounter; // Incremented on death, not reformation.
|
||||
}
|
||||
projectile.Kill();
|
||||
return;
|
||||
}
|
||||
if (projectile.velocity.Y < 12f)
|
||||
{
|
||||
projectile.velocity.Y += 0.25f;
|
||||
}
|
||||
projectile.velocity.X *= 0.95f;
|
||||
projectile.rotation = projectile.velocity.ToRotation();
|
||||
if (projectile.timeLeft < 60f)
|
||||
{
|
||||
projectile.alpha = 255 - (int)MathHelper.Lerp(0, 255, projectile.timeLeft / 60f);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
public override void AI() => ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer);
|
||||
}
|
||||
public class ArtifactOfResilienceShard2 : ModProjectile
|
||||
{
|
||||
public int Timer = 0;
|
||||
public Vector2 StartingPosition;
|
||||
public const float MaxRadius = 660f;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Artifact Shard");
|
||||
Main.projFrames[projectile.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 40;
|
||||
}
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer);
|
||||
}
|
||||
public class ArtifactOfResilienceShard3 : ModProjectile
|
||||
{
|
||||
public int Timer = 0;
|
||||
public Vector2 StartingPosition;
|
||||
public const float MaxRadius = 660f;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Artifact Shard");
|
||||
Main.projFrames[projectile.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 40;
|
||||
}
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer);
|
||||
}
|
||||
public class ArtifactOfResilienceShard4 : ModProjectile
|
||||
{
|
||||
public int Timer = 0;
|
||||
public Vector2 StartingPosition;
|
||||
public const float MaxRadius = 660f;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Artifact Shard");
|
||||
Main.projFrames[projectile.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 40;
|
||||
}
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer);
|
||||
}
|
||||
public class ArtifactOfResilienceShard5 : ModProjectile
|
||||
{
|
||||
public int Timer = 0;
|
||||
public Vector2 StartingPosition;
|
||||
public const float MaxRadius = 660f;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Artifact Shard");
|
||||
Main.projFrames[projectile.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 40;
|
||||
}
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer);
|
||||
}
|
||||
public class ArtifactOfResilienceShard6 : ModProjectile
|
||||
{
|
||||
public int Timer = 0;
|
||||
public Vector2 StartingPosition;
|
||||
public const float MaxRadius = 660f;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Artifact Shard");
|
||||
Main.projFrames[projectile.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 40;
|
||||
}
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer);
|
||||
}
|
||||
}
|
||||