Start of GoJ

This commit is contained in:
Xyk committed 2024-03-03 18:02:09 -08:00
1 parent 96937dc072
commit 7bcb1545d6
5 files changed
+158 -48

No files matched your search

+51 -5
View File
@@ -1,31 +1,77 @@
using CalamityMod.Projectiles.Melee;
using CalamityMod.Dusts;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Melee;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.Audio;
namespace CalamityMod.Items.Weapons.Melee
{
public class GreatswordofJudgement : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Melee";
private float swingRoatation = 0;
private int time = 0;
private Color mainColor;
private int swordDirection;
public override void SetDefaults()
{
Item.width = 78;
Item.height = 78;
Item.damage = 40;
Item.DamageType = DamageClass.Melee;
Item.useAnimation = 18;
Item.useAnimation = 25;
Item.useStyle = ItemUseStyleID.Swing;
Item.useTime = 18;
Item.useTime = 25;
Item.useTurn = true;
Item.knockBack = 7f;
Item.UseSound = SoundID.Item1;
Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/TerratomereSwing") with { Volume = 0.3f, Pitch = 0.5f };
Item.autoReuse = true;
Item.value = CalamityGlobalItem.Rarity10BuyPrice;
Item.rare = ItemRarityID.Red;
Item.shoot = ModContent.ProjectileType<JudgementProj>();
Item.shootSpeed = 10f;
Item.shootSpeed = 5f;
}
public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox)
{
float scale = 1.1f;
Vector2 newSize = new Point(hitbox.Width, hitbox.Height).ToVector2() * scale;
hitbox = new Rectangle(hitbox.X - (int)((newSize.X - hitbox.Width) / 2f), hitbox.Y - (int)((newSize.Y - hitbox.Height) / 2f), (int)newSize.X, (int)newSize.Y);
}
public override void UseAnimation(Player player)
{
swordDirection = player.direction;
time = 0;
swingRoatation = 0;
mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid;
}
public override void MeleeEffects(Player player, Rectangle hitbox)
{
time++;
swingRoatation += swordDirection == 1 ? 0.13f : -0.13f;
float Rot = (swordDirection == -1 ? 1.8f : -1.8f) + swingRoatation;
if (swordDirection != player.direction)
{
swingRoatation *= -1;
swordDirection = player.direction;
}
Particle Smear = new SemiCircularSmearFade(player.Center, Vector2.Zero, mainColor * 0.8f, Rot, Main.rand.NextFloat(1.75f, 1.8f), new Vector2(1, 1), 2, true, false, true, player.direction);
GeneralParticleHandler.SpawnParticle(Smear);
if (Main.rand.NextBool(3))
{
Vector2 dustVel = new Vector2(5 * swordDirection, -5).RotatedByRandom(1.55f) * Main.rand.NextFloat(0.7f, 1.3f);
Dust dust = Dust.NewDustPerfect(player.Center + dustVel * 9, 278);
dust.scale = Main.rand.NextFloat(0.4f, 0.55f);
dust.velocity = dustVel * 0.55f;
dust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid;
dust.noGravity = true;
}
}
public override void AddRecipes()
{
CreateRecipe().
+62
View File
@@ -0,0 +1,62 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Particles
{
public class SemiCircularSmearFade : Particle
{
public override string Texture => "CalamityMod/Particles/SemiCircularSmearVertical";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public Player player = Main.player[Main.myPlayer];
public Color InitialColor;
public bool PlayerCentered;
public bool RotateToVelocity;
public Vector2 Squish;
public bool ProduceLight;
public int Direction;
public SemiCircularSmearFade(Vector2 position, Vector2 velocity, Color color, float rotation, float scale, Vector2 squish, int lifetime, bool playerCentered = false, bool rotateToVelocity = false, bool produceLight = true, int direction = 1)
{
Position = position;
Velocity = velocity;
Color = InitialColor = color;
Scale = scale;
Squish = squish;
Rotation = rotation;
Lifetime = lifetime;
PlayerCentered = playerCentered;
RotateToVelocity = rotateToVelocity;
ProduceLight = produceLight;
Direction = direction;
}
public override void Update()
{
if (PlayerCentered)
Position = player.MountedCenter;
if (RotateToVelocity)
Rotation = Velocity.ToRotation() + MathHelper.PiOver2;
if (ProduceLight)
{
Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f);
}
Scale *= 0.95f;
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
Velocity *= 0.95f;
}
//Use custom draw for the squish
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, Rotation, tex.Size() * 0.5f, Scale * Squish, Direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+45 -43
View File
@@ -9,69 +9,71 @@ namespace CalamityMod.Projectiles.Melee
public class JudgementProj : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
int whiteLightTimer = 5;
public ref float time => ref Projectile.ai[0];
public float hitboxSize = 10;
public Color mainColor;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
}
public override void SetDefaults()
{
Projectile.width = 12;
Projectile.height = 12;
Projectile.width = 132;
Projectile.height = 30;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 60;
Projectile.tileCollide = false;
Projectile.timeLeft = 450;
Projectile.DamageType = DamageClass.Melee;
Projectile.usesIDStaticNPCImmunity = true;
Projectile.idStaticNPCHitCooldown = 10;
Projectile.extraUpdates = 15;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
whiteLightTimer--;
if (whiteLightTimer == 0)
if (time == 0)
{
float spread = 180f * 0.0174f;
double startAngle = Math.Atan2(Projectile.velocity.X, Projectile.velocity.Y) - spread / 2;
double deltaAngle = spread / 8f;
double offsetAngle;
int i;
if (Projectile.owner == Main.myPlayer)
{
for (i = 0; i < 1; i++)
{
offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i;
int projectile1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType<WhiteOrb>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f);
int projectile2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType<WhiteOrb>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f);
Main.projectile[projectile1].velocity.X *= 0.1f;
Main.projectile[projectile1].velocity.Y *= 0.1f;
Main.projectile[projectile2].velocity.X *= 0.1f;
Main.projectile[projectile2].velocity.Y *= 0.1f;
}
}
whiteLightTimer = 5;
Projectile.scale = 0.25f;
Projectile.velocity *= 0.75f;
mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid;
}
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f);
for (int i = 0; i < 2; i++)
Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2;
if (time < 200)
{
int shinyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.GemDiamond, 0f, 0f, 100, default, 1.25f);
Main.dust[shinyDust].noGravity = true;
Main.dust[shinyDust].velocity *= 0.5f;
Main.dust[shinyDust].velocity += Projectile.velocity * 0.1f;
Projectile.scale += 0.008f;
hitboxSize += 0.55f;
}
Projectile.velocity *= 0.995f;
if (time < 300 && time > 20 && Main.rand.NextBool(3))
{
Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(hitboxSize, hitboxSize), 66);
trailDust.scale = Main.rand.NextFloat(0.7f, 0.85f);
trailDust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.85f, 1.5f);
trailDust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid;
trailDust.noGravity = true;
}
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 9f, 20f);
time++;
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item122, Projectile.position);
if (Projectile.owner == Main.myPlayer)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 100, 0f, 0f, ModContent.ProjectileType<WhiteBoltAura>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f);
}
//Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 100, 0f, 0f, ModContent.ProjectileType<WhiteBoltAura>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f);
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, mainColor == Color.MediumPurple ? Color.MediumOrchid : Color.MediumPurple);
return true;
}
public override Color? GetAlpha(Color lightColor)
{
return mainColor;
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, hitboxSize, targetHitbox);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB