Added the Maelstrom
This commit is contained in:
1 parent
2b5bbc1330
commit
d81b5e2c2f
12 files changed
+392
-3
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 364 B |
Binary file not shown.
|
After Width: | Height: | Size: 240 B |
Binary file not shown.
|
After Width: | Height: | Size: 341 B |
@@ -0,0 +1,61 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Items.Placeables;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
public class TheMaelstrom : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("The Maelstrom");
|
||||
Tooltip.SetDefault("Fires charged Reaper Sharks that explode into water");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.damage = 397;
|
||||
item.width = 20;
|
||||
item.height = 12;
|
||||
item.useTime = 45;
|
||||
item.useAnimation = 45;
|
||||
item.useStyle = ItemUseStyleID.HoldingOut;
|
||||
item.knockBack = 3f;
|
||||
item.value = CalamityGlobalItem.Rarity12BuyPrice;
|
||||
item.rare = ItemRarityID.Purple;
|
||||
item.Calamity().customRarity = CalamityRarity.Turquoise;
|
||||
item.noMelee = true;
|
||||
item.noUseGraphic = true;
|
||||
item.ranged = true;
|
||||
item.channel = true;
|
||||
item.autoReuse = true;
|
||||
item.shoot = ModContent.ProjectileType<MaelstromHoldout>();
|
||||
item.shootSpeed = 20f;
|
||||
item.useAmmo = AmmoID.Arrow;
|
||||
item.Calamity().canFirePointBlankShots = 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)
|
||||
{
|
||||
Projectile.NewProjectile(position, new Vector2(speedX, speedY).SafeNormalize(Vector2.UnitX * player.direction), ModContent.ProjectileType<MaelstromHoldout>(), 0, 0f, player.whoAmI);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<TheStorm>());
|
||||
recipe.AddIngredient(ModContent.ItemType<ReaperTooth>(), 3);
|
||||
recipe.AddIngredient(ModContent.ItemType<DivineGeode>(), 20);
|
||||
recipe.AddIngredient(ModContent.ItemType<Voidstone>(), 50);
|
||||
recipe.AddTile(TileID.LunarCraftingStation);
|
||||
recipe.SetResult(this);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@@ -9,16 +9,18 @@ namespace CalamityMod.Particles
|
||||
public class SparkParticle : Particle
|
||||
{
|
||||
public Color InitialColor;
|
||||
public bool AffectedByGravity;
|
||||
public override bool SetLifetime => true;
|
||||
public override bool UseCustomDraw => true;
|
||||
public override bool UseAdditiveBlend => true;
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/StarProj";
|
||||
|
||||
public SparkParticle(Vector2 relativePosition, Vector2 velocity, int lifetime, float scale, Color color)
|
||||
public SparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color)
|
||||
{
|
||||
Position = relativePosition;
|
||||
Velocity = velocity;
|
||||
AffectedByGravity = affectedByGravity;
|
||||
Scale = scale;
|
||||
Lifetime = lifetime;
|
||||
Color = InitialColor = color;
|
||||
@@ -29,7 +31,7 @@ namespace CalamityMod.Particles
|
||||
Scale *= 0.95f;
|
||||
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
|
||||
Velocity *= 0.95f;
|
||||
if (Velocity.Length() < 12f)
|
||||
if (Velocity.Length() < 12f && AffectedByGravity)
|
||||
{
|
||||
Velocity.X *= 0.94f;
|
||||
Velocity.Y += 0.25f;
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f);
|
||||
sparkVelocity.Y -= 6f;
|
||||
SparkParticle spark = new SparkParticle(impactPoint, sparkVelocity, sparkLifetime, sparkScale, sparkColor);
|
||||
SparkParticle spark = new SparkParticle(impactPoint, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class MaelstromHoldout : ModProjectile
|
||||
{
|
||||
private Player Owner => Main.player[projectile.owner];
|
||||
private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed;
|
||||
private ref float CurrentChargingFrames => ref projectile.ai[0];
|
||||
private ref float ArrowsLoaded => ref projectile.ai[1];
|
||||
private ref float FramesToLoadNextArrow => ref projectile.localAI[0];
|
||||
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Ranged/TheMaelstrom";
|
||||
public override void SetStaticDefaults() => DisplayName.SetDefault("The Maelstrom");
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 78;
|
||||
projectile.height = 137;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.ranged = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true);
|
||||
Vector2 shootPosition = armPosition + projectile.velocity * projectile.width * 0.5f;
|
||||
|
||||
// Destroy the holdout projectile if the owner is no longer eligible to hold it.
|
||||
if (!OwnerCanShoot)
|
||||
{
|
||||
projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
// Frame 1 effects: Record how fast the hold item being used is, to determine how fast to load arrows.
|
||||
if (FramesToLoadNextArrow == 0f)
|
||||
{
|
||||
Main.PlaySound(SoundID.Item20, projectile.Center);
|
||||
FramesToLoadNextArrow = Owner.ActiveItem().useAnimation;
|
||||
}
|
||||
|
||||
// Actually make progress towards loading more arrows.
|
||||
CurrentChargingFrames++;
|
||||
|
||||
// If it is time to do so, produce a pulse of particles and shoot an arrow.
|
||||
if (CurrentChargingFrames % FramesToLoadNextArrow == FramesToLoadNextArrow - 1)
|
||||
ShootProjectiles(shootPosition);
|
||||
|
||||
UpdateProjectileHeldVariables(armPosition);
|
||||
ManipulatePlayerVariables();
|
||||
}
|
||||
|
||||
public void ShootProjectiles(Vector2 shootPosition)
|
||||
{
|
||||
// Create electric particles.
|
||||
if (Main.netMode != NetmodeID.Server)
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
int sparkLifetime = Main.rand.Next(22, 36);
|
||||
float sparkScale = Main.rand.NextFloat(1f, 1.3f);
|
||||
Color sparkColor = Color.Lerp(Color.Cyan, Color.AliceBlue, Main.rand.NextFloat(0.35f));
|
||||
Vector2 sparkVelocity = (MathHelper.TwoPi * i / 16f + Main.rand.NextFloat(0.09f)).ToRotationVector2() * Main.rand.NextFloat(6f, 14f);
|
||||
sparkVelocity.Y -= Owner.gravDir * 4f;
|
||||
|
||||
SparkParticle spark = new SparkParticle(shootPosition, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
}
|
||||
|
||||
// Play a shoot sound.
|
||||
Main.PlaySound(SoundID.Item66, projectile.Center);
|
||||
Main.PlaySound(SoundID.Item96, projectile.Center);
|
||||
|
||||
if (Main.myPlayer != projectile.owner)
|
||||
return;
|
||||
|
||||
Item heldItem = Owner.ActiveItem();
|
||||
|
||||
// Calculate damage at the instant the arrow is fired
|
||||
int arrowDamage = (int)(heldItem.damage * Owner.RangedDamage());
|
||||
float shootSpeed = heldItem.shootSpeed;
|
||||
float knockback = heldItem.knockBack;
|
||||
|
||||
bool uselessFuckYou = OwnerCanShoot;
|
||||
int projectileType = 0;
|
||||
Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref arrowDamage, ref knockback, false);
|
||||
projectileType = ModContent.ProjectileType<TheMaelstromShark>();
|
||||
|
||||
knockback = Owner.GetWeaponKnockback(heldItem, knockback);
|
||||
Vector2 shootVelocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * shootSpeed;
|
||||
|
||||
Projectile.NewProjectile(shootPosition, shootVelocity, projectileType, arrowDamage, knockback, projectile.owner, 0f, 0f);
|
||||
}
|
||||
|
||||
private void UpdateProjectileHeldVariables(Vector2 armPosition)
|
||||
{
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
float aimInterpolant = Utils.InverseLerp(5f, 25f, projectile.Distance(Main.MouseWorld), true);
|
||||
Vector2 oldVelocity = projectile.velocity;
|
||||
projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(Main.MouseWorld), aimInterpolant);
|
||||
if (projectile.velocity != oldVelocity)
|
||||
{
|
||||
projectile.netSpam = 0;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
projectile.position = armPosition - projectile.Size * 0.5f + projectile.velocity * 24f;
|
||||
projectile.rotation = projectile.velocity.ToRotation();
|
||||
if (projectile.spriteDirection == -1)
|
||||
projectile.rotation += MathHelper.Pi;
|
||||
projectile.spriteDirection = projectile.direction;
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
|
||||
private void ManipulatePlayerVariables()
|
||||
{
|
||||
Owner.ChangeDir(projectile.direction);
|
||||
Owner.heldProj = projectile.whoAmI;
|
||||
Owner.itemTime = 2;
|
||||
Owner.itemAnimation = 2;
|
||||
Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation();
|
||||
}
|
||||
|
||||
public override bool CanDamage() => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class TheMaelstromExplosion : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Explosion");
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 75;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.friendly = true;
|
||||
projectile.magic = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.scale = 0.1f;
|
||||
|
||||
// Hardcoded spaghetti appearss to make the scale setting above tamper with the hitbox.
|
||||
projectile.width = projectile.height = (int)(60 / projectile.scale);
|
||||
projectile.timeLeft = 60;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 16;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.scale = MathHelper.Lerp(projectile.scale, 1f, 0.125f);
|
||||
projectile.Opacity = projectile.scale * Utils.InverseLerp(0f, 30f, projectile.timeLeft, true);
|
||||
|
||||
// Emit sparks and dust.
|
||||
if (Main.netMode != NetmodeID.Server)
|
||||
{
|
||||
int sparkLifetime = Main.rand.Next(22, 36);
|
||||
float sparkScale = Main.rand.NextFloat(1f, 1.3f);
|
||||
Color sparkColor = Color.Lerp(Color.Cyan, Color.DarkBlue, Main.rand.NextFloat(0.7f));
|
||||
Vector2 sparkVelocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(3f, 8f);
|
||||
|
||||
SparkParticle spark = new SparkParticle(projectile.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
|
||||
Vector2 dustSpawnOffset = Main.rand.NextVector2Circular(projectile.width, projectile.height) * projectile.scale * 0.4f;
|
||||
Dust electricity = Dust.NewDustPerfect(projectile.Center + dustSpawnOffset, 267);
|
||||
electricity.color = Color.Cyan;
|
||||
electricity.color.A = 84;
|
||||
electricity.scale *= Main.rand.NextFloat(0.7f, 1.2f);
|
||||
electricity.velocity = dustSpawnOffset.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2).RotatedByRandom(0.37f);
|
||||
electricity.velocity *= Main.rand.NextFloat(2f, 6f);
|
||||
electricity.noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = Main.projectileTexture[projectile.type];
|
||||
Vector2 origin = texture.Size() * 0.5f;
|
||||
|
||||
Color frontAfterimageColor = projectile.GetAlpha(Color.Lerp(Color.Cyan, Color.DarkBlue, projectile.identity / 7f % 0.8f)) * 0.2f;
|
||||
frontAfterimageColor.A = 0;
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / 12f + projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * 2f;
|
||||
Vector2 afterimageDrawPosition = projectile.Center + drawOffset - Main.screenPosition;
|
||||
spriteBatch.Draw(texture, afterimageDrawPosition, null, frontAfterimageColor, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
{
|
||||
return CalamityUtils.CircularHitboxCollision(projectile.Center, projectile.Size.Length() * projectile.scale / 1.414f, targetHitbox);
|
||||
}
|
||||
|
||||
public override bool CanDamage() => projectile.Opacity > 0.4f;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,105 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class TheMaelstromShark : ModProjectile
|
||||
{
|
||||
public PrimitiveTrail LightningTrailDrawer = null;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Reaper Shark");
|
||||
Main.projFrames[projectile.type] = 6;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 15;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 44;
|
||||
projectile.height = 44;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.arrow = true;
|
||||
projectile.penetrate = 1;
|
||||
projectile.Opacity = 0f;
|
||||
projectile.ranged = true;
|
||||
projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.frameCounter++;
|
||||
projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type];
|
||||
|
||||
projectile.rotation = projectile.velocity.ToRotation();
|
||||
projectile.spriteDirection = (Math.Cos(projectile.rotation) > 0f).ToDirectionInt();
|
||||
if (projectile.spriteDirection == -1)
|
||||
projectile.rotation += MathHelper.Pi;
|
||||
|
||||
projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.1f, 0f, 1f);
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height);
|
||||
Main.PlaySound(SoundID.Dig, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
internal Color ColorFunction(float completionRatio)
|
||||
{
|
||||
float fadeOpacity = Utils.InverseLerp(0.94f, 0.54f, completionRatio, true) * projectile.Opacity;
|
||||
return Color.Lerp(Color.Cyan, Color.White, 0.4f) * fadeOpacity;
|
||||
}
|
||||
|
||||
internal float WidthFunction(float completionRatio)
|
||||
{
|
||||
float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.InverseLerp(0f, 0.3f, completionRatio, true), 2D);
|
||||
return MathHelper.Lerp(0f, 12f * projectile.Opacity, expansionCompletion);
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
// Create death effects for the shark, including a death sound, gore, and some blood.
|
||||
Main.PlaySound(SoundID.NPCDeath1, projectile.Center);
|
||||
Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/MaelstromReaperShark1"), projectile.scale);
|
||||
Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/MaelstromReaperShark2"), projectile.scale);
|
||||
Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/MaelstromReaperShark3"), projectile.scale);
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
Dust blood = Dust.NewDustPerfect(projectile.Center, 5);
|
||||
blood.velocity = Main.rand.NextVector2Circular(6f, 6f);
|
||||
blood.scale *= Main.rand.NextFloat(0.7f, 1.3f);
|
||||
blood.noGravity = true;
|
||||
}
|
||||
|
||||
if (Main.myPlayer != projectile.owner)
|
||||
return;
|
||||
|
||||
Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<TheMaelstromExplosion>(), projectile.damage, 0f, projectile.owner);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = Main.projectileTexture[projectile.type];
|
||||
Rectangle frame = texture.Frame(1, Main.projFrames[projectile.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;
|
||||
|
||||
if (LightningTrailDrawer is null)
|
||||
LightningTrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
|
||||
|
||||
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak"));
|
||||
LightningTrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition, 60);
|
||||
spriteBatch.Draw(texture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, direction, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Reference in new issue
Block a user