Loot crate particle and item resprites
This commit is contained in:
1 parent
10f3544d64
commit
da33c1e3b8
13 files changed
+161
-43
No files matched your search
@@ -36,6 +36,7 @@ using CalamityMod.Items.VanillaArmorChanges;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.Items.Weapons.Summon;
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.NPCs.Abyss;
|
||||
using CalamityMod.NPCs.ExoMechs.Apollo;
|
||||
@@ -5601,6 +5602,9 @@ namespace CalamityMod.CalPlayer
|
||||
Player.head = EquipLoader.GetEquipSlot(Mod, snowmanNoseless ? "PopoNoseless" : "Popo", EquipType.Head);
|
||||
Player.face = -1;
|
||||
}
|
||||
else if (AresExoskeleton.ArmExists(Player))
|
||||
Player.body = EquipLoader.GetEquipSlot(Mod, "AresExoskeleton", EquipType.Body);
|
||||
|
||||
else if ((abyssalDivingSuitPower || abyssalDivingSuitForce) && !abyssalDivingSuitHide)
|
||||
{
|
||||
Player.legs = EquipLoader.GetEquipSlot(Mod, "AbyssalDivingSuit", EquipType.Legs);
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace CalamityMod.ILEditing
|
||||
{
|
||||
cache.Add(new OrderedProjectileEntry()
|
||||
{
|
||||
Proj = Main.projectile[i] ?? new Projectile(),
|
||||
Proj = Main.projectile[i] ?? new(),
|
||||
OriginalIndex = i
|
||||
});
|
||||
}
|
||||
@@ -182,12 +182,18 @@ namespace CalamityMod.ILEditing
|
||||
});
|
||||
cursor.Emit(OpCodes.Stsfld, typeof(ILChanges).GetField("OrderedProjectiles", BindingFlags.Static | BindingFlags.Public));
|
||||
|
||||
// Find the update loop update local index.
|
||||
int updateLoopLocalIndex = -1;
|
||||
cursor.GotoNext(i => i.MatchStloc(out updateLoopLocalIndex));
|
||||
|
||||
// Go before the declaration of the projectile loop index and declare the ordered projectile.
|
||||
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchStsfld<Main>("ProjectileUpdateLoopIndex")))
|
||||
cursor.Goto(0);
|
||||
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStsfld<Main>("ProjectileUpdateLoopIndex")))
|
||||
{
|
||||
LogFailure("Projectile Update Priority fix", "Could not locate the ProjectileUpdateLoopIndex field.");
|
||||
return;
|
||||
}
|
||||
int updateIndexPosition = cursor.Index;
|
||||
|
||||
// Replace the projectile reference on the Projectile.Update call.
|
||||
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdelemRef()))
|
||||
@@ -199,14 +205,21 @@ namespace CalamityMod.ILEditing
|
||||
// Pop the Main.projectile[i] reference and replace it with OrderedProjectiles[i].Proj.
|
||||
cursor.Emit(OpCodes.Pop);
|
||||
cursor.Emit(OpCodes.Ldsfld, typeof(ILChanges).GetField("OrderedProjectiles", BindingFlags.Static | BindingFlags.Public));
|
||||
cursor.Emit(OpCodes.Ldloc, 29);
|
||||
cursor.Emit(OpCodes.Ldloc, updateLoopLocalIndex);
|
||||
cursor.Emit(OpCodes.Callvirt, typeof(List<OrderedProjectileEntry>).GetMethod("get_Item"));
|
||||
cursor.Emit(OpCodes.Ldfld, typeof(OrderedProjectileEntry).GetField("Proj"));
|
||||
|
||||
// Remove the direct i reference in the Update call and replace it with the original index in the cache, to prevent update ID
|
||||
// Pop the direct i reference in the Update call and replace it with the original index in the cache, to prevent update ID
|
||||
// mismatches.
|
||||
cursor.Remove();
|
||||
cursor.Emit(OpCodes.Ldloc, 29);
|
||||
cursor.Goto(updateIndexPosition);
|
||||
|
||||
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCall<Projectile>("Call")))
|
||||
{
|
||||
LogFailure("Projectile Update Priority fix", "Could not locate the projectile Update call.");
|
||||
return;
|
||||
}
|
||||
cursor.Emit(OpCodes.Pop);
|
||||
cursor.Emit(OpCodes.Ldloc, updateLoopLocalIndex);
|
||||
cursor.EmitDelegate<Func<int, int>>(i => OrderedProjectiles[i].OriginalIndex);
|
||||
}
|
||||
#endregion Fix Projectile Update Priority Problems
|
||||
|
||||
@@ -6,27 +6,12 @@ using Microsoft.Xna.Framework;
|
||||
using Terraria.DataStructures;
|
||||
using CalamityMod.Items.Accessories.Vanity;
|
||||
using CalamityMod.Cooldowns;
|
||||
using CalamityMod.Projectiles.Magic;
|
||||
using Terraria.Audio;
|
||||
using ReLogic.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Linq;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Projectiles.Magic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
using static Microsoft.Xna.Framework.Input.Keys;
|
||||
using System;
|
||||
using CalamityMod.Items.BaseItems;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Particles;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
using static Microsoft.Xna.Framework.Input.Keys;
|
||||
|
||||
namespace CalamityMod.Items.Armor.Wulfrum
|
||||
{
|
||||
|
||||
@@ -4,11 +4,19 @@ using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Projectiles.Summon.SmallAresArms;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using CalamityMod.Particles;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Summon
|
||||
{
|
||||
public class AresExoskeleton : ModItem
|
||||
{
|
||||
public int FrameCounter = 0;
|
||||
|
||||
public int Frame = 0;
|
||||
|
||||
public const int BoxParticleLifetime = 95;
|
||||
|
||||
public const int PlasmaCannonShootRate = 30;
|
||||
|
||||
public const int TeslaCannonShootRate = 30;
|
||||
@@ -23,6 +31,27 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
|
||||
public const float NukeDamageFactor = 1.5f;
|
||||
|
||||
public static bool ArmExists(Player player)
|
||||
{
|
||||
if (player.ownedProjectileCounts[ModContent.ProjectileType<ExoskeletonPlasmaCannon>()] >= 1)
|
||||
return true;
|
||||
if (player.ownedProjectileCounts[ModContent.ProjectileType<ExoskeletonTeslaCannon>()] >= 1)
|
||||
return true;
|
||||
if (player.ownedProjectileCounts[ModContent.ProjectileType<ExoskeletonLaserCannon>()] >= 1)
|
||||
return true;
|
||||
if (player.ownedProjectileCounts[ModContent.ProjectileType<ExoskeletonGaussNukeCannon>()] >= 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
// Add the body equip texture.
|
||||
if (Main.netMode != NetmodeID.Server)
|
||||
EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Body}", EquipType.Body, this);
|
||||
}
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Ares' Exoskeleton");
|
||||
@@ -39,7 +68,7 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
Item.damage = 672;
|
||||
Item.useStyle = ItemUseStyleID.HoldUp;
|
||||
Item.noUseGraphic = true;
|
||||
Item.width = Item.height = 56;
|
||||
Item.width = Item.height = 36;
|
||||
Item.useTime = Item.useAnimation = 9;
|
||||
Item.noMelee = true;
|
||||
Item.knockBack = 1f;
|
||||
@@ -53,7 +82,27 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
Item.DamageType = DamageClass.Summon;
|
||||
Item.Calamity().CannotBeEnchanted = true;
|
||||
}
|
||||
|
||||
|
||||
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale)
|
||||
{
|
||||
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Summon/AresExoskeleton").Value;
|
||||
if (ArmExists(Main.LocalPlayer))
|
||||
{
|
||||
texture = ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Summon/AresExoskeletonRemote").Value;
|
||||
position.X += scale * 6f;
|
||||
}
|
||||
|
||||
spriteBatch.Draw(texture, position, new(0, 0, texture.Width, texture.Height), Color.White, 0f, origin, scale, 0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
|
||||
{
|
||||
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Summon/AresExoskeleton").Value;
|
||||
spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref Frame, ref FrameCounter, 1, 1), lightColor, 0f, Vector2.Zero, 1f, 0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
int panelID = ModContent.ProjectileType<ExoskeletonPanel>();
|
||||
@@ -77,6 +126,11 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
int panel = Projectile.NewProjectile(source, position, Vector2.Zero, panelID, damage, 0f, player.whoAmI);
|
||||
if (Main.projectile.IndexInRange(panel))
|
||||
Main.projectile[panel].originalDamage = Item.damage;
|
||||
|
||||
// Also throw a mechanical box cool particle out.
|
||||
Vector2 boxVelocity = -Vector2.UnitY.RotatedByRandom(0.7f) * 6f + Vector2.UnitX * player.direction * 4f;
|
||||
Particle box = new AresSummonCrateParticle(player, boxVelocity, BoxParticleLifetime);
|
||||
GeneralParticleHandler.SpawnParticle(box);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 596 B After Width: | Height: | Size: 507 B |
Binary file not shown.
|
After Width: | Height: | Size: 414 B |
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 912 B |
@@ -0,0 +1,52 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class AresSummonCrateParticle : Particle
|
||||
{
|
||||
public override bool SetLifetime => true;
|
||||
public override string Texture => "CalamityMod/Particles/AresSummonCrate";
|
||||
public override bool UseCustomDraw => true;
|
||||
|
||||
public AresSummonCrateParticle(Player owner, Vector2 velocity, int lifetime)
|
||||
{
|
||||
Position = owner.Center - Vector2.UnitY * 4f;
|
||||
Scale = 1f;
|
||||
Color = Color.White;
|
||||
Velocity = velocity;
|
||||
Rotation = 0f;
|
||||
Lifetime = lifetime;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
Rotation += Math.Sign(Velocity.X) * 0.05f;
|
||||
Velocity.X *= 0.95f;
|
||||
Velocity.Y += 0.24f;
|
||||
if (Collision.SolidCollision(Position - Vector2.One * Scale * 19f, (int)(Scale * 38f), (int)(Scale * 38f), true))
|
||||
{
|
||||
Velocity.X *= 0.8f;
|
||||
Rotation = 0f;
|
||||
Velocity.Y = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Texture2D texture = GeneralParticleHandler.GetTexture(Type);
|
||||
Color lightColor = Lighting.GetColor(Position.ToTileCoordinates());
|
||||
|
||||
int frameY = (int)Math.Round(MathHelper.Lerp(0f, 2f, (float)Math.Pow(LifetimeCompletion, 0.16f)));
|
||||
Rectangle frame = texture.Frame(1, 3, 0, frameY);
|
||||
float opacity = MathHelper.Clamp(1f - (float)Math.Pow(LifetimeCompletion, 7f), 0f, 1f);
|
||||
spriteBatch.Draw(texture, Position - Main.screenPosition, frame, lightColor * opacity, Rotation, frame.Size() * 0.5f, Scale, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
@@ -12,11 +11,11 @@ namespace CalamityMod.Particles
|
||||
public override string Texture => "CalamityMod/Particles/WulfrumHat";
|
||||
public override bool UseCustomDraw => true;
|
||||
|
||||
public int Direction ;
|
||||
public int Direction;
|
||||
|
||||
public WulfrumHatParticle(Player owner, Vector2 velocity, int lifetime)
|
||||
{
|
||||
Position = owner.Center - Vector2.UnitY * 20f;;
|
||||
Position = owner.Center - Vector2.UnitY * 20f;
|
||||
Direction = owner.direction;
|
||||
Scale = 1f;
|
||||
Color = Color.White;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
@@ -14,11 +15,9 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public int OwnerIndex
|
||||
{
|
||||
get => Projectile.GetByUUID(Projectile.owner, Projectile.ai[1]);
|
||||
set => Projectile.ai[1] = value;
|
||||
}
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
public Projectile OwnerProjectile => CalamityUtils.FindProjectileByIdentity((int)Projectile.ai[1], Projectile.owner);
|
||||
|
||||
public const int LifetimeConst = 75;
|
||||
public override float MaxScale => 0.5f + (float)Math.Cos(Main.GlobalTimeWrappedHourly * 10f) * 0.07f;
|
||||
@@ -47,6 +46,8 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
Projectile.localNPCHitCooldown = 14;
|
||||
Projectile.scale = 0.5f;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.hide = true;
|
||||
Projectile.Calamity().UpdatePriority = 1f;
|
||||
}
|
||||
|
||||
public override float DetermineLaserLength()
|
||||
@@ -58,7 +59,7 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
|
||||
public override void UpdateLaserMotion()
|
||||
{
|
||||
if (OwnerIndex == -1)
|
||||
if (OwnerProjectile is null)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
@@ -68,15 +69,16 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
|
||||
public override void AttachToSomething()
|
||||
{
|
||||
if (OwnerIndex == -1 || !Main.projectile[OwnerIndex].active)
|
||||
Projectile ownerProjectile = OwnerProjectile;
|
||||
if (ownerProjectile is null)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
float attachmentOffset = Main.projectile[OwnerIndex].width * Main.projectile[OwnerIndex].scale * 0.75f;
|
||||
Projectile.Center = Main.projectile[OwnerIndex].Center + Main.projectile[OwnerIndex].rotation.ToRotationVector2() * attachmentOffset;
|
||||
Projectile.rotation = Main.projectile[OwnerIndex].rotation;
|
||||
float attachmentOffset = ownerProjectile.width * ownerProjectile.scale * 0.75f;
|
||||
Projectile.Center = ownerProjectile.Center + ownerProjectile.rotation.ToRotationVector2() * attachmentOffset - Owner.velocity;
|
||||
Projectile.rotation = ownerProjectile.rotation;
|
||||
Projectile.velocity = Projectile.rotation.ToRotationVector2();
|
||||
|
||||
// Update frames.
|
||||
@@ -85,6 +87,11 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
|
||||
public override bool ShouldUpdatePosition() => false;
|
||||
|
||||
public override void DrawBehind(int index, List<int> behindNPCsAndTiles, List<int> behindNPCs, List<int> behindProjectiles, List<int> overPlayers, List<int> overWiresUI)
|
||||
{
|
||||
overPlayers.Add(index);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
// This should never happen, but just in case.
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
{
|
||||
Main.projectile[laser].originalDamage = Projectile.originalDamage;
|
||||
if (fireLaser)
|
||||
Main.projectile[laser].ai[1] = Projectile.whoAmI;
|
||||
Main.projectile[laser].ai[1] = Projectile.identity;
|
||||
}
|
||||
|
||||
// Increment the shoot counter. This decides if the cannon fires a simple laser or a beam.
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
if (MousePressFrameCountdown >= 1)
|
||||
frame = 2;
|
||||
if (PanelFlashTimer >= 1)
|
||||
frame = (int)Math.Round(MathHelper.Lerp(4f, 6f, PanelFlashTimer / 24f));
|
||||
frame = (int)Math.Round(MathHelper.Lerp(4f, 6f, PanelFlashTimer / 16f));
|
||||
|
||||
return IconTexture?.Frame(1, 7, 0, frame) ?? default;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
{
|
||||
if (PanelFlashTimer >= 1)
|
||||
PanelFlashTimer++;
|
||||
if (PanelFlashTimer >= 18)
|
||||
if (PanelFlashTimer >= 16)
|
||||
PanelFlashTimer = 0;
|
||||
|
||||
if (MousePressFrameCountdown > 0)
|
||||
@@ -116,7 +116,9 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
public bool FadeOut => Projectile.ai[0] == 1f;
|
||||
|
||||
public Vector2 PlayerOffset;
|
||||
|
||||
|
||||
public ref float Time => ref Projectile.ai[1];
|
||||
|
||||
public static Rectangle MouseRectangle => new((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 2, 2);
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
@@ -177,12 +179,14 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
|
||||
}
|
||||
|
||||
// Handle fade effects.
|
||||
Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity - FadeOut.ToDirectionInt() * 0.0225f, 0f, 1f);
|
||||
if (Time >= AresExoskeleton.BoxParticleLifetime)
|
||||
Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity - FadeOut.ToDirectionInt() * 0.0225f, 0f, 1f);
|
||||
if (FadeOut && Projectile.Opacity <= 0f)
|
||||
Projectile.Kill();
|
||||
|
||||
if (Main.player[Projectile.owner].dead || !Main.player[Projectile.owner].active)
|
||||
Projectile.Kill();
|
||||
Time++;
|
||||
|
||||
// Create and destroy arms as necessary.
|
||||
if (Main.myPlayer != Projectile.owner)
|
||||
|
||||
Reference in new issue
Block a user