Added the Prince
This commit is contained in:
1 parent
91c3b290c8
commit
bd77d14c3a
8 files changed
+276
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Dusts
|
||||
{
|
||||
public class RosePiece : ModDust
|
||||
{
|
||||
public override void OnSpawn(Dust dust)
|
||||
{
|
||||
dust.color = default;
|
||||
dust.rotation = Main.rand.NextFloat(MathHelper.TwoPi);
|
||||
}
|
||||
|
||||
public override bool Update(Dust dust)
|
||||
{
|
||||
dust.rotation += MathHelper.ToRadians(1.56f);
|
||||
|
||||
if (!dust.noGravity)
|
||||
dust.velocity.Y = MathHelper.Clamp(dust.velocity.Y + 0.15f, -1.8f, 2.5f);
|
||||
|
||||
Vector2 velocity = Vector2.UnitY.RotatedBy(dust.rotation) * new Vector2(2f, 0.5f);
|
||||
|
||||
// Adjust the move angle if a tile has been hit.
|
||||
if (velocity != Collision.TileCollision(dust.position, velocity, (int)(dust.scale * 4f), (int)(dust.scale * 4f)))
|
||||
dust.rotation = -1f;
|
||||
|
||||
dust.position += velocity + dust.velocity;
|
||||
|
||||
// Fade away.
|
||||
dust.scale = MathHelper.Clamp(dust.scale - 0.01f, 0f, 4f) * 0.99f;
|
||||
if (dust.scale < 0.4f)
|
||||
dust.active = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Dust dust, Color lightColor) => lightColor;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 178 B |
@@ -0,0 +1,68 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Projectiles.Magic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Magic
|
||||
{
|
||||
public class ThePrince : ModItem
|
||||
{
|
||||
public const int FlameSplitCount = 6;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("The Prince");
|
||||
Tooltip.SetDefault($"Casts a holy fireball that explodes into {FlameSplitCount} flames\n" +
|
||||
"So you're telling me that the prince exploded, and then turned into a flower?\n" +
|
||||
"-Dain, the sailor druid");
|
||||
Item.staff[item.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.damage = 155;
|
||||
item.knockBack = 4.25f;
|
||||
item.shootSpeed = 23.5f;
|
||||
item.magic = true;
|
||||
item.noMelee = true;
|
||||
item.mana = 12;
|
||||
item.width = 102;
|
||||
item.height = 112;
|
||||
item.useTime = item.useAnimation = 21;
|
||||
item.useStyle = ItemUseStyleID.HoldingOut;
|
||||
item.autoReuse = true;
|
||||
item.UseSound = SoundID.DD2_FlameburstTowerShot;
|
||||
item.shoot = ModContent.ProjectileType<PrinceFlameLarge>();
|
||||
item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice;
|
||||
item.rare = ItemRarityID.Purple;
|
||||
item.Calamity().customRarity = CalamityRarity.Turquoise;
|
||||
}
|
||||
|
||||
public override Vector2? HoldoutOrigin()
|
||||
{
|
||||
return new Vector2(20f, 20f);
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
||||
{
|
||||
Vector2 velocity = new Vector2(speedX, speedY);
|
||||
Vector2 flameSpawnPosition = player.RotatedRelativePoint(player.MountedCenter, true);
|
||||
flameSpawnPosition += velocity.SafeNormalize(Vector2.Zero) * 105f;
|
||||
Projectile.NewProjectile(flameSpawnPosition, velocity, type, damage, knockBack, player.whoAmI);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<ArchAmaryllis>());
|
||||
recipe.AddIngredient(ModContent.ItemType<DivineGeode>(), 20);
|
||||
recipe.AddIngredient(ModContent.ItemType<UnholyEssence>(), 10);
|
||||
recipe.AddIngredient(ModContent.ItemType<UeliaceBar>(), 7);
|
||||
recipe.AddTile(TileID.LunarCraftingStation);
|
||||
recipe.SetResult(this);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,114 @@
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Items.Weapons.Magic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class PrinceFlameLarge : ModProjectile
|
||||
{
|
||||
public ref float Time => ref projectile.ai[0];
|
||||
public const int Lifetime = 60;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Holy Fireball");
|
||||
Main.projFrames[projectile.type] = 8;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 4;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = projectile.height = 40;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = Lifetime;
|
||||
projectile.penetrate = -1;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 11;
|
||||
projectile.magic = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Create rose petals.
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Dust rose = Dust.NewDustPerfect(projectile.Center, ModContent.DustType<RosePiece>());
|
||||
rose.velocity += projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(0.61f) * 2.5f;
|
||||
rose.velocity.Y += Main.rand.NextFloat(-2.4f, 1.6f);
|
||||
rose.velocity *= 0.4f;
|
||||
rose.scale = Main.rand.NextFloat(1.2f, 1.7f);
|
||||
rose.noGravity = Main.rand.NextBool();
|
||||
}
|
||||
projectile.localAI[0] = 1f;
|
||||
}
|
||||
|
||||
// Dissipate at the end of the projectile's lifetime.
|
||||
if (projectile.timeLeft < 26f)
|
||||
{
|
||||
projectile.rotation = projectile.rotation.AngleLerp(0f, 0.15f);
|
||||
projectile.frame = (int)Math.Round(MathHelper.Lerp(4f, 7f, Utils.InverseLerp(26f, 0f, projectile.timeLeft, true)));
|
||||
projectile.velocity *= 0.95f;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create bursts of fire dust.
|
||||
if (Time % 8f == 7f)
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
Vector2 dustSpawnOffset = Vector2.UnitX * -projectile.width / 2f;
|
||||
dustSpawnOffset += -Vector2.UnitY.RotatedBy(i * MathHelper.TwoPi / 12f) * new Vector2(8f, 16f);
|
||||
dustSpawnOffset = dustSpawnOffset.RotatedBy(projectile.rotation - MathHelper.PiOver2);
|
||||
|
||||
Dust holyFire = Dust.NewDustDirect(projectile.Center, 0, 0, (int)CalamityDusts.ProfanedFire, 0f, 0f, 160, default, 1f);
|
||||
holyFire.scale = 1.1f;
|
||||
holyFire.noGravity = true;
|
||||
holyFire.position = projectile.Center + dustSpawnOffset;
|
||||
holyFire.velocity = projectile.velocity * 0.1f;
|
||||
holyFire.velocity = (projectile.Center - projectile.velocity * 3f - holyFire.position).SafeNormalize(Vector2.Zero) * 1.25f;
|
||||
}
|
||||
}
|
||||
|
||||
Dust fire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire);
|
||||
fire.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 6f);
|
||||
fire.scale *= Main.rand.NextFloat(1.15f, 1.7f);
|
||||
fire.noGravity = Main.rand.NextBool();
|
||||
|
||||
Time++;
|
||||
projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2;
|
||||
projectile.frameCounter++;
|
||||
projectile.frame = projectile.frameCounter / 5 % 4;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
lightColor = Color.Lerp(lightColor, Color.White, 0.8f);
|
||||
lightColor.A /= 4;
|
||||
CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
if (Main.myPlayer != projectile.owner)
|
||||
return;
|
||||
|
||||
int damage = (int)(projectile.damage * 0.66f);
|
||||
float kb = projectile.knockBack * 0.4f;
|
||||
for (int i = 0; i < ThePrince.FlameSplitCount; i++)
|
||||
{
|
||||
Vector2 shootVelocity = (MathHelper.TwoPi * i / ThePrince.FlameSplitCount).ToRotationVector2() * 8f;
|
||||
Vector2 flameSpawnPosition = projectile.Center + shootVelocity;
|
||||
Projectile.NewProjectile(flameSpawnPosition, shootVelocity, ModContent.ProjectileType<PrinceFlameSmall>(), damage, kb, projectile.owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,53 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class PrinceFlameSmall : ModProjectile
|
||||
{
|
||||
public ref float Time => ref projectile.ai[0];
|
||||
public const int AttackDelay = 12;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Holy Fire");
|
||||
Main.projFrames[projectile.type] = 4;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 3;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = projectile.height = 16;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = 300;
|
||||
projectile.penetrate = 1;
|
||||
projectile.magic = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Time++;
|
||||
projectile.frameCounter++;
|
||||
projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type];
|
||||
projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2;
|
||||
|
||||
if (Time > AttackDelay)
|
||||
CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 700f, 14f, 32f);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
lightColor = Color.Lerp(lightColor, Color.White, 0.8f);
|
||||
lightColor.A /= 3;
|
||||
CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanDamage() => Time > AttackDelay;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 837 B |
Reference in new issue
Block a user