This commit is contained in:
mountaindrew10 committed 2022-07-12 07:53:11 -05:00
commit 6dbbb8965a
232 files changed
+8050 -1014

No files matched your search

+24 -1
View File
@@ -18,6 +18,7 @@ using CalamityMod.Events;
using CalamityMod.FluidSimulation;
using CalamityMod.Items;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Accessories.Vanity;
using CalamityMod.Items.Armor;
using CalamityMod.Items.Armor.Bloodflare;
using CalamityMod.Items.Armor.Brimflame;
@@ -26,6 +27,7 @@ using CalamityMod.Items.Armor.GemTech;
using CalamityMod.Items.Armor.OmegaBlue;
using CalamityMod.Items.Armor.PlagueReaper;
using CalamityMod.Items.Armor.Silva;
using CalamityMod.Items.Armor.Wulfrum;
using CalamityMod.Items.Dyes;
using CalamityMod.Items.Mounts;
using CalamityMod.Items.Mounts.Minecarts;
@@ -2548,6 +2550,8 @@ namespace CalamityMod.CalPlayer
return new Item();
}
public override void ProcessTriggers(TriggersSet triggersSet)
{
if (CalamityKeybinds.NormalityRelocatorHotKey.JustPressed && normalityRelocator && Main.myPlayer == Player.whoAmI)
@@ -5849,10 +5853,17 @@ namespace CalamityMod.CalPlayer
// The amount of damage that will be dealt is yet to be determined.
//
//Todo - At some point it'd be nice to have a "TransformationPlayer" that has all the transformation sfx and visuals so their priorities can be more easily managed.
#region Custom Hurt Sounds
if (hurtSoundTimer == 0)
{
if ((profanedCrystal || profanedCrystalForce) && !profanedCrystalHide)
if (Player.GetModPlayer<RoverDrivePlayer>().ProtectionMatrixDurability > 0)
{
playSound = false;
SoundEngine.PlaySound(RoverDrive.ShieldHurtSound, Player.position);
hurtSoundTimer = 20;
}
else if ((profanedCrystal || profanedCrystalForce) && !profanedCrystalHide)
{
playSound = false;
SoundEngine.PlaySound(Providence.DeathSound, Player.position);
@@ -5876,6 +5887,18 @@ namespace CalamityMod.CalPlayer
SoundEngine.PlaySound(NPCs.Astral.Atlas.HurtSound, Player.position);
hurtSoundTimer = 10;
}
else if (Player.GetModPlayer<WulfrumTransformationPlayer>().transformationActive)
{
playSound = false;
SoundEngine.PlaySound(SoundID.NPCHit4, Player.position);
hurtSoundTimer = 10;
}
else if (Player.GetModPlayer<WulfrumArmorPlayer>().wulfrumSet && (Player.name.ToLower() == "wagstaff" || Player.name.ToLower() == "john wulfrum"))
{
playSound = false;
SoundEngine.PlaySound(SoundID.DSTMaleHurt, Player.position);
hurtSoundTimer = 10;
}
}
#endregion
+7
View File
@@ -11,6 +11,8 @@ using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Items.Armor.Wulfrum;
namespace CalamityMod.CalPlayer
{
@@ -37,6 +39,11 @@ namespace CalamityMod.CalPlayer
layer.Hide();
}
}
if (Player.HeldItem.ModItem is IHideFrontArm amputator && amputator.ShouldHideArm(Player))
{
PlayerDrawLayers.ArmOverItem.Hide();
}
}
public override void DrawEffects(PlayerDrawSet drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
+6
View File
@@ -58,6 +58,7 @@ using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence;
using CalamityMod.Items.Armor.Wulfrum;
namespace CalamityMod.CalPlayer
{
@@ -207,6 +208,11 @@ namespace CalamityMod.CalPlayer
// Apply stealth damage to rogue.
Player.GetDamage<RogueDamageClass>() += stealthDamage;
//Slow the player down after any other speed modifiers might have been applied.
//Todo - Move this back to the wulfrum set class whenever statmodifiers are implemented for stats other than damage
if (WulfrumHat.PowerModeEngaged(Player, out _))
Player.moveSpeed *= 0.8f;
}
#endregion
+10 -5
View File
@@ -15,14 +15,19 @@ namespace CalamityMod.CalPlayer.DrawLayers
protected override void Draw(ref PlayerDrawSet drawInfo)
{
//Todo : Make this work even for accessories by somehow checking for the players.head equipslot's item instead of the head item.
Player drawPlayer = drawInfo.drawPlayer;
int headItemType = drawPlayer.armor[0].type;
if (drawPlayer.armor[10].type > ItemID.None)
headItemType = drawPlayer.armor[10].type;
Item headItem = drawPlayer.armor[0];
if (ModContent.GetModItem(headItemType) is IExtendedHat extendedHatDrawer)
if (drawPlayer.armor[10].type > ItemID.None)
headItem = drawPlayer.armor[10];
if (ModContent.GetModItem(headItem.type) is IExtendedHat extendedHatDrawer)
{
if (extendedHatDrawer.PreDrawExtension(drawInfo) && !drawInfo.drawPlayer.dead)
string equipSlotName = extendedHatDrawer.EquipSlotName(drawPlayer) != "" ? extendedHatDrawer.EquipSlotName(drawPlayer) : headItem.Name;
int equipSlot = EquipLoader.GetEquipSlot(Mod, equipSlotName, EquipType.Head);
if (extendedHatDrawer.PreDrawExtension(drawInfo) && !drawInfo.drawPlayer.dead && equipSlot == drawPlayer.head)
{
int dyeShader = drawPlayer.dye?[0].dye ?? 0;
+7
View File
@@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
using Terraria;
public interface IExtendedHat
{
@@ -15,4 +16,10 @@ public interface IExtendedHat
///Return true to make the extension get drawn automatically from the texture and offsets provided. Return false if you want to draw it yourself
/// </summary>
bool PreDrawExtension(PlayerDrawSet drawInfo) => true;
/// <summary>
/// The name of the equip slot for the item. If left empty, the equip slot that is looked for will use the name of the item.
/// Useful if you have multiple head textures you need to extend.
/// </summary>
string EquipSlotName(Player drawPlayer) => "";
}
+15
View File
@@ -0,0 +1,15 @@
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
using Terraria;
/// <summary>
/// Interface that can be used by items that need to hide the players front arm when held.
/// Useful for prosthesis type items.
/// </summary>
public interface IHideFrontArm
{
/// <summary>
/// When should the arm be hidden. Defauls to always
/// </summary>
bool ShouldHideArm(Player player) => true;
}
+20 -10
View File
@@ -1,4 +1,10 @@
using CalamityMod.Balancing;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using CalamityMod.Balancing;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
@@ -55,12 +61,6 @@ using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent;
using Terraria.GameContent.Dyes;
@@ -75,6 +75,8 @@ namespace CalamityMod
{
public class CalamityMod : Mod
{
public const string CalamityWikiURL = "calamitymod.wiki.gg";
// TODO -- A huge amount of random floating variables exist here.
// These should all be moved to other files, whether that's CalamityLists or brand new ModSystems.
// It is best to have a ton of small ModSystems.
@@ -133,10 +135,11 @@ namespace CalamityMod
internal Mod overhaul = null;
internal Mod redemption = null;
internal Mod soa = null;
internal Mod subworldLibrary = null;
internal Mod summonersAssociation = null;
internal Mod thorium = null;
internal Mod varia = null;
internal Mod subworldLibrary = null;
internal Mod wikithis = null;
#region Load
public override void Load()
@@ -172,14 +175,16 @@ namespace CalamityMod
ModLoader.TryGetMod("Redemption", out redemption);
soa = null;
ModLoader.TryGetMod("SacredTools", out soa);
subworldLibrary = null;
ModLoader.TryGetMod("SubworldLibrary", out subworldLibrary);
summonersAssociation = null;
ModLoader.TryGetMod("SummonersAssociation", out summonersAssociation);
thorium = null;
ModLoader.TryGetMod("ThoriumMod", out thorium);
varia = null;
ModLoader.TryGetMod("Varia", out varia);
subworldLibrary = null;
ModLoader.TryGetMod("SubworldLibrary", out subworldLibrary);
wikithis = null;
ModLoader.TryGetMod("Wikithis", out wikithis);
// Initialize the EnemyStats struct as early as it is safe to do so
NPCStats.Load();
@@ -206,6 +211,8 @@ namespace CalamityMod
{
LoadClient();
GeneralParticleHandler.Load();
if (wikithis is not null)
wikithis.Call("AddModURL", this, CalamityWikiURL);
}
CooldownRegistry.Load();
@@ -331,6 +338,7 @@ namespace CalamityMod
public override void Unload()
{
musicMod = null;
ancientsAwakened = null;
bossChecklist = null;
census = null;
@@ -339,9 +347,11 @@ namespace CalamityMod
overhaul = null;
redemption = null;
soa = null;
subworldLibrary = null;
summonersAssociation = null;
thorium = null;
varia = null;
wikithis = null;
AstralSky = null;
+73
View File
@@ -0,0 +1,73 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.Graphics.Shaders;
using static Terraria.ModLoader.ModContent;
using CalamityMod.Items.Armor.Wulfrum;
namespace CalamityMod.Cooldowns
{
public class WulfrumBastion : CooldownHandler
{
public bool PowerActive => instance.timeLeft > WulfrumHat.BastionCooldown;
public float DurabilityPercent => (instance.timeLeft - WulfrumHat.BastionCooldown) / (float)WulfrumHat.BastionTime;
public static new string ID => "WulfrumBastion";
public override bool ShouldDisplay => true;
public override string DisplayName => PowerActive ? "Power Armor Durability" : "Wulfrum Bastion Cooldown";
public override string Texture => PowerActive ? "CalamityMod/Cooldowns/WulfrumBastionActive" : "CalamityMod/Cooldowns/WulfrumBastion";
public override string OutlineTexture => "CalamityMod/Cooldowns/WulfrumBastionOutline";
public override string OverlayTexture => "CalamityMod/Cooldowns/WulfrumBastionOverlay";
public override Color OutlineColor => PowerActive ? new Color(194, 255, 67) : new Color(206, 201, 170);
public override Color CooldownStartColor => PowerActive ? Color.Lerp(new Color(112, 244, 244), new Color(54, 177, 221), DurabilityPercent) : new Color(92, 187, 99);
public override Color CooldownEndColor => PowerActive ? Color.Lerp(new Color(112, 244, 244), new Color(54, 177, 221), DurabilityPercent) : new Color(160, 232, 77);
public override SoundStyle? EndSound => new("CalamityMod/Sounds/Custom/AbilitySounds/WulfrumBastionRecharge");
//public override bool SavedWithPlayer => false;
public override void OnCompleted()
{
for (int i = 0; i < 6; i++)
{
Vector2 dustDirection = Main.rand.NextVector2CircularEdge(1f, 1f);
Dust d = Dust.NewDustPerfect(instance.player.Center + dustDirection * Main.rand.NextFloat(0.4f, 10f), 226, dustDirection * Main.rand.NextFloat(1f, 4f), 100, Color.Transparent, Main.rand.NextFloat(0.8f, 1.2f));
d.noGravity = true;
d.noLight = true;
d.fadeIn = 1f;
}
}
//Charge down at first, and then charge back up
private float AdjustedCompletion => PowerActive ? (instance.timeLeft - WulfrumHat.BastionCooldown) / (float)WulfrumHat.BastionTime : 1 - (instance.timeLeft / (float)WulfrumHat.BastionCooldown);
public override void ApplyBarShaders(float opacity)
{
//Use the adjusted completion
GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity);
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion);
GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor);
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor);
GameShaders.Misc["CalamityMod:CircularBarShader"].Apply();
}
public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
{
Texture2D sprite = Request<Texture2D>(Texture).Value;
Texture2D outline = Request<Texture2D>(OutlineTexture).Value;
Texture2D overlay = Request<Texture2D>(OverlayTexture).Value;
//Draw the outline
spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f);
//Draw the icon
spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
//Draw the small overlay
int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion);
Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight);
spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

+93
View File
@@ -0,0 +1,93 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using static CalamityMod.CalamityUtils;
using static Terraria.ModLoader.ModContent;
using CalamityMod.Items.Accessories;
using Terraria.Audio;
using Terraria.Graphics.Shaders;
using System;
namespace CalamityMod.Cooldowns
{
public class WulfrumRoverDriveDurability : CooldownHandler
{
private static Color ringColorLerpStart = new Color(49, 220, 221);
private static Color ringColorLerpEnd = new Color(99, 226, 142);
private float AdjustedCompletion => (instance.timeLeft) / (float)RoverDrive.ProtectionMatrixDurabilityMax;
public static new string ID => "WulfrumRoverDriveDurability";
public override bool CanTickDown => !instance.player.GetModPlayer<RoverDrivePlayer>().RoverDriveOn || instance.timeLeft <= 0;
public override bool ShouldDisplay => instance.player.GetModPlayer<RoverDrivePlayer>().RoverDriveOn;
public override string DisplayName => "Protective Matrix Durability";
public override string Texture => "CalamityMod/Cooldowns/WulfrumRoverDriveActive";
public override string OutlineTexture => "CalamityMod/Cooldowns/WulfrumRoverDriveOutline";
public override string OverlayTexture => "CalamityMod/Cooldowns/WulfrumRoverDriveOverlay";
public override Color OutlineColor => new Color(112, 244, 244);
public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
public override bool SavedWithPlayer => false;
public override bool PersistsThroughDeath => false;
public override void ApplyBarShaders(float opacity)
{
//Use the adjusted completion
GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity);
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion);
GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor);
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor);
GameShaders.Misc["CalamityMod:CircularBarShader"].Apply();
}
public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
{
base.DrawExpanded(spriteBatch, position, opacity, scale);
float Xoffset = instance.timeLeft > 9 ? -10f : -5;
DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + new Vector2(Xoffset, 4) * scale, Color.Lerp(ringColorLerpStart, Color.OrangeRed, 1 - instance.Completion), Color.Black, scale);
}
public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
{
Texture2D sprite = Request<Texture2D>(Texture).Value;
Texture2D outline = Request<Texture2D>(OutlineTexture).Value;
Texture2D overlay = Request<Texture2D>(OverlayTexture).Value;
//Draw the outline
spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f);
//Draw the icon
spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
//Draw the small overlay
int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion);
Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight);
spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
float Xoffset = instance.timeLeft > 9 ? -10f : -5;
DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + new Vector2(Xoffset, 4) * scale, Color.Lerp(ringColorLerpStart, Color.OrangeRed, 1 - instance.Completion), Color.Black, scale);
}
}
public class WulfrumRoverDriveRecharge : CooldownHandler
{
private static Color ringColorLerpStart = new Color(194, 255, 57);
private static Color ringColorLerpEnd = new Color(92, 187, 99);
public static new string ID => "WulfrumRoverDriveRecharge";
public override bool ShouldDisplay => true;
public override string DisplayName => "Protective Matrix Recharge";
public override string Texture => "CalamityMod/Cooldowns/WulfrumRoverDrive";
public override bool SavedWithPlayer => false;
public override bool PersistsThroughDeath => false;
public override Color OutlineColor => new Color(194, 255, 67);
public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
public override void OnCompleted() => instance.player.GetModPlayer<RoverDrivePlayer>().ProtectionMatrixDurability = RoverDrive.ProtectionMatrixDurabilityMax;
public override SoundStyle? EndSound => null;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

+59
View File
@@ -0,0 +1,59 @@
using Microsoft.Xna.Framework;
using System.Collections.Generic;
namespace CalamityMod.DataStructures
{
public class VerletSimulatedSegment
{
public Vector2 position, oldPosition;
public bool locked;
public VerletSimulatedSegment(Vector2 _position, bool _locked = false)
{
position = _position;
oldPosition = _position;
locked = _locked;
}
public static List<VerletSimulatedSegment> SimpleSimulation(List<VerletSimulatedSegment> segments, float segmentDistance, int loops = 10, float gravity = 0.3f)
{
//https://youtu.be/PGk0rnyTa1U?t=400 verlet integration chains reference here
foreach (VerletSimulatedSegment segment in segments)
{
if (!segment.locked)
{
Vector2 positionBeforeUpdate = segment.position;
segment.position += (segment.position - segment.oldPosition); // This adds conservation of energy to the segments. This makes it super bouncy and shouldnt be used but it's really funny
segment.position += Vector2.UnitY * gravity; //=> This adds gravity to the segments.
segment.oldPosition = positionBeforeUpdate;
}
}
int segmentCount = segments.Count;
for (int k = 0; k < loops; k++)
{
for (int j = 0; j < segmentCount - 1; j++)
{
VerletSimulatedSegment pointA = segments[j];
VerletSimulatedSegment pointB = segments[j + 1];
Vector2 segmentCenter = (pointA.position + pointB.position) / 2f;
Vector2 segmentDirection = Terraria.Utils.SafeNormalize(pointA.position - pointB.position, Vector2.UnitY);
if (!pointA.locked)
pointA.position = segmentCenter + segmentDirection * segmentDistance / 2f;
if (!pointB.locked)
pointB.position = segmentCenter - segmentDirection * segmentDistance / 2f;
segments[j] = pointA;
segments[j + 1] = pointB;
}
}
return segments;
}
}
}
+12
View File
@@ -125,6 +125,18 @@ namespace CalamityMod.Effects
screenRef = new Ref<Effect>(CalamityMod.Instance.Assets.Request<Effect>("Effects/PixelatedSightLine", AssetRequestMode.ImmediateLoad).Value);
Filters.Scene["PixelatedSightLine"] = new Filter(new ScreenShaderData(screenRef, "SightLinePass"), EffectPriority.High);
Filters.Scene["PixelatedSightLine"].Load();
screenRef = new Ref<Effect>(CalamityMod.Instance.Assets.Request<Effect>("Effects/WulfrumTilePing", AssetRequestMode.ImmediateLoad).Value);
Filters.Scene["WulfrumTilePing"] = new Filter(new ScreenShaderData(screenRef, "TilePingPass"), EffectPriority.High);
Filters.Scene["WulfrumTilePing"].Load();
screenRef = new Ref<Effect>(CalamityMod.Instance.Assets.Request<Effect>("Effects/WulfrumScaffoldSelection", AssetRequestMode.ImmediateLoad).Value);
Filters.Scene["WulfrumScaffoldSelection"] = new Filter(new ScreenShaderData(screenRef, "TilePingPass"), EffectPriority.High);
Filters.Scene["WulfrumScaffoldSelection"].Load();
screenRef = new Ref<Effect>(CalamityMod.Instance.Assets.Request<Effect>("Effects/RoverDriveShield", AssetRequestMode.ImmediateLoad).Value);
Filters.Scene["RoverDriveShield"] = new Filter(new ScreenShaderData(screenRef, "ShieldPass"), EffectPriority.High);
Filters.Scene["RoverDriveShield"].Load();
}
}
}
+53
View File
@@ -0,0 +1,53 @@
float time;
float blowUpPower; //The power the blow up effect is set as. Ideally betwen 0 and 1
float blowUpSize; //The strenght of the expansion caused by the blow up effect
float3 shieldColor;
float shieldOpacity;
float3 shieldEdgeColor;
float shieldEdgeBlendStrenght;
float noiseScale;
float resolution;
texture sampleTexture;
sampler2D Texture1Sampler = sampler_state { texture = <sampleTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; };
float4 main(float2 uv : TEXCOORD) : COLOR
{
//Pixelate?
//uv.x -= uv.x % (1 / resolution);
//uv.y -= uv.y % (1 / resolution);
//Crop in a circle
float distanceFromCenter = length(uv - float2(0.5, 0.5)) * 2;
if (distanceFromCenter > 1)
return float4(0, 0, 0, 0);
//"Blow up" the noise map so it looks circular.
float blownUpUVX = pow((abs(uv.x - 0.5)) * 2, blowUpPower);
float blownUpUVY = pow((abs(uv.y - 0.5)) * 2, blowUpPower);
float2 blownUpUV = float2(-blownUpUVY * blowUpSize * 0.5 + uv.x * (1 + blownUpUVY * blowUpSize), -blownUpUVX * blowUpSize * 0.5 + uv.y * (1 + blownUpUVX * blowUpSize));
//Rescale
blownUpUV *= noiseScale;
//Scroll effect
blownUpUV.x = (blownUpUV.x + time) % 1;
//Get the noise color
float4 noiseColor = tex2D(Texture1Sampler, blownUpUV);
//Apply a layers of fake fresnel
noiseColor += pow(distanceFromCenter, 6); // + pow(distanceFromCenter, 3) * 0.6; <- Brings us over into ps 3.0 territory if we have pixelation on.
//Fade the edges
if (distanceFromCenter > 0.95)
noiseColor *= (1 - ((distanceFromCenter - 0.95) / 0.05));
return noiseColor * float4(lerp(shieldColor, shieldEdgeColor, pow(distanceFromCenter, shieldEdgeBlendStrenght)), shieldOpacity);
}
technique Technique1
{
pass ShieldPass
{
PixelShader = compile ps_2_0 main();
}
}
Binary file not shown.
+189
View File
@@ -0,0 +1,189 @@
float Resolution; //Pixel resolution
float time;
float tileEdgeBlendStrenght; //How hard the border of a tile should get blended away.
float mainOpacity;
float blinkTime;
float4 baseTintColor; //Color of the tile's overlay
float3 tileEdgeColor; //Color of the tile's edge effects
float4 scanlineColor; //Color of the scanline effects
float4 placementGlowColor; //Color of the tile when first placed
float4 ScanLines[10];
int ScanLinesCount;
int verticalScanLinesIndex;
//Per tile stuff
float2 tilePosition; //The position of the top left of the tile
bool4 cardinalConnections; //Up, Left, Right, Down connections.
texture sampleTexture;
sampler2D Texture1Sampler = sampler_state { texture = <sampleTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; };
bool AND(bool4 value)
{
return value.x && value.y && value.z && value.w;
}
int COUNT(bool4 value)
{
int count = 0;
if (value.x)
count++;
if (value.y)
count++;
if (value.z)
count++;
if (value.w)
count++;
return count;
}
float MOD(float a, float n)
{
return a - floor(a / n) * n;
}
float inverselerp(float x, float start, float end)
{
return clamp((x - start) / (end - start), 0, 1);
}
//Checks if a corner should be drawn or excluded, based on how many edges the pixel is near to.
bool cornerDrawCheck(float2 position)
{
float oneEight = 1 / Resolution;
float sevenEights = 7 / Resolution;
bool4 edgeChecks = bool4(false, false, false, false);
//top
if (position.y < oneEight && !cardinalConnections.x)
edgeChecks.x = true;
//bottom
if (position.y >= sevenEights && !cardinalConnections.w)
edgeChecks.w = true;
//left
if (position.x < oneEight && !cardinalConnections.y)
edgeChecks.y = true;
//right
if (position.x >= sevenEights && !cardinalConnections.z)
edgeChecks.z = true;
//if on 2 edges at once, youre on a corner
return COUNT(edgeChecks) < 2;
}
//Gets the gradient from the tile outline effects
float getOpacityFromEdge(float2 position)
{
//If fully surrounded, don't draw anything
if (AND(cardinalConnections))
return 0;
float oneFourth = 1 / Resolution;
float twoFourths = 3 / Resolution;
float threeFourths = 4 / Resolution;
float one = 7 / Resolution;
float baseOpacity = 0;
//up
if (!cardinalConnections.x)
baseOpacity += pow(inverselerp(position.y, twoFourths, 0), tileEdgeBlendStrenght);
//down
if (!cardinalConnections.w)
baseOpacity += pow(inverselerp(position.y, threeFourths, one), tileEdgeBlendStrenght);
//left
if (!cardinalConnections.y)
baseOpacity += pow(inverselerp(position.x, twoFourths, 0), tileEdgeBlendStrenght);
//right
if (!cardinalConnections.z)
baseOpacity += pow(inverselerp(position.x, threeFourths, one), tileEdgeBlendStrenght);
return baseOpacity;
}
//Gets the opacity of the scanline on the specific pixel
float getOpacityFromScanLine(float2 position)
{
float opacity = 0;
float4 scanline;
//x = offset from origin, y = period, z = speed, w = opacity.
for (int i = 0; i < ScanLinesCount; i++)
{
scanline = ScanLines[i];
float pixelPos;
if (i >= verticalScanLinesIndex)
pixelPos = (position.x + tilePosition.x / 16) % scanline.y;
else
pixelPos = (position.y + tilePosition.y / 16) % scanline.y;
//Custom mod in case scanline.z is negative, aka the scanline moves in the opposite direction.
float scanlinePos = MOD((scanline.x + time * scanline.z), scanline.y);
scanlinePos -= scanlinePos % (1 / Resolution);
pixelPos -= pixelPos % (1 / Resolution);
if (pixelPos == scanlinePos)
opacity += scanline.w;
}
return opacity * (scanlineColor.a - baseTintColor.a);
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
//Pixelate
uv.x -= uv.x % (1 / Resolution);
uv.y -= uv.y % (1 / Resolution);
//Don't draw the corner the case of a missing corner.
if (!cornerDrawCheck(uv))
return float4(0, 0, 0, 0);
float3 ColorTotal = lerp(baseTintColor.rgb, placementGlowColor.rgb, blinkTime);
float OpacityTotal = lerp(baseTintColor.a, placementGlowColor.a, blinkTime);
//Do the outlines
float tileEdgeBlend = getOpacityFromEdge(uv);
OpacityTotal = lerp(OpacityTotal, 1, tileEdgeBlend);
ColorTotal = lerp(ColorTotal, tileEdgeColor, tileEdgeBlend);
float scanlineOpacity = getOpacityFromScanLine(uv);
if (scanlineOpacity > 0)
{
OpacityTotal += scanlineOpacity;
ColorTotal = lerp(ColorTotal, scanlineColor.rgb, scanlineOpacity);
}
//General fade out
OpacityTotal *= mainOpacity;
ColorTotal = ColorTotal * OpacityTotal;
return float4(ColorTotal, OpacityTotal);
}
technique Technique1
{
pass TileSelectPass
{
PixelShader = compile ps_3_0 main();
}
}
Binary file not shown.
+212
View File
@@ -0,0 +1,212 @@
float Resolution; //Pixel resolution
float time;
float2 pingCenter; //The origin of the ping wave.
float pingRadius; //The max radius of the ping.
float pingWaveThickness; //The thickness of the wave before it entirely fades out.
float pingProgress; //How far along the ping progressed
float pingTravelTime; //Percent of the ping's duration during which the ping expands to reach its full radius.
float pingFadePoint; //Percent of the ping's duration at which to start fading away.
float edgeBlendStrength; //How starkly should the ping's edge fade off.
float edgeBlendOutLenght; //Small lenght at the edge of the wave to blend away smoothly.
float tileEdgeBlendStrenght; //How hard the border of a tile should get blended away.
float4 baseTintColor; //Color of the tile's overlay
float3 tileEdgeColor; //Color of the tile's edge effects
float4 scanlineColor; //Color of the scanline effects
float4 waveColor; //Color of the ping wave
float4 ScanLines[10];
int ScanLinesCount;
int verticalScanLinesIndex;
//Per tile stuff
float2 tilePosition; //The position of the top left of the tile
bool4 cardinalConnections; //Up, Left, Right, Down connections.
texture sampleTexture;
sampler2D Texture1Sampler = sampler_state { texture = <sampleTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; };
bool AND(bool4 value)
{
return value.x && value.y && value.z && value.w;
}
int COUNT(bool4 value)
{
int count = 0;
if (value.x)
count++;
if (value.y)
count++;
if (value.z)
count++;
if (value.w)
count++;
return count;
}
float MOD(float a, float n)
{
return a - floor(a / n) * n;
}
float inverselerp(float x, float start, float end)
{
return clamp((x - start) / (end - start), 0, 1);
}
//Checks if a corner should be drawn or excluded, based on how many edges the pixel is near to.
bool cornerDrawCheck(float2 position)
{
float oneEight = 1 / Resolution;
float sevenEights = 7 / Resolution;
bool4 edgeChecks = bool4(false, false, false, false);
//top
if (position.y < oneEight && !cardinalConnections.x)
edgeChecks.x = true;
//bottom
if (position.y >= sevenEights && !cardinalConnections.w)
edgeChecks.w = true;
//left
if (position.x < oneEight && !cardinalConnections.y)
edgeChecks.y = true;
//right
if (position.x >= sevenEights && !cardinalConnections.z)
edgeChecks.z = true;
//if on 2 edges at once, youre on a corner
return COUNT(edgeChecks) < 2;
}
//Gets the gradient from the tile outline effects
float getOpacityFromEdge(float2 position)
{
//If fully surrounded, don't draw anything
if (AND(cardinalConnections))
return 0;
float oneFourth = 1 / Resolution;
float twoFourths = 3 / Resolution;
float threeFourths = 4 / Resolution;
float one = 7 / Resolution;
float baseOpacity = 0;
//up
if (!cardinalConnections.x)
baseOpacity += pow(inverselerp(position.y, twoFourths, 0), tileEdgeBlendStrenght);
//down
if (!cardinalConnections.w)
baseOpacity += pow(inverselerp(position.y, threeFourths, one), tileEdgeBlendStrenght);
//left
if (!cardinalConnections.y)
baseOpacity += pow(inverselerp(position.x, twoFourths, 0), tileEdgeBlendStrenght);
//right
if (!cardinalConnections.z)
baseOpacity += pow(inverselerp(position.x, threeFourths, one), tileEdgeBlendStrenght);
return baseOpacity;
}
//Gets the opacity of the scanline on the specific pixel
float getOpacityFromScanLine(float2 position)
{
float opacity = 0;
float4 scanline;
//x = offset from origin, y = period, z = speed, w = opacity.
for (int i = 0; i < ScanLinesCount; i++)
{
scanline = ScanLines[i];
float pixelPos;
if (i >= verticalScanLinesIndex)
pixelPos = (position.x + tilePosition.x / 16) % scanline.y;
else
pixelPos = (position.y + tilePosition.y / 16) % scanline.y;
//Custom mod in case scanline.z is negative, aka the scanline moves in the opposite direction.
float scanlinePos = MOD((scanline.x + time * scanline.z), scanline.y);
scanlinePos -= scanlinePos % (1 / Resolution);
pixelPos -= pixelPos % (1 / Resolution);
if (pixelPos == scanlinePos)
opacity += scanline.w;
}
return opacity * (scanlineColor.a - baseTintColor.a);
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
//Pixelate
uv.x -= uv.x % (1 / Resolution);
uv.y -= uv.y % (1 / Resolution);
//Don't draw the corner the case of a missing corner.
if (!cornerDrawCheck(uv))
return float4(0, 0, 0, 0);
float distanceFromPingOrigin = length(pingCenter - (tilePosition + uv * 16));
float waveExpansionPercent = pingProgress / pingTravelTime;
float currentPingRadius = pingRadius * waveExpansionPercent;
float realWaveExpansionPercent = min(waveExpansionPercent, 1);
float realPingRadius = pingRadius * realWaveExpansionPercent;
//Crop the ping wave into a circle
if (distanceFromPingOrigin > realPingRadius)
return float4(0, 0, 0, 0);
float waveEdgeDistanceFromCenter = max(currentPingRadius - pingWaveThickness, 0);
float edgeBlendFactor = pow(min(max((distanceFromPingOrigin - (waveEdgeDistanceFromCenter)), 0) / (pingWaveThickness - edgeBlendOutLenght), 1), edgeBlendStrength);
float3 ColorTotal = lerp(baseTintColor.rgb, waveColor.rgb, edgeBlendFactor);
float OpacityTotal = lerp(baseTintColor.a, waveColor.a, edgeBlendFactor);
//Do the outlines
float tileEdgeBlend = getOpacityFromEdge(uv);
OpacityTotal = lerp(OpacityTotal, 1, tileEdgeBlend);
ColorTotal = lerp(ColorTotal, tileEdgeColor, tileEdgeBlend);
float scanlineOpacity = getOpacityFromScanLine(uv);
if (scanlineOpacity > 0)
{
OpacityTotal += scanlineOpacity;
ColorTotal = lerp(ColorTotal, scanlineColor.rgb, scanlineOpacity);
}
//Fade away the border
if (realPingRadius - distanceFromPingOrigin < edgeBlendOutLenght)
OpacityTotal *= (realPingRadius - distanceFromPingOrigin) / edgeBlendOutLenght;
//General fade out at the end.
OpacityTotal *= 1 - max(pingProgress - pingFadePoint, 0) / (1 - pingFadePoint);
ColorTotal = ColorTotal * OpacityTotal;
return float4(ColorTotal, OpacityTotal);
}
technique Technique1
{
pass TilePingPass
{
PixelShader = compile ps_3_0 main();
}
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

+22
View File
@@ -51,10 +51,17 @@ namespace CalamityMod.ILEditing
IL.Terraria.Player.QuickMana += ConditionallyReplaceManaSickness;
IL.Terraria.Player.ItemCheck_Inner += ConditionallyReplaceManaSickness;
On.Terraria.Main.SortDrawCacheWorms += DrawFusableParticles;
On.Terraria.Main.DrawInfernoRings += DrawForegroundParticles;
On.Terraria.Main.SetDisplayMode += ResetRenderTargetSizes;
IL.Terraria.GameContent.Drawing.TileDrawing.DrawPartialLiquid += DrawCustomLava;
IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw += DrawCustomLava2;
IL.Terraria.Main.oldDrawWater += DrawCustomLava3;
On.Terraria.GameContent.Drawing.TileDrawing.Draw += ClearTilePings;
On.Terraria.Player.GrappleMovement += CustomGrappleMovementCheck;
On.Terraria.Player.UpdatePettingAnimal += CustomGrapplePreDefaultMovement;
On.Terraria.Player.PlayerFrame += CustomGrapplePostFrame;
On.Terraria.Player.SlopeDownMovement += CustomGrapplePreStepUp;
// TODO -- Revisit this. It's not an extremely important thing, but it'd be ideal to not just abandon it.
// IL.Terraria.WaterfallManager.DrawWaterfall += DrawCustomLavafalls;
@@ -96,6 +103,7 @@ namespace CalamityMod.ILEditing
IL.Terraria.WorldGen.Chlorophyte += AdjustChlorophyteSpawnLimits;
IL.Terraria.GameContent.UI.States.UIWorldCreation.SetDefaultOptions += ChangeDefaultWorldSize;
IL.Terraria.GameContent.UI.States.UIWorldCreation.AddWorldSizeOptions += SwapSmallDescriptionKey;
On.Terraria.IO.WorldFile.ClearTempTiles += ClearModdedTempTiles;
// Removal of vanilla stupidity
IL.Terraria.GameContent.Events.Sandstorm.HasSufficientWind += DecreaseSandstormWindSpeedRequirement;
@@ -117,6 +125,13 @@ namespace CalamityMod.ILEditing
IL.Terraria.NPC.NPCLoot += FixSplittingWormBannerDrops;
On.Terraria.Item.Prefix += LetRogueItemsBeReforgeable;
// IL.Terraria.Main.DoUpdate += FixProjectileUpdatePriorityProblems;
//Additional detours that are in their own item files given they are only relevant to these specific items:
//Rover drive detours on Player.DrawInfernoRings to draw its shield
//Wulfrum armor hooks on Player.KeyDoubleTap and DrawPendingMouseText to activate its set bonus and spoof the mouse text to display the stats of the activated weapon if shift is held
//HeldOnlyItem detours Player.dropItemCheck, ItemSlot.Draw (Sb, itemarray, int, int, vector2, color) and ItemSlot.LeftClick_ItemArray to make its stuff work
}
/// <summary>
@@ -147,6 +162,7 @@ namespace CalamityMod.ILEditing
IL.Terraria.Player.QuickMana -= ConditionallyReplaceManaSickness;
IL.Terraria.Player.ItemCheck_Inner -= ConditionallyReplaceManaSickness;
On.Terraria.Main.SortDrawCacheWorms -= DrawFusableParticles;
On.Terraria.Main.DrawInfernoRings -= DrawForegroundParticles;
On.Terraria.Main.SetDisplayMode -= ResetRenderTargetSizes;
IL.Terraria.GameContent.Drawing.TileDrawing.DrawPartialLiquid -= DrawCustomLava;
IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw -= DrawCustomLava2;
@@ -154,6 +170,11 @@ namespace CalamityMod.ILEditing
IL.Terraria.WaterfallManager.DrawWaterfall -= DrawCustomLavafalls;
On.Terraria.NPC.Collision_DecideFallThroughPlatforms -= EnableCalamityBossPlatformCollision;
IL.Terraria.Wiring.HitWireSingle -= AddTwinklersToStatue;
On.Terraria.GameContent.Drawing.TileDrawing.Draw -= ClearTilePings;
On.Terraria.Player.GrappleMovement -= CustomGrappleMovementCheck;
On.Terraria.Player.UpdatePettingAnimal -= CustomGrapplePreDefaultMovement;
On.Terraria.Player.PlayerFrame -= CustomGrapplePostFrame;
On.Terraria.Player.SlopeDownMovement -= CustomGrapplePreStepUp;
// Damage and health balance
IL.Terraria.Main.DamageVar -= AdjustDamageVariance;
@@ -189,6 +210,7 @@ namespace CalamityMod.ILEditing
IL.Terraria.WorldGen.Chlorophyte -= AdjustChlorophyteSpawnLimits;
IL.Terraria.GameContent.UI.States.UIWorldCreation.SetDefaultOptions -= ChangeDefaultWorldSize;
IL.Terraria.GameContent.UI.States.UIWorldCreation.AddWorldSizeOptions -= SwapSmallDescriptionKey;
On.Terraria.IO.WorldFile.ClearTempTiles -= ClearModdedTempTiles;
// Removal of vanilla stupidity
IL.Terraria.GameContent.Events.Sandstorm.HasSufficientWind -= DecreaseSandstormWindSpeedRequirement;
+109 -4
View File
@@ -14,6 +14,8 @@ using CalamityMod.Projectiles;
using CalamityMod.Systems;
using CalamityMod.Waters;
using CalamityMod.World;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.Items.Accessories;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Mono.Cecil.Cil;
@@ -33,6 +35,7 @@ using Terraria.ID;
using Terraria.ModLoader;
using Terraria.UI.Gamepad;
using Terraria.Utilities;
using Terraria.Graphics.Light;
namespace CalamityMod.ILEditing
{
@@ -236,7 +239,7 @@ namespace CalamityMod.ILEditing
{
if (Main.dayTime || BossRushEvent.BossRushActive)
return true;
return orig();
}
#endregion Allow Empress to Enrage in Boss Rush
@@ -644,7 +647,7 @@ namespace CalamityMod.ILEditing
#region General Particle Rendering
private static void DrawFusableParticles(On.Terraria.Main.orig_SortDrawCacheWorms orig, Main self)
{
GeneralParticleHandler.DrawAllParticles(Main.spriteBatch);
DeathAshParticle.DrawAll();
FusableParticleManager.RenderAllFusableParticles();
@@ -654,6 +657,11 @@ namespace CalamityMod.ILEditing
orig(self);
}
private static void DrawForegroundParticles(On.Terraria.Main.orig_DrawInfernoRings orig, Main self)
{
GeneralParticleHandler.DrawAllParticles(Main.spriteBatch);
orig(self);
}
#endregion General Particle Rendering
#region Custom Lava Visuals
@@ -903,8 +911,8 @@ namespace CalamityMod.ILEditing
c.EmitDelegate<Func<short[], short[]>>(arr =>
{
// resize the array and add our custom firefly
Array.Resize(ref arr, arr.Length+1);
arr[arr.Length-1] = (short)ModContent.NPCType<Twinkler>();
Array.Resize(ref arr, arr.Length + 1);
arr[arr.Length - 1] = (short)ModContent.NPCType<Twinkler>();
return arr;
});
@@ -916,5 +924,102 @@ namespace CalamityMod.ILEditing
throw new Exception("Hook location not found, switch(*) { case 54: ...");
}
#endregion Statue Additions
#region Tile ping overlay
private static void ClearTilePings(On.Terraria.GameContent.Drawing.TileDrawing.orig_Draw orig, Terraria.GameContent.Drawing.TileDrawing self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets, int waterStyleOverride)
{
//Retro & Trippy light modes are fine. Just reset the cache before every time stuff gets drawn.
if (Lighting.UpdateEveryFrame)
{
//But only if its not on the non solid layer, assumedly because it draws first or something
if (!solidLayer)
TilePingerSystem.ClearTiles();
}
else
{
//For the white color mode, we also can simply clear all the cache at once, but this time its only on the solid layers. Don't ask me why i don't know it just works
if (Lighting.Mode == LightMode.White)
{
if (solidLayer)
TilePingerSystem.ClearTiles();
}
//In color mode, the tiles get cleared alternating between solid and non solid tiles
else
TilePingerSystem.ClearTiles(solidLayer);
}
orig(self, solidLayer, forRenderTargets, intoRenderTargets, waterStyleOverride);
}
#endregion
#region Custom Grappling hooks
/// <summary>
/// Determines if the custom grapple movement should take place or not. Useful for hooks that only do movement tricks in some cases
/// </summary>
private static void CustomGrappleMovementCheck(On.Terraria.Player.orig_GrappleMovement orig, Player self)
{
WulfrumPackPlayer mp = self.GetModPlayer<WulfrumPackPlayer>();
if (mp.GrappleMovementDisabled)
return;
orig(self);
}
/// <summary>
/// This is called right before the game decides wether or not to update the players velocity based on "real" physics (aka not tongued or hooked or with a pulley)
/// </summary>
private static void CustomGrapplePreDefaultMovement(On.Terraria.Player.orig_UpdatePettingAnimal orig, Player self)
{
orig(self);
WulfrumPackPlayer mp = self.GetModPlayer<WulfrumPackPlayer>();
mp.hookCache = -1;
//if tongued, dnc.
if (self.tongued)
return;
//Cache the player's grapple and remove it temporarily (Gets re added in the modplayer's PostUpdateRunSpeeds)
if (self.grappling[0] >= 0 && mp.GrappleMovementDisabled && Main.projectile[self.grappling[0]].type == ModContent.ProjectileType<WulfrumHook>())
{
mp.hookCache = self.grappling[0];
self.grappling[0] = -1;
}
}
/// <summary>
/// Used before the player steps up a half tile. If we don't do that, players that are grappled but don't use hook movement won't be able to go over tiles.
/// The hook cache is reset in PreUpdateMovement
/// </summary>
private static void CustomGrapplePreStepUp(On.Terraria.Player.orig_SlopeDownMovement orig, Player self)
{
orig(self);
WulfrumPackPlayer mp = self.GetModPlayer<WulfrumPackPlayer>();
if (self.grappling[0] >= 0 && mp.GrappleMovementDisabled && Main.projectile[self.grappling[0]].type == ModContent.ProjectileType<WulfrumHook>())
{
mp.hookCache = self.grappling[0];
self.grappling[0] = -1;
}
}
/// <summary>
/// This is done to put the hook if it was cacehd during the frame instruction.
/// </summary>
private static void CustomGrapplePostFrame(On.Terraria.Player.orig_PlayerFrame orig, Player self)
{
orig(self);
WulfrumPackPlayer mp = self.GetModPlayer<WulfrumPackPlayer>();
if (mp.hookCache > -1)
self.grappling[0] = mp.hookCache;
mp.hookCache = -1;
}
#endregion
}
}
+18
View File
@@ -7,6 +7,8 @@ using Terraria;
using Terraria.GameContent.UI.States;
using Terraria.ID;
using Terraria.WorldBuilding;
using CalamityMod.Systems;
using System.Linq;
namespace CalamityMod.ILEditing
{
@@ -206,5 +208,21 @@ namespace CalamityMod.ILEditing
c.Emit(OpCodes.Ldstr, "Mods.CalamityMod.UI.SmallWorldWarning");
}
#endregion
#region Clear temporary modded tiles
private static void ClearModdedTempTiles(On.Terraria.IO.WorldFile.orig_ClearTempTiles orig)
{
orig();
for (int i = 0; i < Main.maxTilesX; i++)
{
for (int j = 0; j < Main.maxTilesY; j++)
{
if (TempTilesManagerSystem.TemporaryTileIDs.Contains(Main.tile[i, j].TileType))
WorldGen.KillTile(i, j);
}
}
}
#endregion
}
}
+222 -5
View File
@@ -2,18 +2,117 @@
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using CalamityMod.Cooldowns;
using CalamityMod.Items.Materials;
using Terraria.Audio;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.Graphics.Shaders;
using Terraria.Graphics.Effects;
using System;
using CalamityMod.Particles;
using ReLogic.Content;
namespace CalamityMod.Items.Accessories
{
public class RoverDrive : ModItem
{
public static readonly SoundStyle ShieldHurtSound = new("CalamityMod/Sounds/Custom/RoverDriveHit") { PitchVariance = 0.6f, Volume = 0.6f, MaxInstances = 0 };
public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/RoverDriveActivate") { Volume = 0.85f };
public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/Custom/RoverDriveBreak") { Volume = 0.75f };
public static int ProtectionMatrixDurabilityMax = 50;
public static int ProtectionMatrixRechargeTime = 60 * 10;
public static int ProtectionMatrixDefenseBoost = 10;
public static Asset<Texture2D> NoiseTex;
public override void Load()
{
On.Terraria.Main.DrawInfernoRings += DrawRoverDriveShields;
}
public override void Unload()
{
On.Terraria.Main.DrawInfernoRings -= DrawRoverDriveShields;
}
private void DrawRoverDriveShields(On.Terraria.Main.orig_DrawInfernoRings orig, Main self)
{
bool playerFound = false;
for (int i = 0; i < 255; i++)
{
if (!Main.player[i].active || Main.player[i].outOfRange || Main.player[i].dead)
continue;
if (Main.player[i].GetModPlayer<RoverDrivePlayer>().ProtectionMatrixDurability <= 0)
continue;
float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f));
if (playerFound == false)
{
float noiseScale = MathHelper.Lerp(0.4f, 0.8f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f);
Effect shieldEffect = Filters.Scene["RoverDriveShield"].GetShader().Shader;
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.24f);
shieldEffect.Parameters["blowUpPower"].SetValue(2.5f);
shieldEffect.Parameters["blowUpSize"].SetValue(0.5f);
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
//shieldEffect.Parameters["resolution"].SetValue(resolution);
float baseShieldOpacity = 0.9f + 0.1f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f);
shieldEffect.Parameters["shieldOpacity"].SetValue(baseShieldOpacity * (0.5f + 0.5f * (float)Math.Pow(Main.LocalPlayer.GetModPlayer<RoverDrivePlayer>().ProtectionMatrixDurability / (float)ProtectionMatrixDurabilityMax, 0.5f)));
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
Color blueTint = new Color(51, 102, 255);
Color cyanTint = new Color(71, 202, 255);
Color wulfGreen = new Color(194, 255, 67) * 0.8f;
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, blueTint, cyanTint, wulfGreen);
shieldEffect.Parameters["shieldColor"].SetValue(blueTint.ToVector3());
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shieldEffect, Main.GameViewMatrix.TransformationMatrix);
}
playerFound = true;
Player myPlayer = Main.player[i];
if (NoiseTex == null)
NoiseTex = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/TechyNoise");
Texture2D tex = NoiseTex.Value;
Vector2 pos = myPlayer.MountedCenter + myPlayer.gfxOffY * Vector2.UnitY - Main.screenPosition;
Main.spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
}
if (playerFound)
{
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform);
}
orig(self);
}
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Rover Drive");
Tooltip.SetDefault("Activates a protective shield that grants 15 defense for 10 seconds\n" +
//Actually 10.1 seconds at full power with a dissipation across 0.1666 seconds but whatever
"The shield then dissipates and recharges for 20 seconds before being reactivated");
Tooltip.SetDefault($"Activates a protective matrix that can absorb {ProtectionMatrixDurabilityMax} damage and grants {ProtectionMatrixDefenseBoost} defense\n" +
$"However, the systems are fickle and the shield will need {ProtectionMatrixRechargeTime / 60} seconds to charge up fully\n" +
"Getting hit during the shield recharge period will reset it back to zero\n" +
"Can also be scrapped at an extractinator");
ItemID.Sets.ExtractinatorMode[Item.type] = Item.type;
}
public override void SetDefaults()
@@ -23,12 +122,130 @@ namespace CalamityMod.Items.Accessories
Item.value = CalamityGlobalItem.Rarity1BuyPrice;
Item.rare = ItemRarityID.Blue;
Item.accessory = true;
//Needed for extractination
Item.useStyle = ItemUseStyleID.HiddenAnimation;
Item.useAnimation = 10;
Item.useTime = 2;
Item.consumable = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
CalamityPlayer modPlayer = player.Calamity();
modPlayer.roverDrive = true;
RoverDrivePlayer modPlayer = player.GetModPlayer<RoverDrivePlayer>();
//modPlayer.roverDrive = true;
modPlayer.RoverDriveOn = true;
if (modPlayer.ProtectionMatrixDurability > 0)
player.statDefense += ProtectionMatrixDefenseBoost;
}
//Scrappable for 3-6 wulfrum scrap or a 20% chance to get an energy core
public override void ExtractinatorUse(ref int resultType, ref int resultStack)
{
resultType = ModContent.ItemType<WulfrumMetalScrap>();
resultStack = Main.rand.Next(3, 6);
if (Main.rand.NextFloat() > 0.8f)
{
resultStack = 1;
resultType = ModContent.ItemType<EnergyCore>();
}
}
}
public class RoverDrivePlayer : ModPlayer
{
public bool RoverDriveOn;
public int ProtectionMatrixDurability = 0;
public int ProtectionMatrixCharge = 0;
public override void ResetEffects()
{
//Turn this into armor health when we can
if (RoverDriveOn)
Player.statLifeMax2 += ProtectionMatrixDurability;
else
ProtectionMatrixDurability = 0;
RoverDriveOn = false;
}
public override void PostHurt(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
{
if (RoverDriveOn)
{
if (ProtectionMatrixDurability > 0)
{
ProtectionMatrixDurability -= (int)damage;
if (ProtectionMatrixDurability <= 0)
{
ProtectionMatrixDurability = 0;
SoundEngine.PlaySound(RoverDrive.BreakSound, Player.Center);
Player.Calamity().GeneralScreenShakePower += 2f;
}
int numParticles = Main.rand.Next(2, 6);
for (int i = 0; i < numParticles; i++)
{
Vector2 velocity = Main.rand.NextVector2CircularEdge(1f, 1f) * Main.rand.NextFloat(3, 14);
velocity.X += 5f * hitDirection;
GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(Player.Center, velocity, Main.rand.NextFloat(2.5f, 3f), Main.rand.NextBool() ? new Color(99, 255, 229) : new Color(25, 132, 247), 25));
}
}
if (Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveDurability.ID, out var cdDurability))
{
cdDurability.timeLeft = ProtectionMatrixDurability;
}
//Reset recharge time.
if (Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var cd))
{
cd.timeLeft = RoverDrive.ProtectionMatrixRechargeTime;
}
}
}
public override void UpdateDead()
{
ProtectionMatrixDurability = 0;
}
public override void PostUpdateMiscEffects()
{
if (!RoverDriveOn)
{
if (Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveDurability.ID, out var cdDurability) && !RoverDriveOn)
cdDurability.timeLeft = 0;
if (Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var cdRecharge) && !RoverDriveOn)
cdRecharge.timeLeft = 0;
}
else
{
if (ProtectionMatrixDurability == 0 && !Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var cd))
{
Player.AddCooldown(WulfrumRoverDriveRecharge.ID, RoverDrive.ProtectionMatrixRechargeTime);
}
if (ProtectionMatrixDurability > 0 && !Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveDurability.ID, out cd))
{
CooldownInstance durabilityCooldown = Player.AddCooldown(WulfrumRoverDriveDurability.ID, RoverDrive.ProtectionMatrixDurabilityMax);
durabilityCooldown.timeLeft = ProtectionMatrixDurability;
SoundEngine.PlaySound(RoverDrive.ActivationSound, Player.Center);
}
if (ProtectionMatrixDurability > 0)
{
Lighting.AddLight(Player.Center, Color.DeepSkyBlue.ToVector3() * 0.2f);
}
}
}
}
}
@@ -0,0 +1,111 @@
using CalamityMod.CalPlayer;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Items.Accessories.Vanity
{
[AutoloadEquip(EquipType.Head)]
//A lot of legacy names that's for sure. A combo of the pre "WulfrumHeadX" names, and the aforementionned "WulfrumHeadX" names.
//This is done so that non summoners don't end up with a helmet they don't really care about anyways, and is a cute reference to the old look.
[LegacyName("WulfrumMask")]
[LegacyName("WulfrumHeadRogue")]
[LegacyName("WulfrumHeadgear")]
[LegacyName("WulfrumHeadRanged")]
[LegacyName("WulfrumHelm")]
[LegacyName("WulfrumHeadMelee")]
[LegacyName("WulfrumHood")]
[LegacyName("WulfrumHeadMagic")]
public class AbandonedWulfrumHelmet : ModItem
{
public override void Load()
{
if (Main.netMode != NetmodeID.Server)
{
EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/AbandonedWulfrumHelmet_HeadSet", EquipType.Head, name: "WulfrumOldSetHead");
EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/AbandonedWulfrumHelmet_Body", EquipType.Body, this);
EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/AbandonedWulfrumHelmet_Legs", EquipType.Legs, this);
}
}
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Abandoned Wulfrum Helmet");
Tooltip.SetDefault("A worn and rusty helmet ressembling older models of wulfrum armor\n" +
//Could include lore about how X kind of people used to wear it. Like "Streets used to be filled with people of The Resistance wearing this cheap yet effective armor.
"Transforms the holder into a wulfrum robot\n" +
"Can also be worn in the helmet slot as a regular helm");
if (Main.netMode == NetmodeID.Server)
return;
int equipSlotHead = EquipLoader.GetEquipSlot(Mod, "WulfrumOldSetHead", EquipType.Head);
ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false;
int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body);
ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true;
ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true;
int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs);
ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true;
}
public override void SetDefaults()
{
Item.width = 26;
Item.height = 30;
Item.accessory = true;
Item.value = CalamityGlobalItem.Rarity1BuyPrice;
Item.rare = ItemRarityID.Green;
Item.vanity = true;
}
public override void UpdateVanity(Player player)
{
player.GetModPlayer<WulfrumTransformationPlayer>().transformationActive = true;
player.GetModPlayer<WulfrumTransformationPlayer>().vanityEquipped = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
if (!hideVisual)
{
player.GetModPlayer<WulfrumTransformationPlayer>().transformationActive = true;
player.GetModPlayer<WulfrumTransformationPlayer>().vanityEquipped = true;
}
}
}
public class WulfrumTransformationPlayer : ModPlayer
{
public bool vanityEquipped = false;
public bool transformationActive = false;
public bool forceHelmetOn = false;
public override void ResetEffects()
{
vanityEquipped = false;
transformationActive = false;
forceHelmetOn = false;
}
public override void FrameEffects()
{
if (forceHelmetOn || transformationActive)
{
Player.head = EquipLoader.GetEquipSlot(Mod, "WulfrumOldSetHead", EquipType.Head);
Player.face = -1;
}
if (transformationActive)
{
Player.legs = EquipLoader.GetEquipSlot(Mod, "AbandonedWulfrumHelmet", EquipType.Legs);
Player.body = EquipLoader.GetEquipSlot(Mod, "AbandonedWulfrumHelmet", EquipType.Body);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

+496
View File
@@ -0,0 +1,496 @@
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Terraria.GameInput;
using Terraria.DataStructures;
using CalamityMod.Projectiles.Typeless;
using static Terraria.ModLoader.ModContent;
using System.Linq;
using Microsoft.Xna.Framework;
using CalamityMod.DataStructures;
using System.Collections.Generic;
using System;
using System.Linq;
using CalamityMod.Items.Materials;
using Terraria.Audio;
using CalamityMod.Sounds;
namespace CalamityMod.Items.Accessories
{
[AutoloadEquip(EquipType.Back)]
public class WulfrumAcrobaticsPack : ModItem
{
public static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Custom/WulfrumHookShoot") { Volume = 0.7f, MaxInstances = 1, SoundLimitBehavior = SoundLimitBehavior.ReplaceOldest};
public static readonly SoundStyle GrabSound = new("CalamityMod/Sounds/Custom/WulfrumHookGrapple") { Volume = 0.7f, MaxInstances = 1, SoundLimitBehavior = SoundLimitBehavior.ReplaceOldest };
public static readonly SoundStyle ReleaseSound = new("CalamityMod/Sounds/Custom/WulfrumHookDisengage") { Volume = 0.7f, MaxInstances = 1, SoundLimitBehavior = SoundLimitBehavior.ReplaceOldest };
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Acrobatics Pack");
Tooltip.SetDefault("This mess of cogs and wires in a box retools the winch mechanism of hooks to transform them into a wulfrum slingshot\n" +
"The wulfrum slingshot trades the ability to reel you back in for advanced rope physics, letting you swing around the hook as you please\n" +
"Additionally, the pack automatically attempts to grapple to the floor in case it detects imminent fall damage\n" +
"This safety feature won't activate if the down key is being held\n" +
"8% increased movement speed");
}
public override void SetDefaults()
{
Item.width = 20;
Item.height = 22;
Item.value = Item.buyPrice(0, 1, 0, 0);
Item.accessory = true;
Item.rare = ItemRarityID.Blue;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.moveSpeed += 0.08f;
player.GetModPlayer<WulfrumPackPlayer>().WulfrumPackEquipped = true;
player.GetModPlayer<WulfrumPackPlayer>().PackItem = Item;
Lighting.AddLight(player.Center, Color.Lerp(Color.DeepSkyBlue,Color.GreenYellow, (float)Math.Sin( Main.GlobalTimeWrappedHourly * 2f) * 0.5f + 0.5f).ToVector3());
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient(ItemID.Chain, 2).
AddIngredient<WulfrumMetalScrap>(6).
AddIngredient<EnergyCore>(1).
AddTile(TileID.Anvils).
Register();
}
}
public class WulfrumPackProjectile : GlobalProjectile
{
public override bool? CanUseGrapple(int type, Player player)
{
//Player can shoot up to 2 wulfrum hooks, but only 2 is allowed to stay grappled.
if (player.GetModPlayer<WulfrumPackPlayer>().WulfrumPackEquipped)
{
if (Main.projectile.Count(n => n.active && n.owner == player.whoAmI && n.type == ProjectileType<WulfrumHook>()) > 1)
return false;
}
//This should never happen. This is for the case in which the player shoots a hook without having the wulfrum pack equipped but somehow having a wulfrum hook out.
//Under no real circumstances should this happen, given wulfrum hooks instantly get killed if the player doesn't have the wulfrum pack.
else if (Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ProjectileType<WulfrumHook>()))
return false;
return base.CanUseGrapple(type, player);
}
//Prevent players with a wulfrum pack to spawn any non-wulfrum hooks.
public override void OnSpawn(Projectile projectile, IEntitySource source)
{
Player owner = Main.player[projectile.owner];
if (projectile.aiStyle == 7 && projectile.type != ProjectileType<WulfrumHook>() && owner.GetModPlayer<WulfrumPackPlayer>().WulfrumPackEquipped)
{
projectile.active = false;
}
}
}
public class WulfrumPackPlayer : ModPlayer
{
public bool WulfrumPackEquipped = false;
public Item PackItem = null;
public bool AutoGrappleActivated
{
get
{
if (!WulfrumPackEquipped || Grappled || //Ignore if player isnt wearing the grapple pack, or is already grappled.
Player.noFallDmg || Player.equippedWings != null || //Ignore if player can't take fall damage
Player.controlDown || //Ignore if player disables the auto grapple by holding down
Player.velocity.Y * Player.gravDir < 0 || //Ignore if not falling *down*
(Player.fallStart >= (int)(Player.position.Y / 16f) && Player.gravDir > 0) || (!(Player.fallStart <= (int)(Player.position.Y / 16f)) && Player.gravDir < 0) || //Ignore if the player is not falling below their last fall point
Player.mount.Active || //ignore if player is on a mount
Player.webbed || Player.stoned || Player.frozen || Player.vortexDebuff //Ignore if players movement is compromised
)
return false;
return true;
}
}
/// <summary>
/// The index of the grapple projectile currently grappled.
/// </summary>
public int Grapple = 0;
/// <summary>
/// The lenght of the current rope. Determined when the grapple lands.
/// </summary>
public float SwingLenght = 0f;
/// <summary>
/// Used when we need to store the hook between instructions.
/// </summary>
public int hookCache = -1;
/// <summary>
/// Is the player grappled?
/// </summary>
public bool Grappled => WulfrumPackEquipped && Main.projectile[Grapple].active && Main.projectile[Grapple].ModProjectile is WulfrumHook hook && hook.State == WulfrumHook.HookState.Grappling;
public bool GrappleMovementDisabled
{
get
{
if (!Grappled)
return false;
if (!PlayerOnGround)
return false;
if ((Player.Center - Main.projectile[Grapple].Center).Length() > SwingLenght)
return false;
return true;
}
}
public Vector2 CurrentPosition;
public Vector2 OldPosition;
public List<VerletSimulatedSegment> Segments;
public static int SimulationResolution = 3;
public static int HookUpdates = 3;
public static float GrappleVelocity = 17f;
public static float ReturnVelocity = 5f;
public static float MaxHopVelocity = 4f; //The maximum velocity at which the player gets any amount of vertical boost from hopping out of the hook
public static int SafetySteps = 3;
public static float SafetyHookAngle = MathHelper.PiOver2 * 1.2f;
public static float SafetyHookAngleResolution = 50f;
public bool PlayerOnGround => Collision.SolidCollision(Player.position + Vector2.UnitY* 2f * Player.gravDir, Player.width, Player.height, false);
public override void ResetEffects()
{
WulfrumPackEquipped = false;
PackItem = null;
}
//Initialize the segments between the player and the hook's end point.
public void SetSegments(Vector2 endPoint)
{
if (Segments == null)
Segments = new List<VerletSimulatedSegment>();
Segments.Clear();
for (int i = 0; i <= SimulationResolution; i++)
{
float progress = i / (float)SimulationResolution;
VerletSimulatedSegment segment = new VerletSimulatedSegment(Vector2.Lerp(endPoint, Player.Center, progress));
if (i == 0)
segment.locked = true;
if (i == SimulationResolution)
segment.oldPosition = Player.oldPosition + new Vector2(Player.width, Player.height) * 0.5f;
Segments.Add(segment);
}
}
public override void PostUpdateRunSpeeds()
{
if (hookCache != -1)
Player.grappling[0] = hookCache;
hookCache = -1;
}
public override void PreUpdateMovement()
{
//If the hook cache was set from -1 in the part before the player stepped up,reset it.
//Should this be detoured before the PlayerLoaders PreUpdateMovement call? In case another mod uses hooks in this call and their modplayer gets called before this one?
if (hookCache > -1)
Player.grappling[0] = hookCache;
hookCache = -1;
if (Grappled)
{
if ((Main.projectile[Grapple].Center - Player.Center).Length() > SwingLenght + 80f)
{
SoundEngine.PlaySound(WulfrumAcrobaticsPack.ReleaseSound, Main.projectile[Grapple].Center);
Main.projectile[Grapple].Kill();
}
else
SimulateMovement(Main.projectile[Grapple]);
}
}
public void SimulateMovement(Projectile grapple)
{
Segments = VerletSimulatedSegment.SimpleSimulation(Segments, SwingLenght / SimulationResolution, 50, 0.3f * Player.gravDir);
Vector2 CurrentPosition;
foreach (VerletSimulatedSegment position in Segments)
{
CurrentPosition = position.position;
//Control point markers
//Dust doost = Dust.NewDustPerfect(CurrentPosition, 1, Vector2.Zero);
//doost.noGravity = true;
}
if (!GrappleMovementDisabled)
{
CurrentPosition = Segments[SimulationResolution].position;
Player.velocity = CurrentPosition - Player.Center;
//let the player swing themselves around if they are under the hook.
if (Player.gravDir * (Player.Center.Y - Segments[0].position.Y) > 0)
{
float swing = 0;
if (Math.Sign(Player.velocity.X) < 0)
{
if (Player.controlLeft)
swing -= 0.1f;
else if (Player.controlRight)
swing += 0.1f;
}
else if (Math.Sign(Player.velocity.X) > 0)
{
if (Player.controlRight)
swing += 0.1f;
else if (Player.controlLeft)
swing -= 0.1f;
}
Player.velocity.X += swing;
}
else if (Math.Abs(Player.Center.X - Segments[0].position.X) < 30f && Math.Abs(Player.velocity.X) < 1)
{
Player.velocity.X = Player.velocity.X == 0 ? 1.5f : 1.5f * Math.Sign(Player.velocity.X);
}
}
if (Grappled)
{
for (int i = 1; i < Segments.Count; i++)
{
Lighting.AddLight(Segments[i].position, Color.Lerp(Color.DeepSkyBlue, Color.GreenYellow, i / (float)SimulationResolution).ToVector3());
}
}
//Set the old position of the simulation's segments to be the players current center (before the velocity gets applied
//We can't set the new position here by simply adding the velocity to the players current position because it leads to.. funny bugs if you collide with tiles.
Segments[SimulationResolution].oldPosition = Player.Center;
}
public override void PostUpdate()
{
//After the player's movements are finished being calculated, set the current position of the hook chain to be at their new center.
if (Grappled)
{
Segments[SimulationResolution].position = Player.Center;
if (!GrappleMovementDisabled)
{
//Play a swoosh sound if the player changed sides and moved fast
bool playerCrossedSides = Math.Sign(Segments[SimulationResolution].oldPosition.X - Segments[0].position.X) != Math.Sign(Segments[SimulationResolution].position.X - Segments[0].position.X);
float swingSpeed = (Segments[SimulationResolution].oldPosition - Segments[SimulationResolution].position).Length();
if (swingSpeed > 6f && playerCrossedSides)
SoundEngine.PlaySound(CommonCalamitySounds.LouderSwingWoosh with { Volume = CommonCalamitySounds.LouderSwingWoosh.Volume * (Math.Clamp((swingSpeed - 6f) / 12f, 0, 1)) }, Player.Center);
}
}
else if (AutoGrappleActivated)
{
Vector2 nextPlayerPosition = Player.position + Player.velocity;
Vector2 checkedPlayerPosition = Player.position;
bool imminentDanger = false;
for (int i = 0; i < SafetySteps; i++)
{
Vector2 collisionVector = Collision.TileCollision(checkedPlayerPosition, Player.velocity, Player.width, Player.height, gravDir: (int)Player.gravDir);
if (collisionVector.Y < Player.velocity.Y)
{
imminentDanger = true;
checkedPlayerPosition += collisionVector;
break;
}
checkedPlayerPosition += collisionVector;
}
if (!imminentDanger)
return;
int fallDistance = (int)(checkedPlayerPosition.Y / 16f) - Player.fallStart;
int fallDmgThreshold = 25 + Player.extraFall;
//Technically doesn't ignore clouds but oh well.
if (fallDistance * Player.gravDir > fallDmgThreshold)
{
float halfSpread = SafetyHookAngle / 2f;
Point bestGrapplePos = Point.Zero;
float bestGrappleScore = 0;
for (float angle = -halfSpread; angle < halfSpread; angle += SafetyHookAngle / SafetyHookAngleResolution)
{
for (int i = 0; i < (int)(WulfrumHook.MaxReach / 16f); i++ )
{
Vector2 checkSpot = Player.Center + (-Vector2.UnitY * Player.gravDir * i * 16f).RotatedBy(angle);
Point tilePos = checkSpot.ToSafeTileCoordinates();
Tile tile = Main.tile[tilePos];
if (tile.HasUnactuatedTile && tile.CanTileBeLatchedOnTo() && !Player.IsBlacklistedForGrappling(tilePos))
{
if (bestGrappleScore < EvaluatePotentialSafetyHookPos((checkSpot - Player.Center).Length(), angle))
{
bestGrapplePos = tilePos;
bestGrappleScore = EvaluatePotentialSafetyHookPos((checkSpot - Player.Center).Length(), angle);
}
break;
}
}
}
if (bestGrapplePos != Point.Zero)
{
//Clear any hooks that might have been flying before then.
for (int i = 0; i < Main.maxProjectiles; ++i)
{
Projectile p = Main.projectile[i];
if (!p.active || p.owner != Player.whoAmI || p.type != ProjectileType<WulfrumHook>())
continue;
if (p.ModProjectile is WulfrumHook claw)
{
SoundEngine.PlaySound(WulfrumAcrobaticsPack.ReleaseSound, p.Center);
p.Kill();
}
}
//Reset the players fall height, because if they take fall dmg in teh frame right after this one it may have a chance of still killing the player due to the
//code where the grapple resets the players fall speed hasnt been called yet
Player.fallStart = (int)(Player.position.Y / 16);
if (Player.whoAmI == Main.myPlayer)
{
Projectile.NewProjectile(Player.GetSource_ItemUse(PackItem), bestGrapplePos.ToWorldCoordinates(), Vector2.Zero, ProjectileType<WulfrumHook>(), 3, 0, Player.whoAmI);
}
}
}
}
}
public float EvaluatePotentialSafetyHookPos(float distance, float angle)
{
float score = 0.0001f;
if (distance < 2 * WulfrumHook.MaxReach / 3f)
score += distance / (2 * WulfrumHook.MaxReach / 3f);
else
score += 1 - (distance - (2 * WulfrumHook.MaxReach / 3f)) / (WulfrumHook.MaxReach / 3f);
score += (1 - Math.Abs(angle) / (SafetyHookAngle / 2f)) * 0.5f;
return score;
}
public override void ProcessTriggers(TriggersSet triggersSet)
{
if (!WulfrumPackEquipped)
return;
//Shoot a new hook
if (triggersSet.Grapple && Player.releaseHook)
{
//Clear any previous non-wulfrum hooks / Any hooks that just got shot (should already be handled by the global proj
for (int i = 0; i < Main.maxProjectiles; ++i)
{
Projectile p = Main.projectile[i];
if (!p.active || p.owner != Player.whoAmI || p.aiStyle != 7 || p.type == ProjectileType<WulfrumHook>())
continue;
p.Kill();
}
if (Main.projectile.Count(n => n.active && n.owner == Player.whoAmI && n.type == ProjectileType<WulfrumHook>()) <= 1)
{
SoundEngine.PlaySound(WulfrumAcrobaticsPack.ShootSound, Player.Center);
if (Player.whoAmI == Main.myPlayer)
{
Vector2 velocity = (Main.MouseWorld - Player.Center).SafeNormalize(Vector2.One) * GrappleVelocity;
Projectile.NewProjectile(Player.GetSource_ItemUse(PackItem), Player.Center, velocity, ProjectileType<WulfrumHook>(), 0, 0, Player.whoAmI);
}
}
}
//Jumping out of the hook
if (triggersSet.Jump && Player.releaseJump)
{
for (int i = 0; i < Main.maxProjectiles; ++i)
{
Projectile p = Main.projectile[i];
if (!p.active || p.owner != Player.whoAmI || p.type != ProjectileType<WulfrumHook>())
continue;
//Only clear hooks that are attached to stuff
if (p.ModProjectile is WulfrumHook claw && claw.State == WulfrumHook.HookState.Grappling)
{
float angleToUpright = (Player.Center - p.Center).AngleBetween(-Vector2.UnitY);
if (angleToUpright > MathHelper.PiOver4 * 0.45f) // Don't do any jump stuff if the player is jumping from above the hook.
{
Vector2 velocityBoost = Vector2.Zero;
//Additionally, accelerate the player a lil' if they were holding down the buttons in the direction of their swing.
if ((Math.Sign(Player.velocity.X) < 0 && Player.controlLeft) || (Math.Sign(Player.velocity.X) > 0 && Player.controlRight))
{
velocityBoost += Player.velocity * 0.15f;
}
//Additionally^2, if the player isnt moving very fast, make them do a straight up hop.
//Don't do the hop if the player isnt moving at all though because thats handled by vanilla.
if (Player.velocity.Length() < MaxHopVelocity && Player.velocity.Length() > 0.0001f || PlayerOnGround)
{
velocityBoost -= Vector2.UnitY * Player.jumpSpeed * (1 - (float)Math.Pow(Player.velocity.Length() / MaxHopVelocity, 5f));
}
Player.velocity += velocityBoost;
Player.jump = Player.jumpHeight / 2;
}
else
{
//Prevents double jumps from getting activated
Player.releaseJump = false;
}
SoundEngine.PlaySound(WulfrumAcrobaticsPack.ReleaseSound, p.Center);
p.Kill();
}
}
}
}
public override void FrameEffects()
{
//Cache the hook. This is done so that the player may walk around animated if the grapple's movement is disabled.
//The cache is retrieved in the postFrame detour.
if (Player.grappling[0] >= 0 && GrappleMovementDisabled && Main.projectile[Player.grappling[0]].type == ProjectileType<WulfrumHook>())
{
hookCache = Player.grappling[0];
Player.grappling[0] = -1;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

+65 -3
View File
@@ -1,16 +1,26 @@
using Terraria;
using Terraria.ModLoader;
using CalamityMod.Items.Materials;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Accessories
{
public class WulfrumBattery : ModItem
{
public static readonly SoundStyle ExtraDropSound = new("CalamityMod/Sounds/Custom/WulfrumExtraDrop") { PitchVariance = 0.3f };
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Battery");
Tooltip.SetDefault("7% increased summon damage");
Tooltip.SetDefault( "Empowers your summons with wulfrum energy, letting them emit light around them\n" +
"7% increased summon damage\n" +
"50% chance to get an extra scrap when killing wulfrum robots\n" +
"Can also be scrapped at an extractinator");
ItemID.Sets.ExtractinatorMode[Item.type] = Item.type;
}
public override void SetDefaults()
@@ -20,11 +30,63 @@ namespace CalamityMod.Items.Accessories
Item.value = Item.buyPrice(0, 1, 0, 0);
Item.accessory = true;
Item.rare = ItemRarityID.Blue;
//Needed for extractination
Item.useStyle = ItemUseStyleID.HiddenAnimation;
Item.useAnimation = 10;
Item.useTime = 2;
Item.consumable = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.GetDamage<SummonDamageClass>() += 0.07f;
player.GetModPlayer<WulfrumBatteryPlayer>().battery = true;
}
//Scrappable for 3-6 wulfrum scrap or a 20% chance to get an energy core
public override void ExtractinatorUse(ref int resultType, ref int resultStack)
{
resultType = ModContent.ItemType<WulfrumMetalScrap>();
resultStack = Main.rand.Next(3, 6);
if (Main.rand.NextFloat() > 0.8f)
{
resultStack = 1;
resultType = ModContent.ItemType<EnergyCore>();
}
}
}
public class WulfrumBatteryPlayer : ModPlayer
{
public bool battery = false;
public override void ResetEffects() => battery = false;
public override void UpdateDead() => battery = false;
}
public class WulfrumBatteryGlobalProjectile : GlobalProjectile
{
public override void AI(Projectile projectile)
{
if (!projectile.npcProj && !projectile.trap && projectile.minion && !ProjectileID.Sets.MinionShot[projectile.type] && Main.player[projectile.owner].GetModPlayer<WulfrumBatteryPlayer>().battery)
{
float lightMult = 3f;
if (Lighting.UpdateEveryFrame) //The light loks wayyy too bright in retro/trippy
lightMult = 1.5f;
Lighting.AddLight(projectile.Center, Color.DeepSkyBlue.ToVector3() * lightMult);
if (Main.rand.NextBool(16))
{
float size = (projectile.Hitbox.Size() / 2f).Length();
Dust zapDust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(1f, 1f) * size, 226, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(1f, 2.3f));
zapDust.noGravity = true;
}
}
}
}
}
-38
View File
@@ -1,38 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Armor.Wulfrum
{
[AutoloadEquip(EquipType.Body)]
public class WulfrumArmor : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Armor");
Tooltip.SetDefault("3% increased critical strike chance");
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 50, 0);
Item.rare = ItemRarityID.Blue;
Item.defense = 2;
}
public override void UpdateEquip(Player player) => player.GetCritChance<GenericDamageClass>() += 3;
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(12).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

+145
View File
@@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Cooldowns;
using CalamityMod.Items.BaseItems;
using CalamityMod.Projectiles.Summon;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Items.Armor.Wulfrum
{
public class WulfrumFusionCannon : HeldOnlyItem, IHideFrontArm
{
public static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/WulfrumProsthesisShoot") { PitchVariance = 0.1f, Volume = 0.4f };
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Experimental Wulfrum Fusion Array");
Tooltip.SetDefault("Fires quick bursts of medium-range pellets\n" +
"[c/878787:\"Who needs whips when you can simply become the summon yourself?\"]");
//Imaging hiding actually important/interesting/funny lore in there... :drool: that would be so dark souls
}
public override string Texture => "CalamityMod/Items/Armor/Wulfrum/WulfrumFusionCannon";
public bool noAnimation = false;
public override void SetDefaults()
{
Item.damage = 6;
Item.DamageType = DamageClass.Summon;
Item.width = 34;
Item.height = 42;
Item.useStyle = ItemUseStyleID.Shoot;
Item.noMelee = true;
Item.knockBack = 2;
Item.rare = ItemRarityID.Green;
Item.UseSound = ShootSound;
Item.autoReuse = true;
Item.shoot = ModContent.ProjectileType<WulfrumFusionBolt>();
Item.shootSpeed = 18f;
Item.holdStyle = 16; //Custom hold style
Item.useAnimation = 10;
Item.useTime = 4;
Item.reuseDelay = 17;
Item.noUseGraphic = false;
}
public override void ModifyTooltips(List<TooltipLine> tooltips)
{
var name = tooltips.FirstOrDefault(x => x.Name == "ItemName" && x.Mod == "Terraria");
name.OverrideColor = Color.Lerp(new Color(194, 255, 67), new Color(112, 244, 244), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f));
}
public override void HoldItem(Player player)
{
player.Calamity().mouseWorldListener = true;
if (player.whoAmI == Main.myPlayer)
{
if (!WulfrumHat.HasArmorSet(player))
{
Item.type = 0;
Item.SetDefaults(0);
Item.stack = 0;
Main.mouseItem = new Item();
}
}
Item.noUseGraphic = false;
if (!player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out var cd) || cd.timeLeft > WulfrumHat.BastionCooldown + WulfrumHat.BastionTime - WulfrumHat.BastionBuildTime)
Item.noUseGraphic = true;
}
public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback)
{
velocity = velocity.RotatedByRandom(MathHelper.PiOver4 * 0.1f);
}
public override bool CanUseItem(Player player)
{
return player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out var cd) && cd.timeLeft < WulfrumHat.BastionCooldown + WulfrumHat.BastionTime - WulfrumHat.BastionBuildTime;
}
public void SetItemInHand(Player player, Rectangle heldItemFrame)
{
//Make the player face where they're aiming.
if (player.Calamity().mouseWorld.X > player.Center.X)
{
player.ChangeDir(1);
}
else
{
player.ChangeDir(-1);
}
//Hide the cannon till its visible on the player
if (!player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out var cd) || cd.timeLeft > WulfrumHat.BastionCooldown + WulfrumHat.BastionTime - WulfrumHat.BastionBuildTime)
return;
if (player.ItemTimeIsZero)
noAnimation = false;
if (player.itemAnimation > Item.useAnimation)
noAnimation = true;
float animProgress = 1 - player.itemAnimation / (float)player.itemAnimationMax;
//It beecomes nan if the player loads into a world with the set bonus already active / without shooting any weapons before using it.
//this is because itemAnimationMax isnt set before the item gets used once.
if (noAnimation || animProgress is float.NaN)
animProgress = 1;
//Default
Vector2 itemPosition = player.MountedCenter + new Vector2(-2f * player.direction, -1f * player.gravDir);
float itemRotation = (player.Calamity().mouseWorld - itemPosition).ToRotation();
//Adjust for animation
if (animProgress < 0.9f)
itemPosition -= itemRotation.ToRotationVector2() * (1 - (float)Math.Pow(1 - (0.9f - animProgress) / 0.9f, 4)) * 3f;
if (animProgress < 0.6f)
itemRotation += -0.3f * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction * player.gravDir;
//Shakezzz
itemPosition += Main.rand.NextVector2Circular(2f, 2f) * (1 - animProgress);
Vector2 itemSize = new Vector2(38, 18);
Vector2 itemOrigin = new Vector2(-12, 0);
CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin, true);
}
public override void HoldStyle(Player player, Rectangle heldItemFrame) => SetItemInHand(player, heldItemFrame);
public override void UseStyle(Player player, Rectangle heldItemFrame) => SetItemInHand(player, heldItemFrame);
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) => false;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 B

-58
View File
@@ -1,58 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Armor.Wulfrum
{
[AutoloadEquip(EquipType.Head)]
[LegacyName("WulfrumHood")]
public class WulfrumHeadMagic : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Visage");
Tooltip.SetDefault("10% increased magic damage");
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 75, 0);
Item.rare = ItemRarityID.Blue;
Item.defense = 1; //6
}
public override bool IsArmorSet(Item head, Item body, Item legs)
{
return body.type == ModContent.ItemType<WulfrumArmor>() && legs.type == ModContent.ItemType<WulfrumLeggings>();
}
public override void UpdateArmorSet(Player player)
{
player.setBonus = "+3 defense\n" +
"+5 defense when below 50% life";
player.statDefense += 3; //9
if (player.statLife <= player.statLifeMax2 * 0.5f)
{
player.statDefense += 5; //14
}
}
public override void UpdateEquip(Player player)
{
player.GetDamage<MagicDamageClass>() += 0.1f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(5).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

-60
View File
@@ -1,60 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Armor.Wulfrum
{
[AutoloadEquip(EquipType.Head)]
[LegacyName("WulfrumHelm")]
public class WulfrumHeadMelee : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Helm");
Tooltip.SetDefault("10% increased melee damage");
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 75, 0);
Item.rare = ItemRarityID.Blue;
Item.defense = 3; //8
}
public override bool IsArmorSet(Item head, Item body, Item legs)
{
return body.type == ModContent.ItemType<WulfrumArmor>() && legs.type == ModContent.ItemType<WulfrumLeggings>();
}
public override void UpdateArmorSet(Player player)
{
player.setBonus = "Enemies are more likely to target you\n" +
"+3 defense\n" +
"+5 defense when below 50% life";
player.statDefense += 3; //11
if (player.statLife <= (int)(player.statLifeMax2 * 0.5))
{
player.statDefense += 5; //16
}
player.aggro += 100;
}
public override void UpdateEquip(Player player)
{
player.GetDamage<MeleeDamageClass>() += 0.1f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(5).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

-58
View File
@@ -1,58 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Armor.Wulfrum
{
[AutoloadEquip(EquipType.Head)]
[LegacyName("WulfrumHeadgear")]
public class WulfrumHeadRanged : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Headgear");
Tooltip.SetDefault("10% increased ranged damage");
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 75, 0);
Item.rare = ItemRarityID.Blue;
Item.defense = 2; //7
}
public override bool IsArmorSet(Item head, Item body, Item legs)
{
return body.type == ModContent.ItemType<WulfrumArmor>() && legs.type == ModContent.ItemType<WulfrumLeggings>();
}
public override void UpdateArmorSet(Player player)
{
player.setBonus = "+3 defense\n" +
"+5 defense when below 50% life";
player.statDefense += 3; //10
if (player.statLife <= player.statLifeMax2 * 0.5f)
{
player.statDefense += 5; //15
}
}
public override void UpdateEquip(Player player)
{
player.GetDamage<RangedDamageClass>() += 0.1f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(5).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

-66
View File
@@ -1,66 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.CalPlayer;
namespace CalamityMod.Items.Armor.Wulfrum
{
[AutoloadEquip(EquipType.Head)]
[LegacyName("WulfrumMask")]
public class WulfrumHeadRogue : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Mask");
Tooltip.SetDefault("10% increased rogue damage");
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 75, 0);
Item.rare = ItemRarityID.Blue;
Item.defense = 1; //6
}
public override bool IsArmorSet(Item head, Item body, Item legs)
{
return body.type == ModContent.ItemType<WulfrumArmor>() && legs.type == ModContent.ItemType<WulfrumLeggings>();
}
public override void UpdateArmorSet(Player player)
{
var modPlayer = player.Calamity();
player.setBonus = "+3 defense\n" +
"+5 defense when below 50% life\n" +
"Rogue stealth builds while not attacking and slower while moving, up to a max of 50\n" +
"Once you have built max stealth, you will be able to perform a Stealth Strike\n" +
"Rogue stealth only reduces when you attack, it does not reduce while moving\n" +
"The higher your rogue stealth the higher your rogue damage, crit, and movement speed";
player.statDefense += 3; //9
if (player.statLife <= (int)(player.statLifeMax2 * 0.5))
{
player.statDefense += 5; //14
}
modPlayer.rogueStealthMax += 0.5f;
modPlayer.wearingRogueArmor = true;
}
public override void UpdateEquip(Player player)
{
player.GetDamage<ThrowingDamageClass>() += 0.1f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(5).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

-58
View File
@@ -1,58 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Armor.Wulfrum
{
[AutoloadEquip(EquipType.Head)]
[LegacyName("WulfrumHelmet")]
public class WulfrumHeadSummon : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Helmet");
Tooltip.SetDefault("10% increased minion damage");
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 75, 0);
Item.rare = ItemRarityID.Blue;
}
public override bool IsArmorSet(Item head, Item body, Item legs)
{
return body.type == ModContent.ItemType<WulfrumArmor>() && legs.type == ModContent.ItemType<WulfrumLeggings>();
}
public override void UpdateArmorSet(Player player)
{
player.setBonus = "+3 defense and +1 max minion\n" +
"+5 defense when below 50% life";
player.statDefense += 3; //8
player.maxMinions++;
if (player.statLife <= (int)(player.statLifeMax2 * 0.5))
{
player.statDefense += 5; //13
}
}
public override void UpdateEquip(Player player)
{
player.GetDamage<SummonDamageClass>() += 0.1f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(5).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

-41
View File
@@ -1,41 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Armor.Wulfrum
{
[AutoloadEquip(EquipType.Legs)]
public class WulfrumLeggings : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Leggings");
Tooltip.SetDefault("Movement speed increased by 5%");
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 25, 0);
Item.rare = ItemRarityID.Blue;
Item.defense = 1;
}
public override void UpdateEquip(Player player)
{
player.moveSpeed += 0.05f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(8).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

+467
View File
@@ -0,0 +1,467 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
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;
namespace CalamityMod.Items.Armor.Wulfrum
{
#region Armor pieces
//Datsuzei / Moonstone armor from starlight river was a nice jumping off point for this kind of set.
[AutoloadEquip(EquipType.Head)]
[LegacyName("WulfrumHelmet")]
[LegacyName("WulfrumHeadSummon")]
public class WulfrumHat : ModItem, IExtendedHat
{
#region big hat
public string ExtensionTexture => "CalamityMod/Items/Armor/Wulfrum/WulfrumHat_HeadExtension";
public Vector2 ExtensionSpriteOffset(PlayerDrawSet drawInfo) => -Vector2.UnitY * 2f;
public string EquipSlotName(Player drawPlayer) => drawPlayer.Male ? Name : "WulfrumHatFemale";
#endregion
public static readonly SoundStyle SetActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/WulfrumBastionActivate");
public static readonly SoundStyle SetBreakSound = new("CalamityMod/Sounds/Custom/AbilitySounds/WulfrumBastionBreak");
public static readonly SoundStyle SetBreakSoundSafe = new("CalamityMod/Sounds/Custom/AbilitySounds/WulfrumBastionBreakSafely");
public static int BastionBuildTime = (int)(0.55f * 60);
public static int BastionTime = 30 * 60;
public static int TimeLostPerHit = 2 * 60;
public static int BastionCooldown = 20 * 60;
internal static Item DummyCannon = new Item(); //Used for the attack swap. Basically we force the player to hold a fake item.
public static bool PowerModeEngaged(Player player, out CooldownInstance cd)
{
cd = null;
bool hasWulfrumBastionCD = player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out cd);
return (hasWulfrumBastionCD && cd.timeLeft > BastionCooldown);
}
public override void Load()
{
if (Main.netMode != NetmodeID.Server)
{
EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Armor/Wulfrum/WulfrumHat_FemaleHead", EquipType.Head, name : "WulfrumHatFemale");
}
On.Terraria.Player.KeyDoubleTap += ActivateSetBonus;
On.Terraria.Main.DrawPendingMouseText += SpoofMouseItem;
}
public override void Unload()
{
On.Terraria.Player.KeyDoubleTap -= ActivateSetBonus;
On.Terraria.Main.DrawPendingMouseText -= SpoofMouseItem;
DummyCannon.TurnToAir();
DummyCannon = null;
}
private void ActivateSetBonus(On.Terraria.Player.orig_KeyDoubleTap orig, Player player, int keyDir)
{
if (keyDir == 0 && HasArmorSet(player) && !player.mount.Active)
{
//Only activate if no cooldown & available scrap.
if (!player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out CooldownInstance cd) && player.HasItem(ModContent.ItemType<WulfrumMetalScrap>()))
{
player.ConsumeItem(ModContent.ItemType<WulfrumMetalScrap>());
//I Thiiiinnnk there's no need to add mp syncing packets sicne cooldowns get auto synced right.
player.AddCooldown(WulfrumBastion.ID, BastionCooldown + BastionTime);
//Though do i need to sync that or is the player inventory auto synced?
DummyCannon.SetDefaults(ItemType<WulfrumFusionCannon>());
}
}
orig(player, keyDir);
}
//Replaces the tooltip of the armor set with the fusion cannon if the player holds shift
private void SpoofMouseItem(On.Terraria.Main.orig_DrawPendingMouseText orig)
{
var player = Main.LocalPlayer;
if (DummyCannon.IsAir && !Main.gameMenu)
DummyCannon.SetDefaults(ItemType<WulfrumFusionCannon>());
if (IsPartOfSet(Main.HoverItem) && HasArmorSet(player) && Main.keyState.IsKeyDown(LeftShift))
{
Main.HoverItem = DummyCannon.Clone();
Main.hoverItemName = DummyCannon.Name;
}
orig();
}
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Hat & Goggles");
Tooltip.SetDefault("10% increased minion damage\n"+
"Comes equipped with hair extensions" );
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 75, 0);
Item.rare = ItemRarityID.Blue;
}
public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ItemType<WulfrumJacket>() && legs.type == ItemType<WulfrumOveralls>();
public static bool HasArmorSet(Player player) => player.armor[0].type == ItemType<WulfrumHat>() && player.armor[1].type == ItemType<WulfrumJacket>() && player.armor[2].type == ItemType<WulfrumOveralls>();
public bool IsPartOfSet(Item item) => item.type == ItemType<WulfrumHat>() ||
item.type == ItemType<WulfrumJacket>() ||
item.type == ItemType<WulfrumOveralls>();
public override void UpdateArmorSet(Player player)
{
WulfrumArmorPlayer armorPlayer = player.GetModPlayer<WulfrumArmorPlayer>();
WulfrumTransformationPlayer transformationPlayer = player.GetModPlayer<WulfrumTransformationPlayer>();
armorPlayer.wulfrumSet = true;
player.setBonus = "+1 max minion"; //The cooler part of the set bonus happens in modifytooltips because i can't recolor it otherwise. Madge
player.maxMinions++;
if (PowerModeEngaged(player, out var cd))
{
if (cd.timeLeft == BastionCooldown + BastionTime)
{
ActivationEffects(player);
}
//Can't account for previous fullbody transformations but at this point, whatever.
Item headItem = player.armor[10].type != 0 ? player.armor[10] : player.armor[0];
bool hatVisible = !transformationPlayer.transformationActive && headItem.type == ItemType<WulfrumHat>();
//Spawn the hat
if (cd.timeLeft == BastionCooldown + BastionTime - (int)(BastionBuildTime * 0.9f) && hatVisible)
{
Particle leftoverHat = new WulfrumHatParticle(player, -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 7f), 25);
GeneralParticleHandler.SpawnParticle(leftoverHat);
}
if (cd.timeLeft < BastionCooldown + BastionTime - BastionBuildTime)
player.GetModPlayer<WulfrumTransformationPlayer>().transformationActive = true;
else if (cd.timeLeft <= BastionCooldown + BastionTime - (int)(BastionBuildTime * 0.9f))
player.GetModPlayer<WulfrumTransformationPlayer>().forceHelmetOn = true;
player.statDefense += 13;
//Drop the player's held item if they were holding something before
if (!(Main.mouseItem.type == DummyCannon.type) && !Main.mouseItem.IsAir)
Main.LocalPlayer.QuickSpawnClonedItem(null, Main.mouseItem, Main.mouseItem.stack);
//Slot 58 is the "fake" slot thats used for the item the player is holding in their mouse.
Main.mouseItem = DummyCannon;
player.inventory[58] = DummyCannon;
player.selectedItem = 58;
}
else
{
//Clear the player's hand
if (Main.mouseItem.type == ItemType<WulfrumFusionCannon>())
Main.mouseItem = new Item();
DummyCannon.TurnToAir();
}
}
public void ActivationEffects(Player player)
{
SoundEngine.PlaySound(SetActivationSound);
//Do'nt do the effect ifthe player is already using the wulfrum vanity lol.
bool transformedAlready = player.GetModPlayer<WulfrumTransformationPlayer>().transformationActive;
if (!transformedAlready)
{
for (int i = 0; i < 5; i++)
{
Particle part = new WulfrumBastionPartsParticle(player, i, BastionBuildTime + 2);
GeneralParticleHandler.SpawnParticle(part);
}
}
//Do spawn the cannon always though
Particle gun = new WulfrumBastionPartsParticle(player, 5, BastionBuildTime + 2);
if (transformedAlready)
{
(gun as WulfrumBastionPartsParticle).TimeOffset = 0;
(gun as WulfrumBastionPartsParticle).AnimationTime = BastionBuildTime + 2;
}
GeneralParticleHandler.SpawnParticle(gun);
}
public static void ModifySetTooltips(ModItem item, List<TooltipLine> tooltips)
{
if (HasArmorSet(Main.LocalPlayer))
{
int setBonusIndex = tooltips.FindIndex(x => x.Name == "SetBonus" && x.Mod == "Terraria");
if (setBonusIndex != -1)
{
TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", "Wulfrum Bastion - Double tap DOWN while dismounted to equip a heavy wulfrum armor");
setBonus1.OverrideColor = Color.Lerp(new Color(194, 255, 67), new Color(112, 244, 244), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f));
tooltips.Insert(setBonusIndex + 1, setBonus1);
TooltipLine setBonus2 = new TooltipLine(item.Mod, "CalamityMod:SetBonus2", "While the power armor is active, you can only use the integrated fusion cannon, but get increased defensive stats");
setBonus2.OverrideColor = new Color(110, 192, 93);
tooltips.Insert(setBonusIndex + 2, setBonus2);
TooltipLine setBonus3 = new TooltipLine(item.Mod, "CalamityMod:SetBonus3", "Calling down the armor consumes one piece of wulfrum scrap, and the armor will lose durability faster when hit");
setBonus3.OverrideColor = new Color(110, 192, 93);
tooltips.Insert(setBonusIndex + 3, setBonus3);
if (!Main.keyState.IsKeyDown(LeftShift))
{
TooltipLine itemDisplay = new TooltipLine(item.Mod, "CalamityMod:ArmorItemDisplay", "Hold SHIFT to see the stats of the fusion cannon");
itemDisplay.OverrideColor = new Color(190, 190, 190);
tooltips.Add(itemDisplay);
}
}
}
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => ModifySetTooltips(this, tooltips);
public override void UpdateEquip(Player player)
{
player.GetDamage<SummonDamageClass>() += 0.1f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumMetalScrap>(5).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
[AutoloadEquip(EquipType.Body)]
[LegacyName("WulfrumArmor")]
public class WulfrumJacket : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Jacket");
Tooltip.SetDefault("3% increased critical strike chance");
if (Main.netMode != NetmodeID.Server)
{
var equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body);
ArmorIDs.Body.Sets.HidesArms[equipSlot] = true;
ArmorIDs.Body.Sets.HidesTopSkin[equipSlot] = true;
}
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 50, 0);
Item.rare = ItemRarityID.Blue;
Item.defense = 2;
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => WulfrumHat.ModifySetTooltips(this, tooltips);
public override void UpdateEquip(Player player) => player.GetCritChance<GenericDamageClass>() += 3;
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumMetalScrap>(12).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
[AutoloadEquip(EquipType.Legs)]
[LegacyName("WulfrumLeggings")]
public class WulfrumOveralls : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Overalls");
Tooltip.SetDefault("Movement speed increased by 5%");
}
public override void SetDefaults()
{
Item.width = 18;
Item.height = 18;
Item.value = Item.buyPrice(0, 0, 25, 0);
Item.rare = ItemRarityID.Blue;
Item.defense = 1;
if (Main.netMode != NetmodeID.Server)
{
var equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs);
ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlot] = true;
}
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => WulfrumHat.ModifySetTooltips(this, tooltips);
public override void UpdateEquip(Player player)
{
player.moveSpeed += 0.05f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumMetalScrap>(8).
AddIngredient<EnergyCore>().
AddTile(TileID.Anvils).
Register();
}
}
#endregion
public class WulfrumArmorPlayer : ModPlayer
{
public static int BastionShootDamage = 10;
public static float BastionShootSpeed = 18f;
public static int BastionShootTime = 10;
public bool wulfrumSet = false;
public override void ResetEffects()
{
wulfrumSet = false;
}
public override void UpdateDead()
{
wulfrumSet = false;
}
public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
{
if (WulfrumHat.PowerModeEngaged(Player, out var cd) && Main.netMode != NetmodeID.Server)
{
SetBonusEndEffect(true);
if (!Player.GetModPlayer<WulfrumTransformationPlayer>().vanityEquipped)
Player.GetModPlayer<WulfrumTransformationPlayer>().transformationActive = false;
}
}
public override void PostUpdate()
{
if (wulfrumSet && Player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out var cd) && cd.timeLeft == WulfrumHat.BastionCooldown)
{
SetBonusEndEffect(false);
}
}
public override void PostHurt(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
{
if (WulfrumHat.PowerModeEngaged(Player, out var cd))
{
cd.timeLeft -= WulfrumHat.TimeLostPerHit;
if (cd.timeLeft < WulfrumHat.BastionCooldown)
{
cd.timeLeft = WulfrumHat.BastionCooldown - 1;
if (Main.netMode != NetmodeID.Server)
SetBonusEndEffect(true);
}
}
}
public void SetBonusEndEffect(bool violent)
{
SoundStyle breakSound = WulfrumHat.SetBreakSoundSafe;
float goreSpeed = 3f;
int goreCount = 4;
int goreIncrement = 2;
if (violent)
{
breakSound = WulfrumHat.SetBreakSound;
goreSpeed = 9f;
goreCount = 9;
goreIncrement = 1;
}
SoundEngine.PlaySound(breakSound, Player.Center);
//Only spawn the cannon gore if the player already has the vanity on.
if (Player.GetModPlayer<WulfrumTransformationPlayer>().vanityEquipped)
{
Vector2 shrapnelVelocity = Main.rand.NextVector2Circular(goreSpeed, goreSpeed);
Gore.NewGore(Player.GetSource_Death(), Player.Center, shrapnelVelocity, Mod.Find<ModGore>("WulfrumPowerSuit1").Type);
}
else
{
int j = 1;
for (int i = 1; i < goreCount; i++)
{
Vector2 shrapnelVelocity = Main.rand.NextVector2Circular(goreSpeed, goreSpeed);
string goreType = "WulfrumPowerSuit" + j.ToString();
Gore.NewGore(Player.GetSource_Death(), Player.Center, shrapnelVelocity, Mod.Find<ModGore>(goreType).Type);
j += Main.rand.Next(1, goreIncrement);
}
}
}
public override void PostUpdateMiscEffects()
{
//This is important. Prevents ppl cheat sheeting the item in from softlocking their mouse button lol
if (Main.mouseItem.ModItem is WulfrumFusionCannon && !WulfrumHat.PowerModeEngaged(Player, out _))
{
Main.mouseItem.TurnToAir();
}
//This shouldn't ever be possible since the power mode prevents you from using or moving items around
if (!wulfrumSet && WulfrumHat.PowerModeEngaged(Player, out var cd))
{
cd.timeLeft = WulfrumHat.BastionCooldown;
}
}
public override void FrameEffects()
{
//Give the braids variant to w*men
if (!Player.Male && Player.head == EquipLoader.GetEquipSlot(Mod, "WulfrumHat", EquipType.Head))
Player.head = EquipLoader.GetEquipSlot(Mod, "WulfrumHatFemale", EquipType.Head);
}
}
}
+67
View File
@@ -0,0 +1,67 @@
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Terraria.DataStructures;
using Terraria.Audio;
using CalamityMod.Items.Materials;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Items.BaseItems
{
/// <summary>
/// A item that only exists as a held item. Useful if for example, it is used as a mean to temporarily replace the players attack ability.
/// </summary>
public abstract class HeldOnlyItem : ModItem
{
public virtual bool VisibleInUI => false;
public override void Load()
{
On.Terraria.Player.dropItemCheck += DontDropCoolStuff;
On.Terraria.UI.ItemSlot.LeftClick_ItemArray_int_int += LockMouseToSpecialItem;
On.Terraria.UI.ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color += DrawSpecial;
}
public override void Unload()
{
On.Terraria.Player.dropItemCheck -= DontDropCoolStuff;
On.Terraria.UI.ItemSlot.LeftClick_ItemArray_int_int -= LockMouseToSpecialItem;
On.Terraria.UI.ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color -= DrawSpecial;
}
private void DrawSpecial(On.Terraria.UI.ItemSlot.orig_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color orig, SpriteBatch sb, Item[] inv, int context, int slot, Vector2 position, Color color)
{
if (inv[slot].ModItem is HeldOnlyItem && !(inv[slot].ModItem as HeldOnlyItem).VisibleInUI)
return;
else
orig(sb, inv, context, slot, position, color);
}
public override void PostUpdate()
{
//Die if in the world
Item.type = 0;
Item.stack = 0;
}
public override bool CanPickup(Player player) => false;
private void LockMouseToSpecialItem(On.Terraria.UI.ItemSlot.orig_LeftClick_ItemArray_int_int orig, Item[] inv, int context, int slot)
{
if (!(Main.mouseItem.ModItem is HeldOnlyItem))
orig(inv, context, slot);
}
//https://media.discordapp.net/attachments/458432092301295618/993675527539916850/unknown.png
private void DontDropCoolStuff(On.Terraria.Player.orig_dropItemCheck orig, Terraria.Player self)
{
if (!(Main.mouseItem.ModItem is HeldOnlyItem))
orig(self);
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) => false;
}
}
+2 -2
View File
@@ -257,13 +257,13 @@ namespace CalamityMod.Items
case ItemID.WoodenCrate:
case ItemID.WoodenCrateHard:
BlockCrateDrops();
DropHelper.DropItemChance(s, player, ModContent.ItemType<WulfrumShard>(), 0.25f, 3, 5);
DropHelper.DropItemChance(s, player, ModContent.ItemType<WulfrumMetalScrap>(), 0.25f, 3, 5);
break;
case ItemID.IronCrate:
case ItemID.IronCrateHard:
BlockCrateDrops();
DropHelper.DropItemChance(s, player, ModContent.ItemType<WulfrumShard>(), 0.25f, 5, 8);
DropHelper.DropItemChance(s, player, ModContent.ItemType<WulfrumMetalScrap>(), 0.25f, 5, 8);
DropHelper.DropItemChance(s, player, ModContent.ItemType<AncientBoneDust>(), 0.25f, 5, 8);
break;
+2 -2
View File
@@ -12,7 +12,7 @@ namespace CalamityMod.Items.Fishing.FishingRods
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Fishing Pole");
Tooltip.SetDefault("This barely works, but it's better than nothing.");
Tooltip.SetDefault("This barely works, but it's better than nothing");
}
public override void SetDefaults()
@@ -33,7 +33,7 @@ namespace CalamityMod.Items.Fishing.FishingRods
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(9).
AddIngredient<WulfrumMetalScrap>(9).
AddTile(TileID.Anvils).
Register();
}
+40 -1
View File
@@ -1,10 +1,17 @@
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Terraria.DataStructures;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.Wulfrum;
using Terraria.Audio;
using CalamityMod.Cooldowns;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Items.Materials
{
public class WulfrumShard : ModItem
[LegacyName("WulfrumShard")]
public class WulfrumMetalScrap : ModItem
{
public override void SetStaticDefaults()
{
@@ -20,5 +27,37 @@ namespace CalamityMod.Items.Materials
Item.value = Item.sellPrice(copper: 80);
Item.rare = ItemRarityID.Blue;
}
public override void OnSpawn(IEntitySource source)
{
if (source is EntitySource_Loot)
{
if (Main.rand.NextBool())
return;
bool closePlayer = false;
for (int i = 0; i < Main.maxPlayers; i++)
{
if ((Main.player[i].Center - Item.Center).Length() < 1200 && Main.player[i].GetModPlayer<WulfrumBatteryPlayer>().battery)
{
closePlayer = true;
break;
}
}
if (closePlayer)
{
Item.stack++;
SoundEngine.PlaySound(WulfrumBattery.ExtraDropSound, Item.Center);
int numDust = Main.rand.Next(3, 7);
for (int i = 0; i < numDust; i++)
{
Dust.NewDustDirect(Item.position, Item.width, Item.height, Main.rand.NextBool() ? 246 : 247, 0, -3f, Scale: Main.rand.NextFloat(0.9f, 1f));
}
}
}
}
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 438 B

+3 -65
View File
@@ -1,4 +1,4 @@
using CalamityMod.Buffs.Mounts;
using CalamityMod.Buffs.Mounts;
using CalamityMod.Tiles.Abyss;
using Microsoft.Xna.Framework;
using System;
@@ -97,16 +97,7 @@ namespace CalamityMod.Items.Mounts
{
if (Main.myPlayer == player.whoAmI)
{
int highestPickPower = 35; //35% if you have no pickaxes.
for (int item = 0; item < Main.InventorySlotsTotal; item++)
{
if (player.inventory[item].pick <= 0)
continue;
if (player.inventory[item].pick > highestPickPower)
{
highestPickPower = player.inventory[item].pick;
}
}
int highestPickPower = player.GetBestPickPower();
float direction = Math.Sign(player.velocity.X);
if (Math.Abs(direction) < 0.1f)
@@ -145,60 +136,7 @@ namespace CalamityMod.Items.Mounts
float tileDist = tileVec.Length();
Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y);
int pickReq = 0;
ModTile moddedTile = TileLoader.GetTile(tile.TileType);
if (moddedTile != null)
{
pickReq = moddedTile.MinPick;
}
else
{
switch (tile.TileType)
{
case TileID.Chlorophyte:
pickReq = 200;
break;
case TileID.Ebonstone:
case TileID.Crimstone:
case TileID.Pearlstone:
case TileID.DesertFossil:
case TileID.Obsidian:
case TileID.Hellstone:
pickReq = 65;
break;
case TileID.Meteorite:
pickReq = 50;
break;
case TileID.Demonite:
case TileID.Crimtane:
if (y > Main.worldSurface)
pickReq = 55;
break;
case TileID.LihzahrdBrick:
case TileID.LihzahrdAltar:
pickReq = 210;
break;
case TileID.Cobalt:
case TileID.Palladium:
pickReq = 100;
break;
case TileID.Mythril:
case TileID.Orichalcum:
pickReq = 110;
break;
case TileID.Adamantite:
case TileID.Titanium:
pickReq = 150;
break;
default:
break;
}
}
if (Main.tileDungeon[tile.TileType])
{
if (x < Main.maxTilesX * 0.35 || x > Main.maxTilesX * 0.65)
pickReq = 65;
}
int pickReq = tile.GetRequiredPickPower(x, y);
if (tileDist < mineHeight)
{
Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 325 B

-44
View File
@@ -1,44 +0,0 @@
using CalamityMod.Items.Materials;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Tools
{
public class WulfrumAxe : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Wulfrum Axe");
}
public override void SetDefaults()
{
Item.damage = 5;
Item.knockBack = 4.5f;
Item.useTime = 15;
Item.useAnimation = 26;
Item.axe = 60 / 5;
Item.tileBoost += 1;
Item.DamageType = DamageClass.Melee;
Item.width = 30;
Item.height = 38;
Item.useTurn = true;
Item.useStyle = ItemUseStyleID.Swing;
Item.value = Item.buyPrice(0, 1, 0, 0);
Item.rare = ItemRarityID.Blue;
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<WulfrumShard>(14).
AddTile(TileID.Anvils).
Register();
}
}
}
Loaded 100 of 232 files, more files were not shown because too many files have changed in this diff. Show more