This commit is contained in:
mountaindrew10 committed 2022-03-16 08:48:14 -06:00
commit 52f352c6da
14 files changed
+286 -305

No files matched your search

+3
View File
@@ -133,6 +133,9 @@ namespace CalamityMod.CalPlayer
// Update the gem tech armor set.
GemTechState.Update();
// Armor set effects
VanillaArmorChangeManager.ApplyPotentialEffectsTo(player);
// Regularly sync player stats & mouse control info during multiplayer
if (player.whoAmI == Main.myPlayer && Main.netMode == NetmodeID.MultiplayerClient)
{
+1 -1
View File
@@ -764,7 +764,7 @@ namespace CalamityMod.DataStructures
{
id = AttunementID.Polaris;
name = "Polaris' Gaze"; //It carries the mark of the Northern Star
function_description = "Hold the attack button to channel the Northern Star's power into a tight vortex of galactic energies, bound by concentric rings of stars. The vortex powers up over time and when hitting enemies";
function_description = "Hold the attack button to channel the Northern Star's power into a tight vortex of galactic energies, bound by concentric rings of stars.\nThe vortex powers up over time and when hitting enemies";
function_description_extra = "Release the attack button to fire off the charged star. Attacking again immediately thereafter dashes to the star, emitting a nova of cosmic bolts";
tooltipColor = new Color(128, 189, 255);
tooltipColor2 = new Color(255, 128, 140);
Binary file not shown.
+1 -3
View File
@@ -1040,9 +1040,7 @@ namespace CalamityMod.Items
#region Equip Changes
public override void UpdateEquip(Item item, Player player)
{
VanillaArmorChangeManager.ApplyPotentialEffectsTo(player);
{
switch (item.type)
{
case ItemID.MagicHat:
+1 -1
View File
@@ -122,7 +122,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void NetRecieve(BinaryReader reader)
{
Charge = reader.ReadInt32();
Charge = reader.ReadSingle();
}
public override void AddRecipes()
+1 -1
View File
@@ -200,7 +200,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void NetRecieve(BinaryReader reader)
{
Charge = reader.ReadInt32();
Charge = reader.ReadSingle();
}
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
+1 -1
View File
@@ -193,7 +193,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void NetRecieve(BinaryReader reader)
{
Charge = reader.ReadInt32();
Charge = reader.ReadSingle();
}
public override void AddRecipes()
+45 -51
View File
@@ -56,59 +56,47 @@ namespace CalamityMod.Items.Weapons.Melee
Tooltip.SetDefault("FUNCTION_DESC\n" +
"Hold down RMB while standing still on flat ground to attune the weapon to the powers of the surrounding biome\n" +
"Using RMB otherwise switches between the current attunement and an extra stored one\n" +
"Main attunement : None\n" +
"Secondary attunement: None\n"); //Theres potential for flavor text as well but im not a writer
"Main Attunement : [None]\n" +
"Secondary Attunement: [None]\n"); //Theres potential for flavor text as well but im not a writer
}
public override void ModifyTooltips(List<TooltipLine> list)
{
SafeCheckAttunements();
Player player = Main.player[Main.myPlayer];
if (player is null)
return;
foreach (TooltipLine l in list)
var effectDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria");
var mainAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip3" && x.mod == "Terraria");
var secondaryAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip4" && x.mod == "Terraria");
//Default stuff
effectDescTooltip.text = "Does nothing..yet";
effectDescTooltip.overrideColor = new Color(163, 163, 163);
mainAttunementTooltip.text = "Main Attunement : [None]";
mainAttunementTooltip.overrideColor = new Color(163, 163, 163);
secondaryAttunementTooltip.text = "Secondary Attunement : [None]";
secondaryAttunementTooltip.overrideColor = new Color(163, 163, 163);
//If theres a main attunement
if (mainAttunement != null)
{
if (l.text.StartsWith("FUNCTION_DESC"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = mainAttunement.function_description;
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Does nothing.. yet";
}
}
effectDescTooltip.text = mainAttunement.function_description;
effectDescTooltip.overrideColor = mainAttunement.tooltipColor;
if (l.text.StartsWith("Main attunement"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = "Main Attumenent : [" + mainAttunement.name + "]";
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Main Attumenent : [None]";
}
}
mainAttunementTooltip.text = "Main Attumenent : [" + mainAttunement.name + "]";
mainAttunementTooltip.overrideColor = mainAttunement.tooltipColor;
}
if (l.text.StartsWith("Secondary attunement"))
{
if (secondaryAttunement != null)
{
l.overrideColor = Color.Lerp(secondaryAttunement.tooltipColor, Color.Gray, 0.5f);
l.text = "Secondary Attumenent : [" + secondaryAttunement.name + "]";
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Secondary Attumenent : [None]";
}
}
//If theres a secondary attunement
if (secondaryAttunement != null)
{
secondaryAttunementTooltip.text = "Secondary Attumenent : [" + secondaryAttunement.name + "]";
secondaryAttunementTooltip.overrideColor = Color.Lerp(secondaryAttunement.tooltipColor, Color.Gray, 0.5f);
}
}
@@ -203,6 +191,8 @@ namespace CalamityMod.Items.Weapons.Melee
if (mainAttunement == secondaryAttunement)
secondaryAttunement = null;
SafeCheckAttunements();
}
public override void NetSend(BinaryWriter writer)
@@ -213,10 +203,9 @@ namespace CalamityMod.Items.Weapons.Melee
public override void NetRecieve(BinaryReader reader)
{
mainAttunement = Attunement.attunementArray[reader.ReadByte()];
secondaryAttunement = Attunement.attunementArray[reader.ReadByte()];
mainAttunement = Attunement.attunementArray[reader.ReadInt32()];
secondaryAttunement = Attunement.attunementArray[reader.ReadInt32()];
}
#endregion
public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat)
@@ -227,6 +216,15 @@ namespace CalamityMod.Items.Weapons.Melee
mult += mainAttunement.DamageMultiplier - 1;
}
public void SafeCheckAttunements()
{
if (mainAttunement != null)
mainAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)mainAttunement.id, (float)AttunementID.Default, (float)AttunementID.Evil)];
if (secondaryAttunement != null)
secondaryAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)secondaryAttunement.id, (float)AttunementID.Default, (float)AttunementID.Evil)];
}
public override void HoldItem(Player player)
{
@@ -236,7 +234,6 @@ namespace CalamityMod.Items.Weapons.Melee
if (player.velocity.Y == 0) //Reset the lunge ability on ground contact
CanLunge = 1;
//Change the swords function based on its attunement
if (mainAttunement == null)
{
@@ -251,12 +248,7 @@ namespace CalamityMod.Items.Weapons.Melee
}
else
{
if (mainAttunement.id < AttunementID.Default || mainAttunement.id > AttunementID.Evil)
mainAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)mainAttunement.id, (float)AttunementID.Default, (float)AttunementID.Evil)];
mainAttunement.ApplyStats(item);
}
if (mainAttunement != null && mainAttunement.id != AttunementID.Cold)
Combo = 0;
@@ -276,6 +268,8 @@ namespace CalamityMod.Items.Weapons.Melee
public override void UpdateInventory(Player player)
{
SafeCheckAttunements();
if (mainAttunement != null && mainAttunement.id == AttunementID.Cold && CanUseItem(player))
ComboResetTimer -= 0.02f; //Make the combo counter get closer to being reset
+45 -89
View File
@@ -47,10 +47,10 @@ namespace CalamityMod.Items.Weapons.Melee
public static int PolarisAttunement_ShredIFrames = 10;
public static int PolarisAttunement_LocalIFrames = 30; //Be warned its got one extra update so all the iframes should be divided in 2
public static int PolarisAttunement_LocalIFramesCharged = 16;
public static float PolarisAttunement_SlashDamageBoost = 13f; //Keep in mind the slice always crits
public static float PolarisAttunement_SlashDamageBoost = 6f; //Keep in mind the slice always crits
public static int PolarisAttunement_SlashBoltsDamage = 1300;
public static int PolarisAttunement_SlashIFrames = 60;
public static float PolarisAttunement_ShotDamageBoost = 2f; //The shots fired if the dash connects
public static int PolarisAttunement_SlashIFrames = 20;
public static float PolarisAttunement_ShotDamageBoost = 0.8f; //The shots fired if the dash connects
public static float PolarisAttunement_ShredChargeupGain = 1.1f; //How much charge is gainted per second.
public static int AndromedaAttunement_BaseDamage = 2100;
@@ -59,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Melee
public static float AndromedaAttunement_MonolithDamageBoost = 1.75f;
public static float AndromedaAttunement_BoltsDamageReduction = 0.2f; //The shots fired as it charges
public static int AriesAttunement_BaseDamage = 1100;
public static int AriesAttunement_BaseDamage = 950;
public static int AriesAttunement_LocalIFrames = 10;
public static int AriesAttunement_Reach = 600;
public static float AriesAttunement_ChainDamageReduction = 0.2f;
@@ -79,7 +79,6 @@ namespace CalamityMod.Items.Weapons.Melee
{
DisplayName.SetDefault("Galaxia");
Tooltip.SetDefault("FUNCTION_DESC\n" +
"FUNCTION_EXTRA\n" +
"FUNCTION_PASSIVE\n" +
"Upgrading the sword let it break free from its earthly boundaries. You now have access to every single attunement at all times!\n" +
"Use RMB to cycle the sword's attunement forward or backwards depending on the position of your cursor\n" +
@@ -91,90 +90,37 @@ namespace CalamityMod.Items.Weapons.Melee
public override void ModifyTooltips(List<TooltipLine> list)
{
SafeCheckAttunements();
Player player = Main.player[Main.myPlayer];
if (player is null)
return;
foreach (TooltipLine l in list)
var effectDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria");
var passiveDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip1" && x.mod == "Terraria");
var mainAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip4" && x.mod == "Terraria");
var blessingTooltip = list.FirstOrDefault(x => x.Name == "Tooltip5" && x.mod == "Terraria");
//Default stuff gets skipped here. MainAttunement is set to true in SafeCheckAttunements() above
//.. but just in case
if (mainAttunement == null)
{
if (l.text == null)
continue;
if (l.text.StartsWith("FUNCTION_DESC"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = mainAttunement.function_description;
}
else //Fake the existence of a main attunement
{
l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipColor;
l.text = Attunement.attunementArray[(int)AttunementID.Phoenix].function_description;
}
continue;
}
if (l.text.StartsWith("FUNCTION_EXTRA"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = mainAttunement.function_description_extra;
}
else
{
l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipColor;
l.text = Attunement.attunementArray[(int)AttunementID.Phoenix].function_description_extra;
}
continue;
}
if (l.text.StartsWith("FUNCTION_PASSIVE"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipPassiveColor;
l.text = mainAttunement.passive_description;
}
else
{
l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipPassiveColor;
l.text = Attunement.attunementArray[(int)AttunementID.Phoenix].passive_description;
}
continue;
}
if (l.text.StartsWith("Active Attunement"))
{
if (mainAttunement != null)
{
l.overrideColor = Color.Lerp(mainAttunement.tooltipColor, mainAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f);
l.text = "Active Attumenent : [" + mainAttunement.name + "]";
}
else
{
l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipColor;
l.text = "Active Attumenent : [" + Attunement.attunementArray[(int)AttunementID.Phoenix].name + "]";
}
continue;
}
if (l.text.StartsWith("Passive Blessing"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipPassiveColor;
l.text = "Passive Blessing : [" + mainAttunement.passive_name + "]";
}
else
{
l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipPassiveColor;
l.text = "Passive Blessing : ["+ Attunement.attunementArray[(int)AttunementID.Phoenix].passive_name + "]";
}
continue;
}
CalamityMod.Instance.Logger.Error("No main attunement on galaxia, couldn't edit its tooltip properly. How the hell did that happen.");
return;
}
effectDescTooltip.text = mainAttunement.function_description + "\n" + mainAttunement.function_description_extra;
effectDescTooltip.overrideColor = mainAttunement.tooltipColor;
passiveDescTooltip.text = mainAttunement.passive_description;
passiveDescTooltip.overrideColor = mainAttunement.tooltipPassiveColor;
mainAttunementTooltip.text = "Active Attumenent : [" + mainAttunement.name + "]";
mainAttunementTooltip.overrideColor = Color.Lerp(mainAttunement.tooltipColor, mainAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f);
blessingTooltip.text = "Passive Blessing : [" + mainAttunement.passive_name + "]";
blessingTooltip.overrideColor = mainAttunement.tooltipPassiveColor;
}
#endregion
@@ -253,7 +199,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void NetRecieve(BinaryReader reader)
{
mainAttunement = Attunement.attunementArray[reader.ReadByte()];
mainAttunement = Attunement.attunementArray[reader.ReadInt32()];
}
#endregion
@@ -273,6 +219,15 @@ namespace CalamityMod.Items.Weapons.Melee
mult += mainAttunement.DamageMultiplier - 1;
}
public void SafeCheckAttunements()
{
if (mainAttunement == null)
mainAttunement = Attunement.attunementArray[(int)AttunementID.Phoenix];
else
mainAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)mainAttunement.id, (float)AttunementID.Phoenix, (float)AttunementID.Andromeda)];
}
public override void HoldItem(Player player)
{
player.Calamity().rightClickListener = true;
@@ -287,11 +242,7 @@ namespace CalamityMod.Items.Weapons.Melee
UseTimer++;
}
if (mainAttunement == null)
mainAttunement = Attunement.attunementArray[(int)AttunementID.Phoenix];
//Clamp the attunement to only be part of the 4 galaxia attunements
else if (mainAttunement.id < AttunementID.Phoenix)
mainAttunement = Attunement.attunementArray[(int)AttunementID.Phoenix];
SafeCheckAttunements();
mainAttunement.ApplyStats(item);
@@ -311,6 +262,11 @@ namespace CalamityMod.Items.Weapons.Melee
}
}
public override void UpdateInventory(Player player)
{
SafeCheckAttunements();
}
public override bool CanUseItem(Player player)
{
return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI &&
+55 -85
View File
@@ -97,100 +97,59 @@ namespace CalamityMod.Items.Weapons.Melee
{
DisplayName.SetDefault("True Biome Blade");
Tooltip.SetDefault("FUNCTION_DESC\n" +
"FUNCTION_EXTRA\n" +
"FUNCTION_PASSIVE\n" +
"Holding down RMB for 2 seconds attunes the weapon to the powers of the surrounding biome\n" +
"Using RMB for a shorter period of time switches your active and passive attunements around\n" +
"Active attunement : None\n" +
"Passive attunement: None\n");
"Active Attunement : None\n" +
"Passive Attunement: None\n");
}
#region tooltip editing
public override void ModifyTooltips(List<TooltipLine> list)
{
SafeCheckAttunements();
Player player = Main.player[Main.myPlayer];
if (player is null)
return;
foreach (TooltipLine l in list)
var effectDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria");
var passiveDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip1" && x.mod == "Terraria");
var mainAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip4" && x.mod == "Terraria");
var secondaryAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip5" && x.mod == "Terraria");
//Default stuff
effectDescTooltip.text = "Does nothing..yet\nIt seems that upgrading the blade expanded the scope of the previous attunements";
effectDescTooltip.overrideColor = new Color(163, 163, 163);
passiveDescTooltip.text = "Your secondary attunement can now provide passive bonuses";
passiveDescTooltip.overrideColor = new Color(163, 163, 163);
mainAttunementTooltip.text = "Active Attumenent : [None]";
mainAttunementTooltip.overrideColor = new Color(163, 163, 163);
secondaryAttunementTooltip.text = "Passive Attunement : [None]";
secondaryAttunementTooltip.overrideColor = new Color(163, 163, 163);
//If theres a main attunement
if (mainAttunement != null)
{
if (l.text == null)
continue;
effectDescTooltip.text = mainAttunement.function_description + "\n" + mainAttunement.function_description_extra;
effectDescTooltip.overrideColor = mainAttunement.tooltipColor;
if (l.text.StartsWith("FUNCTION_DESC"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = mainAttunement.function_description;
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Does nothing.. yet";
}
continue;
}
mainAttunementTooltip.text = "Active Attumenent : [" + mainAttunement.name + "]";
mainAttunementTooltip.overrideColor = Color.Lerp(mainAttunement.tooltipColor, mainAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f);
}
if (l.text.StartsWith("FUNCTION_EXTRA"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = mainAttunement.function_description_extra;
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "It seems that upgrading the blade expanded the scope of the previous attunements";
}
continue;
}
//If theres a secondary attunement
if (secondaryAttunement != null)
{
passiveDescTooltip.text = secondaryAttunement.passive_description;
passiveDescTooltip.overrideColor = secondaryAttunement.tooltipColor;
if (l.text.StartsWith("FUNCTION_PASSIVE"))
{
if (secondaryAttunement != null)
{
l.overrideColor = secondaryAttunement.tooltipColor;
l.text = secondaryAttunement.passive_description;
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Your secondary attunement can now provide passive bonuses";
}
continue;
}
if (l.text.StartsWith("Active attunement"))
{
if (mainAttunement != null)
{
l.overrideColor = Color.Lerp(mainAttunement.tooltipColor, mainAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f);
l.text = "Active Attumenent : [" + mainAttunement.name + "]";
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Active Attumenent : [None]";
}
continue;
}
if (l.text.StartsWith("Passive attunement"))
{
if (secondaryAttunement != null)
{
l.overrideColor = Color.Lerp(Color.Lerp(secondaryAttunement.tooltipColor, secondaryAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f), Color.Gray, 0.5f);
l.text = "Passive Attumenent : [" + secondaryAttunement.name + "]";
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Passive Attumenent : [None]";
}
continue;
}
secondaryAttunementTooltip.text = "Passive Attumenent : [" + secondaryAttunement.name + "]";
secondaryAttunementTooltip.overrideColor = Color.Lerp(Color.Lerp(secondaryAttunement.tooltipColor, secondaryAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f), Color.Gray, 0.5f);
}
}
@@ -271,6 +230,8 @@ namespace CalamityMod.Items.Weapons.Melee
if (mainAttunement == secondaryAttunement)
secondaryAttunement = null;
SafeCheckAttunements();
}
public override void NetSend(BinaryWriter writer)
@@ -281,8 +242,8 @@ namespace CalamityMod.Items.Weapons.Melee
public override void NetRecieve(BinaryReader reader)
{
mainAttunement = Attunement.attunementArray[reader.ReadByte()];
secondaryAttunement = Attunement.attunementArray[reader.ReadByte()];
mainAttunement = Attunement.attunementArray[reader.ReadInt32()];
secondaryAttunement = Attunement.attunementArray[reader.ReadInt32()];
}
#endregion
@@ -295,6 +256,15 @@ namespace CalamityMod.Items.Weapons.Melee
mult += mainAttunement.DamageMultiplier - 1;
}
public void SafeCheckAttunements()
{
if (mainAttunement != null)
mainAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)mainAttunement.id, (float)AttunementID.Whirlwind, (float)AttunementID.Shockwave)];
if (secondaryAttunement != null)
secondaryAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)secondaryAttunement.id, (float)AttunementID.Whirlwind, (float)AttunementID.Shockwave)];
}
public override void HoldItem(Player player)
{
player.Calamity().rightClickListener = true;
@@ -323,12 +293,7 @@ namespace CalamityMod.Items.Weapons.Melee
}
else
{
if (mainAttunement.id < AttunementID.Whirlwind || mainAttunement.id > AttunementID.Shockwave)
mainAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)mainAttunement.id, (float)AttunementID.Whirlwind, (float)AttunementID.Shockwave)];
mainAttunement.ApplyStats(item);
}
if (player.whoAmI != Main.myPlayer)
@@ -360,6 +325,11 @@ namespace CalamityMod.Items.Weapons.Melee
}
}
public override void UpdateInventory(Player player)
{
SafeCheckAttunements();
}
public override bool CanUseItem(Player player)
{
return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI &&
+1 -1
View File
@@ -155,7 +155,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void NetRecieve(BinaryReader reader)
{
Charge = reader.ReadInt32();
Charge = reader.ReadSingle();
}
public override void AddRecipes()
+45 -64
View File
@@ -80,81 +80,53 @@ namespace CalamityMod.Items.Weapons.Melee
{
DisplayName.SetDefault("Biome Blade");
Tooltip.SetDefault("FUNCTION_DESC\n" +
"FUNCTION_EXTRA\n" +
"Hold down RMB while standing still on flat ground to attune the weapon to the powers of the surrounding biome\n" +
"Using RMB otherwise switches between the current attunement and an extra stored one\n" +
"Main attunement : None\n" +
"Secondary attunement: None\n"); //Theres potential for flavor text as well but im not a writer
"Main Attunement : [None]\n" +
"Secondary Attunement: [None]\n"); //Theres potential for flavor text as well but im not a writer
}
#region tooltip editing
public override void ModifyTooltips(List<TooltipLine> list)
{
SafeCheckAttunements();
Player player = Main.player[Main.myPlayer];
if (player is null)
return;
foreach (TooltipLine l in list)
var effectDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria");
var mainAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip3" && x.mod == "Terraria");
var secondaryAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip4" && x.mod == "Terraria");
//Default stuff
effectDescTooltip.text = "Does nothing..yet\nRepairing the blade seems to have improved its attuning capacities";
effectDescTooltip.overrideColor = new Color(163, 163, 163);
mainAttunementTooltip.text = "Main Attunement : [None]";
mainAttunementTooltip.overrideColor = new Color(163, 163, 163);
secondaryAttunementTooltip.text = "Secondary Attunement : [None]";
secondaryAttunementTooltip.overrideColor = new Color(163, 163, 163);
//If theres a main attunement
if (mainAttunement != null)
{
if (l.text.StartsWith("FUNCTION_DESC"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = mainAttunement.function_description;
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Does nothing.. yet";
}
}
effectDescTooltip.text = mainAttunement.function_description + "\n" + mainAttunement.function_description_extra ;
effectDescTooltip.overrideColor = mainAttunement.tooltipColor;
if (l.text.StartsWith("FUNCTION_EXTRA"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = mainAttunement.function_description_extra;
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Repairing the blade seems to have improved its attuning capacities";
}
}
mainAttunementTooltip.text = "Main Attumenent : [" + mainAttunement.name + "]";
mainAttunementTooltip.overrideColor = mainAttunement.tooltipColor;
}
if (l.text.StartsWith("Main attunement"))
{
if (mainAttunement != null)
{
l.overrideColor = mainAttunement.tooltipColor;
l.text = "Main Attumenent : [" + mainAttunement.name + "]";
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Main Attumenent : [None]";
}
}
if (l.text.StartsWith("Secondary attunement"))
{
if (secondaryAttunement != null)
{
l.overrideColor = Color.Lerp(secondaryAttunement.tooltipColor, Color.Gray, 0.5f);
l.text = "Secondary Attumenent : [" + secondaryAttunement.name + "]";
}
else
{
l.overrideColor = new Color(163, 163, 163);
l.text = "Secondary Attumenent : [None]";
}
}
//If theres a secondary attunement
if (secondaryAttunement != null)
{
secondaryAttunementTooltip.text = "Secondary Attumenent : [" + secondaryAttunement.name + "]";
secondaryAttunementTooltip.overrideColor = Color.Lerp(secondaryAttunement.tooltipColor, Color.Gray, 0.5f);
}
}
#endregion
public override void SetDefaults()
@@ -234,6 +206,8 @@ namespace CalamityMod.Items.Weapons.Melee
if (mainAttunement == secondaryAttunement)
secondaryAttunement = null;
SafeCheckAttunements();
}
public override void NetSend(BinaryWriter writer)
@@ -244,8 +218,8 @@ namespace CalamityMod.Items.Weapons.Melee
public override void NetRecieve(BinaryReader reader)
{
mainAttunement = Attunement.attunementArray[reader.ReadByte()];
secondaryAttunement = Attunement.attunementArray[reader.ReadByte()];
mainAttunement = Attunement.attunementArray[reader.ReadInt32()];
secondaryAttunement = Attunement.attunementArray[reader.ReadInt32()];
}
#endregion
@@ -258,6 +232,15 @@ namespace CalamityMod.Items.Weapons.Melee
mult += mainAttunement.DamageMultiplier - 1;
}
public void SafeCheckAttunements()
{
if (mainAttunement != null)
mainAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)mainAttunement.id, (float)AttunementID.TrueDefault, (float)AttunementID.Marine)];
if (secondaryAttunement != null)
secondaryAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)secondaryAttunement.id, (float)AttunementID.TrueDefault, (float)AttunementID.Marine)];
}
public override void HoldItem(Player player)
{
player.Calamity().rightClickListener = true;
@@ -286,11 +269,7 @@ namespace CalamityMod.Items.Weapons.Melee
}
else
{
if (mainAttunement.id < AttunementID.TrueDefault || mainAttunement.id > AttunementID.Marine)
mainAttunement = Attunement.attunementArray[(int)MathHelper.Clamp((float)mainAttunement.id, (float)AttunementID.TrueDefault, (float)AttunementID.Marine)];
mainAttunement.ApplyStats(item);
}
if (mainAttunement != null && mainAttunement.id != AttunementID.TrueCold && mainAttunement.id != AttunementID.TrueTropical)
Combo = 0;
@@ -309,6 +288,8 @@ namespace CalamityMod.Items.Weapons.Melee
public override void UpdateInventory(Player player)
{
SafeCheckAttunements();
if (mainAttunement != null && mainAttunement.id == AttunementID.TrueCold && CanUseItem(player))
ComboResetTimer -= 0.02f; //Make the combo counter get closer to being reset
+10 -8
View File
@@ -29,20 +29,16 @@ namespace CalamityMod.Projectiles.Ranged
}
public override string Texture => "CalamityMod/Projectiles/Ranged/PumplerGrenade";
private void Explode()
private void Explode(bool NPCHit = false)
{
Main.PlaySound(SoundID.Item14, projectile.Center);
if (Main.myPlayer == projectile.owner)
{
for (int i = 0; i < 15; i++)
{
Particle smoke = new SmallSmokeParticle(projectile.Center + Main.rand.NextVector2Circular(15f, 15f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.8f, 1.6f), 145 - Main.rand.Next(30));
smoke.Velocity = (smoke.Position - projectile.Center) * 0.2f + projectile.velocity;
GeneralParticleHandler.SpawnParticle(smoke);
}
Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<PumplerGrenadeExplosion>(), (int)(projectile.damage), projectile.knockBack, projectile.owner, NPCHit ? 1 : 0);
}
projectile.Kill();
}
public override void AI()
{
if (projectile.timeLeft == 1)
@@ -71,7 +67,13 @@ namespace CalamityMod.Projectiles.Ranged
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
Main.PlaySound(SoundID.Item14, projectile.Center);
Explode();
Explode(true);
}
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
//Damage gets lowered for the main hit, most of the damage comes from the explosion itself.
damage = (int)(damage * 0.1f);
}
}
}
@@ -0,0 +1,77 @@
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using CalamityMod.Dusts;
using CalamityMod.Particles;
namespace CalamityMod.Projectiles.Ranged
{
public class PumplerGrenadeExplosion : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
private bool NPCHit => projectile.ai[0] == 1;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Cucurbitace Blast");
}
public override void SetDefaults()
{
projectile.width = 70;
projectile.height = 70;
projectile.friendly = true;
projectile.timeLeft = 5;
projectile.penetrate = -1;
projectile.ranged = true;
projectile.ignoreWater = true;
}
private void SmokeBoom()
{
for (int i = 0; i < 15; i++)
{
Particle smoke = new SmallSmokeParticle(projectile.Center + Main.rand.NextVector2Circular(15f, 15f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.8f, 1.6f), 145 - Main.rand.Next(30));
smoke.Velocity = (smoke.Position - projectile.Center) * 0.2f + projectile.velocity;
GeneralParticleHandler.SpawnParticle(smoke);
}
}
public override bool? CanHitNPC(NPC target)
{
float blastRadius = projectile.height / 2f;
//Get the absolute value of the distance between the target's hitbox center & the explosion's center
float distanceX = Math.Abs(projectile.Center.X - target.Hitbox.Center.X);
float distanceY = Math.Abs(projectile.Center.Y - target.Hitbox.Center.Y);
//If the distance is just too big for the two to intersect, return false
if (distanceX > (target.Hitbox.Width / 2f + blastRadius) || distanceY > (target.Hitbox.Height / 2f + blastRadius))
return false;
//If either distance is too small (aka if the projectile's center is inside of the target's hitbox, return true
if (distanceX <= (target.Hitbox.Width / 2f) || distanceY <= (target.Hitbox.Height / 2f))
return true;
//Pythagorean theorem stuff to determine the litteral edge cases
float squaredCornerDisance = (float)(Math.Pow(distanceX - target.Hitbox.Width / 2f, 2) + Math.Pow(distanceY - target.Hitbox.Height / 2f, 2));
return (squaredCornerDisance <= Math.Pow(blastRadius, 2));
}
public override void AI()
{
//Bigger explosion if no npc gets hit
if (!NPCHit)
{
projectile.width = 120;
projectile.height = 120;
}
if (projectile.timeLeft == 5)
SmokeBoom();
}
}
}